public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                QLNhanSuEntities database = new QLNhanSuEntities();
                var taiKhoan = database.TaiKhoans.Where(s => s.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                if (taiKhoan != null)
                {
                    taiKhoan.MatKhau           = model.MatKhauMoi;
                    taiKhoan.ResetPasswordCode = "";
                    database.Configuration.ValidateOnSaveEnabled = false;
                    database.SaveChanges();
                    this.AddNotification("Mật khẩu được thay đổi thành công.", NotificationType.SUCCESS);
                }
                else
                {
                    this.AddNotification("Phiên đặt lại mật khẩu đã hết hạn. Vui lòng thử lại!", NotificationType.ERROR);
                }
            }
            else
            {
                this.AddNotification("Có gì đó sai sai...", NotificationType.ERROR);
            }
            ViewBag.Message = message;
            return(View(model));
        }
Exemple #2
0
        public MyRegistry()
        {
            Action someMethod = new Action(() =>
            {
                QLNhanSuEntities ql = new QLNhanSuEntities();
                var nv = ql.ChamCongs.Where(s => s.TrangThai == null && s.Ngay == DateTime.Today);
                foreach (var b in nv)
                {
                    b.TrangThai = "Nghỉ";

                    Nghi nhanVienNghi       = new Nghi();
                    nhanVienNghi.MaNhanVien = b.MaNhanVien;
                    nhanVienNghi.NgayNghi   = DateTime.Today;
                    nhanVienNghi.Phep       = false;
                    nhanVienNghi.NgaySua    = DateTime.Now;
                    nhanVienNghi.GhiChu     = "Hôm nay nghỉ";
                    ql.Nghis.Add(nhanVienNghi);
                }
                ql.SaveChanges();
            });

            this.Schedule(someMethod).ToRunEvery(0).Days().At(10, 00);


            Action taophat = new Action(() =>
            {
                DateTime B                    = DateTime.Now;
                QLNhanSuEntities ql           = new QLNhanSuEntities();
                var mocThoiGian16h            = DateTime.Today.AddHours(16);
                var listNhanVienNghiKhongPhep = ql.Nghis.Where(x => x.Phep == false && x.NgayNghi == DateTime.Today.Date);
                //var nv = ql.ChamCongs.Where(s => s.TrangThai == "Nghỉ" && s.Ngay == DateTime.Today);
                foreach (var b in listNhanVienNghiKhongPhep)
                {
                    var ct_PhatNhanVienNghi = ql.Ct_Phat.Where(x => x.LoaiPhat.TenLoaiPhat == "Nghỉ" && x.MaNhanVien == b.MaNhanVien && x.NgayPhat == mocThoiGian16h).SingleOrDefault();
                    if (ct_PhatNhanVienNghi == null)
                    {
                        var tenphat = ql.LoaiPhats.Where(s => s.TenLoaiPhat == "Nghỉ" && s.TrangThai == true).SingleOrDefault();
                        if (tenphat != null)
                        {
                            Ct_Phat phat    = new Ct_Phat();
                            phat.MaNhanVien = b.MaNhanVien;
                            phat.MaLoaiPhat = tenphat.MaLoaiPhat;
                            phat.NgayPhat   = DateTime.Today.AddHours(16);
                            phat.NguoiPhat  = "Hệ thống";
                            phat.NguoiSua   = "Hệ thống";
                            phat.NgaySua    = DateTime.Today.AddHours(16);
                            phat.TrangThai  = true;
                            ql.Ct_Phat.Add(phat);
                        }
                    }
                }
                ql.SaveChanges();
            });

            this.Schedule(taophat).ToRunEvery(0).Days().At(16, 00);
            //DateTime B = DateTime.Now;
        }
        public ActionResult ResetPassword(string id)
        {
            QLNhanSuEntities database = new QLNhanSuEntities();
            var taiKhoan = database.TaiKhoans.Where(s => s.ResetPasswordCode == id).FirstOrDefault();

            if (taiKhoan != null)
            {
                ResetPasswordModel model = new ResetPasswordModel();
                model.ResetCode = id;
                return(View(model));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Exemple #4
0
        public ActionResult Index(string loaiTimKiem, string tenTimKiem, int?page, string trangThai, string submit)
        {
            IQueryable <Ct_Thuong> ct_T;
            QLNhanSuEntities       db = new QLNhanSuEntities();

            if (submit != null)
            {
                if (submit == "timKiem")
                {
                    try
                    {
                        if (trangThai == "TatCa")
                        {
                            if (loaiTimKiem == "MaNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "TenNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.HoTen.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "PhongBan")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else
                            {
                                ct_T = db.Ct_Thuong.Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                            }
                        }
                        else if (trangThai == "HoatDong")
                        {
                            if (loaiTimKiem == "MaNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }

                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "TenNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.HoTen.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "PhongBan")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else
                            {
                                ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                            }
                        }
                        else if (trangThai == "VoHieuHoa")
                        {
                            if (loaiTimKiem == "MaNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "TenNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.HoTen.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "PhongBan")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else
                            {
                                ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                            }
                        }
                        else
                        {
                            ct_T = db.Ct_Thuong.Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen).OrderBy(x => x.NhanVien.HoTen);
                            return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    catch
                    {
                        this.AddNotification("Không tìm thấy từ khóa yêu cầu. Vui lòng thực hiện tìm kiếm lại!", NotificationType.ERROR);
                        return(View("Index", db.Ct_Thuong.OrderBy(x => x.NhanVien.HoTen).ToList().ToPagedList(page ?? 1, 10)));
                    }
                }
                else
                {
                    try
                    {
                        if (trangThai == "TatCa")
                        {
                            if (loaiTimKiem == "MaNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "TenNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.HoTen.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "PhongBan")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.NhanVien.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else
                            {
                                ct_T = db.Ct_Thuong.Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                            }
                        }
                        else if (trangThai == "HoatDong")
                        {
                            if (loaiTimKiem == "MaNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }

                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "TenNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.HoTen.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "PhongBan")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true && x.NhanVien.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else
                            {
                                ct_T = db.Ct_Thuong.Where(x => x.TrangThai == true).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                            }
                        }
                        else if (trangThai == "VoHieuHoa")
                        {
                            if (loaiTimKiem == "MaNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "TenNhanVien")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.HoTen.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else if (loaiTimKiem == "PhongBan")
                            {
                                if (tenTimKiem == "" || tenTimKiem == null)
                                {
                                    this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                                else
                                {
                                    ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true && x.NhanVien.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                    return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                                }
                            }
                            else
                            {
                                ct_T = db.Ct_Thuong.Where(x => x.TrangThai != true).Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgaySua);
                                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                            }
                        }
                        else
                        {
                            ct_T = db.Ct_Thuong.Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderByDescending(x => x.NgayThuong);
                            return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    catch
                    {
                        this.AddNotification("Có lỗi xảy ra. Vui lòng thực hiện tìm kiếm lại!", NotificationType.ERROR);
                        return(View("Index", db.Ct_Thuong.Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen).ToList().ToPagedList(page ?? 1, 10)));
                    }
                }
            }
            else
            {
                ct_T = db.Ct_Thuong.Include(c => c.NhanVien).Include(c => c.LoaiThuong).OrderBy(x => x.NhanVien.HoTen);
                return(View("Index", ct_T.ToList().ToPagedList(page ?? 1, 10)));
            }
        }
        // GET: LoaiPhat
        public ActionResult Index(int?page, string trangThai, string loaiTimKiem, string tenTimKiem)
        {
            int pageNumber = page ?? 1;
            int pageSize   = 10;

            try
            {
                IQueryable <LoaiPhat> loaiPhats;
                QLNhanSuEntities      db = new QLNhanSuEntities();

                if (trangThai == "TatCa")
                {
                    if (loaiTimKiem == "MaLoaiPhat")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã loại phạt!", NotificationType.WARNING);
                            loaiPhats = db.LoaiPhats.Where(x => x.MaLoaiPhat.ToString().StartsWith("+-*/abcdefgh")).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            loaiPhats = db.LoaiPhats.Where(x => x.MaLoaiPhat.ToString().Contains(tenTimKiem.ToString())).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else if (loaiTimKiem == "TenLoaiPhat")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên loại phạt!", NotificationType.WARNING);
                            loaiPhats = db.LoaiPhats.Where(x => x.TenLoaiPhat.Contains("+-*/abcdefgh")).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            loaiPhats = db.LoaiPhats.Where(x => x.TenLoaiPhat.Contains(tenTimKiem.ToString())).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else
                    {
                        loaiPhats = db.LoaiPhats.OrderBy(x => x.TenLoaiPhat);
                        return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                    }
                }
                else if (trangThai == "HoatDong")
                {
                    if (loaiTimKiem == "MaLoaiPhat")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã loại phạt!", NotificationType.WARNING);
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai == true && x.MaLoaiPhat.ToString().StartsWith("+-*/abcdefgh")).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai == true && x.MaLoaiPhat.ToString().Contains(tenTimKiem.ToString())).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else if (loaiTimKiem == "TenLoaiPhat")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên loại phạt!", NotificationType.WARNING);
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai == true && x.TenLoaiPhat.Contains("+-*/abcdefgh")).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai == true && x.TenLoaiPhat.Contains(tenTimKiem.ToString())).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else
                    {
                        loaiPhats = db.LoaiPhats.Where(x => x.TrangThai == true).OrderBy(x => x.TenLoaiPhat);
                        return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                    }
                }
                else if (trangThai == "VoHieuHoa")
                {
                    if (loaiTimKiem == "MaLoaiPhat")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã loại phạt!", NotificationType.WARNING);
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai != true && x.MaLoaiPhat.ToString().StartsWith("+-*/abcdefgh")).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai != true && x.MaLoaiPhat.ToString().Contains(tenTimKiem.ToString())).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else if (loaiTimKiem == "TenLoaiPhat")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên loại phạt!", NotificationType.WARNING);
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai != true && x.TenLoaiPhat.Contains("+-*/abcdefgh")).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                        else
                        {
                            loaiPhats = db.LoaiPhats.Where(x => x.TrangThai != true && x.TenLoaiPhat.Contains(tenTimKiem.ToString())).OrderBy(x => x.TenLoaiPhat);
                            return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                        }
                    }
                    else
                    {
                        loaiPhats = db.LoaiPhats.Where(x => x.TrangThai != true).OrderBy(x => x.TenLoaiPhat);
                        return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                    }
                }
                else
                {
                    loaiPhats = db.LoaiPhats.OrderBy(x => x.TenLoaiPhat);
                    return(View("Index", loaiPhats.ToList().ToPagedList(pageNumber, pageSize)));
                }
            }
            catch
            {
                this.AddNotification("Có lỗi xảy ra. Vui lòng thực hiện tìm kiếm lại!", NotificationType.ERROR);
                return(View("Index", db.LoaiPhats.OrderBy(x => x.TenLoaiPhat).ToList().ToPagedList(pageNumber, pageSize)));
            }
        }
