/// <summary>
 /// Function to Edit stockposting table
 /// </summary>
 public void StockPostingTableEditFill()
 {
     try
     {
         StockPostingBll BllStockPosting = new StockPostingBll();
         StockPostingInfo infoStockPosting = new StockPostingInfo();
         BatchBll BllBatch = new BatchBll();
         for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
         {
             infoStockPosting.StockPostingId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtstockpostId"].Value);
             infoStockPosting.AgainstInvoiceNo = string.Empty;
             infoStockPosting.AgainstVoucherNo = string.Empty;
             infoStockPosting.Date = PublicVariables._dtCurrentDate;
             infoStockPosting.AgainstVoucherTypeId = 0;
             infoStockPosting.InvoiceNo = Convert.ToString(decProductIdForEdit);
             infoStockPosting.VoucherNo = Convert.ToString(decProductIdForEdit);
             infoStockPosting.VoucherTypeId = 2;
             infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbUnit"].Value);
             infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtqty"].Value);
             infoStockPosting.OutwardQty = 0;
             infoStockPosting.ProductId = decProductIdForEdit;
             infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtrate"].Value);
             infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
             infoStockPosting.Extra1 = string.Empty;
             infoStockPosting.Extra2 = string.Empty;
             infoStockPosting.ExtraDate = DateTime.Now;
             if (!dgvProductCreation.Columns["dgvcmbrack"].Visible)
             {
                 infoStockPosting.RackId = 1;
             }
             else
             {
                 infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value);
             }
             if (!dgvProductCreation.Columns["dgvcmbtgodown"].Visible)
             {
                 infoStockPosting.GodownId = 1;
             }
             else
             {
                 infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value);
             }
             if (cmbAllowBatch.SelectedIndex == 0)
             {
                 if (isBatchRemoved)
                 {
                     infoStockPosting.BatchId = BllBatch.BatchIdForStockPosting(decProductIdForEdit);
                 }
                 else
                 {
                     int inId = BllStockPosting.ReturnBatchIdFromStockPosting(decProductIdForEdit);
                     infoStockPosting.BatchId = inId;
                 }
             }
             else
             {
                 infoStockPosting.BatchId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value);
             }
             isStpUpdated = BllStockPosting.StockPostingEdit(infoStockPosting);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }