private void ShowInfo(int PriceTypeID) { WebDemo.BLL.WebDemo.PriceTypeDev bll = new WebDemo.BLL.WebDemo.PriceTypeDev(); WebDemo.Model.WebDemo.PriceTypeDev model = bll.GetModel(PriceTypeID); this.lblPriceTypeID.Text = model.PriceTypeID.ToString(); this.lblLateFeeRate.Text = model.LateFeeRate.ToString(); this.lblLateFeeDate.Text = model.LateFeeDate.ToString(); this.lblLateFeeBase.Text = model.LateFeeBase.ToString(); this.lblICMonth.Text = model.ICMonth.ToString(); this.lblICMaxBuy.Text = model.ICMaxBuy.ToString(); this.lblICAmount.Text = model.ICAmount.ToString(); this.lblICMonthBuy.Text = model.ICMonthBuy.ToString(); this.lblICDayAvg.Text = model.ICDayAvg.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.PriceTypeDev model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PriceTypeDev set "); strSql.Append("LateFeeRate=@LateFeeRate,"); strSql.Append("LateFeeDate=@LateFeeDate,"); strSql.Append("LateFeeBase=@LateFeeBase,"); strSql.Append("ICMonth=@ICMonth,"); strSql.Append("ICMaxBuy=@ICMaxBuy,"); strSql.Append("ICAmount=@ICAmount,"); strSql.Append("ICMonthBuy=@ICMonthBuy,"); strSql.Append("ICDayAvg=@ICDayAvg"); strSql.Append(" where PriceTypeID=@PriceTypeID "); SqlParameter[] parameters = { new SqlParameter("@LateFeeRate", SqlDbType.Decimal, 9), new SqlParameter("@LateFeeDate", SqlDbType.Int, 4), new SqlParameter("@LateFeeBase", SqlDbType.Decimal, 9), new SqlParameter("@ICMonth", SqlDbType.Int, 4), new SqlParameter("@ICMaxBuy", SqlDbType.Int, 4), new SqlParameter("@ICAmount", SqlDbType.Int, 4), new SqlParameter("@ICMonthBuy", SqlDbType.Int, 4), new SqlParameter("@ICDayAvg", SqlDbType.Int, 4), new SqlParameter("@PriceTypeID", SqlDbType.Int, 4) }; parameters[0].Value = model.LateFeeRate; parameters[1].Value = model.LateFeeDate; parameters[2].Value = model.LateFeeBase; parameters[3].Value = model.ICMonth; parameters[4].Value = model.ICMaxBuy; parameters[5].Value = model.ICAmount; parameters[6].Value = model.ICMonthBuy; parameters[7].Value = model.ICDayAvg; parameters[8].Value = model.PriceTypeID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.PriceTypeDev DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.PriceTypeDev model = new WebDemo.Model.WebDemo.PriceTypeDev(); if (row != null) { if (row["PriceTypeID"] != null && row["PriceTypeID"].ToString() != "") { model.PriceTypeID = int.Parse(row["PriceTypeID"].ToString()); } if (row["LateFeeRate"] != null && row["LateFeeRate"].ToString() != "") { model.LateFeeRate = decimal.Parse(row["LateFeeRate"].ToString()); } if (row["LateFeeDate"] != null && row["LateFeeDate"].ToString() != "") { model.LateFeeDate = int.Parse(row["LateFeeDate"].ToString()); } if (row["LateFeeBase"] != null && row["LateFeeBase"].ToString() != "") { model.LateFeeBase = decimal.Parse(row["LateFeeBase"].ToString()); } if (row["ICMonth"] != null && row["ICMonth"].ToString() != "") { model.ICMonth = int.Parse(row["ICMonth"].ToString()); } if (row["ICMaxBuy"] != null && row["ICMaxBuy"].ToString() != "") { model.ICMaxBuy = int.Parse(row["ICMaxBuy"].ToString()); } if (row["ICAmount"] != null && row["ICAmount"].ToString() != "") { model.ICAmount = int.Parse(row["ICAmount"].ToString()); } if (row["ICMonthBuy"] != null && row["ICMonthBuy"].ToString() != "") { model.ICMonthBuy = int.Parse(row["ICMonthBuy"].ToString()); } if (row["ICDayAvg"] != null && row["ICDayAvg"].ToString() != "") { model.ICDayAvg = int.Parse(row["ICDayAvg"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WebDemo.Model.WebDemo.PriceTypeDev model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PriceTypeDev("); strSql.Append("PriceTypeID,LateFeeRate,LateFeeDate,LateFeeBase,ICMonth,ICMaxBuy,ICAmount,ICMonthBuy,ICDayAvg)"); strSql.Append(" values ("); strSql.Append("@PriceTypeID,@LateFeeRate,@LateFeeDate,@LateFeeBase,@ICMonth,@ICMaxBuy,@ICAmount,@ICMonthBuy,@ICDayAvg)"); SqlParameter[] parameters = { new SqlParameter("@PriceTypeID", SqlDbType.Int, 4), new SqlParameter("@LateFeeRate", SqlDbType.Decimal, 9), new SqlParameter("@LateFeeDate", SqlDbType.Int, 4), new SqlParameter("@LateFeeBase", SqlDbType.Decimal, 9), new SqlParameter("@ICMonth", SqlDbType.Int, 4), new SqlParameter("@ICMaxBuy", SqlDbType.Int, 4), new SqlParameter("@ICAmount", SqlDbType.Int, 4), new SqlParameter("@ICMonthBuy", SqlDbType.Int, 4), new SqlParameter("@ICDayAvg", SqlDbType.Int, 4) }; parameters[0].Value = model.PriceTypeID; parameters[1].Value = model.LateFeeRate; parameters[2].Value = model.LateFeeDate; parameters[3].Value = model.LateFeeBase; parameters[4].Value = model.ICMonth; parameters[5].Value = model.ICMaxBuy; parameters[6].Value = model.ICAmount; parameters[7].Value = model.ICMonthBuy; parameters[8].Value = model.ICDayAvg; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.PriceTypeDev GetModel(int PriceTypeID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PriceTypeID,LateFeeRate,LateFeeDate,LateFeeBase,ICMonth,ICMaxBuy,ICAmount,ICMonthBuy,ICDayAvg from PriceTypeDev "); strSql.Append(" where PriceTypeID=@PriceTypeID "); SqlParameter[] parameters = { new SqlParameter("@PriceTypeID", SqlDbType.Int, 4) }; parameters[0].Value = PriceTypeID; WebDemo.Model.WebDemo.PriceTypeDev model = new WebDemo.Model.WebDemo.PriceTypeDev(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtPriceTypeID.Text)) { strErr += "PriceTypeID格式错误!\\n"; } if (!PageValidate.IsDecimal(txtLateFeeRate.Text)) { strErr += "LateFeeRate格式错误!\\n"; } if (!PageValidate.IsNumber(txtLateFeeDate.Text)) { strErr += "LateFeeDate格式错误!\\n"; } if (!PageValidate.IsDecimal(txtLateFeeBase.Text)) { strErr += "LateFeeBase格式错误!\\n"; } if (!PageValidate.IsNumber(txtICMonth.Text)) { strErr += "ICMonth格式错误!\\n"; } if (!PageValidate.IsNumber(txtICMaxBuy.Text)) { strErr += "ICMaxBuy格式错误!\\n"; } if (!PageValidate.IsNumber(txtICAmount.Text)) { strErr += "ICAmount格式错误!\\n"; } if (!PageValidate.IsNumber(txtICMonthBuy.Text)) { strErr += "ICMonthBuy格式错误!\\n"; } if (!PageValidate.IsNumber(txtICDayAvg.Text)) { strErr += "ICDayAvg格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int PriceTypeID = int.Parse(this.txtPriceTypeID.Text); decimal LateFeeRate = decimal.Parse(this.txtLateFeeRate.Text); int LateFeeDate = int.Parse(this.txtLateFeeDate.Text); decimal LateFeeBase = decimal.Parse(this.txtLateFeeBase.Text); int ICMonth = int.Parse(this.txtICMonth.Text); int ICMaxBuy = int.Parse(this.txtICMaxBuy.Text); int ICAmount = int.Parse(this.txtICAmount.Text); int ICMonthBuy = int.Parse(this.txtICMonthBuy.Text); int ICDayAvg = int.Parse(this.txtICDayAvg.Text); WebDemo.Model.WebDemo.PriceTypeDev model = new WebDemo.Model.WebDemo.PriceTypeDev(); model.PriceTypeID = PriceTypeID; model.LateFeeRate = LateFeeRate; model.LateFeeDate = LateFeeDate; model.LateFeeBase = LateFeeBase; model.ICMonth = ICMonth; model.ICMaxBuy = ICMaxBuy; model.ICAmount = ICAmount; model.ICMonthBuy = ICMonthBuy; model.ICDayAvg = ICDayAvg; WebDemo.BLL.WebDemo.PriceTypeDev bll = new WebDemo.BLL.WebDemo.PriceTypeDev(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }