📄 frmuser.cs
字号:
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// label3
//
this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label3.Location = new System.Drawing.Point(184, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 24);
this.label3.TabIndex = 2;
this.label3.Text = "确认密码";
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label2.Location = new System.Drawing.Point(16, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(104, 24);
this.label2.TabIndex = 1;
this.label2.Text = "密码";
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label1.Location = new System.Drawing.Point(16, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 24);
this.label1.TabIndex = 0;
this.label1.Text = "帐号";
//
// tabPage2
//
this.tabPage2.Controls.Add(this.textBox10);
this.tabPage2.Controls.Add(this.button6);
this.tabPage2.Controls.Add(this.button5);
this.tabPage2.Controls.Add(this.groupBox1);
this.tabPage2.Controls.Add(this.button4);
this.tabPage2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.tabPage2.Location = new System.Drawing.Point(4, 23);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(384, 221);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "删除管理员";
//
// textBox10
//
this.textBox10.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox10.Location = new System.Drawing.Point(80, 136);
this.textBox10.Name = "textBox10";
this.textBox10.Size = new System.Drawing.Size(96, 23);
this.textBox10.TabIndex = 18;
this.textBox10.Text = "";
this.textBox10.Visible = false;
//
// button6
//
this.button6.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button6.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button6.Location = new System.Drawing.Point(272, 168);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(88, 24);
this.button6.TabIndex = 3;
this.button6.Text = "撤消";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button5
//
this.button5.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button5.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button5.Location = new System.Drawing.Point(176, 168);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(88, 24);
this.button5.TabIndex = 2;
this.button5.Text = "提交";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox4);
this.groupBox1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.groupBox1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.groupBox1.Location = new System.Drawing.Point(24, 32);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(336, 88);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "请输入你要删除的管理员帐号";
//
// textBox4
//
this.textBox4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox4.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.textBox4.Location = new System.Drawing.Point(40, 40);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(200, 23);
this.textBox4.TabIndex = 0;
this.textBox4.Text = "";
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button4.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button4.Location = new System.Drawing.Point(80, 168);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(88, 24);
this.button4.TabIndex = 0;
this.button4.Text = "重置";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// frmuser
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(408, 262);
this.Controls.Add(this.tabControl1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(416, 296);
this.MinimumSize = new System.Drawing.Size(416, 296);
this.Name = "frmuser";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "操作员管理";
this.Load += new System.EventHandler(this.frmuser_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void tabPage1_Click(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
this.textBox1.Clear();
this.textBox2.Clear();
this.textBox3.Clear();
this.textBox5.Clear();
this.textBox6.Clear();
this.textBox7.Clear();
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void frmuser_Load(object sender, System.EventArgs e)
{
objSqlConn=new SqlConnection("database=atorregulate;uid=sa;password=;SERVER=(local)");
objSqlConn.Open();
objSqlDataAdapter=new SqlDataAdapter();
objSqlDataAdapter.SelectCommand=new SqlCommand("select*from adminuser",objSqlConn);
objDataSet=new DataSet();
objSqlDataAdapter.Fill(objDataSet,"adminuser");
//播入命令
string insCmd="Insert into adminuser values (@Auid,@Aname,@Aclass,@Apassword,@AIDcard,@Aremark)";
//实例化insertCommand
this.objSqlDataAdapter.InsertCommand=new SqlCommand(insCmd,this.objSqlConn);
//设置播入参数
objParam=objSqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@Auid",System.Data.SqlDbType.VarChar,50));
objParam.SourceColumn="Auid";
objParam.SourceVersion=DataRowVersion.Current;
objParam=objSqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@Aname",System.Data.SqlDbType.VarChar,50));
objParam.SourceColumn="Aname";
objParam.SourceVersion=DataRowVersion.Current;
objParam=objSqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@Aclass",System.Data.SqlDbType.VarChar,50));
objParam.SourceColumn="Aclass";
objParam.SourceVersion=DataRowVersion.Current;
objParam=objSqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@Apassword",System.Data.SqlDbType.VarChar,50));
objParam.SourceColumn="Apassword";
objParam.SourceVersion=DataRowVersion.Current;
objParam=objSqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@AIDcard",System.Data.SqlDbType.VarChar,50));
objParam.SourceColumn="AIDcard";
objParam.SourceVersion=DataRowVersion.Current;
objParam=objSqlDataAdapter.InsertCommand.Parameters.Add(new SqlParameter("@Aremark",System.Data.SqlDbType.VarChar,50));
objParam.SourceColumn="Aremark";
objParam.SourceVersion=DataRowVersion.Current;
this.textBox9.Text=username;
this.textBox10.Text=username;
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
if(this.textBox1.Text!=String.Empty && this.textBox2.Text!=String.Empty && this.textBox3.Text!=String.Empty && this.textBox5.Text!=String.Empty && this.textBox6.Text!=String.Empty)
{
if(this.textBox2.Text==this.textBox3.Text)
{
if(this.textBox5.Text.Length==18)
{
DataRow objDataRow=objDataSet.Tables["adminuser"].NewRow();
objDataRow["Auid"]=this.textBox1.Text;
objDataRow["Aname"]=this.textBox6.Text;
objDataRow["Aclass"]=this.textBox8.Text;
objDataRow["Apassword"]=this.textBox2.Text;
objDataRow["AIDcard"]=this.textBox5.Text;
objDataRow["Aremark"]=this.textBox7.Text;
objDataSet.Tables["adminuser"].Rows.Add(objDataRow);
objDataSet.HasChanges(DataRowState.Added);
objSqlDataAdapter.Update(objDataSet,"adminuser");
MessageBox.Show("已成功添加管理员,此次加入的管理员帐号为 "+this.textBox1.Text+".."+"请记住密码 "+this.textBox2.Text+"...","服务器确认");
this.textBox1.Clear();
this.textBox2.Clear();
this.textBox3.Clear();
this.textBox5.Clear();
this.textBox6.Clear();
this.textBox7.Clear();
this.textBox8.Clear();
}
else
MessageBox.Show("请输入18位的身份证号码!","服务器拒绝");
}
else
MessageBox.Show("两次密码输入要一致!","服务器拒绝");
}
else
MessageBox.Show("请输入完整信息!","服务器拒绝");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
private void button4_Click(object sender, System.EventArgs e)
{
this.textBox4.Clear();
}
private void button6_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button5_Click(object sender, System.EventArgs e)
{
try
{
objSqlConn=new SqlConnection("database=atorregulate;uid=sa;password=;SERVER=(local)");
if(this.textBox4.Text==String.Empty)
{
MessageBox.Show("尚未输入可以修改信息!","服务器拒绝");
}
else
{
DialogResult objDialogResult = MessageBox.Show("确定删除此记录?","确认",MessageBoxButtons.YesNo);
if(objDialogResult.Equals(DialogResult.Yes))
{
objSqlConn.Open();
string sql="select count(*) from adminuser where Auid like '"+this.textBox4.Text+"'";
objSqlCmd=new SqlCommand (sql,objSqlConn);
int flag=(int)objSqlCmd.ExecuteScalar();
objSqlConn.Close();
if(flag>0)
{
string delCmd = "delete from adminuser where Auid like '"+textBox4.Text.ToString().Trim()+"'";
string path=Application.ExecutablePath;
this.objSqlConn.Open();
this.objSqlCmd = new SqlCommand(delCmd,objSqlConn);
this.objSqlCmd.ExecuteNonQuery();
this.textBox4.Clear();
MessageBox.Show("删除成功","服务器确认");
}
else
MessageBox.Show("此用户不存在!","服务器拒绝");
}
}
}
catch(SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
this.objSqlConn.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -