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