Esempio n. 1
0
        private void buttonHapus_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxKodePegawai.Text != "")
                {
                    DialogResult confirm = MessageBox.Show("Data akan dihapus. Anda Yakin ?", "Konfirmasi", MessageBoxButtons.YesNo);

                    if (confirm == DialogResult.Yes)
                    {
                        Pegawai pegDel = new Pegawai(textBoxKodePegawai.Text);
                        string  del    = pegDel.Delete();

                        if (del == "1")
                        {
                            MessageBox.Show("Data Berhasil Dihapus", "Info");
                            buttonKosongi_Click(buttonHapus, e);
                            FormDaftarPegawai frm = (FormDaftarPegawai)Owner;
                            frm.FormDaftarPegawai_Load(buttonHapus, e);
                        }
                        else
                        {
                            MessageBox.Show($"Gagal Menghapus Data, Error : {del}", "Error");
                        }
                    }
                }
            }
            catch (Exception error)
            {
                MessageBox.Show($"Gagal Menghapus Data, Error : {error.Message}", "Error");
            }
        }
 private void simpleButtonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (pegawai != null)
         {
             if (XtraMessageBox.Show("Apakah anda ingin menghapus data ?", "Notif", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 pegawai.Delete();
                 ClearForm();
                 xpCollectionData.Reload();
             }
         }
         else
         {
             throw new Exception("Anda belum memilih data");
         }
     }
     catch (Exception exception)
     {
         XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }