PayoffHistory.cs
资源名称:VCSDB.rar [点击查看]
上传用户:hjieqiu
上传日期:2013-05-11
资源大小:16494k
文件大小:12k
源码类别:
企业管理
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace 人力资源管理系统
- {
- /// <summary>
- /// PayoffHistory 的摘要说明。
- /// </summary>
- public class PayoffHistory : System.Windows.Forms.Form
- {
- private DataTable tempTable = new DataTable();
- private System.Windows.Forms.DataGrid dataGrid1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.TextBox txt1;
- private System.Windows.Forms.TextBox txt2;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label8;
- private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
- private System.Windows.Forms.Button btn_Research;
- private System.Windows.Forms.Button btnQuit;
- private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
- private System.Data.SqlClient.SqlConnection sqlConnection1;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public PayoffHistory()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PayoffHistory));
- this.dataGrid1 = new System.Windows.Forms.DataGrid();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btn_Research = new System.Windows.Forms.Button();
- this.txt1 = new System.Windows.Forms.TextBox();
- this.txt2 = new System.Windows.Forms.TextBox();
- this.label6 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.btnQuit = new System.Windows.Forms.Button();
- this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
- this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
- this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // dataGrid1
- //
- this.dataGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGrid1.CaptionVisible = false;
- this.dataGrid1.DataMember = "";
- this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.dataGrid1.Location = new System.Drawing.Point(0, 56);
- this.dataGrid1.Name = "dataGrid1";
- this.dataGrid1.Size = new System.Drawing.Size(592, 360);
- this.dataGrid1.TabIndex = 4;
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.btn_Research);
- this.groupBox1.Controls.Add(this.txt1);
- this.groupBox1.Controls.Add(this.txt2);
- this.groupBox1.Controls.Add(this.label6);
- this.groupBox1.Controls.Add(this.label8);
- this.groupBox1.Controls.Add(this.btnQuit);
- this.groupBox1.Location = new System.Drawing.Point(0, 0);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(584, 56);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
- //
- // btn_Research
- //
- this.btn_Research.Location = new System.Drawing.Point(376, 16);
- this.btn_Research.Name = "btn_Research";
- this.btn_Research.Size = new System.Drawing.Size(68, 24);
- this.btn_Research.TabIndex = 2;
- this.btn_Research.Text = "查询";
- this.btn_Research.Click += new System.EventHandler(this.btn_Research_Click);
- //
- // txt1
- //
- this.txt1.Location = new System.Drawing.Point(80, 21);
- this.txt1.Name = "txt1";
- this.txt1.Size = new System.Drawing.Size(88, 21);
- this.txt1.TabIndex = 0;
- this.txt1.Text = "";
- //
- // txt2
- //
- this.txt2.Location = new System.Drawing.Point(248, 20);
- this.txt2.Name = "txt2";
- this.txt2.Size = new System.Drawing.Size(96, 21);
- this.txt2.TabIndex = 1;
- this.txt2.Text = "";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(192, 24);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(48, 16);
- this.label6.TabIndex = 23;
- this.label6.Text = "日期";
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(8, 23);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(64, 16);
- this.label8.TabIndex = 22;
- this.label8.Text = "职员姓名";
- //
- // btnQuit
- //
- this.btnQuit.Location = new System.Drawing.Point(472, 16);
- this.btnQuit.Name = "btnQuit";
- this.btnQuit.Size = new System.Drawing.Size(68, 24);
- this.btnQuit.TabIndex = 3;
- this.btnQuit.Text = "退出";
- this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
- //
- // sqlDataAdapter1
- //
- this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
- this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
- new System.Data.Common.DataTableMapping("Table", "职员基本信息表", new System.Data.Common.DataColumnMapping[] {
- new System.Data.Common.DataColumnMapping("姓名", "姓名"),
- new System.Data.Common.DataColumnMapping("日期", "日期"),
- new System.Data.Common.DataColumnMapping("职员编号", "职员编号"),
- new System.Data.Common.DataColumnMapping("基本工资", "基本工资"),
- new System.Data.Common.DataColumnMapping("浮动工资", "浮动工资"),
- new System.Data.Common.DataColumnMapping("合同补", "合同补"),
- new System.Data.Common.DataColumnMapping("粮副补", "粮副补"),
- new System.Data.Common.DataColumnMapping("房补", "房补"),
- new System.Data.Common.DataColumnMapping("临时补", "临时补"),
- new System.Data.Common.DataColumnMapping("职务工资", "职务工资"),
- new System.Data.Common.DataColumnMapping("工龄工资", "工龄工资"),
- new System.Data.Common.DataColumnMapping("考核工资", "考核工资"),
- new System.Data.Common.DataColumnMapping("奖金", "奖金"),
- new System.Data.Common.DataColumnMapping("应发金额合计", "应发金额合计"),
- new System.Data.Common.DataColumnMapping("房租", "房租"),
- new System.Data.Common.DataColumnMapping("水电费", "水电费"),
- new System.Data.Common.DataColumnMapping("请假扣除", "请假扣除"),
- new System.Data.Common.DataColumnMapping("考勤扣除", "考勤扣除"),
- new System.Data.Common.DataColumnMapping("罚款", "罚款"),
- new System.Data.Common.DataColumnMapping("住房公积金", "住房公积金"),
- new System.Data.Common.DataColumnMapping("医疗保险", "医疗保险"),
- new System.Data.Common.DataColumnMapping("养老保险", "养老保险"),
- new System.Data.Common.DataColumnMapping("失业保险", "失业保险"),
- new System.Data.Common.DataColumnMapping("生育保险", "生育保险"),
- new System.Data.Common.DataColumnMapping("工伤保险", "工伤保险"),
- new System.Data.Common.DataColumnMapping("应扣金额合计", "应扣金额合计"),
- new System.Data.Common.DataColumnMapping("工资合计", "工资合计"),
- new System.Data.Common.DataColumnMapping("个人所得税", "个人所得税"),
- new System.Data.Common.DataColumnMapping("实发金额", "实发金额"),
- new System.Data.Common.DataColumnMapping("发放否", "发放否"),
- new System.Data.Common.DataColumnMapping("月份", "月份")})});
- //
- // sqlSelectCommand1
- //
- this.sqlSelectCommand1.CommandText = @"SELECT a.姓名, b.日期, b.职员编号, b.基本工资, b.浮动工资, b.合同补, b.粮副补, b.房补, b.临时补, b.职务工资, b.工龄工资, b.考核工资, b.奖金, b.应发金额合计, b.房租, b.水电费, b.请假扣除, b.考勤扣除, b.罚款, b.住房公积金, b.医疗保险, b.养老保险, b.失业保险, b.生育保险, b.工伤保险, b.应扣金额合计, b.工资合计, b.个人所得税, b.实发金额, b.发放否, b.月份 FROM 职员基本信息表 a INNER JOIN 工资发放历史表 b ON a.职员编号 = b.职员编号";
- this.sqlSelectCommand1.Connection = this.sqlConnection1;
- //
- // sqlConnection1
- //
- this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=hrmbook;";
- //
- // PayoffHistory
- //
- this.AcceptButton = this.btn_Research;
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(584, 413);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.dataGrid1);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.Name = "PayoffHistory";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "【工资发放历史】";
- this.Load += new System.EventHandler(this.PayoffHistory_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
- this.groupBox1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- //--------------------初始化窗体,读入数据------------------
- private void PayoffHistory_Load(object sender, System.EventArgs e)
- {
- this.sqlDataAdapter1.Fill(tempTable);
- this.dataGrid1.DataSource = tempTable.DefaultView;
- DataGridStateControl();
- }
- //--------------将数据显示在表格中,并设置表格参数------------------
- private void DataGridStateControl()
- {
- DataGridTableStyle ts = new DataGridTableStyle();
- DataGridNoActiveCellColumn aColumnTextColumn;
- ts.AlternatingBackColor = Color.LightGray;
- ts.MappingName = tempTable.TableName;
- ts.AllowSorting = false;
- int numCols = tempTable.Columns.Count;
- for (int i = 0;i< numCols;i++)
- {
- aColumnTextColumn = new DataGridNoActiveCellColumn();
- aColumnTextColumn.MappingName = tempTable.Columns[i].ColumnName;
- aColumnTextColumn.HeaderText = tempTable.Columns[i].ColumnName;
- aColumnTextColumn.NullText = "";
- aColumnTextColumn.Format = "D";
- ts.GridColumnStyles.Add(aColumnTextColumn);
- }
- this.dataGrid1.TableStyles.Add(ts);
- this.dataGrid1.Select(0);
- }
- //--------------将符合查询条件的数据查询并显示在表中------------------
- private void btn_Research_Click(object sender, System.EventArgs e)
- {
- string strRowFilter = "";
- strRowFilter="(姓名 like '%"+txt1.Text.Trim()+"%')and(Convert(日期,'System.String') like '%"+txt2.Text.Trim()+"%')";
- //由于在RowFilter属性中不支持对int32的like命令符,所以需要将整数转为string后再使用like
- tempTable.DefaultView.RowFilter = strRowFilter;
- }
- //--------------退出窗体------------------
- private void btnQuit_Click(object sender, System.EventArgs e)
- {
- this.Close();
- }
- }
- }