protected override void OnSaving() { if (string.IsNullOrEmpty(this.姓名)) { throw new Exception("姓名不能为空"); } if (string.IsNullOrEmpty(this.员工编号)) { throw new Exception("员工编号不能为空."); } if (this.年度 < 2018 || this.年度 > DateTime.Today.Year) { throw new Exception("年度不正确"); } ManagementTraineeAbility found = GetManagementTraineeAbility(this.员工编号, this.年度); if (found != null && found.标识 != this.标识) { throw new Exception("已经存在该员工的" + 年度 + "年度评定,不能重复创建"); } else { base.OnSaving(); } }
//更新到正式表 public void UpdateToFormalTable() { if (this.内容不同的字段.Count > 0) { return; } ManagementTraineeAbility m = ManagementTraineeAbility.GetManagementTraineeAbility(员工编号, 年度); if (m == null) { m = new ManagementTraineeAbility(); m.标识 = Guid.NewGuid(); m.创建时间 = DateTime.Now; } this.CopyWatchMember(m); m.序号 = this.序号; m.更新时间 = DateTime.Now; m.Save(); //更新生效标记 if (!this.已生效) { this.生效时间 = DateTime.Now; this.Save(); ManagementTraineeAbilityInput opposite = 另一人录入的记录; opposite.生效时间 = DateTime.Now; opposite.Save(); } }
public ManagementTraineeYearlySalaryCalulator(ManagementTraineeInfo trainee, int year) { List <ManagementTraineeSalary> list = ManagementTraineeSalary.GetQuarterSalaryList(trainee.员工编号, year); 一季度 = list.Find(a => a.季度 == 1); 二季度 = list.Find(a => a.季度 == 2); 季度 = list.Find(a => a.季度 == 3); 四季度 = list.Find(a => a.季度 == 4); 员工编号 = trainee.员工编号; 年度 = year; 管培生信息 = trainee; 起薪 = trainee.年薪; if (起薪 > 0) { 起薪_万元 = 起薪.ToString("#0.#"); } 姓名 = 管培生信息.姓名; 公司 = 管培生信息.员工信息.公司名称; 专业属性 = 管培生信息.专业属性; 岗位类型 = 管培生信息.岗位类型; 年度评定 = ManagementTraineeAbility.GetManagementTraineeAbility(员工编号, year); if (年度评定 != null) { 评定结果 = 年度评定.能力级别; } }
public static ManagementTraineeAbility CreateOrUpdateAbility(string empNo, int year, string name, string level) { ManagementTraineeAbility item = GetManagementTraineeAbility(empNo, year); if (item == null) { item = new ManagementTraineeAbility(); item.标识 = Guid.NewGuid(); item.员工编号 = empNo; item.姓名 = name; item.年度 = year; item.创建时间 = DateTime.Now; } item.能力级别 = level; item.Save(); return(item); }
public static List <ManagementTraineePayStandard> CreatePayStandards(string emplid, int year) { EmployeeInfo employee = EmployeeInfo.GetFromCache(emplid); if (employee == null) { return(null); } //获取管培生基本信息 ManagementTraineeInfo traineeInfo = ManagementTraineeInfo.GetManagementTraineeInfo(emplid); if (traineeInfo == null) { return(null); } DateTime start = new DateTime(year, 7, 1); ManagementTraineePayStandard first = CreateFirstStandard(emplid); //获取本年度评定前最后一次提资记录(增幅 > 0) ManagementTraineePayStandard latest = GetLatestRise(emplid, start); //如果没有找到提资记录,自动创建第一年的提资记录 if (latest == null) { //第一年,已第一条记录为基准 if (year == traineeInfo.入职时间.Year) { latest = first; } else { //创建入职当年的工资标准 CreatePayStandards(emplid, traineeInfo.入职时间.Year); latest = GetLatestRise(emplid, start); } } if (latest == null) { return(null); //如果找不到上一期提资记录,没法继续创建提资记录 } //获取年度评定 ManagementTraineeAbility ability = ManagementTraineeAbility.GetManagementTraineeAbility(emplid, year); string level = "A"; string type = traineeInfo.岗位级别 == "一级" ? traineeInfo.岗位类型 : traineeInfo.专业属性; //每年评定后自动产生后面四个季度的提资记录 List <ManagementTraineePayStandard> list = new List <ManagementTraineePayStandard>(); for (int i = 0; i < 4; i++) { decimal rise_rate = 0; decimal year_salary = latest.年薪; int month_salary = latest.月薪; int time = -999; //如果次数是 -999 表示此季度不提资 int quarter = (i + 2) % 4 + 1; int the_year = quarter <= 2 ? year + 1 : year; int m = the_year - first.年份; int n = quarter - first.季度; int q = m * 4 + n; //距离起薪季度数 int x = the_year - latest.年份; int y = quarter - latest.季度; int quarterInterval = x * 4 + y; //距离最后一次提资季度数 DateTime excuteStartTime = latest.开始执行时间.AddMonths(3 * quarterInterval); //获取提资序数 //(第一年每半年固定提资) if (q <= 4) { if (q == 2) //第一次提资 { time = 1; } if (q == 4) //第二次提资 { time = 2; } } else { if (ability == null) { continue; //如果还没有评定 } level = ability.能力级别; //默认本次提资序数=上一次提资序数+1 switch (level) { case "A": if (quarterInterval >= 2) { time = latest.提资序数 + 1; } break; case "B": if (quarterInterval >= 3) { time = latest.提资序数 + 1; } break; case "C": if (quarterInterval >= 4) { time = latest.提资序数 + 1; } break; } //升阶(满足升阶条件,先升阶,每阶+100, 满阶是 10000) double step = GetStep(traineeInfo.届别, traineeInfo.岗位级别, type, q); if (step == 0) { time = 10000; } //2018-9-21 进入二阶段以后,达到也要达到提资时间间隔才能提资 if (step >= 2 && time > 0 && time < 100) { time = 100; } } if (time == -999) { continue; } ManagementTraineePayRiseStandard standard = ManagementTraineePayRiseStandard.GetManagementTraineePayRiseStandard(traineeInfo.届别, traineeInfo.岗位级别, type, level, time); if (standard == null) { continue; //找不到提资标准 } //获取增幅、年薪和月薪 if (standard.提资方式 == (int)RiseType.金额) { year_salary = standard.年薪; rise_rate = 100 * ((decimal)(year_salary - latest.年薪) / (decimal)latest.年薪); rise_rate = Math.Round(rise_rate, 1, MidpointRounding.AwayFromZero); } else { rise_rate = standard.增幅; year_salary = Math.Round(latest.年薪 * (100 + rise_rate) * (decimal)0.01, 1, MidpointRounding.AwayFromZero); } month_salary = Convert.ToInt32((year_salary * (decimal)10000.0) / (decimal)12.0); ManagementTraineePayStandard new_item = AddManagementTraineePayStandard(emplid, employee.姓名, the_year, quarter, time); if (new_item != null) { new_item.季度 = quarter; new_item.年份 = the_year; new_item.增幅 = rise_rate; new_item.年薪 = year_salary; new_item.月薪 = month_salary; new_item.开始执行时间 = excuteStartTime; new_item.Save(); list.Add(new_item); latest = new_item; } if (time == 10000) { break; //已经满阶,退出 } } return(list); }
public static ManagementTraineeAbility GetManagementTraineeAbility(Guid id) { ManagementTraineeAbility obj = (ManagementTraineeAbility)Session.DefaultSession.GetObjectByKey(typeof(ManagementTraineeAbility), id); return(obj); }
//获取值指定管培生月薪表 public static List <ManagementTraineeSalary> GetMonthlySalaryList(ManagementTraineeInfo trainee, int year) { List <ManagementTraineeSalary> list = new List <ManagementTraineeSalary>(); if (trainee == null) { return(list); } //获取本年所有提资记录 List <ManagementTraineePayStandard> standards = ManagementTraineePayStandard.GetManagementTraineePayStandards(trainee.员工编号); standards = standards.OrderByDescending(a => a.开始执行时间).ToList(); //倒序, 以便按时间找到的第一条记录就是执行的记录 ManagementTraineePayStandard last_rise = null; if (standards.Count > 0) { //上月标准(去年最后一次提资) ManagementTraineePayStandard prev = standards.Find(a => a.开始执行时间 < new DateTime(year, 1, 1)); //最近一次评定 ManagementTraineeAbility last_ability = ManagementTraineeAbility.GetLastAbility(trainee.员工编号); //最近一次提资 last_rise = standards[0]; //最后一次提资 //构造月薪记录 for (int i = 1; i <= 12; i++) { ManagementTraineeSalary salary = new ManagementTraineeSalary(); DateTime start = new DateTime(year, i, 1); ManagementTraineePayStandard effectiveStandard = standards.Find(a => a.开始执行时间 <= start); //如果有执行标准 if (effectiveStandard != null) { salary.员工编号 = trainee.员工编号; salary.姓名 = trainee.姓名; salary.年份 = year; salary.季度 = (int)((i - 0.5) / 3) + 1; salary.月份 = i; salary.专业属性 = trainee.专业属性; salary.管培生信息 = trainee; salary.年薪 = effectiveStandard.年薪; salary.月薪 = effectiveStandard.月薪; if (prev != null && salary.年薪 > prev.年薪) { salary.增幅 = effectiveStandard.增幅.ToString("#0.##") + "%"; } if (salary.年薪 > 0) { salary.年薪_万元 = salary.年薪.ToString("#0.#"); } //不能超过最后一次提资记录的那个季度, int x = salary.年份 - last_rise.年份; int y = salary.季度 - last_rise.季度; if (x * 4 + y <= 0) { list.Add(salary); } else { if (last_ability != null) { int m = salary.年份 - last_ability.年度; int n = salary.季度 - 3; if (m * 4 + n < 4) { list.Add(salary); } } } prev = effectiveStandard; } } } return(list); }