⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmpeoplequery.cs

📁 环境采用ASP.NET和SQL Server 2000 一款为中小企业量身订做的人力资源管理软件。主要包括以下功能:档案管理、考核管理、工资管理、培训管理、评价管理、合同管理、员工调动、员工离职、员工
💻 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>
	/// frmPeopleQuery 的摘要说明。
	/// </summary>
	public class frmPeopleQuery : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.GroupBox grbPepQuery;
		internal System.Windows.Forms.Button btnSearch;
		internal System.Windows.Forms.ComboBox cbbCity;
		internal System.Windows.Forms.ComboBox cbbNature;
		internal System.Windows.Forms.ComboBox cbbSex;
		internal System.Windows.Forms.TextBox txbName;
		internal System.Windows.Forms.TextBox txbNameCode;
		internal System.Windows.Forms.Label lblCity;
		internal System.Windows.Forms.Label lblSex;
		internal System.Windows.Forms.Label lblNature;
		internal System.Windows.Forms.Label lblName;
		internal System.Windows.Forms.Label lblNameCode;
		internal System.Windows.Forms.DataGrid dgdPepInfo;

		// added variable
		private DataView dvResult;

		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmPeopleQuery()
		{
			//
			// 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.grbPepQuery = new System.Windows.Forms.GroupBox();
			this.btnSearch = new System.Windows.Forms.Button();
			this.cbbCity = new System.Windows.Forms.ComboBox();
			this.cbbNature = new System.Windows.Forms.ComboBox();
			this.cbbSex = new System.Windows.Forms.ComboBox();
			this.txbName = new System.Windows.Forms.TextBox();
			this.txbNameCode = new System.Windows.Forms.TextBox();
			this.lblCity = new System.Windows.Forms.Label();
			this.lblSex = new System.Windows.Forms.Label();
			this.lblNature = new System.Windows.Forms.Label();
			this.lblName = new System.Windows.Forms.Label();
			this.lblNameCode = new System.Windows.Forms.Label();
			this.dgdPepInfo = new System.Windows.Forms.DataGrid();
			this.grbPepQuery.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dgdPepInfo)).BeginInit();
			this.SuspendLayout();
			// 
			// grbPepQuery
			// 
			this.grbPepQuery.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.grbPepQuery.Controls.Add(this.btnSearch);
			this.grbPepQuery.Controls.Add(this.cbbCity);
			this.grbPepQuery.Controls.Add(this.cbbNature);
			this.grbPepQuery.Controls.Add(this.cbbSex);
			this.grbPepQuery.Controls.Add(this.txbName);
			this.grbPepQuery.Controls.Add(this.txbNameCode);
			this.grbPepQuery.Controls.Add(this.lblCity);
			this.grbPepQuery.Controls.Add(this.lblSex);
			this.grbPepQuery.Controls.Add(this.lblNature);
			this.grbPepQuery.Controls.Add(this.lblName);
			this.grbPepQuery.Controls.Add(this.lblNameCode);
			this.grbPepQuery.Location = new System.Drawing.Point(0, 7);
			this.grbPepQuery.Name = "grbPepQuery";
			this.grbPepQuery.Size = new System.Drawing.Size(504, 67);
			this.grbPepQuery.TabIndex = 2;
			this.grbPepQuery.TabStop = false;
			// 
			// btnSearch
			// 
			this.btnSearch.Location = new System.Drawing.Point(243, 38);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(40, 21);
			this.btnSearch.TabIndex = 11;
			this.btnSearch.Text = "查询";
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// cbbCity
			// 
			this.cbbCity.Items.AddRange(new object[] {
														 "北京",
														 "河北",
														 "河南",
														 "山西",
														 "其他"});
			this.cbbCity.Location = new System.Drawing.Point(160, 40);
			this.cbbCity.Name = "cbbCity";
			this.cbbCity.Size = new System.Drawing.Size(47, 21);
			this.cbbCity.TabIndex = 10;
			// 
			// cbbNature
			// 
			this.cbbNature.Items.AddRange(new object[] {
														   "汉族",
														   "壮族",
														   "满族",
														   "苗族",
														   "其他"});
			this.cbbNature.Location = new System.Drawing.Point(60, 39);
			this.cbbNature.Name = "cbbNature";
			this.cbbNature.Size = new System.Drawing.Size(47, 21);
			this.cbbNature.TabIndex = 9;
			// 
			// cbbSex
			// 
			this.cbbSex.Items.AddRange(new object[] {
														"男",
														"女"});
			this.cbbSex.Location = new System.Drawing.Point(312, 16);
			this.cbbSex.Name = "cbbSex";
			this.cbbSex.Size = new System.Drawing.Size(47, 21);
			this.cbbSex.TabIndex = 8;
			// 
			// txbName
			// 
			this.txbName.Location = new System.Drawing.Point(160, 16);
			this.txbName.Name = "txbName";
			this.txbName.Size = new System.Drawing.Size(47, 20);
			this.txbName.TabIndex = 7;
			this.txbName.Text = "";
			// 
			// txbNameCode
			// 
			this.txbNameCode.Location = new System.Drawing.Point(60, 12);
			this.txbNameCode.Name = "txbNameCode";
			this.txbNameCode.Size = new System.Drawing.Size(47, 20);
			this.txbNameCode.TabIndex = 5;
			this.txbNameCode.Text = "";
			// 
			// lblCity
			// 
			this.lblCity.Location = new System.Drawing.Point(112, 45);
			this.lblCity.Name = "lblCity";
			this.lblCity.Size = new System.Drawing.Size(48, 14);
			this.lblCity.TabIndex = 4;
			this.lblCity.Text = "籍贯";
			// 
			// lblSex
			// 
			this.lblSex.Location = new System.Drawing.Point(264, 18);
			this.lblSex.Name = "lblSex";
			this.lblSex.Size = new System.Drawing.Size(40, 14);
			this.lblSex.TabIndex = 3;
			this.lblSex.Text = "性别";
			// 
			// lblNature
			// 
			this.lblNature.Location = new System.Drawing.Point(16, 45);
			this.lblNature.Name = "lblNature";
			this.lblNature.Size = new System.Drawing.Size(32, 14);
			this.lblNature.TabIndex = 2;
			this.lblNature.Text = "民族";
			// 
			// lblName
			// 
			this.lblName.Location = new System.Drawing.Point(112, 18);
			this.lblName.Name = "lblName";
			this.lblName.Size = new System.Drawing.Size(40, 14);
			this.lblName.TabIndex = 1;
			this.lblName.Text = "姓名";
			// 
			// lblNameCode
			// 
			this.lblNameCode.Location = new System.Drawing.Point(12, 18);
			this.lblNameCode.Name = "lblNameCode";
			this.lblNameCode.Size = new System.Drawing.Size(46, 14);
			this.lblNameCode.TabIndex = 0;
			this.lblNameCode.Text = "姓名简码";
			// 
			// dgdPepInfo
			// 
			this.dgdPepInfo.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.dgdPepInfo.CaptionVisible = false;
			this.dgdPepInfo.DataMember = "";
			this.dgdPepInfo.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgdPepInfo.Location = new System.Drawing.Point(0, 74);
			this.dgdPepInfo.Name = "dgdPepInfo";
			this.dgdPepInfo.Size = new System.Drawing.Size(504, 176);
			this.dgdPepInfo.TabIndex = 3;
			// 
			// frmPeopleQuery
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(496, 254);
			this.Controls.Add(this.grbPepQuery);
			this.Controls.Add(this.dgdPepInfo);
			this.Name = "frmPeopleQuery";
			this.Text = "职员信息查询";
			this.Load += new System.EventHandler(this.frmPeopleQuery_Load);
			this.grbPepQuery.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgdPepInfo)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			// 加载数据
			LoadData();
			// 设置数据源;
			dgdPepInfo.DataSource = dvResult;
		}

		private void LoadData()
		{
			DataBase db = new DataBase();
			// 组合查询语句
			string strSQL = "select 姓名,性别,出生日期,籍贯,民族,办公电话,婚姻状况,单位名称,文化程度" +
				" from 职员基本信息表 as a, 组织机构编码表 as b" + " where a.单位编号 = b.单位编号";
			string strCondition = "";
			if ( txbNameCode.Text.Trim().Length > 0 )
			{
				strCondition += " and 姓名简码 like'%" + txbNameCode.Text.Trim() + "'%";
			}
			if ( txbName.Text.Trim().Length > 0 )
			{
				strCondition += " and 姓名 like'%" + txbName.Text.Trim() + "'%";
			}
			if ( cbbSex.Text.Trim().Length > 0 )
			{
				strCondition += " and 性别 like'%" + cbbSex.Text.Trim() + "'%";
			}
			if ( cbbNature.Text.Trim().Length > 0 )
			{
				strCondition += " and 民族 like'%" + cbbNature.Text.Trim() + "'%";
			}
			if ( cbbCity.Text.Trim().Length > 0 )
			{
				strCondition += " and 籍贯 like'%" + cbbNature.Text.Trim() + "'%";
			}
			if ( strCondition.Trim().Length > 0 )
			{
				strSQL += strCondition;
			}
			dvResult = db.RunSelectSQL( strSQL );
			dvResult.AllowDelete = false;
			dvResult.AllowEdit = false;
			dvResult.AllowNew = false;
		}

		private void frmPeopleQuery_Load(object sender, System.EventArgs e)
		{
			LoadData();
			// 定义DataGridTableStyle
			DataGridTableStyle ts = new DataGridTableStyle();
			DataGridTextBoxColumn aCol;
			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 || i == 4 )
				{
					aCol.Width = 40;
				}
				ts.GridColumnStyles.Add( aCol );
			}
			ts.AlternatingBackColor = Color.LightGray;
			ts.MappingName = dvResult.Table.TableName;
			dgdPepInfo.TableStyles.Add( ts );
			dgdPepInfo.DataSource = dvResult; 
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -