Пример #1
0
        //async void PageLoad()
        //{
        //    //StartLoading();
        //    //var cancellationTokenSource = new CancellationTokenSource();
        //    //await Task.Factory.StartNew(x =>
        //    //{
        //    //    LoadShops();
        //    //},
        //    //TaskCreationOptions.AttachedToParent, cancellationTokenSource.Token);
        //}

        public NewColleguePage(Colegue colegue)
        {
            InitializeComponent();
            _colegue              = colegue;
            nameEntry.Text        = _colegue.Name;
            loginEntry.Text       = _colegue.Email;
            positionEntry.Text    = _colegue.Position;
            selectShopButton.Text = _colegue.ShopName;
            continueButton.Text   = "Изменить данные";
            if (MobileStaticVariables.UserInfo.ShopList.Count == 1)
            {
                //selectShopButton.Text = MobileStaticVariables.UserInfo.ShopList[0].Name;
                selectShopButton.IsEnabled = false;
            }
        }
Пример #2
0
        private async void continueButton_Clicked(object sender, EventArgs e)
        {
            string login    = (Regex.IsMatch(loginEntry.Text, emailRegex)) ? loginEntry.Text : "";
            string name     = nameEntry.Text.Trim();
            string position = positionEntry.Text.Trim();
            string Shop     = selectShopButton.Text;

            if (name != "")
            {
                if (login != "")
                {
                    if ((Shop != "Магазин не выбран" && MobileStaticVariables.UserInfo.ShopList.Count != 1) || MobileStaticVariables.UserInfo.ShopList.Count == 1)
                    {
                        if (_colegue == null)
                        {
                            _colegue = new Colegue();
                        }
                        _colegue.Email    = login;
                        _colegue.Name     = name;
                        _colegue.Position = position;
                        if (MobileStaticVariables.UserInfo.ShopList.Count == 1)
                        {
                            _colegue.ShopKey = MobileStaticVariables.UserInfo.ShopList.FirstOrDefault().ShopKey;
                        }
                        else
                        {
                            if (dictTO.TryGetValue(Shop, out int shopKey))
                            {
                                _colegue.ShopKey = shopKey;
                            }
                        }

                        var stuff = new StuffModel();
                        stuff.MobileDevicKey = MobileStaticVariables.UserInfo.MobileDeviceKey;
                        stuff.ColegueList.Clear();
                        stuff.ColegueList.Add(_colegue);
                        var cancellationTokenSource = new CancellationTokenSource();
                        try
                        {
                            StartLoading();
                            await Task.Factory.StartNew(x =>
                            {
                                try
                                {
                                    string registration = "";
                                    registration        = MobileStaticVariables.WebUtils.SendAuthRequest("RegManager", stuff);
                                    Logger.WriteLine("registration : " + registration);
                                    if (registration == "")
                                    {
                                        throw new Exception("Получена пустая строка");
                                    }
                                    stuff.ParseJson(registration);
                                    if (stuff.ResultState == RequestResult.Results.Success)
                                    {
                                        Device.BeginInvokeOnMainThread(async() =>
                                        {
                                            await DisplayAlert("Ура", "Добавление прошло успешно", "Продолжить");
                                            EndLoading();
                                            await Navigation.PopToRootAsync();
                                        });
                                    }
                                    else
                                    {
                                        Device.BeginInvokeOnMainThread(async() =>
                                        {
                                            await DisplayAlert("Внимание", stuff.TranslateResult(stuff.ResultState), "Продолжить");
                                            EndLoading();
                                        });
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.WriteError(ex);
                                    Device.BeginInvokeOnMainThread(async() =>
                                    {
                                        EndLoading();
                                        await DisplayAlert("Внимание", "Не удается соедениться с сервером", "Повторить");
                                    });
                                }
                            },
                                                        TaskCreationOptions.AttachedToParent, cancellationTokenSource.Token);
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteError(ex);
                        }
                    }
                    else
                    {
                        await DisplayAlert("Внимание", "Введите магазин, в котором будет работать Ваш будущий коллега", "Хорошо");

                        positionEntry.Focus();
                    }
                }
                else
                {
                    await DisplayAlert("Внимание", "Введите почту, чтобы мы могли связаться с Вашим будущим колегой", "Хорошо");

                    loginEntry.Focus();
                }
            }
            else
            {
                await DisplayAlert("Внимание", "Введите имя Вашего будущего коллеги", "Хорошо");

                nameEntry.Focus();
            }
        }
Пример #3
0
        public DetailColeguePage(Colegue colegue)
        {
            _colegue = colegue;
            InitializeComponent();
            var formatted = new FormattedString();

            formatted.Spans.Add(new Span {
                Text = "Имя : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = colegue.Name, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            nameLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Адрес электронной почты : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = colegue.Email, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            formatted.Spans.Add(new Span {
                Text = "  (нажмите чтобы написать)", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            emailLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Магазин : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = colegue.ShopName, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            shopLabel.FormattedText = formatted;
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Подробности : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = colegue.Position, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
            });
            detailLabel.FormattedText = formatted;
            var posision = "";

            if (colegue.AdminUserKey != 0)
            {
                formatted = new FormattedString();
                formatted.Spans.Add(new Span {
                    Text = "Курирует : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
                });
                formatted.Spans.Add(new Span {
                    Text = colegue.AdminName, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(false)
                });
                adminLabel.FormattedText = formatted;
                posision = "Оператор";
                blockButton.IsVisible = true;
                if (colegue.UserState == UserStates.Blocked)
                {
                    blockButton.Text = "Разблокировать";
                }
                else
                {
                    blockButton.Text = "Заблокировать";
                }
            }
            else
            {
                adminLabel.IsVisible  = false;
                posision              = "Администратор";
                blockButton.IsVisible = false;
            }
            formatted = new FormattedString();
            formatted.Spans.Add(new Span {
                Text = "Должность : ", FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["MainColor"], FontAttributes = FontAttributes.Bold, FontFamily = MobileStaticVariables.UserAppSettings.CurrenFont(true)
            });
            formatted.Spans.Add(new Span {
                Text = posision, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), ForegroundColor = (Color)App.Current.Resources["LetterColor"], FontAttributes = FontAttributes.None
            });
            positionLabel.FormattedText = formatted;
        }