Ejemplo n.º 1
0
 /// <summary>
 /// Pat Banks
 /// Created:  2015/04/11
 /// Loads web pages for hotel guest and udpates session variables
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session.IsNewSession)
     {
         ResetVariables();
     }
     else
     {
         //update variables with Session variables
         try
         {
             foundGuest          = (HotelGuest)Session["foundGuest"];
             ticketQty           = (int)Session["ticketQty"];
             selectedItemListing = (ItemListingDetails)Session["selectedItemListing"];
             extendedPrice       = (decimal)Session["extendedPrice"];
             totalPrice          = (decimal)Session["totalPrice"];
             discount            = (decimal)Session["discount"];
         }
         catch
         {
             //Running on the assumption that if there's an exception it's due to the (int) case on ticketQty failing due to a null session object.
             ResetVariables();
         }
     }
 }
Ejemplo n.º 2
0
        public void TestVerifyGuestPINBookingAccessor()
        {   //Pulls a guest from the database and collects the guest information
            List <HotelGuest> guest1 = HotelGuestAccessor.HotelGuestGet(100);
            //Checks using a pin in the database, stores guest info from database into a guest object
            //Asserts that a record is found, that guest is not null by passing the guest1 guest pin
            HotelGuest guest = BookingAccessor.VerifyHotelGuestPin(guest1[guest1.Count - 1].GuestPIN);

            Assert.IsNotNull(guest);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Miguel Santana
        /// Created: 2015/02/12
        /// Updates a hotel guest with new information
        /// </summary>
        /// <remarks>
        /// Rose Steffensmeier
        /// Updated: 02/23/2015
        /// added room number field
        /// </remarks>
        /// <param name="oldHotelGuest">Object containing original information about a hotel guest</param>
        /// <param name="newHotelGuest">Object containing new hotel guest information</param>
        /// <returns>Number of rows effected</returns>
        public static int HotelGuestUpdate(HotelGuest oldHotelGuest, HotelGuest newHotelGuest)
        {
            var conn    = DatabaseConnection.GetDatabaseConnection();
            var cmdText = "spUpdateHotelGuest";
            var cmd     = new SqlCommand(cmdText, conn);
            var numRows = 0;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@firstName", newHotelGuest.FirstName);
            cmd.Parameters.AddWithValue("@lastName", newHotelGuest.LastName);
            cmd.Parameters.AddWithValue("@zip", newHotelGuest.CityState.Zip);
            cmd.Parameters.AddWithValue("@address1", newHotelGuest.Address1);
            cmd.Parameters.AddWithValue("@address2", newHotelGuest.Address2);
            cmd.Parameters.AddWithValue("@phoneNumber", newHotelGuest.PhoneNumber);
            cmd.Parameters.AddWithValue("@email", newHotelGuest.EmailAddress);
            cmd.Parameters.AddWithValue("@room", newHotelGuest.Room);
            cmd.Parameters.AddWithValue("@active", newHotelGuest.Active);
            cmd.Parameters.AddWithValue("@guestpin", newHotelGuest.GuestPIN);

            cmd.Parameters.AddWithValue("@original_hotelGuestID", oldHotelGuest.HotelGuestID);
            cmd.Parameters.AddWithValue("@original_firstName", oldHotelGuest.FirstName);
            cmd.Parameters.AddWithValue("@original_lastName", oldHotelGuest.LastName);
            cmd.Parameters.AddWithValue("@original_zip", oldHotelGuest.CityState.Zip);
            cmd.Parameters.AddWithValue("@original_address1", oldHotelGuest.Address1);
            cmd.Parameters.AddWithValue("@original_address2", oldHotelGuest.Address2);
            cmd.Parameters.AddWithValue("@original_phoneNumber", oldHotelGuest.PhoneNumber);
            cmd.Parameters.AddWithValue("@original_email", oldHotelGuest.EmailAddress);
            cmd.Parameters.AddWithValue("@original_room", oldHotelGuest.Room);
            cmd.Parameters.AddWithValue("@original_active", oldHotelGuest.Active);
            cmd.Parameters.AddWithValue("@original_guestpin", oldHotelGuest.GuestPIN);

            try
            {
                conn.Open();
                numRows = cmd.ExecuteNonQuery();

                if (numRows == 0)
                {
                    throw new ApplicationException("Concurrency Violation");
                }
            }
            catch (SqlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(numRows);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Miguel Santana
        /// Created: 2015/02/16
        /// Edit an Existing Hotel Guest
        /// </summary>
        /// <param name="hotelGuest"></param>
        /// <param name="readOnly">Make the form ReadOnly.</param>
        /// <exception cref="WanderingTurtleException">Occurs making components readonly.</exception>
        public AddEditHotelGuest(HotelGuest hotelGuest, bool readOnly = false)
        {
            InitializeComponent();

            CurrentHotelGuest = hotelGuest;
            Title             = String.Format("Editing Guest: {0}", CurrentHotelGuest.GetFullName);
            InitializeEverything();

            if (readOnly)
            {
                (Content as Panel).MakeReadOnly(BtnCancel);
            }
        }
Ejemplo n.º 5
0
        public void HotelManagerUpdate()
        {
            ResultsEdit changed = access.AddHotelGuest(TestGuest);
            //locates the fake record ID
            int guestID = TestCleanupAccessor.GetHotelGuest();
            //pulls from real manager
            HotelGuest guest = access.GetHotelGuest(guestID);
            //assigns a new value in guest2
            HotelGuest guest2 = new HotelGuest(guest.FirstName, "Individual", guest.Address1, guest.Address2, guest.CityState, guest.PhoneNumber, guest.EmailAddress, guest.Room, guest.GuestPIN, guest.Active);
            //calls to manager to complete update
            ResultsEdit edited = access.UpdateHotelGuest(guest, guest2);

            Assert.AreEqual(ResultsEdit.Success, edited);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Pat Banks
        /// Created 2015/04/11
        /// Handles submit functionality of a hotel guest adding an event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            lblOtherMessage.Text = "";
            string errors = "";

            //if something isn't selected - throw error
            if (gvListings.SelectedValue == null)
            {
                errors += "<li>Please select an event</li>";
            }
            //gets quantity from the quantity field
            if (!txtGuestTickets.Text.ValidateInt(1))
            {
                errors += "<li>You must enter a valid number of tickets.</li>";
                txtGuestTickets.Text = "";
            }
            else
            {
                if (Int32.Parse(txtGuestTickets.Text) > getSelectedItem().QuantityOffered)
                {
                    errors += "<li>You cannot request more tickets than available</li>";
                    txtGuestTickets.Text = "";
                }
            }
            if (!txtGuestPin.Text.ValidateAlphaNumeric())
            {
                errors += "<li>You must enter a valid pin.</li>";
                txtGuestTickets.Text = "";
            }
            if (errors.Length > 0)
            {
                showError("Please fix the following errors: <ul>" + errors + "</ul>");
                return;
            }
            try
            {
                string inPin = txtGuestPin.Text;

                //see if pin was found = if not there will be an exception
                foundGuest = myManager.CheckValidPIN(inPin);
            }
            catch (Exception)
            {
                showError("You must enter a valid pin.");
            }

            gatherFormInformation();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Pat Banks
        /// Created:  2015/03/03
        /// Constructs a populated form that shows the final charges for a guest and
        /// allows employee to submit to close the invoice
        /// </summary>
        /// <param name="selectedHotelGuestId">Guest selected from the ViewInvoiceUI</param>
        /// <exception cref="WanderingTurtleException">Child window errored during initialization.</exception>
        public ArchiveInvoice(int selectedHotelGuestId)
        {
            try
            {
                InitializeComponent();
                CurrentInvoice = _invoiceManager.RetrieveInvoiceByGuest(selectedHotelGuestId);
                Title          = "Archiving Invoice";

                _guestToView   = _hotelGuestManager.GetHotelGuest(CurrentInvoice.HotelGuestID);
                _myBookingList = _invoiceManager.RetrieveGuestBookingDetailsList(CurrentInvoice.HotelGuestID);
                FillFormFields();
            }
            catch (Exception ex)
            {
                throw new WanderingTurtleException(this, ex);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Arik Chadima
        /// Created: 2015/4/30
        /// Refactored->Extracted method for reuse.
        /// </summary>
        private void ResetVariables()
        {
            foundGuest          = null;
            ticketQty           = 0;
            guestName           = "";
            eventName           = "";
            date                = DateTime.Now;
            discount            = 0;
            totalPrice          = 0;
            extendedPrice       = 0m;
            selectedItemListing = null;

            //create new session variables
            Session["foundGuest"]          = foundGuest;
            Session["ticketQty"]           = ticketQty;
            Session["selectedItemListing"] = selectedItemListing;
            Session["extendedPrice"]       = extendedPrice;
            Session["totalPrice"]          = totalPrice;
            Session["discount"]            = discount;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Pat Banks
        /// Created: 2015/03/03
        /// Opens the EditGuest UI as dialog box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEditGuest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //retrieve the guest information
                HotelGuest selectedGuest = _hotelGuestManager.GetHotelGuest(CurrentInvoice.HotelGuestID);

                //refreshes guest information after AddEditHotelGuest UI
                if (new AddEditHotelGuest(selectedGuest).ShowDialog() == false)
                {
                    return;
                }
                RefreshGuestInformation(CurrentInvoice.HotelGuestID);
                Result = true;
            }
            catch (Exception ex)
            {
                throw new WanderingTurtleException(this, ex);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Miguel Santana
 /// Created: 2015/02/12
 /// Creates a new Hotel Guest in the database
 /// </summary>
 /// <remarks>
 /// Rose Steffensmeier
 /// Updated: 2015/03/10
 ///
 /// Rose Steffensmeier
 /// Updated: 2015/03/12
 /// Updated try/catch blocks
 ///
 /// Tony Noel
 /// Updated 2015/04/13 by
 /// Updated to comply with the ResultsEdit class of error codes.
 /// </remarks>
 /// <param name="newHotelGuest">Object containing new hotel guest information</param>
 /// <returns>Number of rows effected</returns>
 public ResultsEdit AddHotelGuest(HotelGuest newHotelGuest)
 {
     try
     {
         bool worked = HotelGuestAccessor.HotelGuestAdd(newHotelGuest) > 0;
         if (worked == true)
         {
             return(ResultsEdit.Success);
         }
     }
     catch (SqlException)
     {
         throw;
     }
     catch (Exception)
     {
         throw;
     }
     return(ResultsEdit.DatabaseError);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Miguel Santana
        /// Created: 2015/02/12
        /// Creates a new Hotel Guest in the database
        /// </summary>
        /// <remarks>
        /// Pat Banks
        /// Updated: 2015/02/27
        /// Stored Procedure updated to create an invoice record automatically when adding a hotel guest
        ///
        /// Rose Steffensmeier
        /// Updated: 2015/03/12
        /// Added try-catch blocks
        ///
        /// Pat Banks
        /// Updated: 2015/04/03
        /// Added GuestPIN field
        /// </remarks>
        /// <param name="newHotelGuest">Object containing new hotel guest information</param>
        /// <returns>Number of rows effected</returns>
        public static int HotelGuestAdd(HotelGuest newHotelGuest)
        {
            var conn    = DatabaseConnection.GetDatabaseConnection();
            var cmdText = "spInsertHotelGuestInsertInvoice";
            var cmd     = new SqlCommand(cmdText, conn);
            var numRows = 0;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@firstName", newHotelGuest.FirstName);
            cmd.Parameters.AddWithValue("@lastName", newHotelGuest.LastName);
            cmd.Parameters.AddWithValue("@zip", newHotelGuest.CityState.Zip);
            cmd.Parameters.AddWithValue("@address1", newHotelGuest.Address1);
            cmd.Parameters.AddWithValue("@address2", newHotelGuest.Address2);
            cmd.Parameters.AddWithValue("@phoneNumber", newHotelGuest.PhoneNumber);
            cmd.Parameters.AddWithValue("@email", newHotelGuest.EmailAddress);
            cmd.Parameters.AddWithValue("@room", newHotelGuest.Room);
            cmd.Parameters.AddWithValue("@guestPIN", newHotelGuest.GuestPIN);

            try
            {
                conn.Open();
                numRows = cmd.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(numRows);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Miguel Santana
 /// Created: 2015/02/12
 ///
 /// Updates a hotel guest with new information
 /// </summary>
 /// <remarks>
 /// Rose Steffensmeier
 /// Updated: 2015/03/12
 /// Updated try/catch blocks
 ///
 /// Tony Noel
 /// Updated 2015/04/13
 /// Updated to comply with the ResultsEdit class of error codes.
 /// </remarks>
 /// <param name="oldHotelGuest">Object containing original information about a hotel guest</param>
 /// <param name="newHotelGuest">Object containing new hotel guest information</param>
 /// <returns>Number of rows effected</returns>
 public ResultsEdit UpdateHotelGuest(HotelGuest oldHotelGuest, HotelGuest newHotelGuest)
 {
     try
     {
         bool worked = HotelGuestAccessor.HotelGuestUpdate(oldHotelGuest, newHotelGuest) > 0;
         if (worked == true)
         {
             return(ResultsEdit.Success);
         }
     }
     catch (ApplicationException)
     {
         throw;
     }
     catch (SqlException)
     {
         throw;
     }
     catch (Exception)
     {
         throw;
     }
     return(ResultsEdit.DatabaseError);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Pat Banks
        /// Created:  2015/04/14
        /// Verifies the hotel guest pin to sign up for an item listing and create a booking
        /// </summary>
        /// <param name="inPIN">The pin to cross reference against HotelGuests</param>
        /// <returns>Hotel guest that has that pin</returns>
        public static HotelGuest VerifyHotelGuestPin(string inPIN)
        {
            SqlConnection conn = DatabaseConnection.GetDatabaseConnection();

            var        cmdText = "spSelectHotelGuestByPin";
            SqlCommand cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@guestPIN", inPIN);

            HotelGuest foundGuest = null;

            try
            {
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        foundGuest = new HotelGuest(
                            reader.GetInt32(0),                                 //HotelGuestID
                            reader.GetString(1),                                //FirstName
                            reader.GetString(2),                                //LastName
                            reader.GetString(3),                                //Address1
                            !reader.IsDBNull(4) ? reader.GetString(4) : null,   //Address2
                            new CityState(
                                reader.GetString(5),                            //Zip
                                reader.GetString(6),                            //City
                                reader.GetString(7)                             //State
                                ),
                            !reader.IsDBNull(8) ? reader.GetString(8) : null,   //PhoneNumber
                            !reader.IsDBNull(9) ? reader.GetString(9) : null,   //EmailAdddress
                            !reader.IsDBNull(10) ? reader.GetString(10) : null, //Room
                            !reader.IsDBNull(11) ? reader.GetString(11) : null, // PIN
                            reader.GetBoolean(12)                               //Active
                            );
                    } // end while
                }
                else
                {
                    var ax = new ApplicationException("PIN not found");
                    throw ax;
                }
            }
            catch (SqlException)
            {
                var ax = new ApplicationException("PIN not found");
                throw ax;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(foundGuest);
        }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
0
        public void Full()
        {
            // 1 - cadastro das categorias
            ICategoryRepository categoryRepository = new CategoryRepository();

            Category categorySingle = new Category("Single", 230);

            categoryRepository.Create(categorySingle);

            Category categoryStandard = new Category("Standard", 310);

            categoryRepository.Create(categoryStandard);

            Category categoryLuxo = new Category("Luxo", 470);

            categoryRepository.Create(categoryLuxo);

            Assert.True(categoryRepository.Get().Count == 3);

            // 2 - cadastro do quarto

            IRoomRepository roomRepository = new RoomRepository();

            Room roomSingle01 = new Room("01", categorySingle);

            roomRepository.Create(roomSingle01);

            Room roomSingle02 = new Room("02", categorySingle);

            roomRepository.Create(roomSingle02);

            Room roomStandard03 = new Room("03", categoryStandard);

            roomRepository.Create(roomStandard03);

            Room roomStandard04 = new Room("04", categoryStandard);

            roomRepository.Create(roomStandard04);

            Room roomLuxo05 = new Room("05", categoryLuxo);

            roomRepository.Create(roomLuxo05);

            Room roomLuxo06 = new Room("05", categoryLuxo);

            roomRepository.Create(roomLuxo05);

            Assert.True(roomRepository.Get().Count == 6);

            // 3 - cadstro do hospede
            IHotelGuestRepository hotelGuestRepositoryRepository = new HotelGuestRepository();

            HotelGuest hotelGuest = new HotelGuest("João de Barro", "*****@*****.**", "000.111.222-33", "(19) 99999-9999");

            hotelGuestRepositoryRepository.Create(hotelGuest);

            Assert.True(hotelGuestRepositoryRepository.Get().Count == 1);

            // 4 - cadastro da reserva
            IBookingRepository bookingRepository = new BookingRepository();

            Booking booking = new Booking(hotelGuest, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), roomSingle01);

            bookingRepository.Create(booking);

            Assert.True(bookingRepository.Get().Count == 1);
        }
Ejemplo n.º 16
0
 public void HotelManagerGetFail()
 {
     HotelGuest guest = access.GetHotelGuest(-1);
 }
Ejemplo n.º 17
0
        public void HotelManagerGet()
        {
            HotelGuest guest = access.GetHotelGuest(100);

            Assert.AreEqual(100, guest.HotelGuestID);
        }
Ejemplo n.º 18
0
 public void initialize()
 {
     //Contructs the HotelGuest object to be used for all tests.
     TestGuest = new HotelGuest("Fake", "Person", "1111 Fake St.", "", new CityState("52641", "Mt. Pleasant", "IA"), "5556667777", "*****@*****.**", "234234", "3453", true);
 }