Esempio n. 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmNewMovie addRentalItemForm = new frmNewMovie();
            RentalItem  rentalItem        = addRentalItemForm.GetNewRentalItem();

            if (rentalItem != null)
            {
                //Adding data into database after getting it from NewMovie form
                rentalItems.Add(rentalItem);
                RentalItemDB.SaveRentalItems(rentalItems);
                FillRentalItemListBox();
            }
        }
Esempio n. 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Deleting one selected row in listBox from database
            int i = lstRents.SelectedIndex;

            if (i != -1)
            {
                RentalItem rentalItem = rentalItems[i];
                string     message    = "Are you sure you want to delete "
                                        + rentalItem.MovieNo + " " + rentalItem.Description + "?";
                DialogResult button = MessageBox.Show(message, "Confirm Delete",
                                                      MessageBoxButtons.YesNo);
                if (button == DialogResult.Yes)
                {
                    rentalItems.Remove(rentalItem);
                    RentalItemDB.SaveRentalItems(rentalItems);
                    FillRentalItemListBox();
                }
            }
        }
Esempio n. 3
0
 private void frmRentalMaintenance_Load(object sender, EventArgs e)
 {
     rentalItems = RentalItemDB.GetRentalItems();
     //Calling the method to load all datas when form is loaded
     FillRentalItemListBox();
 }