public async Task <ActionResult> Create(ChamCong chamCong, KyLuat kyLuat)
        {
            var model = new ViewModelCC();

            model.ListNhanVien   = database.NhanViens.ToArray();
            model.ListloaiKyLuat = database.LoaiKyLuats.ToArray();
            if (ModelState.IsValid)
            {
                chamCong.Idnv      = int.Parse(HttpContext.Session.GetString("IDNV"));
                chamCong.Ngay      = DateTime.Now;
                chamCong.TrangThai = true;
                database.Add(chamCong);
                await database.SaveChangesAsync();

                if (chamCong.Ngay.Hour > 7 || chamCong.Ngay.Hour == 7 && chamCong.Ngay.Minute >= 1)
                {
                    kyLuat.Idnv     = int.Parse(HttpContext.Session.GetString("IDNV"));
                    kyLuat.IdloaiKl = 2;
                    kyLuat.Ngay     = DateTime.Now;

                    database.Add(kyLuat);
                    await database.SaveChangesAsync();
                }

                return(RedirectToAction("Index", "ChamCong"));
            }
            return(View(model));
        }
        // GET: ChamCongController/Create
        public ActionResult Create()
        {
            var model = new ViewModelCC();

            model.ListNhanVien = database.NhanViens.ToArray();
            return(View(model));
        }
Beispiel #3
0
        public IActionResult Index()
        {
            var model = new ViewModelCC();

            model.ListChamCong = database.ChamCongs.ToArray();
            model.ListNhanVien = database.NhanViens.ToArray();
            return(View(model));
        }
        // GET: ChamCongController
        public ActionResult Index(int id)
        {
            var model = new ViewModelCC();

            model.ListChamCong = database.ChamCongs.ToArray();
            model.ListNhanVien = database.NhanViens.ToArray();
            model.nhanVien     = database.NhanViens.Where(x => x.Idnv == id).FirstOrDefault();

            return(View(model));
        }
        // GET: ChamCongController/Details/5
        public ActionResult Details(int id)
        {
            var model = new ViewModelCC();

            model.nhanVien     = database.NhanViens.Where(x => x.Idnv == id).FirstOrDefault();
            model.ListChamCong = database.ChamCongs.ToArray();
            model.taiKhoan     = database.TaiKhoans.Where(x => x.Idnv == id).FirstOrDefault();

            HttpContext.Session.SetString("IDNV", model.nhanVien.Idnv.ToString());
            return(View(model));
        }