Esempio n. 1
0
    public int cancel(int bookingid)
    {
        Airline2DataSet1TableAdapters.bookingTableAdapter adp5 = new Airline2DataSet1TableAdapters.bookingTableAdapter();

        if (adp5.checkBooking(bookingid) != null )
        {

            string seat_type = adp5.getSeatType(bookingid);
            int route_id = (int)adp5.getRouteID(bookingid);
            int book_seat = (int)adp5.getNoOfSeat(bookingid);

            Airline2DataSet1TableAdapters.flightTableAdapter adp6 = new Airline2DataSet1TableAdapters.flightTableAdapter();

            if (seat_type == "A")
            {
                int seat = (int)adp6.getAvailableSeatA(route_id);

                adp6.UpdateSeatA((seat + book_seat), route_id);
                adp5.DeleteBooking(bookingid);
                return 1;

            }

            else if (seat_type == "B")
            {
                int seat = (int)adp6.getAvailableSeatB(route_id);

                adp6.UpdateSeatB((seat + book_seat), route_id);
                adp5.DeleteBooking(bookingid);
                return 1;

            }

            else if (seat_type == "C")
            {
                int seat = (int)adp6.getAvailableSeatC(route_id);

                adp6.UpdateSeatC((seat + book_seat), route_id);
                adp5.DeleteBooking(bookingid);
                return 1;

            }

            else
            {
                return 0;
            }
        }
        else
        {
            return 0;

        }
    }