/// <summary> /// Function to save the sales quatation /// </summary> public void SaveFunction() { SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); //SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo(); SettingsBll BllSettings = new SettingsBll(); ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoproduct = new ProductInfo(); try { infoSalesQuotationMaster.Date = Convert.ToDateTime(txtSalesQuotationDate.Text); infoSalesQuotationMaster.PricinglevelId = Convert.ToDecimal(cmbPricinglevel.SelectedValue.ToString()); infoSalesQuotationMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); if (isAutomatic) { infoSalesQuotationMaster.SuffixPrefixId = decSalesQuotationPreffixSuffixId; infoSalesQuotationMaster.VoucherNo = strSalesQuotationNo; } else { infoSalesQuotationMaster.SuffixPrefixId = 0; infoSalesQuotationMaster.VoucherNo = bllSalesQuotation.VoucherNoMax(decsalesQuotationTypeId); } infoSalesQuotationMaster.VoucherTypeId = decsalesQuotationTypeId; infoSalesQuotationMaster.InvoiceNo = txtQuotationNo.Text; infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoSalesQuotationMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoSalesQuotationMaster.userId = PublicVariables._decCurrentUserId; infoSalesQuotationMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text); infoSalesQuotationMaster.Narration = txtNarration.Text.Trim(); infoSalesQuotationMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoSalesQuotationMaster.Extra1 = string.Empty; infoSalesQuotationMaster.Extra2 = string.Empty; if (cbxApproved.Checked) { infoSalesQuotationMaster.Approved = true; } else { infoSalesQuotationMaster.Approved = false; } decSalesQuotationmasterIdentity = Convert.ToDecimal(bllSalesQuotation.SalesQuotationMasterAdd(infoSalesQuotationMaster)); int inRowcount = dgvProduct.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { infoSalesQuotationDetails.QuotationMasterId = decSalesQuotationmasterIdentity; if (dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty) { infoproduct = BllProductCreation.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoSalesQuotationDetails.ProductId = infoproduct.ProductId; } if (dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { infoSalesQuotationDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); } if (dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty) { infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); decimal unitConversion = bllSalesQuotation.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId); infoSalesQuotationDetails.UnitConversionId = unitConversion; } if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value); } else { infoSalesQuotationDetails.BatchId = 0; } infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoSalesQuotationDetails.Extra1 = string.Empty; infoSalesQuotationDetails.Extra2 = string.Empty; bllSalesQuotation.SalesQuotationDetailsAdd(infoSalesQuotationDetails); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (dgvProduct.Rows.Count > 0) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesQuotationmasterIdentity); } else { Print(decSalesQuotationmasterIdentity); } } else { Messages.InformationMessage("No data found"); } } Clear(); } catch (Exception ex) { MessageBox.Show("SQ:32" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }