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