private async void OnlineewayBill()
        {
            //GetAuthenticationToken();

            string strJSON = "";

            if (DateTime.Now < EwbSession.EwbApiLoginDetails.EwbTokenExp)
            {
                lblResponce.Text = EwbSession.EwbApiLoginDetails.EwbAuthToken + "valid Upto:" + EwbSession.EwbApiLoginDetails.EwbTokenExp.ToString();
            }
            else
            {
                TxnRespWithObj <EWBSession> TxnSesResp = await EWBAPI.GetAuthTokenAsync(EwbSession);

                if (TxnSesResp.IsSuccess == true)
                {
                    lblResponce.Text = TxnSesResp.RespObj.EwbApiLoginDetails.EwbAuthToken;
                    strJSON          = JsonConvert.SerializeObject(TxnSesResp.RespObj.EwbApiLoginDetails);
                    Database.CommandExecutor("Update Company set EwbLoginDetail='" + strJSON + "'");
                    UpdateEwayBalance(-1, "On Generate Eway Auth");
                    CheckEwayBalance(false);
                }
                else
                {
                    lblResponce.Text = TxnSesResp.TxnOutcome;
                    UpdateEwayBalance(-1, TxnSesResp.TxnOutcome);
                    CheckEwayBalance(false);
                    return;
                }
            }



            strJSON = JsonConvert.SerializeObject(ewbGen);
            //  System.IO.File.WriteAllText(Applidispcation.StartupPath + "\\EWAYJSON.txt", strJSON);

            //strJSON = System.IO.File.ReadAllText(Application.StartupPath + "\\EWAYJSON.txt");

            if (DateTime.Now > EwbSession.EwbApiLoginDetails.EwbTokenExp)
            {
                return;
            }


            TxnRespWithObj <RespGenEwbPl> TxnResp = await EWBAPI.GenEWBAsync(EwbSession, strJSON);

            if (TxnResp.IsSuccess)
            {
                lblResponce.Text = JsonConvert.SerializeObject(TxnResp.RespObj);
                Database.CommandExecutor("Update voucherinfo set EwayBillno='" + TxnResp.RespObj.ewayBillNo + "' where vi_id='" + gvid + "'");
                EwbNo = long.Parse(TxnResp.RespObj.ewayBillNo);

                UpdateEwayBalance(-1, TxnResp.RespObj.ewayBillNo);
            }
            else
            {
                lblResponce.Text = lblResponce.Text + Environment.NewLine + TxnResp.TxnOutcome;
                UpdateEwayBalance(-1, TxnResp.TxnOutcome);
            }

            CheckEwayBalance(false);
            SideFill();
        }
Example #2
0
        private async void btnGenEWB_Click(object sender, EventArgs e)
        {
            ReqGenEwbPl ewbGen = new ReqGenEwbPl();

            ewbGen.supplyType      = "O";
            ewbGen.subSupplyType   = "1";
            ewbGen.docType         = "INV";
            ewbGen.docNo           = "123-8";
            ewbGen.docDate         = "15/12/2017";
            ewbGen.fromGstin       = "08AAQPS7478C1Z1";
            ewbGen.fromTrdName     = "welton";
            ewbGen.fromAddr1       = "2ND CROSS NO 59  19  A";
            ewbGen.fromAddr2       = "GROUND FLOOR OSBORNE ROAD";
            ewbGen.fromPlace       = "FRAZER TOWN";
            ewbGen.fromPincode     = 560042;
            ewbGen.fromStateCode   = 29;
            ewbGen.toGstin         = "05ABZPP6384Q1ZB";
            ewbGen.toTrdName       = "sthuthya";
            ewbGen.toAddr1         = "Shree Nilaya";
            ewbGen.toAddr2         = "Dasarahosahalli";
            ewbGen.toPlace         = "Beml Nagar";
            ewbGen.toPincode       = 689788;
            ewbGen.toStateCode     = 28;
            ewbGen.totalValue      = 5609889;
            ewbGen.cgstValue       = 0;
            ewbGen.sgstValue       = 0;
            ewbGen.igstValue       = 168296.67;
            ewbGen.cessValue       = 224395.56;
            ewbGen.transporterId   = "";
            ewbGen.transporterName = "";
            ewbGen.transDocNo      = "";
            ewbGen.transMode       = "1";
            ewbGen.transDistance   = "656";
            ewbGen.transDocDate    = "";
            ewbGen.vehicleNo       = "PVC1234";
            ewbGen.vehicleType     = "R";
            ewbGen.itemList        = new List <ReqGenEwbPl.ItemList>();
            ewbGen.itemList.Add(new ReqGenEwbPl.ItemList
            {
                productName   = "Wheat",
                productDesc   = "Wheat",
                hsnCode       = 1001,
                quantity      = 4,
                qtyUnit       = "BOX",
                cgstRate      = 0,
                sgstRate      = 0,
                igstRate      = 3,
                cessRate      = 4,
                cessAdvol     = 0,
                taxableAmount = 5609889
            });

            TxnRespWithObj <RespGenEwbPl> TxnResp = await EWBAPI.GenEWBAsync(EwbSession, ewbGen);

            if (TxnResp.IsSuccess)
            {
                rtbResponce.Text = JsonConvert.SerializeObject(TxnResp.RespObj);
            }
            else
            {
                rtbResponce.Text = TxnResp.TxnOutcome;
            }
        }