/// <summary> /// Function to use the Rack Combo Fill by under the Godown /// </summary> /// <param name="dcGodownId"></param> public void RackComboFillByGodownId(decimal dcGodownId) { try { List<DataTable> listObjRack = new List<DataTable>(); RackBll BllRack = new RackBll(); listObjRack = BllRack.RackNamesCorrespondingToGodownId(dcGodownId); cmbRack.DataSource = listObjRack[0]; cmbRack.ValueMember = "rackId"; cmbRack.DisplayMember = "rackName"; } catch (Exception ex) { MessageBox.Show("POS:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Rack Combofill /// </summary> /// <param name="decGodownId"></param> /// <param name="inRow"></param> /// <param name="inCol"></param> public void RackComboFill1(decimal decGodownId, int inRow, int inCol) { try { List<DataTable> listObj = new List<DataTable>(); RackBll BllRack = new RackBll(); listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId); DataGridViewComboBoxCell dgvcmbRackCell = (DataGridViewComboBoxCell)dgvProduct.Rows[inRow].Cells[inCol]; dgvcmbRackCell.DataSource = listObj[0]; dgvcmbRackCell.ValueMember = "rackId"; dgvcmbRackCell.DisplayMember = "rackName"; } catch (Exception ex) { MessageBox.Show("DN29 :" + 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); } }
public void RackComboFillCorrespondingGodown(decimal decGodownId, int inRow, int inColumn) { try { List<DataTable> listObj = new List<DataTable>(); RackBll BllRack = new RackBll(); listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId); DataRow drow = listObj[0].NewRow(); DataGridViewComboBoxCell dgvcmbRackCellConsumption = (DataGridViewComboBoxCell)dgvPhysicalStock.Rows[inRow].Cells[inColumn]; dgvcmbRackCellConsumption.DataSource = listObj[0]; dgvcmbRackCellConsumption.ValueMember = "rackId"; dgvcmbRackCellConsumption.DisplayMember = "rackName"; } catch (Exception ex) { MessageBox.Show("SJ:26" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//Form Rack //-------------------------------------------------------------ReturnFromRackForm--------------------------- public void ReturnFromRackForm(decimal decId) { try { if (!isCallFromGrid) { RackComboFill(); if (decId.ToString() != "0") { cmbDefaultRack.SelectedValue = decId; } else if (strRackName != string.Empty) { cmbDefaultRack.SelectedValue = strRackName; } else { cmbDefaultRack.SelectedIndex = -1; } this.Enabled = true; cmbDefaultRack.Focus(); this.WindowState = FormWindowState.Normal; this.Activate(); } else { DataGridViewComboBoxCell dgvRackCell = (DataGridViewComboBoxCell)dgvProductCreation[dgvProductCreation.Columns["dgvcmbrack"].Index, dgvProductCreation.CurrentRow.Index]; List<DataTable> listObj = new List<DataTable>(); RackBll BllRack = new RackBll(); listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownIdForRack); if (decId.ToString() != "0") { dgvRackCell.DataSource = listObj[0]; dgvRackCell.ValueMember = "rackId"; dgvRackCell.DisplayMember = "rackName"; dgvProductCreation.CurrentRow.Cells["dgvcmbrack"].Value = decId; } } } catch (Exception ex) { MessageBox.Show("PC:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill rack combobox in grid /// </summary> public void RackComboFill() { try { List<DataTable> listObj = new List<DataTable>(); RackBll BllRack = new RackBll(); decimal decGodownId = Convert.ToDecimal(cmbDefaultGodown.SelectedValue.ToString()); listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId); cmbDefaultRack.DataSource = listObj[0]; cmbDefaultRack.DisplayMember = "rackName"; cmbDefaultRack.ValueMember = "rackId"; if (listObj[0].Rows.Count > 0) { cmbDefaultRack.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show("PC:54" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Rackcombofill /// </summary> /// <param name="decrackId"></param> public void rackcombofill1(decimal decrackId) { try { RackBll BllRack = new RackBll(); List<DataTable> listObjc = new List<DataTable>(); ; listObjc = BllRack.RackNamesCorrespondingToGodownId(decrackId); dgvCmbRack.DataSource = listObjc; dgvCmbRack.ValueMember = "rackId"; dgvCmbRack.DisplayMember = "rackName"; } catch (Exception ex) { MessageBox.Show("SR73:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the details against purchase order /// </summary> public void FillOrderDetails() { BatchBll BllBatch = new BatchBll(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); //StockPostingSP spStockPosting = new StockPostingSP(); StockPostingBll BllStockPosting = new StockPostingBll(); ProductCreationBll BllProductCreation = new ProductCreationBll(); try { if (!isEditFill) { isValueChange = false; if (dgvProduct.RowCount > 1) { for (int i = 0; i < dgvProduct.RowCount - 1; i++) { if (dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value.ToString() != string.Empty) { lstArrOfRemove.Add(dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value.ToString()); } } } dgvProduct.Rows.Clear(); isValueChange = true; isDoAfterGridFill = false; List<DataTable> ListObjDetails = new List<DataTable>(); if (Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()) == decOrderNoWhileEditMode && btnSave.Text == "Update") { ListObjDetails = BllPurchaseOrder.PurchaseOrderDetailsViewByOrderMasterIdWithRemainingForEdit(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decMaterialReceiptId); } else { ListObjDetails = BllPurchaseOrder.PurchaseOrderDetailsViewByOrderMasterIdWithRemaining(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decMaterialReceiptId); } int inRowIndex = 0; foreach (DataRow drowDetails in ListObjDetails[0].Rows) { dgvProduct.Rows.Add(); isValueChange = false; isDoAfterGridFill = false; dgvProduct.CurrentCell = dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"]; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToString(drowDetails.ItemArray[0]); strproductId = drowDetails.ItemArray[2].ToString(); ProductInfo infoproduct = new ProductInfo(); infoproduct = BllProductCreation.ProductView(Convert.ToDecimal(strproductId)); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["productId"].Value = Convert.ToDecimal(strproductId); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = infoproduct.ProductCode; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = infoproduct.ProductName; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtvouchertypeId"].Value = Convert.ToString(drowDetails.ItemArray[11]); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtvoucherNo"].Value = Convert.ToString(drowDetails.ItemArray[12]); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtinvoiceNo"].Value = Convert.ToString(drowDetails.ItemArray[13]); UnitComboFill(Convert.ToDecimal(strproductId), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex); isValueChange = true; isDoAfterGridFill = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List< DataTable >listUnitByProduct = new List<DataTable>(); listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(strproductId); foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows) { if (dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); } } isValueChange = false; isDoAfterGridFill = false; BatchComboFill(Convert.ToDecimal(strproductId), dgvProduct.Rows.Count - 2, Convert.ToInt32(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex)); decimal decBatch = BllStockPosting.BatchViewByProductId(Convert.ToDecimal(strproductId)); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = decBatch; string strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatch); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = strBarcode; DGVGodownComboFill(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(1); RackComboFill(1, dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvCmbRack"].ColumnIndex); List<DataTable> listObj = new List<DataTable>(); RackBll BllRack = new RackBll(); listObj = BllRack.RackNamesCorrespondingToGodownId(1); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvCmbRack"].Value = Convert.ToDecimal(listObj[0].Rows[0]["rackId"].ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = Convert.ToString(drowDetails.ItemArray[3]); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = Convert.ToString(drowDetails.ItemArray[4]); decCurrentRate = Convert.ToDecimal(drowDetails.ItemArray[4].ToString()); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value.ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].Value = Convert.ToString(drowDetails.ItemArray[6]); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].ReadOnly = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["inRowIndex"].Value = Convert.ToString(drowDetails["extra1"]); if (cmbVoucherType.Text != "NA") { dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = string.Empty; int intIndex = 0; int.TryParse(Convert.ToString(drowDetails["extra1"]), out intIndex); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; NewAmountCalculation(string.Empty, dgvProduct.Rows.Count - 2); isValueChange = true; isDoAfterGridFill = true; dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } for (int i = inRowIndex; i < dgvProduct.Rows.Count; ++i) dgvProduct["inRowIndex", i].Value = Convert.ToString(GetNextinRowIndex()); SerialNo(); CalculateTotalAmount(); } } catch (Exception ex) { MessageBox.Show("MR39:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On cellLeave of dgvProduct /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e) { BatchBll BllBatch = new BatchBll(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); try { if (isValueChange) { string strBarcode = string.Empty; string strProductCode = string.Empty; if (e.RowIndex > -1 && e.ColumnIndex > -1) { CheckInvalidEntries(e); if (e.ColumnIndex == dgvProduct.Columns["dgvcmbBatch"].Index) { if (dgvProduct.Rows[e.RowIndex].Cells["productId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["productId"].Value.ToString() != string.Empty) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { if (Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value) != string.Empty && Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value) != "0") { decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value); strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString(); strBarcode = BllBatch.ProductBatchBarcodeViewByBatchId(decBatchId); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = strBarcode; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = strProductCode; } } } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty) { UnitConvertionBll bllUnitByProduct = new UnitConvertionBll(); List<DataTable> listUnitByProduct = new List<DataTable>(); listUnitByProduct = bllUnitByProduct.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["productId"].Value.ToString()); 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 (isDoAfterGridFill) { 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, 2); NewAmountCalculation("dgvtxtQty", e.RowIndex); CalculateTotalAmount(); } } } CheckInvalidEntries(e); } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbGodown") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { decGodownId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value); RackComboFill(decGodownId, e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvCmbRack"].ColumnIndex); List<DataTable> listObj = new List<DataTable>(); RackBll BllRack = new RackBll(); listObj = BllRack.RackNamesCorrespondingToGodownId(decGodownId); dgvProduct.Rows[e.RowIndex].Cells["dgvCmbRack"].Value = Convert.ToDecimal(listObj[0].Rows[0]["rackId"].ToString()); } CheckInvalidEntries(e); } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvCmbCurrency" && isAmountcalc) { ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); if (dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value != null && Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value) != string.Empty) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtExchangeRate"].Value = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value))); } else { dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value = BllPurchaseOrder.ExchangeRateIdByCurrencyId(PublicVariables._decCurrencyId); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtExchangeRate"].Value = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value))); } CheckInvalidEntries(e); } //----------while changing Qty,corresponding change in amount-------- else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty) { NewAmountCalculation("dgvtxtQty", e.RowIndex); CalculateTotalAmount(); } } CheckInvalidEntries(e); } //---------------while changing Qty,corresponding change in amount---- else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc) { NewAmountCalculation("dgvtxtRate", e.RowIndex); CalculateTotalAmount(); CheckInvalidEntries(e); } //----while changing amount ,corresponding chnage in total amount------- else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtAmount" && isAmountcalc) { if (cmbcurrency.Text != string.Empty) { CalculateTotalAmount(); } } //} } } CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("MR72:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }