//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); }
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); }
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); }