protected override void OnSaving() { if (string.IsNullOrEmpty(this.薪酬体系)) { throw new Exception("薪酬体系不能为空"); } if (string.IsNullOrEmpty(this.职等)) { throw new Exception("职等不能为空"); } if (string.IsNullOrEmpty(this.职级)) { throw new Exception("职级不能为空"); } if (this.期号 == 0) { throw new Exception("期号不能为空"); } RankSalaryStandardInput found = GetRankSalaryStandardInput(this.薪酬体系, this.职等, this.职级, this.期号, this.是验证录入); if (found != null && found.标识 != this.标识) { throw new Exception("本期已存在同职级的标准,不能创建。"); } else { base.OnSaving(); } contentDifferentFields = null; RANK_SALARY_STANDARD_INPUT_CACHE.Set(CacheKey, this, TimeSpan.FromHours(1)); }
//更新到正式表 public void UpdateToFormalTable() { if (this.内容不同的字段.Count > 0) { return; } RankSalaryStandard m = RankSalaryStandard.GetRankSalaryStandard(this.薪酬体系, this.职等, this.职级, this.期号); if (m == null) { m = new RankSalaryStandard(); m.标识 = Guid.NewGuid(); } this.CopyWatchMember(m); m.Save(); //更新生效标记 if (!this.已生效) { this.生效时间 = DateTime.Now; this.Save(); RankSalaryStandardInput opposite = 另一人录入的记录; opposite.生效时间 = DateTime.Now; opposite.Save(); } }
void LoadData() { //分隔行没有数据 if (is_separator) { return; } 薪酬体系 = jobGrade.薪酬体系; 称 = jobGrade.称; 期号 = period; 职等 = jobGrade; RankNames = ""; 标识 = jobGrade.标识; rss_list.Clear(); List <JobRank> jobranks = JobRank.GetJobRanks(jobGrade.标识); foreach (JobRank rank in jobranks) { //本期标准 RankSalaryStandardInput rss = RankSalaryStandardInput.AddRankSalaryStandardInput(jobGrade.薪酬体系, jobGrade.称, rank.称, period, rank.序号, is_verify); rss_list.Add(rss); 开始执行日期 = rss.开始执行日期; //赋值 string propertyName = "R" + rss.序号; string monthlySalary = rss.月薪.ToString(); PropertyInfo property = this.GetType().GetProperty(propertyName); if (property != null) { property.SetValue(this, monthlySalary, null); } if (RankNames != "") { RankNames += ":"; } RankNames += rank.称; } int t = is_verify ? 2 : 1; //统计表类型:0: 正式, 1: 初次录入, 2: 验证录入 gsa = GradeSalaryAdjust.GetGradeSalaryAdjust(jobGrade.薪酬体系, jobGrade.称, period, t); if (gsa == null) { gsa = GradeSalaryAdjust.AddGradeSalaryAdjust(jobGrade.薪酬体系, jobGrade.称, period, t); gsa.Calculate(); } SetFieldValue(); }
public static GradeSalaryAdjustInput AddGradeSalaryAdjustInput(GradeSalaryAdjust prev_gsa, int period, bool isVerify) { GradeSalaryAdjustInput item = GetGradeSalaryAdjustInput(prev_gsa.薪酬体系, prev_gsa.职等, period, isVerify); if (item == null) { item = new GradeSalaryAdjustInput(); item.标识 = Guid.NewGuid(); item.薪酬体系 = prev_gsa.薪酬体系; item.职等 = prev_gsa.职等; item.期号 = period; item.是验证录入 = isVerify; //复制上一期的数据 item.职等数 = prev_gsa.职等数; item.对比的职等 = prev_gsa.对比的职等; item.序号 = prev_gsa.序号; item.级差 = prev_gsa.级差; item.半年调资额 = prev_gsa.半年调资额; item.每年调资额 = prev_gsa.每年调资额; item.Save(); //自动创建职级工资记录 List <RankSalaryStandardInput> rss_list = new List <RankSalaryStandardInput>(); //获取上一期的职级工资列表 List <RankSalaryStandard> prev_rss_lilst = RankSalaryStandard.GetRankSalaryStandards(prev_gsa.薪酬体系, prev_gsa.职等, prev_gsa.期号); foreach (RankSalaryStandard rss in prev_rss_lilst) { //创建 RankSalaryStandardInput new_rss = RankSalaryStandardInput.AddRankSalaryStandardInput(rss.薪酬体系, rss.职等, rss.职级, period, rss.序号, isVerify); //自动更新数据 new_rss.月薪 = rss.月薪 + item.半年调资额; new_rss.录入人 = "系统"; new_rss.录入时间 = DateTime.Now; new_rss.Save(); rss_list.Add(new_rss); } item.职级工资表 = rss_list; } return(item); }
public static RankSalaryStandardInput AddRankSalaryStandardInput(string salaryPlan, string grade, string rank, int period, int order, bool isVerify) { RankSalaryStandardInput item = GetRankSalaryStandardInput(salaryPlan, grade, rank, period, isVerify); if (item == null) { item = new RankSalaryStandardInput(); item.标识 = Guid.NewGuid(); item.薪酬体系 = salaryPlan; item.职等 = grade; item.职级 = rank; item.期号 = period; item.序号 = order; item.是验证录入 = isVerify; item.录入人 = " "; item.录入时间 = DateTime.Now; item.Save(); } return(item); }
public static List <AdjustJobGrade> GetAdjustJobGradeList(string salary_plan, int year, SemiannualType semiannual, bool insert_separator, bool isVerify) { List <AdjustJobGrade> gradeList = new List <AdjustJobGrade>(); int period = year * 10 + (byte)semiannual; List <RankSalaryStandardInput> rss_list = RankSalaryStandardInput.GetRankSalaryStandardInputs(salary_plan, null, period, isVerify); List <JobGrade> jobGrades = JobGrade.GetJobGrades(salary_plan); foreach (JobGrade grade in jobGrades) { AdjustJobGrade snGrade = new AdjustJobGrade(grade, year, semiannual, isVerify); gradeList.Add(snGrade); } string prev_line_ranknames = ""; //上一行职级名称列表 List <AdjustJobGrade> grades_result = new List <AdjustJobGrade>(); //遍历 foreach (AdjustJobGrade sgrade in gradeList) { if (sgrade.RankNames != "") { //如果职级划分不同,插入一行分割数据 if (prev_line_ranknames != sgrade.RankNames) { if (prev_line_ranknames != "") { grades_result.Add(new AdjustJobGrade(sgrade.RankNames)); } prev_line_ranknames = sgrade.RankNames; } } grades_result.Add(sgrade); } return(grades_result); }
//重新统计 public void Calculate() { int differential = 0; double total = 0; int avg = 0; double yearAdjustRate = 1; int max = 0; int min = 0; List <IRankSalary> rss_list = new List <IRankSalary>(); if (类型 == 0) { foreach (IRankSalary irs in RankSalaryStandard.GetRankSalaryStandards(this.薪酬体系, this.职等, this.期号)) { rss_list.Add(irs); } } else { foreach (IRankSalary irs in RankSalaryStandardInput.GetRankSalaryStandardInputs(this.薪酬体系, this.职等, this.期号, this.类型 == 2)) { rss_list.Add(irs); } } rss_list = rss_list.FindAll(a => a.月薪 > 0).ToList(); //过滤掉没有设置月薪的记录 if (rss_list.Count > 0) { total = rss_list.Sum(a => a.月薪); avg = (int)(total / rss_list.Count); min = rss_list.Min(a => a.月薪); max = rss_list.Max(a => a.月薪); if (rss_list.Count >= 2) { IRankSalary rss0 = rss_list[0]; IRankSalary rss1 = rss_list[1]; differential = rss0.月薪 - rss1.月薪; } } #region 计算年调率 this.每年调资额 = Convert.ToInt32(this.半年调资额 * 1.5); int previous_period = RankSalaryStandard.GetPreviousPeriod(this.薪酬体系, this.期号); GradeSalaryAdjust previous_gsh = GradeSalaryAdjust.GetGradeSalaryAdjust(this.薪酬体系, this.职等, previous_period, 0); //如果找到上期数据(通取正式数据) if (previous_gsh != null) { int avg_previous = previous_gsh.平均工资; if (avg_previous > 0) { yearAdjustRate = (double)每年调资额 / avg_previous; } } else //首次标准 { if (avg != 0) { yearAdjustRate = (double)每年调资额 / avg; } } #endregion this.级差 = differential; this.年调率 = yearAdjustRate; this.平均工资 = avg; this.最低工资 = min; this.最高工资 = max; #region 计算职等差 //获取对比的职等 GradeSalaryAdjust contrast = GradeSalaryAdjust.GetFromCache(this.薪酬体系, this.对比的职等, this.期号, this.类型); if (contrast != null) { this.职等差 = contrast.最低工资 - this.最高工资; } #endregion this.Save(); }
public static RankSalaryStandardInput GetRankSalaryStandardInput(Guid id) { RankSalaryStandardInput obj = (RankSalaryStandardInput)Session.DefaultSession.GetObjectByKey(typeof(RankSalaryStandardInput), id); return(obj); }
//重新统计 public void Calculate() { int differential = 0; int halfYearAdjust = 0; //半年调 int yearAdjust = 0; double total = 0; int avg = 0; double yearAdjustRate = 0; int max = 0; int min = 0; List <RankSalaryStandardInput> rss_list = RankSalaryStandardInput.GetRankSalaryStandardInputs(this.薪酬体系, this.职等, this.期号, this.是验证录入); if (rss_list.Count > 0) { total = rss_list.Sum(a => a.月薪); avg = (int)(total / rss_list.Count); min = rss_list.Min(a => a.月薪); max = rss_list.Max(a => a.月薪); if (rss_list.Count >= 2) { IRankSalary rss0 = rss_list[0]; IRankSalary rss1 = rss_list[1]; differential = rss0.月薪 - rss1.月薪; } } #region 计算年调率 if (this.期调整 != null) { int avg_previous = previous_gsh.平均工资; if (avg_previous > 0) { halfYearAdjust = avg - previous_gsh.平均工资; yearAdjust = halfYearAdjust * 2; yearAdjustRate = (double)yearAdjust / avg_previous; } } #endregion this.级差 = differential; this.半年调资额 = halfYearAdjust; this.每年调资额 = yearAdjust; this.年调率 = yearAdjustRate; this.平均工资 = avg; this.最低工资 = min; this.最高工资 = max; #region 计算职等差 //获取对比的职等 GradeSalaryAdjustInput contrast = GradeSalaryAdjustInput.GetGradeSalaryAdjustInput(this.薪酬体系, this.对比的职等, this.期号, this.是验证录入); if (contrast != null) { this.职等差 = contrast.最低工资 - this.最高工资; } #endregion this.Save(); }