/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.shop_base_code GetModel(string type_no, string code_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select type_no,code_id,code_name,english_name,is_display,code_type,memo from shop_base_code "); strSql.Append(" where type_no=@type_no and code_id=@code_id "); MySqlParameter[] parameters = { new MySqlParameter("@type_no", MySqlDbType.VarChar, 2), new MySqlParameter("@code_id", MySqlDbType.VarChar, 30) }; parameters[0].Value = type_no; parameters[1].Value = code_id; XHD.Model.shop_base_code model = new XHD.Model.shop_base_code(); DataSet ds = Shop_DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.shop_base_code model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update shop_base_code set "); strSql.Append("code_name=@code_name,"); strSql.Append("english_name=@english_name,"); strSql.Append("is_display=@is_display,"); strSql.Append("code_type=@code_type,"); strSql.Append("memo=@memo"); strSql.Append(" where type_no=@type_no and code_id=@code_id "); MySqlParameter[] parameters = { new MySqlParameter("@code_name", MySqlDbType.VarChar, 30), new MySqlParameter("@english_name", MySqlDbType.VarChar, 30), new MySqlParameter("@is_display", MySqlDbType.Int32, 4), new MySqlParameter("@code_type", MySqlDbType.VarChar, 20), new MySqlParameter("@memo", MySqlDbType.VarChar, 255), new MySqlParameter("@type_no", MySqlDbType.VarChar, 2), new MySqlParameter("@code_id", MySqlDbType.VarChar, 30) }; parameters[0].Value = model.code_name; parameters[1].Value = model.english_name; parameters[2].Value = model.is_display; parameters[3].Value = model.code_type; parameters[4].Value = model.memo; parameters[5].Value = model.type_no; parameters[6].Value = model.code_id; int rows = Shop_DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.shop_base_code model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into shop_base_code("); strSql.Append("type_no,code_id,code_name,english_name,is_display,code_type,memo)"); strSql.Append(" values ("); strSql.Append("@type_no,@code_id,@code_name,@english_name,@is_display,@code_type,@memo)"); MySqlParameter[] parameters = { new MySqlParameter("@type_no", MySqlDbType.VarChar, 2), new MySqlParameter("@code_id", MySqlDbType.VarChar, 30), new MySqlParameter("@code_name", MySqlDbType.VarChar, 30), new MySqlParameter("@english_name", MySqlDbType.VarChar, 30), new MySqlParameter("@is_display", MySqlDbType.Int32, 4), new MySqlParameter("@code_type", MySqlDbType.VarChar, 20), new MySqlParameter("@memo", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.type_no; parameters[1].Value = model.code_id; parameters[2].Value = model.code_name; parameters[3].Value = model.english_name; parameters[4].Value = model.is_display; parameters[5].Value = model.code_type; parameters[6].Value = model.memo; int rows = Shop_DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.shop_base_code DataRowToModel(DataRow row) { XHD.Model.shop_base_code model = new XHD.Model.shop_base_code(); if (row != null) { if (row["type_no"] != null) { model.type_no = row["type_no"].ToString(); } if (row["code_id"] != null) { model.code_id = row["code_id"].ToString(); } if (row["code_name"] != null) { model.code_name = row["code_name"].ToString(); } if (row["english_name"] != null) { model.english_name = row["english_name"].ToString(); } if (row["is_display"] != null && row["is_display"].ToString() != "") { model.is_display = int.Parse(row["is_display"].ToString()); } if (row["code_type"] != null) { model.code_type = row["code_type"].ToString(); } if (row["memo"] != null) { model.memo = row["memo"].ToString(); } } return(model); }