IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

C# / ComboBox / Syntaxe "ET" [Débutant]


Sujet :

C#

  1. #1
    Membre confirmé
    Homme Profil pro
    BAC +3
    Inscrit en
    Octobre 2018
    Messages
    164
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : BAC +3

    Informations forums :
    Inscription : Octobre 2018
    Messages : 164
    Par défaut C# / ComboBox / Syntaxe "ET"
    Bonjour j'aimerais faire une vérification sur mes "ComboBox" si l'utilisateur les remplies ou non. Dans le cas ou il n'en remplis aucune alors le message d'erreur s'affiche sinon c'est bon. Pouvez vous m'aider sur la syntaxe du "ET" dans mon "if" s'il vous plaît?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    private void Chercher_Button_Click(object sender, EventArgs e)                                                  //Déclaration du bouton RECHERCHER
            {
                if (CodeEtatFS_ComboBox_Home.SelectedIndex & StationDestination_ComboBox_Home.SelectedIndex != -1)  // L'erreur ICI
                {
                    MessageBox.Show("TEST");
                }
                else
                {
                    MessageBox.Show("vous n'avez pas sélectionné un seul critère de recherche, veuillez en entrer un pour que ce soit pris en compte");
                }
     
            }
    Merci d'avance

  2. #2
    Membre Expert
    Homme Profil pro
    edi
    Inscrit en
    Juin 2007
    Messages
    941
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : edi

    Informations forums :
    Inscription : Juin 2007
    Messages : 941
    Par défaut
    C'est && et non &.

  3. #3
    Membre confirmé
    Homme Profil pro
    BAC +3
    Inscrit en
    Octobre 2018
    Messages
    164
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : BAC +3

    Informations forums :
    Inscription : Octobre 2018
    Messages : 164
    Par défaut
    Il me dit qu'il est impossible d'appliquer && aux opérandes de types int et int ...

  4. #4
    Expert confirmé
    Homme Profil pro
    Responsable Données
    Inscrit en
    Janvier 2009
    Messages
    5 447
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Responsable Données

    Informations forums :
    Inscription : Janvier 2009
    Messages : 5 447
    Par défaut
    Bonjour,
    Il y a surtout un problème de logique.
    Code C" : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    CodeEtatFS_ComboBox_Home.SelectedIndex && StationDestination_ComboBox_Home.SelectedIndex != -1
    Doit être lu ainsi:
    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    (CodeEtatFS_ComboBox_Home.SelectedIndex) && (StationDestination_ComboBox_Home.SelectedIndex != -1)
    Or la partie gauche (CodeEtatFS_ComboBox_Home.SelectedIndex) n'est pas un booléen.

    Tatayo.

  5. #5
    Membre confirmé
    Homme Profil pro
    BAC +3
    Inscrit en
    Octobre 2018
    Messages
    164
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : BAC +3

    Informations forums :
    Inscription : Octobre 2018
    Messages : 164
    Par défaut
    merci pour voutre aide

    Les deux renvoient à la valeur récupéré dans les combobox , le programme me renvoie 10 erreurs maintenant au niveau du else et du &&Nom : Capture.PNG
