///<summary>条件查询产品分类</summary> ///<param name="parent_id">父亲ID 没有传 null</param> ///<returns>ProductClassCollection包含条件查询的记录</returns> public static ProductClassCollection GetListByParentId(int parent_id) { string sql; ProductClassCollection list = new ProductClassCollection(); MySqlParameter[] parms = null; if (parent_id > 0) { sql = "SELECT * FROM t_productclass WHERE Parent_Id=?Parent_Id ORDER BY PC_Order, PC_Id"; parms = new MySqlParameter[] { new MySqlParameter("?Parent_Id", MySqlDbType.Int32) }; parms[0].Value = parent_id; } else { sql = "SELECT * FROM t_productclass WHERE Parent_Id IS NULL ORDER BY PC_Order, PC_Id"; } MySqlDataReader reader = DbHelper.ExecuteDataReader(sql, parms); if (reader.HasRows) { while (reader.Read()) { list.Add(FillDataRecord(reader)); } } reader.Close(); return list; }
///<summary>查询产品分类 所有数据</summary> ///<returns>ProductClassCollection 包含所有记录.</returns> public static ProductClassCollection GetList() { ProductClassCollection list = null; string sql = "SELECT * FROM t_productclass"; MySqlDataReader reader = DbHelper.ExecuteDataReader(sql); if (reader.HasRows) { list = new ProductClassCollection(); while (reader.Read()) { list.Add(FillDataRecord(reader)); } } reader.Close(); return list; }