Пример #1
0
        public ActionResult AddNewParticipants(string cycleDateRangeStart, string cycleDateRangeEnd)
        {
            if (Business.SecurityManager.HasHRRole(CurrentUser))
            {
                Dictionary<string, string> dict = new Dictionary<string, string>();
                Models.DTO.NewCycleManagementPage obj_cycle_management_page = new Models.DTO.NewCycleManagementPage();

                if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd))
                {
                    ViewData["Stage1EndDate"] = "";
                    ViewData["Stage3EndDate"] = "";

                    dict.Add("Stage1EndDate", "");
                    dict.Add("Stage3EndDate", "");
                }
                else
                {
                    dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart));
                    dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd));
                    ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart);
                    ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd);
                }
                ViewData.Model = obj_cycle_management_page;
                return View();
            }
            else
            {
                TempData["AlertMessage"] = Resources.Resource.MSG_FUNCTIONS_NO_ACCESS;
                return Redirect(Url.Content("~/Home/Index"));
            }
        }
Пример #2
0
        public ActionResult AddNewParticipants(string cycleDateRangeStart, string cycleDateRangeEnd, FormCollection form)
        {
            Dictionary<string, string> dict = FormCollectionToDict(form);
            Models.DTO.NewCycleManagementPage obj_cycle_management_page = new Models.DTO.NewCycleManagementPage();
            List<Model.DTO.Core.Employee> lst_current_participants = null;

            if (System.Web.HttpContext.Current.Session["CycleParticipantsList"] != null)
            {
                lst_current_participants = (List<Model.DTO.Core.Employee>)System.Web.HttpContext.Current.Session["CycleParticipantsList"];
            }

            obj_cycle_management_page.Participants = Business.AppraisalManager.GetEmployeesToAddToCycle(form.GetValue("EmployeeName").AttemptedValue == null ? null : form.GetValue("EmployeeName").AttemptedValue.Trim(),
                                                                                                        form.GetValue("DomainID").AttemptedValue == null ? null : form.GetValue("DomainID").AttemptedValue.Trim(),
                                                                                                        form.GetValue("DepartmentName").AttemptedValue == null ? null : form.GetValue("DepartmentName").AttemptedValue.Trim(),
                                                                                                        lst_current_participants);

            if (!Lib.Utility.Common.IsNullOrEmptyList(obj_cycle_management_page.Participants))
            {
                obj_cycle_management_page.Participants = obj_cycle_management_page.Participants.OrderBy(rec => rec.Department.Name).OrderBy(rec => rec.PreferredName).ToList();
                System.Web.HttpContext.Current.Session.Add("CycleNewParticipants", obj_cycle_management_page.Participants);
            }

            if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd))
            {
                ViewData["Stage1EndDate"] = "";
                ViewData["Stage3EndDate"] = "";
                dict.Add("Stage1EndDate", "");
                dict.Add("Stage3EndDate", "");
            }
            else
            {
                dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart));
                dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd));
                ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart);
                ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd);
            }

            ViewData.Model = obj_cycle_management_page;
            TempData["QueryData"] = dict;
            return View();
        }
Пример #3
0
        public ActionResult RemoveNewParticipants(string cycleDateRangeStart, string cycleDateRangeEnd, FormCollection form)
        {
            Dictionary<string, string> dict = FormCollectionToDict(form);
            Models.DTO.NewCycleManagementPage obj_cycle_management_page = new Models.DTO.NewCycleManagementPage();
            List<Model.DTO.Core.Employee> lst_employees = null;

            if (System.Web.HttpContext.Current.Session["CycleParticipantsList"] != null)
            {
                lst_employees = (List<Model.DTO.Core.Employee>)System.Web.HttpContext.Current.Session["CycleParticipantsList"];
            }

            if (string.IsNullOrEmpty(dict["EmployeeName"].Trim()) && string.IsNullOrEmpty(dict["DomainID"].Trim()) && string.IsNullOrEmpty(dict["DepartmentName"].Trim()))
            {
                obj_cycle_management_page.Participants = lst_employees;
            }
            else
            {
                obj_cycle_management_page.Participants = Business.AppraisalManager.GetEmployeesToRemoveFromCycle(dict["EmployeeName"].Trim(), dict["DomainID"].Trim(), dict["DepartmentName"].Trim(), lst_employees);
            }

            if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd))
            {
                ViewData["Stage1EndDate"] = "";
                ViewData["Stage3EndDate"] = "";
                dict.Add("Stage1EndDate", "");
                dict.Add("Stage3EndDate", "");
            }
            else
            {
                dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart));
                dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd));
                ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart);
                ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd);
            }

            ViewData.Model = obj_cycle_management_page;
            TempData["QueryData"] = dict;
            return View();
        }
Пример #4
0
        public ActionResult RemoveNewParticipants(string cycleDateRangeStart, string cycleDateRangeEnd)
        {
            if (Business.SecurityManager.HasHRRole(CurrentUser))
            {
                Dictionary<string, string> dict = new Dictionary<string, string>();
                Models.DTO.NewCycleManagementPage obj_cycle_management_page = new Models.DTO.NewCycleManagementPage();

                if (System.Web.HttpContext.Current.Session["CycleParticipantsList"] != null)
                {
                    obj_cycle_management_page.Participants = (List<Model.DTO.Core.Employee>)System.Web.HttpContext.Current.Session["CycleParticipantsList"];
                }

                if (Lib.Utility.Common.IsNullOrEmptyList(obj_cycle_management_page.Participants))
                {
                    ViewData["AlertMessage"] = "There are no employees to remove.";
                    return Redirect(Url.Content("~/HRManage/NewCycle/" + cycleDateRangeStart + "/" + cycleDateRangeEnd));
                }

                if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd))
                {
                    ViewData["Stage1EndDate"] = "";
                    ViewData["Stage3EndDate"] = "";
                    dict.Add("Stage1EndDate", "");
                    dict.Add("Stage3EndDate", "");
                }
                else
                {
                    dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart));
                    dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd));
                    ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart);
                    ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd);
                }
                ModelState.Clear();
                ViewData.Model = obj_cycle_management_page;
                return View();
            }
            else
            {
                TempData["AlertMessage"] = Resources.Resource.MSG_FUNCTIONS_NO_ACCESS;
                return Redirect(Url.Content("~/Home/Index"));
            }
        }
