/// <summary> /// 增加一条数据 /// </summary> public bool Add(WalleProject.Model.t_complainadvice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_complainadvice("); strSql.Append("comd_date,comd_u_id,comd_staff_id,comd_content,comd_valid)"); strSql.Append(" values ("); strSql.Append("@comd_date,@comd_u_id,@comd_staff_id,@comd_content,@comd_valid)"); MySqlParameter[] parameters = { new MySqlParameter("@comd_date", MySqlDbType.DateTime), new MySqlParameter("@comd_u_id", MySqlDbType.Int32, 10), new MySqlParameter("@comd_staff_id", MySqlDbType.Int32, 10), new MySqlParameter("@comd_content", MySqlDbType.VarChar, 50), new MySqlParameter("@comd_valid", MySqlDbType.VarChar, 2) }; parameters[0].Value = model.comd_date; parameters[1].Value = model.comd_u_id; parameters[2].Value = model.comd_staff_id; parameters[3].Value = model.comd_content; parameters[4].Value = model.comd_valid; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WalleProject.Model.t_complainadvice DataRowToModel(DataRow row) { WalleProject.Model.t_complainadvice model = new WalleProject.Model.t_complainadvice(); if (row != null) { if (row["comd_date"] != null && row["comd_date"].ToString() != "") { model.comd_date = DateTime.Parse(row["comd_date"].ToString()); } if (row["comd_ID"] != null && row["comd_ID"].ToString() != "") { model.comd_ID = int.Parse(row["comd_ID"].ToString()); } if (row["comd_u_id"] != null && row["comd_u_id"].ToString() != "") { model.comd_u_id = int.Parse(row["comd_u_id"].ToString()); } if (row["comd_staff_id"] != null && row["comd_staff_id"].ToString() != "") { model.comd_staff_id = int.Parse(row["comd_staff_id"].ToString()); } if (row["comd_content"] != null) { model.comd_content = row["comd_content"].ToString(); } if (row["comd_valid"] != null) { model.comd_valid = row["comd_valid"].ToString(); } } return(model); }
private void ShowInfo(int comd_ID) { WalleProject.BLL.t_complainadvice bll = new WalleProject.BLL.t_complainadvice(); WalleProject.Model.t_complainadvice model = bll.GetModel(comd_ID); this.txtcomd_date.Text = model.comd_date.ToString(); this.lblcomd_ID.Text = model.comd_ID.ToString(); this.txtcomd_u_id.Text = model.comd_u_id.ToString(); this.txtcomd_staff_id.Text = model.comd_staff_id.ToString(); this.txtcomd_content.Text = model.comd_content; this.txtcomd_valid.Text = model.comd_valid; }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDateTime(txtcomd_date.Text)) { strErr += "comd_date格式错误!\\n"; } if (!PageValidate.IsNumber(txtcomd_u_id.Text)) { strErr += "comd_u_id格式错误!\\n"; } if (!PageValidate.IsNumber(txtcomd_staff_id.Text)) { strErr += "comd_staff_id格式错误!\\n"; } if (this.txtcomd_content.Text.Trim().Length == 0) { strErr += "comd_content不能为空!\\n"; } if (this.txtcomd_valid.Text.Trim().Length == 0) { strErr += "comd_valid不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } DateTime comd_date = DateTime.Parse(this.txtcomd_date.Text); int comd_ID = int.Parse(this.lblcomd_ID.Text); int comd_u_id = int.Parse(this.txtcomd_u_id.Text); int comd_staff_id = int.Parse(this.txtcomd_staff_id.Text); string comd_content = this.txtcomd_content.Text; string comd_valid = this.txtcomd_valid.Text; WalleProject.Model.t_complainadvice model = new WalleProject.Model.t_complainadvice(); model.comd_date = comd_date; model.comd_ID = comd_ID; model.comd_u_id = comd_u_id; model.comd_staff_id = comd_staff_id; model.comd_content = comd_content; model.comd_valid = comd_valid; WalleProject.BLL.t_complainadvice bll = new WalleProject.BLL.t_complainadvice(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WalleProject.Model.t_complainadvice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_complainadvice set "); strSql.Append("comd_date=@comd_date,"); strSql.Append("comd_u_id=@comd_u_id,"); strSql.Append("comd_staff_id=@comd_staff_id,"); strSql.Append("comd_content=@comd_content,"); strSql.Append("comd_valid=@comd_valid"); strSql.Append(" where comd_ID=@comd_ID"); MySqlParameter[] parameters = { new MySqlParameter("@comd_date", MySqlDbType.DateTime), new MySqlParameter("@comd_u_id", MySqlDbType.Int32, 10), new MySqlParameter("@comd_staff_id", MySqlDbType.Int32, 10), new MySqlParameter("@comd_content", MySqlDbType.VarChar, 50), new MySqlParameter("@comd_valid", MySqlDbType.VarChar, 2), new MySqlParameter("@comd_ID", MySqlDbType.Int32, 10) }; parameters[0].Value = model.comd_date; parameters[1].Value = model.comd_u_id; parameters[2].Value = model.comd_staff_id; parameters[3].Value = model.comd_content; parameters[4].Value = model.comd_valid; parameters[5].Value = model.comd_ID; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WalleProject.Model.t_complainadvice GetModel(int comd_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select comd_date,comd_ID,comd_u_id,comd_staff_id,comd_content,comd_valid from t_complainadvice "); strSql.Append(" where comd_ID=@comd_ID"); MySqlParameter[] parameters = { new MySqlParameter("@comd_ID", MySqlDbType.Int32) }; parameters[0].Value = comd_ID; WalleProject.Model.t_complainadvice model = new WalleProject.Model.t_complainadvice(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }