private void loadLCAmend(BEXPORT_LC_AMEND ExLCAmend) { txtImportLCNo.Text = ExLCAmend.ImportLCCode; txtImportLCNo_TextChanged(null, null); // txtSenderReference.Text = ExLCAmend.SenderReference; txtReceiverReference.Text = ExLCAmend.ReceiverReference; txtIssuingBankReference.Text = ExLCAmend.IssuingBankReference; // rcbIssuingBankType.SelectedValue = ExLCAmend.IssuingBankType; rcbIssuingBankType_OnSelectedIndexChanged(null, null); txtIssuingBankNo.Text = ExLCAmend.IssuingBankNo; txtIssuingBankName.Text = ExLCAmend.IssuingBankName; txtIssuingBankAddr1.Text = ExLCAmend.IssuingBankAddr1; txtIssuingBankAddr2.Text = ExLCAmend.IssuingBankAddr2; txtIssuingBankAddr3.Text = ExLCAmend.IssuingBankAddr3; // txtDateOfIssue.SelectedDate = ExLCAmend.DateOfIssue; txtDateOfAmendment.SelectedDate = ExLCAmend.DateOfAmendment; txtNumberOfAmendment.Text = ExLCAmend.NumberOfAmendment.ToString(); // rcbBeneficiaryNumber.SelectedValue = ExLCAmend.BeneficiaryNo; txtBeneficiaryName.Text = ExLCAmend.BeneficiaryName; txtBeneficiaryAddr1.Text = ExLCAmend.BeneficiaryAddr1; txtBeneficiaryAddr2.Text = ExLCAmend.BeneficiaryAddr2; txtBeneficiaryAddr3.Text = ExLCAmend.BeneficiaryAddr3; // txtNewDateOfExpiry.SelectedDate = ExLCAmend.NewDateOfExpiry; rcbCurrency.SelectedValue = ExLCAmend.Currency; newCreaditAmountCurrency.SelectedValue = ExLCAmend.Currency; decreaseCurrency.SelectedValue = ExLCAmend.Currency; txtIncreaseOfDocumentaryCreditAmount.Value = ExLCAmend.IncreaseOfDocumentaryCreditAmount; txtDecreaseOfDocumentaryCreditAmount.Value = ExLCAmend.DecreaseOfDocumentaryCreditAmount; txtDocumentaryCreditAmount.Value = ExLCAmend.DocumentaryCreditAmount.ToString(); txtNewDocumentaryCreditAmountAfterAmendment.Value = ExLCAmend.NewDocumentaryCreditAmountAfterAmendment; txtPercentCreditAmountTolerance1.Value = ExLCAmend.PercentageCreditAmountTolerance1; txtPercentCreditAmountTolerance2.Value = ExLCAmend.PercentageCreditAmountTolerance2; // txtPlaceOfTakingInCharge.Text = ExLCAmend.PlaceOfTakingInCharge; txtPortOfLoading.Text = ExLCAmend.PortOfLoading; txtPortOfDischarge.Text = ExLCAmend.PortOfDischarge; txtPlaceOfFinalDestination.Text = ExLCAmend.PlaceOfFinalDestination; txtLatesDateOfShipment.SelectedDate = ExLCAmend.LatesDateOfShipment; txtNarrative.Text = ExLCAmend.Narrative; txtSenderToReceiverInformation.Text = ExLCAmend.SenderToReceiverInformation; // rcbWaiveCharges.SelectedValue = ExLCAmend.WaiveCharges; tbChargeRemarks.Text = ExLCAmend.ChargeRemarks; tbVatNo.Text = ExLCAmend.VATNo; if (ExLCAmend.WaiveCharges.Equals(bd.YesNo.NO)) loadCharges(); }
private void saveLCAmend(ref BEXPORT_LC_AMEND ExLCAmend) { ExLCAmend.ImportLCCode = txtImportLCNo.Text.Trim(); // ExLCAmend.SenderReference = txtSenderReference.Text.Trim(); ExLCAmend.ReceiverReference = txtReceiverReference.Text.Trim(); ExLCAmend.IssuingBankReference = txtIssuingBankReference.Text.Trim(); // ExLCAmend.IssuingBankType = rcbIssuingBankType.SelectedValue.Trim(); ExLCAmend.IssuingBankNo = txtIssuingBankNo.Text.Trim(); ExLCAmend.IssuingBankName = txtIssuingBankName.Text.Trim(); ExLCAmend.IssuingBankAddr1 = txtIssuingBankAddr1.Text.Trim(); ExLCAmend.IssuingBankAddr2 = txtIssuingBankAddr2.Text.Trim(); ExLCAmend.IssuingBankAddr3 = txtIssuingBankAddr3.Text.Trim(); // ExLCAmend.Currency = rcbCurrency.SelectedValue.Trim(); ExLCAmend.DateOfIssue = txtDateOfIssue.SelectedDate; ExLCAmend.DateOfAmendment = txtDateOfAmendment.SelectedDate; ExLCAmend.NumberOfAmendment = Convert.ToInt32(txtNumberOfAmendment.Value); // ExLCAmend.BeneficiaryNo = rcbBeneficiaryNumber.SelectedValue.Trim(); ExLCAmend.BeneficiaryName = txtBeneficiaryName.Text.Trim(); ExLCAmend.BeneficiaryAddr1 = txtBeneficiaryAddr1.Text.Trim(); ExLCAmend.BeneficiaryAddr2 = txtBeneficiaryAddr2.Text.Trim(); ExLCAmend.BeneficiaryAddr3 = txtBeneficiaryAddr3.Text.Trim(); // ExLCAmend.NewDateOfExpiry = txtNewDateOfExpiry.SelectedDate; ExLCAmend.IncreaseOfDocumentaryCreditAmount = txtIncreaseOfDocumentaryCreditAmount.Value; ExLCAmend.DecreaseOfDocumentaryCreditAmount = txtDecreaseOfDocumentaryCreditAmount.Value; ExLCAmend.NewDocumentaryCreditAmountAfterAmendment = txtNewDocumentaryCreditAmountAfterAmendment.Value; ExLCAmend.DocumentaryCreditAmount = Convert.ToDouble(txtDocumentaryCreditAmount.Value); ExLCAmend.PercentageCreditAmountTolerance1 = txtPercentCreditAmountTolerance1.Value; ExLCAmend.PercentageCreditAmountTolerance2 = txtPercentCreditAmountTolerance2.Value; // ExLCAmend.PlaceOfTakingInCharge = txtPlaceOfTakingInCharge.Text.Trim(); ExLCAmend.PortOfLoading = txtPortOfLoading.Text.Trim(); ExLCAmend.PortOfDischarge = txtPortOfDischarge.Text.Trim(); ExLCAmend.PlaceOfFinalDestination = txtPlaceOfFinalDestination.Text.Trim(); ExLCAmend.LatesDateOfShipment = txtLatesDateOfShipment.SelectedDate; // ExLCAmend.Narrative = txtNarrative.Text; ExLCAmend.SenderToReceiverInformation = txtSenderToReceiverInformation.Text.Trim(); // ExLCAmend.WaiveCharges = rcbWaiveCharges.SelectedValue; ExLCAmend.ChargeRemarks = tbChargeRemarks.Text.Trim(); ExLCAmend.VATNo = tbVatNo.Text.Trim(); }
protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e) { string LCCode = tbLCCode.Text.Trim(), AmendNo = tbLCCode.Text.Trim() + "." + txtNumberOfAmendment.Value.Value; if (tbLCCode.Text.IndexOf(".") > 0) { LCCode = tbLCCode.Text.Substring(0, tbLCCode.Text.IndexOf(".")); AmendNo = tbLCCode.Text.Trim(); } var ExLC = dbEntities.findExportLC(LCCode); var ExLCAmend = dbEntities.findExportLCAmend(AmendNo); var toolBarButton = e.Item as RadToolBarButton; var commandName = toolBarButton.CommandName.ToLower(); switch (commandName) { case bc.Commands.Commit: if (ExLCAmend == null) { ExLCAmend = new BEXPORT_LC_AMEND(); ExLCAmend.AmendNo = AmendNo; ExLCAmend.AmendStatus = bd.TransactionStatus.UNA; ExLCAmend.AmendBy = this.UserInfo.Username; ExLCAmend.AmendDate = DateTime.Now; saveLCAmend(ref ExLCAmend); dbEntities.BEXPORT_LC_AMEND.Add(ExLCAmend); } else { ExLCAmend.AmendNo = AmendNo; ExLCAmend.AmendStatus = bd.TransactionStatus.UNA; saveLCAmend(ref ExLCAmend); //Xoa di insert lai var ExLCCharge = dbEntities.BEXPORT_LC_CHARGES.Where(p => p.ExportLCCode.Trim().ToLower().Equals(AmendNo.ToLower())); if (ExLCCharge != null) { foreach (BEXPORT_LC_CHARGES ch in ExLCCharge) { dbEntities.BEXPORT_LC_CHARGES.Remove(ch); } } } if (ExLCAmend.WaiveCharges.Equals(bd.YesNo.NO)) { BEXPORT_LC_CHARGES ExLCCharge; if (tbChargeAmt1.Value.HasValue) { ExLCCharge = new BEXPORT_LC_CHARGES(); saveCharge(ExLCAmend.AmendNo, txtChargeCode1, rcbChargeCcy1, rcbChargeAcct1, tbChargeAmt1, rcbPartyCharged1, rcbAmortCharge1, rcbChargeStatus1, lblTaxCode1, lblTaxAmt1, ref ExLCCharge); dbEntities.BEXPORT_LC_CHARGES.Add(ExLCCharge); } if (tbChargeAmt2.Value.HasValue) { ExLCCharge = new BEXPORT_LC_CHARGES(); saveCharge(ExLCAmend.AmendNo, txtChargeCode2, rcbChargeCcy2, rcbChargeAcct2, tbChargeAmt2, rcbPartyCharged2, rcbAmortCharge2, rcbChargeStatus2, lblTaxCode2, lblTaxAmt2, ref ExLCCharge); dbEntities.BEXPORT_LC_CHARGES.Add(ExLCCharge); } if (tbChargeAmt3.Value.HasValue) { ExLCCharge = new BEXPORT_LC_CHARGES(); saveCharge(ExLCAmend.AmendNo, txtChargeCode3, rcbChargeCcy3, rcbChargeAcct3, tbChargeAmt3, rcbPartyCharged3, rcbAmortCharge3, rcbChargeStatus3, lblTaxCode3, lblTaxAmt3, ref ExLCCharge); dbEntities.BEXPORT_LC_CHARGES.Add(ExLCCharge); } } // ExLC.AmendStatus = bd.TransactionStatus.UNA; ExLC.AmendBy = this.UserInfo.Username; ExLC.AmendDate = DateTime.Now; // try { dbEntities.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Diagnostics.Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName, validationError.PropertyName, validationError.ErrorMessage); } } throw; // You can also choose to handle the exception here... } // Response.Redirect("Default.aspx?tabid=" + this.TabId); break; case bc.Commands.Authorize: case bc.Commands.Reverse: if (commandName.Equals(bc.Commands.Authorize)) { ExLC.AmendStatus = bd.TransactionStatus.AUT; ExLCAmend.AmendStatus = bd.TransactionStatus.AUT; ExLC.Amount = ExLCAmend.NewDocumentaryCreditAmountAfterAmendment; // dbEntities.SaveChanges(); Response.Redirect("Default.aspx?tabid=" + this.TabId); return; } // ExLC.AmendStatus = bd.TransactionStatus.REV; ExLCAmend.AmendStatus = bd.TransactionStatus.REV; dbEntities.SaveChanges(); Response.Redirect("Default.aspx?tabid=" + this.TabId + "&code=" + tbLCCode.Text); break; } }