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

}

DAL

时间: 2024-10-25 21:52:44

DAL的相关文章

我已经写了DAL层的代码生成器

(1)创建您自己的解决方案 文件夹结构如以下: (2)编写代码: (要使用数据库 建议创建随意数据库就可以) 创建配置文件App.config代码例如以下: <?xml version="1.0"?> <configuration> <connectionStrings> <add name="connstr" connectionString="Data Source=.; Initial Catalog=HRM

EF作为DAL层遇到的问题

今天在部署一个经典三层的项目的时候,用到了EntityFramework,碰到几个问题: 在用EntityFramework将数据库导入到DAL层后,在BL层引用该DAL后,在测试项目的时候,想要查询一个表的结果集,但是发现没有平常熟悉的智能提示,我习惯用ToList(),但是这次只能提示没有出现,我以为是因为dll引用的关系,就自己手写了,但是却给我抛出了三个错误: Error 1 The type 'System.Data.Entity.DbContext' is defined in an

ASP.NET的三层架构(DAL,BLL,UI)

BLL 是业务逻辑层 Business Logic Layer DAL 是数据访问层 Data Access Layer ASP.NET的三层架构(DAL,BLL,UI) 图形表示三层结构. 其中web即为USL层 web –> bll –> dal | | | | V | +–> model <-+ 一.三层体系架构 1.表示层(USL):主要表示WEB方式,也可以表示成WINFORM方式.如果逻辑层相当强大和完善,无论表现层如何定义和更改,逻辑层都能完善地提供服务. 2.业务逻

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

DAL 数据链路层 非查询/查询 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data;using System.Data.SqlClient; namespace DAL{ public class sqlHelper //非查询 { public static int baba(string

C#中三层架构UI、BLL、DAL、Model实际操作

三层架构分为:表现层(UI).业务逻辑层(BLL).数据访问层(DAL)再加上实体类库(Model) 转载请注明出自朱朱家园http://blog.csdn.net/zhgl7688 1.实体类库(Model),主要存放数据库中的表字段. 操作: (1)先建立实体类库Model,打开项目,在解决方案中右键-->添加-->新建项目-->选中类库-->改名Model-->确定 (2)选中Model类库-->Shift+ALT+C-->建立实体类.UserInfo类 n

其他的项目调用DAL项目中的EF Model

 Based on your description and the error code, you will just need to ensure that your DataContext class inheirits from IDisposible: public class YourDataContextClass : DbContext,IDisposable { //Your class details here } And then install the EntityF

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

最近在做 DAL (Data Access Layer 数据访问层) 的服务化,发现有不少地方是人工编写比较繁琐的,因此写了几个小工具来完成. 1.  从 DAO 类自动生成 CoreService 类, CoreService 直接调用 DAO 类 思路: 通过正则表达式解析方法参数, 使用正则替换及源 DAO 文件来生成 CoreService 源文件. package zzz.study.utils; import cc.lovesq.dao.CreativeDAO; import jav

EF Dal通用类

一个通用的ef  dal处理类是非擦汗那个提高工作效率的 using System; using System.Collections.Generic; using System.Data.Entity.Infrastructure; using System.Data.Entity.Migrations; using System.Data.SqlClient; using System.Linq; using System.Linq.Expressions; using System.Ref

关于项目中的DAL数据接入层架构设计

摘要:项目中对关系型数据库的接入再寻常不过,也有海量的ORM工具可供选择,一个一般性的DAL数据接入层的结构却大同小异,这里就分享一下使用Hibernate.Spring.Hessian这三大工具对DAL层的具体实现方法,也是对之前使用的一个总结. 关键词:Hibernate, Spring, Hessian, DAL, 数据接入层, 架构设计 注意:以下配置或代码运行在Hibernate4.2.5,Spring3.2.4,Hessian4.0.37,Tomcat7.0.47环境下 一.Mode

asp.net mvc(模式)和三层架构(BLL、DAL、Model)的联系与区别 转载自:http://blog.csdn.net/luoyeyu1989/article/details/8275866

首先,MVC和三层架构,是不一样的. 三层架构中,DAL(数据访问层).BLL(业务逻辑层).WEB层各司其职,意在职责分离. MVC是 Model-View-Controller,严格说这三个加起来以后才是三层架构中的WEB层,也就是说,MVC把三层架构中的WEB层再度进行了分化,分成了控制器.视图.实体三个部分,控制器完成页面逻辑,通过实体来与界面层完成通话:而C层直接与三层中的BLL进行对话. 所以, .net的三层结构中,并没有action这个概念. asp.net mvc 是微软新发布