Affichages : 345
Taille : 74,7 Ko

  6. #6
    Expert confirmé
    Homme Profil pro
    Responsable Données
    Inscrit en
    Janvier 2009
    Messages
    5 447
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Responsable Données

    Informations forums :
    Inscription : Janvier 2009
    Messages : 5 447
    Par défaut
    J'ai indiqué la façon dont il faut comprendre la ligne, pour trouver l'origine de l'erreur, non comment il faut la taper dans le code !
    La condition d'un if doit être entre parenthèse, et de chaque côté d'un && il faut trouver une expression booléenne, or CodeEtatFS_ComboBox_Home.SelectedIndex n'est pas une expression booléenne.

    Tatayo.

  7. #7
    Membre confirmé
    Homme Profil pro
    BAC +3
    Inscrit en
    Octobre 2018
    Messages
    164
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : BAC +3

    Informations forums :
    Inscription : Octobre 2018
    Messages : 164
    Par défaut
    Ha d'accord pardon , en fait j'avais déjà essayer le && et je me doutais qu'y avait un erreur . Je ne maîtrise pas completement l'utilisation des combo box. Je ne sais pas trop comment m'y prendre

  8. #8
    Membre Expert
    Homme Profil pro
    edi
    Inscrit en
    Juin 2007
    Messages
    941
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : edi

    Informations forums :
    Inscription : Juin 2007
    Messages : 941
    Par défaut
    Je plussoie pour le problème de logique, d'autant que tu as modifié ta structure de raisonnement entre ton premier message et le dernier. Tu devrais prendre un papier et un crayon et formuler explicitement les conditions que tu veux vérifier.

  9. #9
    Membre confirmé
    Homme Profil pro
    BAC +3
    Inscrit en
    Octobre 2018
    Messages
    164
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : BAC +3

    Informations forums :
    Inscription : Octobre 2018
    Messages : 164
    Par défaut
    Je souhaite intégrer la condition suivante :

    SI la valeur de Combox1 & Combox2 & Combox3 & Combox4 & Combox5 == "" ;
    {
    ALORS Messagebox.Show("Il faut selectionner au moins un critères de selections")
    }

    SINON
    Requete SQL ETC...

    J'ai modifié mon code avec le temps si cela peut aider..

    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
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using MySql.Data.MySqlClient;
     
     
    namespace PROJET_FINDER
    {
        public partial class Recherche : DevExpress.XtraEditors.XtraForm
        {
            public Recherche()
            {
                InitializeComponent();
            }
     
     
            readonly MySqlConnection connection = new MySqlConnection("Datasource = localhost;port=3306;username=root;password=");
     
            private void Recherche_Load(object sender, EventArgs e)//Début des appels des ComboBox
            {
                try                                                                                                         //Début Try/Catch pour le ComboBox des catégorie Radiologiqque
                {
                    connection.Open();
                    CatégorieRadiologique_ComboBox_Home.DropDownStyle = ComboBoxStyle.DropDownList;                        //ReadOnly sur la comboBox
                    string selectQuery = "SELECT ID_Rad , Radiologique FROM cdh.ctg_rad";
                    MySqlCommand command = new MySqlCommand(selectQuery, connection);
                    MySqlDataReader reader = command.ExecuteReader();
     
     
                    while (reader.Read())
                    {
                        CatégorieRadiologique_ComboBox_Home.Items.Add(reader.GetString("Radiologique"));
                        string[,] TableauRad = new string[1, 2]
                        {
                            {"ID_Rad","Radiologique"},
     
     
                        };
                    }
                    connection.Close();
                }
                catch (MySqlException cn)
     
                {
                    MessageBox.Show(cn.Message);
                    connection.Close();
                }
     
                try                                                                                                         //Début Try/Catch pour le ComboBox le Code d'Etat
                {
                    connection.Open();                                                                                      //Connexion à la base de donnée ouverte
                    CodeEtatFS_ComboBox_Home.DropDownStyle = ComboBoxStyle.DropDownList;                                    //ReadOnly sur la comboBox
     
                    string selectQuery = "SELECT Code_Etat , Lib_Code_Etat FROM cdh.etat ";
                    MySqlCommand command = new MySqlCommand(selectQuery, connection);                                       //Création de l'objet de la commande SQL
                    MySqlDataReader reader = command.ExecuteReader();                                                       //Déclaration de la nouvelle instance
     
                    while (reader.Read())
                    {
                        CodeEtatFS_ComboBox_Home.Items.Add(reader.GetString("Lib_Code_Etat"));
                        string[,] TableauEtat = new string[1, 2]
                        {
                            {"Code_Etat","Lib_Code_Etat"},
     
                        };
                    }
                    connection.Close();
                }
                catch (MySqlException cn)
                {
                    MessageBox.Show(cn.Message);
                    connection.Close();
                }
     
                try                                                                                                         //Début Try/Catch pour le ComboBox des producteurs du déchet
                {
                    connection.Open();
                    Producteur_ComboBox_Home.DropDownStyle = ComboBoxStyle.DropDownList;                                    //ReadOnly sur la comboBox
                    string selectQuery = "SELECT Code_Producteur , Producteur FROM cdh.prod";
                    MySqlCommand command = new MySqlCommand(selectQuery, connection);
                    MySqlDataReader reader = command.ExecuteReader();
     
     
                    while (reader.Read())
                    {
                        Producteur_ComboBox_Home.Items.Add(reader.GetString("Producteur"));
                        string[,] TableauEtat = new string[1, 2]
                        {
                            {"Code_Producteur","Producteur"},
     
                        };
                    }
                    connection.Close();
                }
                catch (MySqlException cn)
                {
                    MessageBox.Show(cn.Message);
                    connection.Close();
                }
     
                try                                                                                                         //Début Try/Catch pour le ComboBox des Centres
                {
                    connection.Open();
                    Centre_ComboBox_Home.DropDownStyle = ComboBoxStyle.DropDownList;                                        //ReadOnly sur la comboBox
                    string selectQuery = "SELECT * FROM cdh.site_centre";
                    MySqlCommand command = new MySqlCommand(selectQuery, connection);
                    MySqlDataReader reader = command.ExecuteReader();
     
     
                    while (reader.Read())
                    {
                        Centre_ComboBox_Home.Items.Add(reader.GetString("Centre"));
                        string[,] TableauCentre = new string[1, 3]
                        {
                            {"Code_Centre","Centre","ID_Prod"},
     
                        };
                    }
                    connection.Close();
                }
                catch (MySqlException cn)
                {
                    MessageBox.Show(cn.Message);
                    connection.Close();
                }
     
                try                                                                                                         //Début Try/Catch pour le ComboBox de la station de destination du déchet
                {
                    connection.Open();
                    StationDestination_ComboBox_Home.DropDownStyle = ComboBoxStyle.DropDownList;                            //ReadOnly sur la comboBox
                    string selectQuery = "SELECT Code_StationdeDestination , Station_Destination FROM cdh.station_destination";
                    MySqlCommand command = new MySqlCommand(selectQuery, connection);
                    MySqlDataReader reader = command.ExecuteReader();
     
     
                    while (reader.Read())
                    {
                        StationDestination_ComboBox_Home.Items.Add(reader.GetString("Station_Destination"));
                        string[,] TableauEtat = new string[1, 2]
                        {
                            {"Code_StationdeDestination","Station_Destination"},
     
                        };
                    }
                    connection.Close();
                }
                catch (MySqlException cn)
                {
                    MessageBox.Show(cn.Message);
                    connection.Close();
                }
     
                try                                                                                                         //Début Try/Catch pour le ComboBox du conditionnement du déchet
                {
                    connection.Open();
                    Conditionnement_ComboBox_Home.DropDownStyle = ComboBoxStyle.DropDownList;                               //ReadOnly sur la comboBox
                    string selectQuery = "SELECT Code_Conditionnement , Conditionnement FROM cdh.statut_condition";
                    MySqlCommand command = new MySqlCommand(selectQuery, connection);
                    MySqlDataReader reader = command.ExecuteReader();
     
     
                    while (reader.Read())
                    {
                        Conditionnement_ComboBox_Home.Items.Add(reader.GetString("Conditionnement"));
                        string[,] TableauEtat = new string[1, 2]
                        {
                            {"Code_Conditionnement","Conditionnement"},
     
                        };
                    }
                    connection.Close();
                }
                catch (MySqlException cn)
                {
                    MessageBox.Show(cn.Message);
                    connection.Close();
                }
     
            }//Fin des appels des ComboBox
     
            private void DataTimePicker_Home_1_ValueChanged(object sender, EventArgs e)                                     //Lorsque la valeur du DataTimePicker_Home_1 change alors le 3 et le 4 se désactive
            {
                DataTimePicker_Home_3.Enabled = false;
                DataTimePicker_Home_4.Enabled = false;
            }
     
            private void DataTimePicker_Home_2_ValueChanged(object sender, EventArgs e)                                     //Lorsque la valeur du DataTimePicker_Home_2 change alors le 3 et le 4 se désactive
            {
                DataTimePicker_Home_3.Enabled = false;
                DataTimePicker_Home_4.Enabled = false;
            }
     
            private void DataTimePicker_Home_3_ValueChanged(object sender, EventArgs e)                                     //Lorsque la valeur du DataTimePicker_Home_3 change alors le 1 et le 2 se désactive
            {
                DataTimePicker_Home_1.Enabled = false;
                DataTimePicker_Home_2.Enabled = false;
            }
     
            private void DataTimePicker_Home_4_ValueChanged(object sender, EventArgs e)                                     //Lorsque la valeur du DataTimePicker_Home_4 change alors le 1 et le 2 se désactive
            {
                DataTimePicker_Home_1.Enabled = false;
                DataTimePicker_Home_2.Enabled = false;
            }
     
            private void Data_Reset_Button_Click(object sender, EventArgs e)                                                //Bouton de réinitiallisation des paramètres de recherches
            {
                // Réinitialisation des DataTimePicker à leur états initiale (True)
                DataTimePicker_Home_1.Enabled = true;                                       
                DataTimePicker_Home_2.Enabled = true;
                DataTimePicker_Home_3.Enabled = true;
                DataTimePicker_Home_4.Enabled = true;
     
                // Réinitialisation des ComboBox et de la TextBox FS à leur états initials (True)
                FS_TextBox_Home.Enabled = true;
                FS_TextBox_Home.Text = " ";
                CatégorieRadiologique_ComboBox_Home.Enabled = true;
                CodeEtatFS_ComboBox_Home.Enabled = true;
                Producteur_ComboBox_Home.Enabled = true;
                Centre_ComboBox_Home.Enabled = true;
                StationDestination_ComboBox_Home.Enabled = true;
                Conditionnement_ComboBox_Home.Enabled = true;
     
                // Réinitialisation du contenu des ComboBox (Vide = -1)
                CodeEtatFS_ComboBox_Home.SelectedIndex = -1;
                StationDestination_ComboBox_Home.SelectedIndex = -1;
                CatégorieRadiologique_ComboBox_Home.SelectedIndex = -1;
                Conditionnement_ComboBox_Home.SelectedIndex = -1;
                Centre_ComboBox_Home.SelectedIndex = -1;
                Producteur_ComboBox_Home.SelectedIndex = -1;
     
     
            }
     
            private void Chercher_Button_Click(object sender, EventArgs e)                                                  //Déclaration du bouton RECHERCHER
            {
                Object selectedItem_CatRadg = CatégorieRadiologique_ComboBox_Home.ToString();
                Object selectedItem_Etat = CodeEtatFS_ComboBox_Home.ToString();
                Object selectedItem_Producteur = Producteur_ComboBox_Home.ToString();
                Object selectedItem_Centre = Centre_ComboBox_Home.ToString();
                Object selectedItem_StationdeDestination = StationDestination_ComboBox_Home.ToString();
                Object selectedItem_Conditionnement = Conditionnement_ComboBox_Home.ToString();
     
                if (selectedItem_CatRadg.ToString() == " ")
                {
                    MessageBox.Show("vous n'avez pas sélectionné un seul critère de recherche, veuillez en entrer un pour que ce soit pris en compte");
                    connection.Close();
                }
                else if (FS_TextBox_Home.Text != "")                                                                        // Recherche par le numéro FS
                {
                    connection.Open();
     
                    DataTimePicker_Home_1.Enabled = false;                                                                  // Changement détat des comboboxs et DataPicker
                    DataTimePicker_Home_2.Enabled = false;
                    DataTimePicker_Home_3.Enabled = false;
                    DataTimePicker_Home_4.Enabled = false;
                    CodeEtatFS_ComboBox_Home.Enabled = false;
                    StationDestination_ComboBox_Home.Enabled = false;
                    CatégorieRadiologique_ComboBox_Home.Enabled = false;
                    Conditionnement_ComboBox_Home.Enabled = false;
                    Centre_ComboBox_Home.Enabled = false;
                    Producteur_ComboBox_Home.Enabled = false;
     
                    LW_FS_Home.Items.Clear();
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM cdh.fiche WHERE FS=@FS", connection); // Requète SQL SELECT pour selectionner l'élément correspondant au numéro de la FS entré
                    cmd.Parameters.AddWithValue("@FS", FS_TextBox_Home.Text);//Récupération du numéro FS souhaité par l'utilisateur
     
                    using (MySqlDataReader Lire = cmd.ExecuteReader())
     
                    {
                        while (Lire.Read())  // Boucle While qui regarde toutes les infos que l'on souhaite voir avec la méthode "lire"
                        {
                            string FS = Lire["FS"].ToString();                                                              // Declaration des colonnes et leurs équivalents (remplacants)
                            string ID_Rad = Lire["ID_Rad"].ToString();
                            string Code_Etat = Lire["Code_Etat"].ToString();
                            string Code_Producteur = Lire["Code_Producteur"].ToString();
                            string Code_Centre = Lire["Code_Centre"].ToString();
                            string Code_StationdeDestination = Lire["Code_StationdeDestination"].ToString();
                            string Code_Conditionnement = Lire["Code_Conditionnement"].ToString();
     
                            LW_FS_Home.Items.Add(new ListViewItem(new[] {FS, ID_Rad, Code_Etat, Code_Producteur, Code_Centre, Code_StationdeDestination, Code_Conditionnement }));// Ajout des nouvelles valeurs dans la list view
                        }
                    }
                    connection.Close();                                                                                     // Fermeture de la connexion pour pouvoir refaire un recherche
                }
                else
                {
                    connection.Open();
                    string[] TableauCombo = new string[7];
                    {
                        TableauCombo[0] = "ID_Rad=@"+CatégorieRadiologique_ComboBox_Home.SelectedIndex.ToString();
                        TableauCombo[1] = "Code_Etat=@"+CodeEtatFS_ComboBox_Home.SelectedIndex.ToString(); ;
                        TableauCombo[2] = "Code_Producteur=@"+Producteur_ComboBox_Home.SelectedIndex.ToString();
                        TableauCombo[3] = "Code_Centre=@"+Centre_ComboBox_Home.SelectedIndex.ToString();
                        TableauCombo[4] = "Code_StationdeDestination=@"+StationDestination_ComboBox_Home.SelectedIndex.ToString();
                        TableauCombo[5] = "Code_Conditionnement=@"+Conditionnement_ComboBox_Home.SelectedIndex.ToString(); 
                    };
     
                    for (int i = 0; i < TableauCombo.Length ; i++)
                    {
     
                        string requery = "";
                        requery = requery + TableauCombo[i];
     
                        LW_FS_Home.Items.Clear();
                        MySqlCommand cmd = new MySqlCommand("SELECT FS FROM cdh.fiche WHERE "+requery+" ", connection); // Requète SQL SELECT 
                        cmd.Parameters.AddWithValue("@ID_Rad", CatégorieRadiologique_ComboBox_Home.ToString());//Récupération du ID_Rad souhaité par l'utilisateur
                        cmd.Parameters.AddWithValue("@Code_Etat", CodeEtatFS_ComboBox_Home.ToString());//Récupération du Code_Etat souhaité par l'utilisateur
                        cmd.Parameters.AddWithValue("@Code_Producteur", Producteur_ComboBox_Home.ToString());//Récupération du Code_Producteur souhaité par l'utilisateur
                        cmd.Parameters.AddWithValue("@Code_Centre", Centre_ComboBox_Home.ToString());//Récupération du Code_Centre souhaité par l'utilisateur
                        cmd.Parameters.AddWithValue("@Code_StationdeDestination", StationDestination_ComboBox_Home.ToString());//Récupération du Code_StationdeDestination souhaité par l'utilisateur
                        cmd.Parameters.AddWithValue("@Code_Conditionnement", Conditionnement_ComboBox_Home.Text);//Récupération du Code_Conditionnement souhaité par l'utilisateur
     
                        using (MySqlDataReader Lire = cmd.ExecuteReader())
     
                        {
                            while (Lire.Read())  // Boucle While qui regarde toutes les infos que l'on souhaite voir avec la méthode "lire"
                            {
                                string FS = Lire["@FS"].ToString();                                                              // Declaration des colonnes et leurs équivalents (remplacants)
                                string ID_Rad = Lire["@ID_Rad"].ToString();
                                string Code_Etat = Lire["@Code_Etat"].ToString();
                                string Code_Producteur = Lire["@Code_Producteur"].ToString();
                                string Code_Centre = Lire["@Code_Centre"].ToString();
                                string Code_StationdeDestination = Lire["@Code_StationdeDestination"].ToString();
                                string Code_Conditionnement = Lire["@Code_Conditionnement"].ToString();
     
                                LW_FS_Home.Items.Add(new ListViewItem(new[] { FS, ID_Rad, Code_Etat, Code_Producteur, Code_Centre, Code_StationdeDestination, Code_Conditionnement }));// Ajout des nouvelles valeurs dans la list view
                            }
                        }
                        connection.Close();
                    }
                }
     
            }
        }
    }
    /*
     
     
     
     
    while ()
     
     
     
    MessageBox.Show("Selected Item Text: " + selectedItem_Etat.ToString() + "\n"
    + selectedItem_Centre.ToString() + "\n"
    + selectedItem_CatRadg.ToString() + "\n"
    + selectedItem_FS.ToString() + "\n"
    + selectedItem_StationdeDestination.ToString() + "\n"
    + selectedItem_Producteur.ToString() + "\n"
    + selectedItem_Conditionnement.ToString() + "\n");*/

  10. #10
    Expert éminent Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 204
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 204
    Par défaut
    on va te l'écrire en très détaillé car visiblement tu ne comprends pas ce qu'on te dit ..

    if (CodeEtatFS_ComboBox_Home.SelectedIndex & StationDestination_ComboBox_Home.SelectedIndex != -1)ceci n'est pas possible, ca ne veut rien dire

    le if test un booléen, soit vrai ou faux
    & permet d'en tester 2 (ou plus), mais chaque côté du & est analysé individuellement et doit être un booléen
    donc à droite du & on a un combobox.selectedindex != -1, qui retourne true ou false donc c'est bon
    mais à gauche du & tu asunautrecombobox.selectedindex, qui retourne un int, un int n'est pas un booléen donc le compilateur te dis que t'as écris une connerie

    if (CodeEtatFS_ComboBox_Home.SelectedIndex != -1 & StationDestination_ComboBox_Home.SelectedIndex != -1)là c'est mieux car on a bien 2 booléens


    au passage
    & teste toutes les parties
    && s'arrête de tester dès qu'une est fausse (ce qui peut optimiser dans la plupart des cas)
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  11. #11
    Membre Expert
    Homme Profil pro
    edi
    Inscrit en
    Juin 2007
    Messages
    941
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : edi

    Informations forums :
    Inscription : Juin 2007
    Messages : 941
    Par défaut
    Pour résoudre ton if il te suffit de de savoir comment :
    - vérifier si une chaîne est une chaine vide ;
    - combiner deux valeurs booléennes.
    Dans le premier cas tu sais déjà faire, dans le second on a déjà donné des réponses. Il ne reste qu'à combiner le tout à partir du raisonnement que tu as fourni.

    Par contre le & simple n'est pas à utiliser dans ce cas là ; il s'agit du ET bit à bit, qui renvoie bien un booléen parce-que les paramètres en entrée sont des booléens, mais s'il s'était agit d'entiers on aurait un entier au retour. Le && est le vrai ET logique au sens de valeurs de vérité (true ou false) et ne fonctionne qu'avec des booléens.

  12. #12
    Membre confirmé
    Homme Profil pro
    BAC +3
    Inscrit en
    Octobre 2018
    Messages
    164
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : BAC +3

    Informations forums :
    Inscription : Octobre 2018
    Messages : 164
    Par défaut
    Ok d'accord merci beaucoup pour vos réponses c'est beaucoup plus clairs désolé de l'incompréhension

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. syntaxe quotes et guillemets
    Par Xeuch dans le forum Langage
    Réponses: 2
    Dernier message: 05/09/2014, 17h13
  2. Syntaxe quotes et double quotes
    Par almoha dans le forum Langage
    Réponses: 5
    Dernier message: 01/11/2010, 15h33
  3. Syntaxe quote et guillemets
    Par yuyuboy dans le forum Langage
    Réponses: 2
    Dernier message: 06/09/2009, 17h51
  4. [MySQL] Supprimer les erreurs de syntaxe dues aux quotes
    Par gotenks dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 25/01/2006, 16h10
  5. Syntaxe de la balise [quote]
    Par BainE dans le forum Mode d'emploi & aide aux nouveaux
    Réponses: 3
    Dernier message: 28/11/2005, 22h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo