Beispiel #1
0
        // GET: /Nhanvien/
        public ActionResult Index()
        {
            int    quanHuyenIdLoggedInUser = (int)NguoidungHelper.getChiNhanhCuaNguoiDung(LoggedInUser.NguoidungID, 0);
            int    phongBanId           = getPhongBanNguoiDung();
            String isAdminVaTruongPhong = isLoggedUserAdminVaTruongPhong();
            bool   isOnlyTruongPhong    = ngDungHelper.isNguoiDungLaTruongPhong(LoggedInUser.NhanvienID);

            List <Nhanvien> nhanviens = new List <Nhanvien>();

            if (phongBanId == 0)
            {
                nhanviens = (from i in db.Nhanviens
                             join r in db.ToQuanHuyens on i.ToQuanHuyenID equals r.ToQuanHuyenID
                             join s in db.Quanhuyens on r.QuanHuyenID equals s.QuanhuyenID
                             where i.IsDelete == false && s.QuanhuyenID == quanHuyenIdLoggedInUser
                             select new
                {
                    nhanvien = i,
                }).Select(p => p.nhanvien).ToList();
                ViewBag.ToQuanHuyen = db.ToQuanHuyens.Where(p => p.IsDelete == false || p.IsDelete == null);
                ViewBag.chiNhanh    = db.Quanhuyens.Where(p => p.IsDelete == false || p.IsDelete == null);
            }
            else
            {
                nhanviens = (from i in db.Nhanviens
                             join r in db.ToQuanHuyens on i.ToQuanHuyenID equals r.ToQuanHuyenID
                             join s in db.Quanhuyens on r.QuanHuyenID equals s.QuanhuyenID
                             where i.IsDelete == false && i.PhongbanID == phongBanId && s.QuanhuyenID == quanHuyenIdLoggedInUser
                             select new
                {
                    nhanvien = i,
                }).Select(p => p.nhanvien).ToList();
                ViewBag.ToQuanHuyen = db.ToQuanHuyens.Where(p => p.IsDelete == false && p.PhongbanID == phongBanId && p.QuanHuyenID == quanHuyenIdLoggedInUser);
                ViewBag.chiNhanh    = db.Quanhuyens.Where(p => p.QuanhuyenID == quanHuyenIdLoggedInUser);
            }

            var userLoggedInRole = getLoggedInUserRole();

            #region ViewBag
            ViewBag.isAdminVaTruongPhong = isAdminVaTruongPhong;
            ViewBag.isAdmin           = LoggedInUser.Isadmin == true ? "1" : "0";
            ViewBag.chucVu            = db.Chucvus;
            ViewBag.selectedQuan      = quanHuyenIdLoggedInUser;
            ViewBag.selectedTo        = 0;
            ViewBag.phongBan          = db.Phongbans.ToList();
            ViewBag.selectedPhongban  = 0;
            ViewBag.isOnlyTruongPhong = isOnlyTruongPhong;

            #endregion
            return(View(nhanviens));
        }
Beispiel #2
0
        // GET: /Tuyen/
        public ActionResult Index(int?nhanvien, int page = 1)
        {
            int  quanHuyenId       = getQuanHuyenOfLoggedInUser();
            int  phongBanId        = getPhongBanNguoiDung();
            bool isOnlyTruongPhong = ngDungHelper.isNguoiDungLaTruongPhong(LoggedInUser.NhanvienID);

            var nhanViens = new List <Nhanvien>();

            if (!LoggedInUser.Isadmin.Value)
            {
                nhanViens = (from i in db.Nhanviens
                             join r in db.ToQuanHuyens on i.ToQuanHuyenID equals r.ToQuanHuyenID
                             join t in db.Quanhuyens on r.QuanHuyenID equals quanHuyenId
                             where i.PhongbanID == phongBanId && i.ChucvuID == (int)EChucVu.NHAN_VIEN && t.QuanhuyenID == quanHuyenId && i.IsDelete == false
                             select new
                {
                    nhanvien = i
                }).Select(p => p.nhanvien).ToList();
            }
            else
            {
                nhanViens = db.Nhanviens.Where(p => p.IsDelete == false).ToList();
            }

            int pageSize   = (int)EPaginator.PAGESIZE;
            int pageNumber = page != 0 ? page : 0;
            IEnumerable <Tuyenkhachhang> tuyensKhachHang = tuyenHelper.getDanhSachTuyensByNhanVien(nhanvien).OrderBy(p => p.Matuyen).Where(p => p.IsDelete == false).ToPagedList(page, pageSize);

            #region ViewBag
            ViewData["nhanVien"]      = nhanViens;
            ViewBag.pageSize          = pageSize;
            ViewBag.selectedNhanvien  = nhanvien;
            ViewBag.isOnlyTruongPhong = isOnlyTruongPhong;
            ViewBag.phongBanId        = phongBanId;
            #endregion
            return(View(tuyensKhachHang));
        }