public ActionResult Save(tblConsignmentNoteDTO tblConsignmentNoteDTO) { if (ModelState.IsValid) { var resultCheckDuplicateConsignmentNoteNo = ConsignmentNoteBusinessLogic.CheckDuplicateConsignmentNoteNo(tblConsignmentNoteDTO.ConsignmentId, tblConsignmentNoteDTO.ConsignmentNoteNo ?? 0); if (resultCheckDuplicateConsignmentNoteNo) { ModelState.AddModelError("ConsignmentNoteNo", "Consignment Note No already exists."); } else { tblConsignmentNoteDTO.FinalAmount = (tblConsignmentNoteDTO.Amount1 + tblConsignmentNoteDTO.Amount2 + tblConsignmentNoteDTO.Amount3 + tblConsignmentNoteDTO.Amount4 + tblConsignmentNoteDTO.Amount5); var result = ConsignmentNoteBusinessLogic.Save(tblConsignmentNoteDTO); return(RedirectToAction("Index")); } } tblConsignmentNoteDTO = FillDropDown(tblConsignmentNoteDTO); return(View(tblConsignmentNoteDTO)); }
private void btnSave_Click(object sender, EventArgs e) { if (ValidateData()) { if (txtAmount1.Text.Trim() == "") { txtAmount1.Text = "0"; } if (txtAmount2.Text.Trim() == "") { txtAmount2.Text = "0"; } if (txtAmount3.Text.Trim() == "") { txtAmount3.Text = "0"; } if (txtAmount4.Text.Trim() == "") { txtAmount4.Text = "0"; } if (txtAmount5.Text.Trim() == "") { txtAmount5.Text = "0"; } tblConsignmentNoteDTO consignNoteDTO = new tblConsignmentNoteDTO(); consignNoteDTO.CompanyName = txtCompanyName.Text; consignNoteDTO.PolicyNo = txtPolicyNo.Text; consignNoteDTO.CompanyDate = Convert.ToDateTime(dpCompanyDate.Value); consignNoteDTO.CompanyAmount = txtCompanyAmount.Text.Trim() == "" ? 0 : Convert.ToDouble(txtCompanyAmount.Text); consignNoteDTO.ConsigneeId = Convert.ToInt32(cmbConsineeName.SelectedValue); consignNoteDTO.ConsigneeInvoiceNo = txtInvoiceNo.Text; consignNoteDTO.ConsigneeServiceTaxRegNo = txtConsigneeServiceTaxRegNo.Text; consignNoteDTO.ConsignorId = Convert.ToInt32(cmbConsignorName.SelectedValue); consignNoteDTO.ConsignorPurchaseOrderNo = txtPurchaseOrderNo.Text; consignNoteDTO.ConsignorServiceTaxRegNo = txtConsignorServiceTaxRegNo.Text; consignNoteDTO.PanNo = txtPanNo.Text; consignNoteDTO.CentralisedServiceTaxRegnNo = txtCentralisedServiceTaxRegNo.Text; consignNoteDTO.FromCode = txtFromCodeName.Text; consignNoteDTO.ConsignmentNoteNo = txtConsignmentNoteNo.Text.Trim() == "" ? 0 : Convert.ToInt32(txtConsignmentNoteNo.Text); consignNoteDTO.ConsignmentDate = Convert.ToDateTime(dpConsignmentDate.Value); consignNoteDTO.AddressofIssuing = txtAddressOfIssueOffice.Text; consignNoteDTO.ToCode = txtToCodeName.Text; consignNoteDTO.CompanyPhone = txtCompanyPhoneNo.Text; consignNoteDTO.NoofPackages = txtNoOfPackages.Text; consignNoteDTO.MethodOfPacking = txtMethodOfPacking.Text; consignNoteDTO.ActualWtInKGS = txtActualWeightInKg.Text; consignNoteDTO.CategoryOfLoad = txtChargeWeightInKg.Text; consignNoteDTO.Rate = txtRate.Text; consignNoteDTO.Charges1 = txtCharges1.Text; consignNoteDTO.Amount1 = double.Parse(txtAmount1.Text); consignNoteDTO.LoadType = txtLoadType.Text; consignNoteDTO.Distance = txtDistance.Text; consignNoteDTO.KMS = txtKms.Text; consignNoteDTO.Charges1 = txtCharges1.Text; consignNoteDTO.Charges2 = txtCharges2.Text; consignNoteDTO.Amount2 = double.Parse(txtAmount2.Text); consignNoteDTO.Charges3 = txtCharges3.Text; consignNoteDTO.Charges4 = txtCharges4.Text; consignNoteDTO.AdvancedPaymentDate = Convert.ToDateTime(dpAdvancePaymentDate.Value); consignNoteDTO.Charges5 = txtCharges5.Text; consignNoteDTO.Amount3 = txtAmount3.Text.Trim() == "" ? 0 : Convert.ToDouble(txtAmount3.Text); consignNoteDTO.Amount4 = txtAmount4.Text.Trim() == "" ? 0 : Convert.ToDouble(txtAmount4.Text); consignNoteDTO.Amount5 = txtAmount5.Text.Trim() == "" ? 0 : Convert.ToDouble(txtAmount5.Text); txtFinalAmount.Text = (Convert.ToDouble(txtAmount1.Text) + Convert.ToDouble(txtAmount2.Text) + Convert.ToDouble(txtAmount3.Text) + Convert.ToDouble(txtAmount4.Text) + Convert.ToDouble(txtAmount5.Text)).ToString(); consignNoteDTO.FinalAmount = Convert.ToDouble(txtFinalAmount.Text); consignNoteDTO.PrivateMarketOtherIdentificaion = txtPrivateMarks.Text; consignNoteDTO.AdvancedPaymentAmount = txtAdvancePaymentAmount.Text; consignNoteDTO.BusinessType = txtBusinessType.Text; consignNoteDTO.DeclarationNo = txtDeclaredValueGoods.Text; consignNoteDTO.DimensionLength = txtLength.Text; consignNoteDTO.DimensionWidth = txtWidth.Text; consignNoteDTO.DimensionHeight = txtHeight.Text; consignNoteDTO.DimensionNoOfPKGS = txtDiamentionNoOfPkgs.Text; consignNoteDTO.DimensionTotalCFTCMT = txtTotalCFT.Text; consignNoteDTO.DimensionSinglePieceWeight = txtSinglePiece.Text; consignNoteDTO.ValidType = txtValidType.Text; consignNoteDTO.DeclaredValueOfGoods = txtDeclaredValueGoods.Text; consignNoteDTO.ServicetaxThrough = txtServiceTaxThrough.Text; consignNoteDTO.BasicOfBooking = txtBasicOfBooking.Text; consignNoteDTO.BilledWithMs = txtBilledWith.Text; consignNoteDTO.BranchCode = txtBranchCode.Text; consignNoteDTO.PartyCode = txtPartyCode.Text; consignNoteDTO.ToPay = txtToPay.Text; consignNoteDTO.Rebooking = txtRebooking.Text; consignNoteDTO.MainConsignmentNo = txtMainConsignment.Text; consignNoteDTO.ServiceTaxisPayableBy = (cmbServiceTaxisPaybleBy.SelectedItem).ToString(); consignNoteDTO.ConsignmentId = Consignmentid; var resultCheckDuplicateConsignmentNoteNo = ConsignmentNoteBusinessLogic.CheckDuplicateConsignmentNoteNo(Consignmentid, Convert.ToInt32(txtConsignmentNoteNo.Text)); if (resultCheckDuplicateConsignmentNoteNo) { MessageBox.Show("Consignment Number already exists."); txtConsignmentNoteNo.Focus(); } else { var result = ConsignmentNoteBusinessLogic.Save(consignNoteDTO); if (result > 0) { MessageBox.Show("LR Note Successfully Generate"); if (Consignmentid > 0) { this.Close(); } else { clearData(); } } } } }