Esempio n. 1
0
        public ActionResult Create4(VMLeaveQuota vmLeaveQuota, int?[] SelectedEmpIds)
        {
            List <VMLeaveQuotaChild> vmLeaveQuotaChildEntries = new List <VMLeaveQuotaChild>();

            foreach (var empID in SelectedEmpIds)
            {
                VMLeaveQuotaChild vmLeaveQuotaChild = new VMLeaveQuotaChild();
                string            AL    = Request.Form["AL-" + empID.Value.ToString()].ToString();
                string            CL    = Request.Form["CL-" + empID.Value.ToString()].ToString();
                string            SL    = Request.Form["SL-" + empID.Value.ToString()].ToString();
                string            STDL  = Request.Form["STDL-" + empID.Value.ToString()].ToString();
                string            ALCop = Request.Form["ALCop-" + empID.Value.ToString()].ToString();
                string            ALCF  = Request.Form["ALCF-" + empID.Value.ToString()].ToString();
                vmLeaveQuotaChild.EmpID         = (int)empID;
                vmLeaveQuotaChild.AL            = (float)Convert.ToDouble(AL);
                vmLeaveQuotaChild.CL            = (float)Convert.ToDouble(CL);
                vmLeaveQuotaChild.SL            = (float)Convert.ToDouble(SL);
                vmLeaveQuotaChild.STDL          = (float)Convert.ToDouble(STDL);
                vmLeaveQuotaChild.CollapseLeave = (float)Convert.ToDouble(ALCop);
                vmLeaveQuotaChild.CarryForward  = (float)Convert.ToDouble(ALCF);

                vmLeaveQuotaChildEntries.Add(vmLeaveQuotaChild);
            }
            vmLeaveQuota.LeaveQuotaChild = vmLeaveQuotaChildEntries.ToList();
            VMLeaveQuota vm = LeaveQuotaService.GetCreate4(vmLeaveQuota);

            if (vm.ErrorMessages.Count == 0)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("Create3", vm));
            }
        }
        public ActionResult Create3(VMLeaveQuotaSelection es, int?[] SelectedEmpIds)
        {
            VMLeaveQuota vmLeaveQuota = new VMLeaveQuota();

            vmLeaveQuota = LeaveQuotaService.GetCreate3(es, SelectedEmpIds, vmLeaveQuota);
            return(View(vmLeaveQuota));
        }
Esempio n. 3
0
        public VMLeaveQuota GetCreate4(VMLeaveQuota vm)
        {
            List <VMLeaveQuotaChild> LeaveQuotaChildCompleted = new List <VMLeaveQuotaChild>();

            vm.ErrorMessages = new List <string>();
            if (vm.LeaveQuotaChild.Count > 0)
            {
                foreach (var item in vm.LeaveQuotaChild)
                {
                    string errorMessage = "";
                    if (!SaveALLeaveQuotaYearEntry(item.AL, 1, item.EmpID, vm.FinancialYearID, item.CarryForward) == true) // Save AL in DB
                    {
                        errorMessage = errorMessage + "AL not Created";
                    }
                    if (!SaveLeaveQuotaYearEntry(item.CL, 2, item.EmpID, vm.FinancialYearID)) // Save CL in DB
                    {
                        errorMessage = errorMessage + "CL not Created";
                    }
                    if (!SaveLeaveQuotaYearEntry(item.SL, 3, item.EmpID, vm.FinancialYearID)) // Save SL in DB
                    {
                        errorMessage = errorMessage + "SL not Created";
                    }
                    if (!SaveLeaveQuotaYearEntry(item.EAL, 11, item.EmpID, vm.FinancialYearID)) // Save SL in DB
                    {
                        errorMessage = errorMessage + "EAL not Created";
                    }
                    if (!SaveLeaveQuotaYearEntry(item.CME, 12, item.EmpID, vm.FinancialYearID)) // Save SL in DB
                    {
                        errorMessage = errorMessage + "CME not Created";
                    }
                    if (errorMessage != "")
                    {
                        vm.ErrorMessages.Add("Employee No: " + item.EmpNo + " , " + errorMessage);
                    }
                    else
                    {
                        LeaveQuotaChildCompleted.Add(item);
                    }
                }
                foreach (var item in LeaveQuotaChildCompleted)
                {
                    vm.LeaveQuotaChild.Remove(item);
                }
                return(vm);
            }
            else
            {
                return(vm);
            }
        }
Esempio n. 4
0
        public VMLeaveQuota GetCreate3(VMLeaveQuotaSelection es, int?[] SelectedEmployeeIds, VMLeaveQuota vmLeaveQuota)
        {
            List <VMLeaveQuotaChild>   vmLeaveQuotaChildList = new List <VMLeaveQuotaChild>();
            List <VHR_EmployeeProfile> employees             = DDService.GetEmployeeInfo();                                                         // Get All Employees from database
            List <LeavePolicy>         leavePolicyList       = DDService.GetLeavePolicy();                                                          // Get all leave policies
            FinancialYear         financialYear              = DDService.GetFinancialYear().First(aa => aa.PFinancialYearID == es.FinancialYearID); // Get selected financial year
            List <FinancialYear>  financialYearCloseList     = DDService.GetFinancialYear().Where(aa => aa.FYStatus == false).OrderByDescending(aa => aa.FYEndDate).ToList();
            List <LeaveQuotaYear> leaveQuotaPreviousYearList = new List <LeaveQuotaYear>();

            // Get Old Financial Year
            if (financialYearCloseList.Count > 0)
            {
                int LastFinYearID = financialYearCloseList.FirstOrDefault().PFinancialYearID;
                Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = c => c.FinancialYearID == LastFinYearID && c.LeaveTypeID == 1;
                leaveQuotaPreviousYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries);// Get all Leave quota Balances for specific financial year
            }
            Expression <Func <LeaveQuotaYear, bool> > SpecificEntries2 = c => c.FinancialYearID == es.FinancialYearID;
            List <LeaveQuotaYear> leaveQuotaYearList = LeaveQuotaYearReporsitory.FindBy(SpecificEntries2);// Get all Leave quota Balances for specific financial year

            foreach (int empid in SelectedEmployeeIds)
            {
                if (leaveQuotaYearList.Where(aa => aa.EmployeeID == empid).Count() == 0)
                {
                    VMLeaveQuotaChild   vmLeaveQuotaChild = new VMLeaveQuotaChild();
                    VHR_EmployeeProfile employee          = employees.First(aa => aa.PEmployeeID == empid);// Get Specific Employee
                    float ALDays   = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.ALPolicyID).ToList(), employee, financialYear);
                    float CLDays   = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.CLPolicyID).ToList(), employee, financialYear);
                    float SLDays   = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.SLPolicyID).ToList(), employee, financialYear);
                    float STDLDays = GetTotalDays(leavePolicyList.Where(aa => aa.PLeavePolicyID == employee.STDLPolicyID).ToList(), employee, financialYear);
                    vmLeaveQuotaChild.EmpID             = employee.PEmployeeID;
                    vmLeaveQuotaChild.EmpNo             = employee.OEmpID;
                    vmLeaveQuotaChild.EmployeeName      = employee.EmployeeName;
                    vmLeaveQuotaChild.JobTitleName      = employee.JobTitleName;
                    vmLeaveQuotaChild.FinancialYearID   = financialYear.PFinancialYearID;
                    vmLeaveQuotaChild.FinancialYearName = financialYear.FYName;
                    if (employee.DOJ != null)
                    {
                        vmLeaveQuotaChild.DOJ = employee.DOJ.Value.ToString("dd-MMM-yyyy");
                    }
                    vmLeaveQuotaChild.AL   = ALDays;
                    vmLeaveQuotaChild.CL   = CLDays;
                    vmLeaveQuotaChild.SL   = SLDays;
                    vmLeaveQuotaChild.STDL = STDLDays;
                    // Get LeaveBalance for Previous Year
                    if (leaveQuotaPreviousYearList.Where(aa => aa.EmployeeID == employee.PEmployeeID).Count() > 0)
                    {
                        vmLeaveQuotaChild.CollapseLeave = 0;
                        vmLeaveQuotaChild.ALBalance     = GetALLeaveBalance(leaveQuotaPreviousYearList.Where(aa => aa.EmployeeID == employee.PEmployeeID).ToList());
                        vmLeaveQuotaChild.CarryForward  = vmLeaveQuotaChild.ALBalance - vmLeaveQuotaChild.CollapseLeave;
                    }
                    else
                    {
                        vmLeaveQuotaChild.CarryForward  = 0;
                        vmLeaveQuotaChild.CollapseLeave = 0;
                        vmLeaveQuotaChild.ALBalance     = 0;
                    }
                    vmLeaveQuotaChildList.Add(vmLeaveQuotaChild);
                }
            }
            vmLeaveQuota.FinancialYearID   = financialYear.PFinancialYearID;
            vmLeaveQuota.FinancialYearName = financialYear.FYName;
            vmLeaveQuota.LeaveQuotaChild   = vmLeaveQuotaChildList;
            return(vmLeaveQuota);
        }