Example #1
0
    public int booking(int route_id,int no_of_seat,string seat_type,string from, string to,string trip_type,double ticket_price,double total_price)
    {
        Airline2DataSet1TableAdapters.bookingTableAdapter adp2 = new Airline2DataSet1TableAdapters.bookingTableAdapter();

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

        Airline2DataSet1TableAdapters.ticketpriceTableAdapter adp4 = new Airline2DataSet1TableAdapters.ticketpriceTableAdapter();

        if (seat_type == "A")
        {
            int noA = (int)adp3.getAvailableSeatA(route_id);
            if (noA >= no_of_seat)
            {
                if (ticket_price >= (double)adp4.getCostPrice("A") && ticket_price <= (double)adp4.getMaxPrice("A"))
                {
                    adp2.Insert(route_id, no_of_seat, seat_type, from, to, trip_type, ticket_price, total_price);
                    adp3.UpdateSeatA((noA - no_of_seat), route_id);
                    return 1;
                }

                else
                {
                    return 0;
                }

            }
            else
            {
                return 0;
            }

        }

        else if (seat_type == "B")
        {
            int noB = (int)adp3.getAvailableSeatB(route_id);
            if (noB >= no_of_seat)
            {
                if (ticket_price >= (double)adp4.getCostPrice("B") && ticket_price <= (double)adp4.getMaxPrice("B"))
                {
                    adp2.Insert(route_id, no_of_seat, seat_type, from, to, trip_type, ticket_price, total_price);
                    adp3.UpdateSeatB((noB - no_of_seat), route_id);
                    return 1;
                }

                else
                {
                    return 0;
                }

            }
            else
            {
                return 0;
            }

        }

        else if (seat_type == "C")
        {
            int noC = (int)adp3.getAvailableSeatC(route_id);
            if (noC >= no_of_seat)
            {
                if (ticket_price >= (double)adp4.getCostPrice("C") && ticket_price <= (double)adp4.getMaxPrice("C"))
                {
                    adp2.Insert(route_id, no_of_seat, seat_type, from, to, trip_type, ticket_price, total_price);
                    adp3.UpdateSeatC((noC - no_of_seat), route_id);
                    return 1;
                }

                else
                {
                    return 0;
                }

            }
            else
            {
                return 0;
            }

        }

        else
        {
            return 0;
        }
    }
Example #2
0
 public double getCostPrice(string seat_type)
 {
     Airline2DataSet1TableAdapters.ticketpriceTableAdapter adp11 = new Airline2DataSet1TableAdapters.ticketpriceTableAdapter();
     return (double)adp11.getCostPrice(seat_type);
 }