예제 #1
0
        public ActionResult Index(string searchYeuCau, string searchTinhTrang, string searchName,
                                  string searchTenDanhMuc, string searchTenDonVi, string searchTenLop, string searchEmail, string searchTenVaiTro, int page = 1, int pageSize = 10)
        {
            var dao   = new HocVuDao();
            var model = dao.ListThongKe(searchYeuCau, searchTinhTrang, searchName, searchTenDanhMuc,
                                        searchTenDonVi, searchTenLop, searchEmail, searchTenVaiTro, page, pageSize);
            var dao1 = new DonViDao();

            ViewBag.listDonVi     = new SelectList(dao1.ListAll(), "TenDonVi", "TenDonVi");
            ViewBag.listTinhTrang = new SelectList(dao.ListAll(), "TinhTrang", "TinhTrang");
            var lop = new LopDao();

            ViewBag.listLop = new SelectList(lop.ListAll(), "TenLop", "TenLop");
            var vaitro = new VaiTroDao();

            ViewBag.listVaiTro       = new SelectList(vaitro.ListAll(), "TenVaiTro", "TenVaiTro");
            ViewBag.searchYeuCau     = searchYeuCau;
            ViewBag.searchTinhTrang  = searchTinhTrang;
            ViewBag.searchName       = searchName;
            ViewBag.searchTenDanhMuc = searchTenDanhMuc;
            ViewBag.searchTenDonVi   = searchTenDonVi;
            ViewBag.searchTenLop     = searchTenLop;
            ViewBag.searchEmail      = searchEmail;
            ViewBag.searchTenVaiTro  = searchTenVaiTro;

            var        list     = dao.ListAll();
            List <int> repart   = new List <int>();
            var        userID   = list.Select(x => x.UserID).Distinct();
            var        listUser = from a in userID
                                  join b in db.Users on a.Value equals b.UserID
                                  select b.UserName;

            foreach (var item in userID)
            {
                repart.Add(list.Count(x => x.UserID == item));
            }
            var rep = repart;

            ViewBag.UserID = listUser;
            ViewBag.REP    = repart.ToList();


            var danhmucID = list.Select(x => x.DanhMucID).Distinct();
            var listDM    = from a in danhmucID
                            join b in db.DanhMucs on a.ToString() equals b.DanhMucID.ToString()
                            select b.TenDanhMuc;

            List <int> listDanhMuc = new List <int>();

            foreach (var item in danhmucID)
            {
                listDanhMuc.Add(list.Count(x => x.DanhMucID == item));
            }
            ViewBag.danhmucID   = listDM;
            ViewBag.listDanhMuc = listDanhMuc.ToList();
            return(View(model));
        }
예제 #2
0
        public void SetViewBagLop(int?LopID = null)
        {
            var dao = new LopDao();

            ViewBag.LopID = new SelectList(dao.ListAll(), "LopID", "TenLop", LopID);
        }
        public void SetViewBag(int?selectedId = null)
        {
            var dao = new LopDao();

            ViewBag.Id_Lop = new SelectList(dao.ListAll(), "Id_Lop", "TenLop", selectedId);
        }