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 updateVehicleInfo(string type, string motorplate, string reg_certificate)
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("type", type);
            postData.Add("license_plate", motorplate);
            postData.Add("reg_certificate", reg_certificate);

            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.sendPutRequest("vehicle/" + Global.GlobalData.selectedVehicle.vehicle_id, 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("/Refresh.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Esempio n. 3
0
        private async void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            //validate all fields

            //update
            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.sendPutRequest("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"));
                // refresh lai trang
                NavigationService.Navigate(new Uri("/Refresh.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Esempio n. 4
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. 5
0
        public async void updateUserInfo(string fullname, string email, string personalID, string phone)
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("fullname", fullname);
            postData.Add("email", email);
            postData.Add("personalID", personalID);
            postData.Add("phone", phone);

            postData.Add("link_avatar", ImageConvert.ImageConvert.convertImageToBase64(imgAvatar));
            postData.Add("personalID_img", ImageConvert.ImageConvert.convertImageToBase64(imgPersonalID));

            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);
            var result = await RequestToServer.sendPutRequest("user", 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("/Refresh.xaml", UriKind.RelativeOrAbsolute));
            }
        }
Esempio n. 6
0
        public async void getDriverInformation()
        {
            string methodName = "driver";
            var    result     = await RequestToServer.sendGetRequest(methodName);

            JObject jsonObject = JObject.Parse(result);
            //set information to view
        }
Esempio n. 7
0
        public async void getDriverInfo()
        {
            var result = await RequestToServer.sendGetRequest("driver");

            JObject jsonObject = JObject.Parse(result);

            txtbDriverLicense.Text = jsonObject.Value <string>("driver_license");

            //get picture
            imgDriverLicense.Source = ImageConvert.ImageConvert.convertBase64ToImage(jsonObject.Value <string>("driver_license_img").Trim());
        }
Esempio n. 8
0
        public async void updatePassword(string newPassword)
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("value", newPassword);

            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);
            var result = await RequestToServer.sendPutRequest("user/password", content);

            JObject jsonObject = JObject.Parse(result);

            MessageBox.Show(jsonObject.Value <string>("message"));
        }
Esempio n. 9
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. 10
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. 11
0
        public async void getUserInfo()
        {
            var result = await RequestToServer.sendGetRequest("user");

            JObject jsonObject = JObject.Parse(result);

            txtbEmail.Text      = jsonObject.Value <string>("email");
            txtbFullname.Text   = jsonObject.Value <string>("fullname");
            txtbPhone.Text      = jsonObject.Value <string>("phone");
            txtbPersonalID.Text = jsonObject.Value <string>("personalID");

            //get picture
            imgAvatar.Source     = ImageConvert.ImageConvert.convertBase64ToImage(jsonObject.Value <string>("link_avatar"));
            imgPersonalID.Source = ImageConvert.ImageConvert.convertBase64ToImage(jsonObject.Value <string>("personalID_img"));
        }
Esempio n. 12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            RequestToServer req  = new RequestToServer(this);
            BBCNews         data = new BBCNews();

            _data = new BBCNewsList(data);

            _btnSearch.TouchUpInside += Search_Clicked;
            _searchTextField.Text     = "";

            _myCollectionView.RegisterNibForCell(MyCollectionViewCell.Nib, MyCollectionViewCell.Key);
            _dataDelegate = new DataDelegate();
            _myCollectionView.Delegate   = _dataDelegate;
            _myCollectionView.DataSource = new DataSourceNews(this, _data, NavigationController);
        }
Esempio n. 13
0
        public async void getUserInformation()
        {
            string methodName = "user";
            var    result     = await RequestToServer.sendGetRequest(methodName);

            JObject jsonObject = JObject.Parse(result);

            //set information to view
            txtboxEmail.Text       = jsonObject.Value <string>("email");
            txtboxPhone.Text       = jsonObject.Value <string>("phone");
            txtboxPersionalId.Text = jsonObject.Value <string>("personalID");
            txtblockFullName.Text  = jsonObject.Value <string>("fullname");
            //set Image
            imgAvatar.Source     = ImageConvert.ImageConvert.convertBase64ToImage(jsonObject.Value <string>("link_avatar").Trim());
            imgPersonalID.Source = ImageConvert.ImageConvert.convertBase64ToImage(jsonObject.Value <string>("personalID_img").Trim());
        }
Esempio n. 14
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. 15
0
        public async void updateUserInfomation()
        {
            Dictionary <string, string> postData = new Dictionary <string, string>();

            postData.Add("fullname", "");
            postData.Add("phone", "");
            postData.Add("personalID", "");
            postData.Add("personalID_img", "");
            postData.Add("link_avatar", "");
            postData.Add("locked", "");
            HttpFormUrlEncodedContent content =
                new HttpFormUrlEncodedContent(postData);
            var result = await RequestToServer.sendPutRequest("user", content);

            JObject jsonObject = JObject.Parse(result);

            MessageBox.Show(jsonObject.Value <string>("message"));
        }
Esempio n. 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ChatLayout);

            req = new RequestToServer(this);

            mRecyclerView  = FindViewById <RecyclerView>(Resource.Id.recycler_view);
            mLayoutManager = new LinearLayoutManager(this);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            mUserCollection = new RecyclerAdapter(new BBCNewsList(new BBCNews()));
            mRecyclerView.SetAdapter(mUserCollection);


            var searchButtor = FindViewById <Button>(Resource.Id.search_button);

            searchButtor.Click += SearchButtor_Click;
        }
Esempio n. 17
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. 18
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. 19
0
 public async void getChartInfo()
 {
     var result = await RequestToServer.sendGetRequest("user");
 }
Esempio n. 20
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();
        }