• DAL


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data;
    using System.Data.SqlClient;

    /// <summary>
    ///SortInfo 的摘要说明
    /// </summary>
    public class SortInfo
    {

    public static List<Sort> GetSortsBig() //获取大类
    {
    //string safeSql = "GetSortsBig";
    DataTable table = SqlHelper.GetDatatable("GetSortsBig", null);
    List<Sort> sorts = new List<Sort>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Sort sort = new Sort();
    sort.SortId = Int32.Parse(r["SortId"].ToString());
    sort.SortName = r["SortName"].ToString();
    sorts.Add(sort);
    }
    }
    return sorts;
    }
    #region 通过小类Id获取其中类
    public static Sort GetmSortBysSortId(string sortId)
    {
    Sort s = null;
    SqlParameter sqlParam = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetmSortBysSortId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sort();
    s.SortId =Int32.Parse(table.Rows[0]["SortId"].ToString());
    s.SortName = table.Rows[0]["SortName"].ToString();
    }
    return s;
    }
    #endregion
    #region 通过类别Id获取其类别
    public static Sort GetSortBySortId(string sortId)
    {
    Sort s = null;
    SqlParameter sqlParam = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetSortBySortId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sort();
    s.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    s.SortName = table.Rows[0]["SortName"].ToString();
    }
    return s;
    }
    #endregion
    public static List<Sort> GetSortId(string fatherId) //通过父类Id获取其下面的小类
    {
    //string safeSql = "GetSortId";
    SqlParameter fid = new SqlParameter("@fatherId",fatherId);
    DataTable table = SqlHelper.GetDatatable("GetSortId", fid);
    List<Sort> sorts = new List<Sort>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Sort sort = new Sort();
    sort.SortId = Int32.Parse(r["SortId"].ToString());
    sort.SortFatherId = Int32.Parse(r["SortFatherId"].ToString());
    sort.SortName = r["SortName"].ToString();
    sorts.Add(sort);
    }

    }
    return sorts;

    }
    public static Sort GetsortBig(string sortId)//通过小类Id获取大类
    {
    Sort sort = null;
    SqlParameter splParm = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetsortBig", splParm);
    if (table.Rows.Count > 0)
    {
    sort = new Sort();
    sort.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    //sort.SortFatherId = table.Rows[0]["SortFatherId"].ToString();
    sort.SortName = table.Rows[0]["SortName"].ToString();
    }
    return sort;
    }

    public static List<Sort> GetZhongSorts(string sortId)//通过小类Id获取所有中类信息
    {
    SqlParameter sqlParm = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetZhongSorts", sqlParm);
    List<Sort> sorts = new List<Sort>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Sort sort = new Sort();
    sort.SortId = Int32.Parse(r["SortId"].ToString());
    sort.SortFatherId = Int32.Parse(r["SortFatherId"].ToString());
    sort.SortName = r["SortName"].ToString();
    sorts.Add(sort);
    }
    }
    return sorts;
    }
    //通过小类SortId获取小类下面的品牌信息
    public static List<Brand> GetBrandBySortId(string sortId)
    {
    SqlParameter sqlParm = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetBrandBySortId", sqlParm);
    List<Brand> brands = new List<Brand>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Brand brand = new Brand();
    brand.BrandId = Int32.Parse(r["BrandId"].ToString());
    brand.BrandName = r["BrandName"].ToString();
    brands.Add(brand);
    }
    }
    return brands;
    }

    #region 通过中类Id获取其下面的品牌
    public static List<Brand> GetBrandByMSortId(string sortId)
    {
    SqlParameter sqlParm = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetBrandByMSortId", sqlParm);
    List<Brand> brands = new List<Brand>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Brand b = new Brand();
    b.BrandName = r["BrandName"].ToString();
    brands.Add(b);
    }
    }
    return brands;
    }
    #endregion


    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data.SqlClient;
    using System.Data;


    /// <summary>
    ///RegistrationInfo 的摘要说明
    /// </summary>
    public class RegistrationInfo
    {
    public static int InsertRegistration(string registerEmail, string registerPassword, bool isActive, DateTime registerTime)
    {
    SqlParameter[] sqlParm = new SqlParameter[]{
    new SqlParameter("@RegisterEmail",registerEmail),
    new SqlParameter("@RegisterPassword",registerPassword),
    new SqlParameter("@IsActive",isActive),
    new SqlParameter("@RegisterTime",registerTime)
    };
    int isOk = SqlHelper.ExecuteCommand("InsertRegistration", sqlParm);

    return isOk;
    }
    public static Registration GetRegistrationByName(string registerEmail)//注册表中确定用户是否已注册过
    {
    Registration reg = null;
    SqlParameter sqlpa = new SqlParameter("@RegisterEmail", registerEmail);
    DataTable table = SqlHelper.GetDatatable("GetRegistrationByName", sqlpa);
    if (table.Rows.Count > 0)
    {
    reg = new Registration();
    reg.RegisterId = Int32.Parse(table.Rows[0]["RegisterId"].ToString());
    reg.RegisterEmail = table.Rows[0]["RegisterEmail"].ToString();
    reg.RegisterPassword = table.Rows[0]["RegisterPassword"].ToString();

    }
    return reg;
    }
    public static Registration GetuserWordMatching(string registerEmail, string passWord)//登入用户名和密码验证
    {
    Registration reg = null;
    SqlParameter[] sp = new SqlParameter[]{
    new SqlParameter("@RegisterEmail",registerEmail),
    new SqlParameter("@RegisterPassword",passWord)
    };
    DataTable table = SqlHelper.GetDatatable("GetuserWordMatching", sp);
    if (table.Rows.Count > 0)
    {
    reg = new Registration();
    reg.RegisterEmail = table.Rows[0]["RegisterEmail"].ToString();
    reg.RegisterPassword = table.Rows[0]["RegisterPassword"].ToString();
    }
    return reg;
    }

    #region 求出最新插入的用户Id
    public static void GetMaxRegistrationId(out int registrationId)
    {
    SqlParameter sqlParam = new SqlParameter();
    sqlParam.ParameterName = "@RegistrationId";
    sqlParam.DbType = DbType.Int32;
    sqlParam.Direction = ParameterDirection.Output;
    SqlCommand command = new SqlCommand();
    DataTable table = SqlHelper.GetDataTable("GetMaxRegistrationId",out command,sqlParam);
    registrationId = Int32.Parse(command.Parameters["@RegistrationId"].Value.ToString());

    }
    #endregion
    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Data.SqlClient;
    using System.Data;
    using System.Text;

    /// <summary>
    ///CommodityInfo 的摘要说明
    /// </summary>
    public class CommodityInfo
    {
    //-- 通过小类SortId 获取热卖推荐商品
    public static List<HotRecommendDetail> GetRecommentSkuDetaiBySordId(string sortId)
    {
    SqlParameter sqlParam = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetRecommentSkuDetaiBySordId", sqlParam);
    List<HotRecommendDetail> hotRecommends = new List<HotRecommendDetail>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    HotRecommendDetail hr = new HotRecommendDetail();
    hr.SkuId = Int32.Parse(r["SkuId"].ToString());
    hr.Recommentid = int.Parse(r["Recommentid"].ToString());
    hr.CommodityName = r["CommodityName"].ToString();
    hr.RecommentPrice = decimal.Parse(r["RecommentPrice"].ToString());
    hr.SortId = Int32.Parse(r["SortId"].ToString());
    hr.SkuImg = r["SkuImg"].ToString();
    hotRecommends.Add(hr);
    }
    }
    return hotRecommends;
    }
    /// <summary>
    /// 通过商品ID获取热销商品
    /// </summary>
    /// <param name="a">要添加的商品</param>
    /// <returns>返回热销商品</returns>
    public static List<HotRecommendDetail> GetHotSaleCommodityById(string commodityId)
    {
    List<HotRecommendDetail> hots = new List<HotRecommendDetail>();
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetHotSaleCommodityById", sqlParam);
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    HotRecommendDetail h = new HotRecommendDetail();
    h.Recommentid = Int32.Parse(r["Recommentid"].ToString());
    h.SkuId = Int32.Parse(r["SkuId"].ToString());
    h.RecommentPrice = decimal.Parse(r["RecommentPrice"].ToString());
    h.CommodityName = r["CommodityName"].ToString();
    h.SortId = Int32.Parse(r["SortId"].ToString());
    hots.Add(h);
    }
    }
    return hots;
    }
    //通过小类SortId获取小类下面的品牌信息
    public static List<Brand> GetBrandBySortId(string sortId)
    {
    SqlParameter sqlParam = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetBrandBySortId", sqlParam);
    List<Brand> brands = new List<Brand>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Brand b = new Brand();
    b.BrandId = Int32.Parse(r["BrandId"].ToString());
    b.SortId = Int32.Parse(r["SortId"].ToString());
    b.BrandName = r["BrandName"].ToString();
    brands.Add(b);
    }
    }
    return brands;
    }
    //通过小类Id获取其筛选属性
    public static List<Selection> GetSelectionBySortId(string sortId)
    {
    SqlParameter sqlparm = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetSelectionBySortId", sqlparm);
    List<Selection> selections = new List<Selection>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Selection s = new Selection();
    s.SelectionId = Int32.Parse(r["SelectionId"].ToString());
    s.SelectionName = r["SelectionName"].ToString();
    s.SortId = Int32.Parse(r["SortId"].ToString());
    selections.Add(s);
    }
    }
    return selections;
    }
    //通过筛选属性Id获取其筛选属性值
    public static List<SelectionValue> GetSelectionValuesBySortId(string selectionId)
    {
    SqlParameter sqlParam = new SqlParameter("@SelectionId", selectionId);
    DataTable table = SqlHelper.GetDatatable("GetSelectionValuesBySortId", sqlParam);
    List<SelectionValue> selectionValues = new List<SelectionValue>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    SelectionValue s = new SelectionValue();
    s.SelectionId = Int32.Parse(r["SelectionId"].ToString());
    s.SelectionValueId = Int32.Parse(r["SelectionValueId"].ToString());
    s.SelectionValueName = r["SelectionValueName"].ToString();
    selectionValues.Add(s);
    }
    }
    return selectionValues;
    }
    #region 通过商品筛选属性值Id获取其商品筛选属性
    public static Selection GetSelectionBySelectionValueId(string selectionValueId)
    {
    Selection s = null;
    SqlParameter sqlParam = new SqlParameter("@SelectionValueId", selectionValueId);
    DataTable table = SqlHelper.GetDatatable("GetSelectionBySelectionValueId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Selection();
    s.SelectionId = Int32.Parse(table.Rows[0]["SelectionId"].ToString());
    s.SelectionName = table.Rows[0]["SelectionName"].ToString();
    s.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    }
    return s;
    }
    #endregion
    #region 通过筛选属性值Id获取其筛选值类别
    public static SelectionValue GetSelectionVlaueBySelectionValueId(string selectionValueId)
    {
    SelectionValue sv = null;
    SqlParameter sqlParam = new SqlParameter("@SelectionValueId", selectionValueId);
    DataTable table = SqlHelper.GetDatatable("GetSelectionVlaueBySelectionValueId", sqlParam);
    if (table.Rows.Count > 0)
    {
    sv = new SelectionValue();
    sv.SelectionValueId = Int32.Parse(table.Rows[0]["SelectionValueId"].ToString());
    sv.SelectionId = Int32.Parse(table.Rows[0]["SelectionId"].ToString());
    sv.SelectionValueName = table.Rows[0]["SelectionValueName"].ToString();
    }
    return sv;
    }
    #endregion

    //---***** 通过小类SortId获取商品***----
    public static List<Commodity> GetCommodityBySortId(string sortId)
    {
    SqlParameter sqlParam = new SqlParameter("@SortId", sortId);
    DataTable table = SqlHelper.GetDatatable("GetCommodityBySortId", sqlParam);
    List<Commodity> commodities = new List<Commodity>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Commodity c = new Commodity();
    c.CommodityId = Int32.Parse(r["CommodityId"].ToString());
    c.SortId = Int32.Parse(r["SortId"].ToString());
    c.CommodityName = r["CommodityName"].ToString();
    c.MarketPrice = decimal.Parse(r["MarketPrice"].ToString());
    commodities.Add(c);
    }
    }
    return commodities;
    }

    //---***** 通过商品CommodityId获取SKU***----
    public static List<Sku> GetSkuByCommodityId(string commodityId)
    {
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetSkuByCommodityId", sqlParam);
    List<Sku> skus = new List<Sku>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Sku s = new Sku();
    s.CommodityId = Int32.Parse(r["CommodityId"].ToString());
    s.SkuId = Int32.Parse(r["SkuId"].ToString());
    s.SkuPrice = decimal.Parse(r["SkuPrice"].ToString());
    s.SkuQuanlity = Int32.Parse(r["SkuQuanlity"].ToString());
    s.SkuImg = r["SkuImg"].ToString();
    s.SkuCode = r["SkuCode"].ToString();
    skus.Add(s);
    }
    }
    return skus;
    }
    //通过SkuAttributeValueId 获取SKu属性值
    public static SkuAttributeValue GetSkuAttributeValueById(string skuAttributeValueId)
    {
    SkuAttributeValue sk = null;
    SqlParameter sqlParam = new SqlParameter("@SkuAttributeValueId", skuAttributeValueId);
    DataTable table = SqlHelper.GetDatatable("GetSkuAttributeValueById", sqlParam);
    if (table.Rows.Count > 0)
    {
    sk = new SkuAttributeValue();
    sk.SkuAttributeValueId = Int32.Parse(table.Rows[0]["SkuAttributeValueId"].ToString());
    sk.SkuAttributeValueName = table.Rows[0]["SkuAttributeValueName"].ToString();
    sk.SkuAttributeId = Int32.Parse(table.Rows[0]["SkuAttributeId"].ToString());
    }
    return sk;
    }
    //--通过SkuId获取相册表中一张小图片--
    public static SkuPicture GetPictureBySkuId(string skuId)
    {
    SkuPicture s = null;
    SqlParameter sqlParam = new SqlParameter("@SkuId", skuId);
    DataTable table = SqlHelper.GetDatatable("GetPictureBySkuId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new SkuPicture();
    s.SkuPictureId = Int32.Parse(table.Rows[0]["SkuPictureId"].ToString());
    s.SkuId = Int32.Parse(table.Rows[0]["SkuId"].ToString());
    s.SkuPictureName = table.Rows[0]["SkuPictureName"].ToString();
    }
    return s;
    }
    // ----通过商品Id获取中类集合
    public static List<Sort> GetMiddleSortsByCommodityId(string commodityId)
    {
    List<Sort> sorts = new List<Sort>();
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetMiddleSortsByCommodityId", sqlParam);
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Sort s = new Sort();
    s.SortId = Int32.Parse(r["SortId"].ToString());
    s.SortFatherId = Int32.Parse(r["SortFatherId"].ToString());
    s.SortName = r["SortName"].ToString();
    sorts.Add(s);
    }
    }
    return sorts;
    }
    //----通过skuId获取商品浏览记录
    public static VisitedSku GetSkuCommodityInfoBySkuId(string skuId)
    {
    VisitedSku vs = null;
    SqlParameter sqlParam = new SqlParameter("@SkuId", skuId);
    DataTable table = SqlHelper.GetDatatable("GetSkuCommodityInfoBySkuId", sqlParam);
    if (table.Rows.Count > 0)
    {
    vs = new VisitedSku();
    vs.CommodityId = Int32.Parse(table.Rows[0]["CommodityId"].ToString());
    vs.SkuId = Int32.Parse(table.Rows[0]["SkuId"].ToString());
    vs.SkuPrice = decimal.Parse(table.Rows[0]["SkuPrice"].ToString());
    vs.CommodityName = table.Rows[0]["CommodityName"].ToString();
    }
    return vs;
    }
    // ----通过商品Id获取大类
    public static Sort GetBigSortByCommodityId(string commodityId)
    {
    Sort s = null;
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetBigSortByCommodityId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sort();
    s.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    s.SortName = table.Rows[0]["SortName"].ToString();
    }
    return s;
    }
    //通过商品Id获取中类
    public static Sort GetMiddleSortByCommodityId(string commodityId)
    {
    Sort s = null;
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetMiddleSortByCommodityId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sort();
    s.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    s.SortName = table.Rows[0]["SortName"].ToString();
    }
    return s;
    }
    //----通过商品Id获取小类
    public static Sort GetSmallSortByCommodityId(string commodityId)
    {
    Sort s = null;
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetSmallSortByCommodityId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sort();
    s.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    s.SortName = table.Rows[0]["SortName"].ToString();
    }
    return s;
    }
    //通过商品Id获取品牌
    public static Brand GetBrandByCommodityId(string commodityId)
    {
    Brand b = null;
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetBrandByCommodityId", sqlParam);
    if (table.Rows.Count > 0)
    {
    b = new Brand();
    b.BrandId = Int32.Parse(table.Rows[0]["BrandId"].ToString());
    b.BrandName = table.Rows[0]["BrandName"].ToString();
    b.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    }
    return b;
    }
    #region 通过品牌Id获取其品牌
    public static Brand GetBrandByBrandId(string brandId)
    {
    Brand b = null;
    SqlParameter sqlParam = new SqlParameter("@BrandId", brandId);
    DataTable table = SqlHelper.GetDatatable("GetBrandByBrandId", sqlParam);
    if (table.Rows.Count > 0)
    {
    b = new Brand();
    b.BrandId = Int32.Parse(table.Rows[0]["BrandId"].ToString());
    b.BrandName = table.Rows[0]["BrandName"].ToString();
    b.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    }
    return b;
    }
    #endregion
    //---通过SkuId获取商品与SKu码----
    public static CommoditySku GetCommoditySkuByCommodityId(string skuId)
    {
    CommoditySku cs = null;
    SqlParameter sqlParam = new SqlParameter("@SkuId", skuId);
    DataTable table = SqlHelper.GetDatatable("GetCommoditySkuByCommodityId", sqlParam);
    if (table.Rows.Count > 0)
    {
    cs = new CommoditySku();
    cs.SkuId = Int32.Parse(table.Rows[0]["SkuId"].ToString());
    cs.CommodityId = Int32.Parse(table.Rows[0]["CommodityId"].ToString());
    cs.SkuQuanlity = Int32.Parse(table.Rows[0]["SkuQuanlity"].ToString());
    cs.SkuCode = table.Rows[0]["SkuCode"].ToString();
    cs.SkuPrice = decimal.Parse(table.Rows[0]["SkuPrice"].ToString());
    cs.MarketPrice = decimal.Parse(table.Rows[0]["MarketPrice"].ToString());
    cs.CommodityName = table.Rows[0]["CommodityName"].ToString();
    }
    return cs;
    }
    //---通过商品ID获取商品下面的Skus集合----
    public static List<Sku> GetSkusByCommodityId(string commodityId)
    {
    SqlParameter sqlParam = new SqlParameter("@CommodityId", commodityId);
    DataTable table = SqlHelper.GetDatatable("GetSkusByCommodityId", sqlParam);
    List<Sku> skus = new List<Sku>();
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    Sku s = new Sku();
    s.CommodityId = Int32.Parse(r["CommodityId"].ToString());
    s.SkuId = Int32.Parse(r["SkuId"].ToString());
    s.SkuPrice = decimal.Parse(r["SkuPrice"].ToString());
    s.SkuQuanlity = Int32.Parse(r["SkuQuanlity"].ToString());
    s.SkuImg = r["SkuImg"].ToString();
    s.SkuCode = r["SkuCode"].ToString();
    skus.Add(s);
    }
    }
    return skus;
    }
    //-- 通过SkuId获取相册集合
    public static List<SkuPicture> GetSkuPictureBySkuId(string skuId)
    {
    List<SkuPicture> skuPictures = new List<SkuPicture>();
    SqlParameter sqlParam = new SqlParameter("@SkuId", skuId);
    DataTable table = SqlHelper.GetDatatable("GetSkuPictureBySkuId", sqlParam);
    if (table.Rows.Count > 0)
    {
    foreach (DataRow r in table.Rows)
    {
    SkuPicture sk = new SkuPicture();
    sk.SkuPictureId = Int32.Parse(r["SkuPictureId"].ToString());
    sk.SkuId = Int32.Parse(r["SkuId"].ToString());
    sk.SkuPictureName = r["SkuPictureName"].ToString();
    skuPictures.Add(sk);

    }
    }
    return skuPictures;
    }
    //**** 通过skuId获取其对应的一个Sku***
    public static Sku GetSkuOneBySkuId(string skuId)
    {
    Sku s = null;
    SqlParameter sqlParam = new SqlParameter("@SkuId", skuId);
    DataTable table = SqlHelper.GetDatatable("GetSkuOneBySkuId", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sku();
    s.SkuId = Int32.Parse(table.Rows[0]["SkuId"].ToString());
    s.CommodityId = Int32.Parse(table.Rows[0]["CommodityId"].ToString());
    s.SkuPrice = decimal.Parse(table.Rows[0]["SkuPrice"].ToString());
    s.SkuQuanlity = Int32.Parse(table.Rows[0]["SkuQuanlity"].ToString());
    s.SkuImg = table.Rows[0]["SkuImg"].ToString();
    s.SkuCode = table.Rows[0]["SkuCode"].ToString();
    }
    return s;
    }
    //---***通过商品Id和skuCode获取SKU***
    public static Sku GetSkuByCommodityIdAndSkuCode(string commodityId, string skuCode)
    {
    Sku s = null;
    SqlParameter[] sqlParam = new SqlParameter[]
    {
    new SqlParameter("@CommodityId",commodityId),
    new SqlParameter("@skuCode",skuCode)
    };
    DataTable table = SqlHelper.GetDatatable("GetSkuByCommodityIdAndSkuCode", sqlParam);
    if (table.Rows.Count > 0)
    {
    s = new Sku();
    s.SkuId = Int32.Parse(table.Rows[0]["SkuId"].ToString());
    s.CommodityId = Int32.Parse(table.Rows[0]["CommodityId"].ToString());
    s.SkuPrice = decimal.Parse(table.Rows[0]["SkuPrice"].ToString());
    s.SkuQuanlity = Int32.Parse(table.Rows[0]["SkuQuanlity"].ToString());
    s.SkuImg = table.Rows[0]["SkuImg"].ToString();
    s.SkuCode = table.Rows[0]["SkuCode"].ToString();
    }
    return s;
    }
    //---***通过属性SkuAttributeId其SkuAttribute属性**
    public static SkuAttribute GetSkuAttributeBySkuAttributeId(string skuAttributeId)
    {
    SkuAttribute sk = null;
    SqlParameter sqlParam = new SqlParameter("@SkuAttributeId", skuAttributeId);
    DataTable table = SqlHelper.GetDatatable("GetSkuAttributeBySkuAttributeId", sqlParam);
    if (table.Rows.Count > 0)
    {
    sk = new SkuAttribute();
    sk.SkuAttributeId = Int32.Parse(table.Rows[0]["SkuAttributeId"].ToString());
    sk.SortId = Int32.Parse(table.Rows[0]["SortId"].ToString());
    sk.SkuAttributeName = table.Rows[0]["SkuAttributeName"].ToString();
    }
    return sk;
    }
    #region 通过商品筛选条件提取商品
    public static List<SelectCommodity> GetSelectionConditionCommodities(string sortId, string brandId, string priceA, string priceB, string strSelectionValueId, out int howManyCommodities)
    {
    SqlParameter[] sqlParam = new SqlParameter[6];
    SqlParameter param = new SqlParameter("@SortId", sortId);
    sqlParam[0] = param;
    param = new SqlParameter("@BrandId", brandId);
    sqlParam[1] = param;
    param = new SqlParameter("@PriceA", priceA);
    sqlParam[2] = param;
    param = new SqlParameter("@PriceB", priceB);
    sqlParam[3] = param;
    param = new SqlParameter("@StrSelectionValueId", strSelectionValueId);
    sqlParam[4] = param;
    param = new SqlParameter();
    param.ParameterName = "@HowManyCommodities";
    param.DbType = DbType.Int32;
    param.Direction = ParameterDirection.Output;
    sqlParam[5] = param;
    SqlCommand cmd = new SqlCommand();
    DataTable table = SqlHelper.GetDataTable("GetSelectionConditionCommodities", out cmd, sqlParam);
    howManyCommodities = Int32.Parse(cmd.Parameters["@HowManyCommodities"].Value.ToString());
    List<SelectCommodity> commodities = null;
    if (table.Rows.Count > 0)
    {
    commodities = new List<SelectCommodity>();
    foreach (DataRow r in table.Rows)
    {
    SelectCommodity c = new SelectCommodity();
    c.CommodityId = Int32.Parse(r["CommodityId"].ToString());
    c.CommodityName = r["CommodityName"].ToString();
    c.MarketPrice = decimal.Parse(r["MarketPrice"].ToString());
    c.CommodityAddTime = DateTime.Parse(r["CommodityAddTime"].ToString());
    c.SortId = Int32.Parse(r["SortId"].ToString());
    c.BrandId = Int32.Parse(r["BrandId"].ToString());
    c.CSelectionAttribute = r["CSelectionAttribute"].ToString();
    c.SkuPrice = decimal.Parse(r["SkuPrice"].ToString());
    c.SkuImg = r["SkuImg"].ToString();
    c.SkuQuanlity = Int32.Parse(r["SkuQuanlity"].ToString());
    commodities.Add(c);
    }
    }
    return commodities;
    }
    #endregion

    #region 用Ajax提取分页商品
    public static List<SelectCommodity> GetExtractCommodity(string sortId, string brandId, string pageNumber, out int howManyPages)
    {
    SqlParameter[] sqlParam = new SqlParameter[5];
    SqlParameter param = new SqlParameter("@SortId", sortId);
    sqlParam[0] = param;
    param = new SqlParameter("@BrandId", brandId);
    sqlParam[1] = param;
    param = new SqlParameter("@PageNumber", pageNumber);
    sqlParam[2] = param;
    //param = new SqlParameter("@CommoditiesPerPage", MyShopConfiguration.CommoditiesPerPage);
    param = new SqlParameter("@CommoditiesPerPage", 12);
    sqlParam[3] = param;
    param = new SqlParameter();
    param.ParameterName = "@HowManyCommodities";
    param.DbType = DbType.Int32;
    param.Direction = ParameterDirection.Output;
    sqlParam[4] = param;
    SqlCommand command = new SqlCommand();
    DataTable table = SqlHelper.GetDataTable("GetExtractCommodity", out command, sqlParam);

    int HowManyCommodities = Int32.Parse(command.Parameters["@HowManyCommodities"].Value.ToString());
    //howManyPages = (int)Math.Ceiling((double)HowManyCommodities / (double)MyShopConfiguration.CommoditiesPerPage);
    howManyPages = (int)Math.Ceiling((double)HowManyCommodities / 12);
    List<SelectCommodity> commodities = null;
    if (table.Rows.Count > 0)
    {
    commodities = new List<SelectCommodity>();
    foreach (DataRow r in table.Rows)
    {
    SelectCommodity c = new SelectCommodity();
    c.CommodityId = Int32.Parse(r["CommodityId"].ToString());
    c.BrandId = Int32.Parse(r["BrandId"].ToString());
    c.CommodityName = r["CommodityName"].ToString();
    c.MarketPrice = decimal.Parse(r["MarketPrice"].ToString());
    c.CommodityAddTime = DateTime.Parse(r["CommodityAddTime"].ToString());
    c.SortId = Int32.Parse(r["SortId"].ToString());
    c.CSelectionAttribute = r["CSelectionAttribute"].ToString();
    c.SkuPrice = decimal.Parse(r["SkuPrice"].ToString());
    c.SkuImg = r["SkuImg"].ToString();
    commodities.Add(c);
    }
    }
    return commodities;
    }
    #endregion
    #region 商品分页用Ajax分页
    public static string GetExtractCommodityAjax(string sortId, string brandId, string pageNumber, out int howManyPages)
    {
    SqlParameter[] sqlParam = new SqlParameter[5];
    SqlParameter param = new SqlParameter("@SortId", sortId);
    sqlParam[0] = param;
    param = new SqlParameter("@BrandId", brandId);
    sqlParam[1] = param;
    param = new SqlParameter("@PageNumber", pageNumber);
    sqlParam[2] = param;
    //param = new SqlParameter("@CommoditiesPerPage", MyShopConfiguration.CommoditiesPerPage);
    param = new SqlParameter("@CommoditiesPerPage", 16);
    sqlParam[3] = param;
    param = new SqlParameter();
    param.ParameterName = "@HowManyCommodities";
    param.DbType = DbType.Int32;
    param.Direction = ParameterDirection.Output;
    sqlParam[4] = param;
    SqlCommand command = new SqlCommand();

    //howManyPages = (int)Math.Ceiling((double)HowManyCommodities / (double)MyShopConfiguration.CommoditiesPerPage);

    string xml = SqlHelper.GetXReader("GetExtractCommodityAjax",out command, sqlParam);
    int HowManyCommodities = Int32.Parse(command.Parameters["@HowManyCommodities"].Value.ToString());
    howManyPages = (int)Math.Ceiling((double)HowManyCommodities / 16);
    return xml;
    }
    #endregion
    #region 商品分页用刷新筛选
    public static List<SelectCommodity> GetExtractCommodityRefresh(string sortId, string brandId,string priceA, string priceB, string pageNumber, string strSelectionValueId, string orderAse, out int howManyPages, out int howManyCommodities)
    {
    SqlParameter[] sqlParam = new SqlParameter[9];
    SqlParameter param = new SqlParameter("@SortId", sortId);
    sqlParam[0] = param;
    param = new SqlParameter("@BrandId", brandId);
    sqlParam[1] = param;
    param = new SqlParameter("@PriceA", priceA);
    sqlParam[2] = param;
    param = new SqlParameter("@PriceB", priceB);
    sqlParam[3] = param;
    param = new SqlParameter("@PageNumber", pageNumber);
    sqlParam[4] = param;
    //param = new SqlParameter("@CommoditiesPerPage", MyShopConfiguration.CommoditiesPerPage);
    param = new SqlParameter("@CommoditiesPerPage", 8);
    sqlParam[5] = param;
    //selectAVId 为筛选时选择的商品筛选属性值Id
    param = new SqlParameter("@StrSelectionValueId", strSelectionValueId);
    sqlParam[6] = param;
    param = new SqlParameter("@orderAse", orderAse);
    sqlParam[7] = param;//排序 销量 价格 评分 上架时间
    param = new SqlParameter();
    param.ParameterName = "@HowManyCommodities";
    param.DbType = DbType.Int32;
    param.Direction = ParameterDirection.Output;
    sqlParam[8] = param;
    SqlCommand command = new SqlCommand();
    DataTable table = SqlHelper.GetDataTable("GetExtractCommodityRefresh", out command, sqlParam);

    howManyCommodities = Int32.Parse(command.Parameters["@HowManyCommodities"].Value.ToString());
    //howManyPages = (int)Math.Ceiling((double)HowManyCommodities / (double)MyShopConfiguration.CommoditiesPerPage);
    howManyPages = (int)Math.Ceiling((double)howManyCommodities / 8);
    List<SelectCommodity> commodities = null;
    if (table.Rows.Count > 0)
    {
    commodities = new List<SelectCommodity>();
    foreach (DataRow r in table.Rows)
    {
    SelectCommodity c = new SelectCommodity();
    c.CommodityId = Int32.Parse(r["CommodityId"].ToString());
    c.CommodityName = r["CommodityName"].ToString();
    c.MarketPrice = decimal.Parse(r["MarketPrice"].ToString());
    c.CommodityAddTime = DateTime.Parse(r["CommodityAddTime"].ToString());
    c.SortId = Int32.Parse(r["SortId"].ToString());
    c.BrandId = Int32.Parse(r["BrandId"].ToString());
    c.CSelectionAttribute = r["CSelectionAttribute"].ToString();
    c.SkuPrice = decimal.Parse(r["SkuPrice"].ToString());
    c.SkuImg = r["SkuImg"].ToString();
    c.SkuQuanlity = Int32.Parse(r["SkuQuanlity"].ToString());
    commodities.Add(c);
    }
    }
    return commodities;
    }
    #endregion

    }

  • 相关阅读:
    js自动小轮播
    js字符串
    工资
    可是姑娘,你为什么要编程呢?
    程序猿媳妇儿注意事项
    js勾选时显示相应内容
    js点击显示隐藏
    js选项卡
    js数组
    js旋转V字俄罗斯方块
  • 原文地址:https://www.cnblogs.com/simpleBlue3/p/3893612.html
Copyright © 2020-2023  润新知