public ActionResult Edit([Bind(Include = "GrdID,GradeName,OGradeID,NormalOTAmount,RestOTAmount,GZOTAmount")] HR_Grade hr_grade)
        {
            if (ModelState.IsValid)
            {
                ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp;
                using (var ctx = new HRMEntities())
                {
                    HR_Grade        OldGrade     = ctx.HR_Grade.First(aa => aa.GrdID == hr_grade.GrdID);
                    HR_GradeHistory GradeHistory = new HR_GradeHistory();
                    GradeHistory.CDateTime      = DateTime.Now;
                    GradeHistory.GradeName      = OldGrade.GradeName;
                    GradeHistory.GrdID          = OldGrade.GrdID;
                    GradeHistory.GZOTAmount     = OldGrade.GZOTAmount;
                    GradeHistory.IP             = AuditManager.GetIPAddress();
                    GradeHistory.NormalOTAmount = OldGrade.NormalOTAmount;
                    GradeHistory.OGradeID       = OldGrade.OGradeID;
                    GradeHistory.OGradeID       = OldGrade.OGradeID;
                    GradeHistory.RestOTAmount   = OldGrade.RestOTAmount;
                    GradeHistory.UserID         = loggedUser.UserID;
                    ctx.HR_GradeHistory.Add(GradeHistory);
                    ctx.SaveChanges();
                    hr_grade.OGradeID = OldGrade.OGradeID;
                }
                db.Entry(hr_grade).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Grade), Convert.ToInt16(AuditManager.AuditOperation.Edit), DateTime.Now, (int)hr_grade.GrdID);
                return(RedirectToAction("Index"));
            }
            return(View(hr_grade));
        }
        public ActionResult DeleteConfirmed(short id)
        {
            HR_Grade hr_grade = db.HR_Grade.Find(id);

            db.HR_Grade.Remove(hr_grade);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "GrdID,GradeName,OGradeID,NormalOTAmount,RestOTAmount,GZOTAmount")] HR_Grade hr_grade)
        {
            if (ModelState.IsValid)
            {
                db.HR_Grade.Add(hr_grade);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hr_grade));
        }
        // GET: /HumanResource/Grade/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HR_Grade hr_grade = db.HR_Grade.Find(id);

            if (hr_grade == null)
            {
                return(HttpNotFound());
            }
            return(View(hr_grade));
        }
Example #5
0
        internal static double?GetOTAmount(HR_Grade hR_Grade, int?mins, string DutyCode)
        {
            double OTAmount = 0;

            switch (DutyCode)
            {
            case "D":
                OTAmount = GetAmount(hR_Grade.NormalOTAmount, mins);
                break;

            case "G":
                OTAmount = GetAmount(hR_Grade.GZOTAmount, mins);
                break;

            case "R":
                OTAmount = GetAmount(hR_Grade.RestOTAmount, mins);
                break;
            }
            return(OTAmount);
        }