private void button4_Click(object sender, EventArgs e) { if (_dictPassengers.Count > 0) { DateTime flightDepartureDate = (DateTime)dgvFlightInformation["DepartureTime", dgvFlightInformation.CurrentRow.Index].Value; string from = (string)cmbFrom.SelectedValue; string to = (string)cmbTo.SelectedValue; PassengerInfo[] passengers = new PassengerInfo[_dictPassengers.Count]; int i = 0; Dictionary <string, PassengerInfo> .Enumerator enumerator = _dictPassengers.GetEnumerator(); while (enumerator.MoveNext()) { passengers[i++] = enumerator.Current.Value; } PaymentInfo payment = new PaymentInfo(); payment.cardholdername = txtHolderName.Text; payment.cardname = txtCardName.Text; payment.cv2 = txtCardPin.Text; payment.expiryDate = dtpCardExpiry.Value; FBooking.FlightBookingServiceClient flightBooking = new FlightBookingServiceClient(); try { if (flightBooking.checkAvailability(from, to, flightDepartureDate, passengers.Length)) { MessageBox.Show("Seats Available..."); if (flightBooking.makeReservation(from, to, flightDepartureDate, passengers, payment)) { MessageBox.Show("Successfully reserved..."); } else { MessageBox.Show("Reservation unsuccessful..."); } } else { MessageBox.Show("Seats Unavailable..."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (flightBooking.State == CommunicationState.Faulted) { flightBooking = new FlightBookingServiceClient(); } flightBooking.Close(); } } else { MessageBox.Show("Please atleast one passenger..."); } }
private void btnBookRoom_Click(object sender, EventArgs e) { if (_dictPassengers.Count > 0) { Package packageInfo = (Package)cmbPackage.SelectedItem; string from = packageInfo.From; string to = packageInfo.To; DateTime flightDepartureDate = (DateTime)dgvFlightInformation["DepartureTime", dgvFlightInformation.CurrentRow.Index].Value; DateTime end = flightDepartureDate.AddDays(packageInfo.Duration); PassengerInfo[] passengers = new PassengerInfo[_dictPassengers.Count]; int i = 0; Dictionary<string, PassengerInfo>.Enumerator enumerator = _dictPassengers.GetEnumerator(); while (enumerator.MoveNext()) passengers[i++] = enumerator.Current.Value; PaymentInfo payment = new PaymentInfo(); payment.cardholdername = txtHolderName.Text; payment.cardname = txtCardName.Text; payment.cv2 = txtCardPin.Text; payment.expiryDate = dtpCardExpiry.Value; FBooking.FlightBookingServiceClient flightBooking = new FlightBookingServiceClient(); using (TransactionScope ts = new TransactionScope()) { try { if (flightBooking.checkAvailability(from, to, flightDepartureDate, passengers.Length)) { MessageBox.Show("Flight Seats Available..."); if (flightBooking.makeReservation(from, to, flightDepartureDate, passengers, payment)) MessageBox.Show("Flight Reservation Successful..."); else throw new Exception("Flight Reservation unsuccessful..."); } else throw new Exception("Seats Unavailable..."); string cartType = txtCardType.Text; string guestAccount = txtGuestAccount.Text; string guestName = txtGuestName.Text; string guestPassport = txtGuestPassport.Text; int duration = packageInfo.Duration; int numberOfGuest = _dictPassengers.Count; string roomNo = (string)dgvRoomDetails["roomNo", dgvRoomDetails.CurrentRow.Index].Value; if (_hotelBooking.checkRoomAvailability(roomNo, dtpStartDate.Value.ToString(), duration)) { MessageBox.Show("Hotel Room Available..."); MessageBox.Show(_hotelBooking.makeRoomReservation(cartType, guestAccount, guestName, guestPassport, duration, numberOfGuest, roomNo, dtpStartDate.Value.ToString(), "")); } else throw new Exception("Hotel Room Unavailable.."); ts.Complete(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } }
private void button4_Click(object sender, EventArgs e) { if (_dictPassengers.Count > 0) { DateTime flightDepartureDate = (DateTime)dgvFlightInformation["DepartureTime", dgvFlightInformation.CurrentRow.Index].Value; string from = (string)cmbFrom.SelectedValue; string to = (string)cmbTo.SelectedValue; PassengerInfo[] passengers = new PassengerInfo[_dictPassengers.Count]; int i = 0; Dictionary<string, PassengerInfo>.Enumerator enumerator = _dictPassengers.GetEnumerator(); while (enumerator.MoveNext()) passengers[i++] = enumerator.Current.Value; PaymentInfo payment = new PaymentInfo(); payment.cardholdername = txtHolderName.Text; payment.cardname = txtCardName.Text; payment.cv2 = txtCardPin.Text; payment.expiryDate = dtpCardExpiry.Value; FBooking.FlightBookingServiceClient flightBooking = new FlightBookingServiceClient(); try { if (flightBooking.checkAvailability(from, to, flightDepartureDate, passengers.Length)) { MessageBox.Show("Seats Available..."); if (flightBooking.makeReservation(from, to, flightDepartureDate, passengers, payment)) MessageBox.Show("Successfully reserved..."); else MessageBox.Show("Reservation unsuccessful..."); } else MessageBox.Show("Seats Unavailable..."); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (flightBooking.State == CommunicationState.Faulted) flightBooking = new FlightBookingServiceClient(); flightBooking.Close(); } } else { MessageBox.Show("Please atleast one passenger..."); } }
private void btnBookRoom_Click(object sender, EventArgs e) { if (_dictPassengers.Count > 0) { Package packageInfo = (Package)cmbPackage.SelectedItem; string from = packageInfo.From; string to = packageInfo.To; DateTime flightDepartureDate = (DateTime)dgvFlightInformation["DepartureTime", dgvFlightInformation.CurrentRow.Index].Value; DateTime end = flightDepartureDate.AddDays(packageInfo.Duration); PassengerInfo[] passengers = new PassengerInfo[_dictPassengers.Count]; int i = 0; Dictionary <string, PassengerInfo> .Enumerator enumerator = _dictPassengers.GetEnumerator(); while (enumerator.MoveNext()) { passengers[i++] = enumerator.Current.Value; } PaymentInfo payment = new PaymentInfo(); payment.cardholdername = txtHolderName.Text; payment.cardname = txtCardName.Text; payment.cv2 = txtCardPin.Text; payment.expiryDate = dtpCardExpiry.Value; FBooking.FlightBookingServiceClient flightBooking = new FlightBookingServiceClient(); using (TransactionScope ts = new TransactionScope()) { try { if (flightBooking.checkAvailability(from, to, flightDepartureDate, passengers.Length)) { MessageBox.Show("Flight Seats Available..."); if (flightBooking.makeReservation(from, to, flightDepartureDate, passengers, payment)) { MessageBox.Show("Flight Reservation Successful..."); } else { throw new Exception("Flight Reservation unsuccessful..."); } } else { throw new Exception("Seats Unavailable..."); } string cartType = txtCardType.Text; string guestAccount = txtGuestAccount.Text; string guestName = txtGuestName.Text; string guestPassport = txtGuestPassport.Text; int duration = packageInfo.Duration; int numberOfGuest = _dictPassengers.Count; string roomNo = (string)dgvRoomDetails["roomNo", dgvRoomDetails.CurrentRow.Index].Value; if (_hotelBooking.checkRoomAvailability(roomNo, dtpStartDate.Value.ToString(), duration)) { MessageBox.Show("Hotel Room Available..."); MessageBox.Show(_hotelBooking.makeRoomReservation(cartType, guestAccount, guestName, guestPassport, duration, numberOfGuest, roomNo, dtpStartDate.Value.ToString(), "")); } else { throw new Exception("Hotel Room Unavailable.."); } ts.Complete(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } }