Example #1
0
        private async void btnGetEWBDetails_Click(object sender, EventArgs e)
        {
            string EwbNo = "391000800056";
            TxnRespWithObj <RespGetEWBDetail> TxnResp = await EWBAPI.GetEWBDetailAsync(EwbSession, EwbNo);

            if (TxnResp.IsSuccess)
            {
                rtbResponce.Text = JsonConvert.SerializeObject(TxnResp.RespObj);
            }
            else
            {
                rtbResponce.Text = TxnResp.TxnOutcome;
            }
        }
        private async void PrintewayBill()
        {
            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 Print Auth");
                    CheckEwayBalance(false);
                }
                else
                {
                    lblResponce.Text = TxnSesResp.TxnOutcome;
                    CheckEwayBalance(false);
                    return;
                }
            }


            string rtbResponce = "";
            TxnRespWithObj <RespGetEWBDetail> TxnResp = await EWBAPI.GetEWBDetailAsync(EwbSession, EwbNo);

            if (TxnResp.IsSuccess == true)
            {
                UpdateEwayBalance(-1, "On Print Detail");
                EWBAPI.PrintEWB(EwbSession, TxnResp.RespObj, "", true, true);
                UpdateEwayBalance(-1, "On Print");
            }
            else
            {
                rtbResponce = TxnResp.TxnOutcome;
                UpdateEwayBalance(-1, TxnResp.TxnOutcome);
            }

            CheckEwayBalance(false);
        }