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

📄 amendstafferinfo.cs

📁 人力资源管理系统 在vc的环境下编写的
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@籍贯", System.Data.SqlDbType.VarChar, 50, "籍贯"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@民族", System.Data.SqlDbType.VarChar, 20, "民族"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@文化程度", System.Data.SqlDbType.VarChar, 50, "文化程度"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@毕业学校", System.Data.SqlDbType.VarChar, 100, "毕业学校"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@健康状况", System.Data.SqlDbType.VarChar, 50, "健康状况"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@婚姻状况", System.Data.SqlDbType.VarChar, 10, "婚姻状况"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@身份证号码", System.Data.SqlDbType.VarChar, 18, "身份证号码"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@家庭电话", System.Data.SqlDbType.VarChar, 50, "家庭电话"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@办公电话", System.Data.SqlDbType.VarChar, 50, "办公电话"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@手机", System.Data.SqlDbType.VarChar, 50, "手机"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@电子邮件地址", System.Data.SqlDbType.VarChar, 50, "电子邮件地址"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@职工账号", System.Data.SqlDbType.VarChar, 20, "职工账号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@单位编号", System.Data.SqlDbType.VarChar, 20, "单位编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 100, "备注"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_职员编号", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "职员编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_健康状况", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "健康状况", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出生日期", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出生日期", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_办公电话", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "办公电话", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_单位编号", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "单位编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_备注", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "备注", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名简码", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名简码", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_婚姻状况", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "婚姻状况", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_家庭电话", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "家庭电话", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_年龄", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "年龄", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_手机", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "手机", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_文化程度", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "文化程度", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_毕业学校", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "毕业学校", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_民族", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "民族", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_电子邮件地址", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "电子邮件地址", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_籍贯", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "籍贯", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_职工账号", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "职工账号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_身份证号码", System.Data.SqlDbType.VarChar, 18, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "身份证号码", System.Data.DataRowVersion.Original, null));
			// 
			// AmendStafferInfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(642, 469);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.toolBar1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "AmendStafferInfo";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "【职员信息维护】";
			this.Load += new System.EventHandler(this.AmendStafferInfo_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		//--------------------初始化窗体,读入数据------------------
		private void AmendStafferInfo_Load(object sender, System.EventArgs e)
		{
			this.sqlDataAdapter1.Fill(tempTable);
			this.dataGrid1.DataSource = tempTable.DefaultView;
			InputComboBox();//填充【单位编号】下拉列表框的下拉列表
			DataGridStateControl();
			DataBindingsFunction();
			cmAmend = (CurrencyManager) BindingContext[tempTable];
		}

		//--------------将数据显示在表格中,并设置表格参数------------------		
		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 = 1;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 DataBindingsFunction()
		{
			this.txt1.DataBindings.Add("Text",tempTable,"职员编号");
			this.txt2.DataBindings.Add("Text",tempTable,"姓名");
			this.txt3.DataBindings.Add("Text",tempTable,"姓名简码");
			this.txt4.DataBindings.Add("Text",tempTable,"出生日期");
			this.txt5.DataBindings.Add("Text",tempTable,"年龄");
			this.txt6.DataBindings.Add("Text",tempTable,"文化程度");
			this.txt7.DataBindings.Add("Text",tempTable,"毕业学校");
			this.txt8.DataBindings.Add("Text",tempTable,"健康状况");
			this.txt9.DataBindings.Add("Text",tempTable,"婚姻状况");
			this.txt10.DataBindings.Add("Text",tempTable,"身份证号码");
			this.txt11.DataBindings.Add("Text",tempTable,"家庭电话");
			this.txt12.DataBindings.Add("Text",tempTable,"办公电话");
			this.txt13.DataBindings.Add("Text",tempTable,"手机");
			this.txt14.DataBindings.Add("Text",tempTable,"电子邮件地址");
			this.txt15.DataBindings.Add("Text",tempTable,"职工账号");
			this.txt16.DataBindings.Add("Text",tempTable,"备注");

			this.cmb1.DataBindings.Add("Text",tempTable,"性别");
			this.cmb2.DataBindings.Add("Text",tempTable,"民族");
			this.cmb3.DataBindings.Add("Text",tempTable,"籍贯");
			this.cmb4.DataBindings.Add("Text",tempTable,"单位编号");
		}

		//-----------为【单位编号】下拉列表框设置下拉数据辞典---------------
		private void InputComboBox()
		{
			this.strSQL = "select 单位编号 from 组织机构编码表 order by 单位编号";
			this.da =  new SqlDataAdapter(this.strSQL,this.tempConnection);
			this.da.Fill(tblDataSource);
			for (int i=0;i<tblDataSource.Rows.Count;i++)
				this.cmb4.Items.Add(tblDataSource.Rows[i][0]);
			
		}
		//-----------处理数据导航按钮与新增修改等事务---------------
		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if (e.Button.ToolTipText == "首记录")
			{
				this.dataGrid1.UnSelect(cmAmend.Position); //取消选中指定行
				cmAmend.Position = 0;
				this.dataGrid1.Select(cmAmend.Position);       //选中指定行
				this.dataGrid1.CurrentRowIndex = cmAmend.Position; //移动表头指示图标
				return;
			}
			if (e.Button.ToolTipText == "上一记录")
			{
				if (cmAmend.Position > 0)
				{
					this.dataGrid1.UnSelect(cmAmend.Position); 
					cmAmend.Position--;
					this.dataGrid1.Select(cmAmend.Position);      
					this.dataGrid1.CurrentRowIndex = cmAmend.Position; 
				}
				return;
			}
			if (e.Button.ToolTipText == "下一记录")
			{
				if (cmAmend.Position < cmAmend.Count-1)
				{
					this.dataGrid1.UnSelect(cmAmend.Position); 
					cmAmend.Position++;
					this.dataGrid1.Select(cmAmend.Position);       
					this.dataGrid1.CurrentRowIndex = cmAmend.Position; 
				}
				return;
			}
			if (e.Button.ToolTipText == "尾记录")
			{
				this.dataGrid1.UnSelect(cmAmend.Position); 
				cmAmend.Position = cmAmend.Count-1;
				this.dataGrid1.Select(cmAmend.Position);       
				this.dataGrid1.CurrentRowIndex = cmAmend.Position; 
				return;
			}
			if (e.Button.ToolTipText == "新增记录")
			{
				cmAmend.AddNew();
				return;
			}
			if (e.Button.ToolTipText == "删除记录")
			{
				if (MessageBox.Show("      确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo) == DialogResult.Yes)
				{
					try
					{
						if (cmAmend.Count > 0)
							cmAmend.RemoveAt(cmAmend.Position);
						else
						{
							MessageBox.Show("没有可以删除的数据","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						}
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					}
					return;
				}
			}
			if (e.Button.ToolTipText == "提交修改")
			{
				if (this.txt1.Text.Trim() == "")//检查不能为空的字段
				{
					MessageBox.Show("职员编号不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
				if (this.txt2.Text.Trim()=="")
				{
					MessageBox.Show("职员姓名不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
				cmAmend.EndCurrentEdit();//结束当前编辑操作并提交修改
				if (tempTable.GetChanges() != null)
				{
					try
					{
						this.sqlDataAdapter1.Update(tempTable);
					}
					catch(Exception express)
					{
						MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						this.tempTable.RejectChanges();
					}
					
				}
				return;		
			}
			if (e.Button.ToolTipText == "取消修改")
			{
				try
				{
					cmAmend.CancelCurrentEdit();  //取消编辑
				}
				catch(Exception express)
				{
					MessageBox.Show(express.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
				return;
			}
			if (e.Button.ToolTipText == "退出")
			{
				this.Close();
			}
		}

		//---------在【机构编码】下拉列表框右边的文本框中显示与之对应的机构名称-------
		private void cmb4_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			DataTable tempTable = new DataTable();
			string strSearchWord = this.cmb4.Text.Trim();
			this.strSQL = "select 单位名称 from 组织机构编码表 where 单位编号 = '" + strSearchWord + "'";
			this.da = new SqlDataAdapter(this.strSQL,this.tempConnection);
			this.da.Fill(tempTable);//查询获得机构的单位名称,并填写到文本框中
			if (tempTable.Rows.Count>0)
			{
				this.txt17.Text = tempTable.Rows[0][0].ToString().Trim();
				this.cmb4.SelectAll();
			}
		}



		//-------------------选择表格中的任何一个单元,等同于选中一行----------------
		private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
		{
			if (this.tempTable.Rows.Count > 0)
			{
				int currentRowNumber = this.dataGrid1.CurrentCell.RowNumber;
				if (currentRowNumber >= 0 && currentRowNumber < cmAmend.Count)
					cmAmend.Position = currentRowNumber;	
			}
		}
	}
}

⌨️ 快捷键说明

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