コード例 #1
0
        /// <summary>
        /// This method defines the policy for the employee that is applied through  employee edit view in the Human resource Area
        /// the Policies are different for both A1 and BCl employees that is why a generic method is created for overall employees to be called through a
        /// single method
        /// </summary>
        /// <param name="lvPolicy"> Get the Leave Policy details of the employe in the Leave Policy table</param>
        /// <param name="emp"> Get the employee whose policy is to checked </param>
        /// <returns></returns>
        public static bool EmployeeEligbleForLeave(LeavePolicy lvPolicy, List <VHR_EmployeeProfile> emp)
        {
            try
            {
                bool check = false;
                if (lvPolicy.ActiveAfterJoinDate == true)
                {
                    check = true;
                }
                else if (lvPolicy.ActiveAfterProbation == true)
                {
                    if (emp.FirstOrDefault().Status == "Active")
                    {
                        check = true;
                    }
                }
                else if (lvPolicy.ActiveAfterCustomDays == true)
                {
                    if (emp.FirstOrDefault().DOJ != null)
                    {
                        double daysFromJoining = (DateTime.Today.Date - emp.FirstOrDefault().DOJ.Value.Date).TotalDays;
                        if (daysFromJoining > lvPolicy.CustomDays)
                        {
                            check = true;
                        }
                    }
                }

                return(check);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public async Task <IActionResult> EditLeavePolicy(LeavePolicy item)
        {
            var model = await _context.LeavePolicies.SingleOrDefaultAsync(b => b.Id == item.Id);

            await TryUpdateModelAsync(model);

            model.LastUpdated = DateTime.Now.Date;
            model.UpdatedBy   = "user";
            await _context.SaveChangesAsync();

            string level;

            if (item.IsCompanyPolicy)
            {
                level = "ORG";
            }
            else if (item.GradeGroupId.HasValue)
            {
                level = "GRADE_GROUP";
            }
            else
            {
                level = "JOB_GRADE";
            }

            return(RedirectToAction("LeavePoliciesList", new { level = level }));
        }
コード例 #3
0
        public JsonResult UpdateAdvanceCreditAndAvailed(LeavePolicy leavePolicy)
        {
            MTSHRDataLayer.EmployeeLeave data = new MTSHRDataLayer.EmployeeLeave();
            var result = JsonConvert.SerializeObject(data.UpdateAdvanceCreditAndAvailed(leavePolicy.Id, leavePolicy.MaxAllowBal, leavePolicy.ConsecutiveLeave));

            return(Json(new { success = result }));
        }
コード例 #4
0
        private void ValidationMethod(LeavePolicy obj)
        {
            #region --Validation--
            //Validation for Carry Forward Feilds
            if (obj.CF == true)
            {
                if (obj.CFMaxDays == null)
                {
                    ModelState.AddModelError("CFMaxDays", "Add Days");
                }
            }

            if (obj.ActiveAfterCustomDays == true)
            {
                if (obj.CustomDays == null)
                {
                    ModelState.AddModelError("ActiveAfterCustomDays", "Add Days");
                }
            }
            if (obj.LeavePolicyName == null || obj.LeavePolicyName == "")
            {
                ModelState.AddModelError("LeavePolicyName", "Leave policy name cannot be empty");
            }
            #endregion
        }
コード例 #5
0
        public JsonResult UpdateLeavepolicy(LeavePolicy leavePolicy)
        {
            MTSHRDataLayer.Leave data = new MTSHRDataLayer.Leave();
            var result = JsonConvert.SerializeObject(data.UpdateLeavePolicy(leavePolicy.Id, leavePolicy.LeaveType, leavePolicy.LeaveCode, leavePolicy.ApplicableAfter, leavePolicy.ApplicableFor, leavePolicy.MaritalStatus,
                                                                            leavePolicy.Accural, leavePolicy.MaxAllowBal, leavePolicy.ConsecutiveLeave, leavePolicy.ADJUSTMENT_LEAVE_AGAINST, leavePolicy.LEAVE_CANNOT_TAKE_TOGETHER, leavePolicy.ENABLE_UPLOAD_DOC_FOR_EXCEEDED_DAYS, leavePolicy.PRORATA));

            return(Json(new { success = result }));
        }
コード例 #6
0
        public ActionResult Edit(int?id)
        {
            LeavePolicy obj = LeavePolicyService.GetEdit((int)id);

            HelperMethod(obj);

            return(PartialView(obj));
        }
コード例 #7
0
        public string ApproveLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                //Check the Leave balance if there are some leaves remaining of the employee whose leave is being approved.
                if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                {
                    //Changes Leave Stage ID to "A" (Approved).
                    lvapplication.LeaveStageID = "A";
                    //Gets the leave Type through generic service.
                    LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                    LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                    LeaveApplicationRepository.Edit(lvapplication);
                    LeaveApplicationRepository.Save();
                    UnitOfWork.Commit();
                    //Adds leave to leave data frim where its impact is generated on the reports.
                    LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                    //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                    LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                    VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                    VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                    // Add notification to the Employee that leave has been approved.
                    DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                               Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                    //Add entry in the flow table
                    SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                    //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                    Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                    VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                    DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                            ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                    // Disable Notification of the pending Leave.
                    int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                    Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                    DDService.DeleteNotification(SpecificEntries);
                }
            }
            return(Message);
        }
コード例 #8
0
        public IActionResult DeleteLeavePolicy(long id)
        {
            LeavePolicy a = LeavePolicy_repo.Find(id);

            if (a == null)
            {
                return(NotFound());
            }
            LeavePolicy_repo.Delete(a);
            return(Ok());
        }
コード例 #9
0
        public bool HasLeaveQuota(int empID, LeavePolicy leaveType, int FinYearID)
        {
            bool check = false;
            List <LeaveQuotaYear> _lvConsumed = new List <LeaveQuotaYear>();
            Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = aa => aa.EmployeeID == empID && aa.FinancialYearID == FinYearID && aa.LeaveTypeID == leaveType.LeaveTypeID;

            _lvConsumed = LeaveQuotaYearRepo.FindBy(SpecificEntries);
            if (_lvConsumed.Count > 0)
            {
                check = true;
            }
            return(check);
        }
コード例 #10
0
        public async Task <IActionResult> AddLeavePolicy(LeavePolicy item, string level)
        {
            if (level == "ORG")
            {
                item.IsCompanyPolicy = true;
            }
            item.CreatedDate = DateTime.Now.Date;
            item.LastUpdated = DateTime.Now.Date;
            item.UpdatedBy   = "user";
            _context.LeavePolicies.Add(item);
            await _context.SaveChangesAsync();

            return(RedirectToAction("LeavePoliciesList", new { level = level }));
        }
コード例 #11
0
 /// <summary>
 /// For those leave types for which no leave policy is required
 /// </summary>
 /// <returns></returns>
 public static LeavePolicy GetNoPolicy()
 {
     try
     {
         LeavePolicy AttLvPolicy = new LeavePolicy();
         AttLvPolicy.LeaveTypeID   = 0;
         AttLvPolicy.UpdateBalance = false;
         return(AttLvPolicy);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #12
0
        private float GetTotalDays(List <LeavePolicy> leavePolicies, VHR_EmployeeProfile employee, FinancialYear financialYear)
        {
            if (leavePolicies.Count == 0)
            {
                return(0);
            }
            else
            {
                LeavePolicy leavePolicy = leavePolicies.First();
                if (leavePolicy.ProRata == true)
                {
                    // get months between
                    if (employee.DOJ.Value > financialYear.FYStartDate)
                    {
                        float months = 0;
                        float leaves = 0;

                        // Get month of first Salary
                        if (employee.DOJ.Value.Month == financialYear.FYStartDate.Value.Month)
                        {
                            months = 12;
                        }
                        else
                        {
                            int FirstSalaryMonth = employee.DOJ.Value.Month;
                            if (employee.DOJ.Value.Year == financialYear.FYStartDate.Value.Year)
                            {
                                months = 13 - FirstSalaryMonth + 6;
                            }
                            else
                            {
                                months = 7 - FirstSalaryMonth;
                            }
                        }
                        leaves = (months * leavePolicy.TotalDays.Value) / 12;
                        return((int)(leaves));
                    }
                    else
                    {
                        return((leavePolicy.TotalDays == null) ? 0 : (float)leavePolicy.TotalDays);
                    }
                }
                else
                {
                    return((leavePolicy.TotalDays == null) ? 0 : (float)leavePolicy.TotalDays);
                }
            }
        }
コード例 #13
0
        public bool AddLeaveToLeaveData(LeaveApplication lvappl, LeaveType lvType, LeavePolicy lvPolicy)
        {
            //Add leave to Leave data for the implemetation in the reports
            DateTime datetime = new DateTime();

            datetime = lvappl.FromDate;
            //Gets the Specific employee and his shift
            Expression <Func <Employee, bool> > SpecificEntries = aa => aa.PEmployeeID == lvappl.EmpID;
            Employee emp   = EmployeeRepo.FindBy(SpecificEntries).First();
            Shift    shift = emp.Shift;
            //Gets the roster or crew information of the Employee
            Expression <Func <VAT_RosterDetail, bool> > SpecificEntries2 = aa => aa.CriteriaData == emp.CrewID && aa.RosterDate >= lvappl.FromDate && aa.RosterDate <= lvappl.ToDate;
            List <VAT_RosterDetail> rosterDetails = RosterDetailRepo.FindBy(SpecificEntries2);

            for (int i = 0; i < lvappl.CalenderDays; i++)
            {
                //If the user is BCL Employee his rest day count would be not be true
                if (lvPolicy.CountRestDays != true)
                {
                    //If roster is applied to the employee
                    if (rosterDetails.Where(aa => aa.RosterDate == datetime).Count() > 0)
                    {
                        VAT_RosterDetail rd = rosterDetails.First(aa => aa.RosterDate == datetime);
                        //IF work minutes of the roster are greater than 0 it means that roster is applied system call the Leave data function and apply leave for that day.
                        if (rd.WorkMin > 0)
                        {
                            AddLeaveData(lvappl, lvType, datetime);
                        }
                    }
                    else
                    {
                        //IF current day is not
                        if (!CurrentDayNotRest(shift, datetime))
                        {
                            AddLeaveData(lvappl, lvType, datetime);
                        }
                    }
                }
                else
                {
                    AddLeaveData(lvappl, lvType, datetime);
                }
                datetime = datetime.AddDays(1);
            }
            return(true);
        }
コード例 #14
0
 public ActionResult Create(LeavePolicy obj)
 {
     ReadFromRadioButton(obj);
     if (obj.LeavePolicyName == null || obj.LeavePolicyName == "")
     {
         ModelState.AddModelError("LeavePolicyName", "Leave Policy name cannot be empty");
     }
     if (LeavePolicyService.GetIndex().Where(lp => lp.LeavePolicyName == obj.LeavePolicyName).Count() > 0)
     {
         ModelState.AddModelError("LeavePolicyName", "Leave Policy name must be unique");
     }
     if (ModelState.IsValid)
     {
         LeavePolicyService.PostCreate(obj);
         return(Json("OK", JsonRequestBehavior.AllowGet));
     }
     HelperMethod(obj);
     return(PartialView("Create", obj));
 }
コード例 #15
0
        public ActionResult ValidateSLAttachment(LeaveApplication lvapplication)
        {
            VMLoggedUser LoggedInUser       = Session["LoggedInUser"] as VMLoggedUser;
            string       _EmpNo             = Request.Form["EmpNo"].ToString();
            LeavePolicy  lvPolicy           = new LeavePolicy();
            LeaveType    lvType             = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
            List <VHR_EmployeeProfile> _emp = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();

            lvapplication.EmpID = _emp.FirstOrDefault().PEmployeeID;
            lvPolicy            = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());
            float noofDays = LeaveApplicationService.CalculateNoOfDays(lvapplication, lvType, lvPolicy);

            if (noofDays >= lvPolicy.AttachmentForDays)
            {
                return(Json("Required", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("NotRequired", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #16
0
        public string RecommendLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                if (employee.HasOneStep == false)
                {
                    if (LoggedInUser.LineManagerID == null && (lvapplication.LeaveStageID == "P" || lvapplication.LeaveStageID == "D"))
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                    else if (LoggedInUser.LineManagerID != null && (lvapplication.LeaveStageID == "P"))
                    {
                        //gets the information of leave and saving entries from logged in user to leaveApplication.

                        int _userID = (int)LoggedInUser.PUserID;
                        lvapplication.LineManagerID     = (int)LoggedInUser.LineManagerID;
                        lvapplication.SubmittedByUserID = LoggedInUser.PUserID;
                        lvapplication.LeaveStageID      = "D";
                        LeaveApplicationRepository.Edit(lvapplication);
                        LeaveApplicationRepository.Save();
                        // Add notification to Line manager's end that he has a pending leave Request.
                        DDService.SaveNotification(lvapplication.LineManagerID, "/ESSP/ESSPLeaveApp/PendingLeaveApplicationIndex",
                                                   Convert.ToInt32(NTLeaveEnum.LeaveRecommend), true, lvapplication.EmpID, lvapplication.PLeaveAppID);
                        SaveLeaveApplicationFlow(lvapplication.LineManagerID, _userID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, lvapplication.LeaveReason, "");
                        // Save entry in Notification Email table for where the email is generated through service.
                        VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                        VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                        Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries2 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                        VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries2).First();
                        DDService.GenerateEmail(LMUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                                ESSPText.GetPendingLeaveText(vlvApplication, LMUser.UserEmployeeName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeavePending));

                        // Disable Notification of the pending Leave.
                        int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                        Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                        DDService.DeleteNotification(SpecificEntries);
                    }
                    else if (LoggedInUser.LineManagerID != null && (lvapplication.LeaveStageID == "D"))
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                }
                else
                {
                    if (lvapplication.LeaveStageID == "P")
                    {
                        ApprovalCode(vmESSPCommon, LoggedInUser, lvapplication, lvPolicy);
                    }
                }
            }
            return(Message);
        }
コード例 #17
0
        public ActionResult Create(LeaveApplication lvapplication)
        {
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;

            if (lvapplication.FromDate.Date > lvapplication.ToDate.Date)
            {
                ModelState.AddModelError("FromDate", "From Date should be smaller than To Date");
            }


            FinancialYear dbFinancialYear = DDService.GetFinancialYear().Where(aa => aa.PFinancialYearID == lvapplication.FinancialYearID).First();

            if (lvapplication.ToDate > dbFinancialYear.FYEndDate || lvapplication.ToDate < dbFinancialYear.FYStartDate)
            {
                ModelState.AddModelError("FromDate", "To Date must lie in selected financial year");
            }
            Expression <Func <PayrollPeriod, bool> > SpecificEntries3 = c => c.PeriodStageID == "O";
            PayrollPeriod dbpayrollperiod = PayrollPeriodService.GetIndexSpecific(SpecificEntries3).First();

            if (lvapplication.FromDate < dbpayrollperiod.PRStartDate)
            {
                ModelState.AddModelError("FromDate", "Cannot Create leaves in the Closed Payroll Period");
            }

            string _EmpNo = Request.Form["EmpNo"].ToString();
            List <VHR_EmployeeProfile> _emp = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
            Expression <Func <VHR_EmployeeProfile, bool> > SpecificEntries121 = c => c.OEmpID == _EmpNo;
            VHR_EmployeeProfile employee = VHR_EmployeeProfile.GetIndexSpecific(SpecificEntries121).First();

            lvapplication.EmpID = employee.PEmployeeID;


            var RBValue = Request.Form["HalfLvHA"];

            if (RBValue == "false")
            {
                lvapplication.IsHalf = false;
            }
            else
            {
                lvapplication.IsHalf = true;
            }
            LeavePolicy lvPolicy = new LeavePolicy();
            LeaveType   lvType   = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);

            if (_emp.Count == 0)
            {
                ModelState.AddModelError("EmpID", "Invalid Department Access or Employee Resigned.");
            }

            else
            {
                if (_emp.First().Status == "Resigned")
                {
                    if (_emp.First().ResignDate <= lvapplication.ToDate)
                    {
                        ModelState.AddModelError("ToDate", "Cannot Apply leaves of Resigned Employee.");
                    }
                }
                lvapplication.EmpID = employee.PEmployeeID;
                lvPolicy            = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());
                //lvType = db.Att_LeaveType.First(aa => aa.LvTypeID == lvapplication.LeaveTypeID);
                Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries = aa => aa.EmpID == lvapplication.EmpID && lvapplication.FromDate >= aa.FromDate && lvapplication.FromDate <= aa.ToDate && lvapplication.ToDate > aa.FromDate;
                if (VATLeaveApplicationService.GetIndexSpecific(SpecificEntries).Count() > 0)
                {
                    ModelState.AddModelError("FromDate", "Duplicate leave applied for one or more days");
                }
            }

            if (lvapplication.IsHalf == false && lvapplication.IsDeducted == false)
            {
                List <DailyAttendance> att = new List <DailyAttendance>();
                Expression <Func <DailyAttendance, bool> > SpecificEntries2 = aa => aa.EmpID == lvapplication.EmpID && aa.AttDate >= lvapplication.FromDate && aa.AttDate <= lvapplication.ToDate;
                att = DailyAttendanceService.GetIndexSpecific(SpecificEntries2);
                if (att.Count > 0)
                {
                    foreach (var at in att)
                    {
                        if (at.TimeIn != null || at.TimeOut != null)
                        {
                            ModelState.AddModelError("LeaveTypeID", "This employee has attendance for Specific day, Please clear his attendance first to proceed further");
                        }
                    }
                }
            }
            // CL cannot be taken after next to AL consective day
            if (lvapplication.LeaveTypeID == 2)
            {
                if (LeaveApplicationService.CheckForALConsectiveDay(lvapplication))
                {
                    ModelState.AddModelError("FromDate", "You have applied AL leave for previous date");
                }
            }

            float noofDays = LeaveApplicationService.CalculateNoOfDays(lvapplication, lvType, lvPolicy);

            if (lvapplication.LeaveTypeID == 11)
            {
                if (noofDays < lvPolicy.MinimumDays)
                {
                    ModelState.AddModelError("LeaveTypeID", "Cannot Apply Academic for Less than" + lvPolicy.MinimumDays.ToString() + " days");
                }
            }
            {
                if (noofDays < lvPolicy.MinimumDays)
                {
                    ModelState.AddModelError("LeaveTypeID", "Cannot Apply CME/Workshop for Less than" + lvPolicy.MinimumDays.ToString() + " days");
                }
            }
            if (lvapplication.IsHalf != true)
            {
                Expression <Func <VAT_JobCardApplication, bool> > SpecificEntries1 = aa => aa.OEmpID == _EmpNo && aa.DateStarted == lvapplication.FromDate && aa.DateStarted <= lvapplication.ToDate && aa.DateEnded > lvapplication.FromDate;
                if (JobcardAppService.GetIndexSpecific(SpecificEntries1).Count() > 0)
                {
                    ModelState.AddModelError("FromDate", "Job card exist for same date");
                }
            }
            Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
            Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();

            if (shifts.GZDays == true)
            {
                List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == lvapplication.FromDate).ToList();
                if (holiday.Count > 0)
                {
                    ModelState.AddModelError("FromDate", "Cannot apply leave of the Gazetted Holiday");
                }
            }
            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                ModelState.AddModelError("FromDate", "Cannot enter leaves in Closed Payroll Period");
            }
            //if (!DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //    ModelState.AddModelError("FromDate", "Payroll Period is Closed for this date");
            if (ModelState.IsValid)
            {
                if (LeaveApplicationService.CheckDuplicateLeave(lvapplication))
                {
                    // max days

                    float CalenderDays = LeaveApplicationService.CalculateCalenderDays(lvapplication, lvType, lvPolicy);
                    lvapplication.ReturnDate   = LeaveApplicationService.GetReturnDate(lvapplication, lvType, lvPolicy);
                    lvapplication.NoOfDays     = noofDays;
                    lvapplication.CalenderDays = CalenderDays;
                    int _UserID = LoggedInUser.PUserID;
                    lvapplication.CreatedBy = _UserID;
                    if (lvPolicy.PLeavePolicyID == 0)
                    {
                        LeaveApplicationService.CreateLeave(lvapplication, lvType, LoggedInUser, lvPolicy);
                        return(Json("OK", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        //check for employee eligible for leave
                        if (AssistantLeave.EmployeeEligbleForLeave(lvPolicy, _emp))
                        {
                            if (lvPolicy.UpdateBalance == true)
                            {
                                if (LeaveApplicationService.HasLeaveQuota(lvapplication.EmpID, lvPolicy, (int)lvapplication.FinancialYearID))
                                {
                                    if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                                    {
                                        //if (LeaveApplicationService.CheckForMaxMonthDays(lvapplication, lvPolicy, LvProcessController.GetFinancialYearID(db.PR_FinancialYear.ToList(), lvapplication.FromDate)))
                                        {
                                            LeaveApplicationService.CreateLeave(lvapplication, lvType, LoggedInUser, lvPolicy);
                                            return(Json("OK", JsonRequestBehavior.AllowGet));
                                        }
                                        //else
                                        //    ModelState.AddModelError("FromDate", "Leave Monthly Quota Exceeds");
                                    }
                                    else
                                    {
                                        ModelState.AddModelError("LeaveTypeID", "Leave Balance Exceeds!!!");
                                    }
                                }
                                else
                                {
                                    ModelState.AddModelError("LeaveTypeID", "Leave Quota does not exist");
                                }
                            }
                            else
                            {
                                LeaveApplicationService.CreateLeave(lvapplication, lvType, LoggedInUser, lvPolicy);
                                return(Json("OK", JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("LeaveTypeID", "Employee is not eligible for leave");
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("FromDate", "This Employee already has leave in this range of dates");
                }
            }
            HelperMethod(lvapplication);
            return(PartialView("Create", lvapplication));
        }
コード例 #18
0
 public void CreateLeave(LeaveApplication lvapplication, LeaveType lvType, VMLoggedUser user, LeavePolicy lvPolicy)
 {
     try
     {
         //Saves the Leave application vlaue in the leave application table on creation of the leave
         lvapplication.LeaveDate = DateTime.Today;
         int _userID = user.PUserID;
         lvapplication.CreatedBy = _userID;
         lvapplication.Active    = true;
         LeaveAppRepo.Add(lvapplication);
         LeaveAppRepo.Save();
         //Creates the leave Data of the leave application to be implemented in the leave application
         AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
         //Checks for the leave application balance
         BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
         LeaveAppRepo.Edit(lvapplication);
         LeaveAppRepo.Save();
         AddLeaveToAttData(lvapplication, lvType);
     }
     catch (Exception)
     {
     }
 }
コード例 #19
0
        public ActionResult Create(LeaveApplication lvapplication)
        {
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;

            if (lvapplication.LeaveAddress == "" || lvapplication.LeaveAddress == null)
            {
                ModelState.AddModelError("LeaveAddress", "Contact number is mandatory !");
            }
            if (lvapplication.LeaveAddress != null)
            {
                Match match = Regex.Match(lvapplication.LeaveAddress, @"^-*[0-9,\-]+$");
                if (!match.Success)
                {
                    ModelState.AddModelError("LeaveAddress", "Enter a valid Contact No");
                }
            }

            if (lvapplication.FromDate.Date > lvapplication.ToDate.Date)
            {
                ModelState.AddModelError("FromDate", "From Date should be smaller than To Date");
            }
            FinancialYear dbFinancialYear = DDService.GetFinancialYear().Where(aa => aa.PFinancialYearID == lvapplication.FinancialYearID).First();

            if (lvapplication.ToDate >= dbFinancialYear.FYEndDate || lvapplication.ToDate <= dbFinancialYear.FYStartDate)
            {
                ModelState.AddModelError("FromDate", "To Date must lie in selected financial year");
            }
            if (lvapplication.ToDate > AppAssistant.MaxDate)
            {
                ModelState.AddModelError("ToDate", "Date cannot be greater than " + AppAssistant.MaxDate.ToString("dd-MM-yyyy"));
            }
            if (lvapplication.FromDate < AppAssistant.MinDate)
            {
                ModelState.AddModelError("FromDate", "Date cannot be less than " + AppAssistant.MinDate.ToString("dd-MM-yyyy"));
            }

            string _EmpNo = Request.Form["EmpNo"].ToString();
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.OEmpID == _EmpNo).First();
            var RBValue = Request.Form["HalfLvHA"];

            if (_emp.First().LineManagerID == null)
            {
                ModelState.AddModelError("EmpID", "There is no Line Manager associated with your profile. Please contact HR");
            }
            {
                LeavePolicy lvPolicy = new LeavePolicy();
                LeaveType   lvType   = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                if (_emp.Count == 0)
                {
                    ModelState.AddModelError("FromDate", "Emp No not exist");
                }
                else
                {
                    lvapplication.EmpID = _emp.FirstOrDefault().PEmployeeID;
                    lvPolicy            = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());
                    //lvType = db.Att_LeaveType.First(aa => aa.LvTypeID == lvapplication.LeaveTypeID);
                }
                if (lvapplication.IsHalf == false && lvapplication.IsDeducted == false)
                {
                    List <DailyAttendance> att = new List <DailyAttendance>();
                    Expression <Func <DailyAttendance, bool> > SpecificEntries = aa => aa.EmpID == lvapplication.EmpID && aa.AttDate >= lvapplication.FromDate && aa.AttDate <= lvapplication.ToDate;
                    att = DailyAttendanceService.GetIndexSpecific(SpecificEntries);
                    if (att.Count > 0)
                    {
                        foreach (var at in att)
                        {
                            if (at.TimeIn != null || at.TimeOut != null)
                            {
                                ModelState.AddModelError("LeaveTypeID", "This employee has attendance for Specific day, Please clear his attendance first to proceed further");
                            }
                        }
                    }
                }
                // CL cannot be taken after next to AL consective day
                float noofDays = LeaveApplicationService.CalculateNoOfDays(lvapplication, lvType, lvPolicy);
                if (lvapplication.LeaveTypeID == 2)
                {
                    if (LeaveApplicationService.CheckForALConsectiveDay(lvapplication))
                    {
                        ModelState.AddModelError("FromDate", "You have applied AL leave for previous date");
                    }
                }
                // Check for Minimum Days of Attachment of Sick Leave
                if (lvapplication.LeaveTypeID == 3)
                {
                    if (noofDays < lvPolicy.MinimumDays)
                    {
                        ModelState.AddModelError("LeaveTypeID", "Cannot Apply SL for Less than" + lvPolicy.MinimumDays.ToString() + " days");
                    }
                }
                //if (LeaveForHoliday(lvapplication))
                //{
                //    ModelState.AddModelError("LeaveTypeID", "This employee has Rest Or GZ for specific Day");
                //}
                //if (!CheckForLvTypeHasLvPolicyForEmp(_emp, lvType))
                //{
                //    ModelState.AddModelError("LeaveTypeID", "This employee does not have Leave Policy, Please add Leave Policy first");
                //}
                //if (!DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
                //    ModelState.AddModelError("FromDate", "Payroll Period is Closed for this date");
                Expression <Func <Shift, bool> > SpecificEntries97 = c => c.PShiftID == employee.ShiftID;
                Shift shifts = ShiftService.GetIndexSpecific(SpecificEntries97).First();
                if (shifts.GZDays == true)
                {
                    List <Holiday> holiday = DDService.GetHolidays().Where(aa => aa.HolidayDate == lvapplication.FromDate).ToList();
                    if (holiday.Count > 0)
                    {
                        ModelState.AddModelError("FromDate", "Cannot apply leave of the Gazetted Holiday");
                    }
                }
                Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
                List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();
                if (dbPayrollPeriods.Count() > 0)
                {
                    ModelState.AddModelError("FromDate", "Cannot enter leaves in Closed Payroll Period");
                }
                if (ModelState.IsValid)
                {
                    if (LeaveApplicationService.CheckDuplicateLeave(lvapplication))
                    {
                        // max days

                        float CalenderDays = LeaveApplicationService.CalculateCalenderDays(lvapplication, lvType, lvPolicy);
                        lvapplication.ReturnDate   = LeaveApplicationService.GetReturnDate(lvapplication, lvType, lvPolicy);
                        lvapplication.IsDeducted   = false;
                        lvapplication.NoOfDays     = noofDays;
                        lvapplication.CalenderDays = CalenderDays;
                        int _UserID = LoggedInUser.PUserID;
                        lvapplication.CreatedBy = _UserID;
                        if (lvPolicy.PLeavePolicyID == 0)
                        {
                            ESSPLeaveService.CreateLeave(lvapplication, lvType, LoggedInUser);
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            //check for employee eligible for leave
                            if (AssistantLeave.EmployeeEligbleForLeave(lvPolicy, _emp))
                            {
                                if (lvPolicy.UpdateBalance == true)
                                {
                                    if (LeaveApplicationService.HasLeaveQuota(lvapplication.EmpID, lvPolicy, (int)lvapplication.FinancialYearID))
                                    {
                                        if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                                        {
                                            //if (LeaveApplicationService.CheckForMaxMonthDays(lvapplication, lvPolicy, LvProcessController.GetFinancialYearID(db.PR_FinancialYear.ToList(), lvapplication.FromDate)))
                                            {
                                                lvapplication.LineManagerID = (int)_emp.First().LineManagerID;
                                                ESSPLeaveService.CreateLeave(lvapplication, lvType, LoggedInUser);
                                                ToasterMessages.Add("Leave applied successfully.");
                                                Session["ToasterMessages"] = ToasterMessages;
                                                return(Json(lvapplication.PLeaveAppID, JsonRequestBehavior.AllowGet));
                                            }
                                            //else
                                            //    ModelState.AddModelError("FromDate", "Leave Monthly Quota Exceeds");
                                        }
                                        else
                                        {
                                            ModelState.AddModelError("LeaveTypeID", "Leave Balance Exceeds, Please check the balance");
                                        }
                                    }
                                    else
                                    {
                                        ModelState.AddModelError("LeaveTypeID", "Leave Quota does not exist");
                                    }
                                }
                                else
                                {
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("LeaveTypeID", "Employee is not eligible for leave");
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("FromDate", "This Employee already has leave in this range of dates");
                    }
                }
                HelperMethod(lvapplication);
                return(PartialView("Create", lvapplication));
            }
        }
コード例 #20
0
        public float CalculateNoOfDays(LeaveApplication lvapplication, LeaveType lvType, LeavePolicy lvPolicy)
        {
            List <Holiday> holidays = new List <Holiday>();

            holidays = DDService.GetHolidays();
            float val = 0;

            if (lvapplication.IsHalf == true)
            {
                val = (float)0.5;
            }
            else
            {
                val = (lvapplication.ToDate - lvapplication.FromDate).Days + 1;
                Expression <Func <Employee, bool> > SpecificEntries = aa => aa.PEmployeeID == lvapplication.EmpID;
                Employee emp   = EmployeeRepo.FindBy(SpecificEntries).FirstOrDefault();
                Shift    shift = emp.Shift;
                Expression <Func <VAT_RosterDetail, bool> > SpecificEntries2 = aa => aa.CriteriaData == emp.CrewID && aa.RosterDate >= lvapplication.FromDate && aa.RosterDate <= lvapplication.ToDate;
                List <VAT_RosterDetail> rosterDetails = RosterDetailRepo.FindBy(SpecificEntries2);
                if ((lvPolicy.CountRestDays != true || lvPolicy.CountGZDays != true) && lvPolicy.PLeavePolicyID != 0)
                {
                    DateTime dts = lvapplication.FromDate;
                    while (dts <= lvapplication.ToDate)
                    {
                        if (rosterDetails.Where(aa => aa.RosterDate == dts).Count() > 0)
                        {
                            VAT_RosterDetail rd = rosterDetails.First(aa => aa.RosterDate == dts);

                            if (holidays.Where(aa => aa.HolidayDate == dts).Count() > 0 && shift.GZDays == true)
                            {
                                if (lvPolicy.CountGZDays == false)
                                {
                                    val = val - 1;
                                }
                            }
                            else
                            {
                                if (rd.WorkMin == 0)
                                {
                                    val = val - 1;
                                }
                            }
                        }
                        else
                        {
                            if (holidays.Where(aa => aa.HolidayDate == dts).Count() > 0 && shift.GZDays == true)
                            {
                                if (lvPolicy.CountGZDays == false)
                                {
                                    val = val - 1;
                                }
                            }
                            else
                            {
                                if (CurrentDayNotRest(shift, dts))
                                {
                                    val = val - 1;
                                }
                            }
                        }
                        dts = dts.AddDays(1);
                    }
                }
            }
            return(val);
        }
コード例 #21
0
 public IActionResult UpdateLeavePolicy([FromBody] LeavePolicy model)
 {
     LeavePolicy_repo.Update(model);
     return(new OkObjectResult(new { LeavePolicyID = model.LeavePolicyId }));
 }
コード例 #22
0
        /// <summary>
        /// Get the leave type and their respective Policies.
        /// </summary>
        /// <param name="_emp"></param>
        /// <param name="LeaveType"></param>
        /// <param name="leavePolicies"></param>
        /// <returns></returns>
        public static LeavePolicy GetEmployeeLeavePolicyID(List <VHR_EmployeeProfile> _emp, byte LeaveType, List <LeavePolicy> leavePolicies)
        {
            try
            {
                short       empLvPolivyID = 0;
                LeavePolicy lvPolicy      = new LeavePolicy();
                //check emp leave type
                switch (LeaveType)
                {
                case 2:    ///1	Casual
                    if (_emp.FirstOrDefault().CLPolicyID != null)
                    {
                        empLvPolivyID = (short)_emp.FirstOrDefault().CLPolicyID;
                        lvPolicy      = leavePolicies.FirstOrDefault(aa => aa.PLeavePolicyID == empLvPolivyID);
                    }
                    else
                    {
                        lvPolicy = GetNoPolicy();
                    }
                    break;

                case 3:    //2	Sick
                    if (_emp.FirstOrDefault().SLPolicyID != null)
                    {
                        empLvPolivyID = (short)_emp.FirstOrDefault().SLPolicyID;
                        lvPolicy      = leavePolicies.FirstOrDefault(aa => aa.PLeavePolicyID == empLvPolivyID);
                    }
                    else
                    {
                        lvPolicy = GetNoPolicy();
                    }
                    break;

                case 1:    //3	Annual
                    if (_emp.FirstOrDefault().ALPolicyID != null)
                    {
                        empLvPolivyID = (short)_emp.FirstOrDefault().ALPolicyID;
                        lvPolicy      = leavePolicies.FirstOrDefault(aa => aa.PLeavePolicyID == empLvPolivyID);
                    }
                    else
                    {
                        lvPolicy = GetNoPolicy();
                    }
                    break;

                case 4:    //8	StudyLeave
                    if (_emp.FirstOrDefault().STDLPolicyID != null)
                    {
                        empLvPolivyID = (short)_emp.FirstOrDefault().STDLPolicyID;
                        lvPolicy      = leavePolicies.FirstOrDefault(aa => aa.PLeavePolicyID == empLvPolivyID);
                    }
                    else
                    {
                        lvPolicy = GetNoPolicy();
                    }
                    break;

                case 5:    //8	LWOP
                    if (leavePolicies.Where(aa => aa.LeaveTypeID == 5).Count() > 0)
                    {
                        lvPolicy = leavePolicies.FirstOrDefault(aa => aa.LeaveTypeID == 5);
                    }
                    else
                    {
                        lvPolicy = GetNoPolicy();
                    }
                    break;

                default:    //

                    lvPolicy = GetNoPolicy();
                    break;
                }
                return(lvPolicy);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #23
0
        public float CalculateCalenderDays(LeaveApplication lvapplication, LeaveType lvType, LeavePolicy lvPolicy)
        {
            float val = 0;

            if (lvapplication.IsHalf == true)
            {
                val = (float)0.5;
            }
            else
            {
                val = (lvapplication.ToDate - lvapplication.FromDate).Days + 1;
            }
            return(val);
        }
コード例 #24
0
        public DateTime?GetReturnDate(LeaveApplication lvapplication, LeaveType lvType, LeavePolicy lvPolicy)
        {
            DateTime returnDate = lvapplication.ToDate.AddDays(1);
            DateTime EndDate    = lvapplication.ToDate.AddDays(7);

            if (lvapplication.IsHalf == true)
            {
                return(returnDate);
            }
            else
            {
                Expression <Func <Employee, bool> > SpecificEntries = aa => aa.PEmployeeID == lvapplication.EmpID;
                Employee emp = EmployeeRepo.FindBy(SpecificEntries).First();
                Shift    ss  = emp.Shift;
                Expression <Func <VAT_RosterDetail, bool> > SpecificEntries2 = aa => aa.CriteriaData == emp.CrewID && aa.RosterDate >= lvapplication.FromDate && aa.RosterDate <= EndDate;
                List <VAT_RosterDetail> rosterDetails = RosterDetailRepo.FindBy(SpecificEntries2);
                if (lvPolicy.CountRestDays != true)
                {
                    DateTime dts = returnDate;
                    while (true)
                    {
                        if (rosterDetails.Where(aa => aa.RosterDate == dts).Count() > 0)
                        {
                            VAT_RosterDetail rd = rosterDetails.First(aa => aa.RosterDate == dts);
                            if (rd.WorkMin > 0)
                            {
                                return(dts);
                            }
                        }
                        else
                        {
                            if (CurrentDayNotRest(ss, dts) == false)
                            {
                                return(dts);
                            }
                        }
                        dts = dts.AddDays(1);
                    }
                }
                return(returnDate);
            }
        }
コード例 #25
0
 public ActionResult Delete(LeavePolicy obj)
 {
     LeavePolicyService.PostDelete(obj);
     return(Json("OK", JsonRequestBehavior.AllowGet));
 }
コード例 #26
0
        public void ApprovalCode(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, LeaveApplication lvapplication, LeavePolicy lvPolicy)
        {
            if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
            {
                //Changes Leave Stage ID to "A" (Approved).
                lvapplication.LeaveStageID = "A";
                //Gets the leave Type through generic service.
                LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                LeaveApplicationRepository.Edit(lvapplication);
                LeaveApplicationRepository.Save();
                UnitOfWork.Commit();
                //Adds leave to leave data frim where its impact is generated on the reports.
                LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                // Add notification to the Employee that leave has been approved.
                DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                           Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                //Add entry in the flow table
                SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                        ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                // Disable Notification of the pending Leave.
                int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                DDService.DeleteNotification(SpecificEntries);

                // Disable Notification of the pending Leave.
                int notiTypeID2 = Convert.ToInt32(NTLeaveEnum.LeaveRecommend);
                Expression <Func <Notification, bool> > SpecificEntries2 = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID2) && c.PID == lvapplication.PLeaveAppID);
                DDService.DeleteNotification(SpecificEntries2);
            }
        }
コード例 #27
0
 private void HelperMethod(LeavePolicy obj)
 {
     ViewBag.LeaveTypeID = new SelectList(DDService.GetLeaveType().ToList().OrderBy(aa => aa.LeaveTypeName).ToList(), "PLeaveTypeID", "LeaveTypeName", obj.LeaveTypeID);
 }
コード例 #28
0
 private void ReadFromRadioButton(LeavePolicy obj)
 {
     #region -- Radio Buttons--
     // Adjust Activation of Leave Radio Button
     string radioActivationValue = "";
     var    ActivationValue      = ValueProvider.GetValue("activation");
     if (ActivationValue != null)
     {
         radioActivationValue = ActivationValue.AttemptedValue;
     }
     if (radioActivationValue == "ActiveAfterJoinDate")
     {
         obj.ActiveAfterJoinDate   = true;
         obj.ActiveAfterProbation  = false;
         obj.ActiveAfterCustomDays = false;
         obj.CustomDays            = 0;
     }
     if (radioActivationValue == "ActiveAfterProbation")
     {
         obj.ActiveAfterProbation  = true;
         obj.ActiveAfterJoinDate   = false;
         obj.ActiveAfterCustomDays = false;
         obj.CustomDays            = 0;
     }
     if (radioActivationValue == "ActiveAfterCustomDays")
     {
         obj.ActiveAfterCustomDays = true;
         obj.ActiveAfterProbation  = false;
         obj.ActiveAfterJoinDate   = false;
     }
     // Adjust Payable of Leave Radio Button
     string radioPayableValue = "";
     var    PayableValue      = ValueProvider.GetValue("payable");
     if (ActivationValue != null)
     {
         radioPayableValue = PayableValue.AttemptedValue;
     }
     if (radioPayableValue == "WithFullPay")
     {
         obj.WithFullPay = true;
     }
     else
     {
         obj.WithFullPay = false;
     }
     if (radioPayableValue == "WithHalfPay")
     {
         obj.WithHalfPay = true;
     }
     else
     {
         obj.WithHalfPay = false;
     }
     if (radioPayableValue == "WithOutPay")
     {
         obj.WithOutPay = true;
     }
     else
     {
         obj.WithOutPay = false;
     }
     #endregion
 }
コード例 #29
0
        public bool CheckLeaveBalance(LeaveApplication _lvapp, LeavePolicy LeaveType)
        {
            bool    balance = false;
            decimal RemainingLeaves;

            if (LeaveType.UpdateBalance == true)
            {
                //Get the list of leave quota year in which balance of the leave is present .in the specific Financial year
                List <LeaveQuotaYear> _lvConsumed = new List <LeaveQuotaYear>();
                Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = aa => aa.EmployeeID == _lvapp.EmpID && aa.FinancialYearID == _lvapp.FinancialYearID && aa.LeaveTypeID == _lvapp.LeaveTypeID;
                _lvConsumed = LeaveQuotaYearRepo.FindBy(SpecificEntries);
                if (_lvConsumed.Count > 0)
                {
                    if (_lvapp.LeaveTypeID == 1)
                    {
                        if (_lvapp.IsAccum == true)
                        {
                            RemainingLeaves = (decimal)_lvConsumed.FirstOrDefault().CFRemaining;
                            if ((RemainingLeaves - Convert.ToDecimal(_lvapp.NoOfDays)) >= 0)
                            {
                                balance = true;
                            }
                            else
                            {
                                balance = false;
                            }
                        }
                        else
                        {
                            RemainingLeaves = (decimal)_lvConsumed.FirstOrDefault().GrandRemaining;
                            if ((RemainingLeaves - Convert.ToDecimal(_lvapp.NoOfDays)) >= 0)
                            {
                                balance = true;
                            }
                            else
                            {
                                balance = false;
                            }
                        }
                    }
                    else
                    {
                        RemainingLeaves = (decimal)_lvConsumed.FirstOrDefault().GrandRemaining;
                        if ((RemainingLeaves - Convert.ToDecimal(_lvapp.NoOfDays)) >= 0)
                        {
                            balance = true;
                        }
                        else
                        {
                            balance = false;
                        }
                    }
                }
                else
                {
                    balance = false;
                }
            }
            else
            {
                balance = true;
            }

            return(balance);
        }