/// <summary> /// 更新一条数据 /// </summary> public bool Update(WK.Model.bus_dish_plan model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update bus_dish_plan set "); strSql.Append("dish_id=@dish_id,"); strSql.Append("start_date=@start_date,"); strSql.Append("end_date=@end_date,"); strSql.Append("dish_type=@dish_type,"); strSql.Append("is_delete=@is_delete,"); strSql.Append("remark=@remark,"); strSql.Append("create_by=@create_by,"); strSql.Append("create_date=@create_date,"); strSql.Append("update_by=@update_by,"); strSql.Append("update_date=@update_date"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@dish_id", MySqlDbType.Int32, 11), new MySqlParameter("@start_date", MySqlDbType.DateTime), new MySqlParameter("@end_date", MySqlDbType.DateTime), new MySqlParameter("@dish_type", MySqlDbType.Int32, 11), new MySqlParameter("@is_delete", MySqlDbType.Int32, 11), new MySqlParameter("@remark", MySqlDbType.VarChar, 500), new MySqlParameter("@create_by", MySqlDbType.Int32, 11), new MySqlParameter("@create_date", MySqlDbType.DateTime), new MySqlParameter("@update_by", MySqlDbType.Int32, 11), new MySqlParameter("@update_date", MySqlDbType.VarChar, 10), new MySqlParameter("@id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.dish_id; parameters[1].Value = model.start_date; parameters[2].Value = model.end_date; parameters[3].Value = model.dish_type; parameters[4].Value = model.is_delete; parameters[5].Value = model.remark; parameters[6].Value = model.create_by; parameters[7].Value = model.create_date; parameters[8].Value = model.update_by; parameters[9].Value = model.update_date; parameters[10].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WK.Model.bus_dish_plan DataRowToModel(DataRow row) { WK.Model.bus_dish_plan model = new WK.Model.bus_dish_plan(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["dish_id"] != null && row["dish_id"].ToString() != "") { model.dish_id = int.Parse(row["dish_id"].ToString()); } if (row["start_date"] != null && row["start_date"].ToString() != "") { model.start_date = DateTime.Parse(row["start_date"].ToString()); } if (row["end_date"] != null && row["end_date"].ToString() != "") { model.end_date = DateTime.Parse(row["end_date"].ToString()); } if (row["dish_type"] != null && row["dish_type"].ToString() != "") { model.dish_type = int.Parse(row["dish_type"].ToString()); } if (row["is_delete"] != null && row["is_delete"].ToString() != "") { model.is_delete = int.Parse(row["is_delete"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["create_by"] != null && row["create_by"].ToString() != "") { model.create_by = int.Parse(row["create_by"].ToString()); } if (row["create_date"] != null && row["create_date"].ToString() != "") { model.create_date = DateTime.Parse(row["create_date"].ToString()); } if (row["update_by"] != null && row["update_by"].ToString() != "") { model.update_by = int.Parse(row["update_by"].ToString()); } if (row["update_date"] != null) { model.update_date = row["update_date"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WK.Model.bus_dish_plan model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into bus_dish_plan("); strSql.Append("dish_id,start_date,end_date,dish_type,is_delete,remark,create_by,create_date,update_by,update_date)"); strSql.Append(" values ("); strSql.Append("@dish_id,@start_date,@end_date,@dish_type,@is_delete,@remark,@create_by,@create_date,@update_by,@update_date)"); MySqlParameter[] parameters = { new MySqlParameter("@dish_id", MySqlDbType.Int32, 11), new MySqlParameter("@start_date", MySqlDbType.DateTime), new MySqlParameter("@end_date", MySqlDbType.DateTime), new MySqlParameter("@dish_type", MySqlDbType.Int32, 11), new MySqlParameter("@is_delete", MySqlDbType.Int32, 11), new MySqlParameter("@remark", MySqlDbType.VarChar, 500), new MySqlParameter("@create_by", MySqlDbType.Int32, 11), new MySqlParameter("@create_date", MySqlDbType.DateTime), new MySqlParameter("@update_by", MySqlDbType.Int32, 11), new MySqlParameter("@update_date", MySqlDbType.VarChar, 10) }; parameters[0].Value = model.dish_id; parameters[1].Value = model.start_date; parameters[2].Value = model.end_date; parameters[3].Value = model.dish_type; parameters[4].Value = model.is_delete; parameters[5].Value = model.remark; parameters[6].Value = model.create_by; parameters[7].Value = model.create_date; parameters[8].Value = model.update_by; parameters[9].Value = model.update_date; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WK.Model.bus_dish_plan GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,dish_id,start_date,end_date,dish_type,is_delete,remark,create_by,create_date,update_by,update_date from bus_dish_plan "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; WK.Model.bus_dish_plan model = new WK.Model.bus_dish_plan(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }