示例#1
0
        private void glavbtn_Click(object sender, EventArgs e)
        {
            this.Hide();
            Glavnaya glavnaya = new Glavnaya();

            glavnaya.ShowDialog();
            this.Close();
        }
示例#2
0
文件: Login.cs 项目: 2ez4lmz/KursZK
 private void metroButton1_Click(object sender, EventArgs e)
 {
     if (mistakecounter > 3)
     {
         MessageBox.Show("Вы исчерпали все попытки\nПрограмма будет закрыта", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Application.Exit();
     }
     else
     {
         if (txtlogin.Text == "" || txtpass.Text == "")
         {
             MessageBox.Show("Заполните поля!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             using (SqlConnection connection = new SqlConnection(sqlconn))
             {
                 connection.Open();
                 using (SqlCommand command = new SqlCommand("SELECT IDUser, Login, Password FROM Users WHERE Login = @login AND Password = @password", connection))
                 {
                     command.Parameters.AddWithValue("@login", txtlogin.Text);
                     command.Parameters.AddWithValue("@password", txtpass.Text);
                     using (SqlDataReader reader = command.ExecuteReader())
                     {
                         while (reader.Read())
                         {
                             if (reader.HasRows)
                             {
                                 MessageBox.Show(reader.GetInt32(0).ToString());
                                 this.Hide();
                                 Glavnaya glavnaya = new Glavnaya();
                                 glavnaya.ShowDialog();
                                 this.Close();
                             }
                             else
                             {
                                 MessageBox.Show("Неверный логин или пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                 mistakecounter++;
                             }
                         }
                     }
                 }
             }
         }
     }
 }