Beispiel #1
0
 private void MudarSenhas_FormClosed(object sender, FormClosedEventArgs e)
 {
     conexao.Close();
     telaP.Show();
 }
Beispiel #2
0
        private void Logar()
        {
            string           email  = "";
            SQLiteCommand    Login  = new SQLiteCommand("SELECT `email` FROM `usuario` WHERE `usuario` = '" + tbUsuario.Text + "' AND `senha` = '" + tbSenha.Text + "'", conexao);
            SQLiteCommand    checar = new SQLiteCommand("SELECT `tipo` FROM `usuario` WHERE `usuario` = '" + tbUsuario.Text + "'", conexao);
            SQLiteDataReader myReader;

            conexao.Open();
            myReader = Login.ExecuteReader();
            int count = 0;

            while (myReader.Read())
            {
                email  = myReader["email"].ToString();
                count += 1;
            }

            if (count == 1)
            {
                string nome = "";
                myReader = checar.ExecuteReader();
                while (myReader.Read())
                {
                    tipo   = myReader["tipo"].ToString();
                    count += 1;
                }
                if (tipo == "True")
                {
                    SQLiteCommand    cliente = new SQLiteCommand("SELECT `nome` FROM `clientes` WHERE `email` = '" + email + "'", conexao);
                    SQLiteDataReader myReader2;
                    myReader2 = cliente.ExecuteReader();

                    while (myReader2.Read())
                    {
                        nome = myReader2["nome"].ToString();
                    }
                }



                if (tipo == "False")
                {
                    SQLiteCommand    func = new SQLiteCommand("SELECT `nome` FROM `funcionarios` WHERE `email` = '" + email + "'", conexao);
                    SQLiteDataReader myReader3;
                    myReader3 = func.ExecuteReader();
                    while (myReader3.Read())
                    {
                        nome = myReader3["nome"].ToString();
                    }
                }



                TelaPrincipal tela = new TelaPrincipal(this, nome, email);

                tela.Show();
                tbUsuario.Focus();
                tbUsuario.Text = "";
                tbSenha.Text   = "";
                conexao.Close();
                this.Hide();
            }
            else if (count == 0)
            {
                MessageBox.Show("Usuário ou senha inválidos", "Erro");
                conexao.Close();
            }
        }