Пример #5
0
        public ActionResult NewCycle(FormCollection form)
        {
            string message = string.Empty;
            Dictionary<string, string> dict = FormCollectionToDict(form);
            bool boo_start_cycle = Convert.ToInt32(dict["startcycle"]) == 1 ? true : false;
            Models.DTO.NewCycleManagementPage obj_cycle_management_page = new Models.DTO.NewCycleManagementPage();

            if (!boo_start_cycle)
            {
                if (form["Stage1EndDate"] != null && form["Stage3EndDate"] != null)
                {
                    if (string.IsNullOrEmpty(dict["Stage1EndDate"]) || string.IsNullOrEmpty(dict["Stage1EndDate"]))
                    {
                        ViewData.Model = obj_cycle_management_page;
                        TempData["ErrorMessage"] = "Please enter all the dates for the appraisal cycle before retrieving the participants.";
                        return View();
                    }

                    DateTime eligibilityRangeStart = DateTime.ParseExact(form["Stage1EndDate"].ToString(), "d/M/yyyy", null);
                    DateTime eligibilityRangeEnd = DateTime.ParseExact(form["Stage3EndDate"].ToString(), "d/M/yyyy", null);

                    List<Model.DTO.Core.Employee> lst_selected_employees = Business.AppraisalManager.GetEligibleEmployeesForCycle(eligibilityRangeStart, eligibilityRangeEnd);

                    if (!Lib.Utility.Common.IsNullOrEmptyList(lst_selected_employees))
                    {
                        System.Web.HttpContext.Current.Session.Add("CycleParticipantsList", lst_selected_employees);
                        obj_cycle_management_page.Participants = lst_selected_employees.OrderBy(rec => rec.Department.Name).ThenBy(rec => rec.PreferredName).ToList();
                    }
                    else
                    {
                        obj_cycle_management_page.Participants = new List<Model.DTO.Core.Employee>();
                    }

                    System.Web.HttpContext.Current.Session.Add("CycleName", dict["cyclename"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage1StartDate", dict["Stage1StartDate"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage1EndDate", dict["Stage1EndDate"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage2StartDate", dict["Stage2StartDate"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage2EndDate", dict["Stage2EndDate"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage3StartDate", dict["Stage3StartDate"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage3EndDate", dict["Stage3EndDate"].ToString());

                    System.Web.HttpContext.Current.Session.Add("Stage1SubmissionDeadline", dict["Stage1SubmissionDeadline"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage1Level1ApprovalDeadline", dict["Stage1Level1ApprovalDeadline"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage1Level2ApprovalDeadline", dict["Stage1Level2ApprovalDeadline"].ToString());

                    System.Web.HttpContext.Current.Session.Add("Stage2SubmissionDeadline", dict["Stage1SubmissionDeadline"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage2Level1ApprovalDeadline", dict["Stage1Level1ApprovalDeadline"].ToString());
                    System.Web.HttpContext.Current.Session.Add("Stage2Level2ApprovalDeadline", dict["Stage1Level2ApprovalDeadline"].ToString());
                }

                ViewData.Model = obj_cycle_management_page;

                dict.Add("strStage1EndDate", Lib.Utility.Common.ChangeDateFormatVS(dict["Stage1EndDate"].ToString()));
                dict.Add("strStage3EndDate", Lib.Utility.Common.ChangeDateFormatVS(dict["Stage3EndDate"].ToString()));
                TempData["QueryData"] = dict;
                return View();
            }
            else
            {
                if (System.Web.HttpContext.Current.Session["CycleParticipantsList"] != null)
                {
                    PMS.Model.DTO.Cycle.Cycle obj_cycle = new PMS.Model.DTO.Cycle.Cycle()
                    {
                        Name = form["cyclename"].Trim(),
                        Stage = new Model.DTO.Master.Stage() { Id = Model.PMSConstants.STAGE_ID_PRE_CYCLE },
                        Status = new Model.DTO.Master.Status() { Id = Model.PMSConstants.STATUS_ID_OPEN },
                        Starter = new Model.DTO.Core.Employee() { Id = CurrentUser.Id },
                        StartedTimestamp = DateTime.Now
                    };

                    Dictionary<string, DateTime> dict_cycle_stage_dates = new Dictionary<string, DateTime>();
                    dict_cycle_stage_dates.Add("PreCStart", DateTime.Now.Date);
                    dict_cycle_stage_dates.Add("PreCEnd", DateTime.ParseExact(dict["Stage1StartDate"], "dd/MM/yyyy", null).AddDays(-1));
                    dict_cycle_stage_dates.Add("Stage1StartDate", DateTime.ParseExact(dict["Stage1StartDate"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage1EndDate", DateTime.ParseExact(dict["Stage1EndDate"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage2StartDate", DateTime.ParseExact(dict["Stage2StartDate"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage2EndDate", DateTime.ParseExact(dict["Stage2EndDate"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage3StartDate", DateTime.ParseExact(dict["Stage3StartDate"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage3EndDate", DateTime.ParseExact(dict["Stage3EndDate"], "dd/MM/yyyy", null));

                    dict_cycle_stage_dates.Add("Stage1SubmissionDeadline", DateTime.ParseExact(dict["Stage1SubmissionDeadline"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage1Level1ApprovalDeadline", DateTime.ParseExact(dict["Stage1Level1ApprovalDeadline"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage1Level2ApprovalDeadline", DateTime.ParseExact(dict["Stage1Level2ApprovalDeadline"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage2SubmissionDeadline", DateTime.ParseExact(dict["Stage2SubmissionDeadline"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage2Level1ApprovalDeadline", DateTime.ParseExact(dict["Stage2Level1ApprovalDeadline"], "dd/MM/yyyy", null));
                    dict_cycle_stage_dates.Add("Stage2Level2ApprovalDeadline", DateTime.ParseExact(dict["Stage2Level2ApprovalDeadline"], "dd/MM/yyyy", null));

                    obj_cycle.CycleStages = CreateDefaultStagesForNewCycle(dict_cycle_stage_dates);

                    obj_cycle.Appriasals = Business.AppraisalManager.CreateAppraisalsForNewCycle((List<Model.DTO.Core.Employee>)System.Web.HttpContext.Current.Session["CycleParticipantsList"], obj_cycle.CycleStages, CurrentUser);

                    if (Business.AppraisalManager.CreateNewCycle(obj_cycle, Model.Mappers.CoreMapper.MapUserDTOToEmployeeDTO(CurrentUser), out message))
                    {
                        ClearAllCreatedSessionObjects();
                        return Redirect(Url.Content("~/"));
                    }
                    else
                    {
                        TempData["ErrorMessage"] = "Unable to save cycle information. Please try again or contact IT Department.";
                        return View();
                    }
                }
                else
                {
                    TempData["ErrorMessage"] = "Cycle information is not found. Please try again or contact IT Department.";
                    return View();
                }
            }
        }
Пример #6
0
        public ActionResult NewCycle(string cycleDateRangeStart, string cycleDateRangeEnd, int? cycleId)
        {
            if (Business.SecurityManager.HasHRRole(CurrentUser))
            {
                Dictionary<string, string> dict = new Dictionary<string, string>();
                Models.DTO.NewCycleManagementPage obj_cycle_management_page = new Models.DTO.NewCycleManagementPage();

                if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd))
                {
                    obj_cycle_management_page.CurrentCycle = new PMS.Model.DTO.Cycle.Cycle();
                    dict.Add("Stage1EndDate", "");
                    dict.Add("Stage3EndDate", "");
                    dict.Add("strStage1EndDate", "");
                    dict.Add("strStage3EndDate", "");

                    dict.Add("Stage1SubmissionDeadline", "");
                    dict.Add("Stage1Level1ApprovalDeadline", "");
                    dict.Add("Stage1Level2ApprovalDeadline", "");
                    dict.Add("Stage2SubmissionDeadline", "");
                    dict.Add("Stage2Level1ApprovalDeadline", "");
                    dict.Add("Stage2Level2ApprovalDeadline", "");
                    TempData["QueryData"] = dict;
                }
                else
                {
                    cycleDateRangeStart = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart);
                    cycleDateRangeEnd = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd);
                    string key = cycleDateRangeStart + " " + cycleDateRangeEnd;

                    obj_cycle_management_page.Participants = (List<Model.DTO.Core.Employee>)System.Web.HttpContext.Current.Session["CycleParticipantsList"];

                    dict.Add("cyclename", (string)System.Web.HttpContext.Current.Session["CycleName"]);
                    dict.Add("Stage1StartDate", (string)System.Web.HttpContext.Current.Session["Stage1StartDate"]);
                    dict.Add("Stage1EndDate", (string)System.Web.HttpContext.Current.Session["Stage1EndDate"]);
                    dict.Add("Stage2StartDate", (string)System.Web.HttpContext.Current.Session["Stage2StartDate"]);
                    dict.Add("Stage2EndDate", (string)System.Web.HttpContext.Current.Session["Stage2EndDate"]);
                    dict.Add("Stage3StartDate", (string)System.Web.HttpContext.Current.Session["Stage3StartDate"]);
                    dict.Add("Stage3EndDate", (string)System.Web.HttpContext.Current.Session["Stage3EndDate"]);
                    dict.Add("strStage1EndDate", Lib.Utility.Common.ChangeDateFormatVS(dict["Stage1EndDate"]));
                    dict.Add("strStage3EndDate", Lib.Utility.Common.ChangeDateFormatVS(dict["Stage3EndDate"]));

                    dict.Add("Stage1SubmissionDeadline", (string)System.Web.HttpContext.Current.Session["Stage1SubmissionDeadline"]);
                    dict.Add("Stage1Level1ApprovalDeadline", (string)System.Web.HttpContext.Current.Session["Stage1Level1ApprovalDeadline"]);
                    dict.Add("Stage1Level2ApprovalDeadline", (string)System.Web.HttpContext.Current.Session["Stage1Level2ApprovalDeadline"]);

                    dict.Add("Stage2SubmissionDeadline", (string)System.Web.HttpContext.Current.Session["Stage2SubmissionDeadline"]);
                    dict.Add("Stage2Level1ApprovalDeadline", (string)System.Web.HttpContext.Current.Session["Stage2Level1ApprovalDeadline"]);
                    dict.Add("Stage2Level2ApprovalDeadline", (string)System.Web.HttpContext.Current.Session["Stage2Level2ApprovalDeadline"]);

                    TempData["QueryData"] = dict;
                }

                //ModelState.Clear();
                ViewData.Model = obj_cycle_management_page;
                return View();
            }
            else
            {
                TempData["AlertMessage"] = Resources.Resource.MSG_FUNCTIONS_NO_ACCESS;
                return Redirect(Url.Content("~/Home/Index"));
            }
        }