/// <summary> /// 工资管理模块 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SalaryButton_Click(object sender, RoutedEventArgs e) { stateflag = 3; RemoveFieldColumns(); pagename.Content = "工资管理"; DataGridTextColumn dgtxtCol; string[] fields = { "id", "基本工资", "最终工资", "Id", "Pre_sal", "Current_sal" }; for (int i = 0; i < 3; i++) { dgtxtCol = new DataGridTextColumn(); dgtxtCol.Header = fields[i]; dgtxtCol.Binding = new Binding(fields[i + 3]); UserGrid.Columns.Insert(1 + i, dgtxtCol); } //List<Salary> salarys = new List<Salary>(); salaryList.Clear(); Salary salary = new Salary(); SalaryBLL salaryBLL = new SalaryBLL(); List <Salary> salary1 = salaryBLL.GetAllSalary(); int id = 0; foreach (Salary item in salary1) { id = item.Id; salary = salaryBLL.GetsalaryByID(id); RP rP = new RP(); RPBLL rpBll = new RPBLL(); List <RP> rps = rpBll.GetRPsByUserId(id); int sum = 0; if (rps != null) { foreach (RP item1 in rps) { sum += item1.Sal; } salary.Current_sal = salary.Pre_sal + sum; salaryBLL.Modifysalary(salary); } Salary salary2 = new Salary(); salary2 = salaryBLL.GetsalaryByID(id); if (salary2 != null) { salaryList.Add(salary2); } } UserGrid.ItemsSource = salaryList; sum = salaryList.Count; //sum是记录总数 SalaryBinding(maxnum, 1); }
//获取当前登录员工的个人信息,工资信息 private void GetUserInfoAndSalary() { user = userBLL.GetUserByID(uid); if (user == null) { throw new Exception("无法获得uid为" + uid + "的员工信息"); } salary = salaryBLL.GetsalaryByID(uid); if (salary == null) { throw new Exception("无法获得uid为" + uid + "的工资信息"); } }
/// <summary> /// 条件查询 /// </summary> private void search_buttonSalary() { if (combox_search.SelectedItem == null) { MessageBox.Show("请先选择查询条件"); return; } if (txt_search.Text != "" && (combox_search.SelectedItem).ToString() != "") { SalaryBLL salaryBLL = new SalaryBLL(); Salary salary = null; salaryList.Clear(); if (combox_search.SelectedIndex == 1) { if (!isInteger(txt_search.Text)) { MessageBox.Show("请输入数字"); txt_search.Text = ""; return; } int id = int.Parse(txt_search.Text); salary = salaryBLL.GetsalaryByID(id); if (salary != null) { salaryList.Add(salary); UserGrid.ItemsSource = salaryList; } } sum = salaryList.Count; SalaryBinding(maxnum, 1); } else { MessageBox.Show("查找方式和内容不能为空!"); } txt_search.Text = ""; }