コード例 #1
0
        /// <summary>
        /// Báo cáo dư có
        /// </summary>
        /// <returns></returns>
        public ActionResult duco()
        {
            int selectedQuanHuyenID = Convert.ToInt32(NguoidungHelper.getChiNhanhCuaNguoiDung(Convert.ToInt32(Session["nguoiDungID"]), 0));
            int quanHuyenID         = selectedQuanHuyenID;
            var year             = DateTime.Now.Year;
            var month            = DateTime.Now.Month;
            var selectedChiNhanh = NguoidungHelper.getChiNhanhCuaNguoiDung(Convert.ToInt32(Session["nguoiDungID"]), 0);

            ViewBag.selectedChiNhanh = selectedChiNhanh;
            var selectedPhongBan = ngDungHelper.getPhongBanCuaNguoiDung(Convert.ToInt32(Session["nguoiDungID"]), quanHuyenID, 0);

            ViewBag.selectedPhongBan = selectedPhongBan;
            var nhanvien = 0;

            if (Request.QueryString["nhanvienid"] != null && Request.QueryString["nhanvienid"].ToString().Length > 0)
            {
                nhanvien = Convert.ToInt32(Request.QueryString["nhanvienid"]);
            }
            if (Request.QueryString["year"] != null && Request.QueryString["year"].ToString() != "")
            {
                year = Convert.ToInt32(Request.QueryString["year"]);
            }
            if (Request.QueryString["month"] != null && Request.QueryString["year"].ToString() != "")
            {
                month = Convert.ToInt32(Request.QueryString["month"]);
            }
            var Duco = db.DuCoes.Where(h => h.SoTienNopTheoThang.Hoadonnuoc.ThangHoaDon == month && h.SoTienNopTheoThang.Hoadonnuoc.NamHoaDon == year && h.Khachhang.QuanhuyenID == (int)selectedChiNhanh);

            if (nhanvien != 0)
            {
                Duco = db.DuCoes.Where(h => h.SoTienNopTheoThang.Hoadonnuoc.ThangHoaDon == month && h.SoTienNopTheoThang.Hoadonnuoc.NamHoaDon == year && h.SoTienNopTheoThang.Hoadonnuoc.NhanvienID == nhanvien);
            }
            return(View(Duco.ToList()));
        }
コード例 #2
0
        /// <summary>
        /// Báo cáo dư nợ
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        public ActionResult duno(int month, int year)
        {
            int chinhanh = (int)NguoidungHelper.getChiNhanhCuaNguoiDung(Convert.ToInt32(Session["nguoiDungID"]), 0);

            var selectedChiNhanh = NguoidungHelper.getChiNhanhCuaNguoiDung(Convert.ToInt32(Session["nguoiDungID"]), 0);

            ViewBag.selectedChiNhanh = selectedChiNhanh;
            var selectedPhongBan = ngDungHelper.getPhongBanCuaNguoiDung(Convert.ToInt32(Session["phongBan"]), chinhanh, 0);;

            ViewBag.selectedPhongBan = selectedPhongBan;
            var nhanvien = 0;

            if (Request.QueryString["nhanvienid"] != null && Request.QueryString["nhanvienid"].ToString().Length > 0)
            {
                nhanvien = Convert.ToInt32(Request.QueryString["nhanvienid"]);
            }
            if (Request.QueryString["year"] != null && Request.QueryString["year"].ToString() != "")
            {
                year = Convert.ToInt32(Request.QueryString["year"]);
            }
            if (Request.QueryString["month"] != null && Request.QueryString["month"].ToString() != "")
            {
                month = Convert.ToInt32(Request.QueryString["month"]);
            }

            var hoadonnuocs = db.Hoadonnuocs.Include(h => h.Khachhang).Include(h => h.Nhanvien).Where(h => h.NamHoaDon == year && (h.Trangthaithu == null || h.Trangthaithu == false) && h.Khachhang.QuanhuyenID == (int)selectedChiNhanh);
            var d           = hoadonnuocs.Count();

            if (nhanvien != 0)
            {
                hoadonnuocs = db.Hoadonnuocs.Include(h => h.Khachhang).Include(h => h.Nhanvien).Where(h => h.NamHoaDon == year && (h.Trangthaithu == null || h.Trangthaithu == false) && h.NhanvienID == nhanvien);
            }
            return(View(hoadonnuocs.ToList()));
        }
コード例 #3
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));
        }
コード例 #4
0
        public ActionResult Index()
        {
            int    phongBanId = getPhongBanNguoiDung();
            int    loggedInUserQuanHuyenId = (int)NguoidungHelper.getChiNhanhCuaNguoiDung(LoggedInUser.NguoidungID, 0);
            var    nguoidungs           = new List <Nguoidung>();
            String isAdminVaTruongPhong = isLoggedUserAdminVaTruongPhong();

            if (phongBanId != 0)
            {
                nguoidungs = (from i in db.Nguoidungs
                              join r in db.Nhanviens on i.NhanvienID equals r.NhanvienID
                              join s in db.ToQuanHuyens on r.ToQuanHuyenID equals s.ToQuanHuyenID
                              join t in db.Quanhuyens on s.QuanHuyenID equals t.QuanhuyenID
                              where r.PhongbanID == phongBanId && i.Isadmin == false && t.QuanhuyenID == loggedInUserQuanHuyenId
                              select new
                {
                    nguoiDung = i,
                    nhanvien = r
                }).Select(p => p.nguoiDung).ToList();
                ViewBag.phongBan = db.Phongbans.Where(p => p.PhongbanID == phongBanId).ToList();
            }
            else
            {
                nguoidungs       = db.Nguoidungs.ToList();
                ViewBag.phongBan = db.Phongbans.ToList();
            }

            #region ViewBag
            ViewBag.isAdminVaTruongPhong = isAdminVaTruongPhong;
            ViewBag.isAdmin                 = LoggedInUser.Isadmin == true ? "1" : "0";
            ViewData["toQuanHuyens"]        = db.ToQuanHuyens.Where(p => p.IsDelete == false).ToList();
            ViewBag.loggedInUserQuanHuyenId = loggedInUserQuanHuyenId;
            ViewBag.currentlyLoggedInUser   = LoggedInUser.NguoidungID;
            ViewBag.chinhanh                = db.Quanhuyens.Where(p => p.IsDelete == false).ToList();
            #endregion
            return(View(nguoidungs.ToList()));
        }
コード例 #5
0
        public ActionResult FilterNhanVien(FormCollection form)
        {
            int    phongBanId = getPhongBanNguoiDung();
            int    quanHuyenIdLoggedInUser = (int)NguoidungHelper.getChiNhanhCuaNguoiDung(LoggedInUser.NguoidungID, 0);
            String isAdminVaTruongPhong    = isLoggedUserAdminVaTruongPhong();
            var    isAdmin = LoggedInUser.Isadmin == true ? "1" : "0";

            #region FormRequest
            int    selectedQuan     = String.IsNullOrEmpty(form["chinhanh"]) ? 0 : Convert.ToInt32(form["chinhanh"]);
            int    selectedTo       = String.IsNullOrEmpty(form["to"]) ? 0 : Convert.ToInt32(form["to"]);
            int    selectedPhongBan = String.IsNullOrEmpty(form["phongban"]) ? 0 : Convert.ToInt32(form["phongban"]);
            String chucVu           = form["chucVu"];
            #endregion

            List <Nhanvien> nhanViens = new List <Nhanvien>();
            if (selectedQuan != 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 == selectedQuan
                             select new
                {
                    nhanvien = i,
                }).Select(p => p.nhanvien).ToList();
            }
            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
                             select new
                {
                    nhanvien = i,
                }).Select(p => p.nhanvien).ToList();
            }

            if (selectedTo != 0)
            {
                nhanViens = nhanViens.Where(p => p.ToQuanHuyenID == selectedTo && (p.IsDelete == false || p.IsDelete == null)).ToList();
            }

            if (selectedPhongBan != 0)
            {
                nhanViens = nhanViens.Where(p => p.PhongbanID == selectedPhongBan && (p.IsDelete == false || p.IsDelete == null)).ToList();
            }

            if (isAdmin == "1")
            {
                if (selectedQuan == 0)
                {
                    ViewBag.ToQuanHuyen = db.ToQuanHuyens.Where(p => p.IsDelete == false);
                }
                else
                {
                    ViewBag.ToQuanHuyen = db.ToQuanHuyens.Where(p => p.IsDelete == false && p.QuanHuyenID == selectedQuan);
                }
                ViewBag.chiNhanh = db.Quanhuyens.Where(p => p.IsDelete == false);
            }
            else
            {
                ViewBag.ToQuanHuyen = db.ToQuanHuyens.Where(p => p.IsDelete == false && p.PhongbanID == phongBanId && p.QuanHuyenID == quanHuyenIdLoggedInUser);
                ViewBag.chiNhanh    = db.Quanhuyens.Where(p => p.QuanhuyenID == quanHuyenIdLoggedInUser);
                nhanViens           = nhanViens.Where(p => p.PhongbanID == phongBanId).ToList();
            }

            if (!String.IsNullOrEmpty(chucVu))
            {
                nhanViens = nhanViens.Where(p => p.ChucvuID == Convert.ToInt32(chucVu)).ToList();
            }

            #region ViewBag
            ViewBag.isAdminVaTruongPhong = isAdminVaTruongPhong;
            ViewBag.isAdmin          = isAdmin;
            ViewBag.chucVu           = db.Chucvus;
            ViewBag.selectedQuan     = selectedQuan;
            ViewBag.selectedTo       = selectedTo;
            ViewBag.phongBan         = db.Phongbans.ToList();
            ViewBag.selectedPhongBan = selectedPhongBan;
            #endregion

            return(View("Index", nhanViens));
        }
コード例 #6
0
        public ActionResult Index(FormCollection form)
        {
            String chiNhanh = form["chinhanh"];
            String phongBan = form["phongBan"];
            int    toQH     = String.IsNullOrEmpty(form["toQuanHuyen"]) ? 0 : Convert.ToInt32(form["toQuanHuyen"]);
            String isAdmin  = form["isAdmin"];
            IEnumerable <Nguoidung> nguoiDung = db.Nguoidungs;
            int phongBanNguoiDung             = getPhongBanNguoiDung();

            if (!String.IsNullOrEmpty(chiNhanh))
            {
                int chiNhanhID        = Convert.ToInt32(chiNhanh);
                var nguoiDungChiNhanh = (from i in db.Nguoidungs
                                         join r in db.Nhanviens on i.NhanvienID equals r.NhanvienID
                                         join s in db.ToQuanHuyens on r.ToQuanHuyenID equals s.ToQuanHuyenID
                                         join t in db.Quanhuyens on s.QuanHuyenID equals t.QuanhuyenID
                                         where t.QuanhuyenID == chiNhanhID
                                         select new
                {
                    nguoiDung = i,
                    phongBanID = r.PhongbanID
                });
                if (phongBanNguoiDung == 0)
                {
                    nguoiDung = nguoiDungChiNhanh.Select(p => p.nguoiDung).Distinct().ToList();
                }
                else
                {
                    nguoiDung = nguoiDungChiNhanh.Where(p => p.phongBanID == phongBanNguoiDung).Select(p => p.nguoiDung).Distinct().ToList();
                }
            }
            //nếu phòng ban không để trông thì lọc theo phòng ban của ng dùng
            if (!String.IsNullOrEmpty(phongBan))
            {
                int phongBanID        = Convert.ToInt32(phongBan);
                var nguoiDungPhongBan = (from i in nguoiDung
                                         join r in db.Nhanviens on i.NhanvienID equals r.NhanvienID
                                         join s in db.ToQuanHuyens on r.PhongbanID equals s.PhongbanID
                                         where r.PhongbanID == phongBanID
                                         select new
                {
                    nguoiDung = i
                });
                nguoiDung = nguoiDungPhongBan.Select(p => p.nguoiDung).Distinct().ToList();
            }

            //nếu là admin
            if (!String.IsNullOrEmpty(isAdmin))
            {
                bool isAdminValue = Convert.ToInt32(isAdmin) == 1 ? true : false;
                nguoiDung = nguoiDung.Where(p => p.Isadmin == isAdminValue).Distinct().ToList();
            }

            ViewBag.chinhanh = db.Quanhuyens.Where(p => p.IsDelete == false).ToList();
            int phongbanId = getPhongBanNguoiDung();

            if (phongbanId == 0)
            {
                ViewBag.phongBan = db.Phongbans.ToList();
            }
            else
            {
                ViewBag.phongBan = db.Phongbans.Where(p => p.PhongbanID == phongbanId).ToList();
            }

            #region ViewBag
            ViewData["toQuanHuyens"] = db.ToQuanHuyens.Where(p => p.IsDelete == false).ToList();
            int loggedInUserQuanHuyenId = (int)NguoidungHelper.getChiNhanhCuaNguoiDung(LoggedInUser.NguoidungID, 0);
            ViewBag.loggedInUserQuanHuyenId = loggedInUserQuanHuyenId;
            ViewBag.isAdminVaTruongPhong    = isLoggedUserAdminVaTruongPhong();
            ViewBag.currentlyLoggedInUser   = LoggedInUser.NguoidungID;
            ViewBag.isAdmin = LoggedInUser.Isadmin == true ? "1" : "0";
            #endregion
            return(View(nguoiDung.OrderByDescending(p => p.NguoidungID).ToList()));
        }
コード例 #7
0
ファイル: BaseController.cs プロジェクト: war-man/hddn
 public int getQuanHuyenOfLoggedInUser()
 {
     return(Convert.ToInt32(NguoidungHelper.getChiNhanhCuaNguoiDung(LoggedInUser.NguoidungID, 0)));
 }