private void Button3_Click(object sender, EventArgs e) { string sqlphoto = "select photo from teacher where tcode = '" + this.Tea.Tcode + "';"; SqlDataReader sqlData = Dyy.GetDataReader(sqlphoto); sqlData.Read(); this.picPath = Application.StartupPath.Replace("bin\\Debug", "") + sqlData["photo"].ToString().Replace("~", "Resources"); FileStream fs = new FileStream(this.picPath, FileMode.Open, FileAccess.Read); fs.Close(); fs.Dispose(); try { pictureBox1.Image = Image.FromStream(fs); } catch { } if (this.newPath != this.picPath && newPath != null) { File.Copy(newPath, picPath, true); MessageBox.Show("修改成功!"); } else { MessageBox.Show("对不起,修改失败!"); } }
private void PersonalInfo_Load(object sender, EventArgs e) { string s = "select * from teacher where tcode='" + Tea.Tcode + "';"; SqlDataReader sqlData = Dyy.GetDataReader(s); sqlData.Read(); this.label2.Text = sqlData["name"].ToString(); this.label4.Text = sqlData["gender"].ToString(); this.label12.Text = sqlData["tcode"].ToString(); this.label6.Text = sqlData["degree"].ToString(); this.label8.Text = sqlData["title"].ToString(); this.label10.Text = sqlData["introduction"].ToString(); //显示教师个人信息 }
private void FrmTeacher_Load(object sender, EventArgs e) { string sqlphoto = "select photo from teacher where tcode = '" + this.Tea.Tcode + "';"; SqlDataReader sqlData = Dyy.GetDataReader(sqlphoto); sqlData.Read(); string s = Application.StartupPath.Replace("bin\\Debug", "") + sqlData["photo"].ToString().Replace("~", "Resources"); FileStream fs = new FileStream(s, FileMode.Open, FileAccess.Read); pictureBox1.Image = Image.FromStream(fs); fs.Close(); fs.Dispose(); pictureBox2.Image = Image.FromFile(Application.StartupPath.Replace("bin\\Debug", "") + "Resources\\images\\teacher\\999.jpg"); }
private void Button1_Click(object sender, EventArgs e) { string strselect = " SELECT\n" + "teacher.name 姓名,\n" + "teacher.tcode 工号,\n" + "teacher.gender 性别,\n" + "teacher.degree 学位,\n" + "teacher.title 职称 \n" + "FROM\n" + "teacher\n" + "WHERE "; if (comboBox2.Text == "模糊") { if (comboBox1.Text == "工号") { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " tcode like '%" + textBox1.Text.Trim() + "%'"; } } else { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " name like '%" + textBox1.Text.Trim() + "%'"; } } } else { if (comboBox1.Text == "工号") { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " tcode = '" + textBox1.Text.Trim() + "'"; } } else { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " name = '" + textBox1.Text.Trim() + "'"; } } } if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { dataGridView1.DataSource = Dyy.GetFillData(strselect); } else { MessageBox.Show("不可为空"); textBox1.Clear(); } string intro = "select * from teacher where"; if (comboBox1.Text == "姓名") { intro += " name = '" + textBox1.Text.Trim() + "' "; } else { intro += " tcode= '" + textBox1.Text.Trim() + "'"; } SqlDataReader reader = Dyy.GetDataReader(intro); if (reader.HasRows) { reader.Read(); richTextBox1.Text = reader["introduction"].ToString(); } else { richTextBox1.Clear(); MessageBox.Show("查询条件模糊,个人简介失败"); } }