public ActionResult Create([Bind(Include = "EmployeeID,DateAdvanced,Value")] ADVANCED aDVANCED)
        {
            int sum = SumAdvanced(aDVANCED.EmployeeID);

            if (sum + aDVANCED.Value > GetLimitAdvanced(aDVANCED.EmployeeID))
            {
                ModelState.AddModelError("Value", "Vượt quá giới hạn được tạm ứng.");
            }
            if (ModelState.IsValid)
            {
                DateTime minDate = new DateTime(1, 1, 1, 0, 0, 0);
                if (aDVANCED.DateAdvanced == minDate)
                {
                    DateTime now = DateTime.Now;
                    aDVANCED.DateAdvanced = new DateTime(now.Year, now.Month, now.Day);
                    db.ADVANCEDs.Add(aDVANCED);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    db.Entry(aDVANCED).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.EmployeeID = new SelectList(db.EMPLOYEEs, "EmployeeID", "EmployeeName", aDVANCED.EmployeeID);
            return(View(aDVANCED));
        }
        public ActionResult DeleteConfirmed(string id, DateTime date)
        {
            ADVANCED aDVANCED = db.ADVANCEDs.Find(id, date);

            db.ADVANCEDs.Remove(aDVANCED);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: ALLOWANCEDETAILs/Delete/5
        public ActionResult Delete(string id, DateTime date)
        {
            Session["MainTitle"] = "Quản lý tiền lương";
            Session["SubTitle"]  = "Xóa thông tin tạm ứng";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ADVANCED aDVANCED = db.ADVANCEDs.Find(id, date);

            if (aDVANCED == null)
            {
                return(HttpNotFound());
            }
            return(View(aDVANCED));
        }
        public ActionResult Edit(string id, DateTime date)
        {
            Session["MainTitle"] = "Quản lý tiền lương";
            Session["SubTitle"]  = "Sửa thông tin tạm ứng";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ADVANCED aDVANCED = db.ADVANCEDs.Find(id, date);

            if (aDVANCED == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.AllowanceID = new SelectList(db.ALLOWANCEs, "AllowanceID", "AllowanceName", aLLOWANCEDETAIL.AllowanceID);
            //ViewBag.EmployeeID = new SelectList(db.EMPLOYEEs, "EmployeeID", "EmployeeName", aLLOWANCEDETAIL.EmployeeID);
            return(View(aDVANCED));
        }
        public ActionResult Edit([Bind(Include = "EmployeeID,DateAdvanced,Value")] ADVANCED aDVANCED)
        {
            ADVANCED oldAdv = db.ADVANCEDs.Find(aDVANCED.EmployeeID, aDVANCED.DateAdvanced);
            int      sum    = SumAdvanced(aDVANCED.EmployeeID) - oldAdv.Value;

            if (sum + aDVANCED.Value > GetLimitAdvanced(aDVANCED.EmployeeID))
            {
                ModelState.AddModelError("Value", "Vượt quá giới hạn được tạm ứng.");
            }

            if (ModelState.IsValid)
            {
                db.Entry(aDVANCED).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.EmployeeID = new SelectList(db.EMPLOYEEs, "EmployeeID", "EmployeeName", aDVANCED.EmployeeID);
            return(View(aDVANCED));
        }