private void AddTeachs_Click(object sender, RoutedEventArgs e) { if (teachers.SelectedIndex >= 0 && courses.SelectedIndex >= 0) { string str_teacher = teachers.SelectedItem.ToString(); string str_course = courses.SelectedItem.ToString(); string select_tch = "SELECT tch_id from teacher where tch_name='" + str_teacher + "'"; string select_cr = "SELECT cource_id from cource where cource_name='" + str_course + "'"; int tch_id = conn.SelectID(select_tch); int course_id = conn.SelectID(select_cr); string exist_query = "SELECT * FROM teachs WHERE teacher_id=" + tch_id + " and course_id=" + course_id + ""; string query = "INSERT INTO teachs VALUES(" + tch_id + "," + course_id + ")"; if (!conn.DoseExists(exist_query)) { if (conn.insertDB(query)) { MessageBox.Show("Information is Added"); } } else { MessageBox.Show("This teacher already teachs the course"); } //MessageBox.Show(tch_id + " " + course_id); } }
private void button1_Click(object sender, RoutedEventArgs e) { string Query = "select std_password from students where std_id =" + id + " and std_password='******'"; if (conn.DoseExists(Query) && newpass.Password.Equals(newpass1.Password)) { string update = "update students set std_password='******' where std_id=" + id; if (conn.updateDB(update)) { MessageBox.Show("Password is Updated"); } } else { MessageBox.Show("Worong Password or The new Password Not The Same"); } }