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 Button1_Click(object sender, EventArgs e) { string strselect = "SELECT \n" + " course.number 课程号, \n" + " course.cname 课程中文名, \n" + " course.ename 课程英文名, \n" + " course.score 学分, \n" + " course.chour 周理论学时, \n" + " course.lhour 周实验学时, \n" + " course.tchour 理论总学时, \n" + " course.tlhour 实验总学时 \n" + " FROM course \n" + " WHERE"; if (comboBox2.Text == "模糊查询") { if (comboBox1.Text == "课程号") { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " number like '%" + textBox1.Text.Trim() + "%'"; } } else { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " cname like '%" + textBox1.Text.Trim() + "%'"; } } } else { if (comboBox1.Text == "课程号") { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " number = '" + textBox1.Text.Trim() + "'"; } } else { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " cname = '" + textBox1.Text.Trim() + "'"; } } } if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { dataGridView1.DataSource = Dyy.GetFillData(strselect); } else { MessageBox.Show("不可为空"); textBox1.Clear(); } }
private void Data_Update() { string sqlstr = "SELECT course_class.id as '班级id', student.id as '学生id', student.scode, student.name," + " class_student.gpa_score," + " class_student.paper_score, class_student.practice_score, class_student.score" + " FROM class_student, student, course_class WHERE" + " course_class_id in (SELECT id FROM course_class WHERE teacher_id='" + Tea.Id + "')" + " AND class_student.student_id=student.id" + " AND class_student.course_class_id=course_class.id;"; dataGridView1.DataSource = Dyy.GetFillData(sqlstr); }
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 Button1_Click(object sender, EventArgs e) { string strselect = "SELECT \n" + " student.name 姓名, \n" + "student.scode 学号, \n" + "student.gender 性别, \n" + "class.name 班级 \n" + "FROM \n" + "student,class \n" + "WHERE student.class_id = class.id and"; if (comboBox2.Text == "模糊") { if (comboBox1.Text == "学号") { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " student.scode like '%" + textBox1.Text.Trim() + "%'"; } } else { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " student.name like '%" + textBox1.Text.Trim() + "%'"; } } } else { if (comboBox1.Text == "学号") { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " student.scode = '" + textBox1.Text.Trim() + "'"; } } else { if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { strselect += " student.name = '" + textBox1.Text.Trim() + "'"; } } } if (!string.IsNullOrWhiteSpace(textBox1.Text.Trim())) { dataGridView1.DataSource = Dyy.GetFillData(strselect); } }
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 strsql = "Update" + " class_student set gpa_score='" + textBox3.Text.Trim() + "'," + "paper_score='" + textBox4.Text.Trim() + "',practice_score='" + textBox5.Text.Trim() + "'," + "score='" + textBox6.Text.Trim() + "' " + "where course_class_id='" + textBox1.Text.Trim() + "' and student_id='" + textBox2.Text.Trim() + "'"; try { if (Dyy.GetExcuteNonQuery(strsql) > 0) { MessageBox.Show("评定成功"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); } else { MessageBox.Show("班级学生信息不存在"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); } } catch (Exception ex) { MessageBox.Show("修改错误,错误原因:" + ex.Message); } finally { //string sqlstr = " SELECT \n" + // " class_student.course_class_id 课程ID, \n" + // " class_student.student_id 学生ID, \n" + // " class_student.gpa_score 平时表现成绩, \n" + // " class_student.paper_score 理论考试成绩, \n" + // " class_student.practice_score 实践考核成绩, \n" + // " class_student.score 总评成绩 \n" + // " FROM class_student"; //dataGridView1.DataSource = Dyy.GetFillData(sqlstr); Data_Update(); } }
private void Button1_Click(object sender, EventArgs e) { string strselect = "SELECT \n" + " education_program.name 专业, \n" + " education_program.objective 培养目标, \n" + " education_program.duration 标准学制, \n" + " education_program.degree 授予学位, \n" + " education_program.min_credit 毕业学分要求, \n" + " education_program.publish_year 制定年份 \n" + " FROM \n" + "education_program \n" + "WHERE name = '" + comboBox2.Text + "' and publish_year = '" + comboBox1.Text + "'"; dataGridView1.DataSource = Dyy.GetFillData(strselect); }
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("查询条件模糊,个人简介失败"); } }