Пример #1
0
        private void btnHapus_Click(object sender, EventArgs e)
        {
            if (lvwListProdusen.SelectedItems.Count > 0)
            {
                var konfirmasi = MessageBox.Show("Apakah data barang ingin dihapus?", "Konfirmasi",
                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (konfirmasi == DialogResult.Yes)
                {
                    // ambil objek mhs yang mau dihapus dari collection
                    Produsen prod = listProdusen[lvwListProdusen.SelectedIndices[0]];

                    // panggil operasi CRUD
                    var result = prodController.Delete(prod);
                    if (result > 0)
                    {
                        LoadProdusen();
                    }
                }
            }
            else // data belum dipilih
            {
                MessageBox.Show("Data mahasiswa belum dipilih !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }