⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 product.cs

📁 电子商务网站转载而来[展开所有目录] [建议增加分类] (重要) 您上载的源码为何会被站长不采用或帐号被删除? 1.源码太简单 2.不是源码 3.缺少文件 4.所选类别和开发环境
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Model;
using IDAL;
using DBUnititly;

/// <summary>
/// SQLProduct 的摘要说明
/// </summary>
namespace SQLServer
{
    public class Product : IProduct
    {
        public IList<ProductInfo> GetProduct()
        {

            IList<ProductInfo> product = new List<ProductInfo>();
            using (SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.txtConnecttionString, CommandType.StoredProcedure, "SelectProduct", null))
            {
                while (dr.Read())
                {
                    ProductInfo productInfo = new ProductInfo(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetString(3), dr.GetBoolean(4));
                    product.Add(productInfo);
                }
            }
            return product;


        }
        public IList<ProductInfo> GetProductById(string nProductId)
        {

            IList<ProductInfo> product = new List<ProductInfo>();
            SqlParameter[] paras = { new SqlParameter("@Id", SqlDbType.VarChar, 30) };
            paras[0].Value = nProductId;
            using (SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.txtConnecttionString, CommandType.StoredProcedure, "SelectProductById", paras))
            {
                while (dr.Read())
                {

                    ProductInfo productInfo = new ProductInfo(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetString(3), dr.GetBoolean(4));
                    product.Add(productInfo);
                }
            }
            return product;
        }
        public IList<ProductInfo> GetProductByCategory(string nCategoryId)
        {

            IList<ProductInfo> product = new List<ProductInfo>();
            SqlParameter[] paras = { new SqlParameter("@CategoryId", SqlDbType.VarChar, 30) };
            paras[0].Value = nCategoryId;
            using (SqlDataReader dr = SQLHelper.ExecuteReader(SQLHelper.txtConnecttionString, CommandType.StoredProcedure, "SelectProductByCategoryId", paras))
            {
                while (dr.Read())
                {

                    ProductInfo productInfo = new ProductInfo(dr.GetString(0), dr.GetString(1), dr.GetString(2));
                    product.Add(productInfo);
                }
            }
            return product;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -