Esempio n. 1
0
        /// <summary>
        /// 品牌选择列表
        /// </summary>
        /// <param name="brandName">品牌名称</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <returns></returns>
        public ContentResult SelectList(string brandName, int pageNumber = 1, int pageSize = 24)
        {
            if (!SecureHelper.IsSafeSqlString(brandName))
            {
                brandName = "";
            }

            string    condition = AdminBrands.AdminGetBrandListCondition(brandName);
            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminBrands.AdminGetBrandCount(condition));

            DataTable brandSelectList = AdminBrands.AdminGetBrandSelectList(pageModel.PageSize, pageModel.PageNumber, condition);

            StringBuilder result = new StringBuilder("{");

            result.AppendFormat("\"totalPages\":\"{0}\",\"pageNumber\":\"{1}\",\"items\":[", pageModel.TotalPages, pageModel.PageNumber);
            foreach (DataRow row in brandSelectList.Rows)
            {
                result.AppendFormat("{0}\"id\":\"{1}\",\"name\":\"{2}\"{3},", "{", row["brandid"], row["name"].ToString().Trim(), "}");
            }

            if (brandSelectList.Rows.Count > 0)
            {
                result.Remove(result.Length - 1, 1);
            }

            result.Append("]}");
            return(Content(result.ToString()));
        }
Esempio n. 2
0
        public ActionResult Edit(BrandModel model, int brandId = -1)
        {
            BrandInfo brandInfo = AdminBrands.GetBrandById(brandId);

            if (brandInfo == null)
            {
                return(PromptView("品牌不存在"));
            }

            int brandId2 = AdminBrands.GetBrandIdByName(model.BrandName);

            if (brandId2 > 0 && brandId2 != brandId)
            {
                ModelState.AddModelError("BrandName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                brandInfo.DisplayOrder = model.DisplayOrder;
                brandInfo.Name         = model.BrandName;
                brandInfo.Logo         = model.Logo;

                AdminBrands.UpdateBrand(brandInfo);
                AddAdminOperateLog("修改品牌", "修改品牌,品牌ID为:" + brandId);
                return(PromptView("品牌修改成功"));
            }

            Load();
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult EditProduct(int pid = -1)
        {
            ProductInfo productInfo = AdminProducts.AdminGetProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("商品不存在"));
            }

            CategoryInfo vCategoryInfo = AdminCategories.GetCategoryById(productInfo.CateId);
            string       vCateName     = "";

            if (vCategoryInfo != null)
            {
                vCateName = vCategoryInfo.Name;
            }


            EditProductModel model = new EditProductModel();

            model.PSN          = productInfo.PSN;
            model.CateId       = productInfo.CateId;
            model.CategoryName = vCateName;
            model.BrandId      = productInfo.BrandId;
            model.ProductName  = productInfo.Name;
            model.ShopPrice    = productInfo.ShopPrice;
            model.MarketPrice  = productInfo.MarketPrice;
            model.CostPrice    = productInfo.CostPrice;
            model.State        = productInfo.State;
            model.IsBest       = productInfo.IsBest == 1 ? true : false;
            model.IsHot        = productInfo.IsHot == 1 ? true : false;
            model.IsNew        = productInfo.IsNew == 1 ? true : false;
            model.DisplayOrder = productInfo.DisplayOrder;
            model.Weight       = productInfo.Weight;
            model.Description  = productInfo.Description;

            model.BrandName = AdminBrands.GetBrandById(productInfo.BrandId).Name;


            //库存信息
            ProductStockInfo productStockInfo = AdminProducts.GetProductStockByPid(pid);

            model.StockNumber = productStockInfo.Number;
            model.StockLimit  = productStockInfo.Limit;

            //商品属性列表
            List <ProductAttributeInfo> productAttributeList = Products.GetProductAttributeList(pid);

            //商品sku项列表
            DataTable productSKUItemList = AdminProducts.GetProductSKUItemList(productInfo.Pid);

            ViewData["pid"]                  = productInfo.Pid;
            ViewData["cateId"]               = productInfo.CateId;
            ViewData["categoryName"]         = vCateName;
            ViewData["productAttributeList"] = productAttributeList;
            ViewData["productSKUItemList"]   = productSKUItemList;
            ViewData["referer"]              = ShopUtils.GetAdminRefererCookie();

            return(View(model));
        }
Esempio n. 4
0
        /// <summary>
        /// 品牌列表
        /// </summary>
        /// <param name="brandName">品牌名称</param>
        /// <param name="sortColumn">排序列</param>
        /// <param name="sortDirection">排序方向</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <returns></returns>
        public ActionResult List(string brandName, string sortColumn, string sortDirection, int pageSize = 15, int pageNumber = 1)
        {
            string condition = AdminBrands.AdminGetBrandListCondition(brandName);
            string sort      = AdminBrands.AdminGetBrandListSort(sortColumn, sortDirection);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminBrands.AdminGetBrandCount(condition));

            BrandListModel model = new BrandListModel()
            {
                BrandList     = AdminBrands.AdminGetBrandList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel     = pageModel,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                BrandName     = brandName
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&brandName={5}",
                                                          Url.Action("list"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          sortColumn,
                                                          sortDirection,
                                                          brandName));
            return(View(model));
        }
Esempio n. 5
0
        /// <summary>
        /// 展示优惠劵类型
        /// </summary>
        /// <param name="couponTypeId">优惠劵类型id</param>
        public ActionResult ShowCouponType(int couponTypeId = -1)
        {
            CouponTypeInfo couponTypeInfo = AdminCoupons.AdminGetCouponTypeById(couponTypeId);

            if (couponTypeInfo == null)
            {
                return(PromptView("优惠劵类型不存在"));
            }

            CouponTypeModel model = new CouponTypeModel();

            model.CouponTypeName   = couponTypeInfo.Name;
            model.Money            = couponTypeInfo.Money;
            model.Count            = couponTypeInfo.Count;
            model.SendModel        = couponTypeInfo.SendMode;
            model.GetModel         = couponTypeInfo.GetMode;
            model.UseModel         = couponTypeInfo.UseMode;
            model.UserRankLower    = couponTypeInfo.UserRankLower;
            model.OrderAmountLower = couponTypeInfo.OrderAmountLower;
            model.LimitCateId      = couponTypeInfo.LimitCateId;
            model.LimitBrandId     = couponTypeInfo.LimitBrandId;
            model.LimitProduct     = couponTypeInfo.LimitProduct;
            model.SendStartTime    = couponTypeInfo.SendStartTime;
            model.SendEndTime      = couponTypeInfo.SendEndTime;
            model.UseTimeType      = couponTypeInfo.UseExpireTime > 0 ? 1 : 0;
            model.UseExpireTime    = couponTypeInfo.UseExpireTime;
            model.UseStartTime     = couponTypeInfo.UseStartTime;
            model.UseEndTime       = couponTypeInfo.UseEndTime;
            model.State            = couponTypeInfo.State;

            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(model.LimitCateId);

            if (categoryInfo != null)
            {
                model.LimitCateName = categoryInfo.Name;
            }
            else
            {
                model.LimitCateName = "未限制分类";
            }

            BrandInfo brandInfo = AdminBrands.GetBrandById(model.LimitBrandId);

            if (brandInfo != null)
            {
                model.LimitBrandName = brandInfo.Name;
            }
            else
            {
                model.LimitBrandName = "未限制品牌";
            }

            LoadCouponType();
            return(View(model));
        }
Esempio n. 6
0
        /// <summary>
        /// 删除品牌
        /// </summary>
        public ActionResult Del(int brandId = -1)
        {
            int result = AdminBrands.DeleteBrandById(brandId);

            if (result == 0)
            {
                return(PromptView("删除失败,请先删除此品牌下的商品"));
            }
            AddAdminOperateLog("删除品牌", "删除品牌,品牌ID为:" + brandId);
            return(PromptView("品牌删除成功"));
        }
Esempio n. 7
0
        public ActionResult Edit(int brandId = -1)
        {
            BrandInfo brandInfo = AdminBrands.GetBrandById(brandId);

            if (brandInfo == null)
            {
                return(PromptView("品牌不存在"));
            }

            BrandModel model = new BrandModel();

            model.DisplayOrder = brandInfo.DisplayOrder;
            model.BrandName    = brandInfo.Name;
            model.Logo         = brandInfo.Logo;
            Load();

            return(View(model));
        }
Esempio n. 8
0
        /// <summary>
        /// 品牌列表
        /// </summary>
        /// <param name="brandName">品牌名称</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <returns></returns>
        public ActionResult List(string brandName, int pageSize = 15, int pageNumber = 1)
        {
            string condition = AdminBrands.AdminGetBrandListCondition(brandName);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminBrands.AdminGetBrandCount(condition));

            BrandListModel model = new BrandListModel()
            {
                PageModel = pageModel,
                BrandList = AdminBrands.AdminGetBrandList(pageModel.PageSize, pageModel.PageNumber, condition),
                BrandName = brandName
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&brandName={3}",
                                                          Url.Action("list"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          brandName));
            return(View(model));
        }
Esempio n. 9
0
        /// <summary>
        /// 属性列表
        /// </summary>
        public ActionResult AttributeList(string sortColumn, string sortDirection, int cateId = -1)
        {
            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId);

            if (categoryInfo == null)
            {
                return(PromptView("分类不存在"));
            }

            string sort = AdminBrands.AdminGetBrandListSort(sortColumn, sortDirection);

            AttributeListModel model = new AttributeListModel()
            {
                AttributeList = AdminCategories.AdminGetAttributeList(cateId, sort),
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                CateId        = cateId,
                CategoryName  = categoryInfo.Name
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?cateId={1}&sortColumn={2}&sortDirection={3}", Url.Action("attributelist"), cateId, sortColumn, sortDirection));
            return(View(model));
        }
Esempio n. 10
0
        public ActionResult Add(BrandModel model)
        {
            if (AdminBrands.GetBrandIdByName(model.BrandName) > 0)
            {
                ModelState.AddModelError("BrandName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                BrandInfo brandInfo = new BrandInfo()
                {
                    DisplayOrder = model.DisplayOrder,
                    Name         = model.BrandName,
                    Logo         = model.Logo
                };

                AdminBrands.CreateBrand(brandInfo);
                AddAdminOperateLog("添加品牌", "添加品牌,品牌为:" + model.BrandName);
                return(PromptView("品牌添加成功"));
            }
            Load();
            return(View(model));
        }