private void button3_Click(object sender, EventArgs e) { StudentDetailsButton.PerformClick(); FormPanel.Hide(); AddButton.Hide(); Update_Button.Hide(); }
private void Update_Button_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"|DataDirectory|\\Database.mdf\";Integrated Security=True"); try { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "update student set First_name='" + First_name_TB.Text + "',Last_name='" + Last_name_TB.Text + "',Department='" + Department_TB.Text + "',Phone_no='" + Phone_no_TB.Text + "',Address='" + Address_TB.Text + "', [Guardian's_name]='" + Guardian_name_TB.Text + "',[Guardian's_no] = '" + Guardian_ph_no_TB.Text + "',DOB = '" + DOB_TB.Text + "' where Student_id='" + Student_id_TB.Text + "' "; cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Student Record updated successfully"); } catch (Exception ex) { MessageBox.Show("" + ex); } refresh_DataGridView(); StudentDetailsButton.PerformClick(); }
private void Student_UserControl_Load(object sender, EventArgs e) { StudentDetailsButton.PerformClick(); refresh_DataGridView(); }