Exemplo n.º 1
0
        private static bool HasUpdates(out int VersaoRelease)
        {
            BaseDados bd  = new BaseDados();
            string    sql = @"SELECT VersaoRelease FROM atualizacao WHERE id = @1;";

            VersaoRelease = bd.ExecNumberQuery(sql, ConfigAtualizacaoUsing);
            return(VersaoUpdate > VersaoRelease && VersaoRelease > 0);
        }
Exemplo n.º 2
0
        private static void IncrementNumAcessos(int id)
        {
            BaseDados bd = new BaseDados();

            string sql     = @"SELECT n_acessos FROM login WHERE id = @1;";
            int    n_acess = bd.ExecNumberQuery(sql, id) + 1;

            sql = @"UPDATE login SET n_acessos = @2 WHERE id = @1;";
            bd.ExecNonQuery(sql, id, n_acess);
        }
Exemplo n.º 3
0
        public static UserInfo VerificarLogin(string username, string password)
        {
            BaseDados bd       = new BaseDados();
            UserInfo  userInfo = new UserInfo();

            string sql = @"SELECT IFNULL(id, -1) FROM login WHERE username = @1 AND password = @2;";

            int id;

            try { id = bd.ExecNumberQuery(sql, username, password); }
            catch { id = -1; }

            if (id < 1)
            {
                throw new Exception("Dados de Login Incorretos!");
            }

            sql = @"SELECT bloqueado FROM login WHERE id = @1;";

            int bloqueado = bd.ExecNumberQuery(sql, id);

            if (bloqueado != 0)
            {
                sql = @"SELECT bloqueio_data as data, bloqueio_motivo as motivo FROM login WHERE id = @1;";
                DataTable dt = bd.ExecQuery(sql, id);

                string exp = "<b>Utilizador bloqueado</b> em: " + (String.IsNullOrEmpty(dt.Rows[0]["data"] + "") ? "---" : dt.Rows[0]["data"].ToString()) + "<br />" +
                             "<b>Motivo: </b>" + (String.IsNullOrEmpty(dt.Rows[0]["motivo"] + "") ? "---" : dt.Rows[0]["motivo"].ToString());

                throw new Exception(exp);
            }
            else
            {
                IncrementNumAcessos(id);
                userInfo = GetUserInfo(id);
            }


            return(userInfo);
        }