📄 modifystudent.cs
字号:
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(36, 21);
this.label4.TabIndex = 31;
this.label4.Text = "族别";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ForeColor = System.Drawing.SystemColors.ControlText;
this.label3.Location = new System.Drawing.Point(44, 123);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(36, 21);
this.label3.TabIndex = 30;
this.label3.Text = "性别";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(44, 82);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(36, 21);
this.label2.TabIndex = 29;
this.label2.Text = "姓名";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(44, 51);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(36, 21);
this.label1.TabIndex = 28;
this.label1.Text = "学号";
//
// comboBox4
//
this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox4.Enabled = false;
this.comboBox4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox4.ForeColor = System.Drawing.SystemColors.ControlText;
this.comboBox4.Location = new System.Drawing.Point(417, 206);
this.comboBox4.Name = "comboBox4";
this.comboBox4.Size = new System.Drawing.Size(171, 23);
this.comboBox4.TabIndex = 51;
//
// comboBox3
//
this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox3.Enabled = false;
this.comboBox3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox3.ForeColor = System.Drawing.SystemColors.ControlText;
this.comboBox3.Location = new System.Drawing.Point(417, 165);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(171, 23);
this.comboBox3.TabIndex = 50;
this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox2.ForeColor = System.Drawing.SystemColors.ControlText;
this.comboBox2.Items.AddRange(new object[] {
"党员",
"团员",
"群众"});
this.comboBox2.Location = new System.Drawing.Point(417, 82);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(96, 23);
this.comboBox2.TabIndex = 49;
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.comboBox1.ForeColor = System.Drawing.SystemColors.ControlText;
this.comboBox1.Items.AddRange(new object[] {
"男",
"女"});
this.comboBox1.Location = new System.Drawing.Point(108, 123);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(96, 23);
this.comboBox1.TabIndex = 48;
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
this.button2.Location = new System.Drawing.Point(416, 350);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 31);
this.button2.TabIndex = 46;
this.button2.Text = "取消";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
this.button1.Location = new System.Drawing.Point(117, 350);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 31);
this.button1.TabIndex = 45;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label13
//
this.label13.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label13.ForeColor = System.Drawing.SystemColors.ControlText;
this.label13.Location = new System.Drawing.Point(43, 10);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(74, 21);
this.label13.TabIndex = 53;
this.label13.Text = "zymc";
this.label13.Visible = false;
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = "Data Source=xsxxdb.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet." +
"OLEDB.4.0;";
//
// label14
//
this.label14.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label14.ForeColor = System.Drawing.SystemColors.ControlText;
this.label14.Location = new System.Drawing.Point(160, 10);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(64, 21);
this.label14.TabIndex = 54;
this.label14.Text = "bjmc";
this.label14.Visible = false;
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.pictureBox1.Location = new System.Drawing.Point(496, 240);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(88, 96);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 56;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// label15
//
this.label15.AutoSize = true;
this.label15.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label15.ForeColor = System.Drawing.SystemColors.ControlText;
this.label15.Location = new System.Drawing.Point(456, 248);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(36, 21);
this.label15.TabIndex = 55;
this.label15.Text = "照片";
//
// ModifyStudent
//
this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
this.ClientSize = new System.Drawing.Size(618, 397);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label15);
this.Controls.Add(this.label14);
this.Controls.Add(this.label13);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.textBox10);
this.Controls.Add(this.textBox8);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBox4);
this.Controls.Add(this.comboBox3);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "ModifyStudent";
this.Text = "修改学生信息";
this.Load += new System.EventHandler(this.ModifyStudent_Load);
this.ResumeLayout(false);
}
#endregion
private void ModifyStudent_Load(object sender, System.EventArgs e)
{
//this.Text=this.Tag.ToString();
oleDbConnection1.Open();
OleDbDataAdapter adp=new OleDbDataAdapter("select SpecialtyName from SpecialtyInfo",oleDbConnection1);
DataSet ds=new DataSet();
adp.Fill(ds,"specialty");
comboBox3.DisplayMember="SpecialtyName";
comboBox3.ValueMember="SpecialtyName";
comboBox3.DataSource=ds.Tables[0].DefaultView;
comboBox3.Text=label13.Text.Trim();
oleDbConnection1.Close();
oleDbConnection1.Open();
string sql="select photo from StudentInfo where StudentId="+this.Tag.ToString();
OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
if (Convert.DBNull!=cmd.ExecuteScalar())
pictureBox1.Image=Image.FromStream(new MemoryStream((Byte[])cmd.ExecuteScalar()));
}
private void comboBox3_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (comboBox3.Text.Trim()!="")
{
OleDbDataAdapter adp=new OleDbDataAdapter("select ClassId,ClassName from ClassInfo where SpecialtyName='"+comboBox3.Text.Trim()+"'",oleDbConnection1);
DataSet ds=new DataSet();
adp.Fill(ds,"Class");
comboBox4.DisplayMember="ClassName";
comboBox4.ValueMember="ClassId";
comboBox4.DataSource=ds.Tables[0].DefaultView;
comboBox4.Text=label14.Text.Trim();
}
}
private Byte[] getphoto(string photopath)
{
string str=photopath;
FileStream file = new FileStream(str,FileMode.Open, FileAccess.Read);
Byte[] bytBLOBData = new Byte[file.Length];
file.Read(bytBLOBData, 0, bytBLOBData.Length);
file.Close();
return bytBLOBData;
}
private void button1_Click(object sender, System.EventArgs e)
{
if (textBox1.Text.Trim()=="" || textBox2.Text.Trim()=="" || comboBox1.Text.Trim()=="" || textBox4.Text.Trim()=="" || textBox5.Text.Trim()=="" || textBox6.Text.Trim()=="" || comboBox2.Text.Trim()=="" || textBox8.Text.Trim()=="" || comboBox4.Text.Trim()=="")
MessageBox.Show("请填写完整的学生信息","提示");
else
{ string sql;
sql="select * from StudentInfo where StudentNumber='"+textBox1.Text.Trim()+"' and StudentId<>"+this.Tag.ToString().Trim();
OleDbCommand cmd=new OleDbCommand(sql,oleDbConnection1);
if (null!=cmd.ExecuteScalar())
MessageBox.Show("学生学号重复","提示");
else
{
sql="update StudentInfo set StudentNumber='"+textBox1.Text.ToString()+"',Name='"+textBox2.Text.ToString()+"',Sex='"+comboBox1.Text.Trim()+"',Race='"+textBox4.Text.ToString()+"',Address='"+textBox5.Text.ToString()+"',Telephone='"+textBox6.Text.ToString()+"',Role='"+comboBox2.Text.Trim()+"',PostalCode='"+textBox8.Text.ToString()+"',ClassId="+comboBox4.SelectedValue.ToString();
if (textBox10.Text.Trim()!="")
sql=sql+",Remark='"+textBox10.Text.Trim()+"'";
if (openFileDialog1.FileName!="")
{
sql=sql+",Photo=?";
Byte[] bytBLOBData=getphoto(openFileDialog1.FileName);
cmd.Parameters.Add(new OleDbParameter("jpeg",OleDbType.Binary,bytBLOBData.Length,ParameterDirection.Input,true,0,0,null,DataRowVersion.Default,bytBLOBData));
}
sql=sql+" where StudentId="+this.Tag.ToString().Trim();
cmd.CommandText=sql;
cmd.ExecuteNonQuery();
MessageBox.Show("学生信息修改成功","提示");
}
}
}
private void pictureBox1_Click(object sender, System.EventArgs e)
{
openFileDialog1.Filter="bmp|*.bmp|gif|*.gif|jpg|*jpg|jpeg|*.jpeg|ico|*.ico";
openFileDialog1.ShowDialog();
if (openFileDialog1.FileName!="")
this.pictureBox1.Image=Image.FromFile(openFileDialog1.FileName);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -