Ejemplo n.º 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (Convert.ToInt32(seatText.Text) < 120)                           //let 120 be the maximum number of seats on the aircraft
     {
         if (availableSeat() == true)
         {
             Booking booking = new Booking();
             booking.CustomerId    = Convert.ToInt32(customerIdText.Text);
             booking.SeatNo        = Convert.ToInt32(seatText.Text);
             booking.DateOfJourney = dateOfJourneyText.Value;
             booking.FlightId      = Convert.ToInt32(flightIdText.Text);
             db.Bookings.Add(booking);
             db.SaveChanges();
             MessageBox.Show("Flight booked!");
         }
         else
         {
             MessageBox.Show("Sorry! This seat is already booked");
         }
     }
     else
     {
         MessageBox.Show("There's only 120 seats on the aircraft!");
     }
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            FlightDetail flightDetail = new FlightDetail();

            flightDetail.FlightName    = flightNameText.Text;
            flightDetail.Source        = sourceText.Text;
            flightDetail.Destination   = destinationText.Text;
            flightDetail.Departure     = departureText.Text;
            flightDetail.ArrivalTime   = arrivalTimeText.Text;
            flightDetail.FlightClass   = flightClassText.Text;
            flightDetail.FlightCharges = Convert.ToDecimal(flightChargesText.Text);
            flightDetail.Seats         = Convert.ToInt32(seatsText.Text);
            db.FlightDetails.Add(flightDetail);
            db.SaveChanges();
            MessageBox.Show("Added flight!");
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            db = new AirlineDbEntities();
            CustomerDetail cust = db.CustomerDetails.Where(a => a.Id == id).FirstOrDefault();

            cust.Name       = nameText.Text;
            cust.FatherName = fnameText.Text;
            cust.BirthDate  = birthDateText.Value;
            cust.Email      = emailText.Text;
            cust.Phone      = phoneText.Text;
            cust.Address    = addressText.Text;
            //db.CustomerDetails.Attach(cust);
            db.SaveChanges();
            MessageBox.Show("Customer modified!");

            th = new Thread(openNewForm);                               //close this window, and open new
            th.SetApartmentState(ApartmentState.STA);
            th.Start();
            this.Close();
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            AirlineDbEntities db        = new AirlineDbEntities();
            CustomerDetail    customers = new CustomerDetail
            {
                Name       = nameText.Text,
                FatherName = fnameText.Text,
                BirthDate  = birthDateText.Value,
                Email      = emailText.Text,
                Phone      = phoneText.Text,
                Address    = addressText.Text
            };

            try
            {
                db.CustomerDetails.Add(customers);
                db.SaveChanges();
                MessageBox.Show("Added customer!");
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Database insert exception. ", ex);
            }
        }