コード例 #1
0
        private void buttonHapus_Click(object sender, EventArgs e)
        {
            DialogResult confirm = MessageBox.Show("Data Barang akan dihapus. Anda Yakin ?", "Konfirmasi", MessageBoxButtons.YesNo);

            if (confirm == DialogResult.Yes)
            {
                if (listBarang.Count > 0)
                {
                    Barang bar   = (Barang)listBarang[0];
                    string hapus = bar.Delete();

                    if (hapus == "1")
                    {
                        MessageBox.Show("Data Barang Berhasil Dihapus", "Warning");

                        buttonKosongi_Click(buttonHapus, e);

                        FormDaftarBarang frm = (FormDaftarBarang)Owner;
                        frm.FormDaftarBarang_Load(buttonHapus, e);
                    }
                    else
                    {
                        MessageBox.Show("Data Barang Gagal Dihapus" + hapus, "Warning");
                    }
                }
            }
        }
コード例 #2
0
        private void btnHapusBarang_Click(object sender, EventArgs e)
        {
            Barang barang = new Barang();

            barang.setId(Convert.ToInt32(txtIdBarang.Text));
            Console.WriteLine(barang.getId());
            barang.Delete();
            foreach (Control ctrl in mtpBarang.Controls)
            {
                if (ctrl is TextBox)
                {
                    ctrl.Text = "";
                }
            }
            MessageBox.Show("Barang berhasil dihapus.");
        }