Beispiel #1
0
        //Inserção de dados

        public string RNFN_Nota(Body_WCF RNFN_Body)
        {
            Ender_Banco Conexao = new Ender_Banco();
            string      Query   = "insert into emissao_nota (id_empresa,num_nota,tip_nota,qtd_itens,totalg,data)" +
                                  "values(?,?,?,?,?,curdate());";
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);
            string         Valid          = null;

            try
            {
                Data_Conection.Open();
                command.CommandText = Query;
                command.Parameters.AddWithValue("@id_empresa", RNFN_Body.Id_empresa);
                command.Parameters.AddWithValue("@num_nota", RNFN_Body.Num_nota);
                command.Parameters.AddWithValue("@tip_nota", RNFN_Body.Tip_nota);
                command.Parameters.AddWithValue("@qtd_itens", RNFN_Body.Qtd_itens);
                command.Parameters.AddWithValue("@totalg", RNFN_Body.Totalg);
                command.ExecuteNonQuery();
            }
            catch (OdbcException Erro)
            {
                Valid = Erro.Message;
                if (Valid.Contains("trigger because it is already"))
                {
                    Valid = "Dado Existente";
                }
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Valid);
        }
Beispiel #2
0
        public List <string> CE_programa_instituicao(string Query, string[] Coluna, string[] Filtros)
        {
            Ender_Banco    Conexao        = new Ender_Banco();
            List <string>  Valid          = new List <string>();
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);

            try
            {
                Data_Conection.Open();
                command.CommandText = Query;
                for (int cont = 0; cont < Coluna.Count(); cont++)
                {
                    command.Parameters.AddWithValue("@" + Coluna[cont], Filtros[cont]);
                }
                command.ExecuteNonQuery();
                OdbcDataReader Reader = command.ExecuteReader();
                while (Reader.Read())
                {
                    Valid.Add(Reader.GetInt16(0).ToString());
                    Valid.Add(Reader.GetInt16(1).ToString());
                    Valid.Add(Reader.GetString(2).ToString());
                }
            }
            catch (OdbcException Erro)
            {
                Valid.Add(Erro.Message);
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Valid);
        }
Beispiel #3
0
        //Consulta
        public List <string> RNFN_Pesquisa(string CNPJ)
        {
            Ender_Banco   Conexao = new Ender_Banco();
            List <string> Valid   = new List <string>();
            string        Query   = "select programa_instituicao.nome_programa,programa_instituicao.id_instituicao from " +
                                    "programa_instituicao," +
                                    "cadastro_instituicao " +
                                    "where cadastro_instituicao.cnpj=? " +
                                    "and programa_instituicao.id_programa = cadastro_instituicao.id_instituicao;";
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);

            try
            {
                Data_Conection.Open();
                command.CommandText = Query;
                command.Parameters.AddWithValue("@cadastro_instituicao.cnpj", CNPJ);
                command.ExecuteNonQuery();
                OdbcDataReader Reader = command.ExecuteReader();
                while (Reader.Read())
                {
                    Valid.Add(Reader.GetString(0));
                    Valid.Add(Reader.GetInt64(1).ToString());
                }
            }
            catch (OdbcException Erro)
            {
                Valid.Add(Erro.Message);
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Valid);
        }
Beispiel #4
0
        public string RNFN_Dispesa(Body_WCF RNFN_Body_Dispesa)
        {
            Ender_Banco Conexao = new Ender_Banco();
            string      Query   = "insert into dispesa_realizada (id_empresa, id_instituicao,id_programa,parcela,num_nota,data)" +
                                  "values (?,?,?,?,?,curdate());";
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);
            string         Valid          = null;

            try
            {
                Data_Conection.Open();
                command.CommandText = Query;
                command.Parameters.AddWithValue("@id_empresa", RNFN_Body_Dispesa.Id_empresa);
                command.Parameters.AddWithValue("@id_instituicao", RNFN_Body_Dispesa.Id_instituicao);
                command.Parameters.AddWithValue("@id_programa", RNFN_Body_Dispesa.Id_programa);
                command.Parameters.AddWithValue("@parcela", RNFN_Body_Dispesa.Parcela);
                command.Parameters.AddWithValue("@num_nota", RNFN_Body_Dispesa.Num_nota);
                command.ExecuteNonQuery();
            }
            catch (OdbcException Erro)
            {
                Valid = Erro.Message;
                if (Valid.Contains("trigger because it is already"))
                {
                    Valid = "Dado Existente";
                }
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Valid);
        }
Beispiel #5
0
        public string Login_Auten(Body_WCF Autenticacao)
        {
            Ender_Banco    Conexao        = new Ender_Banco();
            string         Query          = "select tip_senha from autentic where user=? and senha=?;";
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);

            try
            {
                Data_Conection.Open();
                command.Parameters.AddWithValue("@user", Autenticacao.User);
                command.Parameters.AddWithValue("@senha", Autenticacao.Senha);
                command.ExecuteNonQuery();
                OdbcDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if (reader.GetString(0) == null)
                    {
                        Query = "Usuário ou Senha Invalido..";
                    }
                    else
                    {
                        Query = reader.GetString(0);
                    }
                }
            }
            catch (OdbcException ex)
            {
                return(ex.Message);
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Query);
        }
Beispiel #6
0
        public string Status_Conexao()
        {
            Ender_Banco    Conexao        = new Ender_Banco();
            string         Valid          = null;
            string         Query          = "select * from dispesa_realizada;";
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);

            try
            {
                Data_Conection.Open();
                command.CommandText = Query;
                command.ExecuteNonQuery();
            }
            catch (OdbcException Erro)
            {
                Valid = Erro.Message;
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Valid);
        }