Exemplo n.º 1
0
 public LoginForm()
 {
     InitializeComponent();
     this.CenterToScreen();
     this.TopMost = true;
     LoginText.Focus();
 }
 public LoginWindow()
 {
     /*new NewNoteMasterWindow().Show();
      * Close();
      */
     InitializeComponent();
     LoginText.Focus();
 }
Exemplo n.º 3
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();
                }
            }
        }
Exemplo n.º 4
0
 private void CleanText()
 {
     LoginText.Clear();
     PassText.Clear();
     LoginText.Focus();
 }
 public RegisterWindow()
 {
     InitializeComponent();
     LoginText.Focus();
 }
Exemplo n.º 6
0
 private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e)
 {
     LoginText.Focus();
 }