private void Button_Click(object sender, RoutedEventArgs e) { //<take strings from UI> string name1 = nameBox.Text; string name2 = nameBox2.Text; string address1 = addressBox1.Text; string address2 = addressBox2.Text; string city = addressBox3.Text; string postCode = addressBox4.Text; //</take strings from UI> if (string.IsNullOrEmpty(name1) == false && string.IsNullOrEmpty(name2) == false && string.IsNullOrEmpty(address1) == false && string.IsNullOrEmpty(city) == false && string.IsNullOrEmpty(postCode) == false) { Customer currentCustomer = new Customer(name1, name2, address1, address2, city, postCode); //pass Customer details to Customer constructor UserTracker tracker = UserTracker.Instance; //return the only instance of UserTracker tracker.IncrementCount(); tracker.Store(currentCustomer); MessageBox.Show("Your Customer reference number is " + currentCustomer.CustomerRef + ".\nYou will need this every time you log in."); //tell customer their ref number HubPage hub = new HubPage(currentCustomer); if (tracker._Path != null) //if the details were successfully printed to the a valid file path { hub.Show(); //on with the show go to the hub page this.Close(); } } else { MessageBox.Show("All compulsory fields (*) must be filled.", "Missing data.", // reason for error MessageBoxButton.OK, MessageBoxImage.Error); //give 'em a BONK } }
public Facade(EditBooking editor) { _customer = UserTracker.Instance; _booker = BookingTracker.Instance; _guests = GuestTracker.Instance; _directory = DirectoryManager.Instance; this.editor = editor; //bring in reference to the booking editor }
//delete a Customer and return to start page private void delButton_Click(object sender, RoutedEventArgs e) { UserTracker del = UserTracker.Instance; del.Delete(editCustomer); MainWindow start = new MainWindow(); start.Show(); this.Close(); }
private void saveButton_Click(object sender, RoutedEventArgs e) { //<set new name and address> editCustomer.Name = nameBox1.Text + " " + nameBox2.Text; editCustomer.Address = addressBox1.Text + ", " + addressBox2.Text + ", " + cityBox.Text + ", " + postBox.Text; //</set new name and address> UserTracker update = UserTracker.Instance; update.EditCustomer(editCustomer); HubPage hub = new HubPage(editCustomer); hub.Show(); this.Close(); }
private void button_Click(object sender, RoutedEventArgs e) { string checkNum = custRefBox.Text.Trim(); //checknum = user's input. .Trim() added to remove line feed characters Customer currentCustomer = new Customer(); UserTracker tracker = UserTracker.Instance; //singleton instance of UserTracker tracker.ReadCustomer(checkNum, currentCustomer); //check persisntence file for customer records on HubPage hub = new HubPage(currentCustomer); try { if (currentCustomer.CustomerRef == Int32.Parse(checkNum)) //if the customer ref (and therefore other details) were successfully set { hub.Show(); //on with the show, start making a booking this.Close(); } } catch { MessageBox.Show("Customer reference must be a number.", "Invalid input.", // reason for error MessageBoxButton.OK, MessageBoxImage.Error); //give 'em a BONK } }
public void EditBooking(Booking currentBooking, Customer currentCustomer) { bool passed = true; try { BookingTracker booker = BookingTracker.Instance; //instanciate current booking currentBooking.ArrivalDate = editor.inDatePick.SelectedDate.Value.Date; //set arrival dat eto chosen datepicker vaule currentBooking.DepartureDate = editor.outDatePick.SelectedDate.Value.Date; //ditto for departure date currentBooking.Diet = editor.dietBox.Text; //diet requirements setter //validate for bad dates try { int hireLength = (currentBooking.HireEnd - currentBooking.HireStart).Days; if (Convert.ToDateTime(hireLength) <= DateTime.MinValue) { passed = false; MessageBox.Show("Make sure you get here before you leave.", "Invalid inout.", // reason for error MessageBoxButton.OK, MessageBoxImage.Error); //give 'em a BONK } } catch { passed = false; } //check if extra: breakfast is selected //please forgive lack of brakets but this part is insanely long for what it is with them if (editor.breakfastBox.IsChecked == true) { currentBooking.Breakfast = true; } else { currentBooking.Breakfast = false; } //check if extra: meals is selected if (editor.mealsBox.IsChecked == true) { currentBooking.Meals = true; } else { currentBooking.Meals = false; } //check if extra: hire car is selected if (editor.carHireBox.IsChecked == true) { currentBooking.CarHire = true; } else { currentBooking.CarHire = false; } //make sure that null values never end up being attempted to be printed for the car hire fields if (editor.carHireBox.IsChecked == false) { currentBooking.DriverName = "N/A"; currentBooking.HireStart = DateTime.MinValue; currentBooking.HireEnd = DateTime.MinValue; } else { currentBooking.DriverName = editor.driverNameBox.Text; currentBooking.HireStart = editor.driveDay1Picker.SelectedDate.Value.Date; currentBooking.HireEnd = editor.driveDay2Picker.SelectedDate.Value.Date; } booker.IncrementCount(); //increment the booker.Store(currentBooking, currentCustomer); // call the Store method in the booking manager GuestTracker gPrint = GuestTracker.Instance; gPrint.Store(currentBooking); //write guests from the list in booking to a file MessageBox.Show("Your Booking reference number is: " + (currentBooking.BookingRef) + "\n You will need this later."); UserTracker addBooking = UserTracker.Instance; addBooking.AddBooking(currentBooking, currentCustomer); if (passed == true) { HubPage hub = new HubPage(currentCustomer); hub.Show(); editor.Close(); } } catch { MessageBox.Show("You must enter data in all compulsory (*) fields.", "Missing data.", // reason for error MessageBoxButton.OK, MessageBoxImage.Error); //give 'em a BONK } }