/// <summary>
 /// Function to save batch
 /// </summary>
 public void BatchWithBarCode()
 {
     BatchBll BllBatch = new BatchBll();
     BatchInfo infoBatch = new BatchInfo();
     Int32 inBarcode = BllBatch.AutomaticBarcodeGeneration();
     infoBatch.BatchNo = "NA";
     infoBatch.ExpiryDate = DateTime.Now;
     infoBatch.ManufacturingDate = DateTime.Now;
     infoBatch.partNo = txtPartNo.Text.Trim();
     if (btnSave.Text == "Update")
     {
         infoBatch.ProductId = decProductIdForEdit;
     }
     else
     {
         infoBatch.ProductId = decSaveProduct;
     }
     infoBatch.narration = string.Empty;
     infoBatch.ExtraDate = DateTime.Now;
     infoBatch.barcode = Convert.ToString(inBarcode);
     infoBatch.Extra1 = string.Empty;
     infoBatch.Extra2 = string.Empty;
     inBatchIdWithPartNoNA = BllBatch.BatchAddWithBarCode(infoBatch);
 }
 /// <summary>
 /// Function to add data to StockTable With Batch
 /// </summary>
 public void BatchTableWithStockAndProductBatchFill()
 {
     try
     {
         BatchBll BllBatch = new BatchBll();
         BatchInfo infoBatch = new BatchInfo();
         StockPostingBll BllStockPosting = new StockPostingBll();
         StockPostingInfo infoStockPosting = new StockPostingInfo();
         for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
         {
             infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
             infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
             infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
             if (btnSave.Text == "Update")
             {
                 infoBatch.ProductId = decProductIdForEdit;
             }
             else
             {
                 infoBatch.ProductId = decSaveProduct;
             }
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             infoBatch.ExtraDate = DateTime.Now;
             infoBatch.narration = string.Empty;
             infoBatch.barcode = Convert.ToString(BllBatch.AutomaticBarcodeGeneration());
             decBatchId = BllBatch.BatchAddReturnIdentity(infoBatch);
             infoStockPosting.AgainstInvoiceNo = string.Empty;
             infoStockPosting.AgainstVoucherNo = string.Empty;
             infoStockPosting.Date = PublicVariables._dtCurrentDate;
             infoStockPosting.AgainstVoucherTypeId = 0;
             infoStockPosting.InvoiceNo = Convert.ToString(decSaveProduct);
             infoStockPosting.VoucherNo = Convert.ToString(decSaveProduct);
             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.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.Rows[inI].Cells["dgvcmbrack"].Visible) == false)
             {
                 infoStockPosting.RackId = 1;
             }
             else
             {
                 infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value);
             }
             if ((dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Visible) == false)
             {
                 infoStockPosting.GodownId = 1;
             }
             else
             {
                 infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value);
             }
             if (btnSave.Text == "Update")
             {
                 infoStockPosting.ProductId = decProductIdForEdit;
             }
             else
             {
                 infoStockPosting.ProductId = decSaveProduct;
             }
             if (cmbAllowBatch.SelectedIndex == 0)
             {
                 infoStockPosting.BatchId = 0;
             }
             else
             {
                 infoStockPosting.BatchId = decBatchId;
             }
             decCheck = BllStockPosting.StockPostingAdd(infoStockPosting);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:18" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function for New Row Added To tbl_Batch
 /// </summary>
 /// <param name="inI"></param>
 public void BatchTableNewRows(int inI)
 {
     try
     {
         BatchBll BllBatch = new BatchBll();
         BatchInfo infoBatch = new BatchInfo();
         infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
         infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
         infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
         infoBatch.ProductId = decProductIdForEdit;
         infoBatch.Extra1 = string.Empty;
         infoBatch.Extra2 = string.Empty;
         infoBatch.ExtraDate = DateTime.Now;
         infoBatch.narration = string.Empty;
         infoBatch.barcode = Convert.ToString(BllBatch.AutomaticBarcodeGeneration());
         decimal decId = BllBatch.BatchAddReturnIdentity(infoBatch);
         dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value = decId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:73" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to save batch
 /// </summary>
 public void BatchTableFill()
 {
     try
     {
         BatchBll BllBatch = new BatchBll();
         BatchInfo infoBatch = new BatchInfo();
         for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
         {
             infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
             infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
             infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
             infoBatch.barcode = Convert.ToString(BllBatch.AutomaticBarcodeGeneration());
             if (btnSave.Text == "Update")
             {
                 infoBatch.ProductId = decProductIdForEdit;
             }
             else
             {
                 infoBatch.ProductId = decSaveProduct;
             }
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             infoBatch.ExtraDate = DateTime.Now;
             infoBatch.narration = string.Empty;
             decBatchId = BllBatch.BatchAddAndDelete(infoBatch, decProductIdForEdit);
             dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value = decBatchId;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Functin to save and update batch
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         if (txtBatchName.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter batch name");
             txtBatchName.Focus();
         }
         else if (cmbProduct.SelectedIndex == -1)
         {
             Messages.InformationMessage("Select product");
             cmbProduct.Focus();
         }
         else
         {
             BatchBll BllBatch = new BatchBll();
             BatchInfo infoBatch = new BatchInfo();
             infoBatch.BatchNo = txtBatchName.Text.Trim();
             infoBatch.ProductId = Convert.ToDecimal(cmbProduct.SelectedValue.ToString());
             infoBatch.ManufacturingDate = Convert.ToDateTime(txtMfgDate.Text);
             infoBatch.ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text);
             infoBatch.narration = txtNarration.Text.Trim();
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             Int32 inBarcode = BllBatch.AutomaticBarcodeGeneration();
             infoBatch.barcode = Convert.ToString(inBarcode);
             if (btnSave.Text == "Save")
             {
                 if (Messages.SaveConfirmation())
                 {
                     if (BllBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), 0) == false)
                     {
                         if (dtpMfgDate.Value <= dtpExpiryDate.Value)
                         {
                             BllBatch.BatchAddParticularFields(infoBatch);
                             Messages.SavedMessage();
                             Clear();
                         }
                         else
                         {
                             Messages.InformationMessage(" Can't save batch with mfg date greater than expiry date");
                             txtMfgDate.Select();
                         }
                     }
                     else
                     {
                         Messages.InformationMessage(" Already exist");
                         txtBatchName.Focus();
                     }
                 }
             }
             else
             {
                 if (Messages.UpdateConfirmation())
                 {
                     infoBatch.BatchId = decId;
                     if (BllBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), decBatchId) == false)
                     {
                         BllBatch.BatchEdit(infoBatch);
                         Messages.UpdatedMessage();
                         SearchClear();
                         Clear();
                     }
                     else
                     {
                         Messages.InformationMessage("Already exists");
                         txtBatchName.Focus();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("B1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         int inRowCount = dgvMultipleProductCreation.RowCount;
         BatchBll BllBatch = new BatchBll();
         BatchInfo infoBatch = new BatchInfo();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         ProductInfo infoProduct = new ProductInfo();
         UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
         UnitConvertionInfo infoUnitConvertion = new UnitConvertionInfo();
         for (int i = 0; i < inRowCount - 1; i++)
         {
             infoProduct.GroupId = Convert.ToDecimal(cmbProductGroup.SelectedValue.ToString());
             infoProduct.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue.ToString());
             infoProduct.TaxId = Convert.ToDecimal(cmbTax.SelectedValue.ToString());
             if (cmbGoDown.SelectedIndex != -1)
             {
                 infoProduct.GodownId = Convert.ToDecimal(cmbGoDown.SelectedValue.ToString());
             }
             else
             {
                 infoProduct.GodownId = 0;
             }
             if (cmbRack.SelectedIndex != -1)
             {
                 infoProduct.RackId = Convert.ToDecimal(cmbRack.SelectedValue.ToString());
             }
             else
             {
                 infoProduct.RackId = 0;
             }
             infoProduct.MinimumStock = 0;
             infoProduct.MaximumStock = 0;
             infoProduct.ReorderLevel = 0;
             infoProduct.IsallowBatch = false;
             infoProduct.Ismultipleunit = false;
             infoProduct.IsBom = false;
             infoProduct.Isopeningstock = false;
             infoProduct.IsActive = true;
             infoProduct.IsshowRemember = false;
             infoProduct.Narration = string.Empty;
             infoProduct.Extra1 = string.Empty;
             infoProduct.Extra2 = string.Empty;
             infoProduct.ExtraDate = PublicVariables._dtCurrentDate;
             infoProduct.PartNo = string.Empty;
             infoProduct.TaxapplicableOn = cmbTaxApplication.SelectedItem.ToString();
             infoProduct.ProductCode = dgvMultipleProductCreation.Rows[i].Cells["dgvtxtProductCode"].Value.ToString().Trim();
             infoProduct.ProductName = dgvMultipleProductCreation.Rows[i].Cells["dgvtxtProductName"].Value.ToString().Trim();
             if (dgvMultipleProductCreation.Rows[i].Cells["dgvcmbBrand"].Value != null)
             {
                 infoProduct.BrandId = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvcmbBrand"].Value.ToString());
             }
             else
             {
                 infoProduct.BrandId = 1;
             }
             if (dgvMultipleProductCreation.Rows[i].Cells["dgvcmbModel"].Value != null)
             {
                 infoProduct.ModelNoId = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvcmbModel"].Value.ToString());
             }
             else
             {
                 infoProduct.ModelNoId = 1;
             }
             if (dgvMultipleProductCreation.Rows[i].Cells["dgvcmbSize"].Value != null)
             {
                 infoProduct.SizeId = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvcmbSize"].Value.ToString());
             }
             else
             {
                 infoProduct.SizeId = 1;
             }
             infoProduct.PurchaseRate = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvtxtPurchaseRate"].Value.ToString());
             infoProduct.SalesRate = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvtxtSalesRate"].Value.ToString());
             infoProduct.Mrp = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvtxtMRP"].Value.ToString());
             decIdentity = BllProductCreation.ProductAdd(infoProduct);
             //...................................................................ADD UNIT TO UNIT CONVERSION TABLE...................................................................................//
             infoUnitConvertion.ProductId = decIdentity;
             infoUnitConvertion.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue.ToString());
             infoUnitConvertion.ConversionRate = 1;
             infoUnitConvertion.ExtraDate = DateTime.Now;
             infoUnitConvertion.Quantities = string.Empty;
             infoUnitConvertion.Extra1 = string.Empty;
             infoUnitConvertion.Extra2 = string.Empty;
             bllUnitConvertion.UnitConvertionAdd(infoUnitConvertion);
             //...................................................................ADD BATCH TO BATCH TABLE...................................................................................//
             Int32 inBarcode = BllBatch.AutomaticBarcodeGeneration();
             infoBatch.BatchNo = "NA";
             infoBatch.ExpiryDate = DateTime.Now;
             infoBatch.ManufacturingDate = DateTime.Now;
             infoBatch.partNo = string.Empty;
             infoBatch.ProductId = decIdentity;
             infoBatch.narration = string.Empty;
             infoBatch.ExtraDate = DateTime.Now;
             infoBatch.barcode = Convert.ToString(inBarcode);
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             BllBatch.BatchAddWithBarCode(infoBatch);
         }
         Messages.SavedMessage();
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }