Esempio n. 1
0
        private async void btnAddNewVehicle_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("type", txtbType.Text.Trim());
            postData.Add("license_plate", txtbVehiclePlate.Text.Trim());
            postData.Add("reg_certificate", txtbRegistrationCertificate.Text.Trim());

            postData.Add("vehicle_img", ImageConvert.ImageConvert.convertImageToBase64(imgVehicle));
            postData.Add("license_plate_img", ImageConvert.ImageConvert.convertImageToBase64(imgLicensePlate));
            postData.Add("motor_insurance_img", ImageConvert.ImageConvert.convertImageToBase64(imgMotorInsurance));

            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);

            var result = await RequestToServer.sendPostRequest("vehicle", content);

            JObject jsonObject = JObject.Parse(result);

            if (jsonObject.Value <bool>("error"))
            {
                MessageBox.Show(jsonObject.Value <string>("message"));
            }
            else
            {
                //Global.GlobalData.isDriver = true;
                MessageBox.Show(jsonObject.Value <string>("message"));
                // refresh lai trang
                NavigationService.Navigate(new Uri("/Driver/VehicleManagement.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Esempio n. 2
0
        private async void btnUpgrade_Click(object sender, RoutedEventArgs e)
        {
            //validate all fields

            //upgrade
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("driver_license", txtbDriverLicense.Text.Trim());

            postData.Add("driver_license_img", ImageConvert.ImageConvert.convertImageToBase64(imgDriverLicense));

            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);
            var result = await RequestToServer.sendPostRequest("driver", content);

            JObject jsonObject = JObject.Parse(result);

            if (jsonObject.Value <bool>("error"))
            {
                MessageBox.Show(jsonObject.Value <string>("message"));
            }
            else
            {
                Global.GlobalData.isDriver = true;
                MessageBox.Show(jsonObject.Value <string>("message"));
                // navigate ve acc info
                NavigationService.Navigate(new Uri("/AccountInfo.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Esempio n. 3
0
        private async void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            //validate

            //send info to server
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("start_address", txtbStart.Text.Trim());
            postData.Add("end_address", txtbEnd.Text.Trim());
            postData.Add("description", txtbDescription.Text.Trim());
            postData.Add("cost", txtbCost.Text.Trim());
            postData.Add("vehicle_id", txtbVehicleID.Text.Trim());
            postData.Add("distance", txtbDistance.Text.Trim());
            postData.Add("start_address_lat", start_lat.Trim());
            postData.Add("start_address_long", start_long.Trim());
            postData.Add("end_address_lat", end_lat.Trim());
            postData.Add("end_address_long", end_long.Trim());

            string date = datePicker.Value.ToString();
            string time = timePicker.Value.ToString();

            postData.Add("leave_date", "2011-07-07 04:04:04");
            postData.Add("duration", txtbCost.Text.Trim());
            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);

            //var result = await RequestToServer.sendGetRequest("itinerary/2", content);
            var result = await RequestToServer.sendPostRequest("itinerary", content);

            JObject jsonObject = JObject.Parse(result);

            MessageBox.Show(jsonObject.Value <string>("message"));

            //back to trang dau tien
        }
Esempio n. 4
0
        private async void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("email", txtbEmail.Text.Trim());
            postData.Add("password", txtbPassword.Text);
            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);
            var result = await RequestToServer.sendPostRequest("user", content);

            JObject jsonObject = JObject.Parse(result);

            MessageBox.Show(jsonObject.Value <string>("message"));
        }
Esempio n. 5
0
        public async void upgradeDriver()
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("driver_license", "");
            postData.Add("driver_license_img", "");
            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);
            var result = await RequestToServer.sendPostRequest("driver", content);

            JObject jsonObject = JObject.Parse(result);

            MessageBox.Show(jsonObject.Value <string>("message"));
        }
Esempio n. 6
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            //test();
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("email", txtbEmail.Text.Trim());
            postData.Add("password", txtbPassword.Text);
            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);

            var result = await RequestToServer.sendPostRequest("user/login", content);

            JObject jsonObject = JObject.Parse(result);

            if (jsonObject.Value <string>("error").Equals("False"))
            {
                //get API key
                Global.GlobalData.APIkey = jsonObject.Value <string>("apiKey").Trim();

                //Global.GlobalData.isDriver = jsonObject.Value<bool>("driver");
                Global.GlobalData.isDriver        = true;
                Global.GlobalData.customer_status = jsonObject.Value <int>("customer_status");
                Global.GlobalData.driver_status   = jsonObject.Value <int>("driver_staus");

                //storage for the next login
                IsolatedStorageSettings.ApplicationSettings["isLogin"]         = "******";
                IsolatedStorageSettings.ApplicationSettings["APIkey"]          = Global.GlobalData.APIkey;
                IsolatedStorageSettings.ApplicationSettings["isDriver"]        = Global.GlobalData.isDriver;
                IsolatedStorageSettings.ApplicationSettings["customer_status"] = Global.GlobalData.customer_status;
                IsolatedStorageSettings.ApplicationSettings["driver_status"]   = Global.GlobalData.driver_status;
                IsolatedStorageSettings.ApplicationSettings.Save();
                //Navigate to MainPage
                if (GlobalData.isDriver)
                {
                    NavigationService.Navigate(new Uri("/Driver/ItineraryManagement.xaml", UriKind.Relative));
                }
                else
                {
                    NavigationService.Navigate(new Uri("/Customer/MainMap.xaml", UriKind.RelativeOrAbsolute));
                }
            }
            else
            {
                MessageBox.Show(jsonObject.Value <string>("message"));
            }
        }
Esempio n. 7
0
        private async void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            //validate

            //send info to server
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("start_address", txtbStart.Text.Trim());
            postData.Add("end_address", txtbEnd.Text.Trim());
            postData.Add("description", txtbDescription.Text.Trim());
            postData.Add("cost", txtbCost.Text.Trim());
            postData.Add("distance", txtbDistance.Text.Trim());
            postData.Add("start_address_lat", start_lat.Trim());
            postData.Add("start_address_long", start_long.Trim());
            postData.Add("end_address_lat", end_lat.Trim());
            postData.Add("end_address_long", end_long.Trim());
            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);

            //var result = await RequestToServer.sendGetRequest("itinerary/2", content);
            var result = await RequestToServer.sendPostRequest("itinerary", content);
        }
Esempio n. 8
0
        private async void btnSend_Click(object sender, RoutedEventArgs e)
        {
            //send rating
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("rating", ratingDriver.Value.ToString().Trim());
            postData.Add("rating_user_id", Global.GlobalData.selectedItinerary.driver_id.ToString().Trim());

            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);

            var result = await RequestToServer.sendPostRequest("rating", content);

            //send comment
            Dictionary <string, string> postData2 = new Dictionary <string, string>();

            postData2.Add("content", txtbComment.Text.Trim());
            postData2.Add("comment_user_id", Global.GlobalData.selectedItinerary.driver_id.ToString().Trim());

            HttpFormUrlEncodedContent content2 =
                new HttpFormUrlEncodedContent(postData);

            var result2 = await RequestToServer.sendPostRequest("rating", content2);
        }
Esempio n. 9
0
        private async void btnSendFeedback_Click(object sender, RoutedEventArgs e)
        {
            StackPanel panel = new StackPanel();

            TextBox txtbUserName     = new TextBox();
            TextBox txtbUserEmail    = new TextBox();
            TextBox txtbUserFeedback = new TextBox();

            txtbUserFeedback.AcceptsReturn = true;
            txtbUserFeedback.TextWrapping  = TextWrapping.Wrap;
            txtbUserFeedback.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            txtbUserFeedback.Height = 150;

            TextBlock b1 = new TextBlock(); b1.Text = "Name: ";
            TextBlock b2 = new TextBlock(); b2.Text = "Email: ";
            TextBlock b3 = new TextBlock(); b3.Text = "Your feedback: ";

            panel.Children.Add(b1);
            panel.Children.Add(txtbUserName);
            panel.Children.Add(b2);
            panel.Children.Add(txtbUserEmail);
            panel.Children.Add(b3);
            panel.Children.Add(txtbUserFeedback);

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                //set the properties
                Caption            = "Send your feedback",
                Message            = "",
                LeftButtonContent  = "Send",
                RightButtonContent = "Cancel"
            };

            messageBox.Content = panel;
            //messageBox.Content = b2;

            //Add the dismissed event handler
            messageBox.Dismissed += async(s1, e1) =>
            {
                switch (e1.Result)
                {
                case CustomMessageBoxResult.LeftButton:

                    Dictionary <string, string> postData = new Dictionary <string, string>();
                    postData.Add("email", txtbUserEmail.Text.Trim());
                    postData.Add("name", txtbUserName.Text.Trim());
                    postData.Add("content", txtbUserFeedback.Text.Trim());


                    HttpFormUrlEncodedContent content =
                        new HttpFormUrlEncodedContent(postData);
                    var result = await RequestToServer.sendPostRequest("feedback", content);

                    JObject jsonObject = JObject.Parse(result);
                    MessageBox.Show(jsonObject.Value <string>("message"));


                    break;

                case CustomMessageBoxResult.RightButton:
                    //add the task you wish to perform when user clicks on no button here

                    break;

                case CustomMessageBoxResult.None:
                    // Do something.
                    break;

                default:
                    break;
                }
            };

            //add the show method
            messageBox.Show();
        }