Example #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");
            }
        }
Example #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();
                }
            }
        }
Example #3
0
 private void frmP_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     PassText.Clear();
     UserText.Clear();
     errorlabel.IsEnabled = false;
     this.Show();
     UserText.Focus();
 }
Example #4
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();
                }
            }
        }
Example #5
0
 private void CleanText()
 {
     LoginText.Clear();
     PassText.Clear();
     LoginText.Focus();
 }