private void ChangeTeacher() { string sql = string.Format("select 教师编号 from teacher where 教师姓名='{0}'", otn); oti = Convert.ToInt32(StaticSQLiteHelper.ExecuteScalar(sql)); sql = string.Format("select 教师编号 from teacher where 教师姓名='{0}';", ntn); nti = Convert.ToInt32(StaticSQLiteHelper.ExecuteScalar(sql)); //更新课程设置 sql = string.Format("update class_course set 教师姓名='{0}' where 班级={1} and 学科名字='{2}'", ntn, ci, sn); StaticSQLiteHelper.ExecuteNonQuery(sql); //更新白天课程 sql = string.Format("update schedule set teacher_id={0} where class_id={1} and teacher_id={2}", nti, ci, oti); StaticSQLiteHelper.ExecuteNonQuery(sql); //更新晚上课程 sql = string.Format("update night set teacher_id={0} where class_id={1} and teacher_id={2}", nti, ci, oti); StaticSQLiteHelper.ExecuteNonQuery(sql); }
private void cbClass_SelectedIndexChanged(object sender, EventArgs e) { if (cbSubject.SelectedItem == null) { return; } cn = Convert.ToInt32(cbClass.SelectedValue); ci = cn - 1; string sql = "select 教师姓名 from class_course where 班级=" + ci.ToString() + " and 学科名字='" + sn + "'"; otn = StaticSQLiteHelper.ExecuteScalar(sql).ToString(); sql = "select distinct(教师姓名) as 教师姓名 from teacher where 教师姓名<>'" + otn + "' and 学科名字='" + sn + "'"; DataTable dt = StaticSQLiteHelper.ExecuteQuery(sql); cbTeacherName.BeginUpdate(); cbTeacherName.ValueMember = "教师姓名"; cbTeacherName.DisplayMember = "教师姓名"; cbTeacherName.DataSource = dt; cbTeacherName.EndUpdate(); }