frmworker.cs

来自「小区物业管理:管理小区的费用、小区工作人员的编排和工资管理、小区的运作、对住户资」· CS 代码 · 共 1,005 行 · 第 1/3 页

CS
1,005
字号
			this.tabPage1.Controls.Add(this.cbotime);
			this.tabPage1.Controls.Add(this.btn);
			this.tabPage1.Controls.Add(this.btnRe);
			this.tabPage1.Controls.Add(this.btnaddwo);
			this.tabPage1.Controls.Add(this.lbltime);
			this.tabPage1.Controls.Add(this.txtaddress);
			this.tabPage1.Controls.Add(this.lbladdress);
			this.tabPage1.Controls.Add(this.txtIDcard);
			this.tabPage1.Controls.Add(this.lblIDcard);
			this.tabPage1.Controls.Add(this.cbocarcor);
			this.tabPage1.Controls.Add(this.lblcarcor);
			this.tabPage1.Controls.Add(this.txtname);
			this.tabPage1.Controls.Add(this.lblname);
			this.tabPage1.Controls.Add(this.txtID);
			this.tabPage1.Controls.Add(this.lblID);
			this.tabPage1.Location = new System.Drawing.Point(4, 21);
			this.tabPage1.Name = "tabPage1";
			this.tabPage1.Size = new System.Drawing.Size(568, 167);
			this.tabPage1.TabIndex = 0;
			this.tabPage1.Text = "插入员工记录";
			// 
			// cbotime
			// 
			this.cbotime.Items.AddRange(new object[] {
														 "日间",
														 "夜间"});
			this.cbotime.Location = new System.Drawing.Point(384, 88);
			this.cbotime.Name = "cbotime";
			this.cbotime.Size = new System.Drawing.Size(152, 20);
			this.cbotime.TabIndex = 30;
			this.cbotime.Text = "日间";
			// 
			// btn
			// 
			this.btn.Location = new System.Drawing.Point(479, 136);
			this.btn.Name = "btn";
			this.btn.TabIndex = 29;
			this.btn.Text = "返回";
			this.btn.Click += new System.EventHandler(this.btn_Click);
			// 
			// btnRe
			// 
			this.btnRe.Location = new System.Drawing.Point(383, 136);
			this.btnRe.Name = "btnRe";
			this.btnRe.TabIndex = 28;
			this.btnRe.Text = "重置";
			this.btnRe.Click += new System.EventHandler(this.btnRe_Click);
			// 
			// btnaddwo
			// 
			this.btnaddwo.Location = new System.Drawing.Point(287, 136);
			this.btnaddwo.Name = "btnaddwo";
			this.btnaddwo.TabIndex = 27;
			this.btnaddwo.Text = "插入";
			this.btnaddwo.Click += new System.EventHandler(this.btnaddwo_Click);
			// 
			// lbltime
			// 
			this.lbltime.Location = new System.Drawing.Point(287, 88);
			this.lbltime.Name = "lbltime";
			this.lbltime.Size = new System.Drawing.Size(80, 23);
			this.lbltime.TabIndex = 25;
			this.lbltime.Text = "工作时段:";
			// 
			// txtaddress
			// 
			this.txtaddress.Location = new System.Drawing.Point(111, 88);
			this.txtaddress.Name = "txtaddress";
			this.txtaddress.Size = new System.Drawing.Size(136, 21);
			this.txtaddress.TabIndex = 24;
			this.txtaddress.Text = "";
			// 
			// lbladdress
			// 
			this.lbladdress.Location = new System.Drawing.Point(15, 88);
			this.lbladdress.Name = "lbladdress";
			this.lbladdress.Size = new System.Drawing.Size(80, 23);
			this.lbladdress.TabIndex = 23;
			this.lbladdress.Text = "员工籍贯:";
			// 
			// txtIDcard
			// 
			this.txtIDcard.Location = new System.Drawing.Point(383, 48);
			this.txtIDcard.Name = "txtIDcard";
			this.txtIDcard.Size = new System.Drawing.Size(152, 21);
			this.txtIDcard.TabIndex = 22;
			this.txtIDcard.Text = "";
			this.txtIDcard.Leave += new System.EventHandler(this.txtIDcard_Leave);
			// 
			// lblIDcard
			// 
			this.lblIDcard.Location = new System.Drawing.Point(287, 40);
			this.lblIDcard.Name = "lblIDcard";
			this.lblIDcard.Size = new System.Drawing.Size(80, 23);
			this.lblIDcard.TabIndex = 21;
			this.lblIDcard.Text = "员工身份证:";
			// 
			// cbocarcor
			// 
			this.cbocarcor.Items.AddRange(new object[] {
														   "会计",
														   "园丁",
														   "清洁工",
														   "保安",
														   "维修工",
														   "文计",
														   "客服"});
			this.cbocarcor.Location = new System.Drawing.Point(111, 48);
			this.cbocarcor.Name = "cbocarcor";
			this.cbocarcor.Size = new System.Drawing.Size(136, 20);
			this.cbocarcor.TabIndex = 20;
			this.cbocarcor.Text = "会计";
			// 
			// lblcarcor
			// 
			this.lblcarcor.Location = new System.Drawing.Point(15, 48);
			this.lblcarcor.Name = "lblcarcor";
			this.lblcarcor.Size = new System.Drawing.Size(80, 23);
			this.lblcarcor.TabIndex = 19;
			this.lblcarcor.Text = "员工职位:";
			// 
			// txtname
			// 
			this.txtname.Location = new System.Drawing.Point(383, 8);
			this.txtname.Name = "txtname";
			this.txtname.Size = new System.Drawing.Size(152, 21);
			this.txtname.TabIndex = 18;
			this.txtname.Text = "";
			// 
			// lblname
			// 
			this.lblname.Location = new System.Drawing.Point(287, 8);
			this.lblname.Name = "lblname";
			this.lblname.Size = new System.Drawing.Size(80, 23);
			this.lblname.TabIndex = 17;
			this.lblname.Text = "员工姓名:";
			// 
			// txtID
			// 
			this.txtID.Location = new System.Drawing.Point(111, 8);
			this.txtID.Name = "txtID";
			this.txtID.Size = new System.Drawing.Size(136, 21);
			this.txtID.TabIndex = 16;
			this.txtID.Text = "";
			// 
			// lblID
			// 
			this.lblID.Location = new System.Drawing.Point(15, 8);
			this.lblID.Name = "lblID";
			this.lblID.Size = new System.Drawing.Size(80, 23);
			this.lblID.TabIndex = 15;
			this.lblID.Text = "员工编号:";
			// 
			// tabPage2
			// 
			this.tabPage2.Controls.Add(this.btnDEit);
			this.tabPage2.Controls.Add(this.btnDel1);
			this.tabPage2.Controls.Add(this.txtDID);
			this.tabPage2.Controls.Add(this.lblDID);
			this.tabPage2.Location = new System.Drawing.Point(4, 21);
			this.tabPage2.Name = "tabPage2";
			this.tabPage2.Size = new System.Drawing.Size(568, 167);
			this.tabPage2.TabIndex = 1;
			this.tabPage2.Text = "删除员工记录";
			// 
			// btnDEit
			// 
			this.btnDEit.Location = new System.Drawing.Point(368, 16);
			this.btnDEit.Name = "btnDEit";
			this.btnDEit.TabIndex = 6;
			this.btnDEit.Text = "返回";
			this.btnDEit.Click += new System.EventHandler(this.btnDEit_Click);
			// 
			// btnDel1
			// 
			this.btnDel1.Location = new System.Drawing.Point(272, 16);
			this.btnDel1.Name = "btnDel1";
			this.btnDel1.TabIndex = 4;
			this.btnDel1.Text = "删除";
			this.btnDel1.Click += new System.EventHandler(this.btnDel1_Click);
			// 
			// txtDID
			// 
			this.txtDID.Location = new System.Drawing.Point(104, 16);
			this.txtDID.Name = "txtDID";
			this.txtDID.Size = new System.Drawing.Size(144, 21);
			this.txtDID.TabIndex = 1;
			this.txtDID.Text = "";
			// 
			// lblDID
			// 
			this.lblDID.Location = new System.Drawing.Point(24, 16);
			this.lblDID.Name = "lblDID";
			this.lblDID.Size = new System.Drawing.Size(72, 23);
			this.lblDID.TabIndex = 0;
			this.lblDID.Text = "员工编号:";
			// 
			// frmworker
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(7, 14);
			this.ClientSize = new System.Drawing.Size(592, 334);
			this.Controls.Add(this.btnPrintprv);
			this.Controls.Add(this.btnPrint);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.grpfind);
			this.Controls.Add(this.tabControl1);
			this.Controls.Add(this.dbgworker);
			this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.ForeColor = System.Drawing.SystemColors.ActiveCaption;
			this.Name = "frmworker";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "员工资料";
			this.Load += new System.EventHandler(this.frmworker_Load);
			this.grpfind.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dbgworker)).EndInit();
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			this.tabPage2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>


		private void frmworker_Load(object sender, System.EventArgs e)
		{
			objSqlConnection=new SqlConnection ("database=atorregulate;uid=sa;pwd=;SERVER=(local)");
			objSqlConnection.Open ();
			objSqlDataAdapter=new SqlDataAdapter ();
			objSqlDataAdapter.SelectCommand =new SqlCommand ("select Wnumber as 员工编号,Wname as 员工姓名,Wcarcor as 员工职位,Wtime as 工作时段,WIDcard as 身份证号码,Waddress as 家庭地址 from worker",objSqlConnection);
			objDataSet=new DataSet ();
			objSqlDataAdapter.Fill (objDataSet,"worker");

			//将DataSet控制定到数据集
			this.dbgworker .SetDataBinding (objDataSet,"worker");
			//dbgworker.DataSource =objDataSet.Tables [0].DefaultView ;

			//定义插入命令
			string insCmd="Insert into worker values (@Wnumber,@Wname,@Wcarcor,@Wtime,@WIDcard,@Waddress)";

			//实例化InsertCommand
			this.objSqlDataAdapter .InsertCommand =new SqlCommand (insCmd,this.objSqlConnection );

			//设置插入命令参数
			objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new SqlParameter  ("@Wnumber",System.Data .SqlDbType .Int ));
			objParam.SourceColumn ="员工编号";
			objParam.SourceVersion =DataRowVersion.Current ;
			objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Wname",System.Data .SqlDbType.Char  ));
			objParam.SourceColumn ="员工姓名";
			objParam.SourceVersion =DataRowVersion.Current ;
			objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Wcarcor",System.Data .SqlDbType .VarChar ));
			objParam.SourceColumn ="员工职位";
			objParam.SourceVersion =DataRowVersion.Current ;
			objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Wtime",System.Data .SqlDbType .Char ));
			objParam.SourceColumn ="工作时段";
			objParam.SourceVersion =DataRowVersion.Current ;
			objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@WIDcard",System.Data .SqlDbType .VarChar));
			objParam.SourceColumn ="身份证号码";
			objParam.SourceVersion =DataRowVersion.Current ;
			objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Waddress",System.Data .SqlDbType .VarChar ));
			objParam.SourceColumn ="家庭地址";
			objParam.SourceVersion =DataRowVersion.Current ;
		}

		//验证插入记录的单个控件
		private bool ValidateFields()
		{
			bool returnValue=true;
			//检查有无空的员工编号
			if (this.txtID .Text .Trim ()==String.Empty||this.txtIDcard .Text .Trim ()==String.Empty ||this.txtaddress .Text .Trim ()==String.Empty  )
			{
				MessageBox.Show ("提供完整的详细信息","服务器拒绝");
				this.txtID .Focus ();
				return false;
			}
			else
			{
				for(int i=0;i<this.txtname .Text .Length ;i++)
				{
					if(Char.IsNumber (txtname.Text .ToString (),i))
					{
						MessageBox.Show ("员工姓名不能为数字","服务器拒绝");
						this.txtname .Focus ();
						returnValue=false;
						break;
					}
				}
			}
			return returnValue;
		}

		private void btnAdd_Click(object sender, System.EventArgs e)
		{
            this.tabControl1 .Visible =true;
			this.btnAdd .Enabled =false;
			this.btnPrint .Enabled =false;
			this.btnPrintprv .Enabled =false;
		}

		private void btnExid_Click(object sender, System.EventArgs e)
		{
			this.Close ();
		}


		private void btnRu_Click(object sender, System.EventArgs e)
		{
			
			this.dbgworker .Enabled =true;
			objSqlConnection=new SqlConnection ("database=atorregulate;uid=sa;pwd=;SERVER=(local)");
			objSqlConnection.Open ();
			objSqlDataAdapter=new SqlDataAdapter ();
			objSqlDataAdapter.SelectCommand =new SqlCommand ("select Wnumber as 员工编号,Wname as 员工姓名,Wcarcor as 员工职位,Wtime as 工作时段,WIDcard as 身份证号码,Waddress as 家庭地址 from worker",objSqlConnection);
			objDataSet=new DataSet ();
			objSqlDataAdapter.Fill (objDataSet,"worker");
			this.dbgworker .SetDataBinding (objDataSet,"worker");
			this.dbgworker .Enabled =false;
		}

		private void btnPrint_Click(object sender, System.EventArgs e)
		{
			if(this.printworker .ShowDialog ()==DialogResult.OK )
			{
				this.pdocworker .Print ();
			}
		}

		private void pdocworker_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{
			Font objFont=new Font ("Tahoma",11,FontStyle.Regular );

⌨️ 快捷键说明

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