private void btnVoltarMenuAdm1_Click(object sender, EventArgs e)
        {
            this.Hide();
            AdMenu amd = new AdMenu();

            amd.Show();
        }
Ejemplo n.º 2
0
        private void btnEntrarAdm_Click(object sender, EventArgs e)
        {
            SQLiteConnection sqlcon = new SQLiteConnection(petdb);

            if ((txtUserAdm.Text == "") && (txtPassAdm.Text == "") || (txtUserAdm.Text == "") || (txtPassAdm.Text == ""))
            {
                lblAvisoAdm.Visible = true;
                lblAvisoAdm.Text    = "Usuário e/ou senha vazios!";
            }
            else
            {
                try
                {
                    sqlcon.Open();
                    string        query = "SELECT * FROM loginadm WHERE account = '" + txtUserAdm.Text + "' AND password ='******'";
                    SQLiteCommand com   = new SQLiteCommand(query, sqlcon);
                    com.ExecuteNonQuery();
                    SQLiteDataReader dr = com.ExecuteReader();

                    int count = 0;

                    while (dr.Read())
                    {
                        count++;
                    }

                    if (count == 1)
                    {
                        this.Hide();
                        AdMenu menudm = new AdMenu();
                        menudm.Show();
                    }

                    if (count < 1)
                    {
                        lblAvisoAdm.Visible = true;
                        lblAvisoAdm.Text    = "Usuário e/ou senha inválidos!";
                        txtUserAdm.Clear();
                        txtPassAdm.Clear();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao logar: " + ex);
                }
            }
        }