Esempio n. 1
0
 private void btnDeleteBooking_Click(object sender, EventArgs e)
 {
     myBookings.BookingID = Convert.ToInt16(txtBookingID2.Text);
     BookingsTextFields();
     myBookings.deleteBooking();
     dgvBookings.DataSource = myBookings.viewBookings();
 }
        public void testDeleteBooking()
        {
            SeatBookingClass        booking1        = new SeatBookingClass("Stall", "M", 5, 1);
            List <SeatBookingClass> SeatsToBookList = new List <SeatBookingClass>();

            SeatsToBookList.Add(booking1);
            BookingsClass.newBooking(1, "2017-06-28 12:00", 0, SeatsToBookList);

            SeatBookingClass booking2 = new SeatBookingClass("Stall", "M", 6, 1);

            SeatsToBookList[0] = booking2;
            BookingsClass.newBooking(2, "2017-06-27 12:00", 0, SeatsToBookList);

            BookingsClass.deleteBooking(2);
            dataSet = BookingsClass.getBookingDetailsById(2);
            int actualBookingRowCount   = dataSet.Tables[0].Rows.Count;
            int expectedBookingRowCount = 0;

            dataSet = SeatsClass.getSeatDetails("Stall", "M", 5, 1);
            int actualSeatBookingId  = int.Parse(dataSet.Tables[0].Rows[0]["booking_Id"].ToString());
            int epectedSeatBookingId = 0;

            Assert.AreEqual(expectedBookingRowCount, actualBookingRowCount);
            Assert.AreEqual(epectedSeatBookingId, actualSeatBookingId);
        }
 private void DeleteBooking_button_Click(object sender, RoutedEventArgs e)
 {
     if (Surname_ManageBooking_combo.Items.Count == 0)
     {
         MessageBox.Show("Please search for a customer to be deleted");
     }
     else
     {
         int chosenCustomerID = int.Parse(this.Surname_ManageBooking_combo.SelectedValue.ToString());
         if (CustomerClass.getAllBookkingsMadeByCustomer(chosenCustomerID).Tables[0].Rows.Count == 0)
         {
             MessageBox.Show("No Booking available to be deleted");
         }
         else
         {
             if (AvailableBookings_DataGrid.SelectedIndex == 1)
             {
                 MessageBox.Show("Empty row - Please select a valid booking");
             }
             else
             {
                 if (AvailableBookings_DataGrid.SelectedItem == null)
                 {
                     MessageBox.Show("No Booking selected");
                 }
                 else
                 {
                     DataRowView      chosenRow        = (DataRowView)AvailableBookings_DataGrid.SelectedItem;
                     int              chosenId         = int.Parse(chosenRow["Booking_Id"].ToString());
                     MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo);
                     if (messageBoxResult == MessageBoxResult.Yes)
                     {
                         BookingsClass.deleteBooking(chosenId);
                         MessageBox.Show("Booking deleted");
                     }
                     else
                     {
                         MessageBox.Show("Delete cancelled");
                     }
                 }
             }
         }
     }
 }