Пример #1
0
 /// <summary>
 /// Function to Update values in StockJournal Table
 /// </summary>
 /// <param name="stockjournaldetailsinfo"></param>
 public void StockJournalDetailsEdit(StockJournalDetailsInfo stockjournaldetailsinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("StockJournalDetailsEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@stockJournalDetailsId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.StockJournalDetailsId;
         sprmparam       = sccmd.Parameters.Add("@stockJournalMasterId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.StockJournalMasterId;
         sprmparam       = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.ProductId;
         sprmparam       = sccmd.Parameters.Add("@qty", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.Qty;
         sprmparam       = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.Rate;
         sprmparam       = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.UnitId;
         sprmparam       = sccmd.Parameters.Add("@unitConversionId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.UnitConversionId;
         sprmparam       = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.BatchId;
         sprmparam       = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.GodownId;
         sprmparam       = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.RackId;
         sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.Amount;
         sprmparam       = sccmd.Parameters.Add("@consumptionOrProduction", SqlDbType.VarChar);
         sprmparam.Value = stockjournaldetailsinfo.ConsumptionOrProduction;
         sprmparam       = sccmd.Parameters.Add("@slno", SqlDbType.Int);
         sprmparam.Value = stockjournaldetailsinfo.Slno;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = stockjournaldetailsinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = stockjournaldetailsinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = stockjournaldetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #2
0
 /// <summary>
 /// Function to Update values in StockJournal Table
 /// </summary>
 /// <param name="stockjournaldetailsinfo"></param>
 public void StockJournalDetailsEdit(StockJournalDetailsInfo stockjournaldetailsinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("StockJournalDetailsEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@stockJournalDetailsId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.StockJournalDetailsId;
         sprmparam = sccmd.Parameters.Add("@stockJournalMasterId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.StockJournalMasterId;
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.ProductId;
         sprmparam = sccmd.Parameters.Add("@qty", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.Qty;
         sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.Rate;
         sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.UnitId;
         sprmparam = sccmd.Parameters.Add("@unitConversionId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.UnitConversionId;
         sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.BatchId;
         sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.GodownId;
         sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.RackId;
         sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = stockjournaldetailsinfo.Amount;
         sprmparam = sccmd.Parameters.Add("@consumptionOrProduction", SqlDbType.VarChar);
         sprmparam.Value = stockjournaldetailsinfo.ConsumptionOrProduction;
         sprmparam = sccmd.Parameters.Add("@slno", SqlDbType.Int);
         sprmparam.Value = stockjournaldetailsinfo.Slno;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = stockjournaldetailsinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = stockjournaldetailsinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = stockjournaldetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Пример #3
0
        /// <summary>
        /// Function to get particular values from StockJournal Table based on parameter
        /// </summary>
        /// <param name="stockJournalDetailsId"></param>
        /// <returns></returns>
        public StockJournalDetailsInfo StockJournalDetailsView(decimal stockJournalDetailsId)
        {
            StockJournalDetailsInfo stockjournaldetailsinfo = new StockJournalDetailsInfo();
            SqlDataReader           sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("StockJournalDetailsView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@stockJournalDetailsId", SqlDbType.Decimal);
                sprmparam.Value = stockJournalDetailsId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    stockjournaldetailsinfo.StockJournalDetailsId = decimal.Parse(sdrreader[0].ToString());
                    stockjournaldetailsinfo.StockJournalMasterId  = decimal.Parse(sdrreader[1].ToString());
                    stockjournaldetailsinfo.ProductId             = decimal.Parse(sdrreader[2].ToString());
                    stockjournaldetailsinfo.Qty                     = decimal.Parse(sdrreader[3].ToString());
                    stockjournaldetailsinfo.Rate                    = decimal.Parse(sdrreader[4].ToString());
                    stockjournaldetailsinfo.UnitId                  = decimal.Parse(sdrreader[5].ToString());
                    stockjournaldetailsinfo.UnitConversionId        = decimal.Parse(sdrreader[6].ToString());
                    stockjournaldetailsinfo.BatchId                 = decimal.Parse(sdrreader[7].ToString());
                    stockjournaldetailsinfo.GodownId                = decimal.Parse(sdrreader[8].ToString());
                    stockjournaldetailsinfo.RackId                  = decimal.Parse(sdrreader[9].ToString());
                    stockjournaldetailsinfo.Amount                  = decimal.Parse(sdrreader[10].ToString());
                    stockjournaldetailsinfo.ConsumptionOrProduction = sdrreader[11].ToString();
                    stockjournaldetailsinfo.Slno                    = int.Parse(sdrreader[12].ToString());
                    stockjournaldetailsinfo.ExtraDate               = DateTime.Parse(sdrreader[13].ToString());
                    stockjournaldetailsinfo.Extra1                  = sdrreader[14].ToString();
                    stockjournaldetailsinfo.Extra2                  = sdrreader[15].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(stockjournaldetailsinfo);
        }
Пример #4
0
        /// <summary>
        /// Function to fill the details while calling from register or report 
        /// </summary>
        public void FillRegisterOrReport()
        {
            StockJournalMasterSP spStockJournalMaster = new StockJournalMasterSP();
            StockJournalDetailsSP spStockJournalDetails = new StockJournalDetailsSP();
            StockJournalMasterInfo infoStockJournalMaster = new StockJournalMasterInfo();
            StockJournalDetailsInfo infoStockJournalDetails = new StockJournalDetailsInfo();
            AdditionalCostSP spAdditionalCost = new AdditionalCostSP();
            VoucherTypeSP spVoucherType = new VoucherTypeSP();
            try
            {

                isFillMode = true;
                btnSave.Text = "Update";
                cmbFinishedGoods.Enabled = false;
                txtQty.Enabled = false;
                btnAdd.Enabled = false;
                dgvConsumption.Rows.Clear();
                dgvProduction.Rows.Clear();
                dgvAdditionalCost.Rows.Clear();
                DataTable dtblMaster = spStockJournalMaster.StockJournalMasterFillForRegisterOrReport(decStockJournalMasterIdForEdit);
                StockJournalVoucherTypeId = Convert.ToDecimal(dtblMaster.Rows[0]["voucherTypeId"].ToString());
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                infoVoucherType = spVoucherType.VoucherTypeView(StockJournalVoucherTypeId);
                this.Text = infoVoucherType.VoucherTypeName;
                txtDate.Text = dtblMaster.Rows[0]["date"].ToString();
                strVoucherNo = dtblMaster.Rows[0]["voucherNo"].ToString();
                decSuffixPrefixId = Convert.ToDecimal(dtblMaster.Rows[0]["suffixPrefixId"].ToString());
                decVoucherTypeId = Convert.ToDecimal(dtblMaster.Rows[0]["voucherTypeId"].ToString());
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(StockJournalVoucherTypeId);
                dtpDate.Value = Convert.ToDateTime(txtDate.Text);
                txtNarration.Text = dtblMaster.Rows[0]["narration"].ToString();
                cmbCurrency.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["exchangeRateId"].ToString());

                if (dtblMaster.Rows[0]["extra1"].ToString() == "Manufacturing")
                {
                    rbtnManufacturing.Checked = true;
                }
                if (dtblMaster.Rows[0]["extra1"].ToString() == "Transfer")
                {
                    rbtnTransfer.Checked = true;
                }
                if (dtblMaster.Rows[0]["extra1"].ToString() == "Stock Out")
                {
                    rbtnStockOut.Checked = true;
                }
                txtVoucherNo.Text = dtblMaster.Rows[0]["invoiceNo"].ToString();

                DataSet dsDetails = spStockJournalDetails.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 = spAdditionalCost.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);
            }
        }
Пример #5
0
        /// <summary>
        /// Function to save stockjournal
        /// </summary>
        public void Save()
        {
            try
            {
                StockJournalMasterInfo infoStockJournalMaster = new StockJournalMasterInfo();
                StockJournalMasterSP spStockJournalMaster = new StockJournalMasterSP();
                StockJournalDetailsInfo infoStockJournalDetails = new StockJournalDetailsInfo();
                StockJournalDetailsSP spStockJournalDetails = new StockJournalDetailsSP();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo();
                AdditionalCostSP spAdditionalCost = new AdditionalCostSP();
                UnitConvertionSP SPUnitConversion = new UnitConvertionSP();
                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 = spStockJournalMaster.StockJournalMasterAdd(infoStockJournalMaster);
                }
                else
                {
                    infoStockJournalMaster.StockJournalMasterId = decStockJournalMasterIdForEdit;
                    spStockJournalMaster.StockJournalMasterEdit(infoStockJournalMaster);
                    RemoveRowStockJournalConsumptionDetails();
                    RemoveRowStockJournalProductionDetails();
                    if (rbtnManufacturing.Checked)
                    {
                        //if (cmbFinishedGoods.SelectedIndex != 0 && txtQty.Text != string.Empty)
                        //{
                        //    txtQty_Leave(sender,e);
                        //}
                    }
                    RemoveRowStockJournalAdditionalCostDetails();
                    spStockPosting.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);
                                spStockJournalDetails.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);
                                spStockJournalDetails.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);
                            spStockJournalDetails.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 / SPUnitConversion.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;
                            spStockPosting.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 / SPUnitConversion.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;
                            spStockPosting.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);
                                spStockJournalDetails.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);
                                spStockJournalDetails.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);
                            spStockJournalDetails.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 / SPUnitConversion.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;
                            spStockPosting.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 / SPUnitConversion.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;
                            spStockPosting.StockPostingAdd(infoStockPosting);

                        }
                    }

                }
                //....Additional Cost Add...////
                if (btnSave.Text == "Update")
                {
                    spLedgerPosting.DeleteLedgerPostingForStockJournalEdit(strVoucherNo, decVoucherTypeId);//Delete
                    spAdditionalCost.DeleteAdditionalCostForStockJournalEdit(strVoucherNo, decVoucherTypeId);//Delete
                }
                decimal decGrandTotal = 0;
                decimal decRate = 0;
                ExchangeRateSP spExchangeRate = new ExchangeRateSP();
                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;
                    spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                    //....Ledger Posting Add...///
                    //-------------------  Currency Conversion-----------------------------
                    decGrandTotal = Convert.ToDecimal(lblAdditionalCostAmount.Text.Trim());
                    decRate = spExchangeRate.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;
                    }
                    spLedgerPosting.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;
                                spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                                /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/
                                decimal decTotal = 0;
                                //-------------------  Currency Conversion------------------------
                                decTotal = Convert.ToDecimal(infoAdditionalCost.Debit);
                                decRate = spExchangeRate.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;
                                spLedgerPosting.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);
            }
        }
