Example #1
0
        public void HotelManagerAdd()
        {
            //Assigns a Results Edit object after attempting to add the TestGuest into the database
            ResultsEdit changed = access.AddHotelGuest(TestGuest);

            //Asserts that the add will be successful.
            Assert.AreEqual(ResultsEdit.Success, changed);
        }
Example #2
0
 public void initialize()
 {
     TestGuest = new HotelGuest("Fake", "Person", "1111 Fake St.", "", new CityState("52641", "Mt. Pleasant", "IA"), "5556667777", "*****@*****.**", "234234", "3453", true);
     hgm.AddHotelGuest(TestGuest);
 }
Example #3
0
        /// <summary>
        /// Miguel Santana
        /// Created: 2015/02/16
        /// Validate fields and submit data to HotelGuestManager
        /// </summary>
        /// <remarks>
        /// Rose Steffensmeier
        /// Updated: 2015/03/05
        /// Added Room number field
        /// Pat Banks
        /// Updated:  2015/04/03
        /// added guest pin field
        /// </remarks>
        private async void Submit()
        {
            if (CurrentHotelGuest != null && ValidateChanged())
            {
                switch (await ShowMessage("No data was changed. Would you like to keep editing?", "Alert", MessageDialogStyle.AffirmativeAndNegative))
                {
                case MessageDialogResult.Affirmative:
                    Close();
                    break;

                default:
                    return;
                }
            }

            if (!Validate())
            {
                return;
            }
            try
            {
                //FormatException found in if loop
                if (CurrentHotelGuest == null)
                {
                    Result = _hotelGuestManager.AddHotelGuest(
                        new HotelGuest(
                            TxtFirstName.Text.Trim(),
                            TxtLastName.Text.Trim(),
                            TxtAddress1.Text.Trim(),
                            TxtAddress2.Text.Trim(),
                            (CityState)CboZip.SelectedItem,
                            TxtPhoneNumber.Text.Trim(),
                            TxtEmailAddress.Text.Trim(),
                            TxtRoomNumber.Text.Trim(),
                            TxtGuestPin.Text.Trim()
                            )
                        );
                }
                else
                {
                    Result = _hotelGuestManager.UpdateHotelGuest(
                        CurrentHotelGuest,
                        new HotelGuest(
                            TxtFirstName.Text.Trim(),
                            TxtLastName.Text.Trim(),
                            TxtAddress1.Text.Trim(),
                            TxtAddress2.Text.Trim(),
                            (CityState)CboZip.SelectedItem,
                            TxtPhoneNumber.Text.Trim(),
                            TxtEmailAddress.Text.Trim(),
                            TxtRoomNumber.Text.Trim(),
                            TxtGuestPin.Text.Trim()
                            )
                        );
                }

                if (Result == ResultsEdit.Success)
                {
                    await ShowMessage("Your Request was Processed Successfully", "Success");

                    DialogResult = true;
                    Close();
                }
                else
                {
                    ShowErrorMessage("Error Processing Request", "Error");
                }
            }
            catch (SqlException ex)
            {
                if (ex.Message.Contains("UniqueRoomExceptNulls"))
                {
                    ShowErrorMessage("A Pin is Already Associated With This Room.", "Error");
                }
                else if (ex.Message.Contains("UniquePINExceptNulls"))
                {
                    ShowErrorMessage("A Room is Already Associated With This Pin.", "Error");
                }
                else
                {
                    ShowErrorMessage("There Was An Issue Contacting the Database.", "Error");
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }