日期:2014-06-10 浏览次数:20805 次
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using HRMSys.DAL; using HRMSys.Model; namespace HYMSys.UI.EmployeeMgr { public partial class PrintSalarySheet : Form { public PrintSalarySheet() { InitializeComponent(); } /// <summary> /// 窗口自动载入事件,载入部门 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PrintSalarySheet_Load(object sender, EventArgs e) { DepartmentDAL dal = new DepartmentDAL(); cb_depart.DataSource= dal.ListAll(); cb_depart.DisplayMember = "Name"; //cb_depart.SelectedValue = "Id";//这里应该写 cb_depart.ValueMember = "Id",SelectedValue现在为空,因为就没有选择 cb_depart.ValueMember = "Id"; } /// <summary> /// 搜索某年某月的工资表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_search_Click(object sender, EventArgs e) { //取得文本框里的值 int year = Convert.ToInt32( tb_year.Text); int month = Convert.ToInt32(tb_month.Text); Guid id = (Guid)cb_depart.SelectedValue; //判断是否已经生成工资表 SalarySheetDAL sheetDAL = new SalarySheetDAL(); if (sheetDAL.IsExists(year, month, id) == false) { MessageBox.Show("还未生成工资!"); return; } //得到员工的工资表,将信息转换位水晶报表的字段 Guid sheetId = sheetDAL.GetYearMonthDepartSheetId(year, month, id); SalarySheetItemList[] items = sheetDAL.GetSalaryItems(sheetId); //声明一个水晶报表的显示字段 SalarySheetItemRpt[] rptItems = new SalarySheetItemRpt[items.Length]; for (int i = 0; i < items.Length; i++) { SalarySheetItemList 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 = item.EmployeeName; rptItems[i] = rptItem; } //声明一个水晶报表类 SalarySheetReport report = new SalarySheetReport(); report.SetDataSource(rptItems); report.SetParameterValue("年", year); report.SetParameterValue("月", month); report.SetParameterValue("部门名称", cb_depart.SelectedText); crystalReportViewer1.ReportSource = report; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HYMSys.UI.EmployeeMgr { public class SalarySheetItemRpt { public decimal Bonus { get; set; } public decimal BaseSalary { get; set; } public decimal Fine { get; set; } public decimal Other { get; set; } public string EmployeeName { get; set; } } }
<?xml version="1.0"?> <configuration> <connectionStrings> <add name="constr" connectionString="server=.;database=HRMSysDB1;uid=sa;pwd=123123"/> </connectionStrings> <appSettings> <add key="PasswodSalt" value="Love@.>1"/> </appSettings> <startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
七:其中的报错处理
解决,将承载进程去到
今天为止我的小的人事管理系统就完成了,经历了将近两个多月的时间,太不容易了,特别对于我这种菜鸟来说,这个是仿照一个WPF的小项目做的winform程序,做到这里我感觉自己有太多太多的知识不是理解的很透彻,唯有“纸上得来终觉浅,绝知此事要躬行”这样才能学好编程!在这里希望开发界的前辈多来来吐槽、批评和指导。-------红马車