1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| public static ListeAction getConstatsByGamme(string gamme)
{
ListeAction actions = null;
SqlDataReader reader = null;
SqlConnection conn = Connexion.getConnexion();
conn.Open();
String requete = "SELECT REP_CODE, REP_LIBELLE FROM TYPE_ACTIONS WHERE GROUP_CODE = @gamme AND B_CONSTAT = 1 ORDER BY REP_LIBELLE;";
SqlCommand command = conn.CreateCommand();//new SqlCommand(requete, conn);
command.CommandText = requete;
command.Parameters.Add(new SqlParameter("@gamme", SqlDbType.VarChar, 10));
command.Parameters["@gamme"].Value = gamme;
try
{
using (reader = command.ExecuteReader())
{
lock (reader)
{
while (reader.Read())
{
// création de la liste
if (actions == null)
{
actions = new ListeAction();
}
TypeAction action = new TypeAction();
//action.setLibelle(UtilitaireDB.GererNullString(reader, "REP_LIBELLE"));
action.setLibelle(reader["REP_LIBELLE"].ToString());
//action.setCodeTypeAction(UtilitaireDB.GererNullInt32(reader, "REP_CODE"));
action.setCodeTypeAction(Convert.ToInt32(reader["REP_CODE"].ToString()));
actions.Add(action);
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw;
}
finally
{
conn.Close();
reader.Close();
}
return actions;
} |
Partager