/// <summary> /// Function to Update values in account group Table /// </summary> /// <param name="unitinfo"></param> /// <returns></returns> public bool UnitEdit(UnitInfo unitinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("UnitEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = unitinfo.UnitId; sprmparam = sccmd.Parameters.Add("@unitName", SqlDbType.VarChar); sprmparam.Value = unitinfo.UnitName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = unitinfo.Narration; sprmparam = sccmd.Parameters.Add("@noOfDecimalplaces", SqlDbType.Decimal); sprmparam.Value = unitinfo.noOfDecimalplaces; sprmparam = sccmd.Parameters.Add("@formalName", SqlDbType.VarChar); sprmparam.Value = unitinfo.formalName; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = unitinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = unitinfo.Extra2; int inEffectedRow = sccmd.ExecuteNonQuery(); if (inEffectedRow > 0) { return true; } else { return false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); return false; } finally { sqlcon.Close(); } }
/// <summary> /// Function to execute while calling from frmPriceList form to add new pricelist for the product /// </summary> /// <param name="decPricingLevel"></param> /// <param name="decProduct"></param> /// <param name="decPriceListId"></param> /// <param name="frmPriceList"></param> public void CallFromPriceListForPricingLevel(decimal decPricingLevel, decimal decProduct, decimal decPriceListId, frmPriceList frmPriceList) { try { ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); UnitSP spunit = new UnitSP(); UnitInfo infoUnit = new UnitInfo(); PriceListSP spPriceList = new PriceListSP(); PriceListInfo infoPriceList = new PriceListInfo(); PricingLevelSP spPricingLevel = new PricingLevelSP(); PricingLevelInfo infoPricingLevel = new PricingLevelInfo(); infoProduct = spProduct.PriceListPopUpView(decProduct); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; decProduct = infoProduct.ProductId; decProductMain = infoProduct.ProductId; infoUnit = spunit.UnitViewForPriceListPopUp(decProduct); decUnitId = infoUnit.UnitId; txtUnitName.Text = infoUnit.UnitName; decPriceLevelId = infoPriceList.PricinglevelId; infoPricingLevel = spPricingLevel.PricingLevelNameViewForPriceListPopUp(decPricingLevel, decProduct, decUnitId); decPriceLevelId = infoPricingLevel.PricinglevelId; txtPricingLevel.Text = infoPricingLevel.PricinglevelName; if (txtPricingLevel.Text == string.Empty) { infoPricingLevel = spPricingLevel.PricingLevelView(decPricingLevel); txtPricingLevel.Text = infoPricingLevel.PricinglevelName; } decPricingLevelMain = infoPricingLevel.PricinglevelId; txtPricingLevel.ReadOnly = true; txtProductCode.ReadOnly = true; txtProductName.ReadOnly = true; txtUnitName.ReadOnly = true; txtRate.Focus(); BatchUnderProductComboFill(decProduct); PriceListPopupGridFill(); deca = decPriceListId; this.frmPriceListobj = frmPriceList; } catch (Exception ex) { MessageBox.Show("PLP1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to account group Table /// </summary> /// <param name="unitinfo"></param> /// <returns></returns> public decimal UnitAdd(UnitInfo unitinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("UnitAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@unitName", SqlDbType.VarChar); sprmparam.Value = unitinfo.UnitName; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = unitinfo.Narration; sprmparam = sccmd.Parameters.Add("@noOfDecimalplaces", SqlDbType.Decimal); sprmparam.Value = unitinfo.noOfDecimalplaces; sprmparam = sccmd.Parameters.Add("@formalName", SqlDbType.VarChar); sprmparam.Value = unitinfo.formalName; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = unitinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = unitinfo.Extra2; decIdentity = decimal.Parse(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decIdentity; }
/// <summary> /// save function /// </summary> public void SaveFunction() { try { UnitSP spUnit = new UnitSP(); UnitInfo infoUnit = new UnitInfo(); infoUnit.UnitName = txtUnitname.Text.Trim(); infoUnit.noOfDecimalplaces = Convert.ToDecimal(txtDecimalPlaces.Text.ToString()); infoUnit.Narration = txtNarration.Text.Trim(); infoUnit.formalName = txtFormalName.Text.Trim(); infoUnit.Extra1 = string.Empty; infoUnit.Extra2 = string.Empty; infoUnit.ExtraDate = DateTime.Now; if (spUnit.UnitCheckExistence(txtUnitname.Text.Trim(), 0) == false) { decUnit = spUnit.UnitAdd(infoUnit); if (decUnit > 0) { Messages.SavedMessage(); GridFill(); Clear(); } } else { Messages.InformationMessage(" Unit name already exist"); txtUnitname.Focus(); } } catch (Exception ex) { MessageBox.Show("U3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// grid cell double click event for editing purpose /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvUnitSearch_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvUnitSearch.CurrentRow != null) { if (dgvUnitSearch.Rows.Count > 0 && e.ColumnIndex > -1) { if (dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value != null) { if (dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value.ToString() != string.Empty) { if (Convert.ToDecimal(dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value) != 1) { UnitSP spUnit = new UnitSP(); UnitInfo infoUnit = new UnitInfo(); decUnitid = decimal.Parse(dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value.ToString()); infoUnit = spUnit.UnitView(decUnitid); txtFormalName.Text = infoUnit.formalName; txtDecimalPlaces.Text = infoUnit.noOfDecimalplaces.ToString(); txtNarration.Text = infoUnit.Narration; txtUnitSearch.Text = string.Empty; txtUnitname.Text = infoUnit.UnitName; strUnitName = infoUnit.UnitName; btnSave.Text = "Update"; txtUnitname.Focus(); btnDelete.Enabled = true; } else { Messages.InformationMessage("Default unit cannot update or delete"); Clear(); } } } } } } catch (Exception ex) { MessageBox.Show("U14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// update function /// </summary> public void EditFunction() { try { UnitSP spUnit = new UnitSP(); UnitInfo infoUnit = new UnitInfo(); infoUnit.UnitName = txtUnitname.Text.Trim(); infoUnit.noOfDecimalplaces = Convert.ToDecimal(txtDecimalPlaces.Text.ToString()); infoUnit.Narration = txtNarration.Text.Trim(); infoUnit.formalName = txtFormalName.Text.Trim(); infoUnit.UnitId = decUnitid; infoUnit.Extra1 = string.Empty; infoUnit.Extra2 = string.Empty; if (CheckExistenceOfUnitName() == false) { if (spUnit.UnitEdit(infoUnit)) { Messages.UpdatedMessage(); Clear(); } } else { Messages.InformationMessage("Already exists"); txtUnitname.Focus(); } } catch (Exception ex) { MessageBox.Show("U4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Doing basic calculations in cell value change /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPhysicalStock_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); BatchSP spBatch = new BatchSP(); PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP(); if (e.RowIndex != -1 && e.ColumnIndex != -1) { string strBarcode = string.Empty; string strProductCode = string.Empty; if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtBarcode") { string strBCode = string.Empty; DataTable dtbl = new DataTable(); if (dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value != null && dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString() != string.Empty) { strBCode = dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString(); productDetailsFill(strBCode, dgvPhysicalStock.CurrentRow.Index, "Barcode"); CheckColumnMissing(); } } else if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtProductCode") { UnitInfo infoUnit = new UnitInfo(); string strPrdCode = string.Empty; if (dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty) { strPrdCode = dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString(); productDetailsFill(strPrdCode, dgvPhysicalStock.CurrentRow.Index, "ProductCode"); CheckColumnMissing(); } } else if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtProductName") { string strProductName = string.Empty; DataTable dtbl = new DataTable(); if (dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null && dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty) { strProductName = dgvPhysicalStock.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString(); productDetailsFill(strProductName, dgvPhysicalStock.CurrentRow.Index, "ProductName"); CheckColumnMissing(); } } if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc || dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc) { NewAmountCalculation(e.RowIndex); CheckColumnMissing(); } if (dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc || dgvPhysicalStock.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc) { CalculateTotalAmount(); } } } catch (Exception ex) { MessageBox.Show("PS:45" + 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 add new standard rate for the purticular product /// </summary> /// <param name="decProductId"></param> /// <param name="frmStandardRate"></param> public void CallFromStandardRate(decimal decProductId, frmStandardRate frmStandardRate) { try { base.Show(); StandardrateObj = frmStandardRate; StandardrateObj.Enabled = false; ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); UnitSP spUnit = new UnitSP(); UnitInfo infoUnit = new UnitInfo(); infoProduct = spProduct.ProductViewForStandardRate(decProductId); txtProductCode.Text = infoProduct.ProductCode; txtProductName.Text = infoProduct.ProductName; decProduct = infoProduct.ProductId; infoUnit = spUnit.unitVieWForStandardRate(decProductId); decUnitId = infoUnit.UnitId; txtUnitName.Text = infoUnit.UnitName; txtProductName.ReadOnly = true; txtProductCode.ReadOnly = true; txtUnitName.ReadOnly = true; BatchUnderProductComboFill(decProductId); GridFill(decProductId); } catch (Exception ex) { MessageBox.Show("SRP2:" + 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 fil Controls based on the ProductName /// </summary> /// <param name="decProductId"></param> public void FillControlsByProductName(decimal decProductId) { try { PriceListInfo InfoPriceList = new PriceListInfo(); ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); PriceListSP spPriceList = new PriceListSP(); ProductBatchInfo infoProductBatch = new ProductBatchInfo(); infoProduct = new ProductSP().ProductView(decProductId); txtProductCode.Text = infoProduct.ProductCode; infoProductBatch = spProduct.BarcodeViewByProductCode(txtProductCode.Text); decProductId = infoProductBatch.ProductId; decBatchId = infoProductBatch.BatchId; InfoPriceList = spPriceList.PriceListViewByBatchIdORProduct(decBatchId); batchcombofill(); txtBarcode.Text = infoProductBatch.Barcode; cmbItem.Text = infoProduct.ProductName; 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(); } TaxAmountCalculation(); isAfterFillControls = true; } catch (Exception ex) { MessageBox.Show("POS:27" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Unit view for PriceListPopUp based on parameter /// </summary> /// <param name="decProductId"></param> /// <returns></returns> public UnitInfo UnitViewForPriceListPopUp(decimal decProductId) { UnitInfo infoUnit = new UnitInfo(); SqlDataReader sqldr = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sqlcmd = new SqlCommand("UnitViewForPriceListPopUp", sqlcon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.Add("@productId", SqlDbType.Decimal).Value = decProductId; sqldr = sqlcmd.ExecuteReader(); while (sqldr.Read()) { infoUnit.UnitId = Convert.ToDecimal(sqldr["unitId"].ToString()); infoUnit.UnitName = (sqldr["unitName"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sqlcon.Close(); sqldr.Close(); } return infoUnit; }
/// <summary> /// Function to get particular values from account group table based on the parameter /// </summary> /// <param name="unitId"></param> /// <returns></returns> public UnitInfo UnitView(decimal unitId) { UnitInfo unitinfo = new UnitInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("UnitView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = unitId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { unitinfo.UnitId = Convert.ToDecimal(sdrreader["unitId"]); unitinfo.UnitName = sdrreader["unitName"].ToString(); unitinfo.Narration = sdrreader["narration"].ToString(); unitinfo.noOfDecimalplaces = Convert.ToDecimal(sdrreader["noOfDecimalplaces"].ToString()); unitinfo.formalName = sdrreader["formalName"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return unitinfo; }