/// <summary> /// Function to Update values in StockJournal Table /// </summary> /// <param name="stockjournalmasterinfo"></param> public void StockJournalMasterEdit(StockJournalMasterInfo stockjournalmasterinfo) { try { spStockJournalMaster.StockJournalMasterEdit(stockjournalmasterinfo); } catch (Exception ex) { MessageBox.Show("AL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to StockJournal Table /// </summary> /// <param name="stockjournalmasterinfo"></param> /// <returns></returns> public decimal StockJournalMasterAdd(StockJournalMasterInfo stockjournalmasterinfo) { decimal decStockJournalMasterId = 0; try { decStockJournalMasterId = spStockJournalMaster.StockJournalMasterAdd(stockjournalmasterinfo); } catch (Exception ex) { MessageBox.Show("AL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decStockJournalMasterId); }
public decimal StockJournalMasterAdd(StockJournalMasterInfo stockjournalmasterinfo) { decimal decStockJournalMasterId = 0m; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockJournalMasterAdd", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam12 = new SqlParameter(); sprmparam12 = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam12.Value = stockjournalmasterinfo.VoucherNo; sprmparam12 = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam12.Value = stockjournalmasterinfo.InvoiceNo; sprmparam12 = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam12.Value = stockjournalmasterinfo.SuffixPrefixId; sprmparam12 = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam12.Value = stockjournalmasterinfo.VoucherTypeId; sprmparam12 = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam12.Value = stockjournalmasterinfo.Date; sprmparam12 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam12.Value = stockjournalmasterinfo.Narration; sprmparam12 = sccmd.Parameters.Add("@additionalCost", SqlDbType.Decimal); sprmparam12.Value = stockjournalmasterinfo.AdditionalCost; sprmparam12 = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam12.Value = stockjournalmasterinfo.FinancialYearId; sprmparam12 = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam12.Value = stockjournalmasterinfo.FinancialYearId; sprmparam12 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam12.Value = stockjournalmasterinfo.Extra1; sprmparam12 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam12.Value = stockjournalmasterinfo.Extra2; decStockJournalMasterId = Convert.ToDecimal(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } return(decStockJournalMasterId); }
public void StockJournalMasterEdit(StockJournalMasterInfo stockjournalmasterinfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockJournalMasterEdit", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam13 = new SqlParameter(); sprmparam13 = sccmd.Parameters.Add("@stockJournalMasterId", SqlDbType.Decimal); sprmparam13.Value = stockjournalmasterinfo.StockJournalMasterId; sprmparam13 = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam13.Value = stockjournalmasterinfo.VoucherNo; sprmparam13 = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam13.Value = stockjournalmasterinfo.InvoiceNo; sprmparam13 = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam13.Value = stockjournalmasterinfo.SuffixPrefixId; sprmparam13 = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam13.Value = stockjournalmasterinfo.VoucherTypeId; sprmparam13 = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam13.Value = stockjournalmasterinfo.Date; sprmparam13 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam13.Value = stockjournalmasterinfo.Narration; sprmparam13 = sccmd.Parameters.Add("@additionalCost", SqlDbType.Decimal); sprmparam13.Value = stockjournalmasterinfo.AdditionalCost; sprmparam13 = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam13.Value = stockjournalmasterinfo.FinancialYearId; sprmparam13 = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam13.Value = stockjournalmasterinfo.ExtraDate; sprmparam13 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam13.Value = stockjournalmasterinfo.Extra1; sprmparam13 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam13.Value = stockjournalmasterinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
public StockJournalMasterInfo StockJournalMasterView(decimal stockJournalMasterId) { StockJournalMasterInfo stockjournalmasterinfo = new StockJournalMasterInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockJournalMasterView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@stockJournalMasterId", SqlDbType.Decimal); sprmparam2.Value = stockJournalMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { stockjournalmasterinfo.StockJournalMasterId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString()); stockjournalmasterinfo.VoucherNo = ((DbDataReader)sdrreader)[1].ToString(); stockjournalmasterinfo.InvoiceNo = ((DbDataReader)sdrreader)[2].ToString(); stockjournalmasterinfo.SuffixPrefixId = decimal.Parse(((DbDataReader)sdrreader)[3].ToString()); stockjournalmasterinfo.VoucherTypeId = decimal.Parse(((DbDataReader)sdrreader)[4].ToString()); stockjournalmasterinfo.Date = DateTime.Parse(((DbDataReader)sdrreader)[5].ToString()); stockjournalmasterinfo.Narration = ((DbDataReader)sdrreader)[6].ToString(); stockjournalmasterinfo.AdditionalCost = decimal.Parse(((DbDataReader)sdrreader)[7].ToString()); stockjournalmasterinfo.FinancialYearId = decimal.Parse(((DbDataReader)sdrreader)[8].ToString()); stockjournalmasterinfo.ExtraDate = DateTime.Parse(((DbDataReader)sdrreader)[9].ToString()); stockjournalmasterinfo.Extra1 = ((DbDataReader)sdrreader)[10].ToString(); stockjournalmasterinfo.Extra2 = ((DbDataReader)sdrreader)[11].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(stockjournalmasterinfo); }
/// <summary> /// Function to fill the details while calling from register or report /// </summary> public void FillRegisterOrReport() { StockJournalBll BllStockJournal = new StockJournalBll(); StockJournalMasterInfo infoStockJournalMaster = new StockJournalMasterInfo(); StockJournalDetailsInfo infoStockJournalDetails = new StockJournalDetailsInfo(); AditionalCostBll bllAdditionalCost = new AditionalCostBll(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); try { isFillMode = true; btnSave.Text = "Update"; cmbFinishedGoods.Enabled = false; txtQty.Enabled = false; btnAdd.Enabled = false; dgvConsumption.Rows.Clear(); dgvProduction.Rows.Clear(); dgvAdditionalCost.Rows.Clear(); List<DataTable> listObjMaster = BllStockJournal.StockJournalMasterFillForRegisterOrReport(decStockJournalMasterIdForEdit); StockJournalVoucherTypeId = Convert.ToDecimal(listObjMaster[0].Rows[0]["voucherTypeId"].ToString()); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); infoVoucherType = BllVoucherType.VoucherTypeView(StockJournalVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; txtDate.Text = listObjMaster[0].Rows[0]["date"].ToString(); strVoucherNo = listObjMaster[0].Rows[0]["voucherNo"].ToString(); decSuffixPrefixId = Convert.ToDecimal(listObjMaster[0].Rows[0]["suffixPrefixId"].ToString()); decVoucherTypeId = Convert.ToDecimal(listObjMaster[0].Rows[0]["voucherTypeId"].ToString()); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(StockJournalVoucherTypeId); dtpDate.Value = Convert.ToDateTime(txtDate.Text); txtNarration.Text = listObjMaster[0].Rows[0]["narration"].ToString(); cmbCurrency.SelectedValue = Convert.ToDecimal(listObjMaster[0].Rows[0]["exchangeRateId"].ToString()); if (listObjMaster[0].Rows[0]["extra1"].ToString() == "Manufacturing") { rbtnManufacturing.Checked = true; } if (listObjMaster[0].Rows[0]["extra1"].ToString() == "Transfer") { rbtnTransfer.Checked = true; } if (listObjMaster[0].Rows[0]["extra1"].ToString() == "Stock Out") { rbtnStockOut.Checked = true; } txtVoucherNo.Text = listObjMaster[0].Rows[0]["invoiceNo"].ToString(); DataSet dsDetails = BllStockJournal.StockJournalDetailsForRegisterOrReport(decStockJournalMasterIdForEdit); DataTable dtblConsumption = dsDetails.Tables[0]; if (dsDetails.Tables[0].Rows.Count > 0) { for (int i = 0; i < dtblConsumption.Rows.Count; i++) { dgvConsumption.Rows.Add(); dgvConsumption.Rows[i].HeaderCell.Value = string.Empty; dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["stockJournalDetailsId"].ToString()); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value = dtblConsumption.Rows[i]["slno"].ToString(); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionBarcode"].Value = dtblConsumption.Rows[i]["barcode"].ToString(); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductCode"].Value = dtblConsumption.Rows[i]["productCode"].ToString(); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductName"].Value = dtblConsumption.Rows[i]["productName"].ToString(); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value = dtblConsumption.Rows[i]["productId"].ToString(); IsSetGridValueChange = true; dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value = dtblConsumption.Rows[i]["qty"].ToString(); IsSetGridValueChange = false; dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["godownId"].ToString()); dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["rackId"].ToString()); if (dtblConsumption.Rows[i]["batchId"] != null && dtblConsumption.Rows[i]["batchId"].ToString() != "0") { dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["batchId"].ToString()); } else { dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value = string.Empty; } IsSetGridValueChange = true; dgvConsumption.Rows[i].Cells["dgvcmbConsumptionunitId"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["unitId"].ToString()); IsSetGridValueChange = false; dgvConsumption.Rows[i].Cells["dgvtxtConsumptionUnitConversionId"].Value = dtblConsumption.Rows[i]["unitConversionId"].ToString(); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionBarcode"].ReadOnly = true; dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductCode"].ReadOnly = true; dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductName"].ReadOnly = true; dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value = dtblConsumption.Rows[i]["rate"].ToString(); dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value = dtblConsumption.Rows[i]["amount"].ToString(); dgvConsumption.Rows[i].HeaderCell.Value = ""; } } DataTable dtblProduction = dsDetails.Tables[1]; for (int i = 0; i < dtblProduction.Rows.Count; i++) { dgvProduction.Rows.Add(); dgvProduction.Rows[i].HeaderCell.Value = string.Empty; dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["stockJournalDetailsId"].ToString()); dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value = dtblProduction.Rows[i]["slno"].ToString(); dgvProduction.Rows[i].Cells["dgvtxtProductionBarcode"].Value = dtblProduction.Rows[i]["barcode"].ToString(); dgvProduction.Rows[i].Cells["dgvtxtProductionProductCode"].Value = dtblProduction.Rows[i]["productCode"].ToString(); dgvProduction.Rows[i].Cells["dgvtxtProductionProductName"].Value = dtblProduction.Rows[i]["productName"].ToString(); dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value = dtblProduction.Rows[i]["productId"].ToString(); IsSetGridValueChange = true; dgvProduction.Rows[i].Cells["dgvtxtProductionQty"].Value = dtblProduction.Rows[i]["qty"].ToString(); IsSetGridValueChange = false; if (rbtnManufacturing.Checked) { cmbFinishedGoods.SelectedValue = dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value; if (cmbFinishedGoods.SelectedValue != null) { cmbFinishedGoods.Enabled = true; txtQty.Enabled = true; btnAdd.Enabled = true; txtQty.Text = dtblProduction.Rows[i]["qty"].ToString(); } } dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["godownId"].ToString()); dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["rackId"].ToString()); if (dtblProduction.Rows[i]["batchId"] != null && dtblProduction.Rows[i]["batchId"].ToString() != string.Empty) { dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["batchId"].ToString()); } else { dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value = string.Empty; } IsSetGridValueChange = true; dgvProduction.Rows[i].Cells["dgvcmbProductionunitId"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["unitId"].ToString()); IsSetGridValueChange = false; dgvProduction.Rows[i].Cells["dgvtxtProductionUnitConversionId"].Value = dtblProduction.Rows[i]["unitConversionId"].ToString(); dgvProduction.Rows[i].Cells["dgvtxtProductionBarcode"].ReadOnly = true; dgvProduction.Rows[i].Cells["dgvtxtProductionProductCode"].ReadOnly = true; dgvProduction.Rows[i].Cells["dgvtxtProductionProductName"].ReadOnly = true; dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value = dtblProduction.Rows[i]["rate"].ToString(); dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value = dtblProduction.Rows[i]["amount"].ToString(); } DataSet dsAdditionalCost = bllAdditionalCost.StockJournalAdditionalCostForRegisteOrReport(strVoucherNo, decVoucherTypeId); if (dsAdditionalCost.Tables[0].Rows.Count > 0) { DataTable dtblCashOrBank = dsAdditionalCost.Tables[0]; cmbCashOrBank.SelectedValue = Convert.ToDecimal(dtblCashOrBank.Rows[0]["ledgerId"]); } if (dsAdditionalCost.Tables[1].Rows.Count > 0) { DataTable dtblIndirectExpenses = dsAdditionalCost.Tables[1]; int inRowIndexAdditional = 0; for (int i = 0; i < dtblIndirectExpenses.Rows.Count; i++) { dgvAdditionalCost.Rows.Add(); dgvAdditionalCost.Rows[i].HeaderCell.Value = string.Empty; dgvAdditionalCost.Rows[i].Cells["dgvtxtAdditionalCostSlNo"].Value = ++inRowIndexAdditional; dgvAdditionalCost.Rows[i].Cells["dgvcmbAdditionalCostLedger"].Value = Convert.ToDecimal(dtblIndirectExpenses.Rows[i]["ledgerId"].ToString()); dgvAdditionalCost.Rows[i].Cells["dgvtxtAdditionalCostAmount"].Value = dtblIndirectExpenses.Rows[i]["debit"].ToString(); } } grandTotalAmountCalculationConsumption(); grandTotalAmountCalculationProduction(); TotalAdditionalCostAmount(); btnDelete.Enabled = true; if (isAutomatic) { txtVoucherNo.ReadOnly = true; } else { txtVoucherNo.ReadOnly = false; } gbxTransactionType.Enabled = false; isFillMode = false; } catch (Exception ex) { MessageBox.Show("SJ:50" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save stockjournal /// </summary> public void Save() { try { StockJournalMasterInfo infoStockJournalMaster = new StockJournalMasterInfo(); StockJournalDetailsInfo infoStockJournalDetails = new StockJournalDetailsInfo(); StockJournalBll BllStockJournal = new StockJournalBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AditionalCostBll bllAdditionalCost = new AditionalCostBll(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); if (isAutomatic == true) { infoStockJournalMaster.SuffixPrefixId = decSuffixPrefixId; infoStockJournalMaster.VoucherNo = strVoucherNo; } else { infoStockJournalMaster.SuffixPrefixId = 0; infoStockJournalMaster.VoucherNo = strVoucherNo; } infoStockJournalMaster.ExtraDate = DateTime.Now; infoStockJournalMaster.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockJournalMaster.Date = Convert.ToDateTime(txtDate.Text); infoStockJournalMaster.AdditionalCost = Convert.ToDecimal(lblAdditionalCostAmount.Text); infoStockJournalMaster.VoucherNo = strVoucherNo; infoStockJournalMaster.VoucherTypeId = decVoucherTypeId; infoStockJournalMaster.Narration = txtNarration.Text.Trim(); infoStockJournalMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockJournalMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue); if (rbtnManufacturing.Checked) { infoStockJournalMaster.Extra1 = "Manufacturing"; } if (rbtnTransfer.Checked) { infoStockJournalMaster.Extra1 = "Transfer"; } if (rbtnStockOut.Checked) { infoStockJournalMaster.Extra1 = "Stock Out"; } infoStockJournalMaster.Extra2 = string.Empty; if (btnSave.Text == "Save") { decStockMasterId = BllStockJournal.StockJournalMasterAdd(infoStockJournalMaster); } else { infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit; BllStockJournal.StockJournalMasterEdit(infoStockJournalMaster); RemoveRowStockJournalConsumptionDetails(); RemoveRowStockJournalProductionDetails(); RemoveRowStockJournalAdditionalCostDetails(); BllStockPosting.DeleteStockPostingForStockJournalEdit(strVoucherNo, decVoucherTypeId); } if (dgvConsumption.Rows.Count > 0) { int inCount = dgvConsumption.Rows.Count; for (int i = 0; i < inCount - 1; i++) { if (btnSave.Text == "Save") { infoStockJournalDetails.StockJournalMasterId = decStockMasterId; } else { infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit; } infoStockJournalDetails.Extra1 = string.Empty; infoStockJournalDetails.Extra2 = string.Empty; infoStockJournalDetails.ExtraDate = DateTime.Now; infoStockJournalDetails.ProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value); infoStockJournalDetails.Qty = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value); infoStockJournalDetails.Rate = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value); infoStockJournalDetails.UnitId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionunitId"].Value); infoStockJournalDetails.UnitConversionId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionunitConversionId"].Value); if (btnSave.Text == "Update") { infoStockJournalDetails.StockJournalMasterId = decStockJournalMasterIdForEdit; if (dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value == null || dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value.ToString() == string.Empty) { if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Consumption"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } else { infoStockJournalDetails.StockJournalDetailsId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value); if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value != null && dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Consumption"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value); BllStockJournal.StockJournalDetailsEdit(infoStockJournalDetails); } } else { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); infoStockJournalDetails.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); infoStockJournalDetails.Amount = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Consumption"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } //Stock Posting Add if (btnSave.Text == "Update") { infoStockPosting.BatchId = infoStockJournalDetails.BatchId; infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = infoStockJournalDetails.GodownId; infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.ProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value); infoStockPosting.RackId = infoStockJournalDetails.RackId; infoStockPosting.Rate = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value); infoStockPosting.UnitId = infoStockJournalDetails.UnitId; infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } else { infoStockPosting.BatchId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value); infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.ProductId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value); infoStockPosting.RackId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value); infoStockPosting.Rate = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value); infoStockPosting.UnitId = Convert.ToDecimal(dgvConsumption.Rows[i].Cells["dgvcmbConsumptionunitId"].Value); infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } if (dgvProduction.Rows.Count > 0) { int inCount = dgvProduction.Rows.Count; for (int i = 0; i < inCount - 1; i++) { if (btnSave.Text == "Update") { infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit; } else { infoStockJournalDetails.StockJournalMasterId = decStockMasterId; } infoStockJournalDetails.Extra1 = string.Empty; infoStockJournalDetails.Extra2 = string.Empty; infoStockJournalDetails.ExtraDate = DateTime.Now; infoStockJournalDetails.ProductId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value); infoStockJournalDetails.Qty = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionQty"].Value); infoStockJournalDetails.Rate = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value); infoStockJournalDetails.UnitId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionunitId"].Value); infoStockJournalDetails.UnitConversionId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionunitConversionId"].Value); if (btnSave.Text == "Update") { infoStockJournalDetails.StockJournalMasterId = decStockJournalMasterIdForEdit; if (dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value == null || dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value.ToString() == string.Empty) { if (dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Production"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } else { infoStockJournalDetails.StockJournalDetailsId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value); if (dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value.ToString() != string.Empty) { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); } else { infoStockJournalDetails.BatchId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value.ToString() != string.Empty) { infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); } else { infoStockJournalDetails.GodownId = 0; } if (dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value != null && dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value.ToString() != string.Empty) { infoStockJournalDetails.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); } else { infoStockJournalDetails.RackId = 0; } infoStockJournalDetails.Amount = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Production"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value); BllStockJournal.StockJournalDetailsEdit(infoStockJournalDetails); } } else { infoStockJournalDetails.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); infoStockJournalDetails.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); infoStockJournalDetails.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); infoStockJournalDetails.Amount = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value); infoStockJournalDetails.ConsumptionOrProduction = "Production"; infoStockJournalDetails.Slno = Convert.ToInt32(dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value); BllStockJournal.StockJournalDetailsAdd(infoStockJournalDetails); } //Stock Posting Add if (btnSave.Text == "Save") { infoStockPosting.BatchId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value); infoStockPosting.InwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value); infoStockPosting.RackId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value); infoStockPosting.Rate = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value); infoStockPosting.UnitId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvcmbProductionunitId"].Value); infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } else { infoStockPosting.BatchId = infoStockJournalDetails.BatchId; infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = infoStockJournalDetails.GodownId; infoStockPosting.InwardQty = infoStockJournalDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(infoStockJournalDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value); infoStockPosting.RackId = infoStockJournalDetails.RackId; infoStockPosting.Rate = Convert.ToDecimal(dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value); infoStockPosting.UnitId = infoStockJournalDetails.UnitId; infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } //....Additional Cost Add...//// if (btnSave.Text == "Update") { BllLedgerPosting.DeleteLedgerPostingForStockJournalEdit(strVoucherNo, decVoucherTypeId);//Delete bllAdditionalCost.DeleteAdditionalCostForStockJournalEdit(strVoucherNo, decVoucherTypeId);//Delete } decimal decGrandTotal = 0; decimal decRate = 0; ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); if (dgvAdditionalCost.Rows.Count > 1) { infoAdditionalCost.Credit = Convert.ToDecimal(lblAdditionalCostAmount.Text); infoAdditionalCost.Debit = 0; infoAdditionalCost.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue); infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.VoucherTypeId = decVoucherTypeId; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; infoAdditionalCost.ExtraDate = DateTime.Now; bllAdditionalCost.AdditionalCostAdd(infoAdditionalCost); //....Ledger Posting Add.../// //------------------- Currency Conversion----------------------------- decGrandTotal = Convert.ToDecimal(lblAdditionalCostAmount.Text.Trim()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decGrandTotal = decGrandTotal * decRate; //--------------------------------------------------------------- infoLedgerPosting.Credit = decGrandTotal; infoLedgerPosting.Debit = 0; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue); infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.VoucherTypeId = decVoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; if (btnSave.Text == "Save") { infoLedgerPosting.ExtraDate = DateTime.Now; } BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows) { if (dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value != null) { if (dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value.ToString() != string.Empty) { /*-----------------------------------------Additional Cost Add----------------------------------------------------*/ infoAdditionalCost.Credit = 0; infoAdditionalCost.Debit = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString()); infoAdditionalCost.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value.ToString()); infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.VoucherTypeId = decVoucherTypeId; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; infoAdditionalCost.ExtraDate = DateTime.Now; bllAdditionalCost.AdditionalCostAdd(infoAdditionalCost); /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/ decimal decTotal = 0; //------------------- Currency Conversion------------------------ decTotal = Convert.ToDecimal(infoAdditionalCost.Debit); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decTotal = decTotal * decRate; //--------------------------------------------------------------- infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = decTotal; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbAdditionalCostLedger"].Value.ToString()); infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.VoucherTypeId = decVoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { Print(decStockMasterId); } Clear(); } else { Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { Print(decStockJournalMasterIdForEdit); } this.Close(); } } catch (Exception ex) { MessageBox.Show("SJ:36" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }