private void advBandedGridView1_CellValueChanged(object sender, CellValueChangedEventArgs e) { ManagementTraineePayStandardInput row = advBandedGridView1.GetRow(e.RowHandle) as ManagementTraineePayStandardInput; if (row != null) { decimal prevYearSalary = 0; //上期年薪 if (e.RowHandle == 0) { prevYearSalary = prevStandard.年薪; } else { ManagementTraineePayStandardInput prev = trainee_salary_list[e.RowHandle - 1]; if (prev != null) { prevYearSalary = prev.年薪; } } if (e.Column.FieldName == "年薪" && prevYearSalary > 0) { //重算后面的增幅 for (int i = e.RowHandle; i < trainee_salary_list.Count; i++) { if (i > e.RowHandle + 1) { break; //只需要更新当前记录和后面一条记录 } ManagementTraineePayStandardInput item = trainee_salary_list[i]; if (i > e.RowHandle && item.年薪 == 0) { break; //后面的记录如果还没有录入 } decimal year_salary = item.年薪; decimal rise_rate = 100 * ((decimal)(year_salary - prevYearSalary) / prevYearSalary); rise_rate = Math.Round(rise_rate, 1); decimal month_salary = Convert.ToInt32((year_salary * (decimal)10000.0) / (decimal)12.0); item.增幅 = rise_rate; item.月薪 = Convert.ToInt32(month_salary); item.Save(); prevYearSalary = year_salary; } gridControl1.RefreshDataSource(); gridControl1.Refresh(); } } }
List <ManagementTraineePayStandardInput> CreateEditingRows() { List <ManagementTraineePayStandardInput> list = new List <ManagementTraineePayStandardInput>(); int 提资序数 = prevStandard.提资序数 + 1; ManagementTraineePayStandard first = ManagementTraineePayStandard.CreateFirstStandard(trainee.员工编号); for (int i = 0; i < 4; i++) { int 年度 = i >= 2 ? year + 1 : year; DateTime 年度开始 = new DateTime(年度, 1, 1); int 季度 = (i + 2) % 4 + 1; int m = 年度 - first.年份; int n = 季度 - first.季度; int q = m * 4 + n; //距离起薪季度数 string type = trainee.岗位级别 == "一级" ? trainee.岗位类型 : trainee.专业属性; //升阶(满足升阶条件,先升阶,每阶+100, 满阶是 10000) double step = ManagementTraineePayStandard.GetStep(trainee.届别, trainee.岗位级别, type, q); if (step == 0) { 提资序数 = 10000; } if (step == 2) { 提资序数 = 100; } ManagementTraineePayStandardInput item = ManagementTraineePayStandardInput.AddManagementTraineePayStandardInput(trainee.员工编号, 年度, 季度, i + 1, 提资序数, isCheck); list.Add(item); 提资序数++; } return(list); }
private void gridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) { if (showDifferent == false) { return; } e.Appearance.ForeColor = Color.Black; e.Appearance.BackColor = Color.Transparent; ManagementTraineePayStandardInput row = advBandedGridView1.GetRow(e.RowHandle) as ManagementTraineePayStandardInput; if (row != null) { foreach (ModifyField field in row.内容不同的字段) { if (field.称 == e.Column.FieldName && field.称 == "年薪") { e.Appearance.ForeColor = Color.Yellow; e.Appearance.BackColor = Color.Red; } } } }
protected void LoadData(bool compare) { bool isSameEditor = false; CreateWaitDialog("正在查询...", "请稍等"); trainee_salary_list = ManagementTraineePayStandardInput.GetEditingRows(trainee.员工编号, year, isCheck); //如果没有记录,自动创建 if (trainee_salary_list.Count == 0) { trainee_salary_list = CreateEditingRows(); } //如果比较 if (compare) { trainee_salary_list_opposite = ManagementTraineePayStandardInput.GetEditingRows(trainee.员工编号, year, !isCheck); } SetWaitDialogCaption("正在加载..."); if (isSameEditor) { CloseWaitDialog(); MessageBox.Show("两次录入不能是同一个人"); this.Close(); } gridControl1.DataSource = trainee_salary_list; gridControl1.Refresh(); CloseWaitDialog(); showDifferent = compare; }