Ejemplo n.º 1
0
 private void button1_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
             {
                 string nim      = tNIM.Text;
                 string nama     = tNama.Text;
                 string prodi    = tProdi.Text;
                 string angkatan = tAngkatan.Text;
                 classData.insertMahasiswa(nim, nama, prodi, angkatan);
                 clear();
                 dataGridView1.DataSource = classData.getAllData();
                 MessageBox.Show("Data successfuly inserted");
             }
             catch (Exception ex)
             {
                 label7.Text = "Server Error";
             }
         }
         else
         {
             MessageBox.Show("Please check your data");
         }
     }
     else
     {
         MessageBox.Show("Please check your data");
     }
 }
Ejemplo n.º 2
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";
         }
     }
 }
Ejemplo n.º 3
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");
            }
        }