예제 #1
0
 private void btnData_Click(object sender, EventArgs e)
 {
     try
     {
         dataGridView1.DataSource = classData.getAllData();
     }
     catch
     {
         label5.Text = "Server error";
     }
 }
예제 #2
0
 private void buttonDelete_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(textBoxNIM.Text);
             dataGridView1.DataSource = classData.getAllData();
             MessageBox.Show("Data successfuly deleted");
         }
         catch (Exception ex)
         {
             label5.Text = "Server Error";
         }
     }
 }
예제 #3
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (textBoxNIM.Text != "" &&
                textBoxNama.Text != "" &&
                textBoxProdi.Text != "" &&
                textBoxAngkatan.Text != "")
            {
                if (textBoxNIM.Text.Length <= 12 &&
                    textBoxAngkatan.Text.Length <= 4 &&
                    textBoxProdi.Text.Length <= 30 &&
                    textBoxNama.Text.Length <= 20)
                {
                    try
                    {
                        Mahasiswa mhs = new Mahasiswa();
                        mhs.nim      = textBoxNIM.Text;
                        mhs.nama     = textBoxNama.Text;
                        mhs.prodi    = textBoxProdi.Text;
                        mhs.angkatan = textBoxAngkatan.Text;

                        ClassData classData = new ClassData();
                        classData.updateDatabase(mhs);
                        MessageBox.Show("Data successfuly updated");

                        dataGridView1.DataSource = classData.getAllData();
                    }
                    catch
                    {
                        label5.Text = "Server Error";
                    }
                }
                else
                {
                    MessageBox.Show("Please check your data");
                }
            }
            else
            {
                MessageBox.Show("Please check your data");
            }
        }