public void TestDeleteGuestValid()
        {
            //Arrange
            int validGuestID = _guests[0].GuestID;

            _guestManager.DeactivateGuest(validGuestID);
            //Act
            _guestManager.DeleteGuest(validGuestID);
            //Assert
            _guestManager.ReadGuestByGuestID(validGuestID);
        }
예제 #2
0
        /// <summary>
        /// Alisa Roehr
        /// Created: 2019/03/01
        ///
        /// for deleting guests.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteGuest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dgGuests.SelectedItem != null)
                {
                    Guest guest = _guestManager.ReadGuestByGuestID(((Guest)dgGuests.SelectedItem).GuestID);
                    if (guest.Active == false)
                    {
                        var result = MessageBox.Show("Are you sure you want to delete this guest?", "This guest will no longer be in the system.", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                        if (result == MessageBoxResult.Yes)
                        {
                            _guestManager.DeleteGuest(guest.GuestID);
                            MessageBox.Show("The guest has been purged.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Guest must be deactivated to be deleted.");
                    }
                    _guests = _guestManager.ReadAllGuests();
                    dgGuests.ItemsSource = _guests;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Deleting Guest Failed!");
            }
        }
예제 #3
0
 /// <summary>
 /// 删除一行时执行
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GuestTable_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     SqlDataSource1.DeleteCommand = "SELECT * FROM HOTEL WHERE hID='-1'";
     GuestManager.DeleteGuest(new Guest
     {
         GuestID   = e.Values["gID"].ToString().Trim(),
         GuestName = e.Values["gName"].ToString().Trim(),
         Username  = UsernameLabel.Text
     });
     GuestTable.DataBind();
 }