/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.shop_ship_unload model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update shop_ship_unload set "); strSql.Append("unload_name=@unload_name,"); strSql.Append("comp_id=@comp_id,"); strSql.Append("province_id=@province_id,"); strSql.Append("city_id=@city_id,"); strSql.Append("distinct_id=@distinct_id,"); strSql.Append("unload_tel=@unload_tel,"); strSql.Append("unload_address=@unload_address"); strSql.Append(" where unload_id=@unload_id "); MySqlParameter[] parameters = { new MySqlParameter("@unload_name", MySqlDbType.VarChar, 255), new MySqlParameter("@comp_id", MySqlDbType.Int32, 5), new MySqlParameter("@province_id", MySqlDbType.Int32, 5), new MySqlParameter("@city_id", MySqlDbType.Int32, 10), new MySqlParameter("@distinct_id", MySqlDbType.Int32, 11), new MySqlParameter("@unload_tel", MySqlDbType.VarChar, 255), new MySqlParameter("@unload_address", MySqlDbType.VarChar, 255), new MySqlParameter("@unload_id", MySqlDbType.Int32, 10) }; parameters[0].Value = model.unload_name; parameters[1].Value = model.comp_id; parameters[2].Value = model.province_id; parameters[3].Value = model.city_id; parameters[4].Value = model.distinct_id; parameters[5].Value = model.unload_tel; parameters[6].Value = model.unload_address; parameters[7].Value = model.unload_id; int rows = Shop_DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.shop_ship_unload DataRowToModel(DataRow row) { XHD.Model.shop_ship_unload model = new XHD.Model.shop_ship_unload(); if (row != null) { if (row["unload_id"] != null && row["unload_id"].ToString() != "") { model.unload_id = int.Parse(row["unload_id"].ToString()); } if (row["unload_name"] != null) { model.unload_name = row["unload_name"].ToString(); } if (row["comp_id"] != null && row["comp_id"].ToString() != "") { model.comp_id = int.Parse(row["comp_id"].ToString()); } if (row["province_id"] != null && row["province_id"].ToString() != "") { model.province_id = int.Parse(row["province_id"].ToString()); } if (row["city_id"] != null && row["city_id"].ToString() != "") { model.city_id = int.Parse(row["city_id"].ToString()); } if (row["distinct_id"] != null && row["distinct_id"].ToString() != "") { model.distinct_id = int.Parse(row["distinct_id"].ToString()); } if (row["unload_tel"] != null) { model.unload_tel = row["unload_tel"].ToString(); } if (row["unload_address"] != null) { model.unload_address = row["unload_address"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.shop_ship_unload model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into shop_ship_unload("); strSql.Append("unload_id,unload_name,comp_id,province_id,city_id,distinct_id,unload_tel,unload_address)"); strSql.Append(" values ("); strSql.Append("@unload_id,@unload_name,@comp_id,@province_id,@city_id,@distinct_id,@unload_tel,@unload_address)"); MySqlParameter[] parameters = { new MySqlParameter("@unload_id", MySqlDbType.Int32, 10), new MySqlParameter("@unload_name", MySqlDbType.VarChar, 255), new MySqlParameter("@comp_id", MySqlDbType.Int32, 5), new MySqlParameter("@province_id", MySqlDbType.Int32, 5), new MySqlParameter("@city_id", MySqlDbType.Int32, 10), new MySqlParameter("@distinct_id", MySqlDbType.Int32, 11), new MySqlParameter("@unload_tel", MySqlDbType.VarChar, 255), new MySqlParameter("@unload_address", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.unload_id; parameters[1].Value = model.unload_name; parameters[2].Value = model.comp_id; parameters[3].Value = model.province_id; parameters[4].Value = model.city_id; parameters[5].Value = model.distinct_id; parameters[6].Value = model.unload_tel; parameters[7].Value = model.unload_address; int rows = Shop_DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.shop_ship_unload GetModel(int unload_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select unload_id,unload_name,comp_id,province_id,city_id,distinct_id,unload_tel,unload_address from shop_ship_unload "); strSql.Append(" where unload_id=@unload_id "); MySqlParameter[] parameters = { new MySqlParameter("@unload_id", MySqlDbType.Int32, 10) }; parameters[0].Value = unload_id; XHD.Model.shop_ship_unload model = new XHD.Model.shop_ship_unload(); 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); } }