コード例 #1
0
        public async Task <IActionResult> Index(int pageIndex = 1, int pageSize = 10, long categoryId = 0, string title = "")
        {
            string where  = _comService.GetWhere();
            ViewBag.Title = title;
            ViewBag.Cat   = categoryId;
            if (!string.IsNullOrEmpty(title))
            {
                where += $" and g.name like '%{title}%' ";
            }
            if (categoryId > 0)
            {
                where += $" and g.categoryId ={categoryId} ";
            }
            int        total;
            string     tableSl  = $@"select g.id,g.Status,g.Sort,g.Stock,g.Name,
s.Name StoreName,cast(g.Price as float) Price ,
cast(g.RetailPrice as float) RetailPrice from dbo.TGoods g
left join dbo.TChainStore s on g.chainstoreid=s.Id";
            DataSet    ds       = _AppService.GetPage(pageIndex, pageSize, "g.sort desc", out total, where, tableSl);
            IPagedList pageList = new PagedList <DataRow>(ds.Tables[0].Select(), pageIndex, pageSize, total);

            if (Request.Headers.ContainsKey("x-requested-with"))
            {
                return(View("_Table", pageList));
            }
            ViewBag.Cat      = categoryId;
            ViewBag.PayType  = "";
            ViewBag.Category = (await _catAppService.GetGoodsCategory()).Rows;
            return(View(pageList));
        }
コード例 #2
0
ファイル: GoodsController.cs プロジェクト: lwsadmin/UnionMall
        public async Task <IActionResult> List(string goodsName, string storeId, string categoryId,
                                               string brandId, string type, string status, int page = 1, int pageSize = 10)
        {
            string where = _comService.GetWhere();
            if (!string.IsNullOrEmpty(goodsName))
            {
                where = $" and g.Name like '%{goodsName}%'";
            }
            if (!string.IsNullOrEmpty(categoryId))
            {
                where += $" and g.categoryId = {categoryId}";
            }
            if (!string.IsNullOrEmpty(brandId))
            {
                where += $" and g.brandId = {brandId}";
            }
            if (!string.IsNullOrEmpty(storeId))
            {
                where += $" and g.ChinStoreId = {storeId}";
            }
            if (!string.IsNullOrEmpty(type))
            {
                where += $" and g.type = {type}";
            }
            if (!string.IsNullOrEmpty(status))
            {
                where += $" and g.status = {status}";
            }

            int        total;
            DataSet    ds       = _AppService.GetPage(page, pageSize, "g.sort desc", out total, where);
            IPagedList pageList = new PagedList <DataRow>(ds.Tables[0].Select(), page, pageSize, total);

            ViewBag.PageSize = pageSize;
            if (Request.Headers.ContainsKey("x-requested-with"))
            {
                return(View("_Table", pageList));
            }

            ViewBag.Category = _catAppService.GetCategoryDropDownList(AbpSession.TenantId, 0);
            ViewBag.Brand    = _brandAppService.GetMultiSelect();
            ViewBag.Store    = (await _storeAppService.GetDropDown());

            IList <SelectListItem> listItem = new List <SelectListItem>();
            Array values = System.Enum.GetValues(typeof(Entity.GoodsState));

            foreach (int item in values)
            {
                listItem.Add(new SelectListItem
                {
                    Value = item.ToString(),
                    Text  = L(System.Enum.GetName(typeof(Entity.GoodsState), item))
                });
            }
            ViewData.Add("GoodsType", new SelectList(listItem, "Value", "Text"));

            return(View(pageList));
        }