/// <summary> /// batch combo fill /// </summary> /// <param name="decProductId"></param> public void BatchUnderProductComboFill(decimal decProductId) { try { BatchBll BllBatch = new BatchBll(); List<DataTable> listBatch = new List<DataTable>(); listBatch = BllBatch.BatchViewbyProductIdForComboFill(decProductId); cmbBatch.DataSource = listBatch[0]; cmbBatch.ValueMember = "batchId"; cmbBatch.DisplayMember = "batchNo"; } catch (Exception ex) { MessageBox.Show("SRP10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Barcode Printing GrideFill /// </summary> public void BarcodePrintingGrideFill() { BatchBll BllBatch = new BatchBll(); try { if (cmbProductCode.SelectedIndex != -1) { if (cmbProductCode.SelectedValue.ToString() != "System.Data.DataRowView" && cmbProductCode.Text != "System.Data.DataRowView") { if (cmbBatch.SelectedIndex != -1) { if (cmbBatch.SelectedValue.ToString() != "System.Data.DataRowView" && cmbBatch.Text != "System.Data.DataRowView") { if (cmbPurchaseInvoiceNo.SelectedIndex != -1) { if (cmbPurchaseInvoiceNo.SelectedValue.ToString() != "System.Data.DataRowView" && cmbPurchaseInvoiceNo.Text != "System.Data.DataRowView") { dgvBarcodePrinting.Rows.Clear(); listBarcodePrinting = BllBatch.BarcodePrintingGrideFill(Convert.ToDecimal(cmbProductCode.SelectedValue.ToString()), Convert.ToDecimal(cmbBatch.SelectedValue.ToString()), Convert.ToDecimal(cmbPurchaseInvoiceNo.SelectedValue.ToString())); foreach (DataRow item in listBarcodePrinting[0].Rows) { dgvBarcodePrinting.Rows.Add(); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvProductCode"].Value = item["productCode"].ToString(); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvProductName"].Value = item["productName"].ToString(); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvBatch"].Value = item["batchNo"].ToString(); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvBarcode"].Value = item["barcode"].ToString(); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvCurrentStock"].Value = item["CurrentStock"].ToString(); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvMRP"].Value = Math.Round(Convert.ToDecimal(item["mrp"].ToString()), PublicVariables._inNoOfDecimalPlaces); dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvCopies"].Value = 0; dgvBarcodePrinting.Rows[dgvBarcodePrinting.Rows.Count - 1].Cells["dgvPurchaseRate"].Value = item["purchaseRate"].ToString(); } } } } } } } } catch (Exception ex) { MessageBox.Show("BCP9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Batch combobox fill /// </summary> public void BatchComboFill() { try { BatchBll BllBatch = new BatchBll(); List<DataTable> list = BllBatch.BatchViewAll(); cmbBatchNo.DisplayMember = "batchNo"; cmbBatchNo.ValueMember = "batchId"; DataRow dr = list[0].NewRow(); dr["batchId"] = -1; dr["batchNo"] = "All"; list[0].Rows.InsertAt(dr, 0); cmbBatchNo.DataSource = list[0]; cmbBatchNo.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(" PVSBR:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void dgvPhysicalStock_CellLeave(object sender, DataGridViewCellEventArgs e) { if (!isFromEditMode) { try { string strBarcode = string.Empty; string strProductCode = string.Empty; ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); BatchBll BllBatch = new BatchBll(); //PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP(); PhysicalStockBll BllPhysicalStock = new PhysicalStockBll(); if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvcmbBatch") { if (dgvPhysicalStock.CurrentRow.Cells["dgvcmbBatch"].Value != null) { if (Convert.ToString(dgvPhysicalStock.CurrentRow.Cells["dgvcmbBatch"].Value) != string.Empty && Convert.ToDecimal(dgvPhysicalStock.CurrentRow.Cells["dgvcmbBatch"].Value) != 0) { if (isGridValueChanged) { decBatchId = Convert.ToDecimal(dgvPhysicalStock.CurrentRow.Cells["dgvcmbBatch"].Value); strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId); isGridValueChanged = false; dgvPhysicalStock.CurrentRow.Cells["dgvtxtBarcode"].Value = strBarcode; isGridValueChanged = true; } } } } CheckColumnMissing(); } } catch (Exception ex) { MessageBox.Show("PS:45" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Batch all combofill for Grid /// </summary> public void batchAllComboFill() { try { BatchBll BllBatch = new BatchBll(); List<DataTable> listBatch = new List<DataTable>(); listBatch = BllBatch.BatchViewAll(); dgvcmbSalesInvoiceBatch.DataSource = listBatch[0]; dgvcmbSalesInvoiceBatch.ValueMember = "batchId"; dgvcmbSalesInvoiceBatch.DisplayMember = "batchNo"; } catch (Exception ex) { MessageBox.Show("SI: 29" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// BatchComboFill /// </summary> /// <param name="decProductId"></param> /// <param name="inRow"></param> /// <param name="inCol"></param> public void BatchComboFill(decimal decProductId, int inRow, int inCol) { try { List<DataTable> list = new List<DataTable>(); BatchBll BllBatch = new BatchBll(); list = BllBatch.BatchNamesCorrespondingToProduct(decProductId); DataGridViewComboBoxCell dgvcmbBatchCell = (DataGridViewComboBoxCell)dgvProduct.Rows[inRow].Cells[inCol]; dgvcmbBatchCell.DataSource = list[0]; dgvcmbBatchCell.ValueMember = "batchId"; dgvcmbBatchCell.DisplayMember = "batchNo"; } catch (Exception ex) { MessageBox.Show("DN30: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Get the Product details from the Product Search form /// </summary> /// <param name="frmProductSearchPopup"></param> /// <param name="decproductId"></param> /// <param name="decCurrentRowIndex"></param> public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex) { ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); BatchBll BllBatch = new BatchBll(); DataTable dtbl = new DataTable(); UnitConvertionBll bllUnitConversion = new UnitConvertionBll(); try { base.Show(); this.frmProductSearchPopupObj = frmProductSearchPopup; infoProduct = BllProductCreation.ProductView(decproductId); if (IsdgvConsuption) { int inRowcount = dgvConsumption.Rows.Count; dgvConsumption.Rows.Add(); for (int i = 0; i < inRowcount; i++) { if (i == decCurrentRowIndex) { dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductCode"].Value = infoProduct.ProductCode; strProductCode = infoProduct.ProductCode; ProductDetailsFillConsumption(strProductCode, i, "ProductCode"); } } } else { int inRowcount = dgvProduction.Rows.Count; dgvProduction.Rows.Add(); for (int i = 0; i < inRowcount; i++) { if (i == decCurrentRowIndex) { dgvProduction.Rows[i].Cells["dgvtxtProductionProductCode"].Value = infoProduct.ProductCode; strProductCode = infoProduct.ProductCode; ProductDetailsFillProduction(strProductCode, i, "ProductCode"); } } } frmProductSearchPopupObj.Close(); frmProductSearchPopupObj = null; } catch (Exception ex) { MessageBox.Show("SJ:92" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// fill Items into the purticular controls for Update or delete /// </summary> public void FillControls() { try { StandardRateInfo infoStandardRate = new StandardRateInfo(); standardRateBll BllStandaredRate = new standardRateBll(); infoStandardRate = BllStandaredRate.StandardRateView(decStandardRate); dtpFromDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableFrom.ToString()); dtpToDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableTo.ToString()); dtpFromDate.Text = infoStandardRate.ApplicableFrom.ToString(); dtpToDate.Text = infoStandardRate.ApplicableTo.ToString(); txtRate.Text = infoStandardRate.Rate.ToString(); decProduct = infoStandardRate.ProductId; decUnitId = infoStandardRate.UnitId; ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); infoProduct = BllProductCreation.ProductViewForStandardRate(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; decStandardRateId = infoStandardRate.StandardRateId; UnitInfo infoUnit = new UnitInfo(); UnitBll bllUnit = new UnitBll(); infoUnit = bllUnit.UnitView(decUnit); txtUnitName.Text = infoUnit.UnitName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; BatchInfo infoBatch = new BatchInfo(); BatchBll BllBatch = new BatchBll(); decBatchId = infoStandardRate.BatchId; infoBatch = BllBatch.BatchView(decBatchId); cmbBatch.SelectedValue = infoBatch.BatchId; } catch (Exception ex) { MessageBox.Show("SRP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void ProductDetailsFill(int inRowIndex, string strFillMode) { try { ProductInfo infoProduct = new ProductInfo(); BatchBll BllBatch = new BatchBll(); StockPostingBll BllStockPosting = new StockPostingBll(); //StockPostingSP spStockPosting = new StockPostingSP(); string strPrdCode = string.Empty; string strProductName = string.Empty; if (strFillMode == "ProductCode") { if (dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value as string != string.Empty) { strPrdCode = dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value.ToString(); } infoProduct = new ProductCreationBll().ProductViewByCode(strPrdCode); } if (strFillMode == "ProductName") { if (dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value != null && dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty) { strProductName = dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value.ToString(); } infoProduct = new ProductCreationBll().ProductViewByName(strProductName); } if (infoProduct.ProductId != 0) { dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; string strproductId = Convert.ToString(infoProduct.ProductId); dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId; UnitComboFill1(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; BatchComboFill(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = BllStockPosting.BatchViewByProductId(Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value)); string strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value.ToString())); dgvProduct.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = strBarcode; GridGodownComboFill(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbGodown"].ColumnIndex); dgvProduct.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = infoProduct.GodownId; RackComboFill1(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbRack"].ColumnIndex); dgvProduct.Rows[inRowIndex].Cells["dgvcmbRack"].Value = infoProduct.RackId; UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(strproductId); foreach (DataRow drUnitByProduct in ListObj[0].Rows) { if (dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[inRowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); } } dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate, PublicVariables._inNoOfDecimalPlaces); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString()); decimal decProductId = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString()); decimal decBatchId = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value.ToString()); getProductRate(inRowIndex, decProductId, decBatchId); } else { dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvcmbRack"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvProduct.Rows[inRowIndex].Cells["dgvtxtQty"].Value = string.Empty; } } catch (Exception ex) { MessageBox.Show("DN47:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for fill details in Purchase Return when coming from Register or Report /// </summary> public void FillRegisterOrReport() { try { btnSave.Text = "Update"; btnDelete.Enabled = true; txtReturnNo.ReadOnly = true; VoucherTypeBll BllVoucherType = new VoucherTypeBll(); List<DataTable> ListObjPurchaseReturnMaster = new List<DataTable>(); List<DataTable> ListObjPurchaseMasterViewById = new List<DataTable>(); UnitConvertionBll BllUnitConvertion = new UnitConvertionBll(); PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll(); BatchBll BllBatch = new BatchBll(); List<DataTable> ListObj = new List<DataTable>(); decimal decPurchaseReturnDetailsId = 0; decimal decTotalValue = 0; decimal decRegisterTotalAmount = 0; decimal decInvoiceNo = 0; ListObjPurchaseReturnMaster = BllPurchaseReturn.PurchaseReturnViewByPurchaseReturnMasterId(decPurchaseReturnMasterId); if (ListObjPurchaseReturnMaster[0].Rows.Count > 0) { txtReturnNo.Text = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo"].ToString(); strReturnNo = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo"].ToString(); strVoucherNo = ListObjPurchaseReturnMaster[0].Rows[0]["voucherNo"].ToString(); decPurchaseReturnSuffixPrefixId = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["suffixPrefixId"].ToString()); decPurchaseReturnVoucherTypeId = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId"].ToString()); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); infoVoucherType = BllVoucherType.VoucherTypeView(decPurchaseReturnVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPurchaseReturnVoucherTypeId); txtReturnNo.ReadOnly = (isAutomatic) ? true : false; decPurchaseReturnTypeId = decPurchaseReturnVoucherTypeId; dtpDate.Text = ListObjPurchaseReturnMaster[0].Rows[0]["date"].ToString(); cmbCashOrParty.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["ledgerId"].ToString(); cmbPurchaseAccount.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["purchaseAccount"].ToString(); txtTransportationCompany.Text = ListObjPurchaseReturnMaster[0].Rows[0]["transportationCompany"].ToString(); txtNarration.Text = ListObjPurchaseReturnMaster[0].Rows[0]["narration"].ToString(); txtLrlNo.Text = ListObjPurchaseReturnMaster[0].Rows[0]["lrNo"].ToString(); cmbCurrency.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["exchangeRateId"].ToString(); if (ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString() != string.Empty) { cmbVoucherType.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString(); } else { cmbVoucherType.SelectedValue = 0; } cmbInvoiceNo.Text = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo1"].ToString(); if (ListObjPurchaseReturnMaster[0].Rows[0]["totalAmount1"].ToString() != string.Empty) { decRegisterTotalAmount = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["totalAmount"].ToString()); } txtTotalAmount.Text = ListObjPurchaseReturnMaster[0].Rows[0]["totalAmount"].ToString(); if (ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"].ToString() != string.Empty && Convert.ToInt32(ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"]) != 0) { InvoiceNoComboFillInRegister(); cmbInvoiceNo.SelectedValue = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"].ToString()); decInvoiceNo = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()); ListObjPurchaseMasterViewById = BllPurchaseReturn.PurchaseReturnMasterViewByPurchaseMasterId(Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"].ToString())); } else { cmbInvoiceNo.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"]; } strInvoiceNo = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo1"].ToString(); decimal decDiscnt = Math.Round(Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces); ListObj = BllPurchaseReturn.PurchaseReturnDetailsViewByMasterId(decPurchaseReturnMasterId); dgvPurchaseReturn.Rows.Clear(); for (int i = 0; i < ListObj[0].Rows.Count; i++) { isAmountcalc = false; dgvPurchaseReturn.Rows.Add(); int ini = dgvPurchaseReturn.Rows.Count; decPurchaseReturnDetailsId = Convert.ToDecimal(ListObj[0].Rows[i]["purchaseReturnDetailsId"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtSlNo"].Value = ListObj[0].Rows[i]["slno"].ToString(); dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString(); dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductName"].Value = ListObj[0].Rows[i]["productName"].ToString(); dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value = ListObj[0].Rows[i]["productId"].ToString(); decimal decProductId = Convert.ToDecimal(dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value.ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtConversionRate"].Value = BllUnitConvertion.UnitConversionRateByUnitConversionId(decimal.Parse(ListObj[0].Rows[i]["unitConversionId"].ToString())); dgvPurchaseReturn.Rows[i].Cells["dgvtxtUnitConversionId"].Value = decimal.Parse(ListObj[0].Rows[i]["unitConversionId"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtqty"].Value = (ListObj[0].Rows[i]["qty"].ToString() != string.Empty) ? Convert.ToDecimal(ListObj[0].Rows[i]["qty"].ToString()) : 0; if (ListObj[0].Rows[i]["unitName"].ToString() != string.Empty) { UnitComboFill(decProductId, dgvPurchaseReturn.Rows[i].Index, dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].Value = ListObj[0].Rows[i]["unitName"].ToString(); } else { dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].Value = "NA"; } dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].ReadOnly = (ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString() != string.Empty) ? true : false; if (ListObj[0].Rows[i]["godownId"].ToString() != string.Empty) { dgvPurchaseReturn.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["godownId"].ToString()); } else { dgvPurchaseReturn.Rows[i].Cells["dgvcmbGodown"].Value = "NA"; } if (ListObj[0].Rows[i]["rackId"].ToString() != string.Empty) { dgvPurchaseReturn.Rows[i].Cells["dgvCmbRack"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["rackId"].ToString()); } else { dgvPurchaseReturn.Rows[i].Cells["dgvCmbRack"].Value = "NA"; } if (ListObj[0].Rows[i]["batchId"].ToString() != string.Empty) { BatchComboFill(decProductId, dgvPurchaseReturn.Rows[i].Index, dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].ColumnIndex); dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString()); } else { dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value = "NA"; } if (ListObj[0].Rows[i]["taxId"].ToString() != string.Empty && ListObj[0].Rows[i]["taxId"].ToString() != "NA") { dgvPurchaseReturn.Rows[i].Cells["dgvcmbTax"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["taxId"].ToString()); } else { dgvPurchaseReturn.Rows[i].Cells["dgvcmbTax"].Value = "NA"; } if (ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString() != string.Empty) { dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].ReadOnly = true; } dgvPurchaseReturn.Rows[i].Cells["dgvtxtPurchaseDetailsId"].Value = ListObj[0].Rows[i]["purchaseDetailsId"].ToString(); dgvPurchaseReturn.Rows[i].Cells["dgvtxtbarcode"].Value = ListObj[0].Rows[i]["barcode"].ToString(); dgvPurchaseReturn.Rows[i].Cells["dgvtxtPurchaseReturnDetailsId"].Value = decPurchaseReturnDetailsId; decimal decRate = Convert.ToDecimal(ListObj[0].Rows[i]["rate"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtrate"].Value = Math.Round(decRate, PublicVariables._inNoOfDecimalPlaces); decimal decGross = Convert.ToDecimal(ListObj[0].Rows[i]["grossAmount"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtgrossValue"].Value = Math.Round(decGross, PublicVariables._inNoOfDecimalPlaces); decimal decDis = Convert.ToDecimal(ListObj[0].Rows[i]["discount"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtdiscount"].Value = Math.Round(decDis, PublicVariables._inNoOfDecimalPlaces); decimal decNet = Convert.ToDecimal(ListObj[0].Rows[i]["netAmount"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtNetAmount"].Value = Math.Round(decNet, PublicVariables._inNoOfDecimalPlaces); decimal decTax = Convert.ToDecimal(ListObj[0].Rows[i]["taxAmount"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxttaxAmount"].Value = Math.Round(decTax, PublicVariables._inNoOfDecimalPlaces); decimal decTotal = Convert.ToDecimal(ListObj[0].Rows[i]["amount"].ToString()); dgvPurchaseReturn.Rows[i].Cells["dgvtxtAmount"].Value = Math.Round(decTotal, PublicVariables._inNoOfDecimalPlaces); decTotalValue = decTotalValue + Convert.ToDecimal(ListObj[0].Rows[i]["amount"].ToString()); if (cmbInvoiceNo.Visible == true) { dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 1].ReadOnly = true; } } lblTaxAmount.Text = Math.Round(decimal.Parse(ListObjPurchaseReturnMaster[0].Rows[0]["totalTax"].ToString()), 2).ToString(); ; txtTotalAmount.Text = decTotalValue.ToString(); txtBillDiscount.Text = decDiscnt.ToString(); DGVPurchaseReturnTaxFill(); DGVTaxCombofill(); Calculate(); isAmountcalc = true; } } catch (Exception ex) { MessageBox.Show("PR:55" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to add the products to grid /// </summary> public void AddToGrid() { BatchBll BllBatch = new BatchBll(); GodownBll BllGodown = new GodownBll(); try { SettingsBll BllSettings = new SettingsBll(); if (txtProductCode.Text.Trim() == null && txtProductCode.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter product code"); txtProductCode.Focus(); } else if (cmbItem.SelectedIndex == -1 && cmbItem.SelectedValue == null) { Messages.InformationMessage("Select a product"); cmbItem.Focus(); } else if (Convert.ToDecimal(txtQuantity.Text.Trim()) <= 0 || txtQuantity.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter quantity"); txtQuantity.Focus(); } else if (cmbUnit.SelectedValue == null) { Messages.InformationMessage("Select a unit"); cmbUnit.Focus(); } else if (BllSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && decimal.Parse(txtRate.Text.Trim()) <= 0 || txtRate.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter rate"); txtRate.Focus(); } else { int inCurrentRowIndex = new int(); bool isExecutef = false; if (rowIdToEdit == 0) { dgvPointOfSales.Rows.Add(); inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1; isExecutef = true; } else { for (int i = 0; i < dgvPointOfSales.Rows.Count; ++i) { if (dgvPointOfSales.Rows[i].Cells["rowId"].Value.ToString() == rowIdToEdit.ToString()) { isExecutef = true; inCurrentRowIndex = i; break; } } } if (!isExecutef) { dgvPointOfSales.Rows.Add(); inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1; } ProductInfo infoProduct = new ProductInfo(); BatchInfo infoBatch = new BatchInfo(); RackInfo infoRack = new RackInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); UnitConvertionInfo InfoUnitConvertion = new UnitConvertionInfo(); infoProduct = BllProductCreation.ProductView(decProductId); decimal dcProductBatch = BllBatch.BatchIdViewByProductId(decProductId); InfoUnitConvertion = new UnitConvertionBll().UnitViewAllByProductId(decProductId); infoBatch = BllBatch.BatchView(dcProductBatch); decimal dcGodownId = infoProduct.GodownId; GodownInfo infoGodown = new GodownInfo(); infoGodown = BllGodown.GodownView(dcGodownId); decimal dcRackId = infoProduct.RackId; infoRack = new RackBll().RackView(dcRackId); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = txtProductCode.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = cmbItem.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtQuantity"].Value = txtQuantity.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnit"].Value = cmbUnit.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = txtRate.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGrossValue"].Value = txtGrossValue.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxPercentage"].Value = cmbTax.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxAmount"].Value = txtTaxAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtNetAmount"].Value = txtNetAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtDiscount"].Value = txtDiscountAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTotalAmount"].Value = txtAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxttaxid"].Value = Convert.ToDecimal(cmbTax.SelectedValue); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchId"].Value = dcProductBatch; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackId"].Value = infoProduct.RackId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownId"].Value = infoProduct.GodownId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnitId"].Value = Convert.ToDecimal(cmbUnit.SelectedValue); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtunitconversionId"].Value = InfoUnitConvertion.UnitconvertionId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = txtBarcode.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchno"].Value = infoBatch.BatchNo; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownName"].Value = infoGodown.GodownName; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackName"].Value = infoRack.RackName; TotalAmountCalculation(); ClearGroupbox(); dgvPointOfSales.CurrentCell = dgvPointOfSales[0, dgvPointOfSales.Rows.Count - 1]; txtBarcode.Focus(); } } catch (Exception ex) { MessageBox.Show("POS:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid CellEndEdit for product details fill to curresponding row in grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPurchaseReturn_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { string strBarcode2 = string.Empty; decimal decBatchId2 = 0; BatchBll BllBatch = new BatchBll(); RackBll BllRack = new RackBll(); PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll(); ProductCreationBll BllProductCreation = new ProductCreationBll(); if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtproductName") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value.ToString().Trim() != string.Empty) { ProductInfo infoProduct = BllProductCreation.ProductViewByName(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value.ToString()); if (infoProduct.ProductCode != null && infoProduct.ProductCode != string.Empty) { FillProductDetails(infoProduct.ProductCode.ToString(), e.RowIndex); } else { StringEmptyDetailsInGrid(); } } else { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value = string.Empty; } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtproductCode") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value.ToString().Trim() != string.Empty) { ProductInfo infoProduct = BllProductCreation.ProductViewByCode(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value.ToString()); if (infoProduct.ProductName != null && infoProduct.ProductCode != string.Empty) { FillProductDetails(infoProduct.ProductCode.ToString(), e.RowIndex); } else { StringEmptyDetailsInGrid(); } } else { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value = string.Empty; } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtbarcode") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value.ToString().Trim() != string.Empty) { string strBarcode = dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value.ToString(); decBatchId = BllProductCreation.BatchIdByPartNoOrBarcode(strBarcode, strBarcode); if (decBatchId > 0) { List<DataTable> listObjBatchName = new List<DataTable>(); listObjBatchName = BllProductCreation.ProductCodeAndBarcodeByBatchId(decBatchId); dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value = listObjBatchName[0].Rows[0]["productCode"].ToString(); if (listObjBatchName[0].Rows[0]["barcode"].ToString() != null && listObjBatchName[0].Rows[0]["barcode"].ToString() != string.Empty) { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value = listObjBatchName[0].Rows[0]["barcode"].ToString(); } decimal batchId = BllBatch.BatchViewByBarcode(strBarcode); dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = batchId; FillProductDetails(listObjBatchName[0].Rows[0]["productCode"].ToString(), e.RowIndex); } else { StringEmptyDetailsInGrid(); } } else { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value = string.Empty; } } if (e.ColumnIndex == dgvPurchaseReturn.Columns["dgvcmbUnit"].Index) { if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { if ((dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null) && (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)) { UnitConversionCalc(e.RowIndex); AmountCalculation("dgvtxtqty", e.RowIndex); } } } if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtqty" && isAmountcalc) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) != 0) { if (cmbInvoiceNo.SelectedValue == null || cmbInvoiceNo.SelectedValue.ToString() == string.Empty) { AmountCalculation("dgvtxtqty", e.RowIndex); } else { List<DataTable> ListObj= BllPurchaseInvoice.PurchaseDetailsViewByPurchaseMasterIdWithRemaining(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()), decPurchaseReturnMasterId, decPurchaseReturnVoucherTypeId); if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtPurchaseDetailsId"].Value != null) { if (Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtPurchaseDetailsId"].Value.ToString()) > 0) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null) { if (Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) > Convert.ToDecimal(ListObj[0].Rows[e.RowIndex]["qty"].ToString())) { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value = Math.Round(Convert.ToDecimal(ListObj[0].Rows[e.RowIndex]["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces); } } } } AmountCalculation("dgvtxtqty", e.RowIndex); } } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtrate" && isAmountcalc) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) != 0) { AmountCalculation("dgvtxtrate", e.RowIndex); } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtdiscount") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtdiscount"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtdiscount"].Value.ToString().Trim() != string.Empty && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtDiscount"].Value.ToString().Trim() != "0") { AmountCalculation("dgvtxtrate", e.RowIndex); } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbTax" && isAmountcalc) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbTax"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbTax"].Value.ToString() != string.Empty) { AmountCalculation("dgvtxtrate", e.RowIndex); } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbBatch") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId2 = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvcmbBatch"].Value); strBarcode2 = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId2); dgvPurchaseReturn.CurrentRow.Cells["dgvtxtbarcode"].Value = strBarcode2; } } CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("PR:80" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Fill Product Details in grid /// </summary> /// <param name="strProductCode"></param> /// <param name="rowIndex"></param> private void FillProductDetails(string strProductCode, int rowIndex) { try { ProductInfo infoProductFill = new ProductInfo(); infoProductFill = new ProductCreationBll().ProductViewByCode(strProductCode); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); BatchBll BllBatch = new BatchBll(); ProductCreationBll BllProductCreation = new ProductCreationBll(); StockPostingBll BllStockPosting = new StockPostingBll(); List<DataTable> list = new List<DataTable>(); decimal decCurrentConversionRate = 0; if (infoProductFill.ProductId != 0) { dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductId"].Value = infoProductFill.ProductId; dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductCode"].Value = infoProductFill.ProductCode; dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductName"].Value = infoProductFill.ProductName; dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbGodown"].Value = infoProductFill.GodownId; dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbRack"].Value = infoProductFill.RackId; UnitComboFill(infoProductFill.ProductId, rowIndex, dgvPurchaseReturn.CurrentRow.Cells["dgvcmbUnit"].ColumnIndex); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbUnit"].Value = infoProductFill.UnitId; dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtrate"].Value = Math.Round(infoProductFill.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(new UnitConvertionBll().UnitconversionIdViewByUnitIdAndProductId(infoProductFill.UnitId, infoProductFill.ProductId)); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtConversionRate"].Value = bllUnitConvertion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtUnitConversionId"].Value.ToString())); BatchComboFill(infoProductFill.ProductId, rowIndex, dgvPurchaseReturn.CurrentRow.Cells["dgvcmbBatch"].ColumnIndex); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbBatch"].Value = BllStockPosting.BatchViewByProductId(Convert.ToDecimal(dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductId"].Value)); list = bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoProductFill.UnitId, infoProductFill.ProductName); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtUnitConversionId"].Value = list[0].Rows[0]["unitconversionId"].ToString(); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtConversionRate"].Value = list[0].Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); //dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtqty"].Value = 0; dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbTax"].Value = infoProductFill.TaxId; AmountCalculation("dgvtxtqty", rowIndex); decimal decProdtId = infoProductFill.ProductId; decBatchId = BllStockPosting.BatchViewByProductId(decProdtId); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbBatch"].Value = decBatchId; string strBarcode = Convert.ToString(BllProductCreation.BarcodeViewByBatchId(decBatchId)); dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtbarcode"].Value = strBarcode; if (dgvPurchaseReturn.Rows[rowIndex + 1].Cells["dgvtxtproductCode"].Selected == true) { dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtqty"].Selected = true; dgvPurchaseReturn.Rows[rowIndex + 1].Selected = false; dgvPurchaseReturn.Rows[rowIndex].HeaderCell.Value = "X"; dgvPurchaseReturn.Rows[rowIndex].HeaderCell.Style.ForeColor = Color.Red; } } } catch (Exception ex) { MessageBox.Show("PR:22" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the product details in dataGridView from productCreationPopup /// </summary> /// <param name="productcreation"></param> /// <param name="decproductId"></param> /// <param name="decCurrentRowIndex"></param> public void productDetailsFillFromProductCreation(frmProductCreation productcreation, decimal decproductId, decimal decCurrentRowIndex) { try { decimal decCurrentConversionRate = 0; UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> list = new List<DataTable>(); BatchBll BllBatch = new BatchBll(); ProductInfo infoProductFill = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); int inI = dgvPurchaseReturn.CurrentRow.Index; if (inI == dgvPurchaseReturn.Rows.Count - 1) { dgvPurchaseReturn.Rows.Add(); } if (decproductId != 0) { infoProduct = BllProductCreation.ProductView(decproductId); SerialNo(); dgvPurchaseReturn.Rows[inI].Cells["dgvtxtproductCode"].Value = infoProduct.ProductCode; dgvPurchaseReturn.Rows[inI].Cells["dgvtxtproductId"].Value = decproductId.ToString(); dgvPurchaseReturn.Rows[inI].Cells["dgvtxtproductName"].Value = infoProduct.ProductName; dgvPurchaseReturn.Rows[inI].Cells["dgvcmbGodown"].Value = infoProduct.GodownId; dgvPurchaseReturn.Rows[inI].Cells["dgvcmbRack"].Value = infoProduct.RackId; UnitComboFill(infoProduct.ProductId, dgvPurchaseReturn.CurrentRow.Index, dgvPurchaseReturn.CurrentRow.Cells["dgvcmbUnit"].ColumnIndex); dgvPurchaseReturn.Rows[inI].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; dgvPurchaseReturn.Rows[inI].Cells["dgvtxtrate"].Value = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); dgvPurchaseReturn.Rows[inI].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(new UnitConvertionBll().UnitconversionIdViewByUnitIdAndProductId(infoProduct.UnitId, infoProduct.ProductId)); dgvPurchaseReturn.CurrentRow.Cells["dgvtxtConversionRate"].Value = bllUnitConvertion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(dgvPurchaseReturn.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString())); BatchComboFill(decproductId, inI, dgvPurchaseReturn.Rows[inI].Cells["dgvcmbBatch"].ColumnIndex); dgvPurchaseReturn.Rows[inI].Cells["dgvcmbBatch"].Value = BllBatch.BatchIdViewByProductId(decproductId); RackComboFill(infoProduct.GodownId, inI, dgvPurchaseReturn.Rows[inI].Cells["dgvcmbRack"].ColumnIndex); dgvPurchaseReturn.Rows[inI].Cells["dgvtxtqty"].Value = "0"; dgvPurchaseReturn.Rows[inI].Cells["dgvtxtbarcode"].Value = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvPurchaseReturn.Rows[inI].Cells["dgvcmbBatch"].Value.ToString())); list = bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName); dgvPurchaseReturn.Rows[inI].Cells["dgvtxtConversionRate"].Value = list[0].Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvtxtConversionRate"].Value.ToString()); AmountCalculation("dgvtxtqty", inI); dgvPurchaseReturn.Rows[inI].Cells["dgvtxtqty"].Selected = true; dgvPurchaseReturn.Rows[inI + 1].Selected = false; } dgvPurchaseReturn.Rows[inI].HeaderCell.Value = "X"; dgvPurchaseReturn.Rows[inI].HeaderCell.Style.ForeColor = Color.Red; } catch (Exception ex) { MessageBox.Show("PR:24" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the fields while user double click on the datagridview /// </summary> public void FillControls() { try { PriceListInfo infoPricelist = new PriceListInfo(); PriceListBll BllPriceList = new PriceListBll(); infoPricelist.PricelistId = decpriceListId; infoPricelist = BllPriceList.PriceListView(decpriceListId); txtRate.Text = infoPricelist.Rate.ToString(); ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); infoProduct = BllProductCreation.PriceListPopUpView(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; BatchInfo infobatch = new BatchInfo(); // BatchSP spBatch = new BatchSP(); BatchBll BllBatch = new BatchBll(); infobatch = BllBatch.BatchView(decBatchId); cmbBatch.SelectedValue = infobatch.BatchId; UnitInfo infoUnit = new UnitInfo(); UnitBll bllUnit = new UnitBll(); infoUnit = bllUnit.UnitView(decUnitId); txtUnitName.Text = infoUnit.UnitName; PricingLevelInfo infoPricingLevel = new PricingLevelInfo(); PricingLevelBll BllPricingLevel = new PricingLevelBll(); infoPricingLevel = BllPricingLevel.PricingLevelView(decPriceLevelId); txtPricingLevel.Text = infoPricingLevel.PricinglevelName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; txtPricingLevel.ReadOnly = true; } catch (Exception ex) { MessageBox.Show("PLP9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// dgvProduction grid cell valuechange event to calculate the basic functions and calculation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduction_CellValueChanged(object sender, DataGridViewCellEventArgs e) { try { if (IsSetGridValueChange) { if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvProduction.RowCount > 1) { if (dgvProduction.Columns[e.ColumnIndex].Name == "dgvcmbProductionunitId") { if (dgvProduction.Rows[e.RowIndex].Cells["dgvcmbProductionunitId"].Value != null && dgvProduction.Rows[e.RowIndex].Cells["dgvcmbProductionunitId"].Value.ToString() != string.Empty) { UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> listUnitByProduct = new List<DataTable>(); listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionProductId"].Value.ToString()); foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduction.Rows[e.RowIndex].Cells["dgvcmbProductionunitId"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionunitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); decimal decNewConversionRate = Convert.ToDecimal(dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionConversionRate"].Value.ToString()); decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate; dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionRate"].Value = Math.Round(decNewRate, 2); } } TotalAmountCalculationProduction("", e.RowIndex); } } if (e.ColumnIndex == dgvProduction.Columns["dgvcmbProductionBatch"].Index) { BatchBll BllBatch = new BatchBll(); decimal decBatchId = 0; string strBarcode = string.Empty; if (dgvProduction.CurrentRow.Cells["dgvtxtProductionProductId"].Value != null) { if (dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value != null) { if (dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value.ToString() != string.Empty && dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value.ToString() != "0") { decBatchId = Convert.ToDecimal(dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value); strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId); dgvProduction.CurrentRow.Cells["dgvtxtProductionBarcode"].Value = strBarcode; } } } } } } } } catch (Exception ex) { MessageBox.Show("SJ:81" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Sales grid cell leave event to calculate the basic functions and calculation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvSalesInvoice_CellLeave(object sender, DataGridViewCellEventArgs e) { if (IsSetGridValueChange == true) { BatchBll BllBatch = new BatchBll(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List< DataTable > listUnitConversion = new List<DataTable>(); decimal decBatchId = 0; string strBarcode = string.Empty; try { if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value != null) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.RowCount > 1) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { try { if (decimal.Parse(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) > 0) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null) { if (decimal.Parse(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()) > decimal.Parse(dtblDeliveryNoteDetails.Rows[e.RowIndex]["qty"].ToString())) { dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value = dtblDeliveryNoteDetails.Rows[e.RowIndex]["qty"].ToString(); if (decDeliveryNoteQty < decimal.Parse(dtblDeliveryNoteDetails.Rows[e.RowIndex]["qty"].ToString())) { dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value = decDeliveryNoteQty; decDeliveryNoteQty = 0; } } } } } catch (Exception) { } } if (dgvSalesInvoice.Columns[e.ColumnIndex].Name == "dgvtxtSalesInvoicembUnitName") { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoicembUnitName"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString() != string.Empty) { UnitConversionCalc(e.RowIndex); } } if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { DiscountCalculation(e.RowIndex, e.ColumnIndex); } if (dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbSalesInvoiceTaxName" || dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceGrossValue" || dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceDiscountPercentage") { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Visible) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Value != null && (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceNetAmount"].Value != null || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value != null)) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString() != string.Empty && (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString() != string.Empty)) { { taxAndGridTotalAmountCalculation(e.RowIndex); } } } } else { taxAndGridTotalAmountCalculation(e.RowIndex); } } if (dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceRate" || dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceQty") { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value != null) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString() != string.Empty) { { GrossValueCalculation(e.RowIndex); } } } } } if (e.ColumnIndex == dgvSalesInvoice.Columns["dgvcmbSalesInvoiceBatch"].Index) { if (dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value != null) { if (dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty && dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != "0") { decBatchId = Convert.ToDecimal(dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId); dgvSalesInvoice.CurrentRow.Cells["dgvtxtSalesInvoiceBarcode"].Value = strBarcode; if (dgvSalesInvoice.CurrentRow.Cells["dgvtxtSalesInvoiceProductId"].Value != null) // here get product rate for sales(standard rate) { getProductRate(e.RowIndex, Convert.ToDecimal(dgvSalesInvoice.CurrentRow.Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()), decBatchId); UnitConversionCalc(e.RowIndex); } } } } } } if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceConversionRate"].Value != null) { decCurrentConversionRate = Convert.ToDecimal(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceConversionRate"].Value.ToString()); } if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value != null) { decCurrentRate = Convert.ToDecimal(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); } } CheckInvalidEntries(e); SiGridTotalAmountCalculation(); CalculateAmountFromGrid(e.RowIndex, e, e.ColumnIndex); } } catch (Exception ex) { MessageBox.Show("SI: 105" + 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> /// Function to fil Controls based on the barcode /// </summary> /// <param name="strBarcode"></param> public void FillControlsByBarcode(string strBarcode) { try { BatchInfo infoBatch = new BatchInfo(); BatchBll BllBatch = new BatchBll(); PriceListInfo InfoPriceList = new PriceListInfo(); PriceListBll BllPriceList = new PriceListBll(); infoBatch = BllBatch.BatchAndProductViewByBarcode(strBarcode); cmbBatch.Text = infoBatch.BatchNo; decProductId = infoBatch.ProductId; decBatchId = infoBatch.BatchId; InfoPriceList = BllPriceList.PriceListViewByBatchIdORProduct(decBatchId); ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); infoProduct = BllProductCreation.ProductView(decProductId); txtProductCode.Text = infoProduct.ProductCode; string strProductCode = infoProduct.ProductCode; isFromBarcode = true; cmbItem.Text = infoProduct.ProductName; isFromBarcode = false; cmbGodown.SelectedValue = infoProduct.GodownId; cmbRack.SelectedValue = infoProduct.RackId; UnitComboFill(); UnitInfo infoUnit = new UnitInfo(); infoUnit = new UnitBll().unitVieWForStandardRate(decProductId); cmbUnit.SelectedValue = infoUnit.UnitId; if (InfoPriceList.PricinglevelId != 0) { cmbPricingLevel.SelectedValue = InfoPriceList.PricinglevelId; } else { cmbPricingLevel.SelectedIndex = 0; } ComboTaxFill(); cmbTax.SelectedValue = infoProduct.TaxId; if (txtProductCode.Text.Trim() != string.Empty && cmbItem.SelectedIndex != -1) { decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces; decimal dcRate = BllProductCreation.ProductRateForSales(decProductId, Convert.ToDateTime(txtDate.Text), decBatchId, decNodecplaces); txtRate.Text = dcRate.ToString(); try { if (decimal.Parse(txtQuantity.Text) == 0) txtQuantity.Text = "1"; } catch { txtQuantity.Text = "1"; } txtQuantity.Focus(); } else { txtRate.Text = string.Empty; } } catch (Exception ex) { MessageBox.Show("POS:25" + 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 use the Batch Combo Fill based on the product /// </summary> public void batchcombofill() { try { BatchBll BllBatch = new BatchBll(); List<DataTable> listBatch = new List<DataTable>(); listBatch = BllBatch.BatchNoViewByProductId(decProductId); cmbBatch.DataSource = listBatch[0]; cmbBatch.ValueMember = "batchId"; cmbBatch.DisplayMember = "batchNo"; } catch (Exception ex) { MessageBox.Show("POS:19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for BatchComboFill /// </summary> /// <param name="cmbBatch"></param> public void BatchComboFill(ComboBox cmbBatch) { BatchBll BllBatch = new BatchBll(); try { if (cmbProductCode.SelectedIndex != -1) { if (cmbProductCode.SelectedValue.ToString() != "System.Data.DataRowView" && cmbProductCode.Text != "System.Data.DataRowView") { cmbBatch.Enabled = true; BllBatch.BatchViewAllByProductCodeForBarcodePrinting(Convert.ToDecimal(cmbProductCode.SelectedValue.ToString()), cmbBatch, true); } } } catch (Exception ex) { MessageBox.Show("BCP10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for call from productRegister /// </summary> public void CallFromProductRegister(decimal decId, frmProductRegister frmProRegister) { try { base.Show(); this.frmProductRegisterObj = frmProRegister; frmProductRegisterObj.Enabled = false; ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); BatchInfo infoBatch = new BatchInfo(); StockPostingBll BllStockPosting = new StockPostingBll(); BatchBll BllBatch = new BatchBll(); UnitBll bllUnit = new UnitBll(); List<DataTable> ListObj = new List<DataTable>(); decProductIdForEdit = decId; infoProduct = BllProductCreation.ProductView(decId); strUnitNameForGrid = bllUnit.UnitName(infoProduct.UnitId); btnSave.Text = "Update"; btnDelete.Enabled = true; txtName.Text = infoProduct.ProductName; txtProductCode.Text = infoProduct.ProductCode; cmbGroup.SelectedValue = infoProduct.GroupId; cmbBrand.SelectedValue = infoProduct.BrandId; cmbUnit.SelectedValue = infoProduct.UnitId; if (BllProductCreation.ProductReferenceCheck(decId)) { cmbUnit.Enabled = false; } decUnitIdForUpdate = infoProduct.UnitId; cmbSize.SelectedValue = infoProduct.SizeId; cmbModalNo.SelectedValue = infoProduct.ModelNoId; cmbTax.SelectedValue = infoProduct.TaxId; cmbTaxApplicableOn.SelectedItem = infoProduct.TaxapplicableOn; txtPurchaseRate.Text = infoProduct.PurchaseRate.ToString(); txtSalesRate.Text = infoProduct.SalesRate.ToString(); txtMrp.Text = infoProduct.Mrp.ToString(); txtMinimumStock.Text = infoProduct.MinimumStock.ToString(); txtMaximumStock.Text = infoProduct.MaximumStock.ToString(); txtReorderLevel.Text = infoProduct.ReorderLevel.ToString(); txtPartNo.Text = infoProduct.PartNo; cmbDefaultGodown.SelectedValue = infoProduct.GodownId; cmbDefaultRack.SelectedValue = infoProduct.RackId; if (infoProduct.IsBom) { cmbBom.SelectedIndex = 1; isBomFromRegister = true; } if (infoProduct.Ismultipleunit) { cmbMultipleUnit.SelectedIndex = 1; isMulUnitFromRgister = true; } if (infoProduct.Isopeningstock) { isOpeningStockForUpdate = true; OpeningStockGridFill(); } if (infoProduct.IsallowBatch) { OpeningStockGridWithBathFill(); } else { cmbAllowBatch.SelectedIndex = 0; txtPartNo.Text = BllBatch.PartNoReturn(decProductIdForEdit); } if (infoProduct.Ismultipleunit) { cmbMultipleUnit.SelectedIndex = 1; } else { cmbMultipleUnit.SelectedIndex = 0; } if (infoProduct.IsBom) { cmbBom.SelectedIndex = 1; } else { cmbBom.SelectedIndex = 0; } if (infoProduct.Isopeningstock) { cmbOpeningStock.SelectedIndex = 1; } else { cmbOpeningStock.SelectedIndex = 0; } if (infoProduct.IsActive) { cbxActive.Checked = true; } else { cbxActive.Checked = false; } if (infoProduct.IsshowRemember) { cbxReminder.Checked = true; } else { cbxReminder.Checked = false; } txtNarration.Text = infoProduct.Narration; } catch (Exception ex) { MessageBox.Show("PC:63" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill Product Details Curresponding Product code or Barcode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e) { BatchBll BllBatch = new BatchBll(); try { ProductInfo infoProduct = new ProductInfo(); List<DataTable> listObj = new List<DataTable>(); isValueChange = false; isDoAfterGridFill = false; decimal DefaultRate = 0; if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtBarcode") { string strBCode = string.Empty; if (!dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].ReadOnly && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString() != string.Empty) { strBCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString(); } listObj = new ProductCreationBll().ProductDetailsCoreespondingToBarcode(strBCode); if (listObj[0].Rows.Count > 0) { foreach (DataRow RowDetails in listObj[0].Rows) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value = RowDetails["productId"].ToString(); decimal decProductId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString()); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = RowDetails["productCode"].ToString(); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = RowDetails["productName"].ToString(); UnitComboFill1(Convert.ToDecimal(RowDetails["productId"].ToString()), e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(RowDetails["unitId"].ToString()); BatchComboFill(Convert.ToDecimal(RowDetails["productId"].ToString()), e.RowIndex, Convert.ToInt32(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].ColumnIndex)); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(RowDetails["batchId"].ToString()); GridGodownComboFill(Convert.ToDecimal(RowDetails["productId"].ToString()), e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].ColumnIndex); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(RowDetails["godownId"].ToString()); RackComboFill1(Convert.ToDecimal(RowDetails["godownId"].ToString()), e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvcmbRack"].ColumnIndex); dgvProduct.Rows[e.RowIndex].Cells["dgvcmbRack"].Value = Convert.ToDecimal(RowDetails["rackId"].ToString()); decimal decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString()); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString()); foreach (DataRow drUnitByProduct in ListObj[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()); } } dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(Convert.ToDecimal(RowDetails["salesRate"].ToString()), PublicVariables._inNoOfDecimalPlaces); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString()); getProductRate(e.RowIndex, decProductId, decBatchId); } } else { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbRack"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty; } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductCode") { isValueChange = false; isDoAfterGridFill = false; ProductDetailsFill(dgvProduct.CurrentRow.Index, "ProductCode"); } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductName") { isValueChange = false; isDoAfterGridFill = false; ProductDetailsFill(dgvProduct.CurrentRow.Index, "ProductName"); } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty) { DefaultRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value); } } } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); isValueChange = true; isDoAfterGridFill = true; CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("DN68:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> ///Function for ReturnFromProductCreationPopup /// </summary> public void ReturnFromProductCreation(decimal decProductId) { ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); BatchBll BllBatch = new BatchBll(); List<DataTable> list = new List<DataTable>(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); try { this.Enabled = true; this.BringToFront(); int inI = dgvProduct.CurrentRow.Index; if (inI == dgvProduct.Rows.Count - 1) { dgvProduct.Rows.Add(); } if (decProductId != 0) { infoProduct = BllProductCreation.ProductView(decProductId); dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode.ToString(); dgvProduct.Rows[inI].Cells["dgvtxtProductId"].Value = decProductId.ToString(); dgvProduct.Rows[inI].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value = infoProduct.SalesRate.ToString(); UnitComboFill1(decProductId, inI, dgvProduct.Rows[inI].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; BatchComboFill(decProductId, inI, dgvProduct.Rows[inI].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value = BllBatch.BatchIdViewByProductId(decProductId); dgvProduct.Rows[inI].Cells["dgvtxtBarcode"].Value = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString())); GridGodownComboFill(decProductId, dgvProduct.CurrentRow.Index, dgvProduct.Rows[inI].Cells["dgvcmbGodown"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value = infoProduct.GodownId; RackComboFill1(infoProduct.GodownId, inI, dgvProduct.Rows[inI].Cells["dgvcmbRack"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value = infoProduct.RackId; list = bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName); dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value = list[0].Rows[0]["unitconversionId"].ToString(); dgvProduct.Rows[inI].Cells["dgvtxtConversionRate"].Value = list[0].Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); AmountCalculation("dgvtxtQty", dgvProduct.CurrentRow.Index); dgvProduct.Rows[inI].HeaderCell.Value = "X"; dgvProduct.Rows[inI].HeaderCell.Style.ForeColor = Color.Red; TotalAmountCalculation(); } } catch (Exception ex) { MessageBox.Show("DN25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Work on dgvProductCreation CellEndEdit event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProductCreation_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvtxtbatch") { string strBatch = dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); if (strBatch != "") { BatchBll BllBatch = new BatchBll(); List<DataTable> listBatch = new List<DataTable>(); listBatch = BllBatch.BatchViewByName(strBatch, decId); if (listBatch[0].Rows.Count != 0) { dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = listBatch[0].Rows[0]["expiryDate"]; dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = listBatch[0].Rows[0]["manufacturingDate"]; } } else { dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = string.Empty; dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = string.Empty; } } if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvcmbtgodown") { RackBll BllRack = new RackBll(); RackInfo infoRack = new RackInfo(); List<DataTable> listObjRack = new List<DataTable>(); decimal decGodownId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbtgodown"].Value); listObjRack = BllRack.RackNamesCorrespondingToGodownId(decGodownId); DataRow drow = listObjRack[0].NewRow(); drow["rackName"] = string.Empty; drow["rackId"] = 0; listObjRack[0].Rows.InsertAt(drow, 0); DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbrack"]); cell.DataSource = listObjRack[0]; cell.ValueMember = "rackId"; cell.DisplayMember = "rackName"; } } catch (Exception ex) { MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to call frmProductSearchPopup form to select and view Product created /// </summary> /// <param name="frmProductSearchPopup"></param> /// <param name="decproductId"></param> /// <param name="decCurrentRowIndex"></param> public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex) { try { base.Show(); this.frmProductSearchPopupObj = frmProductSearchPopup; List<DataTable> list = new List<DataTable>(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); ProductInfo infoProduct = new ProductInfo(); BatchBll BllBatch = new BatchBll(); infoProduct = new ProductCreationBll().ProductView(decproductId); dgvProduct.Rows.Add(); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtProductId"].Value = decproductId.ToString(); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; UnitComboFill1(decproductId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; GridGodownComboFill(decproductId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbGodown"].ColumnIndex); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbGodown"].Value = infoProduct.GodownId; RackComboFill1(infoProduct.GodownId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbRack"].ColumnIndex); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbRack"].Value = infoProduct.RackId; BatchComboFill(decproductId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbBatch"].Value = BllBatch.BatchIdViewByProductId(decproductId); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtBarcode"].Value = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbBatch"].Value.ToString())); list = bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtUnitConversionId"].Value = list[0].Rows[0]["unitconversionId"].ToString(); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtConversionRate"].Value = list[0].Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtConversionRate"].Value.ToString()); AmountCalculation("dgvtxtQty", dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtRate"].Value = infoProduct.SalesRate.ToString(); dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].HeaderCell.Value = "X"; dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].HeaderCell.Style.ForeColor = Color.Red; TotalAmountCalculation(); frmProductSearchPopupObj.Close(); frmProductSearchPopupObj = null; } catch (Exception ex) { MessageBox.Show("DN12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Get the Product details from the Product creation form /// </summary> /// <param name="decproductId"></param> public void ReturnFromProductCreation(decimal decproductId) { try { ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); BatchBll BllBatch = new BatchBll(); DataTable dtbl = new DataTable(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); this.Enabled = true; this.BringToFront(); if (decproductId != 0) { infoProduct = BllProductCreation.ProductView(decproductId); strProductCode = infoProduct.ProductCode; if (IsdgvConsuption) { int inCurrentRowIndex = dgvConsumption.CurrentRow.Index; dgvConsumption.Rows.Add(); ProductDetailsFillConsumption(strProductCode, inCurrentRowIndex, "ProductCode"); } else { int inProductionRowIndex = dgvProduction.CurrentRow.Index; dgvProduction.Rows.Add(); ProductDetailsFillProduction(strProductCode, inProductionRowIndex, "ProductCode"); } } } catch (Exception ex) { MessageBox.Show("SJ:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid view Cell Enter for set editmode and set basics of unit conversion /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduct_CellEnter(object sender, DataGridViewCellEventArgs e) { decimal decGodownId = 0; try { if (dgvProduct.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewComboBoxCell) { dgvProduct.EditMode = DataGridViewEditMode.EditOnEnter; } else { dgvProduct.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2; } if (e.RowIndex != -1 && e.ColumnIndex != -1) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty) { decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString()); } } } } if (dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value != null) { if (dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { BatchBll BllBatch = new BatchBll(); decimal decBatchId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbBatch"].Value); string strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = strBarcode; } } if (e.ColumnIndex == dgvProduct.Columns["dgvcmbRack"].Index) { if (dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value != null) { if (dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { if (dgvProduct.CurrentRow.Cells["dgvcmbRack"].Value == null || dgvProduct.CurrentRow.Cells["dgvcmbRack"].Value.ToString() == string.Empty) { decGodownId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value); RackComboFill1(decGodownId, e.RowIndex, e.ColumnIndex); } } } } } CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("DN49:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Doing basic calculations in cell value change /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPhysicalStock_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); BatchBll BllBatch = new BatchBll(); //PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP(); PhysicalStockBll BllPhysicalStock = new PhysicalStockBll(); if (e.RowIndex != -1 && e.ColumnIndex != -1) { string strBarcode = string.Empty; string strProductCode = string.Empty; if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtBarcode") { string strBCode = string.Empty; DataTable dtbl = new DataTable(); if (dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value != null && dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString() != string.Empty) { strBCode = dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString(); productDetailsFill(strBCode, dgvPhysicalStock.CurrentRow.Index, "Barcode"); CheckColumnMissing(); } } else if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtProductCode") { UnitInfo infoUnit = new UnitInfo(); string strPrdCode = string.Empty; if (dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty) { strPrdCode = dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString(); productDetailsFill(strPrdCode, dgvPhysicalStock.CurrentRow.Index, "ProductCode"); CheckColumnMissing(); } } else if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtProductName") { string strProductName = string.Empty; DataTable dtbl = new DataTable(); if (dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null && dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty) { strProductName = dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString(); productDetailsFill(strProductName, dgvPhysicalStock.CurrentRow.Index, "ProductName"); CheckColumnMissing(); } } if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc || dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc) { NewAmountCalculation(e.RowIndex); CheckColumnMissing(); } if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc || dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc) { CalculateTotalAmount(); } } } catch (Exception ex) { MessageBox.Show("PS:45" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }