/// <summary> /// Function to insert values to Batch Table and return the Curresponding row's Id /// </summary> /// <param name="batchinfo"></param> /// <returns></returns> public decimal BatchAddReturnIdentity(BatchInfo batchinfo) { decimal decBatchId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BatchAddReturnIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@batchNo", SqlDbType.VarChar); sprmparam.Value = batchinfo.BatchNo; sprmparam = sccmd.Parameters.Add("@barcode", SqlDbType.VarChar); sprmparam.Value = batchinfo.barcode; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = batchinfo.ProductId; sprmparam = sccmd.Parameters.Add("@manufacturingDate", SqlDbType.DateTime); sprmparam.Value = batchinfo.ManufacturingDate; sprmparam = sccmd.Parameters.Add("@expiryDate", SqlDbType.DateTime); sprmparam.Value = batchinfo.ExpiryDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = batchinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = batchinfo.Extra2; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = batchinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = batchinfo.narration; decBatchId = Convert.ToDecimal(sccmd.ExecuteScalar()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decBatchId; }
/// <summary> /// Function to insert values to Batch Table /// </summary> /// <param name="batchinfo"></param> public void BatchAdd(BatchInfo batchinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BatchAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = batchinfo.BatchId; sprmparam = sccmd.Parameters.Add("@batchNo", SqlDbType.VarChar); sprmparam.Value = batchinfo.BatchNo; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = batchinfo.ProductId; sprmparam = sccmd.Parameters.Add("@manufacturingDate", SqlDbType.DateTime); sprmparam.Value = batchinfo.ManufacturingDate; sprmparam = sccmd.Parameters.Add("@expiryDate", SqlDbType.DateTime); sprmparam.Value = batchinfo.ExpiryDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = batchinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = batchinfo.Extra2; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = batchinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = batchinfo.narration; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to save batch /// </summary> public void BatchWithBarCode() { BatchSP spBatch = new BatchSP(); BatchInfo infoBatch = new BatchInfo(); Int32 inBarcode = spBatch.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 = spBatch.BatchAddWithBarCode(infoBatch); }
/// <summary> /// Function to save batch /// </summary> public void BatchTableFill() { try { BatchSP spBatch = new BatchSP(); 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(spBatch.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 = spBatch.BatchAddAndDelete(infoBatch, decProductIdForEdit); dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value = decBatchId; } } catch (Exception ex) { MessageBox.Show("PC:" + 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); } }
/// <summary> /// Function for call from productRegister /// </summary> public void CallFromProductRegister(decimal decId, frmProductRegister frmProRegister) { try { base.Show(); this.frmProductRegisterObj = frmProRegister; frmProductRegisterObj.Enabled = false; ProductSP spProduct = new ProductSP(); ProductInfo infoProduct = new ProductInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); BatchInfo infoBatch = new BatchInfo(); StockPostingSP spStockposting = new StockPostingSP(); BatchSP spBatch = new BatchSP(); DataTable dtbl = new DataTable(); UnitSP spUnit = new UnitSP(); decProductIdForEdit = decId; infoProduct = spProduct.ProductView(decId); strUnitNameForGrid = spUnit.UnitName(infoProduct.UnitId); btnSave.Text = "Update"; btnDelete.Enabled = true; //cmbUnit.Enabled = false; txtName.Text = infoProduct.ProductName; txtProductCode.Text = infoProduct.ProductCode; cmbGroup.SelectedValue = infoProduct.GroupId; cmbBrand.SelectedValue = infoProduct.BrandId; cmbUnit.SelectedValue = infoProduct.UnitId; if (spProduct.ProductReferenceCheck(decId)) { cmbUnit.Enabled = false; } decUnitIdForUpdate = infoProduct.UnitId; cmbSize.SelectedValue = infoProduct.SizeId; cmbModalNo.SelectedValue = infoProduct.ModelNoId; cmbTax.SelectedValue = infoProduct.TaxId; cmbTaxApplicableOn.SelectedItem = infoProduct.TaxapplicableOn; txtPurchaseRate.Text = infoProduct.PurchaseRate.ToString(); txtSalesRate.Text = infoProduct.SalesRate.ToString(); txtMrp.Text = infoProduct.Mrp.ToString(); txtMinimumStock.Text = infoProduct.MinimumStock.ToString(); txtMaximumStock.Text = infoProduct.MaximumStock.ToString(); txtReorderLevel.Text = infoProduct.ReorderLevel.ToString(); txtPartNo.Text = infoProduct.PartNo; cmbDefaultGodown.SelectedValue = infoProduct.GodownId; cmbDefaultRack.SelectedValue = infoProduct.RackId; if (infoProduct.IsBom) { cmbBom.SelectedIndex = 1; isBomFromRegister = true; } if (infoProduct.Ismultipleunit) { cmbMultipleUnit.SelectedIndex = 1; isMulUnitFromRgister = true; } if (infoProduct.Isopeningstock) { isOpeningStockForUpdate = true; OpeningStockGridFill(); } if (infoProduct.IsallowBatch) { OpeningStockGridWithBathFill(); } else { cmbAllowBatch.SelectedIndex = 0; txtPartNo.Text = spBatch.PartNoReturn(decProductIdForEdit); } if (infoProduct.Ismultipleunit) { cmbMultipleUnit.SelectedIndex = 1; } else { cmbMultipleUnit.SelectedIndex = 0; } if (infoProduct.IsBom) { cmbBom.SelectedIndex = 1; } else { cmbBom.SelectedIndex = 0; } if (infoProduct.Isopeningstock) { cmbOpeningStock.SelectedIndex = 1; } else { cmbOpeningStock.SelectedIndex = 0; } if (infoProduct.IsActive) { cbxActive.Checked = true; } else { cbxActive.Checked = false; } if (infoProduct.IsshowRemember) { cbxReminder.Checked = true; } else { cbxReminder.Checked = false; } txtNarration.Text = infoProduct.Narration; } catch (Exception ex) { MessageBox.Show("PC:63" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to set values to controls when click in grid /// </summary> public void FillControls() { try { BatchInfo infoBatch = new BatchInfo(); BatchSP spBatch = new BatchSP(); infoBatch = spBatch.BatchView(decId); txtBatchName.Text = infoBatch.BatchNo; cmbProduct.SelectedValue = infoBatch.ProductId.ToString(); txtExpiryDate.Text = infoBatch.ExpiryDate.ToString("dd-MMM-yyyy"); txtMfgDate.Text = infoBatch.ManufacturingDate.ToString("dd-MMM-yyyy"); txtNarration.Text = infoBatch.narration; decBatchId = infoBatch.BatchId; } catch (Exception ex) { MessageBox.Show("B8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
//Jamshi //public void SaveFunction() //{ // try // { // BatchSP spBatch = new BatchSP(); // 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; // if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), 0) == false) // { // if (dtpMfgDate.Value <= dtpExpiryDate.Value) // { // spBatch.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(); // } // } // catch (Exception ex) // { // MessageBox.Show("B1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); // } //} //public void EditFunction() //{ // try // { // BatchSP spBatch = new BatchSP(); // 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; // infoBatch.BatchId = decId; // if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), decBatchId) == false) // { // spBatch.BatchEdit(infoBatch); // Messages.UpdatedMessage(); // SearchClear(); // Clear(); // } // else // { // Messages.InformationMessage("Already exists"); // txtBatchName.Focus(); // } // } // catch (Exception ex) // { // MessageBox.Show("B2:" + 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 { BatchSP spBatch = new BatchSP(); 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 = spBatch.AutomaticBarcodeGeneration(); // updated by jaseel infoBatch.barcode = Convert.ToString(inBarcode); if (btnSave.Text == "Save") { //Jamshi //if (PublicVariables.isMessageAdd) //{ // if (Messages.SaveMessage()) // { // SaveFunction(); // } //} //else //{ // SaveFunction(); //} if (Messages.SaveConfirmation()) { if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), 0) == false) { if (dtpMfgDate.Value <= dtpExpiryDate.Value) { spBatch.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 { //Jamshi //if (PublicVariables.isMessageEdit) //{ // if (Messages.UpdateMessage()) // { // EditFunction(); // } //} //else //{ // EditFunction(); //} if (Messages.UpdateConfirmation()) { infoBatch.BatchId = decId; if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), decBatchId) == false) { spBatch.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 fil Controls based on the barcode /// </summary> /// <param name="strBarcode"></param> public void FillControlsByBarcode(string strBarcode) { try { BatchInfo infoBatch = new BatchInfo(); BatchSP spBatch = new BatchSP(); PriceListInfo InfoPriceList = new PriceListInfo(); PriceListSP spPriceList = new PriceListSP(); infoBatch = spBatch.BatchAndProductViewByBarcode(strBarcode); cmbBatch.Text = infoBatch.BatchNo; decProductId = infoBatch.ProductId; decBatchId = infoBatch.BatchId; InfoPriceList = spPriceList.PriceListViewByBatchIdORProduct(decBatchId); ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); infoProduct = spProduct.ProductView(decProductId); txtProductCode.Text = infoProduct.ProductCode; string strProductCode = infoProduct.ProductCode; isFromBarcode = true; cmbItem.Text = infoProduct.ProductName; isFromBarcode = false; cmbGodown.SelectedValue = infoProduct.GodownId; cmbRack.SelectedValue = infoProduct.RackId; UnitComboFill(); UnitInfo infoUnit = new UnitInfo(); infoUnit = new UnitSP().unitVieWForStandardRate(decProductId); cmbUnit.SelectedValue = infoUnit.UnitId; if (InfoPriceList.PricinglevelId != 0) { cmbPricingLevel.SelectedValue = InfoPriceList.PricinglevelId; } else { cmbPricingLevel.SelectedIndex = 0; } ComboTaxFill(); cmbTax.SelectedValue = infoProduct.TaxId; if (txtProductCode.Text.Trim() != string.Empty && cmbItem.SelectedIndex != -1) { decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces; decimal dcRate = new ProductSP().ProductRateForSales(decProductId, Convert.ToDateTime(txtDate.Text), decBatchId, decNodecplaces); txtRate.Text = dcRate.ToString(); try { if (decimal.Parse(txtQuantity.Text) == 0) txtQuantity.Text = "1"; } catch { txtQuantity.Text = "1"; } txtQuantity.Focus(); } else { txtRate.Text = string.Empty; } } catch (Exception ex) { MessageBox.Show("POS:25" + 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 fill the fields while user double click on the datagridview /// </summary> public void FillControls() { try { PriceListInfo infoPricelist = new PriceListInfo(); PriceListSP spPricelist = new PriceListSP(); infoPricelist.PricelistId = decpriceListId; infoPricelist = spPricelist.PriceListView(decpriceListId); txtRate.Text = infoPricelist.Rate.ToString(); ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); infoProduct = spProduct.PriceListPopUpView(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; BatchInfo infobatch = new BatchInfo(); BatchSP spBatch = new BatchSP(); infobatch = spBatch.BatchView(decBatchId); cmbBatch.SelectedValue = infobatch.BatchId; UnitInfo infoUnit = new UnitInfo(); UnitSP spUnit = new UnitSP(); infoUnit = spUnit.UnitView(decUnitId); txtUnitName.Text = infoUnit.UnitName; PricingLevelInfo infoPricingLevel = new PricingLevelInfo(); PricingLevelSP spPricingLevel = new PricingLevelSP(); infoPricingLevel = spPricingLevel.PricingLevelView(decPriceLevelId); txtPricingLevel.Text = infoPricingLevel.PricinglevelName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; txtPricingLevel.ReadOnly = true; } catch (Exception ex) { MessageBox.Show("PLP9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { int inRowCount = dgvMultipleProductCreation.RowCount; BatchSP spBatch = new BatchSP(); BatchInfo infoBatch = new BatchInfo(); ProductSP spProduct = new ProductSP(); ProductInfo infoProduct = new ProductInfo(); UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); 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.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 = spProduct.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; spUnitConvertion.UnitConvertionAdd(infoUnitConvertion); //...................................................................ADD BATCH TO BATCH TABLE...................................................................................// Int32 inBarcode = spBatch.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; spBatch.BatchAddWithBarCode(infoBatch); } Messages.SavedMessage(); Clear(); } catch (Exception ex) { MessageBox.Show("MPC14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from Batch Table based on the parameter /// </summary> /// <param name="batchId"></param> /// <returns></returns> public BatchInfo BatchView(decimal batchId) { BatchInfo batchinfo = new BatchInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BatchView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = batchId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { batchinfo.BatchId = decimal.Parse(sdrreader["BatchId"].ToString()); batchinfo.BatchNo = sdrreader["BatchNo"].ToString(); batchinfo.ProductId = decimal.Parse(sdrreader["ProductId"].ToString()); batchinfo.ManufacturingDate = DateTime.Parse(sdrreader["ManufacturingDate"].ToString()); batchinfo.ExpiryDate = DateTime.Parse(sdrreader["ExpiryDate"].ToString()); batchinfo.Extra1 = sdrreader["Extra1"].ToString(); batchinfo.Extra2 = sdrreader["Extra2"].ToString(); batchinfo.narration = (sdrreader["narration"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return batchinfo; }
/// <summary> /// Function to Batch And Product View By Barcode /// </summary> /// <param name="strBarcode"></param> /// <returns></returns> public BatchInfo BatchAndProductViewByBarcode(string strBarcode) { BatchInfo batchinfo = new BatchInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("BatchAndProductViewByBarcode", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@barcode", SqlDbType.VarChar); sprmparam.Value = strBarcode; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { batchinfo.BatchId = decimal.Parse(sdrreader[0].ToString()); batchinfo.BatchNo = sdrreader[1].ToString(); batchinfo.ProductId = decimal.Parse(sdrreader[2].ToString()); batchinfo.barcode = sdrreader[3].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return batchinfo; }
/// <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> /// fill Items into the purticular controls for Update or delete /// </summary> public void FillControls() { try { StandardRateInfo infoStandardRate = new StandardRateInfo(); StandardRateSP spStandardRate = new StandardRateSP(); infoStandardRate = spStandardRate.StandardRateView(decStandardRate); dtpFromDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableFrom.ToString()); dtpToDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableTo.ToString()); dtpFromDate.Text = infoStandardRate.ApplicableFrom.ToString(); dtpToDate.Text = infoStandardRate.ApplicableTo.ToString(); txtRate.Text = infoStandardRate.Rate.ToString(); decProduct = infoStandardRate.ProductId; decUnitId = infoStandardRate.UnitId; ProductSP spProduct = new ProductSP(); ProductInfo infoProduct = new ProductInfo(); infoProduct = spProduct.ProductViewForStandardRate(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; decStandardRateId = infoStandardRate.StandardRateId; UnitInfo infoUnit = new UnitInfo(); UnitSP spUnit = new UnitSP(); infoUnit = spUnit.UnitView(decUnit); txtUnitName.Text = infoUnit.UnitName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; BatchInfo infoBatch = new BatchInfo(); BatchSP spBatch = new BatchSP(); decBatchId = infoStandardRate.BatchId; infoBatch = spBatch.BatchView(decBatchId); cmbBatch.SelectedValue = infoBatch.BatchId; } catch (Exception ex) { MessageBox.Show("SRP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save data to BatchTable While Updating /// </summary> public void BatchTableEditFill() { try { BatchSP spBatch = new BatchSP(); BatchInfo infoBatch = new BatchInfo(); for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++) { infoBatch.BatchId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value); 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; isBatchUpdated = spBatch.BatchEditForProductEdit(infoBatch); } } catch (Exception ex) { MessageBox.Show("PC:19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to add the products to grid /// </summary> public void AddToGrid() { try { SettingsSP spSettings = new SettingsSP(); if (txtProductCode.Text.Trim() == null && txtProductCode.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter product code"); txtProductCode.Focus(); } else if (cmbItem.SelectedIndex == -1 && cmbItem.SelectedValue == null) { Messages.InformationMessage("Select a product"); cmbItem.Focus(); } else if (Convert.ToDecimal(txtQuantity.Text.Trim()) <= 0 || txtQuantity.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter quantity"); txtQuantity.Focus(); } else if (cmbUnit.SelectedValue == null) { Messages.InformationMessage("Select a unit"); cmbUnit.Focus(); } else if (spSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && decimal.Parse(txtRate.Text.Trim()) <= 0 || txtRate.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter rate"); txtRate.Focus(); } else { int inCurrentRowIndex = new int(); bool isExecutef = false; if (rowIdToEdit == 0) { dgvPointOfSales.Rows.Add(); inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1; isExecutef = true; } else { for (int i = 0; i < dgvPointOfSales.Rows.Count; ++i) { if (dgvPointOfSales.Rows[i].Cells["rowId"].Value.ToString() == rowIdToEdit.ToString()) { isExecutef = true; inCurrentRowIndex = i; break; } } } if (!isExecutef) { dgvPointOfSales.Rows.Add(); inCurrentRowIndex = dgvPointOfSales.Rows.Count - 1; } ProductInfo infoProduct = new ProductInfo(); BatchInfo infoBatch = new BatchInfo(); RackInfo infoRack = new RackInfo(); UnitConvertionInfo InfoUnitConvertion = new UnitConvertionInfo(); infoProduct = new ProductSP().ProductView(decProductId); decimal dcProductBatch = new BatchSP().BatchIdViewByProductId(decProductId); InfoUnitConvertion = new UnitConvertionSP().UnitViewAllByProductId(decProductId); infoBatch = new BatchSP().BatchView(dcProductBatch); decimal dcGodownId = infoProduct.GodownId; GodownInfo infoGodown = new GodownInfo(); infoGodown = new GodownSP().GodownView(dcGodownId); decimal dcRackId = infoProduct.RackId; infoRack = new RackSP().RackView(dcRackId); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = txtProductCode.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = cmbItem.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtQuantity"].Value = txtQuantity.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnit"].Value = cmbUnit.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = txtRate.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGrossValue"].Value = txtGrossValue.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxPercentage"].Value = cmbTax.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTaxAmount"].Value = txtTaxAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtNetAmount"].Value = txtNetAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtDiscount"].Value = txtDiscountAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtTotalAmount"].Value = txtAmount.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxttaxid"].Value = Convert.ToDecimal(cmbTax.SelectedValue); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchId"].Value = dcProductBatch; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackId"].Value = infoProduct.RackId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownId"].Value = infoProduct.GodownId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtUnitId"].Value = Convert.ToDecimal(cmbUnit.SelectedValue); dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtunitconversionId"].Value = InfoUnitConvertion.UnitconvertionId; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = txtBarcode.Text; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtBatchno"].Value = infoBatch.BatchNo; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtGodownName"].Value = infoGodown.GodownName; dgvPointOfSales.Rows[inCurrentRowIndex].Cells["dgvtxtRackName"].Value = infoRack.RackName; TotalAmountCalculation(); ClearGroupbox(); dgvPointOfSales.CurrentCell = dgvPointOfSales[0, dgvPointOfSales.Rows.Count - 1]; txtBarcode.Focus(); } } catch (Exception ex) { MessageBox.Show("POS:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }