private void btnGenerateSheet_Click(object sender, RoutedEventArgs e) { int year = (int)cmbYear.SelectedValue; int month = (int)cmbMonth.SelectedValue; Guid deptId = (Guid)cmbDepartment.SelectedValue; SalarySheetDAL dal = new SalarySheetDAL(); if (dal.IsExisted(year, month, deptId)) { if (MessageBoxResult.Yes == MessageBox.Show("SalarySheet is already existed. Do you want to gernerate one again?", "Warning", MessageBoxButton.YesNo)) { dal.Clear(year, month, deptId); dal.Generate(year, month, deptId); //MessageBox.Show("Successful Generating!"); colEmployee.ItemsSource = new EmployeeDAL().SearchByDpt(deptId); datagrid.ItemsSource = new SalarySheetItemDAL().GetItemsByDate(year, month, deptId); } else { return; } } else { dal.Generate(year, month, deptId); colEmployee.ItemsSource = new EmployeeDAL().SearchByDpt(deptId); datagrid.ItemsSource = new SalarySheetItemDAL().GetItemsByDate(year, month, deptId); } }
private void btnCreateSalarySheet_Click(object sender, RoutedEventArgs e) { int year = (int)cmbYear.SelectedItem; int month = (int)cmbMonth.SelectedItem; Guid DeptId = (Guid)cmbDept.SelectedValue; if (SalarySheetDAL.IsExist(year, month, DeptId)) { if (MessageBox.Show("工资表已存在,是否重新生成?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SalarySheetDAL.DeleteSalarySheet(year, month, DeptId); } SalarySheetDAL.Build(year, month, DeptId); //MessageBox.Show("生成成功!"); colEmployee.ItemsSource = EmployeeDAL.GetEmployeeByDept(DeptId); dataGridSalaryItems.ItemsSource = SalarySheetDAL.GetSalarySheetItem(year, month, DeptId); } }
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; }
private void btnQuery_Click(object sender, RoutedEventArgs e) { int year = Convert.ToInt32(txtYear.Text); int month = Convert.ToInt32(txtMonth.Text); Guid DeptId = (Guid)cmbDept.SelectedValue; if (SalarySheetDAL.IsExist(year, month, DeptId) == false) { MessageBox.Show("还没有生成工资表!"); return; } SalarySheetItem[] salarySheetItems = SalarySheetDAL.GetSalarySheetItem(year, month, DeptId); SalarySheetItemrpt[] salarySheetItemrpts = new SalarySheetItemrpt[salarySheetItems.Length]; for (int i = 0; i < salarySheetItems.Length; i++) { SalarySheetItem item = salarySheetItems[i]; SalarySheetItemrpt itemRpt = new SalarySheetItemrpt(); itemRpt.BaseSalary = item.BaseSalary; itemRpt.Bonus = item.Bonus; itemRpt.Fine = item.Fine; itemRpt.Other = item.Other; itemRpt.EmployeeName = EmployeeDAL.GetById(item.EmployeeId).Name; salarySheetItemrpts[i] = itemRpt; } SalarySheetItemCrystalReport rpt = new SalarySheetItemCrystalReport(); rpt.SetDataSource(salarySheetItemrpts); rpt.SetParameterValue("年", year); rpt.SetParameterValue("月", month); rpt.SetParameterValue("部门", cmbDept.Text); crystalReportsViewer1.ViewerCore.ReportSource = rpt; }
private void dataGridSalaryItems_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { SalarySheetItem item = (SalarySheetItem)e.Row.DataContext; SalarySheetDAL.UpdateSalarySheet(item); }