Esempio n. 1
0
        public String GenerateIdentifier(String code, CertificationTracker tracker)
        {
            CertificationPlanGenerator generator = new CertificationPlanGenerator();
            var DiffMonth = generator.DifferenceMonth(generator.GetCertificationPlanA(code, tracker));

            if (DiffMonth > 0)
            {
                if (DiffMonth <= 31)
                {
                    return("One Month Overdue");
                }
                else if (DiffMonth > 31 && DiffMonth < 63)
                {
                    return("Almost Two Months Overdue");
                }
                else
                {
                    return("Two Months Overdue");
                }
            }
            else
            {
                return("In due time");
            }
        }
Esempio n. 2
0
        public ActionResult Testing3(String id, String urlBack, String type = "")
        {
            ViewBag.URLBack = urlBack;
            ViewBag.Type    = type;
            EmployeeModel empModel = new EmployeeModel();

            if (id != null)
            {
                var employee = ldcr.EmployeeDCR_Vw.Where(emp => emp.Employee_ID == id).FirstOrDefault();
                if (employee != null)
                {
                    empModel.Employee = new EmployeeDCR_Vw
                    {
                        Employee_ID             = employee.Employee_ID,
                        First_Name              = employee.First_Name,
                        Last_Name               = employee.Last_Name,
                        HRCCell                 = employee.HRCCell,
                        Job_Status              = employee.Job_Status,
                        HRCSupervisor           = employee.HRCSupervisor,
                        PlanRecertificationDate = employee.PlanRecertificationDate,
                        Position                = employee.Position
                    };
                    empModel.Certifications       = ldcr.Certifications.OrderBy(l => l.Code).ToList();
                    empModel.TotalCertifications  = ldcr.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderBy(cr => cr.CertificationCode).ToList();
                    empModel.CurrentCertification = ldcr.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderByDescending(cr => cr.DateCertified).FirstOrDefault();
                    double SKP = (Convert.ToDouble(empModel.TotalCertifications.Count()) / Convert.ToDouble(empModel.Certifications.Count())) * (100);
                    if (!Double.IsNaN(SKP))
                    {
                        empModel.PercentAgeCertified = Convert.ToInt32(SKP);
                    }
                    else
                    {
                        empModel.PercentAgeCertified = 0;
                    }
                    var ReCertified = ldcr.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID && cr.DateRecertified != null).OrderBy(cr => cr.Id).ToList().Count();

                    empModel.NumberReCertified = ReCertified;
                    double SRKP = (Convert.ToDouble(ReCertified) / Convert.ToDouble(empModel.Certifications.Count())) * (100);
                    if (!Double.IsNaN(SRKP))
                    {
                        empModel.PercentAgeReCertified = Convert.ToInt32(SRKP);
                    }
                    else
                    {
                        empModel.PercentAgeReCertified = 0;
                    }

                    System.Diagnostics.Debug.WriteLine(Convert.ToInt32(SKP));
                    System.Diagnostics.Debug.WriteLine(Convert.ToInt32(SRKP));
                    var totalPointsCertiFied   = 0;
                    var TotalPointsReCertified = 0;
                    foreach (var certification in empModel.Certifications)
                    {
                        if (empModel.TotalCertifications.FirstOrDefault(el => el.CertificationCode == certification.Code) == null)
                        {
                            CertificationTracker CT = new CertificationTracker();
                            CT.Id                = 0;
                            CT.EmpBadgeNo        = id;
                            CT.CertificationCode = certification.Code;
                            CT.DateCertified     = null;
                            CT.DateRecertified   = null;
                            empModel.MyCertifications.Add(CT);
                            empModel.ImNotCertified.Add(certification);
                        }
                        else
                        {
                            empModel.MyCertifications.Add(empModel.TotalCertifications.FirstOrDefault(el => el.CertificationCode == certification.Code));
                            totalPointsCertiFied += Convert.ToInt32(certification.Points);
                        }
                        if (empModel.TotalCertifications.FirstOrDefault(el => el.CertificationCode == certification.Code && el.DateRecertified != null) != null)
                        {
                            TotalPointsReCertified += Convert.ToInt32(certification.Points);
                        }
                    }
                    empModel.TotalPointsCertified   = totalPointsCertiFied;
                    empModel.TotalPointsReCertified = TotalPointsReCertified;
                }
            }
            return(View(empModel));
        }
