Bonjour, j'ai sur une IHM plusieurs ComboBox dont les données viennent chacune des tables différents. J'aimerais que lorsque j'appuie sur mon bouton "rechercher", le programme prenne en considération les valeurs des ComboBox entrées au préalable par l'utilisateurs pour aller les chercher dans la DATABASE et ainsi les afficher dans ma ListView.

Voici mon code existant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Object selectedItem_Etat = CodeEtatFS_ComboBox_Home.SelectedItem;
Object selectedItem_Centre = Centre_ComboBox_Home.SelectedItem;
Object selectedItem_CatRadg = CatégorieRadiologique_ComboBox_Home.SelectedItem;
Object selectedItem_FS = NuméroFS_ComboBox_Home.SelectedItem;
Object selectedItem_StationdeDestination = StationDestination_ComboBox_Home.SelectedItem;
Object selectedItem_Producteur = Producteur_ComboBox_Home.SelectedItem;
Object selectedItem_Conditionnement = Conditionnement_ComboBox_Home.SelectedItem;
 
            object[,] tabNotes =
           {
                {selectedItem_Etat, CodeEtatFS_ComboBox_Home},
 
                {selectedItem_Centre, Centre_ComboBox_Home},
 
                {selectedItem_FS, NuméroFS_ComboBox_Home},
 
                {selectedItem_CatRadg, CatégorieRadiologique_ComboBox_Home},
 
                {selectedItem_StationdeDestination, StationDestination_ComboBox_Home},
 
                {selectedItem_Producteur, Producteur_ComboBox_Home},
 
                {selectedItem_Conditionnement, Conditionnement_ComboBox_Home}
            };
 
 
 
            int i = 0;
 
            /*bool statement = false;*/
 
 
            while (i == 7)
            {
                connection.Open();
                if (selectedItem_Etat != null)
                {
                    LW_FS_Home.Items.Clear();
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM etat WHERE Lib_Code_Etat=@Lib_Code_Etat", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", CodeEtatFS_ComboBox_Home.Text);//Récupération de l'age souhaité par l'utilisateur
                    i++;
                }
                else if (selectedItem_Centre != null)
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.site_centre WHERE Centre=@Centre", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", Centre_ComboBox_Home.Text);
                    i++;
                }
                else if (selectedItem_FS != null)
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.fiche WHERE FS=@NuméroFS_ComboBox_Home", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", NuméroFS_ComboBox_Home.Text);
                    i++;
                }
                else if (selectedItem_CatRadg != null)
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.ctg_rad WHERE Radiologique=@Radiologique", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", CatégorieRadiologique_ComboBox_Home.Text);
                    i++;
                }
                else if (selectedItem_StationdeDestination != null)
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.station_destination WHERE Station_Destination=@Station_Destination", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", StationDestination_ComboBox_Home.Text);
                    i++;
                }
                else if (selectedItem_Producteur != null)
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.prod WHERE Producteur=@Producteur", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", Producteur_ComboBox_Home.Text);
                    i++;
                }
                else if (selectedItem_Conditionnement != null)
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.statut_condition WHERE Conditionnement=@Conditionnement", connection);
                    cmd.Parameters.AddWithValue("@Lib_Code_Etat", Conditionnement_ComboBox_Home.Text); 
                    i++;
                }
                else
                {
                    MessageBox.Show("AIE");
                }
J'ai décidé d'utilisé un tableau pour que mon while parcours toute les ComboBox qu'elle soit null ou non .

Comment puis-je donc faire pour , en gros , "Toutes les conditions où ce n'est pas null alors tu les mets dans la listview

merci bcp