📄 修改用户.cs
字号:
this.groupBox1.TabStop = false;
this.groupBox1.Text = "个人详细信息";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.radioButton2);
this.groupBox2.Controls.Add(this.radioButton1);
this.groupBox2.Location = new System.Drawing.Point(16, 112);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(216, 72);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "性别";
//
// radioButton2
//
this.radioButton2.CausesValidation = false;
this.radioButton2.Location = new System.Drawing.Point(128, 32);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(40, 24);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "女";
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(32, 32);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(40, 24);
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "男";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(80, 24);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(136, 23);
this.textBox3.TabIndex = 1;
this.textBox3.Text = "";
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 24);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 24);
this.label5.TabIndex = 0;
this.label5.Text = "姓名:";
//
// label6
//
this.label6.Location = new System.Drawing.Point(248, 24);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(56, 24);
this.label6.TabIndex = 0;
this.label6.Text = "地址:";
//
// label7
//
this.label7.Location = new System.Drawing.Point(248, 72);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(80, 24);
this.label7.TabIndex = 0;
this.label7.Text = "电子邮件:";
//
// label8
//
this.label8.Location = new System.Drawing.Point(16, 72);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(56, 24);
this.label8.TabIndex = 0;
this.label8.Text = "电话:";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(328, 24);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(136, 23);
this.textBox4.TabIndex = 1;
this.textBox4.Text = "";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(80, 72);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(136, 23);
this.textBox5.TabIndex = 1;
this.textBox5.Text = "";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(328, 64);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(136, 23);
this.textBox6.TabIndex = 1;
this.textBox6.Text = "";
//
// groupBox3
//
this.groupBox3.Controls.Add(this.radioButton4);
this.groupBox3.Controls.Add(this.radioButton3);
this.groupBox3.Location = new System.Drawing.Point(256, 112);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(216, 72);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "状态";
//
// radioButton4
//
this.radioButton4.CausesValidation = false;
this.radioButton4.Location = new System.Drawing.Point(128, 24);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(80, 40);
this.radioButton4.TabIndex = 1;
this.radioButton4.Text = "非活动";
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(8, 24);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(72, 40);
this.radioButton3.TabIndex = 0;
this.radioButton3.Text = "活动";
//
// xugaiyonghu
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(736, 480);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.button2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "xugaiyonghu";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "修改用户";
this.Load += new System.EventHandler(this.xugaiyonghu_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void xugaiyonghu_Load(object sender, System.EventArgs e)
{
this.comboBox1.SelectedIndex=0;
OleDbConnection conobj=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"+@"Data Source=hua.mdb");
string str="Select * from ws where name='"+user+"'and lx='"+leixing+"'and zhuangtai='"+zhuangtai+"'";
OleDbCommand cmd=new OleDbCommand(str,conobj);
conobj.Open();
OleDbDataReader dr=null;
dr=cmd.ExecuteReader();
dr.Read();
this.textBox1.Text=dr["name"].ToString();
this.textBox2.Text=dr["ps"].ToString();
this.comboBox1.Text=dr["lx"].ToString();
this.textBox3.Text=dr["name1"].ToString();
this.textBox4.Text=dr["dizhi"].ToString();
this.textBox5.Text=dr["dianhua"].ToString();
this.textBox6.Text=dr["youjie"].ToString();
if(dr["xingbie"].ToString()=="男")
{
this.radioButton1.Checked=true;
}
else
{
this.radioButton2.Checked=true;
}
if(dr["zhuangtai"].ToString()=="活动")
{
this.radioButton3.Checked=true;
}
else
{
this.radioButton4.Checked=true;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Hide();
}
string ser,xingtai;
private void button1_Click(object sender, System.EventArgs e)
{
if(this.radioButton1.Checked)
{
ser=this.radioButton1.Text;
}
if(this.radioButton2.Checked)
{
ser=this.radioButton2.Text;
}
if(this.radioButton3.Checked)
{
xingtai=this.radioButton3.Text;
}
if(this.radioButton4.Checked)
{
xingtai=this.radioButton4.Text;
}
string stl="Provider=Microsoft.Jet.OLEDB.4.0;Data source=hua.mdb";
OleDbConnection con=new OleDbConnection(stl);
con.Open();
string str="update ws set name='"+this.textBox1.Text+"',ps='"+this.textBox2.Text+"',lx='"+this.comboBox1.Text+"',name1='"+this.textBox3.Text+"',dizhi='"+this.textBox4.Text+"',dianhua='"+this.textBox5.Text+"',youjie='"+this.textBox6.Text+"',xingbie='"+ser+"',zhuangtai='"+xingtai+"' where name='"+user+"'and lx='"+leixing+"'and zhuangtai='"+zhuangtai+"'";
OleDbCommand an=new OleDbCommand(str,con);
an.ExecuteNonQuery();
MessageBox.Show("修改成功","信息");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -