public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { try { var view = inflater.Inflate(Resource.Layout.activity_application_processing, container, false); List <Place.Field> fields = new List <Place.Field>(); fields.Add(Place.Field.Id); fields.Add(Place.Field.Name); fields.Add(Place.Field.LatLng); fields.Add(Place.Field.Address); #region Инициализаия переменных SizeInputLayout = view.FindViewById <TextInputLayout>(Resource.Id.SizeInputLayout); LInputCargoInsurance = view.FindViewById <TextInputLayout>(Resource.Id.ApplicationInputLayoutCargoInsurance); LInputTime = view.FindViewById <TextInputLayout>(Resource.Id.ApplicationInputLayoutTime); LInputDate = view.FindViewById <TextInputLayout>(Resource.Id.ApplicationInputLayoutDate); LInputContactPerson = view.FindViewById <TextInputLayout>(Resource.Id.ApplicationInputLayoutContactPerson); btn_make_request = view.FindViewById <Button>(Resource.Id.btn_make_request); s_edit_from = view.FindViewById <EditText>(Resource.Id.s_edit_from); s_edit_where = view.FindViewById <EditText>(Resource.Id.s_edit_where); s_shipment_time = view.FindViewById <EditText>(Resource.Id.s_shipment_time); s_shipping_date = view.FindViewById <EditText>(Resource.Id.s_shipping_date); s_length = view.FindViewById <EditText>(Resource.Id.s_length); s_width = view.FindViewById <EditText>(Resource.Id.s_width); s_weight = view.FindViewById <EditText>(Resource.Id.s_weight); s_height = view.FindViewById <EditText>(Resource.Id.s_height); s_size = view.FindViewById <EditText>(Resource.Id.s_size); s_sum_seats = view.FindViewById <EditText>(Resource.Id.s_sum_seats); s_contact_person = view.FindViewById <EditText>(Resource.Id.s_contact_person); s_value = view.FindViewById <EditText>(Resource.Id.s_value); s_cargo_characteristic = view.FindViewById <Spinner>(Resource.Id.s_cargo_characteristic); s_hazard_class = view.FindViewById <Spinner>(Resource.Id.s_hazard_class); s_loading_methods = view.FindViewById <Spinner>(Resource.Id.s_loading_methods); check_argue = view.FindViewById <CheckBox>(Resource.Id.check_argue); SwitchDateTime = view.FindViewById <SwitchCompat>(Resource.Id.ApplicationSwitchDateTime); SwitchCargoInsurance = view.FindViewById <SwitchCompat>(Resource.Id.ApplicationSwitchCargoInsurance); SwitchContactPerson = view.FindViewById <SwitchCompat>(Resource.Id.ApplicationSwitchContactPerson); preloader = view.FindViewById <ProgressBar>(Resource.Id.preloader); s_length.SetMaxLines(8); s_width.SetMaxLines(8); s_height.SetMaxLines(8); s_size.Text = "1"; #region Focusable Enabled Clickable SwitchDateTime.Focusable = true; SwitchCargoInsurance.Focusable = true; SwitchContactPerson.Focusable = true; //s_size.Focusable = false; //s_size.Enabled = false; s_size.Visibility = ViewStates.Visible; s_size.Enabled = false; s_shipment_time.Focusable = false; s_shipment_time.Enabled = false; s_shipping_date.Focusable = false; s_shipping_date.Enabled = false; //s_value.Focusable = false; //s_value.LongClickable = true; s_value.Visibility = ViewStates.Invisible; s_contact_person.Visibility = ViewStates.Invisible; //s_contact_person.Focusable = false; //s_contact_person.LongClickable = false; s_edit_from.Focusable = false; s_edit_where.Focusable = false; #endregion #endregion if (Arguments != null) { string mParam = Arguments.GetString("isDestination"); if (mParam == "true") { s_edit_where.Text = StaticOrder.Destination_address; } else { s_edit_from.Text = StaticOrder.Inception_address; } } s_cargo_characteristic.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner_ItemSelected); //var adapter1 = new ArrayAdapter<String>(Activity, Resource.Array.array_cargo_characteristic, Android.Resource.Layout.SimpleSpinnerItem); var adapter1 = ArrayAdapter.CreateFromResource(Activity, Resource.Array.array_cargo_characteristic, Android.Resource.Layout.SimpleSpinnerItem); adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); s_cargo_characteristic.Adapter = adapter1; s_hazard_class.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(SpinnerClass_ItemSelected); var adapter2 = ArrayAdapter.CreateFromResource(Activity, Resource.Array.array_hazard_class, Android.Resource.Layout.SimpleSpinnerItem); adapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); s_hazard_class.Adapter = adapter2; s_loading_methods.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(SpinnerLoad_ItemSelected); var adapter3 = ArrayAdapter.CreateFromResource(Activity, Resource.Array.array_loading_methodsc, Android.Resource.Layout.SimpleSpinnerItem); adapter3.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); s_loading_methods.Adapter = adapter3; FragmentTransaction transaction2 = this.FragmentManager.BeginTransaction(); #region Обработка нажатий на кнопки //s_size.Click += async delegate //{ // if (string.IsNullOrEmpty(s_length.Text) == false && // string.IsNullOrEmpty(s_width.Text) == false && // string.IsNullOrEmpty(s_height.Text) == false && // string.IsNullOrEmpty(s_sum_seats.Text) == false) // { // CultureInfo ci = (CultureInfo)CultureInfo.CurrentCulture.Clone(); // ci.NumberFormat.CurrencyDecimalSeparator = "."; // float size_calculation = float.Parse(s_length.Text, NumberStyles.Any, ci) // * float.Parse(s_width.Text, NumberStyles.Any, ci) // * float.Parse(s_height.Text, NumberStyles.Any, ci) // * float.Parse(s_sum_seats.Text, NumberStyles.Any, ci); // s_size.Text = size_calculation.ToString(); // } // else // { // AlertDialog.Builder alert = new AlertDialog.Builder(Activity); // alert.SetTitle("Внимание!"); // alert.SetMessage("Необходимо заполнить данные о длине, ширине и высоте груза !"); // alert.SetPositiveButton("Закрыть", (senderAlert, args) => // { // }); // Dialog dialog = alert.Create(); // dialog.Show(); // } //}; SwitchDateTime.Click += SwitchDateTimeClick; SwitchCargoInsurance.Click += SwitchCargoInsuranceClick; SwitchContactPerson.Click += SwitchContactPersonClick; s_width.TextChanged += ValueSizeCalculation; s_height.TextChanged += ValueSizeCalculation; s_length.TextChanged += ValueSizeCalculation; s_sum_seats.TextChanged += ValueSizeCalculation; s_weight.TextChanged += OnWieghtChanged; s_shipping_date.Click += S_shipping_date_Click; //s_shipping_date.TextChanged += delegate //{ // DateTime NowDate = new DateTime(); // string[] NumberMonthYear = s_shipping_date.Text.Split('.'); // int year = Convert.ToInt32(NumberMonthYear[2]); // int month = Convert.ToInt32(NumberMonthYear[1]); // int number = Convert.ToInt32(NumberMonthYear[0]); // DateTime ValueEntered = new DateTime(year, month, number); // if (NowDate.CompareTo(ValueEntered) > 0) // { // Toast.MakeText(Activity, "Указанная дата позже текущей.", ToastLength.Long).Show(); // s_shipping_date.Text = NowDate.ToShortDateString(); // } //}; s_shipment_time.Click += delegate { LayoutInflater layoutInflater = LayoutInflater.From(Activity); View view = layoutInflater.Inflate(Resource.Layout.modal_user_time, null); AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetView(view); #region Объявление переменных в диалоговом окне var rb_first = view.FindViewById <RadioButton>(Resource.Id.rb_first); var rb_second = view.FindViewById <RadioButton>(Resource.Id.rb_second); var rb_third = view.FindViewById <RadioButton>(Resource.Id.rb_third); var rb_vierth = view.FindViewById <RadioButton>(Resource.Id.rb_vierth); var rb_fifth = view.FindViewById <RadioButton>(Resource.Id.rb_fifth); var rb_sixth = view.FindViewById <RadioButton>(Resource.Id.rb_sixth); #endregion #region Обработка событий кнопок rb_first.Click += delegate { s_shipment_time.Text = rb_first.Text; }; rb_second.Click += delegate { s_shipment_time.Text = rb_second.Text; }; rb_third.Click += delegate { s_shipment_time.Text = rb_third.Text; }; rb_vierth.Click += delegate { s_shipment_time.Text = rb_vierth.Text; }; rb_fifth.Click += delegate { s_shipment_time.Text = rb_fifth.Text; }; rb_sixth.Click += delegate { s_shipment_time.Text = rb_sixth.Text; }; #endregion alert.SetCancelable(false) .SetPositiveButton("Выбрать", delegate { }) .SetNegativeButton("Отмена", delegate { alert.Dispose(); }); Dialog dialog = alert.Create(); dialog.Show(); }; check_argue.Click += async delegate { if (check_argue.Checked == true) { using (var client = ClientHelper.GetClient()) { WebService.Home.HomeService.InitializeClient(client); var o_data = await WebService.Home.HomeService.Offer(); if (o_data.Status == HttpStatusCode.OK) { AgreementResponse o_user_data = new AgreementResponse(); o_user_data = o_data.ResponseData; Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction(); AlertDialog.Builder alert = new AlertDialog.Builder(Activity); alert.SetTitle("Согласие с договором офертой"); alert.SetMessage(o_user_data.Agreement); check_argue.Checked = false; alert.SetPositiveButton("Принимаю", (senderAlert, args) => { check_argue.Checked = true; }); alert.SetNegativeButton("Не принимаю", (senderAlert, args) => { check_argue.Checked = false; }); Dialog dialog = alert.Create(); dialog.Show(); } else { Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show(); } }; } }; s_edit_from.Click += async delegate { //GooglePlacesResult fragment = new GooglePlacesResult(); //Bundle args = new Bundle(); //args.PutString("isDestination", "false"); //fragment.Arguments = args; //transaction2.Replace(Resource.Id.framelayout, fragment).AddToBackStack(null).Commit(); Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.Overlay, fields) .SetCountry("RUS") .Build(Activity); myCity = "false"; StartActivityForResult(intent, 0); }; s_edit_where.Click += async delegate { Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.Overlay, fields) .SetCountry("RUS") .Build(Activity); myCity = "true"; StartActivityForResult(intent, 0); //GooglePlacesResult fragment = new GooglePlacesResult(); //Bundle args = new Bundle(); //args.PutString("isDestination", "true"); //fragment.Arguments = args; //transaction2.Replace(Resource.Id.framelayout, fragment).AddToBackStack(null).Commit(); }; btn_make_request.Click += async delegate { try { string InputErrorMessage = ""; if (ValidationValues(ref InputErrorMessage)) { AlertDialogCall(InputErrorMessage); } else { preloader.Visibility = Android.Views.ViewStates.Visible; MakeOrderModel model = new MakeOrderModel() { destination_address = s_edit_where.Text, for_date = s_shipping_date.Text, for_time = s_shipment_time.Text, height = s_height.Text, inception_address = s_edit_from.Text, cargo_class = a_hazard_class, cargo_loading = a_loading_methodsc, cargo_type = a_cargo_characteristic, destination_lat = StaticOrder.Destination_lat, /*"47.232032",*/ destination_lng = StaticOrder.Destination_lng, /*"39.731523",*/ inception_lat = StaticOrder.Inception_lat, /*"47.243221",*/ inception_lng = StaticOrder.Inception_lng, /*"39.668781",*/ insurance = s_value.Text, receiver = s_contact_person.Text, length = s_length.Text, qty = s_sum_seats.Text, weight = s_weight.Text, width = s_width.Text, volume = s_size.Text }; using (var client = ClientHelper.GetClient()) { OrderService.InitializeClient(client); var o_data = await OrderService.GetOrderPrice(model); if (o_data.Status == HttpStatusCode.OK) { //o_data.Message = "Успешно авторизован!"; Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show(); AmountResponse order_data = new AmountResponse(); order_data = o_data.ResponseData; if (IsFieldsEmptyOrNull(o_data.ResponseData)) { string ErrorMessage = "Не удалось оформить заказ. Скорее всего " + "Вы ввели неверные пункт отправления и/или пункт назначения "; AlertDialogCall(ErrorMessage); preloader.Visibility = Android.Views.ViewStates.Invisible; } else { StaticOrder.AddInfoOrder(model); StaticOrder.AddInfoAmount(order_data); preloader.Visibility = Android.Views.ViewStates.Invisible; StaticUser.OrderInStageOfBid = true; try { Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction(); ActivityOrderPreis content = new ActivityOrderPreis(); transaction1.Replace(Resource.Id.framelayout, content); transaction1.Commit(); } catch (Exception ex) { Toast.MakeText(Activity, ex.Message, ToastLength.Long); } } } else { Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show(); } } } } catch (Exception ex) { Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show(); } }; #endregion return(view); } catch (Exception ex) { var view = inflater.Inflate(Resource.Layout.activity_errors_handling, container, false); Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show(); return(view); } }
private async void GetOrderParameters() { try { var o_data = new ServiceResponseObject <OrderObjectResponse <OrderParameters, SensorResponse, StageResponse> >(); o_data = await OrderService.GetSensorParameters(StaticOrder.Order_id); if (o_data.Status == HttpStatusCode.OK) { StaticBox.AddInfoSensors(o_data.ResponseData.SENSORS_STATUS); StaticOrder.AddInfoOrder(o_data.ResponseData.ORDER); Id.Text = (o_data.ResponseData.ORDER.id == null) ? "неизвестно" : o_data.ResponseData.ORDER.id; Weight.Text = (o_data.ResponseData.SENSORS_STATUS.weight == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.weight; Temperature.Text = (o_data.ResponseData.SENSORS_STATUS.temperature == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.temperature; Battery.Text = (o_data.ResponseData.SENSORS_STATUS.battery == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.battery; Illumination.Text = (o_data.ResponseData.SENSORS_STATUS.illumination == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.illumination; Humidity.Text = (o_data.ResponseData.SENSORS_STATUS.humidity == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.humidity; Events.Text = (o_data.ResponseData.ORDER.event_count == null) ? "неизвестно" : StaticOrder.Event_Count + " шт."; progressBar.Progress = (o_data.ResponseData.ORDER.order_stage_id == null) ? 0 : Convert.ToInt32(o_data.ResponseData.ORDER.order_stage_id); if (progressBar.Progress != 0) { Status.Text = progressBar.Progress.ToString() + ". " + o_data.ResponseData.STAGES[progressBar.Progress - 1].name; } else { Status.Text = "неизвестно"; } Cost.Text = (o_data.ResponseData.ORDER.payment_amount == null) ? "неизвестно" : StaticOrder.Payment_Amount + " руб."; if (o_data.ResponseData.ORDER.payment_status == "1") { Payment.Text = "Оплачено"; Payment.SetTextColor(Color.ParseColor("#8EF892")); } else if (o_data.ResponseData.ORDER.payment_status == "0") { Payment.Text = "Не оплачено"; Payment.SetTextColor(Color.ParseColor("#EC8F9B")); } else { Payment.Text = "неизвестно"; } if (o_data.ResponseData.SENSORS_STATUS.gate == "1") { Lock.Text = "Опущена"; btn_Lock.Text = "Поднять"; } else if (o_data.ResponseData.SENSORS_STATUS.gate == "0") { Lock.Text = "Поднята"; btn_Lock.Text = "Опустить"; } else { Lock.Text = "Неизвестно"; btn_Lock.Text = "Неизвестно"; } //if (o_data.ResponseData.SENSORS_STATUS.fold == "1") //{ // Fold.Text = "Разложен"; //} //else if (o_data.ResponseData.SENSORS_STATUS.fold == "0") //{ // Fold.Text = "Сложен"; //} //else //{ // Fold.Text = "Неизвестно"; //} //if (o_data.ResponseData.SENSORS_STATUS.gate == "1") //{ // Gate.Text = "Закрыта"; //} //else if (o_data.ResponseData.SENSORS_STATUS.gate == "0") //{ // Gate.Text = "Открыта"; //} //else //{ // Gate.Text = "Неизвестно"; //} btn_Lock.Enabled = (StaticOrder.Order_Stage_Id == "1" || StaticOrder.Order_Stage_Id == "4" || StaticOrder.Order_Stage_Id == "7" || StaticOrder.Order_Stage_Id == "5" || StaticOrder.Order_Stage_Id == "8") ? false : true; btn_Pay.Enabled = (StaticOrder.Order_Stage_Id == "5") ? true : false; btn_Photo.Enabled = (StaticOrder.Order_Stage_Id == "7" || StaticOrder.Order_Stage_Id == "8" || StaticOrder.Order_Stage_Id == "1") ? false : true; btn_Video.Enabled = (StaticOrder.Order_Stage_Id == "7" || StaticOrder.Order_Stage_Id == "8" || StaticOrder.Order_Stage_Id == "1") ? false : true; } } catch (System.Exception ex) { Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show(); } }
private async void GetOrderParameters() { var o_data = new ServiceResponseObject <OrderObjectResponse <OrderParameters, SensorResponse, StageResponse> >(); StaticOrder.Order_id = StaticTask.order_id; o_data = await OrderService.GetSensorParameters(StaticTask.order_id); if (o_data.Status == HttpStatusCode.OK) { Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show(); Id.Text = (o_data.ResponseData.ORDER.id == null) ? "неизвестно" : o_data.ResponseData.ORDER.id; Weight.Text = (o_data.ResponseData.SENSORS_STATUS.weight == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.weight; Temperature.Text = (o_data.ResponseData.SENSORS_STATUS.temperature == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.temperature; Battery.Text = (o_data.ResponseData.SENSORS_STATUS.battery == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.battery; Illumination.Text = (o_data.ResponseData.SENSORS_STATUS.illumination == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.illumination; Humidity.Text = (o_data.ResponseData.SENSORS_STATUS.humidity == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.humidity; //Gate.Text = (o_data.ResponseData.SENSORS_STATUS.gate == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.gate; //Lock.Text = (o_data.ResponseData.SENSORS_STATUS.Lock == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.Lock; //Fold.Text = (o_data.ResponseData.SENSORS_STATUS.fold == null) ? "неизвестно" : o_data.ResponseData.SENSORS_STATUS.fold; Events.Text = (o_data.ResponseData.ORDER.event_count == null) ? "неизвестно" : o_data.ResponseData.ORDER.event_count; StaticOrder.AddInfoOrder(o_data.ResponseData.ORDER); StaticBox.AddInfoSensors(o_data.ResponseData.SENSORS_STATUS); if (o_data.ResponseData.SENSORS_STATUS.Lock == "1") { Lock.Text = "Закрыт"; } else if (o_data.ResponseData.SENSORS_STATUS.Lock == "0") { Lock.Text = "Открыт"; } else { Lock.Text = "Неизвестно"; } if (o_data.ResponseData.SENSORS_STATUS.fold == "1") { Fold.Text = "Разложен"; } else if (o_data.ResponseData.SENSORS_STATUS.fold == "0") { Fold.Text = "Сложен"; } else { Fold.Text = "Неизвестно"; } if (o_data.ResponseData.SENSORS_STATUS.gate == "1") { Gate.Text = "Закрыта"; } else if (o_data.ResponseData.SENSORS_STATUS.gate == "0") { Gate.Text = "Открыта"; } else { Gate.Text = "Неизвестно"; } } else { Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show(); } }