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. 详解AJAX工作原理以及实例讲解(通俗易懂)

    什么是 AJAX ? AJAX = 异步 JavaScript 和 XML. AJAX 是一种用于创建快速动态网页的技术. 通过在后台与服务器进行少量数据交换,AJAX 可以使网页实现异步更新.这意味 ...

  2. 基于docker的mysql8的主从复制

    基于docker的mysql8的主从复制 创建mysql的docker镜像 构建docker镜像,其中数据卷配置内容在下面,结构目录如下 version: '3.7' services: db: # ...

  3. 【网络安全】Dos攻击科普文

    目录 DOS攻击 什么是DOS攻击 攻击手段分类 具体的攻击方式举例 优秀博客参考 DDOS攻击 DOS攻击 什么是DOS攻击 DOS是Denial of Service的简称,用中文简单翻译就是拒绝 ...

  4. Nmap渗透测试使用方法

    Nmap渗透测试使用方法 目标选择2 端口选择2 操作系统和服务检测2 Nmap输出格式2 用NSE脚本深入挖掘2 HTTP服务信息3 检测SSL漏洞问题的主机3 设备扫描3 按VNC扫描5 按SMB ...

  5. 现在Java 桌面应用程序能做到什么程度(Spring Boot+JavaFX2开发)

    Spring Boot - JavaFX 2.0应用 很多人对Java开发native程序第一反应还停留在暗灰色单一风格的Java GUI界面,开发方式还停留在AWT或者Swing.本文主要基于Spr ...

  6. 基于Groovy搭建Ngrinder脚本调试环境

    介绍 最近公司搭建了一套压力测试平台,引用的是开源的项目 Ngrinder,做了二次开发,在脚本管理方面,去掉官方的SVN,引用的是Git,其他就是做了熔断处理等. 对技术一向充满热情的我,必须先来拥 ...

  7. 处理 Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is

    场景 某监控进程需要访问多个集群的Kafka INFO - org.apache.kafka.common.KafkaException: Failed to construct kafka cons ...

  8. Android9.0 如何区分SDK接口和非 SDK接口

    刚刚有同学问我,不太了解 "非SDK接口" 是什么意思?android9.0有什么限制 ?apache的http也有限制 ? 而且现在的大部分系统都升级上来了,黑名单.灰名单和白名 ...

  9. 实验:用tcp请求http协议的接口

    图示: 开启http服务,浏览器地址,访问测试页面 查看http报文,复制出来 用tcp工具请求测试 http 协议就是这样的,在tcp协议上面做了报文格式处理,连接发送数据后,就自动断开连接 jav ...

  10. WORKGROUP无法访问,您可能没有权限使用网络资源,请与这台服务器的管理员联系以....

    解决方法 1.启用Guest账号 在很多情况下,为了本机系统的安全,Guest账户是被禁用的,这样就无法访问该机器的共享资源,因此必须启用Guest账户. 笔者以Windows XP系统为例进行介绍. ...