Exemplo n.º 1
0
Arquivo: Auth.cs Projeto: dina200/RC
        private void authButton_Click(object sender, EventArgs e)
        {
            String login = loginTextBox.Text;
            String pass  = passTextBox.Text;
            User   user  = null;

            if (login.Equals("admin"))
            {
                user          = new Admin();
                user.login    = login;
                user.password = pass;
            }
            else
            {
                user          = new Manager();
                user.login    = login;
                user.password = pass;
            }
            if (db.getConn().State.ToString().Equals("Closed"))
            {
                db = new dbHelper();
                db.openDb();
            }
            if (db.authorisation(login, pass, user) != null)
            {
                user = db.authorisation(login, pass, user);
                new RentCar(user, this).Show();
                db.close();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Error! Not correct data");
                loginTextBox.Text = "";
                passTextBox.Text  = "";
            }
        }