Esempio n. 1
0
        public bool ValidarLogin(String username, String senha)
        {
            MySqlConnection con = new MySqlConnection();

            loginV  = new V.LoginV();
            conexao = new Conexao.Connection();
            con.ConnectionString = conexao.getConnectionString();
            con.Open();

            string query = "SELECT * from funcionarios WHERE username = ?username and senha = ?senha";

            try
            {
                MySqlCommand cmd = new MySqlCommand(query, con);

                cmd.Parameters.AddWithValue("?username", username);
                cmd.Parameters.AddWithValue("?senha", senha);

                MySqlDataReader sdr = cmd.ExecuteReader();
                if (sdr.Read())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Ocorreu um erro ao tentar logar. Verifique suas informações e tente novamente.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                limparCampos();
                return(false);
            }
        }
Esempio n. 2
0
        public bool ValidarLogin(String username, String senha)
        {
            con     = new MySqlConnection();
            loginv  = new V.LoginV();
            conexao = new Conexao.Connection();
            con.ConnectionString = conexao.getConnectionString();
            String query = "SELECT * FROM funcionarios WHERE username = ?username AND senha = ?senha";

            try
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand(query, con);
                cmd.Parameters.AddWithValue("?username", username);
                cmd.Parameters.AddWithValue("?senha", senha);
                cmd.ExecuteNonQuery();
                MySqlDataReader result = cmd.ExecuteReader();

                return(result.Read());
            }
            finally
            {
                con.Close();
            }
        }