/// <summary> /// Function to add data to StockTable With Batch /// </summary> public void BatchTableWithStockAndProductBatchFill() { try { BatchSP spBatch = new BatchSP(); BatchInfo infoBatch = new BatchInfo(); StockPostingSP spStockPosting = new StockPostingSP(); 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(spBatch.AutomaticBarcodeGeneration()); decBatchId = spBatch.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 = spStockPosting.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 { BatchSP spBatch = new BatchSP(); 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(spBatch.AutomaticBarcodeGeneration()); decimal decId = spBatch.BatchAddReturnIdentity(infoBatch); //decimal decId = spBatch.StockPostingAdd(infoBatch); dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value = decId; } catch (Exception ex) { MessageBox.Show("PC:73" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }