📄 frmsalaryhis.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 人力资源管理系统
{
/// <summary>
/// frmSalaryHis 的摘要说明。
/// </summary>
public class frmSalaryHis : System.Windows.Forms.Form
{
internal System.Windows.Forms.GroupBox grbSalaryHis;
internal System.Windows.Forms.Button btnSearch;
internal System.Windows.Forms.TextBox txbPeopleName;
internal System.Windows.Forms.TextBox txbMonth;
internal System.Windows.Forms.Label lblPeopleName;
internal System.Windows.Forms.Label lblMonth;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
internal System.Windows.Forms.DataGrid dgdSalaryInfo;
// added member
private DataView dvResult;
public frmSalaryHis()
{
//
// 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()
{
this.dgdSalaryInfo = new System.Windows.Forms.DataGrid();
this.grbSalaryHis = new System.Windows.Forms.GroupBox();
this.btnSearch = new System.Windows.Forms.Button();
this.txbPeopleName = new System.Windows.Forms.TextBox();
this.txbMonth = new System.Windows.Forms.TextBox();
this.lblPeopleName = new System.Windows.Forms.Label();
this.lblMonth = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgdSalaryInfo)).BeginInit();
this.grbSalaryHis.SuspendLayout();
this.SuspendLayout();
//
// dgdSalaryInfo
//
this.dgdSalaryInfo.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.dgdSalaryInfo.CaptionVisible = false;
this.dgdSalaryInfo.DataMember = "";
this.dgdSalaryInfo.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgdSalaryInfo.Location = new System.Drawing.Point(0, 32);
this.dgdSalaryInfo.Name = "dgdSalaryInfo";
this.dgdSalaryInfo.Size = new System.Drawing.Size(406, 204);
this.dgdSalaryInfo.TabIndex = 3;
//
// grbSalaryHis
//
this.grbSalaryHis.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.grbSalaryHis.Controls.Add(this.btnSearch);
this.grbSalaryHis.Controls.Add(this.txbPeopleName);
this.grbSalaryHis.Controls.Add(this.txbMonth);
this.grbSalaryHis.Controls.Add(this.lblPeopleName);
this.grbSalaryHis.Controls.Add(this.lblMonth);
this.grbSalaryHis.Location = new System.Drawing.Point(-10, -6);
this.grbSalaryHis.Name = "grbSalaryHis";
this.grbSalaryHis.Size = new System.Drawing.Size(413, 46);
this.grbSalaryHis.TabIndex = 2;
this.grbSalaryHis.TabStop = false;
//
// btnSearch
//
this.btnSearch.Location = new System.Drawing.Point(296, 15);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(40, 21);
this.btnSearch.TabIndex = 12;
this.btnSearch.Text = "查询";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// txbPeopleName
//
this.txbPeopleName.Location = new System.Drawing.Point(216, 15);
this.txbPeopleName.Name = "txbPeopleName";
this.txbPeopleName.Size = new System.Drawing.Size(66, 20);
this.txbPeopleName.TabIndex = 11;
this.txbPeopleName.Text = "";
//
// txbMonth
//
this.txbMonth.Location = new System.Drawing.Point(72, 15);
this.txbMonth.Name = "txbMonth";
this.txbMonth.Size = new System.Drawing.Size(67, 20);
this.txbMonth.TabIndex = 10;
this.txbMonth.Text = "";
//
// lblPeopleName
//
this.lblPeopleName.Location = new System.Drawing.Point(144, 19);
this.lblPeopleName.Name = "lblPeopleName";
this.lblPeopleName.Size = new System.Drawing.Size(64, 15);
this.lblPeopleName.TabIndex = 9;
this.lblPeopleName.Text = "职员姓名";
//
// lblMonth
//
this.lblMonth.Location = new System.Drawing.Point(24, 19);
this.lblMonth.Name = "lblMonth";
this.lblMonth.Size = new System.Drawing.Size(40, 15);
this.lblMonth.TabIndex = 8;
this.lblMonth.Text = "月份";
//
// frmSalaryHis
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(392, 238);
this.Controls.Add(this.grbSalaryHis);
this.Controls.Add(this.dgdSalaryInfo);
this.Name = "frmSalaryHis";
this.Text = "工资发放历史";
this.Load += new System.EventHandler(this.frmSalaryHis_Load);
((System.ComponentModel.ISupportInitialize)(this.dgdSalaryInfo)).EndInit();
this.grbSalaryHis.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void LoadData()
{
DataBase db = new DataBase();
string strSQL = "select 姓名,日期,应发金额合计,应扣金额合计,";
strSQL += "工资合计,个人所得税,实发金额,基本工资, 浮动工资,";
strSQL += "合同补, 粮副补, 房补, 临时补, 职务工资, 工龄工资,";
strSQL += "考核工资, 奖金, 房租, 水电费, 请假扣除, 考勤扣除,罚款, ";
strSQL += "住房公积金, 医疗保险, 养老保险, 失业保险, 生育保险, 工伤保险,发放否 ";
strSQL += "from 职员基本信息表 as a, 工资发放历史表 as b where a.职员编号=b.职员编号";
string strCondition = "";
if ( txbMonth.Text.Trim().Length > 0 )
strCondition += " and 日期 = " + txbMonth.Text.Trim();
if ( txbPeopleName.Text.Trim().Length > 0 && strCondition.Trim().Length > 0 )
strCondition += " and 姓名 like '%" + txbPeopleName.Text.Trim() + "%'";
else if ( txbPeopleName.Text.Trim().Length > 0 )
strCondition += " and 姓名 like '%" + txbPeopleName.Text.Trim() + "%'";
if ( strCondition.Trim().Length > 0 )
strSQL += strCondition;
dvResult = db.RunSelectSQL( strSQL );
dvResult.AllowNew = false;
dvResult.AllowDelete = false;
dvResult.AllowEdit = false;
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
LoadData();
dgdSalaryInfo.DataSource = dvResult;
}
private void frmSalaryHis_Load(object sender, System.EventArgs e)
{
DataGridTableStyle ts = new DataGridTableStyle();
DataGridTextBoxColumn aCol = new DataGridTextBoxColumn();
int numCols = dvResult.Table.Columns.Count;
for ( int i = 0; i < numCols; i ++ )
{
aCol = new DataGridTextBoxColumn();
aCol.MappingName = dvResult.Table.Columns[ i ].ColumnName;
aCol.HeaderText = dvResult.Table.Columns[ i ].ColumnName;
aCol.NullText = "";
if ( i != 1 )
aCol.Format = "F";
ts.GridColumnStyles.Add( aCol );
}
ts.AlternatingBackColor = Color.LightGray;
ts.MappingName = dvResult.Table.TableName;
dgdSalaryInfo.TableStyles.Add( ts );
dgdSalaryInfo.DataSource = dvResult;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -