private void btnCreateSalarySheet_Click(object sender, RoutedEventArgs e) { int year = (int)cmbYear.SelectedValue; int month = (int)cmbMonth.SelectedValue; Guid deptId = (Guid)cmbDept.SelectedValue; SalarySheetDAL dal = new SalarySheetDAL(); if (dal.IsExists(year, month, deptId)) { if (MessageBox.Show("工资单已经生成,是否重新生成?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { dal.Clear(year, month, deptId); } } dal.Build(year, month, deptId); colEmployee.ItemsSource = new EmployeeDAL().ListByDepment(deptId); datagridItems.ItemsSource = new SalarySheetDAL().GetSalarySheetItems( year, month, deptId); }
private void btnQuery_Click(object sender, RoutedEventArgs e) { int year = Convert.ToInt32(txtYear.Text); int month = Convert.ToInt32(txtMonth.Text); Guid deptId = (Guid)cmbDepts.SelectedValue; SalarySheetDAL sheetDAL = new SalarySheetDAL(); if (sheetDAL.IsExists(year, month, deptId) == false) { MessageBox.Show("还未生成工资!"); return; } SalarySheetItem[] items = sheetDAL.GetSalarySheetItems(year, month, deptId); SalarySheetItemRpt[] rptItems = new SalarySheetItemRpt[items.Length]; for (int i = 0; i < items.Length; i++) { SalarySheetItem item = items[i]; SalarySheetItemRpt rptItem = new SalarySheetItemRpt(); rptItem.BaseSalary = item.BaseSalary; rptItem.Bonus = item.Bonus; rptItem.Fine = item.Fine; rptItem.Other = item.Other; //select emp.Name join T_employee rptItem.EmployeeName = new EmployeeDAL().GetById(item.EmployeeId).Name; rptItems[i] = rptItem; } SalarySheetReport report = new SalarySheetReport(); report.SetDataSource(rptItems); report.SetParameterValue("年", year); report.SetParameterValue("月", month); report.SetParameterValue("部门名称", cmbDepts.Text); reportsViewerItems.ViewerCore.ReportSource = report; }