public ActionResult DeleteConfirmed(short id)
 {
     try
     {
         HR_Section hr_section = db.HR_Section.Find(id);
         db.HR_Section.Remove(hr_section);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         throw;
     }
 }
        // GET: /HumanResource/Section/Edit/5
        public ActionResult Edit(short?id)
        {
            ViewBag.DepartmentID = new SelectList(db.HR_Department, "DeptID", "DepartmentName");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ViewBag.Department = db.HR_Section.First(aa => aa.SecID == id).SectionName;
            HR_Section hr_section = db.HR_Section.Find(id);

            if (hr_section == null)
            {
                return(HttpNotFound());
            }
            // ViewBag.DivisionID = new SelectList(db.HR_Division, "DivID", "DivisionName", hr_section.HR_Department.DivsionID);
            ViewBag.DepartmentID = new SelectList(db.HR_Department, "DeptID", "DepartmentName", hr_section.DepartmentID);
            return(View(hr_section));
        }
 // GET: /HumanResource/Section/Details/5
 public ActionResult Details(short?id)
 {
     try
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         HR_Section hr_section = db.HR_Section.Find(id);
         if (hr_section == null)
         {
             return(HttpNotFound());
         }
         return(View(hr_section));
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult Create([Bind(Include = "SecID,SectionName,DepartmentID")] HR_Section hr_section)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    hr_section.Status = true;
                    db.HR_Section.Add(hr_section);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                throw;
            }

            // ViewBag.DivisionID = new SelectList(db.HR_Division, "DivID", "DivisionName", hr_section.HR_Department.DivsionID);
            ViewBag.DepartmentID = new SelectList(db.HR_Department, "DeptID", "DepartmentName", hr_section.DepartmentID);
            return(View(hr_section));
        }
 public ActionResult Edit([Bind(Include = "SecID,SectionName,DepartmentID,Status")] HR_Section hr_section)
 {
     ViewBag.DepartmentID = new SelectList(db.HR_Department, "DeptID", "DepartmentName");
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(hr_section).State = System.Data.Entity.EntityState.Modified;
             SaveChanges(db);
             ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp;
             AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Section), Convert.ToInt16(AuditManager.AuditOperation.Add), DateTime.Now, (int)hr_section.SecID);
             return(RedirectToAction("Index"));
         }
         ViewBag.DepartmentID = new SelectList(db.HR_Department, "DeptID", "DepartmentName", hr_section.DepartmentID);
         // ViewBag.DivisionID = new SelectList(db.HR_Division, "DivID", "DivisionName", hr_section.HR_Department.DivsionID);
         return(View(hr_section));
     }
     catch (Exception ex)
     {
         return(View(hr_section));
     }
 }