public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtrainpartname.Text.Trim().Length == 0) { strErr += "rainpartname不能为空!\\n"; } if (this.txtcode.Text.Trim().Length == 0) { strErr += "code不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int number = int.Parse(this.lblnumber.Text); string rainpartname = this.txtrainpartname.Text; string code = this.txtcode.Text; Maticsoft.Model.rainpartition model = new Maticsoft.Model.rainpartition(); model.number = number; model.rainpartname = rainpartname; model.code = code; Maticsoft.BLL.rainpartition bll = new Maticsoft.BLL.rainpartition(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtrainpartname.Text.Trim().Length == 0) { strErr += "rainpartname不能为空!\\n"; } if (this.txtcode.Text.Trim().Length == 0) { strErr += "code不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string rainpartname = this.txtrainpartname.Text; string code = this.txtcode.Text; Maticsoft.Model.rainpartition model = new Maticsoft.Model.rainpartition(); model.rainpartname = rainpartname; model.code = code; Maticsoft.BLL.rainpartition bll = new Maticsoft.BLL.rainpartition(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.rainpartition model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update rainpartition set "); strSql.Append("rainpartname=@rainpartname,"); strSql.Append("code=@code"); strSql.Append(" where number=@number"); MySqlParameter[] parameters = { new MySqlParameter("@rainpartname", MySqlDbType.VarChar, 255), new MySqlParameter("@code", MySqlDbType.VarChar, 30), new MySqlParameter("@number", MySqlDbType.Int32, 11) }; parameters[0].Value = model.rainpartname; parameters[1].Value = model.code; parameters[2].Value = model.number; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.rainpartition model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into rainpartition("); strSql.Append("rainpartname,code)"); strSql.Append(" values ("); strSql.Append("@rainpartname,@code)"); MySqlParameter[] parameters = { new MySqlParameter("@rainpartname", MySqlDbType.VarChar, 255), new MySqlParameter("@code", MySqlDbType.VarChar, 30) }; parameters[0].Value = model.rainpartname; parameters[1].Value = model.code; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(int number) { Maticsoft.BLL.rainpartition bll = new Maticsoft.BLL.rainpartition(); Maticsoft.Model.rainpartition model = bll.GetModel(number); this.lblnumber.Text = model.number.ToString(); this.txtrainpartname.Text = model.rainpartname; this.txtcode.Text = model.code; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.rainpartition DataRowToModel(DataRow row) { Maticsoft.Model.rainpartition model = new Maticsoft.Model.rainpartition(); if (row != null) { if (row["number"] != null && row["number"].ToString() != "") { model.number = int.Parse(row["number"].ToString()); } if (row["rainpartname"] != null) { model.rainpartname = row["rainpartname"].ToString(); } if (row["code"] != null) { model.code = row["code"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.rainpartition GetModel(int number) { StringBuilder strSql = new StringBuilder(); strSql.Append("select number,rainpartname,code from rainpartition "); strSql.Append(" where number=@number"); MySqlParameter[] parameters = { new MySqlParameter("@number", MySqlDbType.Int32) }; parameters[0].Value = number; Maticsoft.Model.rainpartition model = new Maticsoft.Model.rainpartition(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }