// logic for update details button. updates the customer details in the database private void button_Click(object sender, RoutedEventArgs e) { if (textBoxName.Text == String.Empty || textBoxAddress.Text == String.Empty) { MessageBox.Show(@"Please provide all details."); return; } string name = textBoxName.Text; string address = textBoxAddress.Text; int curtNumber = Convert.ToInt32(lblCustNumb.Content); DataLayer.DataLayerFacade.AmendCustomer(curtNumber, name, address); if (textBoxPassNo.Visibility == Visibility.Visible) { if (textBoxAge.Text == String.Empty || textBoxPassNo.Text == String.Empty) { MessageBox.Show(@"Please provide all details."); return; } string passportNo = textBoxPassNo.Text; int age; try { age = Convert.ToInt32(textBoxAge.Text); } catch (Exception) { MessageBox.Show("Please enter age as a number."); return; } if (age < 0 || age > 101) { MessageBox.Show("Please provide age between 0 and 101."); return; } DataLayerFacade.AmendGuest(name, passportNo, age, oldPassportNo); } CustomerL CustomerList = new CustomerL(); CustomerList.Show(); this.Close(); MessageBox.Show("Customer details have been updated."); }
// deletes a customer provided that he/she has no outstanding bookings private void btnDeleteCust_Click(object sender, RoutedEventArgs e) { try { int bookings = DataLayer.DataLayerFacade.OutstandingBookings(Convert.ToInt32(lblCustNumb.Content)); if (bookings == 0) { DataLayerFacade.DeleteCustomer(Convert.ToInt32(lblCustNumb.Content)); CustomerL CustomerList = new CustomerL(); CustomerList.Show(); this.Close(); MessageBox.Show("Customer has been deleted"); } else { MessageBox.Show("The customer has outstanding bookings. Please cancel those bookings if you want to remove the customer"); } } catch (Exception) { MessageBox.Show("Unable to delete the customer at the moment. Please try again later."); } }
// opens Customer List window private void btnClients_Click(object sender, RoutedEventArgs e) { CustomerL CustomerList = new CustomerL(); CustomerList.Show(); }