private void button1_Click(object sender, EventArgs e) { Student student; string ID = textBox1.Text; SqlConnection con = new SqlConnection(connect); string query = "Select * from Students where ID = '" + textBox1.Text.Trim() + "'"; SqlDataAdapter sda = new SqlDataAdapter(query, con); DataTable dt = new DataTable(); sda.Fill(dt); query = "Select * from Login where Id = '" + textBox1.Text.Trim() + "'"; SqlDataAdapter sda1 = new SqlDataAdapter(query, con); DataTable dt1 = new DataTable(); sda1.Fill(dt1); if (dt.Rows.Count == 0) { MessageBox.Show("No ID exist in the collage"); } else { student = new Student(dt.Rows[0][1].ToString(), dt.Rows[0][0].ToString(), "0", dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), (bool)dt.Rows[0][4]); student.deleteALL(); dt.Rows[0].BeginEdit(); dt1.Rows[0].BeginEdit(); dt.Rows[0][2] = comboBox1.Text; dt1.Rows[0][4] = comboBox1.Text; dt.Rows[0].EndEdit(); dt1.Rows[0].EndEdit(); SqlCommandBuilder cb = new SqlCommandBuilder(sda); SqlCommandBuilder cb1 = new SqlCommandBuilder(sda1); sda.Update(dt); sda1.Update(dt1); MessageBox.Show("The student was successfully assigned to the department " + comboBox1.Text); button1_Click(sender, e); } con.Close(); }
private void button1_Click(object sender, EventArgs e) //save button { student.deleteALL(); saveALL(); }