/// <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); } }
/// <summary> /// On cellendedit of dgvProduct /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e) { ProductCreationBll BllProductCreation = new ProductCreationBll(); try { if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductName") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString().Trim() != string.Empty) { string strProductName = Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value); ProductInfo infoProduct = BllProductCreation.ProductViewByName(strProductName); if (infoProduct.ProductCode != null && infoProduct.ProductCode != string.Empty) { TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = infoProduct.ProductId; List<DataTable> ListObj = new List<DataTable>(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate); DefaultRate = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); ListObjUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, infoProduct.ProductId.ToString(), e.RowIndex); ListObj = bllSalesQuotation.SalesQuotationMasterBatchFill(dgvProduct, infoProduct.ProductId, e.RowIndex); BatchBll BllBatch = new BatchBll(); decimal decBatchId = BllBatch.BatchIdViewByProductId(infoProduct.ProductId); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = decBatchId; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; if (infoProduct.PartNo != string.Empty) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = infoProduct.PartNo; } else { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = BllProductCreation.BarcodeViewByBatchId(decBatchId); } } IsDoAfterFill = true; UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString()); if (listUnitByProduct[0].Rows.Count > 0) { foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); if (IsDoAfterFill) { decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate,PublicVariables._inNoOfDecimalPlaces); } } } } decimal decStandardRate = BllProductCreation.SalesInvoiceProductRateForSales(infoProduct.ProductId, PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces); if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } } } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = string.Empty; } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; } } if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtBarcode") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString().Trim() != string.Empty) { List<DataTable> listObjProductdDetails = new List<DataTable>(); string strBarcode = (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString()); listObjProductdDetails = BllProductCreation.ProductDetailsCoreespondingToBarcode(strBarcode); if (listObjProductdDetails[0].Rows.Count > 0) { TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); List<DataTable> ListObj = new List<DataTable>(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = listObjProductdDetails[0].Rows[0]["productCode"].ToString(); dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = listObjProductdDetails[0].Rows[0]["productId"].ToString(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = listObjProductdDetails[0].Rows[0]["productName"].ToString(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(Convert.ToDecimal(listObjProductdDetails[0].Rows[0]["SalesRate"].ToString())); DefaultRate = Math.Round(Convert.ToDecimal(listObjProductdDetails[0].Rows[0]["purchaseRate"].ToString()), PublicVariables._inNoOfDecimalPlaces); ListObjUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, listObjProductdDetails[0].Rows[0]["productId"].ToString(), e.RowIndex); ListObj = bllSalesQuotation.SalesQuotationMasterBatchFill(dgvProduct, Convert.ToDecimal(listObjProductdDetails[0].Rows[0]["productId"].ToString()), e.RowIndex); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(listObjProductdDetails[0].Rows[0]["batchId"].ToString()); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(listObjProductdDetails[0].Rows[0]["unitId"].ToString()); IsDoAfterFill = true; UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString()); if (listUnitByProduct[0].Rows.Count > 0) { foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); if (IsDoAfterFill) { decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, PublicVariables._inNoOfDecimalPlaces); } } } } decimal decStandardRate = BllProductCreation.SalesInvoiceProductRateForSales(Convert.ToDecimal(listObjProductdDetails[0].Rows[0]["productId"].ToString()), PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces); if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } } } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = string.Empty; } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductCode") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString().Trim() != string.Empty) { ProductInfo infoProduct = new ProductInfo(); string strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString(); infoProduct = BllProductCreation.ProductViewByCode(strProductCode); if (infoProduct.ProductId != 0) { TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = infoProduct.ProductId; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate, PublicVariables._inNoOfDecimalPlaces); DefaultRate = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); List<DataTable> LiostObj = new List<DataTable>(); ListObjUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, infoProduct.ProductId.ToString(), e.RowIndex); LiostObj = bllSalesQuotation.SalesQuotationMasterBatchFill(dgvProduct, infoProduct.ProductId, e.RowIndex); BatchBll BllBatch = new BatchBll(); decimal decBatchId = BllBatch.BatchIdViewByProductId(infoProduct.ProductId); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = decBatchId; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; if (infoProduct.PartNo != string.Empty) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = infoProduct.PartNo; } else { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = BllProductCreation.BarcodeViewByBatchId(decBatchId); } } IsDoAfterFill = true; UnitConvertionBll bllUnitByProduct = new UnitConvertionBll(); List<DataTable> listUnitByProduct = bllUnitByProduct.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString()); if (listUnitByProduct[0].Rows.Count > 0) { foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); if (IsDoAfterFill) { decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, PublicVariables._inNoOfDecimalPlaces); } } } } decimal decStandardRate = BllProductCreation.SalesInvoiceProductRateForSales(infoProduct.ProductId, PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces); if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } } } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = string.Empty; } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty) { DefaultRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value); } } CheckInvalidEntriesInDataGridProduct(e); } catch (Exception ex) { MessageBox.Show("SQ:56" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to call frmProductSearchPopup form to select and view product /// </summary> /// <param name="frmProductSearchPopup"></param> /// <param name="decproductId"></param> /// <param name="decCurrentRowIndex"></param> public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex) { ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); try { this.Enabled = true; this.BringToFront(); this.frmProductSearchPopupObj = frmProductSearchPopup; int inCurrentRowIndex = dgvProduct.CurrentRow.Index; dgvProduct.Rows.Add(); if (decproductId != 0) { List<DataTable> ListObj = new List<DataTable>(); List<DataTable> ListObjUnitViewAll = new List<DataTable>(); infoProduct = BllProductCreation.ProductView(decproductId); TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; dgvProduct.Rows[inCurrentRowIndex].Cells["ProductId"].Value = infoProduct.ProductId; dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate, PublicVariables._inNoOfDecimalPlaces); DefaultRate = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); ListObjUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, infoProduct.ProductId.ToString(), inCurrentRowIndex); ListObj= bllSalesQuotation.SalesQuotationMasterBatchFill(dgvProduct, infoProduct.ProductId, inCurrentRowIndex); BatchBll BllBatch = new BatchBll(); decimal decBatchId = BllBatch.BatchIdViewByProductId(infoProduct.ProductId); dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value = decBatchId; dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; if (infoProduct.PartNo != string.Empty) { dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = infoProduct.PartNo; } else { if (dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value); dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = BllProductCreation.BarcodeViewByBatchId(decBatchId); } } IsDoAfterFill = true; UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[inCurrentRowIndex].Cells["ProductId"].Value.ToString()); if (listUnitByProduct[0].Rows.Count > 0) { foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); if (IsDoAfterFill) { decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate; dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, PublicVariables._inNoOfDecimalPlaces); } } } } decimal decStandardRate = BllProductCreation.SalesInvoiceProductRateForSales(infoProduct.ProductId, PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces); if (dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } } dgvProduct.Rows[inCurrentRowIndex].HeaderCell.Value = "X"; dgvProduct.Rows[inCurrentRowIndex].HeaderCell.Style.ForeColor = Color.Red; } frmProductSearchPopupObj.Close(); frmProductSearchPopupObj = null; } catch (Exception ex) { MessageBox.Show("SQ:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill Details Corresponding Quotation No /// </summary> public void FillQuotationDetails() { SerialNo(); try { BatchBll BllBatch = new BatchBll(); SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo(); TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll(); decimal decOrderNo = 0; if (!isEditFill) { inMaxCount = 0; decOrderNo = Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString()); dgvSalesOrder.Rows.Clear(); List<DataTable> ListObj = new SalesQuotationBll().QuotationMasterViewByQuotationMasterId(Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString())); if (ListObj[0].Rows.Count > 0) { cmbPricingLevel.SelectedValue = ListObj[0].Rows[0]["pricingLevelId"].ToString(); if (ListObj[0].Rows[0]["employeeId"].ToString() != "") { strSalesMan = ListObj[0].Rows[0]["employeeId"].ToString(); cmbSalesMan.SelectedValue = strSalesMan; if (cmbSalesMan.SelectedValue == null) { SalesManComboFill(); cmbSalesMan.SelectedValue = ListObj[0].Rows[0]["employeeId"].ToString(); } } DGVCurrencyComboFill(); cmbCurrency.SelectedValue = ListObj[0].Rows[0]["exchangeRateId"].ToString(); List<DataTable> ListObj1 = new SalesQuotationBll().SalesQuotationDetailsViewByquotationMasterIdWithRemainingBySO(Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString()), decSalesOrderMasterId); int inRowIndex = 0; foreach (DataRow drowDetails in ListObj1[0].Rows) { dgvSalesOrder.Rows.Add(); isValueChange = false; isDoAfterGridFill = false; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtSalesOrderDetailsId"].Value = drowDetails.ItemArray[0].ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtSalesQuotationDetailsId"].Value = drowDetails.ItemArray[0].ToString(); String ProductId = drowDetails.ItemArray[2].ToString(); infoProduct = new ProductCreationBll().ProductView(Convert.ToDecimal(ProductId)); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"]; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString(); AssignProductDefaultValues(dgvSalesOrder.Rows.Count - 2, drowDetails["productId"].ToString()); TransactionGeneralFillObj.UnitViewAllByProductId(dgvSalesOrder, infoProduct.ProductId.ToString(), dgvSalesOrder.Rows.Count - 2); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString(); UnitComboFill(Convert.ToDecimal(ProductId), dgvSalesOrder.Rows.Count - 2, dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtAmount"].Value = drowDetails["amount"].ToString(); BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvSalesOrder.Rows.Count - 2, dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex); if (Convert.ToDecimal(drowDetails["batchId"].ToString()) != 0) { dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); } else { StockPostingBll BllStockPosting = new StockPostingBll(); decimal decBatchId = BllStockPosting.BatchViewByProductId(Convert.ToDecimal(ProductId)); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].Value = decBatchId; } string strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].Value.ToString())); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = strBarcode.ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["inRowIndex"].Value = drowDetails["extra1"].ToString(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> list = new List<DataTable>(); list = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductId"].Value.ToString()); foreach (DataRow drUnitByProduct in list[0].Rows) { if (dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); } } decCurrentConversionRate = Convert.ToDecimal(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtRate"].Value.ToString()); if (cmbQuotationNo.Visible == true) { dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].HeaderCell.Value = ""; int intIndex = 0; int.TryParse(drowDetails["extra1"].ToString(), out intIndex); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; isValueChange = true; } for (int i = inRowIndex; i < dgvSalesOrder.Rows.Count; ++i) dgvSalesOrder["inRowIndex", i].Value = GetNextinRowIndex().ToString(); SerialNo(); TotalAmountCalculation(); isDoAfterGridFill = true; } } } catch (Exception ex) { MessageBox.Show("SO38: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// grid CellValueChanged for do the basic calculation and unit selection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProductBOM_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { CheckInvalidEntries(e); ProductCreationBll BllProductCreation = new ProductCreationBll(); TransactionsGeneralFillBll trstGnFill = new TransactionsGeneralFillBll(); if (e.RowIndex > -1) { if (e.ColumnIndex == dgvProductBOM.Columns["dgvcmbRawMaterial"].Index) { if (dgvProductBOM.Rows[e.RowIndex].Cells["dgvcmbRawMaterial"] != null) { dgvProductBOM.Rows[e.RowIndex].Cells["dgvtxtUnit"].Value = BllProductCreation.ProductUnit(Convert.ToDecimal(dgvProductBOM.Rows[e.RowIndex].Cells[1].Value)); List<DataTable> listObj = new List<DataTable>(); decimal decProductId = Convert.ToDecimal(dgvProductBOM.Rows[e.RowIndex].Cells["dgvcmbRawMaterial"].Value); listObj = trstGnFill.UnitViewAllByProductId(dgvProductBOM, decProductId.ToString(), e.RowIndex); DataRow drow = listObj[0].NewRow(); drow["unitName"] = string.Empty; drow["unitId"] = 0; listObj[0].Rows.InsertAt(drow, 0); DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductBOM.Rows[e.RowIndex].Cells["dgvcmbUnit"]); cell.DataSource = listObj[0]; cell.ValueMember = "unitId"; cell.DisplayMember = "unitName"; if (listObj[0].Rows[0][4] != null && listObj[0].Rows[0][4] != DBNull.Value) { dgvProductBOM.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(listObj[0].Rows[0][4].ToString()); } } } } } catch (Exception ex) { MessageBox.Show("PB:21" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To Get Default Product Values /// </summary> /// <param name="inindex"></param> /// <param name="decproductId"></param> public void ProductDefaultValues(int inindex, decimal decproductId) { try { UnitBll bllUnit = new UnitBll(); isValueChange = false; infoProduct = BllProductCreation.ProductView(decproductId); dgvProduct.Rows[inindex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[inindex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; TransactionsGeneralFillBll objTransactionsGeneralFillBll = new TransactionsGeneralFillBll(); List<DataTable> listObj = new List<DataTable>(); listObj = objTransactionsGeneralFillBll.UnitViewAllByProductId(dgvProduct, decproductId.ToString(), inindex); BatchBll BllBatch = new BatchBll(); BllBatch.BatchViewbyProductIdForComboFillInGrid(decproductId, dgvProduct, inindex); isValueChange = true; } catch (Exception ex) { MessageBox.Show("RO40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }