private void SubmitButton_Click(object sender, EventArgs e) { DialogResult result = default(DialogResult); bool x = inputCorrectSubmit(); if (x) { switch (myState) { case "add": currentAccount = PopulateAccount(); accounts.Add(currentAccount); accountDB.DatabaseAdd(currentAccount); added = true; this.Close(); break; case "edit": currentAccount = PopulateAccount(); accounts.RemoveAt(FindIndex(currentAccount.AccountNo)); accounts.Add(currentAccount); accountDB.DatabaseEdit(currentAccount); setUpAccountListView(); break; } myState = "view"; FormDisplay(myState); } }
private void DeleteButton_Click(object sender, EventArgs e) { int index1 = currentBooking.BookingRef; double oldAmt = accountDB.oldAmt(index1); int index2 = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index2].AmountDue -= oldAmt; if (accountDB.AllAccounts[index2].AmountDue < 0) { accountDB.AllAccounts[index2].AmountDue = 0; } accountDB.DatabaseEdit(accountDB.AllAccounts[index2]); bookingController.Delete(currentBooking); bookingController.removeBooking(currentBooking.Date, currentBooking.EndDate, currentBooking.Room); setUpBookingListView(); }