Пример #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DetailBookings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDetailBookings(DetailBooking detailBooking)
 {
     base.AddObject("DetailBookings", detailBooking);
 }
Пример #2
0
 /// <summary>
 /// Create a new DetailBooking object.
 /// </summary>
 /// <param name="bookingId">Initial value of the BookingId property.</param>
 /// <param name="flightId">Initial value of the FlightId property.</param>
 public static DetailBooking CreateDetailBooking(global::System.Int32 bookingId, global::System.String flightId)
 {
     DetailBooking detailBooking = new DetailBooking();
     detailBooking.BookingId = bookingId;
     detailBooking.FlightId = flightId;
     return detailBooking;
 }
        private void btnFinish_Click(object sender, EventArgs e)
        {
            //validasikan user sudah memilih passengerId dan paymentType
            if (cmbId.SelectedIndex < 0)
            {
                MessageBox.Show("Please select passenger id");
            }
            else if (cmbType.SelectedIndex < 0)
            {
                MessageBox.Show("Please select payment type");
            }
            else
            {
                //tampilkan dialog konfirmasi
                DialogResult res = MessageBox.Show(this,"Are you sure?","Confirmation",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
                if (res == DialogResult.Yes)
                {
                    //apabila user memilih yes, maka insert data ke Booking dan DetailBooking
                    Ticket.payment = cmbType.SelectedItem.ToString();
                    int newId = generateId();
                    Booking obj = new Booking();
                    obj.BookingId = newId;
                    obj.BookingDate = DateTime.Now.Date;
                    obj.PaymentType = cmbType.SelectedItem.ToString();
                    obj.PassengerId = cmbId.SelectedItem.ToString();
                    obj.EmployeeId = Form1.userLogin.EmployeeId;

                    ent.AddToBookings(obj);
                    ent.SaveChanges();

                    DetailBooking obj2 = new DetailBooking();
                    obj2.BookingId = newId;
                    obj2.FlightId = Ticket.flight1;

                    ent.AddToDetailBookings(obj2);
                    ent.SaveChanges();

                    if (Ticket.returned)
                    {
                        DetailBooking obj3 = new DetailBooking();
                        obj3.BookingId = newId;
                        obj3.FlightId = Ticket.flight2;

                        ent.AddToDetailBookings(obj3);
                        ent.SaveChanges();
                    }

                    BookTicketStep3Form final = new BookTicketStep3Form();
                    final.Show();
                    this.Dispose();
                }
            }
        }