Esempio n. 1
0
        public ActionResult Create([Bind(Include = "Id,EmployeeId,FromDesignationId,ToDesignationId,PromotionDate,FromSalary,ToSalary")] PromotionHistory promotionHistory)
        {
            if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin")
            {
                if (ModelState.IsValid)
                {
                    int fromDesignationId = db.Employee.Where(i => i.Id == promotionHistory.EmployeeId).Select(i => i.DesignationId).FirstOrDefault();
                    int toDesigantionId   = Convert.ToInt32(Request["ToDesignationId"]);
                    promotionHistory.FromDesignationId = fromDesignationId;
                    promotionHistory.ToDesignationId   = toDesigantionId;
                    promotionHistory.PromotionDate     = DateTime.Now;
                    db.PromotionHistory.Add(promotionHistory);
                    db.SaveChanges();

                    Employee emp = db.Employee.Find(promotionHistory.EmployeeId);
                    emp.DesignationId   = toDesigantionId;
                    db.Entry(emp).State = EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                List <Employee> employee = new List <Employee>();
                employee = db.Employee.Where(i => i.Status == true).ToList();
                List <Designation> designation = new List <Designation>();
                designation             = db.Designation.Where(i => i.Status == true).ToList();
                ViewBag.EmployeeId      = new SelectList(employee, "Id", "Name");
                ViewBag.ToDesignationId = new SelectList(designation, "Id", "Name");
                return(View(promotionHistory));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Esempio n. 2
0
        // Кнопка "Карьерный рост/перемещения"
        private void PromotionsEmployee_Click(object sender, RoutedEventArgs e)
        {
            if (EmployeesList.SelectedIndex == -1) // Если не было выделено ни одной строки
            {
                return;
            }

            var employee = EmployeesList.SelectedItem as BookClasses.EmployeeRow;
            var window   = new PromotionHistory(employee.EmployeeId);

            window.ShowDialog();
        }
Esempio n. 3
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin")
     {
         PromotionHistory promotionHistory = db.PromotionHistory.Find(id);
         db.PromotionHistory.Remove(promotionHistory);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
Esempio n. 4
0
 // GET: PromotionHistories/Details/5
 public ActionResult Details(int?id)
 {
     if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin")
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         PromotionHistory promotionHistory = db.PromotionHistory.Find(id);
         if (promotionHistory == null)
         {
             return(HttpNotFound());
         }
         return(View(promotionHistory));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "Id,EmployeeId,FromDesignationId,ToDesignationId,PromotionDate,FromSalary,ToSalary")] PromotionHistory promotionHistory)
 {
     if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin")
     {
         if (ModelState.IsValid)
         {
             db.Entry(promotionHistory).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.EmployeeId        = new SelectList(db.Employee, "Id", "Name", promotionHistory.EmployeeId);
         ViewBag.FromDesignationId = new SelectList(db.Designation, "Id", "Name", promotionHistory.FromDesignationId);
         ViewBag.ToDesignationId   = new SelectList(db.Designation, "Id", "Name", promotionHistory.ToDesignationId);
         return(View(promotionHistory));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }
Esempio n. 6
0
 // GET: PromotionHistories/Edit/5
 public ActionResult Edit(int?id)
 {
     if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin")
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         PromotionHistory promotionHistory = db.PromotionHistory.Find(id);
         if (promotionHistory == null)
         {
             return(HttpNotFound());
         }
         ViewBag.EmployeeId        = new SelectList(db.Employee, "Id", "Name", promotionHistory.EmployeeId);
         ViewBag.FromDesignationId = new SelectList(db.Designation, "Id", "Name", promotionHistory.FromDesignationId);
         ViewBag.ToDesignationId   = new SelectList(db.Designation, "Id", "Name", promotionHistory.ToDesignationId);
         return(View(promotionHistory));
     }
     else
     {
         return(RedirectToAction("Login", "Account"));
     }
 }