public List<ProductAttr> GetAttrList(string categoryid, string clientid) { var dal = new ProductsDAL(); DataTable dt = dal.GetAttrList(categoryid, clientid); List<ProductAttr> list = new List<ProductAttr>(); foreach (DataRow dr in dt.Rows) { ProductAttr model = new ProductAttr(); model.FillData(dr); list.Add(model); } return list; }
/// <summary> /// 获取属性列表(包括属性值列表) /// </summary> /// <param name="keyWords"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="totalCount"></param> /// <param name="pageCount"></param> /// <returns></returns> public List<ProductAttr> GetAttrList(string categoryid, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientid) { var dal = new ProductsDAL(); DataSet ds = dal.GetAttrList(categoryid, keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid); List<ProductAttr> list = new List<ProductAttr>(); if (ds.Tables.Contains("Attrs")) { foreach (DataRow dr in ds.Tables["Attrs"].Rows) { ProductAttr model = new ProductAttr(); model.FillData(dr); List<AttrValue> valueList = new List<AttrValue>(); StringBuilder build = new StringBuilder(); foreach (DataRow drValue in ds.Tables["Values"].Select("AttrID='" + model.AttrID + "'")) { AttrValue valueModel = new AttrValue(); valueModel.FillData(drValue); valueList.Add(valueModel); build.Append(valueModel.ValueName + ","); } model.AttrValues = valueList; if (string.IsNullOrEmpty(build.ToString())) { model.ValuesStr = "暂无属性值(单击添加)"; } else { if (build.ToString().Length > 50) { if (build.ToString().Substring(49, 1).ToString() != ",") { model.ValuesStr = build.ToString() + "..."; } else { model.ValuesStr = build.ToString().Substring(0, 49) + " ..."; } } else { model.ValuesStr = build.ToString().Substring(0, build.ToString().Length - 1); } } list.Add(model); } } return list; }
/// <summary> /// 获取属性列表(包括属性值列表) /// </summary> public List<ProductAttr> GetAttrList(string categoryid, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string agentid, string clientid) { var dal = new ProductsDAL(); DataSet ds = dal.GetAttrList(categoryid, keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid); List<ProductAttr> list = new List<ProductAttr>(); if (ds.Tables.Contains("Attrs")) { foreach (DataRow dr in ds.Tables["Attrs"].Rows) { ProductAttr model = new ProductAttr(); model.FillData(dr); model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, agentid); List<AttrValue> valueList = new List<AttrValue>(); foreach (DataRow drValue in ds.Tables["Values"].Select("AttrID='" + model.AttrID + "'")) { AttrValue valueModel = new AttrValue(); valueModel.FillData(drValue); valueList.Add(valueModel); } model.AttrValues = valueList; list.Add(model); } } return list; }
public List<ProductAttr> GetAttrList(string categoryid, string keyWords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string agentid, string clientid) { var dal = new ProductsDAL(); DataSet ds = dal.GetAttrList(categoryid, keyWords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid); List<ProductAttr> list = new List<ProductAttr>(); foreach (DataRow dr in ds.Tables["Attrs"].Rows) { ProductAttr model = new ProductAttr(); model.FillData(dr); model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, agentid); list.Add(model); } return list; }