예제 #1
0
        /// <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();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 根据首字符筛选品牌
        /// </summary>
        protected void GetBrandsByFirstLetter()
        {
            string firstLetter      = RequestHelper.GetQueryString <string>("FirstLetter");
            string _html            = string.Empty;
            int    attributeClassID = RequestHelper.GetQueryString <int>("ID");

            pageAttr = ProductTypeBLL.Read(attributeClassID);
            List <ProductBrandInfo> proBrandList = new List <ProductBrandInfo>();

            if (!string.IsNullOrEmpty(firstLetter))
            {
                if (firstLetter == "+")
                {//其他,不是以字母开头的
                    Regex regChar  = new Regex("^[a-z]");
                    Regex regDChar = new Regex("^[A-Z]");
                    proBrandList = ProductBrandBLL.ReadList().Where(k => !regChar.IsMatch(k.Spelling)).Where(k => !regDChar.IsMatch(k.Spelling)).OrderBy(k => k.Spelling).ToList();
                }
                else
                {//以字母开头的
                    proBrandList = ProductBrandBLL.ReadList().Where(k => k.Spelling.ToLower().StartsWith(firstLetter.ToLower())).OrderBy(k => k.Spelling).ToList();
                }
                foreach (ProductBrandInfo proBrand in proBrandList)
                {
                    if (!string.IsNullOrEmpty(pageAttr.BrandIds))
                    {
                        string brands = ";" + pageAttr.BrandIds + ";";

                        if (brands.IndexOf(";" + proBrand.Id.ToString() + ";") >= 0)
                        {
                            _html += "<label class=\"ig-checkbox checked\"><input type=\"checkbox\" checked=\"checked\" name=\"proBrand\" value=\"" + proBrand.Id + "\" onclick=\"chooseBrand(this,'" + proBrand.Name + "')\"/>" + proBrand.Name + "</label>";
                        }
                        else
                        {
                            _html += " <label class=\"ig-checkbox\" ><input type=\"checkbox\" name=\"proBrand\" value=\"" + proBrand.Id + "\" onclick=\"chooseBrand(this,'" + proBrand.Name + "')\"/>" + proBrand.Name + "</label>";
                        }
                    }
                    else
                    {
                        _html += "<label class=\"ig-checkbox\"><input type=\"checkbox\" name=\"proBrand\" value=\"" + proBrand.Id + "\" onclick=\"chooseBrand(this,'" + proBrand.Name + "')\"/>" + proBrand.Name + "</label>";
                    }
                }
                Response.Clear();
                ResponseHelper.Write(JsonConvert.SerializeObject(new { flag = true, content = _html }));
            }
            else
            {
                Response.Clear();
                ResponseHelper.Write(JsonConvert.SerializeObject(new { flag = false, content = _html }));
            }
            Response.End();
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ClearCache();
            int attributeClassID = RequestHelper.GetQueryString <int>("AttributeClassID");

            int proTypeID = ProductClassBLL.GetProductClassType(attributeClassID);

            ProductTypeInfo aci = ProductTypeBLL.Read(proTypeID);


            if (aci.Id > 0)
            {
                string[] strArr = aci.BrandIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                int[]    intArr = Array.ConvertAll <string, int>(strArr, s => int.Parse(s));

                productBrandList = ProductBrandBLL.ReadList(intArr);
            }
        }
예제 #4
0
        /// <summary>
        /// 根据选择分类获取对应的品牌列表
        /// </summary>
        protected void GetBrandList()
        {
            int                     classId          = RequestHelper.GetQueryString <int>("classId");
            string                  brandname        = RequestHelper.GetQueryString <string>("brandname");
            int                     proTypeID        = ProductClassBLL.GetProductClassType(classId);
            ProductTypeInfo         aci              = ProductTypeBLL.Read(proTypeID);
            List <ProductBrandInfo> productBrandList = new List <ProductBrandInfo>();

            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 (!string.IsNullOrEmpty(brandname))
                {
                    productBrandList = productBrandList.Where(k => k.Name.ToLower().Contains(brandname.ToLower())).ToList();
                }
            }
            Response.Clear();
            ResponseHelper.Write(Newtonsoft.Json.JsonConvert.SerializeObject(new { count = productBrandList.Count, dataList = productBrandList }));
            Response.End();
        }
예제 #5
0
        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;
        }
예제 #6
0
        /// <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);
            }
        }