コード例 #1
0
ファイル: Usuario.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// 
        /// </summary>
        void IMetodosPadroes.Inserir()
        {
            StringBuilder SQL;

            try
            {
                SQL = new StringBuilder();
                if (conexao == null)
                    conexao = new Conexao();

                SQL.AppendLine("INSERT INTO USUARIO");
                SQL.AppendLine("( LOGIN");
                SQL.AppendLine(", SENHA)");

                SQL.AppendLine("VALUES");
                SQL.AppendLine(string.Format("('{0}'", this.login));
                SQL.AppendLine(string.Format(",'{0}')", this.senha));

                conexao.ExecutaComando(SQL.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
ファイル: Candidato.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Altera um candidato
        /// </summary>
        void IMetodosPadroes.Alterar()
        {
            StringBuilder SQL;
            try
            {
                if (conexao == null)
                    conexao = new Conexao();

                SQL = new StringBuilder();
                SQL.AppendLine("UPDATE CANDIDATO");
                SQL.AppendLine(string.Format("SET NOME = '{0}'", this.nome));
                SQL.AppendLine(string.Format(", NUMERO  = {0}", this.numero));
                SQL.AppendLine(string.Format(", VICE = '{0}'", this.vice));
                SQL.AppendLine(string.Format(", CARGO = '{0}'", this.cargo));
                SQL.AppendLine(string.Format(", FOTO = '{0}'", this.foto));
                SQL.AppendLine(string.Format(", PARTIDOID = {0}", this.partidoid));
                SQL.AppendLine(string.Format(", ESTADOCANDIDATO = '{0}'", this.estadocandidato));
                SQL.AppendLine(string.Format("WHERE CANDIDATOID = {0}", this.candidatoid));

                conexao.ExecutaComando(SQL.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
コード例 #3
0
ファイル: Candidato.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Insere um candidato
        /// </summary>
        void IMetodosPadroes.Inserir()
        {
            StringBuilder SQL;
            try
            {
                if (conexao == null)
                    conexao = new Conexao();

                SQL = new StringBuilder();
                SQL.AppendLine("INSERT INTO CANDIDATO");
                SQL.AppendLine("( NOME");
                SQL.AppendLine(", NUMERO");
                SQL.AppendLine(", VICE");
                SQL.AppendLine(", CARGO");
                SQL.AppendLine(", FOTO");
                SQL.AppendLine(", PARTIDOID");
                SQL.AppendLine(", ESTADOCANDIDATO)");
                SQL.AppendLine("VALUES");
                SQL.AppendLine(string.Format("('{0}'", this.nome));
                SQL.AppendLine(string.Format(",{0}", this.numero));
                if (this.vice == null)
                {
                    SQL.AppendLine(string.Format(",NULL"));

                }
                else
                {
                    SQL.AppendLine(string.Format(",'{0}'", this.vice));

                }
                SQL.AppendLine(string.Format(",'{0}'", this.cargo));
                SQL.AppendLine(string.Format(",'{0}'", this.foto));
                SQL.AppendLine(string.Format(",{0}", this.partidoid));
                SQL.AppendLine(string.Format(",'{0}')", this.estadocandidato));
                conexao.ExecutaComando(SQL.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #4
0
ファイル: Usuario.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Altera algum usuário
        /// </summary>
        void IMetodosPadroes.Alterar()
        {
            StringBuilder SQL;
            try
            {
                SQL = new StringBuilder();

                if (conexao == null)
                    conexao = new Conexao();

                SQL.AppendLine("UPDATE USUARIO");
                SQL.AppendLine(string.Format("SET LOGIN = '******'", this.login));
                SQL.AppendLine(string.Format(", SIGLA = '{0}'", this.senha));
                SQL.AppendLine(string.Format("WHERE USUARIOID = {0}", this.usuarioid));

                conexao.ExecutaComando(SQL.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
コード例 #5
0
ファイル: Voto.cs プロジェクト: dielduarte/votaai
        public DataSet BuscarDadosAlteracao(Voto voto, string cargo, string estado)
        {


            if (conexao == null)
                conexao = new Conexao();

            return voto.BuscaParaGrafico(cargo, estado);
        }
コード例 #6
0
ファイル: Usuario.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Exclui algum usuário, passando o id dele como parametro
        /// </summary>
        void IMetodosPadroes.Excluir()
        {
            StringBuilder SQL;
            try
            {
                SQL = new StringBuilder();
                if (conexao == null)
                    conexao = new Conexao();

                SQL.AppendLine("DELETE FROM USUARIO");
                SQL.AppendLine(string.Format("WHERE USUARIOID={0}", this.usuarioid));

                conexao.ExecutaComando(SQL.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #7
0
ファイル: Usuario.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Retorna verdadeiro ou falso para o login do usuário
        /// </summary>
        /// <returns>True se o usuário existe, false se não voltar</returns>
        public bool LogarUsuario()
        {
            StringBuilder SQL;
            try
            {
                if (conexao == null)
                    conexao = new Conexao();

                SQL = new StringBuilder();

                SQL.AppendLine("SELECT * FROM");
                SQL.AppendLine(string.Format("WHERE login = {0} AND senha = {1}", this.login, this.senha));

                if (conexao.BuscaDados(SQL.ToString()).Tables[0].Rows.Count > 1)
                    return true;
                else
                    return false;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #8
0
ファイル: Usuario.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Retorna o DataSet da busca
        /// </summary>
        /// <returns>o dataset</returns>
        public DataSet BuscarDados(Usuario user)
        {
            IMetodosPadroes metodos = user;

            if (conexao == null)
                conexao = new Conexao();

            return metodos.Busca();
        }
コード例 #9
0
ファイル: Usuario.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Cria uma lista com todos os usuários disponíveis
        /// </summary>
        DataSet IMetodosPadroes.Busca()
        {
            StringBuilder SQL;

            try
            {
                SQL = new StringBuilder();

                if (conexao == null)
                    conexao = new Conexao();

                SQL.AppendLine("SELECT * FROM usuario");
                SQL.AppendLine("WHERE (1=1)");
                if (this.login != null)
                {
                    SQL.AppendLine(string.Format(" AND login = '******' ", this.login));
                }

                if (this.senha != null && this.senha != 0)
                {
                    SQL.AppendLine(string.Format(" AND senha = '{0}'", this.senha));
                }

                if (this.usuarioid != 0 && this.usuarioid != null)
                {
                    SQL.AppendLine(string.Format(" AND usuarioid = {0}", this.usuarioid));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return conexao.BuscaDados(SQL.ToString());
        }
コード例 #10
0
ファイル: Eleitor.cs プロジェクト: dielduarte/votaai
        public DataSet BuscarDados(Eleitor part)
        {
            IMetodosPadroes metodos = part;

            if (conexao == null)
                conexao = new Conexao();

            return metodos.Busca();
        }
コード例 #11
0
ファイル: Candidato.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Retorna o DataSet da busca
        /// </summary>
        /// <returns>o dataset</returns>
        public DataSet BuscarDados(Candidato cand)
        {
            IMetodosPadroes metodos = cand;

            if (conexao == null)
                conexao = new Conexao();

            return metodos.Busca();
        }
コード例 #12
0
ファイル: Candidato.cs プロジェクト: dielduarte/votaai
        /// <summary>
        /// Busca dados, de acordo com os dados passados pelo usuário
        /// </summary>
        /// <returns>Um dataset com os usuários</returns>
        DataSet IMetodosPadroes.Busca()
        {
            StringBuilder sql;
            try
            {
                if (conexao == null)
                    conexao = new Conexao();

                sql = new StringBuilder();
                sql.AppendLine("SELECT * FROM CANDIDATO");

                sql.AppendLine("WHERE (1 = 1)");

                if (this.candidatoid != 0)
                    sql.AppendLine(string.Format(" AND candidatoid = {0}", this.candidatoid));
                if (this.cargo != null)
                    sql.AppendLine(string.Format(" AND cargo = '{0}'", this.cargo));
                if (this.nome != null)
                    sql.AppendLine(string.Format(" AND nome = '{0}'", this.nome));
                if (this.partidoid != 0 && this.partidoid != null)
                    sql.AppendLine(string.Format(" AND partidoid = {0}", this.partidoid));
                if (this.numero != 0 && this.numero != null)
                   sql.AppendLine(string.Format(" AND numero = {0}", this.numero));
                if (this.estadocandidato != null)
                    sql.AppendLine(string.Format(" AND estadocandidato = '{0}'", this.estadocandidato));
                
                

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return conexao.BuscaDados(sql.ToString());
        }
コード例 #13
0
ファイル: Partido.cs プロジェクト: dielduarte/votaai
        public DataSet BuscarDadosAlteracao(Partido part)
        {


            if (conexao == null)
                conexao = new Conexao();

            return part.BuscaDadosInsert();
        }