private void loadLCDoc(BEXPORT_LC_DOCS_PROCESSING ExLCDoc)
 {
     if (ExLCDoc == null) return;
     //
     txtBeneficiaryNumber.Text = ExLCDoc.BeneficiaryNo;
     txtBeneficiaryName.Text = ExLCDoc.BeneficiaryName;
     txtBeneficiaryAddr1.Text = ExLCDoc.BeneficiaryAddr1;
     txtBeneficiaryAddr2.Text = ExLCDoc.BeneficiaryAddr2;
     txtBeneficiaryAddr3.Text = ExLCDoc.BeneficiaryAddr3;
     //
     txtApplicantName.Text = ExLCDoc.ApplicantName;
     txtApplicantAddr1.Text = ExLCDoc.ApplicantAddr1;
     txtApplicantAddr2.Text = ExLCDoc.ApplicantAddr2;
     txtApplicantAddr3.Text = ExLCDoc.ApplicantAddr3;
     //
     txtIssuingBankNo.Text = ExLCDoc.IssuingBankNo;
     txtIssuingBankName.Text = ExLCDoc.IssuingBankName;
     txtIssuingBankAddr1.Text = ExLCDoc.IssuingBankAddr1;
     txtIssuingBankAddr2.Text = ExLCDoc.IssuingBankAddr2;
     txtIssuingBankAddr3.Text = ExLCDoc.IssuingBankAddr3;
     //
     txtNostroAgentBankNo.Text = ExLCDoc.NostroAgentBankNo;
     txtNostroAgentBankName.Text = ExLCDoc.NostroAgentBankName;
     txtNostroAgentBankAddr1.Text = ExLCDoc.NostroAgentBankAddr1;
     txtNostroAgentBankAddr2.Text = ExLCDoc.NostroAgentBankAddr2;
     txtNostroAgentBankAddr3.Text = ExLCDoc.NostroAgentBankAddr3;
     //
     txtReceivingBankName.Text = ExLCDoc.ReceivingBankName;
     txtReceivingBankAddr1.Text = ExLCDoc.ReceivingBankAddr1;
     txtReceivingBankAddr2.Text = ExLCDoc.ReceivingBankAddr2;
     txtReceivingBankAddr3.Text = ExLCDoc.ReceivingBankAddr3;
     //
     txtDocumentaryCreditNo.Text = ExLCDoc.DocumentaryCreditNo;
     rcbCurrency.SelectedValue = ExLCDoc.Currency;
     txtInvoiceNo.Text = ExLCDoc.InvoiceNo;
 }
        private void loadLCDoc(BEXPORT_LC_DOCS_PROCESSING ExLCDoc)
        {
            if (TabId == ExportLCDocProcessing.Actions.Accept)
            {
            }
            if (TabId == ExportLCDocProcessing.Actions.Reject)
            {
            }
            txtBeneficiaryNumber.Text = ExLCDoc.BeneficiaryNo;
            txtBeneficiaryName.Text = ExLCDoc.BeneficiaryName;
            txtBeneficiaryAddr1.Text = ExLCDoc.BeneficiaryAddr1;
            txtBeneficiaryAddr2.Text = ExLCDoc.BeneficiaryAddr2;
            txtBeneficiaryAddr3.Text = ExLCDoc.BeneficiaryAddr3;
            //
            txtApplicantName.Text = ExLCDoc.ApplicantName;
            txtApplicantAddr1.Text = ExLCDoc.ApplicantAddr1;
            txtApplicantAddr2.Text = ExLCDoc.ApplicantAddr2;
            txtApplicantAddr3.Text = ExLCDoc.ApplicantAddr3;
            //
            txtIssuingBankNo.Text = ExLCDoc.IssuingBankNo;
            txtIssuingBankName.Text = ExLCDoc.IssuingBankName;
            txtIssuingBankAddr1.Text = ExLCDoc.IssuingBankAddr1;
            txtIssuingBankAddr2.Text = ExLCDoc.IssuingBankAddr2;
            txtIssuingBankAddr3.Text = ExLCDoc.IssuingBankAddr3;
            //
            txtNostroAgentBankNo.Text = ExLCDoc.NostroAgentBankNo;
            txtNostroAgentBankName.Text = ExLCDoc.NostroAgentBankName;
            txtNostroAgentBankAddr1.Text = ExLCDoc.NostroAgentBankAddr1;
            txtNostroAgentBankAddr2.Text = ExLCDoc.NostroAgentBankAddr2;
            txtNostroAgentBankAddr3.Text = ExLCDoc.NostroAgentBankAddr3;
            //
            txtReceivingBankName.Text = ExLCDoc.ReceivingBankName;
            txtReceivingBankAddr1.Text = ExLCDoc.ReceivingBankAddr1;
            txtReceivingBankAddr2.Text = ExLCDoc.ReceivingBankAddr2;
            txtReceivingBankAddr3.Text = ExLCDoc.ReceivingBankAddr3;
            //
            txtDocumentaryCreditNo.Text = ExLCDoc.DocumentaryCreditNo;
            txtCommodity.Value = ExLCDoc.Commodity;
            txtCommodityName.Text = getCommodityName(ExLCDoc.Commodity);
            rcbCurrency.SelectedValue = ExLCDoc.Currency;
            if (TabId == ExportLCDocProcessing.Actions.Amend)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["lst"]) && Request.QueryString["lst"].Equals("4appr"))
                {
                    var ExLCDocOld = dbEntities.findExportLCDoc(ExLCDoc.AmendNoOriginal, true);
                    txtOriginalAmount.Value = ExLCDocOld.Amount;
                    txtNewAmount.Value = ExLCDoc.Amount;
                    //
                    txtOriginalTenor.Text = ExLCDocOld.Tenor;
                    rcbNewTenor.SelectedValue = ExLCDoc.Tenor;
                }
                else
                {
                    if (ExLCDoc.Amount != 0)
                    {
                        txtOriginalAmount.Value = ExLCDoc.Amount;
                    }
                    else
                    {
                        string docCode = tbLCCode.Text.Trim();
                        docCode = docCode.Split('.')[0];
                        if (null != ExLCDoc.AmendNoOriginal)
                        {
                            docCode = ExLCDoc.AmendNoOriginal;
                        }
                        var ExLCDocOld = dbEntities.findExportLCDoc(docCode);

                        txtOriginalAmount.Value = ExLCDocOld.Amount;
                    }
                    txtOriginalTenor.Text = ExLCDoc.Tenor;
                    txtNewAmount.Value = ExLCDoc.Amount;
                }
            }
            else
            {
                txtAmount.Value = ExLCDoc.Amount;
                txtTenor.Text = ExLCDoc.Tenor;
            }
            txtDocumentReceivedDate.SelectedDate = ExLCDoc.DocumentReceivedDate;
            txtProccessingDate.SelectedDate = ExLCDoc.ProccessingDate;
            txtAcceptanceDate.SelectedDate = ExLCDoc.AcceptanceDate;
            txtMaturityDate.SelectedDate = ExLCDoc.MaturityDate;
            txtInvoiceNo.Text = ExLCDoc.InvoiceNo;
            //
            loadLCDocsCode(ExLCDoc.DocsCode1, ExLCDoc.NoOfOriginals1, ExLCDoc.NoOfCopies1, ExLCDoc.OtherDocs1, ref rcbDocsCode1, ref txtNoOfOriginals1, ref txtNoOfCopies1);
            loadLCDocsCode(ExLCDoc.DocsCode2, ExLCDoc.NoOfOriginals2, ExLCDoc.NoOfCopies2, ExLCDoc.OtherDocs2, ref rcbDocsCode2, ref txtNoOfOriginals2, ref txtNoOfCopies2);
            loadLCDocsCode(ExLCDoc.DocsCode3, ExLCDoc.NoOfOriginals3, ExLCDoc.NoOfCopies3, ExLCDoc.OtherDocs3, ref rcbDocsCode3, ref txtNoOfOriginals3, ref txtNoOfCopies3);

            if (null != ExLCDoc.AcceptDate)
                txtAcceptDate.SelectedDate = Convert.ToDateTime(ExLCDoc.AcceptDate);
            txtAcceptRemarks.Text = ExLCDoc.AcceptRemarks;

            txtOtherDocs1.Text = ExLCDoc.OtherDocs1;
            txtOtherDocs2.Text = ExLCDoc.OtherDocs2;
            txtOtherDocs3.Text = ExLCDoc.OtherDocs3;
            txtOtherDocs4.Text = ExLCDoc.OtherDocs4;
            txtOtherDocs5.Text = ExLCDoc.OtherDocs5;
            txtOtherDocs6.Text = ExLCDoc.OtherDocs6;
            txtOtherDocs7.Text = ExLCDoc.OtherDocs7;
            txtOtherDocs8.Text = ExLCDoc.OtherDocs8;
            txtOtherDocs9.Text = ExLCDoc.OtherDocs9;
            txtOtherDocs10.Text = ExLCDoc.OtherDocs10;

            if (!string.IsNullOrEmpty(ExLCDoc.DocsCode3))
            {
                divDocs2.Attributes.CssStyle.Remove("Display");
                divDocs3.Attributes.CssStyle.Remove("Display");
            }
            else if (!string.IsNullOrEmpty(ExLCDoc.DocsCode2))
                divDocs2.Attributes.CssStyle.Remove("Display");
            //
            txtRemark.Text = ExLCDoc.Remark;
            txtSettlementInstruction.Text = ExLCDoc.SettlementInstruction;
            //
            rcbWaiveCharges.SelectedValue = ExLCDoc.WaiveCharges;
            rcbWaiveCharges_OnSelectedIndexChanged(null, null);
            txtChargeRemarks.Text = ExLCDoc.ChargeRemarks;
            txtVATNo.Text = ExLCDoc.VATNo;
            if (ExLCDoc.WaiveCharges.Equals(bd.YesNo.NO)) loadCharges();
        }
        private void saveLCDoc(ref BEXPORT_LC_DOCS_PROCESSING ExLCDoc)
        {
            ExLCDoc.BeneficiaryNo = txtBeneficiaryNumber.Text;
            ExLCDoc.BeneficiaryName = txtBeneficiaryName.Text;
            ExLCDoc.BeneficiaryAddr1 = txtBeneficiaryAddr1.Text;
            ExLCDoc.BeneficiaryAddr2 = txtBeneficiaryAddr2.Text;
            ExLCDoc.BeneficiaryAddr3 = txtBeneficiaryAddr3.Text;
            //
            ExLCDoc.ApplicantName = txtApplicantName.Text;
            ExLCDoc.ApplicantAddr1 = txtApplicantAddr1.Text;
            ExLCDoc.ApplicantAddr2 = txtApplicantAddr2.Text;
            ExLCDoc.ApplicantAddr3 = txtApplicantAddr3.Text;
            //
            ExLCDoc.IssuingBankNo = txtIssuingBankNo.Text;
            ExLCDoc.IssuingBankName = txtIssuingBankName.Text;
            ExLCDoc.IssuingBankAddr1 = txtIssuingBankAddr1.Text;
            ExLCDoc.IssuingBankAddr2 = txtIssuingBankAddr2.Text;
            ExLCDoc.IssuingBankAddr3 = txtIssuingBankAddr3.Text;
            //
            ExLCDoc.NostroAgentBankNo = txtNostroAgentBankNo.Text;
            ExLCDoc.NostroAgentBankName = txtNostroAgentBankName.Text;
            ExLCDoc.NostroAgentBankAddr1 = txtNostroAgentBankAddr1.Text;
            ExLCDoc.NostroAgentBankAddr2 = txtNostroAgentBankAddr2.Text;
            ExLCDoc.NostroAgentBankAddr3 = txtNostroAgentBankAddr3.Text;
            //
            ExLCDoc.ReceivingBankName = txtReceivingBankName.Text;
            ExLCDoc.ReceivingBankAddr1 = txtReceivingBankAddr1.Text;
            ExLCDoc.ReceivingBankAddr2 = txtReceivingBankAddr2.Text;
            ExLCDoc.ReceivingBankAddr3 = txtReceivingBankAddr3.Text;
            //
            ExLCDoc.DocumentaryCreditNo = txtDocumentaryCreditNo.Text;
            ExLCDoc.Commodity = txtCommodity.Value;
            ExLCDoc.Currency = rcbCurrency.SelectedValue;
            ExLCDoc.DocumentReceivedDate = txtDocumentReceivedDate.SelectedDate;
            ExLCDoc.ProccessingDate = txtProccessingDate.SelectedDate;
            ExLCDoc.AcceptanceDate = txtAcceptanceDate.SelectedDate;
            ExLCDoc.MaturityDate = txtMaturityDate.SelectedDate;
            ExLCDoc.InvoiceNo = txtInvoiceNo.Text;
            if (TabId == ExportLCDocProcessing.Actions.Amend)
            {
                ExLCDoc.Amount = txtNewAmount.Value;
                ExLCDoc.Tenor = rcbNewTenor.SelectedValue;
            }
            else
            {
                ExLCDoc.Amount = txtAmount.Value;
                ExLCDoc.Tenor = txtTenor.Text;
            }
            //
            ExLCDoc.DocsCode1 = rcbDocsCode1.SelectedValue;
            if (txtNoOfOriginals1.Value.HasValue)
                ExLCDoc.NoOfOriginals1 = Convert.ToInt32(txtNoOfOriginals1.Value.Value);
            else
                ExLCDoc.NoOfOriginals1 = null;
            if (txtNoOfCopies1.Value.HasValue)
                ExLCDoc.NoOfCopies1 = Convert.ToInt32(txtNoOfCopies1.Value.Value);
            else
                ExLCDoc.NoOfCopies1 = null;
            ExLCDoc.OtherDocs1 = txtOtherDocs1.Text;
            //
            ExLCDoc.DocsCode2 = rcbDocsCode2.SelectedValue;
            if (txtNoOfOriginals2.Value.HasValue)
                ExLCDoc.NoOfOriginals2 = Convert.ToInt32(txtNoOfOriginals2.Value.Value);
            else
                ExLCDoc.NoOfOriginals2 = null;
            if (txtNoOfCopies2.Value.HasValue)
                ExLCDoc.NoOfCopies2 = Convert.ToInt32(txtNoOfCopies2.Value.Value);
            else
                ExLCDoc.NoOfCopies2 = null;
            ExLCDoc.OtherDocs2 = txtOtherDocs2.Text;
            //
            ExLCDoc.DocsCode3 = rcbDocsCode3.SelectedValue;
            if (txtNoOfOriginals3.Value.HasValue)
                ExLCDoc.NoOfOriginals3 = Convert.ToInt32(txtNoOfOriginals3.Value.Value);
            else
                ExLCDoc.NoOfOriginals3 = null;
            if (txtNoOfCopies3.Value.HasValue)
                ExLCDoc.NoOfCopies3 = Convert.ToInt32(txtNoOfCopies3.Value.Value);
            else
                ExLCDoc.NoOfCopies3 = null;
            ExLCDoc.OtherDocs3 = txtOtherDocs3.Text;
            //

            ExLCDoc.OtherDocs4 = txtOtherDocs4.Text;
            ExLCDoc.OtherDocs5 = txtOtherDocs5.Text;
            ExLCDoc.OtherDocs6 = txtOtherDocs6.Text;
            ExLCDoc.OtherDocs7 = txtOtherDocs7.Text;
            ExLCDoc.OtherDocs8 = txtOtherDocs9.Text;
            ExLCDoc.OtherDocs9 = txtOtherDocs9.Text;
            ExLCDoc.OtherDocs10 = txtOtherDocs10.Text;

            ExLCDoc.Remark = txtRemark.Text;
            ExLCDoc.SettlementInstruction = txtSettlementInstruction.Text;
            //
            ExLCDoc.WaiveCharges = rcbWaiveCharges.SelectedValue;
            ExLCDoc.ChargeRemarks = txtChargeRemarks.Text;
            ExLCDoc.VATNo = txtVATNo.Text;
        }
 protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
 {
     string docCode = tbLCCode.Text.Trim(), lcCode;
     var ExLCDoc = dbEntities.findExportLCDoc(docCode);
     BEXPORT_LC ExLC;
     var toolBarButton = e.Item as RadToolBarButton;
     var commandName = toolBarButton.CommandName.ToLower();
     #region Register
     if (TabId == ExportLCDocProcessing.Actions.Register || TabId == ExportLCDocProcessing.Actions.Register1)
     {
         lcCode = docCode.Substring(0, docCode.IndexOf("."));
         ExLC = dbEntities.findExportLC(lcCode);
         var ExLCAmount = ExLC.Amount - (ExLC.PaymentAmount.HasValue ? ExLC.PaymentAmount.Value : 0);
         switch (commandName)
         {
             case bc.Commands.Commit:
                 if (ExLCAmount < txtAmount.Value.Value)
                 {
                     lblLCCodeMessage.Text = "Doc Amount must less than or equal LC Amount";
                     return;
                 }
                 if (ExLCDoc == null)
                 {
                     ExLCDoc = new BEXPORT_LC_DOCS_PROCESSING();
                     ExLCDoc.DocCode = tbLCCode.Text;
                     ExLCDoc.AmendNo = docCode;
                     ExLCDoc.ActiveRecordFlag = "Yes";
                     ExLCDoc.Status = bd.TransactionStatus.UNA;
                     ExLCDoc.CreateDate = DateTime.Now;
                     ExLCDoc.CreateBy = this.UserInfo.Username;
                     saveLCDoc(ref ExLCDoc);
                     dbEntities.BEXPORT_LC_DOCS_PROCESSING.Add(ExLCDoc);
                 }
                 else
                 {
                     ExLCDoc.Status = bd.TransactionStatus.UNA;
                     ExLCDoc.ActiveRecordFlag = "Yes";
                     ExLCDoc.UpdateDate = DateTime.Now;
                     ExLCDoc.UpdatedBy = this.UserInfo.Username;
                     saveLCDoc(ref ExLCDoc);
                     //Xoa di insert lai
                     var ExLCDocCharge = dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Where(p => p.DocsCode.Trim().ToLower().Equals(docCode.ToLower()));
                     if (ExLCDocCharge != null)
                     {
                         foreach(BEXPORT_LC_DOCS_PROCESSING_CHARGES ch in ExLCDocCharge)
                             dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Remove(ch);
                     }
                 }
                 if (ExLCDoc.WaiveCharges.Equals(bd.YesNo.NO))
                 {
                     BEXPORT_LC_DOCS_PROCESSING_CHARGES ExLCCharge;
                     if (tbChargeAmt1.Value.HasValue)
                     {
                         ExLCCharge = new BEXPORT_LC_DOCS_PROCESSING_CHARGES();
                         saveCharge(txtChargeCode1, rcbChargeCcy1, rcbChargeAcct1, tbChargeAmt1, rcbPartyCharged1, rcbAmortCharge1, rcbChargeStatus1, lblTaxCode1, lblTaxAmt1, ref ExLCCharge);
                         dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Add(ExLCCharge);
                     }
                     if (tbChargeAmt2.Value.HasValue)
                     {
                         ExLCCharge = new BEXPORT_LC_DOCS_PROCESSING_CHARGES();
                         saveCharge(txtChargeCode2, rcbChargeCcy2, rcbChargeAcct2, tbChargeAmt2, rcbPartyCharged2, rcbAmortCharge2, rcbChargeStatus2, lblTaxCode2, lblTaxAmt2, ref ExLCCharge);
                         dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Add(ExLCCharge);
                     }
                     if (tbChargeAmt3.Value.HasValue)
                     {
                         ExLCCharge = new BEXPORT_LC_DOCS_PROCESSING_CHARGES();
                         saveCharge(txtChargeCode3, rcbChargeCcy3, rcbChargeAcct3, tbChargeAmt3, rcbPartyCharged3, rcbAmortCharge3, rcbChargeStatus3, lblTaxCode3, lblTaxAmt3, ref ExLCCharge);
                         dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Add(ExLCCharge);
                     }
                 }
                 //
                 dbEntities.SaveChanges();
                 //
                 Response.Redirect("Default.aspx?tabid=" + this.TabId);
                 break;
             case bc.Commands.Authorize:
             case bc.Commands.Reverse:
                 if (ExLCDoc != null)
                 {
                     if (commandName.Equals(bc.Commands.Authorize))
                     {
                         ExLCDoc.Status = bd.TransactionStatus.AUT;
                         ExLCDoc.AuthorizedBy = this.UserInfo.Username;
                         ExLCDoc.AuthorizedDate = DateTime.Now;
                         //
                         if (ExLC.PaymentAmount.HasValue)
                             ExLC.PaymentAmount += ExLCDoc.Amount;
                         else
                             ExLC.PaymentAmount = ExLCDoc.Amount;
                         ExLC.PaymentFull = (ExLC.PaymentAmount == ExLC.Amount);
                         //
                         dbEntities.SaveChanges();
                         Response.Redirect("Default.aspx?tabid=" + this.TabId);
                     }
                     else
                     {
                         ExLCDoc.Status = bd.TransactionStatus.REV;
                         dbEntities.SaveChanges();
                         Response.Redirect("Default.aspx?tabid=" + this.TabId + "&code=" + tbLCCode.Text);
                     }
                 }
                 break;
         }
         return;
     }
     #endregion Register
     #region Amend
     if (TabId == ExportLCDocProcessing.Actions.Amend)
     {
         docCode = docCode.Split('.')[0] + "." + docCode.Split('.')[1];
         switch (commandName)
         {
             case bc.Commands.Commit:
                 if (ExLCDoc == null)
                 {
                     var ExLCDocOld = dbEntities.findExportLCDoc(docCode);
                     ExLCDocOld.ActiveRecordFlag = "No";
                     ExLCDoc = new BEXPORT_LC_DOCS_PROCESSING()
                     {
                         AmendNo = tbLCCode.Text.Trim(),
                         AmendNoOriginal = ExLCDocOld.AmendNo,
                         DocCode = ExLCDocOld.DocCode,
                         ActiveRecordFlag = "Yes",
                         AmendStatus = bd.TransactionStatus.UNA,
                         AmendDate = DateTime.Now,
                         AmendBy = this.UserInfo.Username,
                         PaymentFull = ExLCDocOld.PaymentFull,
                         Status = ExLCDocOld.Status,
                         CreateBy = ExLCDocOld.CreateBy,
                         CreateDate = ExLCDocOld.CreateDate,
                         UpdatedBy = ExLCDocOld.UpdatedBy,
                         UpdateDate = ExLCDocOld.UpdateDate,
                         AuthorizedBy = ExLCDocOld.AuthorizedBy,
                         AuthorizedDate = ExLCDocOld.AuthorizedDate,
                         RejectStatus = ExLCDocOld.RejectStatus,
                         RejectDate = ExLCDocOld.RejectDate,
                         AcceptStatus = ExLCDocOld.AcceptStatus,
                         AcceptDate = ExLCDocOld.AcceptDate,
                         PaymentAmount = ExLCDocOld.PaymentAmount
                     };
                     saveLCDoc(ref ExLCDoc);
                     dbEntities.BEXPORT_LC_DOCS_PROCESSING.Add(ExLCDoc);
                 }
                 else
                 {
                     var ExLCDocOld = dbEntities.findExportLCDoc(ExLCDoc.AmendNoOriginal, true);
                     ExLCDocOld.ActiveRecordFlag = "No";
                     //
                     ExLCDoc.AmendStatus = bd.TransactionStatus.UNA;
                     ExLCDoc.ActiveRecordFlag = "Yes";
                     ExLCDoc.UpdateDate = DateTime.Now;
                     ExLCDoc.UpdatedBy = this.UserInfo.Username;
                     saveLCDoc(ref ExLCDoc);
                     //Xoa di insert lai
                     var ExLCDocCharge = dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Where(p => p.DocsCode.Trim().ToLower().Equals(ExLCDoc.AmendNo.ToLower()));
                     if (ExLCDocCharge != null)
                     {
                         foreach (BEXPORT_LC_DOCS_PROCESSING_CHARGES ch in ExLCDocCharge)
                             dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Remove(ch);
                     }
                 }
                 if (ExLCDoc.WaiveCharges.Equals(bd.YesNo.NO))
                 {
                     BEXPORT_LC_DOCS_PROCESSING_CHARGES ExLCCharge;
                     if (tbChargeAmt1.Value.HasValue)
                     {
                         ExLCCharge = new BEXPORT_LC_DOCS_PROCESSING_CHARGES();
                         saveCharge(txtChargeCode1, rcbChargeCcy1, rcbChargeAcct1, tbChargeAmt1, rcbPartyCharged1, rcbAmortCharge1, rcbChargeStatus1, lblTaxCode1, lblTaxAmt1, ref ExLCCharge);
                         dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Add(ExLCCharge);
                     }
                     if (tbChargeAmt2.Value.HasValue)
                     {
                         ExLCCharge = new BEXPORT_LC_DOCS_PROCESSING_CHARGES();
                         saveCharge(txtChargeCode2, rcbChargeCcy2, rcbChargeAcct2, tbChargeAmt2, rcbPartyCharged2, rcbAmortCharge2, rcbChargeStatus2, lblTaxCode2, lblTaxAmt2, ref ExLCCharge);
                         dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Add(ExLCCharge);
                     }
                     if (tbChargeAmt3.Value.HasValue)
                     {
                         ExLCCharge = new BEXPORT_LC_DOCS_PROCESSING_CHARGES();
                         saveCharge(txtChargeCode3, rcbChargeCcy3, rcbChargeAcct3, tbChargeAmt3, rcbPartyCharged3, rcbAmortCharge3, rcbChargeStatus3, lblTaxCode3, lblTaxAmt3, ref ExLCCharge);
                         dbEntities.BEXPORT_LC_DOCS_PROCESSING_CHARGES.Add(ExLCCharge);
                     }
                 }
                 //
                 dbEntities.SaveChanges();
                 //
                 Response.Redirect("Default.aspx?tabid=" + this.TabId);
                 break;
             case bc.Commands.Authorize:
             case bc.Commands.Reverse:
                 if (ExLCDoc != null)
                 {
                     var ExLCDocOld = dbEntities.findExportLCDoc(ExLCDoc.AmendNoOriginal, true);
                     if (commandName.Equals(bc.Commands.Authorize))
                     {
                         if (!ExLCDoc.Amount.HasValue) ExLCDoc.Amount = ExLCDocOld.Amount;
                         if (!string.IsNullOrEmpty(ExLCDoc.Tenor)) ExLCDoc.Tenor = ExLCDocOld.Tenor;
                         ExLCDoc.AmendStatus = bd.TransactionStatus.AUT;
                         //
                         dbEntities.SaveChanges();
                         Response.Redirect("Default.aspx?tabid=" + this.TabId);
                     }
                     else
                     {
                         ExLCDocOld.ActiveRecordFlag = "Yes";
                         //
                         ExLCDoc.AmendStatus = bd.TransactionStatus.REV;
                         ExLCDoc.ActiveRecordFlag = "No";
                         //
                         dbEntities.SaveChanges();
                         Response.Redirect("Default.aspx?tabid=" + this.TabId + "&code=" + tbLCCode.Text);
                     }
                 }
                 break;
         }
         return;
     }
     #endregion Amend
     #region Accept, Reject
     if (TabId == ExportLCDocProcessing.Actions.Reject || TabId == ExportLCDocProcessing.Actions.Accept)
     {
         switch (commandName)
         {
             case bc.Commands.Commit:
                 if (ExLCDoc != null)
                 {
                     if (TabId == ExportLCDocProcessing.Actions.Reject)
                     {
                         ExLCDoc.RejectStatus = bd.TransactionStatus.UNA;
                         ExLCDoc.RejectDate = DateTime.Now;
                     }
                     else
                     {
                         ExLCDoc.AcceptStatus = bd.TransactionStatus.UNA;
                         ExLCDoc.AcceptDate = txtAcceptDate.SelectedDate;
                         ExLCDoc.AcceptRemarks = txtAcceptRemarks.Text;
                     }
                     saveLCDoc(ref ExLCDoc);
                     dbEntities.SaveChanges();
                 }
                 //
                 Response.Redirect("Default.aspx?tabid=" + this.TabId);
                 break;
             case bc.Commands.Authorize:
             case bc.Commands.Reverse:
                 if (ExLCDoc != null)
                 {
                     if (commandName.Equals(bc.Commands.Authorize))
                     {
                         if (TabId == ExportLCDocProcessing.Actions.Reject)
                             ExLCDoc.RejectStatus = bd.TransactionStatus.AUT;
                         else
                             ExLCDoc.AcceptStatus = bd.TransactionStatus.AUT;
                         //
                         dbEntities.SaveChanges();
                         Response.Redirect("Default.aspx?tabid=" + this.TabId);
                     }
                     else
                     {
                         if (TabId == ExportLCDocProcessing.Actions.Reject)
                             ExLCDoc.RejectStatus = bd.TransactionStatus.REV;
                         else
                             ExLCDoc.AcceptStatus = bd.TransactionStatus.REV;
                         //
                         dbEntities.SaveChanges();
                         Response.Redirect("Default.aspx?tabid=" + this.TabId + "&code=" + tbLCCode.Text);
                     }
                 }
                 break;
         }
         return;
     }
     #endregion Accept, Reject
 }