/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.ecs_goods_activity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ecs_goods_activity set "); strSql.Append("act_name=@act_name,"); strSql.Append("act_desc=@act_desc,"); strSql.Append("act_type=@act_type,"); strSql.Append("goods_id=@goods_id,"); strSql.Append("product_id=@product_id,"); strSql.Append("goods_name=@goods_name,"); strSql.Append("start_time=@start_time,"); strSql.Append("end_time=@end_time,"); strSql.Append("is_finished=@is_finished,"); strSql.Append("ext_info=@ext_info"); strSql.Append(" where act_id=@act_id"); MySqlParameter[] parameters = { new MySqlParameter("@act_name", MySqlDbType.VarChar, 255), new MySqlParameter("@act_desc", MySqlDbType.Text), new MySqlParameter("@act_type", MySqlDbType.Byte, 3), new MySqlParameter("@goods_id", MySqlDbType.Int32, 8), new MySqlParameter("@product_id", MySqlDbType.Int32, 8), new MySqlParameter("@goods_name", MySqlDbType.VarChar, 255), new MySqlParameter("@start_time", MySqlDbType.Int32, 10), new MySqlParameter("@end_time", MySqlDbType.Int32, 10), new MySqlParameter("@is_finished", MySqlDbType.Byte, 3), new MySqlParameter("@ext_info", MySqlDbType.Text), new MySqlParameter("@act_id", MySqlDbType.Int32, 8) }; parameters[0].Value = model.act_name; parameters[1].Value = model.act_desc; parameters[2].Value = model.act_type; parameters[3].Value = model.goods_id; parameters[4].Value = model.product_id; parameters[5].Value = model.goods_name; parameters[6].Value = model.start_time; parameters[7].Value = model.end_time; parameters[8].Value = model.is_finished; parameters[9].Value = model.ext_info; parameters[10].Value = model.act_id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.ecs_goods_activity DataRowToModel(DataRow row) { XHD.Model.ecs_goods_activity model = new XHD.Model.ecs_goods_activity(); if (row != null) { //model.act_id=row["act_id"].ToString(); if (row["act_name"] != null) { model.act_name = row["act_name"].ToString(); } if (row["act_desc"] != null) { model.act_desc = row["act_desc"].ToString(); } if (row["act_type"] != null && row["act_type"].ToString() != "") { model.act_type = int.Parse(row["act_type"].ToString()); } //model.goods_id=row["goods_id"].ToString(); //model.product_id=row["product_id"].ToString(); if (row["goods_name"] != null) { model.goods_name = row["goods_name"].ToString(); } if (row["start_time"] != null && row["start_time"].ToString() != "") { model.start_time = int.Parse(row["start_time"].ToString()); } if (row["end_time"] != null && row["end_time"].ToString() != "") { model.end_time = int.Parse(row["end_time"].ToString()); } if (row["is_finished"] != null && row["is_finished"].ToString() != "") { model.is_finished = int.Parse(row["is_finished"].ToString()); } if (row["ext_info"] != null) { model.ext_info = row["ext_info"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.ecs_goods_activity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ecs_goods_activity("); strSql.Append("act_name,act_desc,act_type,goods_id,product_id,goods_name,start_time,end_time,is_finished,ext_info)"); strSql.Append(" values ("); strSql.Append("@act_name,@act_desc,@act_type,@goods_id,@product_id,@goods_name,@start_time,@end_time,@is_finished,@ext_info)"); MySqlParameter[] parameters = { new MySqlParameter("@act_name", MySqlDbType.VarChar, 255), new MySqlParameter("@act_desc", MySqlDbType.Text), new MySqlParameter("@act_type", MySqlDbType.Byte, 3), new MySqlParameter("@goods_id", MySqlDbType.Int32, 8), new MySqlParameter("@product_id", MySqlDbType.Int32, 8), new MySqlParameter("@goods_name", MySqlDbType.VarChar, 255), new MySqlParameter("@start_time", MySqlDbType.Int32, 10), new MySqlParameter("@end_time", MySqlDbType.Int32, 10), new MySqlParameter("@is_finished", MySqlDbType.Byte, 3), new MySqlParameter("@ext_info", MySqlDbType.Text) }; parameters[0].Value = model.act_name; parameters[1].Value = model.act_desc; parameters[2].Value = model.act_type; parameters[3].Value = model.goods_id; parameters[4].Value = model.product_id; parameters[5].Value = model.goods_name; parameters[6].Value = model.start_time; parameters[7].Value = model.end_time; parameters[8].Value = model.is_finished; parameters[9].Value = model.ext_info; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.ecs_goods_activity GetModel(int act_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select act_id,act_name,act_desc,act_type,goods_id,product_id,goods_name,start_time,end_time,is_finished,ext_info from ecs_goods_activity "); strSql.Append(" where act_id=@act_id"); MySqlParameter[] parameters = { new MySqlParameter("@act_id", MySqlDbType.Int32) }; parameters[0].Value = act_id; XHD.Model.ecs_goods_activity model = new XHD.Model.ecs_goods_activity(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }