/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int attributeClassID = RequestHelper.GetQueryString <int>("ID"); pageAttr = ProductTypeBLL.Read(attributeClassID); if (attributeClassID != int.MinValue) { CheckAdminPower("ReadProductType", PowerCheckType.Single); ProductTypeInfo productType = ProductTypeBLL.Read(attributeClassID); Name.Text = productType.Name; Repeater1.DataSource = ProductTypeAttributeBLL.ReadList(attributeClassID); Repeater1.DataBind(); Repeater2.DataSource = ProductTypeStandardBLL.ReadList(attributeClassID); Repeater2.DataBind(); } if (RequestHelper.GetQueryString <string>("Action") == "GetBrandsByFirstLetter") { GetBrandsByFirstLetter(); } } }
protected void Page_Load(object sender, EventArgs e) { int classId = RequestHelper.GetQueryString <int>("classId"); int productId = RequestHelper.GetQueryString <int>("productId"); var cls = ProductClassBLL.Read(classId); attributeList = ProductTypeAttributeBLL.JoinAttribute(cls.ProductTypeId, productId); }
protected void Page_Load(object sender, EventArgs e) { ClearCache(); int attributeClassID = RequestHelper.GetQueryString <int>("AttributeClassID"); int productID = RequestHelper.GetQueryString <int>("ProductID"); string Action = RequestHelper.GetQueryString <string>("Action"); if (!string.IsNullOrEmpty(Action)) { int proTypeID = ProductClassBLL.GetProductClassType(attributeClassID);//通过产品分类ID获取所对应的产品类型ID; attributeList = ProductTypeAttributeBLL.JoinAttribute(proTypeID, productID); } else { attributeList = ProductTypeAttributeBLL.JoinAttribute(attributeClassID, productID); } }
/// <summary> /// 属性处理 /// </summary> /// <param name="productID"></param> protected void HanderAttribute(ProductInfo product) { if (product.Id > 0) { ProductTypeAttributeRecordBLL.Delete(product.Id); } int lastClassID = ProductClassBLL.GetLastClassID(product.ClassId); int productTypeID = ProductClassBLL.GetProductClassType(lastClassID); List <ProductTypeAttributeInfo> attributeList = ProductTypeAttributeBLL.ReadList(productTypeID); foreach (ProductTypeAttributeInfo attribute in attributeList) { ProductTypeAttributeRecordInfo attributeRecord = new ProductTypeAttributeRecordInfo(); attributeRecord.AttributeId = attribute.Id; attributeRecord.ProductId = product.Id; attributeRecord.Value = RequestHelper.GetForm <string>(attribute.Id.ToString() + "Value").Replace(',', ';'); ProductTypeAttributeRecordBLL.Add(attributeRecord); } }
/// <summary> /// 提交按钮点击方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SubmitButton_Click(object sender, EventArgs e) { #region //添加属性组,即产品类型 int productTypeID = 0; ProductTypeInfo productType = new ProductTypeInfo(); productType.Id = RequestHelper.GetQueryString <int>("ID"); productType.Name = Name.Text; //productType.BrandIds = RequestHelper.GetForm<string>("proBrand").Replace(",",";"); productType.BrandIds = RequestHelper.GetForm <string>("choosedBrnadIds").Replace(";;", ";"); string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (productType.Id == int.MinValue) { CheckAdminPower("AddProductType", PowerCheckType.Single); productTypeID = ProductTypeBLL.Add(productType); AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("ProductType"), productTypeID); #region //添加相关属性 string[] namelist = RequestHelper.GetForm <string>("NameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] valuelist = RequestHelper.GetForm <string>("ValueList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] typelist = RequestHelper.GetForm <string>("TypeList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (namelist.Length > 0) { for (int t = 0; t < namelist.Length; t++) { ProductTypeAttributeInfo attribute = new ProductTypeAttributeInfo(); attribute.Name = namelist[t]; var _attribute = ProductTypeAttributeBLL.Read(attribute.Name, productTypeID); if (_attribute.Id > 0) { ScriptHelper.Alert("该属性已存在,请重新输入", RequestHelper.RawUrl); } else { attribute.ProductTypeId = productTypeID; int typeNum = 0; int.TryParse(typelist[t], out typeNum); attribute.InputType = typeNum; attribute.InputValue = valuelist[t].Replace('|', ';'); attribute.OrderId = 0; ProductTypeAttributeBLL.Add(attribute); } } } #endregion #region //添加相关规格 string[] snamelist = RequestHelper.GetForm <string>("SNameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] svaluelist = RequestHelper.GetForm <string>("SValueList").Split(','); string[] stypelist = RequestHelper.GetForm <string>("STypeList").Split(','); if (snamelist.Length > 0) { for (int t = 0; t < snamelist.Length; t++) { ProductTypeStandardInfo standard = new ProductTypeStandardInfo(); standard.Name = snamelist[t]; var _standard = ProductTypeStandardBLL.Read(standard.Name, productTypeID); if (_standard.Id > 0) { ScriptHelper.Alert("该规格已存在,请重新输入", RequestHelper.RawUrl); } else { standard.ProductTypeId = productTypeID; int typeNum = 0; int.TryParse(stypelist[t], out typeNum); standard.ValueList = svaluelist[t].Replace('|', ';'); ProductTypeStandardBLL.Add(standard); } } } #endregion } else { CheckAdminPower("UpdateProductType", PowerCheckType.Single); ProductTypeBLL.Update(productType); AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("ProductType"), productType.Id); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); #region //删除原有属性 //ProductTypeAttributeBLL.DeleteList(productType.Id); //添加相关属性 string[] namelist = RequestHelper.GetForm <string>("NameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] valuelist = RequestHelper.GetForm <string>("ValueList").Split(','); string[] typelist = RequestHelper.GetForm <string>("TypeList").Split(','); string[] idList = RequestHelper.GetForm <string>("IdList").Split(','); if (namelist.Length > 0) { List <ProductTypeAttributeInfo> productTypeAttrList = ProductTypeAttributeBLL.ReadList(productType.Id); for (int t = 0; t < namelist.Length; t++) { if (idList[t] != "0") { ProductTypeAttributeInfo attribute = ProductTypeAttributeBLL.Read(Convert.ToInt32(idList[t])); attribute.Name = namelist[t]; var _attribute = ProductTypeAttributeBLL.Read(attribute.Name, productType.Id); if (_attribute.Id != attribute.Id && _attribute.Id > 0) { ScriptHelper.Alert("该属性已存在,请重新输入", RequestHelper.RawUrl); } else { attribute.ProductTypeId = productType.Id; int typeNum = 0; int.TryParse(typelist[t], out typeNum); attribute.InputType = typeNum; attribute.InputValue = valuelist[t].Replace('|', ';'); attribute.OrderId = 0; ProductTypeAttributeBLL.Update(attribute); } } else { ProductTypeAttributeInfo attribute = new ProductTypeAttributeInfo(); attribute.Name = namelist[t]; var _attribute = ProductTypeAttributeBLL.Read(attribute.Name, productType.Id); if (_attribute.Id > 0) { ScriptHelper.Alert("该属性已存在,请重新输入", RequestHelper.RawUrl); } else { attribute.ProductTypeId = productType.Id; int typeNum = 0; int.TryParse(typelist[t], out typeNum); attribute.InputType = typeNum; attribute.InputValue = valuelist[t].Replace('|', ';'); attribute.OrderId = 0; ProductTypeAttributeBLL.Add(attribute); } } } } #endregion #region //删除原有规格 //ProductTypeStandardBLL.DeleteList(productType.Id); //添加相关规格 string[] snamelist = RequestHelper.GetForm <string>("SNameList").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] svaluelist = RequestHelper.GetForm <string>("SValueList").Split(','); string[] stypelist = RequestHelper.GetForm <string>("STypeList").Split(','); string[] sidList = RequestHelper.GetForm <string>("SIdList").Split(','); if (snamelist.Length > 0) { List <ProductTypeStandardInfo> productTypeStandardList = ProductTypeStandardBLL.ReadList(productType.Id); for (int t = 0; t < snamelist.Length; t++) { if (sidList[t] != "0") { ProductTypeStandardInfo standard = ProductTypeStandardBLL.Read(Convert.ToInt32(sidList[t])); standard.Name = snamelist[t]; var _standard = ProductTypeStandardBLL.Read(standard.Name, productType.Id); if (_standard.Id != standard.Id && _standard.Id > 0) { ScriptHelper.Alert("该规格已存在,请重新输入", RequestHelper.RawUrl); } else { standard.ProductTypeId = productType.Id; standard.ValueList = svaluelist[t].Replace('|', ';'); ProductTypeStandardBLL.Update(standard); } } else { ProductTypeStandardInfo standard = new ProductTypeStandardInfo(); standard.Name = snamelist[t]; var _standard = ProductTypeStandardBLL.Read(standard.Name, productType.Id); if (_standard.Id > 0) { ScriptHelper.Alert("该规格已存在,请重新输入", RequestHelper.RawUrl); } else { standard.ProductTypeId = productType.Id; standard.ValueList = svaluelist[t].Replace('|', ';'); ProductTypeStandardBLL.Add(standard); } } } } #endregion } #endregion ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl); }
protected override void PageLoad() { base.PageLoad(); var queryClass = StringHelper.AddSafe(HttpUtility.UrlDecode(RequestHelper.GetQueryString <string>("cat"))).Split(','); int classLevel1 = 0, classLevel2 = 0, classLevel3 = 0; if (queryClass.Length > 0) { classLevel1 = ShopCommon.ConvertToT <int>(queryClass[0]); } if (queryClass.Length > 1) { classLevel2 = ShopCommon.ConvertToT <int>(queryClass[1]); } if (queryClass.Length > 2) { classLevel3 = ShopCommon.ConvertToT <int>(queryClass[2]); } int currentClassId = classLevel3 > 0 ? classLevel3 : classLevel2 > 0 ? classLevel2 : classLevel1; if (currentClassId < 0) { currentClassId = 0; } //if (currentClassId < 1) ResponseHelper.Redirect("/"); //面包屑区域--分类 showClassList = ProductClassBLL.ReadList(); currentClass = showClassList.FirstOrDefault(k => k.Id == currentClassId) ?? new ProductClassInfo(); levelClass.Add("level1", showClassList.FirstOrDefault(k => k.Id == classLevel1) ?? new ProductClassInfo()); levelClass.Add("level2", showClassList.FirstOrDefault(k => k.Id == classLevel2) ?? new ProductClassInfo()); levelClass.Add("level3", showClassList.FirstOrDefault(k => k.Id == classLevel3) ?? new ProductClassInfo()); //热门商品 int hotCount = 0; hotProductList = ProductBLL.SearchList(1, 7, new ProductSearchInfo { IsHot = (int)BoolType.True, IsSale = (int)BoolType.True }, ref hotCount); //商品列表 currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 6; int count = 0; string brandIds = StringHelper.AddSafe(HttpUtility.UrlDecode(RequestHelper.GetQueryString <string>("brand"))); string attributeIds = StringHelper.AddSafe(HttpUtility.UrlDecode(RequestHelper.GetQueryString <string>("at"))); string attributeValues = StringHelper.AddSafe(HttpUtility.UrlDecode(RequestHelper.GetQueryString <string>("ex").Trim())); string orderField = StringHelper.AddSafe(HttpUtility.UrlDecode(RequestHelper.GetQueryString <string>("sort"))); string orderType = ""; var orderParams = orderField.Split('_'); if (orderParams.Length > 1) { orderField = orderParams[0]; orderType = orderParams[1]; } int minPrice = RequestHelper.GetQueryString <int>("min"); int maxPrice = RequestHelper.GetQueryString <int>("max"); string keywords = StringHelper.AddSafe(HttpUtility.UrlDecode(RequestHelper.GetQueryString <string>("kw"))); #region 添加到搜索记录 if (keywords != string.Empty) { var historySearch = Server.UrlDecode(CookiesHelper.ReadCookieValue("HistorySearch")); if (("," + historySearch + ",").IndexOf("," + Server.UrlDecode(keywords) + ",") == -1) { if (historySearch == "") { historySearch = Server.UrlDecode(keywords); } else { historySearch = Server.UrlDecode(keywords) + "," + historySearch; } if (historySearch.ToString().IndexOf(",") > -1) { if (historySearch.Split(',').Length > 8) { historySearch = historySearch.Substring(0, historySearch.LastIndexOf(",")); } } CookiesHelper.AddCookie("HistorySearch", Server.UrlEncode(historySearch)); } } #endregion int isNew = RequestHelper.GetQueryString <int>("isNew"); int isHot = RequestHelper.GetQueryString <int>("isHot"); int isSpecial = RequestHelper.GetQueryString <int>("isSpecial"); int isTop = RequestHelper.GetQueryString <int>("isTop"); productList = ProductBLL.SearchList(currentPage, pageSize, currentClassId, brandIds, attributeIds, attributeValues, orderField, orderType, minPrice, maxPrice, keywords, "", isNew, isHot, isSpecial, isTop, ref count, ref showAttributeList, ref showBrandList); //手机端特殊,显示所有当前产品类型下的品牌和属性,不会判断有无产品 if (currentClassId > 0) { //取得当前分类所属类型 ProductTypeInfo productType = ProductTypeBLL.Read(ProductClassBLL.Read(currentClassId).ProductTypeId); showBrandList = ProductBrandBLL.ReadList(Array.ConvertAll <string, int>(productType.BrandIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k))); showAttributeList = ProductTypeAttributeBLL.ReadList(productType.Id); } #region 添加热门关键词 //如果有搜索结果且关键词不为空 if (productList.Count > 0 && !string.IsNullOrEmpty(keywords)) { var theSearchKey = HotSearchKeyBLL.Read(keywords); //之前没有则增加 if (theSearchKey.Id <= 0) { theSearchKey.Name = keywords; theSearchKey.SearchTimes = 1; HotSearchKeyBLL.Add(theSearchKey); } else { //有则修改更新搜索次数 theSearchKey.SearchTimes += 1; HotSearchKeyBLL.Update(theSearchKey); } } #endregion ProductClassInfo thisProductClass = new ProductClassInfo(); if (classLevel3 > 0) { thisProductClass = ProductClassBLL.Read(classLevel3); } else if (classLevel2 > 0) { thisProductClass = ProductClassBLL.Read(classLevel2); } else { thisProductClass = ProductClassBLL.Read(classLevel1); } Title = thisProductClass.PageTitle.Trim() == "" ? thisProductClass.Name : thisProductClass.PageTitle; Keywords = thisProductClass.PageKeyWord.Trim() == "" ? thisProductClass.Name : thisProductClass.PageKeyWord; //Description = thisProductClass.PageSummary.Trim() == "" ? thisProductClass.Remark : thisProductClass.PageSummary; Description = thisProductClass.PageSummary; }
/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindClassBrandAttributeClassStandardType(); BrandID.Items.Insert(0, new ListItem("请选择", "0")); RelationBrandID.Items.Insert(0, new ListItem("请选择", "0")); AccessoryBrandID.Items.Insert(0, new ListItem("请选择", "0")); string classId = RequestHelper.GetQueryString <string>("classId"); productID = RequestHelper.GetQueryString <int>("ID"); _brandId = RequestHelper.GetQueryString <int>("BrandId"); //ProductClass.DataSource = ProductClassBLL.ReadUnlimitClassList(); if (productID <= 0) //添加商品 { DraftButton.Visible = true; //添加商品可保存草稿 if (string.IsNullOrEmpty(classId)) { Response.Redirect("/admin/productaddinit.aspx"); } else { LastClassID = ProductClassBLL.GetLastClassID(classId); proTypeID = ProductClassBLL.GetProductClassType(LastClassID); ProductTypeInfo aci = ProductTypeBLL.Read(proTypeID); if (aci.Id > 0) { string[] strArray = aci.BrandIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); int[] intArray; intArray = Array.ConvertAll <string, int>(strArray, s => int.Parse(s)); productBrandList = ProductBrandBLL.ReadList(intArray); } if (productBrandList.Count > 0) { BrandID.DataSource = productBrandList; BrandID.DataTextField = "Name"; BrandID.DataValueField = "ID"; BrandID.DataBind(); BrandID.Items.Insert(0, new ListItem("请选择", "0")); if (_brandId > 0) { BrandID.Text = _brandId.ToString(); } RelationBrandID.DataSource = productBrandList; RelationBrandID.DataTextField = "Name"; RelationBrandID.DataValueField = "ID"; RelationBrandID.DataBind(); RelationBrandID.Items.Insert(0, new ListItem("请选择", "0")); AccessoryBrandID.DataSource = productBrandList; AccessoryBrandID.DataTextField = "Name"; AccessoryBrandID.DataValueField = "ID"; AccessoryBrandID.DataBind(); AccessoryBrandID.Items.Insert(0, new ListItem("请选择", "0")); } //商品分类对应的属性列表 attributeList = ProductTypeAttributeBLL.ReadList(proTypeID); //商品类型对应的规格列表 standardList = ProductTypeStandardBLL.ReadList(proTypeID); //添加商品时自动查找所属分类的售后服务 Remark.Value = GetProductClassRemark(classId); } } else//修改商品 { CheckAdminPower("ReadProduct", PowerCheckType.Single); DraftButton.Visible = false;//修改商品不可保存草稿 ProductInfo product = ProductBLL.Read(productID); pageProduct = product; //如果修改了分类则标识isupdate if (!string.IsNullOrEmpty(classId) && product.ClassId != classId) { isUpdate = 1; } YejiRatio.Text = product.YejiRatio; Name.Text = product.Name; SellPoint.Text = product.SellPoint; Name.Attributes.Add("style", "color:" + product.Color); color = product.Color; FontStyle.Text = product.FontStyle; ProductNumber.Text = product.ProductNumber; //ProductClass.ClassID = product.ClassId; Keywords.Text = product.Keywords; MarketPrice.Text = product.MarketPrice.ToString(); SendPoint.Text = product.SendPoint.ToString(); Photo.Text = product.Photo; Summary.Text = product.Summary; Introduction.Value = product.Introduction1; Weight.Text = product.Weight.ToString(); GroupPrice.Text = product.GroupPrice.ToString(); GroupQuantity.Text = product.GroupQuantity.ToString(); GroupPhoto.Text = product.GroupPhoto; VirtualOrderCount.Text = product.VirtualOrderCount.ToString(); if (Convert.ToBoolean(product.IsSpecial)) { IsSpecial.Checked = true; } if (Convert.ToBoolean(product.IsNew)) { IsNew.Checked = true; } if (Convert.ToBoolean(product.IsHot)) { IsHot.Checked = true; } if (Convert.ToBoolean(product.IsSale)) { IsSale.Checked = true; } else { IsSale.Checked = false; } if (Convert.ToBoolean(product.IsTop)) { IsTop.Checked = true; } if (Convert.ToBoolean(product.AllowComment)) { AllowComment.Checked = true; } else { AllowComment.Checked = false; } TotalStorageCount.Text = product.TotalStorageCount.ToString(); LastClassID = ProductClassBLL.GetLastClassID(product.ClassId); this.proTypeID = ProductClassBLL.GetProductClassType(LastClassID); //商品分类对应的属性列表 //attributeList = ProductTypeAttributeBLL.JoinAttribute(ProductClassBLL.Read(ProductClassBLL.GetLastClassID(product.ClassId)).ProductTypeId, productID); attributeList = ProductTypeAttributeBLL.JoinAttribute(this.proTypeID, productID); Repeater1.DataSource = attributeList; Repeater1.DataBind(); //商品类型对应的规格列表 standardList = ProductTypeStandardBLL.ReadList(this.proTypeID); standardRecordList = ProductTypeStandardRecordBLL.ReadListByProduct(product.Id, product.StandardType); if (product.StandardType == 1) { if (standardRecordList.Count > 0) { TotalStorageCount.ReadOnly = true; } } if (string.IsNullOrEmpty(classId)) { LastClassID = ProductClassBLL.GetLastClassID(product.ClassId); } else { LastClassID = ProductClassBLL.GetLastClassID(classId); } int proTypeID = ProductClassBLL.GetProductClassType(LastClassID); ProductTypeInfo aci = ProductTypeBLL.Read(proTypeID); if (aci.Id > 0) { string[] strArray = aci.BrandIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); int[] intArray; intArray = Array.ConvertAll <string, int>(strArray, s => int.Parse(s)); productBrandList = ProductBrandBLL.ReadList(intArray); } if (productBrandList.Count > 0) { BrandID.DataSource = productBrandList; BrandID.DataTextField = "Name"; BrandID.DataValueField = "ID"; BrandID.DataBind(); BrandID.Items.Insert(0, new ListItem("请选择", "0")); RelationBrandID.DataSource = productBrandList; RelationBrandID.DataTextField = "Name"; RelationBrandID.DataValueField = "ID"; RelationBrandID.DataBind(); RelationBrandID.Items.Insert(0, new ListItem("请选择", "0")); AccessoryBrandID.DataSource = productBrandList; AccessoryBrandID.DataTextField = "Name"; AccessoryBrandID.DataValueField = "ID"; AccessoryBrandID.DataBind(); AccessoryBrandID.Items.Insert(0, new ListItem("请选择", "0")); } if (_brandId > 0) { BrandID.Text = _brandId.ToString(); } else { BrandID.Text = product.BrandId.ToString(); } sendCount = product.SendCount; OrderID.Text = product.OrderId.ToString(); SalePrice.Text = product.SalePrice.ToString(); Units.Text = product.Unit; Introduction_Mobile.Value = product.Introduction1_Mobile; Sub_Title.Text = product.SubTitle; LowerCount.Text = product.LowerCount.ToString(); Remark.Value = product.Remark; BindRelation(product); productPhotoList = ProductPhotoBLL.ReadList(productID, 0); } //userGradeList = UserGradeBLL.JoinUserGrade(productID); } }