private static void AddWebsiteConfirmButton_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; List <TextBox> data = (List <TextBox>)button.Tag; string websiteName = data[0].Text; string websiteRating = data[1].Text; if (!BackEndHelper.IsNumber(websiteRating)) { MessageBox.Show("Rating must be a number"); return; } int rating = int.Parse(websiteRating); DataModels database = DataModels.GetInstance(); Website website = new Website(websiteName, rating); bool done = database.AddWebsite(website); if (done) { MessageBox.Show("Website Added successfully !"); } else { MessageBox.Show("Couldn't add website"); } }
private static void UpdateWebsiteConfirmButton_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; List <object> data = (List <object>)button.Tag; Website website = (Website)data[0]; TextBox websiteRatingTextBox = (TextBox)data[1]; string websiteRating = websiteRatingTextBox.Text; if (!BackEndHelper.IsNumber(websiteRating)) { MessageBox.Show("Rating must be a number"); return; } int newRating = int.Parse(websiteRating); website.rating = newRating; DataModels database = DataModels.GetInstance(); bool done = database.UpdateWebsite(website); if (done) { MessageBox.Show("Website Updated successfully !"); } else { MessageBox.Show("Couldn't update website"); } }
private static void AddReviewConfirmButton_Click(object sender, RoutedEventArgs e) { DataModels database = DataModels.GetInstance(); Button addRoomButton = (Button)sender; List <object> objects = (List <object>)addRoomButton.Tag; Booking booking = (Booking)objects[0]; TextBox reviewTextBox = (TextBox)objects[1]; TextBox ratingTexyBox = (TextBox)objects[2]; if (!BackEndHelper.IsNumber(ratingTexyBox.Text)) { MessageBox.Show("Rating must be a number !"); return; } bool done = database.AddReview(new Review(reviewTextBox.Text, int.Parse(ratingTexyBox.Text), booking.number)); if (done) { MessageBox.Show("Review submitted"); } else { MessageBox.Show("Error!"); } }
public void SignupButtonUserData_Click(object sender, RoutedEventArgs args) { Front_End.SignupCanvas signupCanvas = Front_End.SignupCanvas.GetInstance(SignupCanvas); if (BackEndHelper.IsValidEmail(signupCanvas.GetEmail()) == false) { MessageBox.Show("Invalid Email"); return; } if (signupCanvas.GetPassword().Length < 8) { MessageBox.Show("Passowrd length must be more than 8 characters"); return; } if (signupCanvas.GetCreditCardSerial().Length > 20 || BackEndHelper.IsNumber(signupCanvas.GetCreditCardSerial()) == false) { MessageBox.Show("Invalid serial number"); return; } if (signupCanvas.GetCreditCardCVV().Length > 4 || signupCanvas.GetCreditCardCVV().Length < 3 || BackEndHelper.IsNumber(signupCanvas.GetCreditCardCVV()) == false) { MessageBox.Show("Invalid cvv"); return; } if (signupCanvas.GetExpirationDate() < DateTime.Today) { MessageBox.Show("Credit card expired"); return; } User user = new User ( signupCanvas.GetUserName(), signupCanvas.GetEmail(), signupCanvas.GetName(), null, new CreditCard (signupCanvas.GetCreditCardSerial(), int.Parse(signupCanvas.GetCreditCardCVV()), signupCanvas.GetExpirationDate() ) ); bool valid = DataModels.GetInstance().RegisterUser(user, signupCanvas.GetPassword()); if (valid == false) { MessageBox.Show("User name taken"); return; } Front_End.NavigationCanvas.GetInstance(NavigationCanvas).Hide(); InitializeLoggedinNavigationCanvas(user); ActiveUser = user; CurrentCanvas.Hide(); InitializeHomeCanvas(); }
private static void ConfirmReserveButton_Click(object sender, RoutedEventArgs e) { DataModels database = DataModels.GetInstance(); Button button = (Button)sender; List <Object> data = (List <Object>)button.Tag; Calendar datePicker = (Calendar)data[0]; TextBox numberofGuestTextBox = (TextBox)data[1]; RoomsListShowCanvas roomListShowCanvas = (RoomsListShowCanvas)data[2]; int index = (int)data[3]; DateTime startDate = datePicker.SelectedDates[0]; DateTime endDate = datePicker.SelectedDates[datePicker.SelectedDates.Count - 1]; if (!BackEndHelper.IsNumber(numberofGuestTextBox.Text)) { MessageBox.Show("Number of guests must be a number"); return; } int numberOfGuests = int.Parse(numberofGuestTextBox.Text); Room room = roomListShowCanvas.GetSelectedRoom(index); if (numberOfGuests > room.type.maxGuests) { MessageBox.Show("Number of Guests bigger than room capacity"); return; } Booking booking = new Booking(database.GetBookingId(), startDate, endDate, numberOfGuests, GetMainWindow().ActiveUser, roomListShowCanvas.GetSelectedMealPlan(index), room, new Review(database.GetBookingId()), roomListShowCanvas.GetSelectedWebsite(index)); if (database.AddBooking(booking)) { MessageBox.Show("You Booked the room !"); } else { MessageBox.Show("Error"); } }