Exemplo n.º 1
0
        public ActionResult EditEmpPromotionsEnd(EmpPromotions EmpPromotions)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var ob = db.EmpPromotions.Where(a => a.ID == EmpPromotions.ID).FirstOrDefault();
                    ob.JobCurrent    = EmpPromotions.JobCurrent;
                    ob.DegreeCurrent = EmpPromotions.DegreeCurrent;
                    ob.Note          = EmpPromotions.Note;
                    db.SaveChanges();

                    var result = new { action = "yes", msg = "Saved Successfully" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                catch
                {
                    var result = new { action = "no", msg = "error occurred" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }

            else
            {
                var result = new { action = "no", msg = "error occurred" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public ActionResult AddEmpPromotionsEnd(EmpPromotions EmpPromotions)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int      EmpID    = EmpPromotions.EmpID ?? 0;
                    Employee Employee = db.Employee.Where(a => a.ID == EmpID).FirstOrDefault();

                    EmpPromotions.DegreeLast = Employee.DegreeID;
                    EmpPromotions.JobLast    = Employee.JobID;
                    db.EmpPromotions.Add(EmpPromotions);
                    db.SaveChanges();

                    Employee.DegreeID = EmpPromotions.DegreeCurrent;
                    Employee.JobID    = EmpPromotions.JobCurrent;
                    db.SaveChanges();
                    var result = new { action = "yes", msg = "Saved Successfully" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                catch
                {
                    var result = new { action = "no", msg = "error occurred" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                var result = new { action = "no", msg = "error occurred" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }