コード例 #1
0
ファイル: Schoolboy.cs プロジェクト: TreshUp/BD4
        private void button1_Click(object sender, EventArgs e)
        {
            Form f2 = new Guest_Form(data);

            this.Hide();
            f2.Show();
        }
コード例 #2
0
ファイル: Login_Screen.cs プロジェクト: TreshUp/BD4
        private void Enter_Click(object sender, EventArgs e)
        {
            string log, pass = "", lvl = "";
            int    k = 0;

            using (OleDbConnection connection = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:/DATA/Тимур данные/Coding/Retry/Retry.mdb"))
            {
                if (Login_text.Text != "")
                {
                    try
                    {
                        connection.Open();
                        OleDbCommand select = new OleDbCommand();
                        select.Connection  = connection;
                        select.CommandText = "SELECT Login, Pass,Lvl_Access FROM Log_Pass Where Login ='******'";
                        //"Select * From Accounts Where Lastname  = '" + searchtb.Text + "'";
                        OleDbDataReader reader = select.ExecuteReader();
                        while (reader.Read())
                        {
                            k++;
                            log  = reader[0].ToString();
                            pass = reader[1].ToString();
                            lvl  = reader[2].ToString();
                        }
                        connection.Close();
                        reader.Close();
                        if (k == 0)
                        {
                            incorrect_login.Visible = true;
                        }
                        if (pass != Password_text.Text)
                        {
                            incorrect_pass.Visible = true;
                        }
                        else
                        {
                            if (lvl == "1")
                            {
                                Form f2 = new Guest_Form(lvl);
                                this.Hide();
                                f2.Show();
                            }
                            if (lvl == "2")
                            {
                                Form f2 = new Guest_Form(lvl);
                                this.Hide();
                                f2.Show();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Нет входных параметров!");
                }
            }
        }