frmuserdatrm.cs
来自「小区物业管理:管理小区的费用、小区工作人员的编排和工资管理、小区的运作、对住户资」· CS 代码 · 共 1,011 行 · 第 1/3 页
CS
1,011 行
this.tabPage1.Controls.Add(this.txttel);
this.tabPage1.Controls.Add(this.txtworkaddress);
this.tabPage1.Controls.Add(this.lblUtel);
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.lblUIDcard);
this.tabPage1.Controls.Add(this.cbocarcor);
this.tabPage1.Controls.Add(this.lblUcarcor);
this.tabPage1.Controls.Add(this.txtname);
this.tabPage1.Controls.Add(this.lblUname);
this.tabPage1.Controls.Add(this.txtID);
this.tabPage1.Controls.Add(this.lblUID);
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 = "插入住户记录";
//
// txttel
//
this.txttel.Location = new System.Drawing.Point(112, 128);
this.txttel.Name = "txttel";
this.txttel.Size = new System.Drawing.Size(136, 21);
this.txttel.TabIndex = 33;
this.txttel.Text = "";
//
// txtworkaddress
//
this.txtworkaddress.Location = new System.Drawing.Point(384, 88);
this.txtworkaddress.Name = "txtworkaddress";
this.txtworkaddress.Size = new System.Drawing.Size(152, 21);
this.txtworkaddress.TabIndex = 32;
this.txtworkaddress.Text = "";
//
// lblUtel
//
this.lblUtel.Location = new System.Drawing.Point(16, 128);
this.lblUtel.Name = "lblUtel";
this.lblUtel.Size = new System.Drawing.Size(80, 23);
this.lblUtel.TabIndex = 31;
this.lblUtel.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);
//
// lblUIDcard
//
this.lblUIDcard.Location = new System.Drawing.Point(287, 48);
this.lblUIDcard.Name = "lblUIDcard";
this.lblUIDcard.Size = new System.Drawing.Size(80, 23);
this.lblUIDcard.TabIndex = 21;
this.lblUIDcard.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 = "男";
//
// lblUcarcor
//
this.lblUcarcor.Location = new System.Drawing.Point(15, 48);
this.lblUcarcor.Name = "lblUcarcor";
this.lblUcarcor.Size = new System.Drawing.Size(80, 23);
this.lblUcarcor.TabIndex = 19;
this.lblUcarcor.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 = "";
//
// lblUname
//
this.lblUname.Location = new System.Drawing.Point(287, 8);
this.lblUname.Name = "lblUname";
this.lblUname.Size = new System.Drawing.Size(80, 23);
this.lblUname.TabIndex = 17;
this.lblUname.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 = "";
//
// lblUID
//
this.lblUID.Location = new System.Drawing.Point(15, 8);
this.lblUID.Name = "lblUID";
this.lblUID.Size = new System.Drawing.Size(80, 23);
this.lblUID.TabIndex = 15;
this.lblUID.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(264, 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 = "住户房号:";
//
// frmuserdatrm
//
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 = "frmuserdatrm";
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 Snumber as 住户房号,Susername as 住户姓名,Ssex as 住户性别,SIDcard as 身份证,Saddress as 家庭地址,Swordunit as 工作单位,Stelnumber as 联系电话 from userdatrm",objSqlConnection);
objDataSet=new DataSet ();
objSqlDataAdapter.Fill (objDataSet,"userdatrm");
//将DataSet控制定到数据集
this.dbgworker .SetDataBinding (objDataSet,"userdatrm");
//dbgworker.DataSource =objDataSet.Tables [0].DefaultView ;
//定义插入命令
string insCmd="Insert into userdatrm values (@Snumber,@Susername,@Ssex,@SIDcardas,@Saddress,@Swordunit,@Stelnumber)";
//实例化InsertCommand
this.objSqlDataAdapter .InsertCommand =new SqlCommand (insCmd,this.objSqlConnection );
//设置插入命令参数
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new SqlParameter ("@Snumber",System.Data .SqlDbType .Int ));
objParam.SourceColumn ="住户房号";
objParam.SourceVersion =DataRowVersion.Current ;
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Susername",System.Data .SqlDbType.Char ));
objParam.SourceColumn ="住户姓名";
objParam.SourceVersion =DataRowVersion.Current ;
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Ssex",System.Data .SqlDbType .Char ));
objParam.SourceColumn ="住户性别";
objParam.SourceVersion =DataRowVersion.Current ;
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@SIDcardas",System.Data .SqlDbType .VarChar ));
objParam.SourceColumn ="身份证";
objParam.SourceVersion =DataRowVersion.Current ;
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Saddress",System.Data .SqlDbType .VarChar));
objParam.SourceColumn ="家庭地址";
objParam.SourceVersion =DataRowVersion.Current ;
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Swordunit",System.Data .SqlDbType .VarChar ));
objParam.SourceColumn ="工作单位";
objParam=objSqlDataAdapter.InsertCommand .Parameters .Add (new System .Data .SqlClient .SqlParameter ("@Stelnumber",System.Data .SqlDbType .Char ));
objParam.SourceColumn ="联系电话";
objParam.SourceVersion =DataRowVersion.Current ;
}
//验证插入记录的单个控件
private bool ValidateFields()
{
bool returnValue=true;
//检查有无空的员工编号
if (this.txtID .Text .Trim ()==String.Empty||this.txtname .Text .Trim ()==String.Empty ||this.txtIDcard .Text .Trim ()==String.Empty ||this.txtaddress .Text .Trim ()==String.Empty ||this.txtworkaddress .Text .Trim ()==String.Empty||this.txttel .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 Snumber as 住户房号,Susername as 住户姓名,Ssex as 住户性别,SIDcard as 身份证,Saddress as 家庭地址,Swordunit as 工作单位,Stelnumber as 联系电话 from userdatrm",objSqlConnection);
objDataSet=new DataSet ();
objSqlDataAdapter.Fill (objDataSet,"userdatrm");
this.dbgworker .SetDataBinding (objDataSet,"userdatrm");
this.dbgworker .Enabled =false;
}
private void btnPrint_Click(object sender, System.EventArgs e)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?