Пример #1
0
        /// <summary>
        /// 查看单个商品
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public Product Get_SingProduct(int nID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@ID", SqlDbType.Int, 4, nID)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_SingProduct", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            Product product = new Product();

            while (rec.Read())
            {
                ProductClass    productClass    = new ProductClass();
                ProductClassSQL productClassSQL = new ProductClassSQL();
                productClass         = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString()));
                product.productClass = productClass;
                product.ID           = Int32.Parse(rec["ID"].ToString());
                product.Pro_Name     = rec["Pro_Name"].ToString();
                product.Pic          = rec["Pic"].ToString();
                product.Content      = rec["Content"].ToString();
                product.Updatatime   = DateTime.Parse(rec["Updatatime"].ToString());
                product.Click        = Int32.Parse(rec["Click"].ToString());
            }
            return(product);
        }
Пример #2
0
        /// <summary>
        /// 按分类查看商品
        /// </summary>
        /// <param name="nstartIndex"></param>
        /// <param name="nendIndex"></param>
        /// <param name="nClassID"></param>
        /// <returns></returns>
        public List <Product> Get_Product(int nstartIndex, int nendIndex, int nClassID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@startIndex", SqlDbType.Int, 4, nstartIndex),
                sqlHelper.CreateInParam("@endIndex",   SqlDbType.Int, 4, nendIndex),
                sqlHelper.CreateInParam("@Classid",    SqlDbType.Int, 4, nClassID),
                sqlHelper.CreateInParam("@docount",    SqlDbType.Bit, 1, 0)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_ClassProduct", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <Product> List_product = new List <Product>();

            while (rec.Read())
            {
                Product         product         = new Product();
                ProductClass    productClass    = new ProductClass();
                ProductClassSQL productClassSQL = new ProductClassSQL();
                productClass         = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString()));
                product.productClass = productClass;
                product.ID           = Int32.Parse(rec["ID"].ToString());
                product.Pro_Name     = rec["Pro_Name"].ToString();
                product.Pic          = rec["Pic"].ToString();
                product.Content      = rec["Content"].ToString();
                product.Updatatime   = DateTime.Parse(rec["Updatatime"].ToString());
                product.Click        = Int32.Parse(rec["Click"].ToString());
                List_product.Add(product);
                product      = null;
                productClass = null;
            }
            return(List_product);
        }