Пример #6
0
 /// <summary>
 /// Function to get particular values from StockJournal Table based on parameter
 /// </summary>
 /// <param name="stockJournalDetailsId"></param>
 /// <returns></returns>
 public StockJournalDetailsInfo StockJournalDetailsView(decimal stockJournalDetailsId)
 {
     StockJournalDetailsInfo stockjournaldetailsinfo = new StockJournalDetailsInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("StockJournalDetailsView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@stockJournalDetailsId", SqlDbType.Decimal);
         sprmparam.Value = stockJournalDetailsId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             stockjournaldetailsinfo.StockJournalDetailsId = decimal.Parse(sdrreader[0].ToString());
             stockjournaldetailsinfo.StockJournalMasterId = decimal.Parse(sdrreader[1].ToString());
             stockjournaldetailsinfo.ProductId = decimal.Parse(sdrreader[2].ToString());
             stockjournaldetailsinfo.Qty = decimal.Parse(sdrreader[3].ToString());
             stockjournaldetailsinfo.Rate = decimal.Parse(sdrreader[4].ToString());
             stockjournaldetailsinfo.UnitId = decimal.Parse(sdrreader[5].ToString());
             stockjournaldetailsinfo.UnitConversionId = decimal.Parse(sdrreader[6].ToString());
             stockjournaldetailsinfo.BatchId = decimal.Parse(sdrreader[7].ToString());
             stockjournaldetailsinfo.GodownId = decimal.Parse(sdrreader[8].ToString());
             stockjournaldetailsinfo.RackId = decimal.Parse(sdrreader[9].ToString());
             stockjournaldetailsinfo.Amount = decimal.Parse(sdrreader[10].ToString());
             stockjournaldetailsinfo.ConsumptionOrProduction = sdrreader[11].ToString();
             stockjournaldetailsinfo.Slno = int.Parse(sdrreader[12].ToString());
             stockjournaldetailsinfo.ExtraDate = DateTime.Parse(sdrreader[13].ToString());
             stockjournaldetailsinfo.Extra1 = sdrreader[14].ToString();
             stockjournaldetailsinfo.Extra2 = sdrreader[15].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return stockjournaldetailsinfo;
 }