Esempio n. 3
0
        public ActionResult PostCertified()
        {
            // [ GET Data from submitted form --
            var DateP        = Request.Form["DateCertified"];
            var Who          = Request.Form["Employee"];
            var Code         = Request.Form["Code"];
            var RedirectURL  = Request.Form["URLBACK"];
            var TrainingDate = Request.Form["TrainingDate"];
            // ----------------------
            var           message = "";                  // initialize variable for message
            List <String> error   = new List <string>(); // initialize variable for error

            CertificationTracker certificationTracker = new CertificationTracker();

            // Validate Data submitted
            if (DateP != null && Who != null && Code != null && Code != "X" && !String.IsNullOrEmpty(DateP) && TrainingDate != null && !String.IsNullOrEmpty(TrainingDate))
            {
                // Check if Employee is Exist
                var emp = cEE.Employees_Details.Where(u => u.Employee_ID.ToString().ToLower() == Who.ToString().ToLower()).FirstOrDefault();
                if (emp != null)
                {
                    certificationTracker.EmpBadgeNo = emp.Employee_ID;
                }
                else
                {
                    error.Add("BadgeNo not exist");
                }
                // Check if certification Code is Exist
                var code = ldcr.Certifications.Where(c => c.Code == Code).FirstOrDefault();
                if (code != null)
                {
                    certificationTracker.CertificationCode = code.Code;
                }
                else
                {
                    error.Add("Certification Code not exist");
                }

                if (Validator.isValidDate(DateP))
                {
                    certificationTracker.DateCertified = DateTime.ParseExact(DateP, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                }
                else
                {
                    error.Add("Date Certified is not Valid!");
                }
                if (Validator.isValidDate(TrainingDate))
                {
                    certificationTracker.TrainingDate = DateTime.ParseExact(TrainingDate, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                }
                else
                {
                    error.Add("TrainingDate is not Valid!");
                }
                if (error.Count > 0)
                {
                    foreach (var da in error)
                    {
                        System.Diagnostics.Debug.WriteLine(da);
                    }
                }
                else
                {
                    var TempCertificationTracker = ldcr.CertificationTrackers.Where(ct => ct.EmpBadgeNo ==
                                                                                    certificationTracker.EmpBadgeNo && ct.CertificationCode == certificationTracker.CertificationCode).FirstOrDefault();

                    if (TempCertificationTracker == null)
                    {
                        // Add the new Tracker
                        ldcr.CertificationTrackers.Add(certificationTracker);
                        ldcr.SaveChanges();
                        message = emp.Last_Name + " , " + emp.First_Name + " is successfully certified in " + certificationTracker.CertificationCode;
                        return(RedirectToAction("ModalSuccess", "IT", new { message = message, id = Who, urlBack = "Details", redirectUrl = RedirectURL }));
                    }
                }
                return(RedirectToAction("ModalFailed", "IT", new { message = message, id = Who, urlBack = "Certified", redirectUrl = RedirectURL }));
            }
            else
            {
                if (DateP == null || String.IsNullOrEmpty(DateP))
                {
                    ModelState.AddModelError("", "Please provide date certified.");
                    message += "Please provide date certified.";
                }
                if (TrainingDate == null || String.IsNullOrEmpty(TrainingDate))
                {
                    ModelState.AddModelError("", "Please provide Training Date.");
                    message += "Please provide Training Date.";
                }
                if (Code == "X")
                {
                    ModelState.AddModelError("", "Please choose certification code");
                    message = "Please choose certification code";
                }

                return(RedirectToAction("ModalFailed", "IT", new { message = message, id = Who, urlBack = "Certified", redirectUrl = RedirectURL }));
            }
        }
Esempio n. 4
0
        public ActionResult Testing(String id, String urlBack)
        {
            ViewBag.URLBack = urlBack;
            EmployeeModel empModel = new EmployeeModel();

            if (id != null)
            {
                var employee = ldcr.EmployeeDCR_Vw.Where(emp => emp.Employee_ID == id).FirstOrDefault();
                if (employee != null)
                {
                    empModel.Employee             = employee;
                    empModel.Certifications       = ldcr.Certifications.OrderBy(l => l.Code).ToList();
                    empModel.TotalCertifications  = ldcr.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderBy(cr => cr.CertificationCode).ToList();
                    empModel.CurrentCertification = ldcr.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID).OrderByDescending(cr => cr.DateCertified).FirstOrDefault();
                    double SKP = (Convert.ToDouble(empModel.TotalCertifications.Count()) / Convert.ToDouble(empModel.Certifications.Count())) * (100);
                    if (!Double.IsNaN(SKP))
                    {
                        //ViewBag.SkillsCertifiedPercentage = Convert.ToInt32(SKP);
                        empModel.PercentAgeCertified = Convert.ToInt32(SKP);
                    }
                    else
                    {
                        //ViewBag.SkillsCertifiedPercentage = 0;
                        empModel.PercentAgeCertified = 0;
                    }
                    var ReCertified = ldcr.CertificationTrackers.Where(cr => cr.EmpBadgeNo == employee.Employee_ID && cr.DateRecertified != null).OrderBy(cr => cr.Id).ToList().Count();
                    //ViewBag.TotalReCertified = ReCertified;
                    empModel.NumberReCertified = ReCertified;
                    double SRKP = (Convert.ToDouble(ReCertified) / Convert.ToDouble(empModel.Certifications.Count())) * (100);
                    if (!Double.IsNaN(SRKP))
                    {
                        // ViewBag.SkillsReCertifiedPercentage = Convert.ToInt32(SRKP);
                        empModel.PercentAgeReCertified = Convert.ToInt32(SRKP);
                    }
                    else
                    {
                        // ViewBag.SkillsReCertifiedPercentage = 0;
                        empModel.PercentAgeReCertified = 0;
                    }

                    System.Diagnostics.Debug.WriteLine(Convert.ToInt32(SKP));
                    System.Diagnostics.Debug.WriteLine(Convert.ToInt32(SRKP));
                    var totalPointsCertiFied   = 0;
                    var TotalPointsReCertified = 0;
                    foreach (var certification in empModel.Certifications)
                    {
                        if (empModel.TotalCertifications.FirstOrDefault(el => el.CertificationCode == certification.Code) == null)
                        {
                            CertificationTracker CT = new CertificationTracker();
                            CT.Id                = 0;
                            CT.EmpBadgeNo        = id;
                            CT.CertificationCode = certification.Code;
                            CT.DateCertified     = null;
                            CT.DateRecertified   = null;
                            empModel.MyCertifications.Add(CT);
                        }
                        else
                        {
                            empModel.MyCertifications.Add(empModel.TotalCertifications.FirstOrDefault(el => el.CertificationCode == certification.Code));
                            totalPointsCertiFied += Convert.ToInt32(certification.Points);
                        }
                        if (empModel.TotalCertifications.FirstOrDefault(el => el.CertificationCode == certification.Code && el.DateRecertified != null) != null)
                        {
                            TotalPointsReCertified += Convert.ToInt32(certification.Points);
                        }
                    }
                    empModel.TotalPointsCertified   = totalPointsCertiFied;
                    empModel.TotalPointsReCertified = TotalPointsReCertified;
                }
            }
            return(View(empModel));
        }
Esempio n. 5
0
        public ActionResult PostReCertified()
        {
            var DateP       = Request.Form["DateReCertified"];
            var Who         = Request.Form["Employee"];
            var Code        = Request.Form["Code"];
            var RedirectURL = Request.Form["URLBACK"];
            var message     = "";

            List <String>        error = new List <string>();
            CertificationTracker certificationTracker = new CertificationTracker();

            if (DateP != null && Who != null && Code != null && Code != "X" && !String.IsNullOrEmpty(DateP))
            {
                // Check if Employee is Exist
                var emp = cEE.Employees_Details.Where(u => u.Employee_ID.ToString().ToLower() == Who.ToString().ToLower()).FirstOrDefault();
                if (emp != null)
                {
                    certificationTracker.EmpBadgeNo = emp.Employee_ID;
                }
                else
                {
                    error.Add("BadgeNo not exist");
                }
                // Check if certification Code is Exist
                var code = ldcr.Certifications.Where(c => c.Code == Code).FirstOrDefault();
                if (code != null)
                {
                    certificationTracker.CertificationCode = code.Code;
                }
                else
                {
                    error.Add("Certification Code not exist");
                }

                if (Validator.isValidDate(DateP))
                {
                    // CertificationTracker ctr = new CertificationTracker();
                    var ctr = ldcr.CertificationTrackers.Where(cTr => cTr.EmpBadgeNo == Who && cTr.CertificationCode == Code).FirstOrDefault();
                    if (ctr != null)
                    {
                        DateTime dtValue = (DateTime)ctr.DateCertified;
                        String   Date    = "";
                        if (dtValue.Month.ToString().Length > 1)
                        {
                            Date += dtValue.Month.ToString() + "/";
                        }
                        else
                        {
                            Date += "0" + dtValue.Month.ToString() + "/";
                        }
                        if (dtValue.Day.ToString().Length > 1)
                        {
                            Date += dtValue.Day.ToString() + "/";
                        }
                        else
                        {
                            Date += "0" + dtValue.Day.ToString() + "/";
                        }
                        Date += dtValue.Year.ToString();

                        if (Validator.compareTwoDate(DateP, Date))
                        {
                            certificationTracker.DateCertified = DateTime.ParseExact(DateP, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            error.Add("Date is prior to Last Certified Date!");
                            message += "Date is prior to Last Certified Date!";
                        }
                    }
                }
                else
                {
                    error.Add("Date is not Valid!");
                }
                if (error.Count > 0)
                {
                    foreach (var da in error)
                    {
                        System.Diagnostics.Debug.WriteLine(da);
                    }
                    return(RedirectToAction("ModalFailed", "IT", new { message = message, id = Who, urlBack = "ReCertified", redirectUrl = RedirectURL }));
                }
                else
                {
                    var TempCertificationTracker = ldcr.CertificationTrackers.Where(ct => ct.EmpBadgeNo ==
                                                                                    certificationTracker.EmpBadgeNo && ct.CertificationCode == certificationTracker.CertificationCode).FirstOrDefault();
                    if (TempCertificationTracker != null)
                    {
                        // Update that tracker
                        System.Diagnostics.Debug.WriteLine(certificationTracker.CertificationCode + " --- " + certificationTracker.EmpBadgeNo
                                                           + " -- " + certificationTracker.DateCertified);
                        TempCertificationTracker.DateRecertified   = certificationTracker.DateCertified;
                        ldcr.Entry(TempCertificationTracker).State = EntityState.Modified;
                        ldcr.SaveChanges();
                        //ldcr.CertificationTrackers.Find(TempCertificationTracker);

                        // DELETE RECERTIFACTION PLan Of the Employee //
                        ldcr.deleteLastPlan(TempCertificationTracker.EmpBadgeNo);
                        Session["NumberOfRecertificationPlans"] = Convert.ToInt32(Session["NumberOfRecertificationPlans"]) - 1;
                        message = emp.Last_Name + " , " + emp.First_Name + " is succesfully Re-Certified in " + TempCertificationTracker.CertificationCode;
                    }
                    return(RedirectToAction("ModalSuccess", "IT", new { message = message, id = Who, urlBack = "Details", redirectUrl = RedirectURL }));
                }
            }
            else
            {
                if (DateP == null || String.IsNullOrEmpty(DateP))
                {
                    ModelState.AddModelError("", "Please provide date certified.");
                    message += "Please provide date Re-certified.";
                }
                if (Code == "X")
                {
                    ModelState.AddModelError("", "Please choose certification code");
                    message = "Please choose certification code";
                }

                return(RedirectToAction("ModalFailed", "IT", new { message = message, id = Who, urlBack = "ReCertified", redirectUrl = RedirectURL }));
            }
        }