Beispiel #1
0
        public PageModel <COAList> GetCoAReportInfo(COAListQuery crQuery, long userid)
        {
            int pageNum = 0;
            IQueryable <COAList> CoaR = context.COAList.AsQueryable <COAList>();

            if (!string.IsNullOrWhiteSpace(crQuery.CoANo))
            {
                CoaR = (from a in CoaR where a.CoANo.Contains(crQuery.CoANo) select a);
            }
            if (!string.IsNullOrWhiteSpace(crQuery.BeginTime.ToString()) && !crQuery.BeginTime.ToString().Contains("0001/1/1 0:00:00"))
            {
                CoaR = (from a in CoaR where a.Addtime >= crQuery.BeginTime select a);
            }
            if (!string.IsNullOrWhiteSpace(crQuery.EndTime.ToString()) && !crQuery.EndTime.ToString().Contains("0001/1/1 0:00:00"))
            {
                CoaR = (from a in CoaR where a.Addtime <= crQuery.EndTime select a);
            }
            if (!string.IsNullOrWhiteSpace(crQuery.CASNo))
            {
                CoaR = (from a in CoaR where a.CASNo.Contains(crQuery.CASNo) select a);
            }
            CoaR = (from a in CoaR where a.UserId == userid select a);
            CoaR = CoaR.GetPage(out pageNum, crQuery.PageNo, crQuery.PageSize, (IQueryable <COAList> d) =>
                                from o in d
                                orderby o.Addtime descending
                                select o);
            return(new PageModel <COAList>
            {
                Models = CoaR,
                Total = pageNum
            });
        }
        public JsonResult List(int page, int rows, string orderNum, string startTime, string endTime, string CASNo)
        {
            COAListQuery opQuery = new COAListQuery();
            DateTime     dt;

            if (DateTime.TryParse(startTime, out dt) && DateTime.TryParse(endTime, out dt))
            {
                opQuery = new COAListQuery()
                {
                    PageSize  = rows,
                    PageNo    = page,
                    BeginTime = DateTime.Parse(startTime),
                    EndTime   = DateTime.Parse(endTime),
                    CoANo     = orderNum,
                    UserId    = base.CurrentUser.Id,
                    CASNo     = CASNo
                };
            }
            else
            {
                opQuery = new COAListQuery()
                {
                    PageSize = rows,
                    PageNo   = page,
                    CoANo    = orderNum,
                    CASNo    = CASNo,
                    UserId   = base.CurrentUser.Id
                };
            }
            PageModel <COAList> opModel = ServiceHelper.Create <ICOAListService>().GetCoAReportInfo(opQuery, base.CurrentUser.Id);
            var array =
                from item in opModel.Models.ToArray()
                select new { Id = item.Id, AddTime = item.Addtime, CoANo = item.CoANo, URL = item.URL, CASNo = item.CASNo };

            return(Json(new { rows = array, total = opModel.Total }));
        }