Пример #1
0
        private void btnLogeo_Click(object sender, RoutedEventArgs e)
        {
            if (UserText.Text != "")
            {
                if (PassText.Password != "")
                {
                    UserModel user            = new UserModel();
                    var       validacionLogin = user.LoginUser(UserText.Text, encrypt.md5(PassText.Password));
                    if (validacionLogin == true)
                    {
                        FormularioPrincipal frmP = new FormularioPrincipal();
                        frmP.Show();
                        frmP.Closing += frmP_Closing;
                        this.Hide();
                    }
                    else
                    {
                        MessageError("Contraseña o nombre de usuario incorrecto\n Intenta de nuevo");

                        PassText.Clear();
                        UserText.Focus();
                    }
                }
                else
                {
                    MessageError("Introduce una contraseña");
                }
            }
            else
            {
                MessageError("Introduce un nombre de usuario");
            }
        }
Пример #2
0
        private void lblNewUserRegistration_Click(object sender, EventArgs e)
        {
            LoginText.Clear();
            PassText.Clear();
            GroupBoxAuth.Visible         = false;
            GroupBoxRegistration.Visible = true;

            string MyQuery = $"select [password] from [user] where role = 'Модератор'";

            using (SqlConnection conn = new SqlConnection(MyConn))
            {
                using (SqlCommand command = new SqlCommand(MyQuery, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (System.Data.SqlClient.SqlException)
                    {
                        MessageBox.Show("Проблемы с соединением с сервером БД\nПроверьте подключение", "Авторизация");
                        Application.Exit();
                    }
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        PssMdr.Add(reader[0].ToString());
                    }
                    conn.Close();
                }
            }
        }
Пример #3
0
 private void frmP_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     PassText.Clear();
     UserText.Clear();
     errorlabel.IsEnabled = false;
     this.Show();
     UserText.Focus();
 }
Пример #4
0
        private void AddButtonClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(PassText.Password))
            {
                PassText.Focus(FocusState.Keyboard);
                VisualUtilities.ShakeView(PassText);

                return;
            }
            else if (string.IsNullOrEmpty(RePassText.Password))
            {
                RePassText.Focus(FocusState.Keyboard);
                VisualUtilities.ShakeView(RePassText);
                return;
            }
            if (PassText.Password.Length == 4)
            {
                if (PassText.Password.All(x => x >= '0' && x <= '9') && Helper.Passcode.Check(PassText.Password))
                {
                }
                else
                {
                    PassText.Focus(FocusState.Keyboard);
                    VisualUtilities.ShakeView(PassText);
                    Helper.ShowNotify("Enter 4-digits numbers");
                    return;
                }
            }
            if (RePassText.Password.Length == 4)
            {
                if (RePassText.Password.All(x => x >= '0' && x <= '9') && Helper.Passcode.Check(RePassText.Password))
                {
                }
                else
                {
                    RePassText.Focus(FocusState.Keyboard);
                    VisualUtilities.ShakeView(RePassText);
                    Helper.ShowNotify("Enter 4-digits numbers");
                    return;
                }
            }
            {
                if (PassText.Password == RePassText.Password)
                {
                    Helper.Passcode.Set(PassText.Password);

                    Hide();
                }
                else
                {
                    VisualUtilities.ShakeView(RePassText);

                    RePassText.Focus(FocusState.Keyboard);
                }
            }
        }
Пример #5
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            LoginText.Focus();
            if (EnterTry == 1)
            {
                btnEnter.Enabled         = false;
                label_timer_expl.Visible = true;
                label_timer.Visible      = true;
                timer1.Start();
                this.timer1.Tick += new System.EventHandler(this.timer_Tick);
            }
            QueryLogin = LoginText.Text;
            QueryPass  = PassText.Text;
            string MyQuery = $"select [role] from [user] where [name_user] = '" + QueryLogin + "'and [password] = '" + QueryPass + "'";

            using (SqlConnection conn = new SqlConnection(MyConn))
            {
                using (SqlCommand command = new SqlCommand(MyQuery, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (System.Data.SqlClient.SqlException)
                    {
                        MessageBox.Show("Проблемы с соединением с сервером БД\nПроверьте подключение", "Авторизация");
                        return;
                    }
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        role = reader[0].ToString();
                        BodyProgram form2 = new BodyProgram(this);
                        form2.Show();
                        LoginText.Clear();
                        PassText.Clear();
                        this.Hide();
                    }
                    else
                    {
                        LoginText.Clear();
                        PassText.Clear();
                        EnterTry--;
                        MessageBox.Show($"Проверьте правильность ввода логина/пароля\nРазрешено попыток: {EnterTry}");
                    }
                    conn.Close();
                }
            }
        }
Пример #6
0
        public async void Load()
        {
            try
            {
                if (await KeyCredentialManager.IsSupportedAsync())
                {
                    var result = await KeyCredentialManager.OpenAsync(Helper.AppName);

                    if (result.Credential != null)
                    {
                        var signResult = await result.Credential.RequestSignAsync(CryptographicBuffer.ConvertStringToBinary(DeviceHelper.PackageName, BinaryStringEncoding.Utf8));

                        if (signResult.Status == KeyCredentialStatus.Success)
                        {
                            Unlock();
                        }
                        else
                        {
                            BiometricsButton.Visibility = Visibility.Visible;
                        }
                    }
                    else
                    {
                        var creationResult = await KeyCredentialManager.RequestCreateAsync(Helper.AppName, KeyCredentialCreationOption.ReplaceExisting);

                        if (creationResult.Status == KeyCredentialStatus.Success)
                        {
                            Unlock();
                        }
                        else
                        {
                            BiometricsButton.Visibility = Visibility.Visible;
                        }
                    }
                }
                else
                {
                    PassText.Focus(FocusState.Keyboard);
                }
            }
            catch { }
        }
Пример #7
0
 private void CleanText()
 {
     LoginText.Clear();
     PassText.Clear();
     LoginText.Focus();
 }