public CadastroTrans getIds(CadastroTrans a) { conn = classeConexão.obterConexao(); if (conn.State == ConnectionState.Open) { string aux = null; SqlCommand cmd1; SqlDataReader reader; conn = classeConexão.obterConexao(); if (a.getOrigem() != "") { cmd1 = new SqlCommand("SELECT idCarteira FROM Usuario WHERE Nome=@1", conn); cmd1.Parameters.Add("@1", SqlDbType.NVarChar, 90).Value = a.getOrigem(); reader = cmd1.ExecuteReader(); if (reader.Read()) { aux = (reader[0].ToString()); } cmd1.Dispose(); reader.Close(); a.setidOrigem(int.Parse(aux)); } cmd1 = new SqlCommand("SELECT idMoeda FROM Moeda WHERE NomeMoeda=@1", conn); cmd1.Parameters.Add("@1", SqlDbType.NVarChar, 90).Value = a.getMoeda(); reader = cmd1.ExecuteReader(); if (reader.Read()) { aux = (reader[0].ToString()); } cmd1.Dispose(); reader.Close(); a.setidMoeda(int.Parse(aux)); cmd1 = new SqlCommand("SELECT idCarteira FROM Usuario WHERE Nome=@1", conn); cmd1.Parameters.Add("@1", SqlDbType.NVarChar, 90).Value = a.getDestino(); reader = cmd1.ExecuteReader(); if (reader.Read()) { aux = (reader[0].ToString()); } cmd1.Dispose(); reader.Close(); a.setidDestino(int.Parse(aux)); return(a); } else { return(null); } }