Example #1
0
        public JsonResult jglist(int page, string name = "", string category = "", string groups = "", string fzr = "", string state = "", string category1 = "")
        {
            List <product> list = new List <product>();

            list = context.product.Where(a => a.ID > 0).ToList();
            if (!string.IsNullOrWhiteSpace(name))
            {
                list = list.Where(a => a.Name.Contains(name)).ToList();
            }
            if (!string.IsNullOrWhiteSpace(category))
            {
                list = list.Where(a => a.Category == category).ToList();
            }
            if (!string.IsNullOrWhiteSpace(category1))
            {
                list = list.Where(a => a.QRDJ == category1).ToList();
            }
            if (!string.IsNullOrWhiteSpace(groups))
            {
                list = list.Where(a => a.Groups == groups).ToList();
            }
            if (!string.IsNullOrWhiteSpace(fzr))
            {
                list = list.Where(a => a.FZR.Contains(fzr)).ToList();
            }
            if (!string.IsNullOrWhiteSpace(state))
            {
                list = list.Where(a => a.state == state).ToList();
            }
            int total = list.Count;

            list = list.Skip((page - 1) * 10).Take(10).ToList();
            List <dfModel> result = new List <dfModel>();

            foreach (var i in list)
            {
                dfModel d = new dfModel();
                var     u = context.users.FirstOrDefault(a => a.UserName == app.username);
                d.BH   = i.BH;
                d.name = i.Name;

                d.dfhj = i.ktpf.Sum(a => a.dfhj);
                d.jjxy = i.ktpf.Sum(a => a.jjxy);
                d.Id   = i.ID;
                d.jsnd = i.ktpf.Sum(a => a.jsnd);
                d.jssp = i.ktpf.Sum(a => a.jssp);
                d.shxy = i.ktpf.Sum(a => a.shxy);
                d.tgyy = i.ktpf.Sum(a => a.tgyy);
                d.zscq = i.ktpf.Sum(a => a.zscq);

                result.Add(d);
            }
            result = result.OrderByDescending(d => d.zscq).ToList();
            return(Json(new { rows = result, total = total }));
        }
Example #2
0
        public JsonResult bmlist(int page, string name = "", string category = "", string groups = "", string fzr = "", string state = "", string category1 = "")
        {
            List <product> list = new List <product>();

            list = context.product.Where(a => a.ID > 0).ToList();
            if (!string.IsNullOrWhiteSpace(name))
            {
                list = list.Where(a => a.Name.Contains(name)).ToList();
            }
            if (!string.IsNullOrWhiteSpace(category))
            {
                list = list.Where(a => a.Category == category).ToList();
            }
            if (!string.IsNullOrWhiteSpace(category1))
            {
                list = list.Where(a => a.QRDJ == category1).ToList();
            }
            if (!string.IsNullOrWhiteSpace(groups))
            {
                list = list.Where(a => a.Groups == groups).ToList();
            }
            if (!string.IsNullOrWhiteSpace(fzr))
            {
                list = list.Where(a => a.FZR.Contains(fzr)).ToList();
            }
            if (!string.IsNullOrWhiteSpace(state))
            {
                list = list.Where(a => a.state == state).ToList();
            }
            int total = list.Count;

            list = list.Skip((page - 1) * 10).Take(10).ToList();
            List <dfModel> result = new List <dfModel>();

            foreach (var i in list)
            {
                dfModel d = new dfModel();
                var     u = context.users.FirstOrDefault(a => a.UserName == app.username);
                d.BH   = i.BH;
                d.name = i.Name;
                var p = i.ktpf.FirstOrDefault(a => a.memberId == u.ID);
                if (p == null)
                {
                    ktpf k = new ktpf();
                    k.dfhj      = 0;
                    k.jjxy      = 0;
                    k.jsnd      = 0;
                    k.jssp      = 0;
                    k.memberId  = u.ID;
                    k.jjxy      = 0;
                    k.jsnd      = 0;
                    k.productId = i.ID;
                    k.shxy      = 0;
                    k.tgyy      = 0;
                    k.zscq      = 0;
                    context.ktpf.Add(k);
                    context.SaveChanges();
                    p = i.ktpf.FirstOrDefault(a => a.memberId == u.ID);
                }
                d.dfhj = p.dfhj;
                d.jjxy = p.jjxy;
                d.Id   = p.ID;
                d.jsnd = p.jsnd;
                d.jssp = p.jssp;
                d.shxy = p.shxy;
                d.tgyy = p.tgyy;
                d.zscq = p.zscq;
                result.Add(d);
            }
            return(Json(new { rows = result, total = total }));
        }