コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\79686\source\repos\driversapp1\driversapp1\DriversDB.mdf; Integrated Security = True");

            I = 0;
            con.Open();
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "SELECT * FROM [Authorization] WHERE Login ='******' AND Password ='******'";
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            I = Convert.ToInt32(dt.Rows.Count.ToString());
            if (I == 0)
            {
                MessageBox.Show("ошибка");
                if (count++ == 5)
                {
                    MessageBox.Show("достигнуто максимальное кол-во попыток. в доступе отказано.");
                    this.Close();
                }
            }
            else
            {
                this.Hide();
                Drivers f = new Drivers();
                f.Show();
            }
            con.Close();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
            Drivers d = new Drivers();

            d.Show();
        }