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

}

DAL的更多相关文章

  1. ASP.NET MVC5+EF6+EasyUI 后台管理系统(58)-DAL层重构

    系列目录 前言:这是对本文系统一次重要的革新,很久就想要重构数据访问层了,数据访问层重复代码太多.主要集中增删该查每个模块都有,所以本次是为封装相同接口方法 如果你想了解怎么重构普通的接口DAL层请查 ...

  2. 动态创建DAL层类的实例

    为了可扩展性,方便以后对于代码的修改维护,使用动态创建DAL层对象. 1.首先在webconfig中的configuration下添加配置项 <appSettings> <add k ...

  3. 携程Ctrip DAL的学习 2

    携程Ctrip DAL的学习 2 本人net开发菜鸟,原理请自行看github的官网源码. 我这里是简单的使用(helloworld的水平). 代码生成器的使用 详见 官网使用说明 注意的地方: 1 ...

  4. 携程Ctrip DAL的学习1

    携程Ctrip DAL的学习 1 本人net开发菜鸟,原理请自行看github的官网源码. 我这里是简单的使用(helloworld的水平). Ctrip DAL是携程框架部开发的数据库访问框架,支持 ...

  5. DAL.SQLHelper 的类型初始值设定项引发异常的处理

    这是DAL.SQLHelper的类中定义了sql连接字符串,但是在web.config中没有定义,在类判断获取的字符串是否为空,或是在web.config添加相应的连接字符串.

  6. ashx文件不能使用DAL和Model的解决办法

    好久没有写web程序了,今天在写web程序时,发现一个问题,在ashx文件中,已经using了DAL和Model命名空间,而且引用中也引用了程序集,可是还报错:未能找到类型或命名空间"Mod ...

  7. Entity Framework连接Mysql数据库并生成Model和DAL层

    Entity Framework (EF,ADO.NET Entity Framework)是微软官方提供的.NET平台的ORM框架.相比于LINQ TO SQL,EF框架具有很明显的优势: EF框架 ...

  8. 三层架构dal 层基本代码 非查询/查询

    DAL 数据链路层 非查询/查询 using System;using System.Collections.Generic;using System.Linq;using System.Text;u ...

  9. 三个 DAL 相关的Java代码小工具

    最近在做 DAL (Data Access Layer 数据访问层) 的服务化,发现有不少地方是人工编写比较繁琐的,因此写了几个小工具来完成. 1.  从 DAO 类自动生成 CoreService ...

  10. DAL、DAO、ORM、Active Record辨析

    转自:http://blog.csdn.net/suiye/article/details/7824943 模型 Model 模型是MVC中的概念,指的是读取数据和改变数据的操作(业务逻辑).一开始我 ...

随机推荐

  1. 高通电源管理函数的power_supply的调用关系

    以msm8909为例,高通的主要文件有几个: qpnp-linear-charger.c(线性充电器) qpnp-vm-bms.c(BMS管理) power_supply_core.c(power_s ...

  2. 非阻塞IO模型

    #include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> # ...

  3. xpath相关用法及技巧

    本节讲解网页解析神器----XPath lxml下载 xpath基本用法 xpath插件 Xpath及XML路径语言,它是一门在XML文档查找信息的语言. 一:lxml下载以及安装 首先需要解决lxm ...

  4. C++ 大作业资料总结

    一般 C++ 大作业都是用 Qt 来写,Qt 本身带了很多例子,详见:https://doc.qt.io/qt-5/qtexamples.html# 如果你想偷懒的话,直接拿来改就好,或者去 Gith ...

  5. webpack知识分享

    webpack 4 webpack 四大核心概念: 入口(entry) // 打包入口 输出(output) : 打包后输出的位置配置 loader  : loader 让 webpack 能够去处理 ...

  6. webStrom快捷键快速创建React组件

    1. rcc + tab键 - - 用ES6模块系统创建一个React组件类 2. rccp + tab键 - - 创建一个带有PropTypes和ES6模块系统的React组件类 3. rcfc + ...

  7. python3.8安装flask出现错误“ModuleNotFoundError: No module named '_ctypes'”

    本想在CentOS下配置flask+nginx+uwsgi环境,结果安装最基础的flask包都出了问题...以下是我的环境: 服务器:阿里云ECS CentOS7 python版本:3.8.0 问题描 ...

  8. class样式的添加和设置.html

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. Python+requests+unittest+excel实现接口自动化测试框架(摘录)

    一.框架结构:  工程目录 二.Case文件设计 三.基础包 base 3.1 封装get/post请求(runmethon.py) 1 import requests 2 import json 3 ...

  10. 明解C语言 入门篇 第四章答案

    练习4-1 #include <stdio.h> int main(void) { int no; int x; do{ printf("请输入一个整数:"); sca ...