示例#1
0
        public void ShowObject(object keyValue)
        {
            var eid  = Convert.ToInt32(keyValue);
            var empl = _proxy.Context.Employees.FirstOrDefault(e => e.EmployeeId == eid);

            if (empl != null)
            {
                _employee = empl;
                employeeBindingSource.DataSource =
                    _proxy.Context.EmployeeInfoes.FirstOrDefault(ei => ei.EmployeeId == eid);

                prevDepartementBindingSource.DataSource = _proxy.Context.Organizations.ToList();
                prevJobBindingSource.DataSource         = _proxy.Context.Jobs.ToList();

                prevLocationLookUpEdit.EditValue = empl.NodeId;
                prevJobTitleLookUpEdit.EditValue = empl.JobId;

                newDepartementBindingSource.DataSource = _proxy.Context.Organizations.ToList();
                newTitleBindingSource.DataSource       = _proxy.Context.Jobs.ToList();

                var pt = new List <PromotionType>();
                pt.Add(new PromotionType("Promotion", 1));
                pt.Add(new PromotionType("Demotion", 2));
                promoTypeBindingSource.DataSource = pt;
                _promotion = new EmployeePromotion()
                {
                    IsNew = true, EmployeeId = eid, NewTitle = empl.JobId, NewNode = empl.NodeId, Type = 1
                };
                promotionBindingSource.DataSource = _promotion;
            }
        }
示例#2
0
        public async Task <IActionResult> AddPromotion(EmployeePromotion item)
        {
            var model = await _context.Employments.SingleOrDefaultAsync(b => b.Id == item.EmploymentId);

            if (item.JobGradeId != model.JobGradeId)
            {
                item.PromotionTypeId = _lookup.GetLookupItems <PromotionType>().SingleOrDefault(b => b.SysCode == "PROMO").Id;
            }
            else
            {
                item.PromotionTypeId = _lookup.GetLookupItems <PromotionType>().SingleOrDefault(b => b.SysCode == "SAL_INCR").Id;
            }
            if (item.SalaryIncreaseValue != 0)
            {
                item.BasicSalary = model.BasicSalary + (item.IsIncreasePercentage ? item.BasicSalary * item.SalaryIncreaseValue / 100 : item.SalaryIncreaseValue);
            }
            item.CreatedDate = DateTime.Now.Date;
            item.LastUpdated = DateTime.Now.Date;
            item.UpdatedBy   = "user";
            item.IsActive    = true;
            _context.EmployeePromotions.Add(item);
            await _context.SaveChangesAsync();

            return(RedirectToAction("PromotionsList", new { id = model.EmployeeId }));
        }
示例#3
0
        public async Task <IActionResult> AddEmployment(Employment item, long oldEmploymentId)
        {
            item.IsActive = true;
            _context.Employments.Add(item);

            //deactivate old employment
            _context.Employments.SingleOrDefault(b => b.Id == oldEmploymentId).IsActive = false;

            //add transfer type promotion
            EmployeePromotion promo = new EmployeePromotion();

            promo.EmploymentId      = item.Id;
            promo.PromotionTypeId   = _lookup.GetLookupItems <PromotionType>().SingleOrDefault(b => b.SysCode == "TRANS").Id;
            promo.BasicSalary       = item.BasicSalary;
            promo.CreatedDate       = DateTime.Now.Date;
            promo.Details           = item.Details;
            promo.EffectiveFromDate = item.FromDate;
            promo.IsActive          = true;
            promo.IsApproved        = false;
            promo.JobGradeId        = item.JobGradeId;
            promo.LastUpdated       = DateTime.Now.Date;
            promo.SalaryStepId      = item.SalaryStepId;
            promo.UpdatedBy         = "user";
            _context.EmployeePromotions.Add(promo);

            await _context.SaveChangesAsync();

            return(RedirectToAction("EmploymentsList", new { id = item.EmployeeId }));
        }
示例#4
0
        public virtual IEnumerable <EmployeePromotion> GetEmployeePromotionView()
        {
            IEnumerable <EmployeePromotion> resultBasic = from emp in new RepositoryFactory().Create <Employee>().GetAll()
                                                          join empSal in new RepositoryFactory().Create <EmployeeSalary>().GetAll() on emp.EmployeeId equals empSal.EmployeeId
                                                          join salRank in new RepositoryFactory().Create <SalaryRank>().GetAll() on empSal.SalaryRankId equals salRank.SalaryRankId
                                                          select new EmployeePromotion
            {
                EmployeeId   = emp.EmployeeId,
                EmployeeName = emp.EmployeeName,
                SalaryRankId = empSal.SalaryRankId,
                BasicSalary  = salRank.RankValue,
                RankName     = salRank.RankName
            };

            IEnumerable <EmployeePerformance> performance = GetAllEmployeePerformance();
            List <EmployeePromotion>          finalResult = new List <EmployeePromotion>();

            var joinedList = from res in resultBasic
                             join perf in performance on res.EmployeeId equals perf.EmployeeId
                             select new
            {
                EmployeeId     = res.EmployeeId,
                EmployeeName   = res.EmployeeName,
                SalaryRankId   = res.SalaryRankId,
                BasicSalary    = res.BasicSalary,
                RankName       = res.RankName,
                AggregateScore = perf.AggregateScore
            };

            foreach (var item in joinedList)
            {
                EmployeePromotion empPromo = new EmployeePromotion()
                {
                    EmployeeId   = item.EmployeeId,
                    EmployeeName = item.EmployeeName,
                    SalaryRankId = item.SalaryRankId,
                    BasicSalary  = item.BasicSalary,
                    RankName     = item.RankName
                };
                if (item.AggregateScore > 70)
                {
                    empPromo.RecommendationStatus = 1;
                }
                else if (item.AggregateScore < 30)
                {
                    empPromo.RecommendationStatus = 0;
                }
                else
                {
                    empPromo.RecommendationStatus = -1;
                }

                finalResult.Add(empPromo);
            }


            return(finalResult);
        }
示例#5
0
        public virtual IEnumerable <EmployeePromotion> GetEmployeePromotionView()
        {
            IRepository <SalaryRank>        salRankRepo     = new RepositoryFactory().Create <SalaryRank>();
            IEnumerable <SalaryRank>        salaryRanks     = new RepositoryFactory().Create <SalaryRank>().GetAll();
            IEnumerable <RankHierarchy>     rankHierarchies = new RepositoryFactory().Create <RankHierarchy>().GetAll();
            IEnumerable <EmployeePromotion> resultBasic     = from emp in new RepositoryFactory().Create <Employee>().GetAll()
                                                              join empSal in new RepositoryFactory().Create <EmployeeSalary>().GetAll() on emp.EmployeeId equals empSal.EmployeeId
                                                              join salRank in salaryRanks on empSal.SalaryRankId equals salRank.SalaryRankId
                                                              select new EmployeePromotion
            {
                EmployeeId   = emp.EmployeeId,
                EmployeeName = emp.EmployeeName,
                SalaryRankId = empSal.SalaryRankId,
                BasicSalary  = salRank.RankValue,
                RankName     = salRank.RankName
            };

            IEnumerable <EmployeePerformance> performance = GetAllEmployeePerformance();
            List <EmployeePromotion>          finalResult = new List <EmployeePromotion>();

            var joinedList = from res in resultBasic
                             join perf in performance on res.EmployeeId equals perf.EmployeeId
                             select new
            {
                EmployeeId     = res.EmployeeId,
                EmployeeName   = res.EmployeeName,
                SalaryRankId   = res.SalaryRankId,
                BasicSalary    = res.BasicSalary,
                RankName       = res.RankName,
                AggregateScore = perf.AggregateScore
            };

            foreach (var item in joinedList)
            {
                //Output.Write("Employee name: " + item.EmployeeName);
                RankHierarchy rankHierarchy = new RankHierarchy();
                SalaryRank    salaryRank;
                try
                {
                    rankHierarchy = rankHierarchies.First(e => e.SalaryRankId == item.SalaryRankId);
                    //Output.Write("Rank hierarchy found");
                }catch (Exception e)
                {
                    //Output.Write(e);
                }

                if (rankHierarchy.SalaryRankId == 0)
                {
                    salaryRank = null;
                }
                else
                {
                    salaryRank = salRankRepo.Get(rankHierarchy.NextSalaryRankId);
                }

                EmployeePromotion empPromo = new EmployeePromotion()
                {
                    EmployeeId   = item.EmployeeId,
                    EmployeeName = item.EmployeeName,
                    SalaryRankId = item.SalaryRankId,
                    BasicSalary  = item.BasicSalary,
                    RankName     = item.RankName
                };
                if (salaryRank == null)
                {
                    empPromo.promotionAvailable   = false;
                    empPromo.RecommendationStatus = 0;
                    //Output.Write("Promotion availability: " + empPromo.promotionAvailable);
                }
                else
                {
                    empPromo.promotionAvailable = true;

                    if (item.AggregateScore > 70)
                    {
                        empPromo.RecommendationStatus = 1;
                    }
                    else if (item.AggregateScore < 30)
                    {
                        empPromo.RecommendationStatus = 0;
                    }
                    else
                    {
                        empPromo.RecommendationStatus = -1;
                    }

                    empPromo.NextSalaryRankId = salaryRank.SalaryRankId;
                    empPromo.NextRankName     = salaryRank.RankName;
                    empPromo.NextBasicSalary  = salaryRank.RankValue;
                    //Output.Write("Promotion availability: " + empPromo.promotionAvailable);
                }



                finalResult.Add(empPromo);
            }


            return(finalResult);
        }
示例#6
0
        //void to create employee from AddEmployee or HireCandidate actions
        private async void CreateEmployee(Employee item, long orgUnitId, int employmentTypeId, DateTime?dateInPosition, long?positionId, int?jobGradeId, int?salaryStepId, int?salaryScaleTypeId, int basicSalary = 0, bool isHead = false, bool isProbation = false)
        {
            if (string.IsNullOrEmpty(item.EmpUid))
            {
                item.EmpUid = (int.Parse(_context.Employees.Max(b => b.EmpUid)) + 1).ToString();
            }
            item.IsActive    = true;
            item.LastUpdated = DateTime.Now.Date;
            item.UpdatedBy   = "user";
            _context.Employees.Add(item);



            Employment pos = new Employment();

            pos.OrgUnitId  = orgUnitId;
            pos.EmployeeId = item.Id;
            pos.IsHead     = isHead;
            pos.PositionId = positionId;
            if (positionId.HasValue)
            {
                var p = await _context.Positions.SingleOrDefaultAsync(b => b.Id == positionId);

                pos.IsAttendRequired  = p.IsAttendRequired;
                pos.IsOverTimeAllowed = p.IsOverTimeAllowed;
            }
            pos.EmploymentTypeId  = employmentTypeId;
            pos.JobGradeId        = jobGradeId;
            pos.SalaryStepId      = salaryStepId;
            pos.SalaryScaleTypeId = salaryScaleTypeId;
            pos.BasicSalary       = basicSalary;
            pos.FromDate          = dateInPosition.HasValue ? dateInPosition.Value : DateTime.Now.Date;
            pos.IsActive          = true;
            pos.IsProbation       = isProbation;
            _context.Employments.Add(pos);

            //add initial hiring as promotion
            EmployeePromotion prom = new EmployeePromotion();

            prom.EmploymentId      = pos.Id;
            prom.PromotionTypeId   = _lookup.GetLookupItems <PromotionType>().SingleOrDefault(b => b.SysCode == "INIT").Id;
            prom.JobGradeId        = jobGradeId;
            prom.SalaryStepId      = salaryStepId;
            prom.BasicSalary       = basicSalary;
            prom.CreatedDate       = DateTime.Now.Date;
            prom.EffectiveFromDate = dateInPosition.HasValue ? dateInPosition.Value : DateTime.Now.Date;
            prom.IsApproved        = true;
            prom.LastUpdated       = DateTime.Now.Date;
            prom.UpdatedBy         = "user";
            _context.EmployeePromotions.Add(prom);

            //add leave entitlements
            int annualTypeId = _lookup.GetLookupItems <LeaveType>().SingleOrDefault(b => b.SysCode == "ANNUAL").Id;
            int sickTypeId   = _lookup.GetLookupItems <LeaveType>().SingleOrDefault(b => b.SysCode == "SICK").Id;
            int entitle      = 0;

            if (jobGradeId.HasValue)
            {
                int grpId = _context.JobGrades.SingleOrDefault(b => b.Id == jobGradeId).Id;
                var lv    = _context.LeavePolicies.SingleOrDefault(b => b.LeaveTypeId == annualTypeId && (b.JobGradeId == jobGradeId || b.GradeGroupId == grpId));
                if (lv != null)
                {
                    entitle = lv.TotalDays;
                }
            }
            _context.EmployeeLeaveBalances.Add(new EmployeeLeaveBalance {
                EmployeeId = item.Id, LeaveTypeId = annualTypeId, AnnualEntitlement = entitle
            });
            entitle = 0;
            if (jobGradeId.HasValue)
            {
                int grpId = _context.JobGrades.SingleOrDefault(b => b.Id == jobGradeId).Id;
                var lv    = _context.LeavePolicies.SingleOrDefault(b => b.LeaveTypeId == sickTypeId && (b.JobGradeId == jobGradeId || b.GradeGroupId == grpId));
                if (lv != null)
                {
                    entitle = lv.TotalDays;
                }
            }
            _context.EmployeeLeaveBalances.Add(new EmployeeLeaveBalance {
                EmployeeId = item.Id, LeaveTypeId = sickTypeId, AnnualEntitlement = entitle
            });

            //update vacancies
            if (isHead)
            {
                _context.OrgUnits.SingleOrDefault(b => b.Id == orgUnitId).IsVacant = false;
            }
            else
            {
                var p = await _context.Positions.SingleOrDefaultAsync(b => b.Id == positionId);

                if (p.TotalVacant > 0)
                {
                    p.TotalVacant--;
                }
            }
            await _context.SaveChangesAsync();
        }