/// <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> /// 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> ///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> /// 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> /// 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 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> /// To select the product from ProductSearchPopup /// </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(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); BatchBll BllBatch = new BatchBll(); try { base.Show(); this.frmProductSearchPopupObj = frmProductSearchPopup; infoProduct = BllProductCreation.ProductView(decproductId); int inRowcount = dgvProduct.Rows.Count; for (int i = 0; i < inRowcount; i++) { if (i == inRowcount - 1) { dgvProduct.Rows.Add(); } if (i == decCurrentRowIndex) { SerialNo(); dgvProduct.Rows[i].Cells["dgvtxtproductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[i].Cells["productId"].Value = decproductId.ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value = infoProduct.GodownId; dgvProduct.Rows[i].Cells["dgvCmbRack"].Value = infoProduct.RackId; UnitComboFill(decproductId, i, dgvProduct.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; List<DataTable> list = new List<DataTable>(); list = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[i].Cells["productId"].Value.ToString()); dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(new UnitConvertionBll().UnitconversionIdViewByUnitIdAndProductId(infoProduct.UnitId, infoProduct.ProductId)); dgvProduct.CurrentRow.Cells["dgvtxtConversionRate"].Value = bllUnitConvertion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value.ToString())); BatchComboFill(decproductId, i, dgvProduct.Rows[i].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value = BllBatch.BatchIdViewByProductId(decproductId); RackComboFill(infoProduct.GodownId, i, dgvProduct.Rows[i].Cells["dgvCmbRack"].ColumnIndex); dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value.ToString())); list= bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName); dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value = list[0].Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtConversionRate"].Value.ToString()); NewAmountCalculation("dgvtxtQty", i); CalculateTotalAmount(); } } frmProductSearchPopupObj.Close(); frmProductSearchPopupObj = null; } catch (Exception ex) { MessageBox.Show("MR4:" + 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; DataTable dtbl = new DataTable(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); BatchBll BllBatch = new BatchBll(); ProductInfo infoProductFill = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); int inI = dgvProduct.CurrentRow.Index; if (inI == dgvProduct.Rows.Count - 1) { dgvProduct.Rows.Add(); } if (decproductId != 0) { infoProduct = BllProductCreation.ProductView(decproductId); SerialNo(); dgvProduct.Rows[inI].Cells["dgvtxtproductCode"].Value = infoProduct.ProductCode; dgvProduct.Rows[inI].Cells["productId"].Value = decproductId.ToString(); dgvProduct.Rows[inI].Cells["dgvtxtProductName"].Value = infoProduct.ProductName; dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value = infoProduct.GodownId; dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value = infoProduct.RackId; UnitComboFill(decproductId, inI, dgvProduct.Rows[inI].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; List<DataTable> list = new List<DataTable>(); list = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[inI].Cells["productId"].Value.ToString()); //UnitComboFill(infoProduct.ProductId, dgvProduct.CurrentRow.Index, dgvProduct.CurrentRow.Cells["dgvcmbUnit"].ColumnIndex); //dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value = infoProduct.UnitId; dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces); dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(new UnitConvertionBll().UnitconversionIdViewByUnitIdAndProductId(infoProduct.UnitId, infoProduct.ProductId)); dgvProduct.CurrentRow.Cells["dgvtxtConversionRate"].Value = bllUnitConvertion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString())); BatchComboFill(decproductId, inI, dgvProduct.Rows[inI].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value = BllBatch.BatchIdViewByProductId(decproductId); RackComboFill(infoProduct.GodownId, inI, dgvProduct.Rows[inI].Cells["dgvCmbRack"].ColumnIndex); dgvProduct.Rows[inI].Cells["dgvtxtBarcode"].Value = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString())); list = bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName); dgvProduct.Rows[inI].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtConversionRate"].Value.ToString()); NewAmountCalculation("dgvtxtQty", inI); CalculateTotalAmount(); } } catch (Exception ex) { MessageBox.Show("MR6:new" + 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) { UnitConvertionBll bllUnitConversion = new UnitConvertionBll(); try { this.frmProductSearchPopupObj = frmProductSearchPopup; List<DataTable> list = new List<DataTable>(); BatchBll BllBatch = new BatchBll(); ProductCreationBll BllProductCreation = new ProductCreationBll(); if (decproductId != 0) { infoProduct = BllProductCreation.ProductView(decproductId); dgvSalesOrder.CurrentRow.Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode.ToString(); dgvSalesOrder.CurrentRow.Cells["dgvtxtProductId"].Value = decproductId.ToString(); dgvSalesOrder.CurrentRow.Cells["dgvtxtProductName"].Value = infoProduct.ProductName; dgvSalesOrder.CurrentRow.Cells["dgvtxtRate"].Value = infoProduct.SalesRate.ToString(); UnitComboFill(decproductId, dgvSalesOrder.CurrentRow.Index, dgvSalesOrder.CurrentRow.Cells["dgvcmbUnit"].ColumnIndex); dgvSalesOrder.CurrentRow.Cells["dgvcmbUnit"].Value = infoProduct.UnitId; BatchComboFill(decproductId, dgvSalesOrder.CurrentRow.Index, dgvSalesOrder.CurrentRow.Cells["dgvcmbBatch"].ColumnIndex); dgvSalesOrder.CurrentRow.Cells["dgvcmbBatch"].Value = BllBatch.BatchIdViewByProductId(decproductId); dgvSalesOrder.CurrentRow.Cells["dgvtxtBarcode"].Value = BllBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvSalesOrder.CurrentRow.Cells["dgvcmbBatch"].Value.ToString())); list = bllUnitConversion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName); dgvSalesOrder.CurrentRow.Cells["dgvtxtUnitConversionId"].Value = list[0].Rows[0]["unitconversionId"].ToString(); dgvSalesOrder.CurrentRow.Cells["dgvtxtConversionRate"].Value = list[0].Rows[0]["conversionRate"].ToString(); decCurrentConversionRate = Convert.ToDecimal(dgvSalesOrder.CurrentRow.Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvSalesOrder.CurrentRow.Cells["dgvtxtRate"].Value.ToString()); AmountCalculation("dgvtxtQty", dgvSalesOrder.CurrentRow.Index); TotalAmountCalculation(); } frmProductSearchPopupObj.Close(); frmProductSearchPopupObj = null; this.Enabled = true; this.BringToFront(); } catch (Exception ex) { MessageBox.Show("S10:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill purchase order details /// </summary> public void PurchaseOrderDetailsFill() { BatchBll BllBatch = new BatchBll(); try { //DataTable dtblMaster = new DataTable(); //DataTable dtblDetails = new DataTable(); //PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP(); //PurchaseOrderDetailsSP spPurchaseOrderDetails = new PurchaseOrderDetailsSP(); //BatchSP spBatch = new BatchSP(); decimal decPurchaseOrderMasterId = 0; decimal decBatchId = 0; if (!isEditFill) { if (cmbCashOrParty.SelectedValue != null) { if (cmbCashOrParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbCashOrParty.Text != "System.Data.DataRowView") { GridComboFill(); decPurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); ListObjMaster = BllPurchaseOrder.PurchaseOrderMasterViewByOrderMasterId(decPurchaseOrderMasterId); if (ListObjMaster[0].Rows.Count > 0) { cmbCurrency.SelectedValue = Convert.ToDecimal(ListObjMaster[0].Rows[0].ItemArray[10].ToString()); } ListObjDetails = BllPurchaseOrder.PurchaseOrderDetailsViewByOrderMasterIdWithRemainingByNotInCurrPI (decPurchaseOrderMasterId, decPurchaseMasterId, decPurchaseInvoiceVoucherTypeId); if (ListObjDetails[0].Rows.Count > 0) { //dgvProductDetails.DataSource = dtblDetails; //---------------- if (dgvProductDetails.DataSource == null) { dgvProductDetails.Rows.Clear(); } else { ((DataTable)dgvProductDetails.DataSource).Rows.Clear(); } int i = 0; foreach (DataRow dr in ListObjDetails[0].Rows) { dgvProductDetails.Rows.Add(); dgvProductDetails.Rows[i].Cells["dgvtxtPurchaseDetailsId"].Value = dr["purchaseDetailsId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = dr["purchaseOrderDetailsId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtMaterialReceiptDetailsId"].Value = dr["materialReceiptDetailsId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtProductId"].Value = dr["productId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtBarcode"].Value = dr["barcode"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtProductCode"].Value = dr["productCode"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtProductName"].Value = dr["productName"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtQuantity"].Value = dr["qty"].ToString(); UnitComboFill(Convert.ToDecimal(dr["productId"].ToString()), i, dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvProductDetails.Rows[i].Cells["dgvtxtUnitConversionId"].Value = dr["unitConversionId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dr["unitId"].ToString()); dgvProductDetails.Rows[i].Cells["dgvcmbGodown"].Value = 1m; dgvProductDetails.Rows[i].Cells["dgvcmbRack"].Value = 1m; BatchComboFill(Convert.ToDecimal(dr["productId"].ToString()), i, dgvProductDetails.Rows[i].Cells["dgvcmbBatch"].ColumnIndex); decBatchId = BllBatch.BatchIdViewByProductId(Convert.ToDecimal(dr["productId"].ToString())); dgvProductDetails.Rows[i].Cells["dgvcmbBatch"].Value = decBatchId; dgvProductDetails.Rows[i].Cells["dgvtxtRate"].Value = dr["rate"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtGrossValue"].Value = dr["grossValue"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtDiscountPercent"].Value = dr["discountPercent"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtDiscount"].Value = dr["discount"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtNetValue"].Value = dr["netvalue"].ToString(); dgvProductDetails.Rows[i].Cells["dgvcmbTax"].Value = Convert.ToDecimal(dr["taxId"].ToString()); dgvProductDetails.Rows[i].Cells["dgvtxtTaxAmount"].Value = dr["taxAmount"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtAmount"].Value = dr["Amount"].ToString(); dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true; i++; } //------------------- } else { if (dgvProductDetails.DataSource == null) { dgvProductDetails.Rows.Clear(); } else { ((DataTable)dgvProductDetails.DataSource).Rows.Clear(); } } SerialNo(); GridviewReadOnlySettings("Against PurchaseOrder"); } } } } catch (Exception ex) { MessageBox.Show("PI19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }