Ejemplo n.º 1
0
        private void appBar_OnSave(object sender, EventArgs e)
        {

            try
            {
                if (DestinationLocationtxt.Text == "" && currentLocationtxt.Text == "")
                {
                    MessageBox.Show("Select Destination and Current Location.");
                    return;
                }
                else if (DestinationLocationtxt.Text == "")
                {
                    MessageBox.Show("Enter Destination Location");
                    return;
                }
                else if (currentLocationtxt.Text == "")
                {
                    MessageBox.Show("Acquire Current Location");
                    return;
                }
                string Type = cab_type.SelectedItem.ToString();
                DateTime objDate = Convert.ToDateTime(datePicker.Value);
                string Date = objDate.ToString("dd-MM-yyyy");
                DateTime objTime = Convert.ToDateTime(timePicker.Value);
                string Time = objTime.ToString("hh:mm tt");

                DateTime BookingDateTime = new DateTime(objDate.Year, objDate.Month, objDate.Day,
                              objTime.Hour, objTime.Minute, objTime.Second);
                //DateTime current = DateTime.Now;

                //MessageBox.Show(BookingDateTime.ToString("dd-MMM-yyy hh:mm:ss tt"));
                //MessageBox.Show(current.ToString());

                MainPage.bookingData.SetPreferences(Date, Time, Type);

                Booking bookingInstance = new Booking(currentLocationtxt.Text, DestinationLocationtxt.Text, BookingDateTime, Type);

                MessageBoxButton button = MessageBoxButton.OKCancel;   // ("Are you sure?");
                MessageBoxResult result = MessageBox.Show("Are you sure?", "", button);
                if (result == MessageBoxResult.OK)
                {
                    // ------------------------------- Remote call to web service (for booking) ----------------------------------
                    ServiceReference1.ServiceClient clientForTesting = new ServiceReference1.ServiceClient();
                    clientForTesting.CabBookingCompleted += new EventHandler<ServiceReference1.CabBookingCompletedEventArgs>(TestCallback);
                    clientForTesting.CabBookingAsync(bookingInstance.BookingStatus, bookingInstance.BookingDateTime, bookingInstance.BookingOrigin, bookingInstance.BookingDestination, bookingInstance.BookingCabType, Booking.SourceLat, Booking.SourceLong, Booking.DestinationLat, Booking.DestinationLong,ForGlobalVariables.LoginDetails.CustomerID.ToString());

                    //MessageBox.Show("Cab Booking Request Sent!" + "\n" + "Current Location: " + currentLocationtxt.Text + "\n" + "Destination: " + DestinationLocationtxt.Text + "\n" + "Cab Type: " + cab_type.SelectedItem.ToString());

                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }