/// <summary> /// Edit function /// </summary> public void EditFunction() { try { StandardRateInfo infoStandardRate = new StandardRateInfo(); StandardRateSP spStandardRate = new StandardRateSP(); infoStandardRate.StandardRateId = decStandardRate; infoStandardRate.ApplicableFrom = Convert.ToDateTime(txtFromDate.Text.ToString()); infoStandardRate.ApplicableTo = Convert.ToDateTime(txtToDate.Text.ToString()); infoStandardRate.ProductId = decProduct; infoStandardRate.UnitId = decUnitId; infoStandardRate.BatchId = Convert.ToDecimal(cmbBatch.SelectedValue); infoStandardRate.Rate = Convert.ToDecimal(txtRate.Text.ToString()); infoStandardRate.Extra1 = string.Empty; infoStandardRate.Extra2 = string.Empty; if (spStandardRate.StandardrateCheckExistence(decStandardRateId, Convert.ToDateTime(txtFromDate.Text.ToString()), Convert.ToDateTime(txtToDate.Text.ToString()), decProduct, infoStandardRate.BatchId) == false) { spStandardRate.StandardRateEdit(infoStandardRate); Messages.UpdatedMessage(); GridFill(decProduct); Clear(); } else { Messages.InformationMessage("Standard rate already exist for selected product and dates"); } } catch (Exception ex) { MessageBox.Show("SRP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to StandardRate Table and return the Curresponding row's Id /// </summary> /// <param name="standardrateinfo"></param> /// <returns></returns> public decimal StandardRateAddParticularfields(StandardRateInfo standardrateinfo) { decimal decStandardRateId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StandardRateAddParticularfields", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@applicableFrom", SqlDbType.DateTime); sprmparam.Value = standardrateinfo.ApplicableFrom; sprmparam = sccmd.Parameters.Add("@applicableTo", SqlDbType.DateTime); sprmparam.Value = standardrateinfo.ApplicableTo; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.ProductId; sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.UnitId; sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.BatchId; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.Rate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = standardrateinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = standardrateinfo.Extra2; object ObjStandardRateId = sccmd.ExecuteScalar(); if (ObjStandardRateId != null) { decStandardRateId = Convert.ToDecimal(ObjStandardRateId.ToString()); } else { decStandardRateId = 0; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decStandardRateId); }
/// <summary> /// Function to insert values to StandardRate Table /// </summary> /// <param name="standardrateinfo"></param> public void StandardRateAdd(StandardRateInfo standardrateinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StandardRateAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@standardRateId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.StandardRateId; sprmparam = sccmd.Parameters.Add("@applicableFrom", SqlDbType.DateTime); sprmparam.Value = standardrateinfo.ApplicableFrom; sprmparam = sccmd.Parameters.Add("@applicableTo", SqlDbType.DateTime); sprmparam.Value = standardrateinfo.ApplicableTo; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.ProductId; sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.UnitId; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.Rate; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = standardrateinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = standardrateinfo.BatchId; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = standardrateinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = standardrateinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from StandardRate table based on the parameter /// </summary> /// <param name="standardRateId"></param> /// <returns></returns> public StandardRateInfo StandardRateView(decimal standardRateId) { StandardRateInfo standardrateinfo = new StandardRateInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StandardRateView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@standardRateId", SqlDbType.Decimal); sprmparam.Value = standardRateId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { standardrateinfo.StandardRateId = decimal.Parse(sdrreader[0].ToString()); standardrateinfo.ApplicableFrom = DateTime.Parse(sdrreader[1].ToString()); standardrateinfo.ApplicableTo = DateTime.Parse(sdrreader[2].ToString()); standardrateinfo.ProductId = decimal.Parse(sdrreader[3].ToString()); standardrateinfo.UnitId = decimal.Parse(sdrreader[4].ToString()); standardrateinfo.BatchId = decimal.Parse(sdrreader[5].ToString()); standardrateinfo.Rate = decimal.Parse(sdrreader[6].ToString()); standardrateinfo.ExtraDate = DateTime.Parse(sdrreader[7].ToString()); standardrateinfo.Extra1 = sdrreader[8].ToString(); standardrateinfo.Extra2 = sdrreader[9].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(standardrateinfo); }
/// <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); } }