Beispiel #1
0
        private bool IsValid()
        {
            TbUsername.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            PbPassword.GetBindingExpression(PasswordHelper.PasswordProperty).UpdateSource();

            return(!Validation.GetHasError(TbUsername) && !Validation.GetHasError(PbPassword));
        }
Beispiel #2
0
 private void DoFocus()
 {
     if (string.IsNullOrEmpty(TbLoginName.Text))
     {
         TbLoginName.Focus();
     }
     else if (string.IsNullOrEmpty(PbPassword.Password))
     {
         PbPassword.Focus();
     }
 }
Beispiel #3
0
        public InputWindow(
            string title,
            string text,
            string tail,
            Func <string, string> check,
            Action <string> onOk,
            bool isPassword)
        {
            _isPassword = isPassword;
            this.Title  = title;
            InitializeComponent();
            this.TbUcName.Text = nameof(InputWindow);
            TbTitle.Text       = title;
            if (isPassword)
            {
                TbText.Visibility     = Visibility.Collapsed;
                PbPassword.Visibility = Visibility.Visible;
                PbPassword.Password   = text;
            }
            else
            {
                TbText.Text = text;
            }
            TbTail.Text = tail;

            var owner = WpfUtil.GetTopWindow();

            if (this != owner)
            {
                this.Owner = owner;
            }
            _check = check;
            _onOk  = onOk ?? throw new ArgumentNullException(nameof(onOk));
            TimeSpan.FromMilliseconds(100).Delay().ContinueWith(t => {
                UIThread.Execute(() => () => {
                    if (isPassword)
                    {
                        PbPassword.Focus();
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(TbText.Text))
                        {
                            TbText.SelectionStart = TbText.Text.Length;
                        }
                        TbText.Focus();
                    }
                });
            });
        }
Beispiel #4
0
        private bool IsValid(bool isEdit)
        {
            if (!isEdit)
            {
                TbUsername.GetBindingExpression(TextBox.TextProperty).UpdateSource();
                PbPassword.GetBindingExpression(PasswordHelper.PasswordProperty).UpdateSource();
            }
            CbGender.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateSource();
            DpBirthDate.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource();
            TbName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbEmail.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbPhoneNumber.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            TbAddress.GetBindingExpression(TextBox.TextProperty).UpdateSource();

            return(!Validation.GetHasError(CbGender) && !Validation.GetHasError(DpBirthDate) && !Validation.GetHasError(TbName) &&
                   !Validation.GetHasError(TbEmail) && !Validation.GetHasError(TbPhoneNumber) && !Validation.GetHasError(TbAddress) &&
                   (!isEdit || (!Validation.GetHasError(TbUsername) && !Validation.GetHasError(PbPassword))));
        }
Beispiel #5
0
        private void CheckFields()
        {
            if (CoBAlgorithm.SelectedIndex == 4)
            {
                SpDpApiSettings.Visibility          = Visibility.Visible;
                GrFileEncryptionPassword.Visibility = Visibility.Collapsed;
                PbPassword.Clear();

                if (_selectedFile != null &&
                    _selectedFileInfo != null &&
                    CoBAlgorithm.SelectedItem != null &&
                    !string.IsNullOrWhiteSpace(TbFileDestination.Text)
                    )
                {
                    BtStart.IsEnabled = true;
                }
                else
                {
                    BtStart.IsEnabled = false;
                }

                return;
            }

            SpDpApiSettings.Visibility          = Visibility.Collapsed;
            GrFileEncryptionPassword.Visibility = Visibility.Visible;

            if (_selectedFile != null &&
                _selectedFileInfo != null &&
                !string.IsNullOrWhiteSpace(PbPassword.Password) &&
                CoBAlgorithm.SelectedItem != null &&
                !string.IsNullOrWhiteSpace(TbFileDestination.Text)
                )
            {
                BtStart.IsEnabled = true;
            }
            else
            {
                BtStart.IsEnabled = false;
            }
        }
Beispiel #6
0
        private void BtnEnterClick(object sender, RoutedEventArgs e)
        {
            List <User> users = TatarCulturDbEntities.GetContext().Users.ToList();
            User        user  = users.FirstOrDefault(p => p.Login == TbLogin.Text && p.Password == PbPassword.Password);

            StringBuilder error = new StringBuilder();

            if (string.IsNullOrWhiteSpace(TbLogin.Text))
            {
                error.AppendLine("Введите логин");
            }

            if (string.IsNullOrWhiteSpace(PbPassword.Password))
            {
                error.AppendLine("Введите пароль");
            }
            if (error.Length > 0)
            {
                MessageBox.Show(error.ToString(), "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }


            if (user != null)
            {
                int rols = (int)user.IdRols;
                Manager.idUser = user.IdUser;


                MainWindow mainWindow = new MainWindow(rols, user);
                mainWindow.Owner = this;
                this.Hide();
                mainWindow.Show();
            }

            else if (user == null)
            {
                MessageBox.Show("Неверный пароль или логин", "Неверный пароль или логин", MessageBoxButton.OK, MessageBoxImage.Error);
                PbPassword.Clear();
            }
        }
Beispiel #7
0
        private void SignIn(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TbLogin.Text))
            {
                MB.MessageBoxInfo("Введите логин");
                TbLogin.Focus();
            }
            else if (string.IsNullOrWhiteSpace(PbPassword.Password))
            {
                MB.MessageBoxInfo("Введите пароль");
                PbPassword.Focus();
            }
            else
            {
                var employee = DataService.GetContext().Employee.FirstOrDefault(u => u.User.Login == TbLogin.Text);

                if (employee == null)
                {
                    MB.MessageBoxInfo("Введен неверно логин/пароль");
                    TbLogin.Focus();
                    count++;
                }
                else
                {
                    if (employee.User.Password != PbPassword.Password)
                    {
                        MB.MessageBoxInfo("Введен неверно логин/пароль");
                        TbLogin.Clear();
                        PbPassword.Clear();
                        count++;
                    }
                    else
                    {
                        Entity.CurrentEmployee = employee;
                        switch (employee.User.IdRole)
                        {
                        case 1:
                            new WinManager().Show();
                            this.Close();
                            break;

                        case 2:
                            new WinEmployee().Show();
                            this.Close();
                            break;

                        case 3:
                            new WinAdmin().Show();
                            this.Close();
                            break;
                        }
                        count = 0;
                    }
                }
                if (count >= 3)
                {
                    TbLogin.Text           = string.Empty;
                    PbPassword.Password    = string.Empty;
                    GridSignIn.Visibility  = Visibility.Hidden;
                    GridCaptcha.Visibility = Visibility.Visible;
                    TbCaptcha.Text         = Captcha.GenerateString(5);
                    return;
                }
            }
        }