private void btnCancel_Click(object sender, RoutedEventArgs e) { New_Reservation CreateNewReservation = new New_Reservation(); CreateNewReservation.Show(); this.Close(); }
//When the Create Reservation is Click private void btnNewReservation_Click(object sender, RoutedEventArgs e) { New_Reservation CreateQuote = new New_Reservation(); CreateQuote.Show(); this.Close(); }
private void btnConfirm_Click(object sender, RoutedEventArgs e) { string strCardNum = txtCardNo.Text.Trim().Replace(" ", ""); string FirstName; string LastName; string CardNo; string PhoneNumber; string Email; DateTime CheckInDate; DateTime CheckOutDate; //Validate card number long lngOut; int i; int intCheckDigit; int intCheckSum = 0; DateTime CheckIn = new DateTime(); DateTime CheckOut = new DateTime(); //Parse Variable double dblNum; // variables to check empty fields bool bolEmpty = false; // boolean that is set to true whenever there is an unselected/empty field string strEmpty = ""; // string used to add fields that will be displayed whenever they are empty // check for empty fields if (txtFirstName.Text.Trim() == "") { bolEmpty = true; strEmpty = "first name"; } if (txtLastName.Text.Trim() == "") { if (bolEmpty == true) { strEmpty = strEmpty + ", last name"; } else { bolEmpty = true; strEmpty = "last name"; } } if (txtCardNo.Text.Trim() == "") { if (bolEmpty == true) { strEmpty = strEmpty + ", credit card no"; } else { bolEmpty = true; strEmpty = "credit card no"; } } if (txtPhone.Text.Trim() == "") { if (bolEmpty == true) { strEmpty = strEmpty + ", phone no"; } else { bolEmpty = true; strEmpty = strEmpty + "phone no"; } } // if bolEmpty is true, display message showing all empty fields that needs to be sorted out if (bolEmpty == true) { MessageBox.Show("The field(s) " + strEmpty + " cannot be empty."); return; } //Check whether first name contains numbers, show error if true if (double.TryParse(txtFirstName.Text.Trim(), out dblNum)) { MessageBox.Show("First name cannot contain numbers."); return; } //Check whether last name contains numbers, show error if true if (double.TryParse(txtLastName.Text.Trim(), out dblNum)) { MessageBox.Show("Last name cannot contain numbers."); return; } //Check that credit card only contains numbers if (!Int64.TryParse(strCardNum, out lngOut)) { MessageBox.Show("Credit card can only contain numeric values."); return; } //Validate the card number length if (strCardNum.Length != 13 && strCardNum.Length != 15 && strCardNum.Length != 16) { MessageBox.Show("Credit card numbers must be either 13, 15, or 16 digits."); return; } //Validate the card number strCardNum = ReverseString(strCardNum); for (i = 0; i < strCardNum.Length; i++) { intCheckDigit = Convert.ToInt32(strCardNum.Substring(i, 1)); if ((i + 1) % 2 == 0) { intCheckDigit *= 2; if (intCheckDigit > 9) { intCheckDigit -= 9; } } intCheckSum += intCheckDigit; } // show error if the checksum is not valid if (intCheckSum % 10 != 0) { MessageBox.Show("Credit card number is not valid."); return; } // validate that phone number only contain numbers if (!Int64.TryParse(txtPhone.Text, out lngOut)) { MessageBox.Show("Phone number can only contain numeric values."); return; } if (txtPhone.Text.Trim().Length != 10) { MessageBox.Show("Phone number must be 10 digits."); return; } // if email is not empty, validate it if (txtEmail.Text.Trim() != "") { if (IsValidEmail(txtEmail.Text.Trim()) == false) { MessageBox.Show("Email must be in valid format."); return; } } //Store the inputed value FirstName = txtFirstName.Text.Trim(); LastName = txtLastName.Text.Trim(); CardNo = txtCardNo.Text.Trim(); PhoneNumber = txtPhone.Text.Trim(); Email = txtEmail.Text.Trim(); CheckIn = Convert.ToDateTime(lblCheckInOut.Content).Date; CheckInDate = CheckIn.Date; CheckOut = Convert.ToDateTime(lblCheckOutOut.Content).Date; CheckOutDate = CheckOut.Date; //Add the reservation to the reservation list newReservation = new Reservation(CheckInDate.Date, CheckOutDate.Date, FirstName, LastName, PhoneNumber, Email, lblRoomTypeOut.Content.ToString(), CurrentQuote.NoOfRoom, lblTotalPriceOut.Content.ToString()); //Save to json file SaveToJson(); //Return to new reservation 1 New_Reservation mw = new New_Reservation(); mw.Show(); this.Close(); }