/// <summary> /// Function for new row added for multiple unit /// </summary> public void NewRowAddedForMulUnit() { try { UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); UnitConvertionInfo infoUnitConversion = new UnitConvertionInfo(); for (int inI = 0; inI < dtblFromMulUnitForUpdate.Rows.Count; inI++) { if (Convert.ToDecimal(dtblFromMulUnitForUpdate.Rows[inI]["unitconvertionId"]) == 0) { infoUnitConversion.ConversionRate = Convert.ToDecimal(dtblFromMulUnitForUpdate.Rows[inI]["CnvertionRate"]); infoUnitConversion.UnitId = Convert.ToDecimal(dtblFromMulUnitForUpdate.Rows[inI]["dgvtxtUnitId"]); infoUnitConversion.Quantities = Convert.ToString(dtblFromMulUnitForUpdate.Rows[inI]["quantities"]); infoUnitConversion.Extra1 = dtblFromMulUnitForUpdate.Rows[inI]["extra1"].ToString(); infoUnitConversion.Extra2 = dtblFromMulUnitForUpdate.Rows[inI]["extra2"].ToString(); infoUnitConversion.ExtraDate = Convert.ToDateTime(dtblFromMulUnitForUpdate.Rows[inI]["extraDate"]); infoUnitConversion.ProductId = decProductIdForEdit; spUnitConvertion.UnitConvertionAdd(infoUnitConversion); } } } catch (Exception ex) { MessageBox.Show("PC:79" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save data to product table /// </summary> public void ProductTableFill() { try { ProductSP spProduct = new ProductSP(); ProductInfo infoProduct = new ProductInfo(); UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); 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 = DateTime.Now; 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 = spProduct.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 add multiple unit details to tbl_UnitConversion table /// </summary> public void UnitConvertionTableFill() { try { UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); UnitConvertionInfo infoUnitConversion = new UnitConvertionInfo(); decimal decProductId = decSaveProduct; if (btnSave.Text == "Update") { decProductId = decProductIdForEdit; } else { decProductId = decSaveProduct; } for (int i = 0; i < dtblMulUnit.Rows.Count; i++) { decimal decConversionRate = Convert.ToDecimal(dtblMulUnit.Rows[i]["CnvertionRate"]); if (decConversionRate != 0) { infoUnitConversion.ConversionRate = Convert.ToDecimal(dtblMulUnit.Rows[i]["CnvertionRate"]); infoUnitConversion.UnitId = Convert.ToDecimal(dtblMulUnit.Rows[i]["dgvtxtUnitId"]); infoUnitConversion.Quantities = Convert.ToString(dtblMulUnit.Rows[i]["quantities"]); infoUnitConversion.Extra1 = dtblMulUnit.Rows[i]["extra1"].ToString(); infoUnitConversion.Extra2 = dtblMulUnit.Rows[i]["extra2"].ToString(); infoUnitConversion.ExtraDate = Convert.ToDateTime(dtblMulUnit.Rows[i]["extraDate"]); infoUnitConversion.ProductId = decProductId; spUnitConvertion.UnitConvertionAdd(infoUnitConversion); } } } catch (Exception ex) { MessageBox.Show("PC:27" + 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); } }