/// <summary> /// Function to fill the details for edit or delete /// </summary> public void FillRegisterOrReport() { SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); try { VoucherTypeBll BllVoucherType = new VoucherTypeBll(); IsDoAfterFill = false; IsCellValue = false; btnSave.Text = "Update"; btnDelete.Enabled = true; infoSalesQuotationMaster =bllSalesQuotation.SalesQuotationMasterView(decSalesquotationMasterId); txtQuotationNo.Text = infoSalesQuotationMaster.InvoiceNo; strVoucherNo = infoSalesQuotationMaster.VoucherNo.ToString(); decSalesQuotationPreffixSuffixId = Convert.ToDecimal(infoSalesQuotationMaster.SuffixPrefixId); decSalesQuotationVoucherId = Convert.ToDecimal(infoSalesQuotationMaster.VoucherTypeId); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decSalesQuotationVoucherId); decsalesQuotationTypeId = decSalesQuotationVoucherId; txtSalesQuotationDate.Text = infoSalesQuotationMaster.Date.ToString("dd-MMM-yyyy"); cmbCashOrParty.SelectedValue = infoSalesQuotationMaster.LedgerId; ComboSalesManFill(); cmbSalesman.SelectedValue = infoSalesQuotationMaster.EmployeeId; txtNarration.Text = infoSalesQuotationMaster.Narration; cmbCurrency.SelectedValue = infoSalesQuotationMaster.ExchangeRateId; decimal decsalesregisterTotal = Convert.ToDecimal(infoSalesQuotationMaster.TotalAmount.ToString()); decsalesregisterTotal = Math.Round(decsalesregisterTotal, PublicVariables._inNoOfDecimalPlaces); txtTotal.Text = Convert.ToString(decsalesregisterTotal); cmbPricinglevel.SelectedValue = infoSalesQuotationMaster.PricinglevelId; List<DataTable> ListObj = new List<DataTable>(); ListObj = bllSalesQuotation.SalesQuotationDetailsViewByMasterId(decSalesquotationMasterId); if (isAutomatic) { txtQuotationNo.ReadOnly = true; txtSalesQuotationDate.Focus(); } else { txtQuotationNo.ReadOnly = false; txtQuotationNo.Focus(); } string strApproved = Convert.ToString(infoSalesQuotationMaster.Approved); if (strApproved == "False") { cbxApproved.Checked = false; } else { cbxApproved.Checked = true; } decimal decCount = bllSalesQuotation.CheckingStastusForSalesQuotation(decSalesquotationMasterId); if (decCount > 0) { cbxApproved.Enabled = false; } else { cbxApproved.Enabled = true; } for (int i = 0; i < ListObj[0].Rows.Count; i++) { isAmountcalc = false; dgvProduct.Rows.Add(); dgvProduct.Rows[i].HeaderCell.Value = string.Empty; dgvProduct.Rows[i].Cells["dgvtxtQuotationDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["quotationDetailsId"].ToString()); dgvProduct.Rows[i].Cells["ProductId"].Value = ListObj[0].Rows[i]["productId"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[i]["Barcode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString(); transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, ListObj[0].Rows[i]["productId"].ToString(), i); bllSalesQuotation.SalesQuotationMasterBatchFill(dgvProduct, Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), i); dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString(); IsCellValue = true; dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString()); IsCellValue = false; dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString(); IsCellValue = true; dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString(); IsCellValue = false; dgvProduct.Rows[i].Cells["dgvcmbbatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString()); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[i].Cells["ProductId"].Value.ToString()); if (listUnitByProduct[0].Rows.Count > 0) { foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); } } } decimal decStandardRate = BllProductCreation.SalesInvoiceProductRateForSales(Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), PublicVariables._dtCurrentDate, Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString()), Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces); if (dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } } } isAmountcalc = true; IsCellValue = true; IsDoAfterFill = true; } catch (Exception ex) { MessageBox.Show("SQ:39" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }