示例#1
0
        async void AcceptButton_Clicked(object sender, EventArgs e)
        {
            AcceptButton.IsEnabled = false;

            var phone = PhoneHelper.ValidPhoneNumber(PhoneTB.Text);

            if (phone == 0)
            {
                return;
            }

            AppBusyPage.Show("Авторизация...");
            App.ClearTestLog();
            var res = await ApiService.Auth(PhoneTB.Text, PassTB.Text);

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }
            if (autoLogin)
            {
                //AppData.Crew.Online = lastOnline;
                AppData.Crew.CrewTypeId = lastCrewTypeId;
            }

            AppBusyPage.Show("Получение списка типов бригад...");
            App.ClearTestLog();
            res = await ApiService.GetCrewTypes();

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            if ((AppData.CrewTypes?.Count ?? 0) == 0)
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", "Не удалось получить список типов бригад", "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            AppBusyPage.Close();
            sctPage = new SelectCrewTypePage();
            sctPage.Disappearing += CrewTypePopup_Disappearing;
            await PopupNavigation.Instance.PushAsync(sctPage, true);
        }
示例#2
0
        async void CrewTypePopup_Disappearing(object sender, EventArgs e)
        {
            if (sctPage.SelectedCrewType?.Id == null)
            {
                await DisplayAlert("Ошибка", "Не выбран тип бригады", "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            AppBusyPage.Show("Сохранение данных на сервер...");
            App.ClearTestLog();
            var res = await ApiService.SetCrewType(sctPage.SelectedCrewType);

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }
            AppData.Crew.CrewTypeId = sctPage.SelectedCrewType.Id;

            AppBusyPage.Show("Получение активного заказа...");
            App.ClearTestLog();
            res = await ApiService.GetActiveOrder();

            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                AppBusyPage.Close();
                await DisplayAlert("Ошибка", res, "ОК");

                AcceptButton.IsEnabled = true;
                return;
            }

            Settings.AppState.LastPhone     = PhoneHelper.ValidPhoneNumber(PhoneTB.Text);
            Settings.AppState.LastPin       = PassTB.Text;
            Settings.AppState.LastLoginDate = DateTime.Now;
            Settings.AppState.Save();

            AppBusyPage.Close();
            App.Current.MainPage = new MainPage(PageType.ActiveOrder);

            /*if (AppData.Crew.ActiveOrder != null)
             *  App.Current.MainPage = new MainPage(PageType.ActiveOrder);
             * else
             *  App.Current.MainPage = new MainPage(PageType.FreeOrders);*/
        }
示例#3
0
        private async void Online_Toggled(object sender, ToggledEventArgs e)
        {
            if (!swOnlineHandling)
            {
                return;
            }

            var s = "Установить статус \"НА ЛИНИИ\"?";

            if (!e.Value)
            {
                s = "Установить статус \"ЗАНЯТ\"?";
            }
            var res = await DisplayAlert("Подтверждение", s, "OK", "Отмена");

            if (res)
            {
                App.ClearTestLog();
                AppBusyPage.Show("Изменение статуса...");
                var r = await ApiService.SetCrewState(e.Value);

                AppBusyPage.Close();
                await App.ShowTestLog(this);

                if (!string.IsNullOrEmpty(r))
                {
                    await DisplayAlert("Ошибка", r, "OK");

                    res = false;
                }
            }
            if (!res)
            {
                swOnlineHandling   = false;
                swOnline.IsToggled = !e.Value;
                swOnlineHandling   = true;
            }
            else
            {
                AppData.Crew.Online      = e.Value;
                lbOnline.Text            = (AppData.Crew?.Online ?? false) ? "Текущий Статус: \"НА ЛИНИИ\"" : "Текущий Статус: \"ЗАНЯТ\"";
                slOnline.BackgroundColor = (AppData.Crew?.Online ?? false) ? Color.Orange : Color.Gray;
                AppData.Save();
            }
        }
示例#4
0
        async void SelectReasonPopup_Disappearing(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(reasonPage?.SelectedReason))
            {
                return;
            }

            App.ClearTestLog();
            AppBusyPage.Show("Отмена заказа...");
            var res = await ApiService.CancelOrder(selectedOrder, reasonPage.SelectedReason);

            AppBusyPage.Close();
            await App.ShowTestLog(this);

            if (!string.IsNullOrEmpty(res))
            {
                await DisplayAlert("Ошибка", res, "OK");

                return;
            }
            AppData.Crew.ActiveOrder = null;
            RefreshContent();
            //gridOrderActions.IsVisible = (selectedOrder?.Status ?? OrderStatus.Cancelled) < OrderStatus.Cancelled;
        }