private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         dataGridView1.DataSource = classData.getAllData();
     }
     catch
     {
         label6.Text = "Server error";
     }
 }
 private void button3_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             ClassData classData = new ClassData();
             classData.deleteMahasiswa(txtNIM.Text);
             clear();
             dataGridView1.DataSource = classData.getAllData();
             MessageBox.Show("Data successfuly deleted");
         }
         catch (Exception ex)
         {
             label7.Text = "Server Error";
         }
     }
 }
        private void button2_Click(object sender, EventArgs e)
        {
            if (txtNIM.Text != "" &&
                txtNama.Text != "" &&
                txtProdi.Text != "" &&
                txtAngkatan.Text != "")
            {
                if (txtNIM.Text.Length <= 12 &&
                    txtAngkatan.Text.Length <= 4 &&
                    txtProdi.Text.Length <= 30 &&
                    txtNama.Text.Length <= 20)
                {
                    try
                    {
                        Mahasiswa mhs = new Mahasiswa();
                        mhs.nim      = txtNIM.Text;
                        mhs.nama     = txtNama.Text;
                        mhs.prodi    = txtProdi.Text;
                        mhs.angkatan = txtAngkatan.Text;

                        ClassData classData = new ClassData();
                        classData.updateDatabase(mhs);
                        MessageBox.Show("Data successfuly updated");
                        clear();
                        dataGridView1.DataSource = classData.getAllData();
                    }
                    catch
                    {
                        label6.Text = "Server Error";
                    }
                }
                else
                {
                    MessageBox.Show("Please check your data");
                }
            }
            else
            {
                MessageBox.Show("Please check your data");
            }
        }