private void editData_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { int idCustomer = Int32.Parse(listView1.SelectedItems[0].Text); mrkEditTarget.getFromDatabase(idCustomer); EditMerek form = new EditMerek(this, mrkEditTarget); form.Show(); } }
private void deleteData_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { string idMerek = listView1.SelectedItems[0].Text; DialogResult result = MessageBox.Show("Data ini sudah tersimpan dari database. Menghapus dari database ?", "Delete", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Merek mrkDelTarget = new Merek(); mrkDelTarget.getFromDatabase(Int32.Parse(idMerek)); if (mrkDelTarget.delFromDatabase() == false) { MessageBox.Show("Data ini tidak dapat dihapus karena terhubung ke Tabel Database lain"); } else { EditMrkForm form = new EditMrkForm(); form.Show(); this.Close(); } } } }