Exemple #6
0
        // GET: NhanVien
        public ActionResult Index(string loaiTimKiem, string tenTimKiem, int?page, string trangThai)
        {
            try
            {
                IQueryable <NhanVien> nhanViens;
                QLNhanSuEntities      db = new QLNhanSuEntities();
                if (trangThai == "TatCa")
                {
                    if (loaiTimKiem == "MaNhanVien")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else if (loaiTimKiem == "TenNhanVien")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.HoTen.Contains("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else if (loaiTimKiem == "PhongBan")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else
                    {
                        nhanViens = db.NhanViens.Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                        return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                    }
                }
                else if (trangThai == "HoatDong")
                {
                    if (loaiTimKiem == "MaNhanVien")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.TrangThai == true && x.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }

                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.TrangThai == true && x.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else if (loaiTimKiem == "TenNhanVien")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.TrangThai == true && x.HoTen.Contains("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.TrangThai == true && x.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else if (loaiTimKiem == "PhongBan")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.TrangThai == true && x.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.TrangThai == true && x.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else
                    {
                        nhanViens = db.NhanViens.Where(x => x.TrangThai == true).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                        return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                    }
                }
                else if (trangThai == "VoHieuHoa")
                {
                    if (loaiTimKiem == "MaNhanVien")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo mã nhân viên!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.TrangThai != true && x.MaNhanVien.ToString().StartsWith("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.TrangThai != true && x.MaNhanVien.ToString().Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else if (loaiTimKiem == "TenNhanVien")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo tên nhân viên!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.TrangThai != true && x.HoTen.Contains("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.TrangThai != true && x.HoTen.Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else if (loaiTimKiem == "PhongBan")
                    {
                        if (tenTimKiem == "" || tenTimKiem == null)
                        {
                            this.AddNotification("Vui lòng nhập từ khóa để tìm kiếm theo phòng ban!", NotificationType.WARNING);
                            nhanViens = db.NhanViens.Where(x => x.TrangThai != true && x.PhongBan.TenPB.Contains("+-*/abcdefgh")).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                        else
                        {
                            nhanViens = db.NhanViens.Where(x => x.TrangThai != true && x.PhongBan.TenPB.Contains(tenTimKiem.ToString())).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                            return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                        }
                    }
                    else
                    {
                        nhanViens = db.NhanViens.Where(x => x.TrangThai != true).Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen);
                        return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                    }
                }
                else
                {
                    nhanViens = db.NhanViens.Include(c => c.PhongBan).Include(c => c.ChucVu).OrderBy(x => x.HoTen).OrderBy(x => x.HoTen);
                    return(View("Index", nhanViens.ToList().ToPagedList(page ?? 1, 10)));
                }
            }
            catch
            {
                this.AddNotification("Có lỗi xảy ra. Vui lòng thực hiện tìm kiếm lại!", NotificationType.ERROR);
                return(View("Index", db.NhanViens.Where(x => x.MaNhanVien.ToString().Equals("+-*/*-+-*/*-+")).Include(c => c.ChucVu).OrderBy(x => x.HoTen).OrderBy(x => x.HoTen).ToList().ToPagedList(page ?? 1, 10)));
            }
        }
Exemple #7
0
        protected void Application_Start()
        {
            DateTime B      = DateTime.Now;
            DateTime dayOfW = DateTime.Today;

            JobManager.Initialize(new MyRegistry());
            QLNhanSuEntities ql = new QLNhanSuEntities();

            if (dayOfW.DayOfWeek != DayOfWeek.Saturday && dayOfW.DayOfWeek != DayOfWeek.Sunday)
            {
                var chamcong = ql.ChamCongs.Where(s => s.Ngay == B.Date).FirstOrDefault();
                if (chamcong == null)
                {
                    var nhanvien = ql.NhanViens.Where(s => s.TrangThai == true && s.MaNhanVien != 1001);
                    foreach (var nv in nhanvien)
                    {
                        //ChamCong cham = new ChamCong();
                        //cham.MaNhanVien = nv.MaNhanVien;
                        //cham.Ngay = B;
                        //ql.ChamCongs.Add(cham);
                        ChamCong cham = new ChamCong();
                        cham.MaNhanVien = nv.MaNhanVien;
                        cham.Ngay       = B;
                        ql.ChamCongs.Add(cham);
                    }
                    ql.SaveChanges();
                }
            }


            int month, year;

            if (B.Month == 1)
            {
                month = 12;
                year  = B.Year - 1;
            }
            else
            {
                month = B.Month - 1;
                year  = B.Year;
            }
            var      day           = DateTime.DaysInMonth(year, month);
            DateTime ngayCuoiThang = new DateTime(year, month, day);
            var      luong         = ql.LuongThangs.Where(s => s.ThangNam.Month.ToString() == month.ToString() && s.ThangNam.Year.ToString() == year.ToString()).FirstOrDefault();

            if (luong == null)
            {
                var nhanvien = ql.NhanViens.Where(s => s.TrangThai == true && s.MaNhanVien != 1001);
                foreach (var nv in nhanvien)
                {
                    int gtthuong  = 0;
                    int gtphat    = 0;
                    int giolam    = 0;
                    int giotangca = 0;
                    var thuong    = ql.Ct_Thuong.Where(s => s.NgaySua.Month == month && s.NgaySua.Year == year && s.MaNhanVien == nv.MaNhanVien);
                    foreach (var t in thuong)
                    {
                        var giatrithuong = ql.LoaiThuongs.Where(s => s.MaLoaiThuong == t.MaLoaiThuong).SingleOrDefault();
                        gtthuong = gtthuong + giatrithuong.GiaTri;
                    }
                    var phat = ql.Ct_Phat.Where(s => s.NgaySua.Month == month && s.NgaySua.Year == year && s.MaNhanVien == nv.MaNhanVien);
                    foreach (var t in phat)
                    {
                        var giatriphat = ql.LoaiPhats.Where(s => s.MaLoaiPhat == t.MaLoaiPhat).SingleOrDefault();
                        gtphat = gtphat + giatriphat.GiaTri;
                    }
                    var cc = ql.ChamCongs.Where(s => s.MaNhanVien == nv.MaNhanVien && s.Ngay.Month.ToString() == month.ToString() && s.Ngay.Year.ToString() == year.ToString() && s.TrangThai != null);
                    if (cc.Count() == 0)
                    {
                    }
                    else
                    {
                        foreach (var c in cc)
                        {
                            giolam    = (int)(giolam + c.ThoiGianLamViec);
                            giotangca = (int)(giotangca + c.ThoiGianTangCa);
                        }
                    }
                    var luongcoban = ql.LuongCoBans.Where(s => s.MaNhanVien == nv.MaNhanVien && s.TrangThai == true).SingleOrDefault();
                    if (luongcoban != null)
                    {
                        LuongThang l = new LuongThang();
                        l.MaLuongCoBan   = luongcoban.MaLuongCoBan;
                        l.ThangNam       = ngayCuoiThang;
                        l.TongGioLamViec = giolam;
                        l.TongGioTangCa  = giotangca;
                        l.TongThuong     = gtthuong;
                        l.TongPhat       = gtphat;
                        l.HeSoLuong      = luongcoban.NhanVien.ChucVu.HeSoChucVu;
                        l.PhuCap         = luongcoban.NhanVien.ChucVu.PhuCap;
                        ql.LuongThangs.Add(l);
                    }
                }
                ql.SaveChanges();
            }

            //sau 10h nếu app đc khởi động mà chấm công hôm nay, những ai chưa chấm công nếu trạng thái là null, thì thay thành "Nghỉ"
            //đồng thời thêm nhân viên đó vào bảng nghỉ
            TimeSpan thoiGianKhongChoVao = DateTime.Parse("10:00 AM").TimeOfDay;

            if (DateTime.Now.TimeOfDay > thoiGianKhongChoVao)
            {
                var nvList = ql.ChamCongs.Where(s => s.TrangThai == null && s.Ngay == DateTime.Today).ToList();
                if (nvList.Count > 0)
                {
                    foreach (var b in nvList)
                    {
                        b.TrangThai = "Nghỉ";

                        //thêm dữ liệu nhân viên nghỉ vào bảng Nghỉ
                        Nghi nhanVienNghi = new Nghi();
                        nhanVienNghi.MaNhanVien = b.MaNhanVien;
                        nhanVienNghi.NgayNghi   = DateTime.Today;
                        nhanVienNghi.Phep       = false;
                        nhanVienNghi.NgaySua    = DateTime.Now;
                        nhanVienNghi.GhiChu     = "Hôm nay nghỉ";
                        ql.Nghis.Add(nhanVienNghi);
                    }
                    ql.SaveChanges();
                }
            }

            //kiểm tra sau 16h nếu nhân viên nghỉ thì thêm phạt nhân viên đó, mà nếu đã có phạt rồi thì ko phạt nữa
            TimeSpan thoiGianThemPhatNhanVienNghi = DateTime.Parse("04:00 PM").TimeOfDay;
            var      mocThoiGian16h = DateTime.Today.AddHours(16);

            if (DateTime.Now.TimeOfDay > thoiGianThemPhatNhanVienNghi)
            {
                //list chấm công nhân viên có trạng thái nghỉ không phép trong ngày hôm nay
                var nvChamCongList = ql.Nghis.Where(x => x.Phep == false && x.NgayNghi == DateTime.Today.Date).ToList();
                foreach (var b in nvChamCongList)
                {
                    var ct_PhatNhanVienNghi = ql.Ct_Phat.Where(x => x.LoaiPhat.TenLoaiPhat == "Nghỉ" && x.MaNhanVien == b.MaNhanVien && x.NgayPhat == mocThoiGian16h).SingleOrDefault();
                    if (ct_PhatNhanVienNghi == null)
                    {
                        var tenphat = ql.LoaiPhats.Where(s => s.TenLoaiPhat == "Nghỉ" && s.TrangThai == true).SingleOrDefault();
                        if (tenphat != null)
                        {
                            Ct_Phat phat = new Ct_Phat();
                            phat.MaNhanVien = b.MaNhanVien;
                            phat.MaLoaiPhat = tenphat.MaLoaiPhat;
                            phat.NgayPhat   = DateTime.Today.AddHours(16);
                            phat.NguoiPhat  = "Hệ thống";
                            phat.NguoiSua   = "Hệ thống";
                            phat.NgaySua    = DateTime.Today.AddHours(16);
                            phat.TrangThai  = true;
                            ql.Ct_Phat.Add(phat);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                ql.SaveChanges();
            }
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }