Example #1
0
 private void button5_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(tNIM.Text);
             clear();
             dataGridView1.DataSource = classData.getAllData();
             MessageBox.Show("Data successfuly deleted");
         }
         catch (Exception ex)
         {
             label7.Text = "Server Error";
         }
     }
 }
Example #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (tNIM.Text != "" &&
                tNama.Text != "" &&
                tProdi.Text != "" &&
                tAngkatan.Text != "")
            {
                if (tNIM.Text.Length <= 12 &&
                    tAngkatan.Text.Length <= 4 &&
                    tProdi.Text.Length <= 30 &&
                    tNama.Text.Length <= 20)
                {
                    try
                    {
                        Mahasiswa mhs = new Mahasiswa();
                        mhs.nim      = tNIM.Text;
                        mhs.nama     = tNama.Text;
                        mhs.prodi    = tProdi.Text;
                        mhs.angkatan = tAngkatan.Text;

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