Example #1
0
        public ActionResult AjaxList(CommodityRequest request)
        {
            var create = _unityContainer.Resolve <ListShopings>();
            var table  = create.AjaxQuery(request);

            return(Json(new { tables = table, html = create.pageHtml }));
        }
Example #2
0
        public ActionResult GetCommodityByCategory(int categoryId)
        {
            var model = new ListCommodityByCategorys();
            var cs    = ICommodityCategorysService.GetById(categoryId);

            if (cs == null)
            {
                return(null);
            }
            var site = ISiteService.Query(new SiteRequest()).FirstOrDefault();

            if (site != null)
            {
                model.ImageUrl = site.imageUrl;
            }
            model.CategoryName = cs.name;
            CommodityRequest request = new CommodityRequest();

            request.commodityCategoryId = categoryId;
            var data = ICommodityService.Query(request);

            if (data != null && data.ModelList != null)
            {
                model.List = data.ModelList.Select(x => new ListCommodityByCategory()
                {
                    commodityId     = x.commodityId,
                    commodityName   = x.commodityName,
                    commodityPrice  = x.commodityPrice,
                    commodityRemark = x.commodityRemark,
                    sellQuantity    = x.sellQuantity,
                    ImgUrl          = x.images
                }).ToList();
            }
            return(Json(model));
        }
Example #3
0
        public List <ListShoping> AjaxQuery(CommodityRequest request)
        {
            var data  = new List <ListShoping>();
            var query = commodityService.Query(request);

            if (query != null)
            {
                data = query.ModelList.Select(x => new ListShoping(x)).ToList();
                var roles = _securityHelper.GetCurrentUser().CurrentUser.Roles.ToList();
                foreach (var item in data)
                {
                    if (roles[0].IsSuper || roles[0].Permissions.Contains("commodityedit"))
                    {
                        item.boor += "<a href='#' onclick=OperatorThis('Edit','/Shoping/Edit/" + item.commodityId + "') class='tablelink'>编辑 &nbsp;</a> ";
                    }
                    if (roles[0].IsSuper || roles[0].Permissions.Contains("commoditydelete"))
                    {
                        item.boor += "<a href='#' onclick=OperatorThis('DeleteShoping','/Shoping/DeleteShoping/" + item.commodityId + "') class='tablelink'>删除 </a> ";
                    }
                }
                pageHtml = MvcPage.AjaxPager((int)request.PageIndex, (int)request.PageSize, query.TotalCount);
            }
            else
            {
                pageHtml = MvcPage.AjaxPager((int)request.PageIndex, (int)request.PageSize, 0);
            }
            return(data);
        }
Example #4
0
        public void Query()
        {
            var request = new CommodityRequest();

            // fill condition
            if (State != States.All)
            {
                request.State = State;
            }

            request.DisplayNameWith = DisplayName;
            request.NameWith        = Name;
            var query = CommodityService.Query(request);

            this.List = query.ToList(this, x => new ListCommodity(x));
        }
Example #5
0
        public void Query()
        {
            var request = new CommodityRequest();
            var query   = commodityService.Query(request);

            if (query != null)
            {
                List     = query.ModelList.Select(x => new ListShoping(x)).ToList();
                pageHtml = MvcPage.AjaxPager((int)request.PageIndex, (int)request.PageSize, query.TotalCount);
            }
            else
            {
                List     = new List <ListShoping>();
                pageHtml = MvcPage.AjaxPager((int)request.PageIndex, (int)request.PageSize, 0);
            }
        }
Example #6
0
        public DataTables <Commodity> Query(CommodityRequest request)
        {
            if (request.commodityState == 0)
            {
                request.commodityState = null;
            }
            SqlParameter[] param =
            {
                new SqlParameter("@commodityName",       request.commodityName),
                new SqlParameter("@commdityKeyword",     request.commdityKeyword),
                new SqlParameter("@commodityNo",         request.commodityNo),
                new SqlParameter("@commodityState",      request.commodityState),
                new SqlParameter("@startSubmitTime",     request.startSubmitTime),
                new SqlParameter("@endSubmitTime",       request.endSubmitTime),
                new SqlParameter("@commodityCategoryId", request.commodityCategoryId),
                new SqlParameter("@pageIndex",           request.PageIndex),
                new SqlParameter("@pageSize",            request.PageSize),
            };
            StoreProcedure sp = new StoreProcedure("P_getCommodity", param);

            return(_databaseInstance.GetTables <Commodity>(sp));
        }
Example #7
0
        //public

        public dataJson GetCommodity(int IndexPage, string content)
        {
            try
            {
                var request = new CommodityRequest();
                request.commodityName   = content;
                request.commdityKeyword = content;
                request.PageIndex       = IndexPage;
                request.commodityState  = CommodityStates.putaway;
                var tables = CommodityService.Query(request);
                if (tables.TotalCount > 0)
                {
                    int TotalPage = Math.Max((tables.TotalCount + request.PageSize - 1) / request.PageSize, 1);
                    if (IndexPage == TotalPage)
                    {
                        _nextPage = 0;
                    }
                    else if (IndexPage < TotalPage)
                    {
                        _nextPage = IndexPage + 1;
                    }
                    var list = tables.ModelList.Select(x => new CommodityModel(x, ImageUrl)).ToList();
                    _listCommodity = list;
                    return(new dataJson()
                    {
                        nextPage = _nextPage, events = list
                    });
                }
                return(new dataJson());
            }
            catch (Exception ex)
            {
                logService.Insert(ex);
                return(null);
            }
        }