本文整理汇总了C#中CloudSalesDAL.ProductsDAL.GetProductByIDForDetails方法的典型用法代码示例。如果您正苦于以下问题:C# ProductsDAL.GetProductByIDForDetails方法的具体用法?C# ProductsDAL.GetProductByIDForDetails怎么用?C# ProductsDAL.GetProductByIDForDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudSalesDAL.ProductsDAL
的用法示例。
在下文中一共展示了ProductsDAL.GetProductByIDForDetails方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProductByIDForDetails
/// <summary>
/// 获取产品信息(加入购物车页面)
/// </summary>
/// <param name="productid"></param>
/// <returns></returns>
public Products GetProductByIDForDetails(string productid)
{
var dal = new ProductsDAL();
DataSet ds = dal.GetProductByIDForDetails(productid);
Products model = new Products();
if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0)
{
model.FillData(ds.Tables["Product"].Rows[0]);
//单位
model.BigUnit = new ProductUnit();
model.BigUnit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.BigUnitID + "'").FirstOrDefault());
model.SmallUnit = new ProductUnit();
model.SmallUnit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.SmallUnitID + "'").FirstOrDefault());
model.AttrLists = new List<ProductAttr>();
model.SaleAttrs = new List<ProductAttr>();
foreach (DataRow attrtr in ds.Tables["Attrs"].Rows)
{
ProductAttr attrModel = new ProductAttr();
attrModel.FillData(attrtr);
attrModel.AttrValues = new List<AttrValue>();
//参数
if (attrModel.Type == (int)EnumAttrType.Parameter)
{
foreach (DataRow valuetr in ds.Tables["Values"].Select("AttrID='" + attrModel.AttrID + "'"))
{
AttrValue valueModel = new AttrValue();
valueModel.FillData(valuetr);
if (model.AttrValueList.IndexOf(valueModel.ValueID) >= 0)
{
attrModel.AttrValues.Add(valueModel);
model.AttrLists.Add(attrModel);
break;
}
}
}
else
{
model.SaleAttrs.Add(attrModel);
}
}
model.ProductDetails = new List<ProductDetail>();
foreach (DataRow item in ds.Tables["Details"].Rows)
{
ProductDetail detail = new ProductDetail();
detail.FillData(item);
//填充存在的规格
foreach (var attrModel in model.SaleAttrs)
{
foreach (DataRow valuetr in ds.Tables["Values"].Select("AttrID='" + attrModel.AttrID + "'"))
{
AttrValue valueModel = new AttrValue();
valueModel.FillData(valuetr);
if (detail.AttrValue.IndexOf(valueModel.ValueID) >= 0)
{
if (attrModel.AttrValues.Where(v => v.ValueID == valueModel.ValueID).Count() == 0)
{
attrModel.AttrValues.Add(valueModel);
}
break;
}
}
}
model.ProductDetails.Add(detail);
}
}
return model;
}
示例2: GetProductByIDForDetails
public Products GetProductByIDForDetails(string productid)
{
var dal = new ProductsDAL();
DataSet ds = dal.GetProductByIDForDetails(productid);
Products model = new Products();
if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0)
{
model.FillData(ds.Tables["Product"].Rows[0]);
model.SmallUnit = GetUnitByID(model.UnitID, model.ClientID);
model.AttrLists = new List<ProductAttr>();
model.SaleAttrs = new List<ProductAttr>();
foreach (DataRow attrtr in ds.Tables["Attrs"].Rows)
{
ProductAttr attrModel = new ProductAttr();
attrModel.FillData(attrtr);
attrModel.AttrValues = new List<AttrValue>();
//参数
if (attrModel.Type == (int)EnumAttrType.Parameter)
{
foreach (var value in GetProductAttrByID(attrModel.AttrID, model.ClientID).AttrValues)
{
if (model.AttrValueList.IndexOf(value.ValueID) >= 0)
{
attrModel.AttrValues.Add(value);
model.AttrLists.Add(attrModel);
break;
}
}
}
}
model.ProductDetails = new List<ProductDetail>();
foreach (DataRow item in ds.Tables["Details"].Rows)
{
ProductDetail detail = new ProductDetail();
detail.FillData(item);
model.ProductDetails.Add(detail);
}
}
return model;
}