private void listView_DoubleClick(object sender, EventArgs e) { ListViewItem lvi = listView.SelectedItems[0]; currentDVD = lvi.Tag as DVD; //MessageBox.Show(currentDVD.Name); using (AddDVD dvdForm = new AddDVD()) { dvdForm.Dvd = currentDVD; if (dvdForm.ShowDialog() == DialogResult.OK) { DVD returnedDVD = dvdForm.Dvd; lvi.Tag = returnedDVD; lvi.SubItems[0].Text = returnedDVD.Name; lvi.SubItems[1].Text = returnedDVD.Genre; lvi.SubItems[2].Text = returnedDVD.Rating.ToString(); lvi.SubItems[3].Text = returnedDVD.MaturityLevel; for (int i = 0; i < dvds.Count; i++) { if (dvds[i].ID == returnedDVD.ID) { dvds[i] = returnedDVD; //MessageBox.Show(dvds[i].Name); int result = DB.UpdateDVD(returnedDVD); MessageBox.Show(String.Format("{0} DVD Updated", result.ToString())); } } } } }
private void bt_add_Click(object sender, EventArgs e) { using (AddDVD addDVD = new AddDVD()) { addDVD.currentCountFilms = dvds.Count(); if (addDVD.ShowDialog() == DialogResult.OK) { DVD newDVD = addDVD.Dvd; generateListViewItems(newDVD); int r = DB.AddDVD(newDVD); if (r > 0) { MessageBox.Show(r.ToString() + " DVD Added"); } else { MessageBox.Show(r.ToString()); } } } ColourRows(); }