Exemplo n.º 1
0
        public ActionResult Manage()
        {
            var gridModel = new ManageCardsGridModel();

            SetupManageGridModel(gridModel.CardsGrid);
            return(View(gridModel));
        }
Exemplo n.º 2
0
        public ActionResult ExportToExcel()
        {
            var gridModel = new ManageCardsGridModel();

            SetupAddGridModel(gridModel.CardsGrid);

            var cards =
                from c in db.Cards
                join v in db.Vehicles on c.Vehicle equals v.Id into cv
                from cvs in cv.DefaultIfEmpty()

                //join o in db.Drivers on cvs.Driver equals o.Id into cvso
                //from cvsos in cvso.DefaultIfEmpty()


                join u in db.aspnet_CustomProfile on c.UserId equals u.UserId into cu1
                from cu1s in cu1.DefaultIfEmpty()

                join u1 in db.aspnet_CustomProfile on c.LossUserId equals u1.UserId into cu2
                from cu2s in cu2.DefaultIfEmpty()

                join u2 in db.aspnet_CustomProfile on c.FoundUserId equals u2.UserId into cu3
                from cu3s in cu3.DefaultIfEmpty()

                join u3 in db.aspnet_CustomProfile on c.AddUserId equals u3.UserId into cu4
                from cu4s in cu4.DefaultIfEmpty()

                join d in db.Depts on c.DeptId equals d.DeptId into cd
                from cds in cd.DefaultIfEmpty()

                select new
            {
                c.Id,
                c.CardNo,
                c.Status,
                cvs.PlateNo,
                cvs.MotorNo,
                cvs.BrandModel,

                cvs.OwnerName,
                cds.DeptName,

                IssueOper = cu1s.FullName,
                c.CreateDate,

                LossOper = cu2s.FullName,
                c.LossDate,

                FoundOper = cu3s.FullName,
                c.FoundDate,

                c.SecondCardNo,
                AddOper = cu4s.FullName,
                c.AddDate,
                c.AddReason
            };
            var cards2 = cards.ToList().Select(s => new
            {
                s.Id,
                s.CardNo,
                Status = s.Status == 0 ? "正常在用" :
                         s.Status == 1 ? "挂失" : "补卡",
                s.PlateNo,
                s.MotorNo,
                s.BrandModel,
                s.OwnerName,
                s.DeptName,
                s.IssueOper,
                s.CreateDate,
                s.LossOper,
                s.LossDate,
                s.FoundOper,
                s.FoundDate,
                s.SecondCardNo,
                s.AddOper,
                s.AddDate,
                s.AddReason
            });
            //JQGridState jqstate = gridModel.CardsGrid.GetState(true);
            JQGridState gridState = Session["GridState"] as JQGridState;

            gridModel.CardsGrid.ExportToExcel(cards2.AsQueryable(), "IC卡清单.xls", gridState);
            return(View());
        }