/// <summary> /// Function to save data to product table /// </summary> public void ProductTableFill() { try { ProductCreationBll BllProductCreation = new ProductCreationBll(); ProductInfo infoProduct = new ProductInfo(); UnitConvertionBll spUnitConvertion = new UnitConvertionBll(); UnitConvertionInfo infoUnitConvertion = new UnitConvertionInfo(); infoProduct.ProductName = txtName.Text.Trim(); infoProduct.ProductCode = txtProductCode.Text.Trim(); if (txtPurchaseRate.Text != string.Empty) { infoProduct.PurchaseRate = Convert.ToDecimal(txtPurchaseRate.Text.Trim()); } else { infoProduct.PurchaseRate = 0; } if (txtSalesRate.Text != string.Empty) { infoProduct.SalesRate = Convert.ToDecimal(txtSalesRate.Text.Trim()); } else { infoProduct.SalesRate = 0; } if (txtMrp.Text != string.Empty) { infoProduct.Mrp = Convert.ToDecimal(txtMrp.Text.Trim()); } else { infoProduct.Mrp = 0; } infoProduct.MaximumStock = Convert.ToDecimal(txtMaximumStock.Text.Trim()); infoProduct.MinimumStock = Convert.ToDecimal(txtMinimumStock.Text.Trim()); infoProduct.ReorderLevel = Convert.ToDecimal(txtReorderLevel.Text.Trim()); infoProduct.Extra1 = string.Empty; infoProduct.Extra2 = string.Empty; infoProduct.ExtraDate = PublicVariables._dtCurrentDate; infoProduct.TaxId = Convert.ToDecimal(cmbTax.SelectedValue); infoProduct.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue); infoProduct.GroupId = Convert.ToDecimal(cmbGroup.SelectedValue); infoProduct.Narration = txtNarration.Text; infoUnitConvertion.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue); infoUnitConvertion.ConversionRate = 1; infoUnitConvertion.Quantities = string.Empty; infoUnitConvertion.Extra1 = string.Empty; infoUnitConvertion.Extra2 = string.Empty; infoUnitConvertion.ExtraDate = DateTime.Now; if (cmbTax.SelectedIndex == 0) { infoProduct.TaxapplicableOn = "Rate"; } else { infoProduct.TaxapplicableOn = Convert.ToString(cmbTaxApplicableOn.SelectedItem); } if (cmbBrand.SelectedIndex != -1) { infoProduct.BrandId = Convert.ToDecimal(cmbBrand.SelectedValue); } else { infoProduct.BrandId = 1; } if (cmbSize.SelectedIndex != -1) { infoProduct.SizeId = Convert.ToDecimal(cmbSize.SelectedValue); } else { infoProduct.SizeId = 1; } if (cmbModalNo.SelectedIndex != -1) { infoProduct.ModelNoId = Convert.ToDecimal(cmbModalNo.SelectedValue); } else { infoProduct.ModelNoId = 1; } if (cmbDefaultGodown.SelectedIndex != -1) { infoProduct.GodownId = Convert.ToDecimal(cmbDefaultGodown.SelectedValue); } else { infoProduct.GodownId = 1; } if (cmbDefaultRack.SelectedIndex != -1) { infoProduct.RackId = Convert.ToDecimal(cmbDefaultRack.SelectedValue); } else { infoProduct.RackId = 1; } if (cmbAllowBatch.SelectedIndex == 0) { infoProduct.IsallowBatch = false; } else { infoProduct.IsallowBatch = true; } if (cmbBom.SelectedIndex == 0) { infoProduct.IsBom = false; } else { if (isSaveBomCheck) { infoProduct.IsBom = true; } else { infoProduct.IsBom = false; } } if (cmbOpeningStock.SelectedIndex == 0) { infoProduct.Isopeningstock = false; } else { infoProduct.Isopeningstock = true; infoProduct.PurchaseRate = Convert.ToDecimal(dgvProductCreation.Rows[0].Cells["dgvtxtrate"].Value); } if (cmbMultipleUnit.SelectedIndex == 0) { infoProduct.Ismultipleunit = false; } else { if (isSaveMulUnitCheck) { infoProduct.Ismultipleunit = true; } else { infoProduct.Ismultipleunit = false; } } if (cbxActive.Checked) { infoProduct.IsActive = true; } else { infoProduct.IsActive = false; } if (cbxReminder.Checked) { infoProduct.IsshowRemember = true; } else { infoProduct.IsshowRemember = false; } decSaveProduct = BllProductCreation.ProductAdd(infoProduct); infoUnitConvertion.ProductId = decSaveProduct; spUnitConvertion.UnitConvertionAdd(infoUnitConvertion); } catch (Exception ex) { MessageBox.Show("PC:24" + 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); } }