private void ShowInfo(int PID) { CHSS.BLL.CParameter bll = new CHSS.BLL.CParameter(); CHSS.Model.CParameter model = bll.GetModel(PID); this.txtPID.Text = model.PID.ToString(); this.txtParaName.Text = model.ParaName; this.txtParaValue.Text = model.ParaValue; this.txtParaMaxValue.Text = model.ParaMaxValue; this.txtParaMiniValue.Text = model.ParaMiniValue; this.txtParaUnit.Text = model.ParaUnit; this.txtParaDescription.Text = model.ParaDescription; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(CHSS.Model.CParameter model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CParameter set "); strSql.Append("ParaName=@ParaName,"); strSql.Append("ParaValue=@ParaValue,"); strSql.Append("ParaMaxValue=@ParaMaxValue,"); strSql.Append("ParaMiniValue=@ParaMiniValue,"); strSql.Append("ParaUnit=@ParaUnit,"); strSql.Append("ParaDescription=@ParaDescription"); strSql.Append(" where PID=@PID"); SqlParameter[] parameters = { new SqlParameter("@ParaName", SqlDbType.NVarChar, 50), new SqlParameter("@ParaValue", SqlDbType.NChar, 10), new SqlParameter("@ParaMaxValue", SqlDbType.NChar, 10), new SqlParameter("@ParaMiniValue", SqlDbType.NChar, 10), new SqlParameter("@ParaUnit", SqlDbType.NChar, 10), new SqlParameter("@ParaDescription", SqlDbType.NVarChar, 200), new SqlParameter("@PID", SqlDbType.Int, 4) }; parameters[0].Value = model.ParaName; parameters[1].Value = model.ParaValue; parameters[2].Value = model.ParaMaxValue; parameters[3].Value = model.ParaMiniValue; parameters[4].Value = model.ParaUnit; parameters[5].Value = model.ParaDescription; parameters[6].Value = model.PID; int rows = DBHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { string ParaName = this.txtParaName.Text; string ParaValue = this.txtParaValue.Text; string ParaMaxValue = this.txtParaMaxValue.Text; string ParaMiniValue = this.txtParaMiniValue.Text; string ParaUnit = this.txtParaUnit.Text; string ParaDescription = this.txtParaDescription.Text; CHSS.Model.CParameter model = new CHSS.Model.CParameter(); model.ParaName = ParaName; model.ParaValue = ParaValue; model.ParaMaxValue = ParaMaxValue; model.ParaMiniValue = ParaMiniValue; model.ParaUnit = ParaUnit; model.ParaDescription = ParaDescription; CHSS.BLL.CParameter bll = new CHSS.BLL.CParameter(); bll.Add(model); Response.Redirect("Show.aspx?id=" + (bll.GetMaxId() - 1)); }
public void btnSave_Click(object sender, EventArgs e) { int PID = int.Parse(this.txtPID.Text); string ParaName = this.txtParaName.Text; string ParaValue = this.txtParaValue.Text; string ParaMaxValue = this.txtParaMaxValue.Text; string ParaMiniValue = this.txtParaMiniValue.Text; string ParaUnit = this.txtParaUnit.Text; string ParaDescription = this.txtParaDescription.Text; CHSS.Model.CParameter model = new CHSS.Model.CParameter(); model.PID = PID; model.ParaName = ParaName; model.ParaValue = ParaValue; model.ParaMaxValue = ParaMaxValue; model.ParaMiniValue = ParaMiniValue; model.ParaUnit = ParaUnit; model.ParaDescription = ParaDescription; CHSS.BLL.CParameter bll = new CHSS.BLL.CParameter(); bll.Update(model); Response.Redirect("Show.aspx?id=" + PID); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(CHSS.Model.CParameter model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CParameter("); strSql.Append("ParaName,ParaValue,ParaMaxValue,ParaMiniValue,ParaUnit,ParaDescription)"); strSql.Append(" values ("); strSql.Append("@ParaName,@ParaValue,@ParaMaxValue,@ParaMiniValue,@ParaUnit,@ParaDescription)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ParaName", SqlDbType.NVarChar, 50), new SqlParameter("@ParaValue", SqlDbType.NChar, 10), new SqlParameter("@ParaMaxValue", SqlDbType.NChar, 10), new SqlParameter("@ParaMiniValue", SqlDbType.NChar, 10), new SqlParameter("@ParaUnit", SqlDbType.NChar, 10), new SqlParameter("@ParaDescription", SqlDbType.NVarChar, 200) }; parameters[0].Value = model.ParaName; parameters[1].Value = model.ParaValue; parameters[2].Value = model.ParaMaxValue; parameters[3].Value = model.ParaMiniValue; parameters[4].Value = model.ParaUnit; parameters[5].Value = model.ParaDescription; object obj = DBHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public CHSS.Model.CParameter DataRowToModel(DataRow row) { CHSS.Model.CParameter model = new CHSS.Model.CParameter(); if (row != null) { if (row["PID"] != null && row["PID"].ToString() != "") { model.PID = int.Parse(row["PID"].ToString()); } if (row["ParaName"] != null) { model.ParaName = row["ParaName"].ToString(); } if (row["ParaValue"] != null) { model.ParaValue = row["ParaValue"].ToString(); } if (row["ParaMaxValue"] != null) { model.ParaMaxValue = row["ParaMaxValue"].ToString(); } if (row["ParaMiniValue"] != null) { model.ParaMiniValue = row["ParaMiniValue"].ToString(); } if (row["ParaUnit"] != null) { model.ParaUnit = row["ParaUnit"].ToString(); } if (row["ParaDescription"] != null) { model.ParaDescription = row["ParaDescription"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public CHSS.Model.CParameter GetModel(int PID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PID,ParaName,ParaValue,ParaMaxValue,ParaMiniValue,ParaUnit,ParaDescription from CParameter "); strSql.Append(" where PID=@PID"); SqlParameter[] parameters = { new SqlParameter("@PID", SqlDbType.Int, 4) }; parameters[0].Value = PID; CHSS.Model.CParameter model = new CHSS.Model.CParameter(); DataSet ds = DBHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }