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
|
StringBuilder sb = new StringBuilder();
sb.Append("select * from patient where 1 = 1");
if (nom != string.Empty)
{
sb.Append(" and nom = @nom");
cmd.CreateParameterWithValue("nom", nom);
}
if (prenom != string.Empty)
{
sb.Append(" and prenom = @prenom");
cmd.CreateParameterWithValue("prenom", prenom);
}
if (datenaissance != null)
{
sb.Append(" and datenaissance = @datenaissance");
cmd.CreateParameterWithValue("datenaissance", datenaissance );
}
if (pathologie != string.Empty)
{
sb.Append("and exists (select * from consultation where id_patient = patient.id and diagnostique = @pathologie)");
cmd.CreateParameterWithValue("pathologie", pathologie);
}
cmd.CommandText = sb.ToString(); |
Partager