| 12
 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
 
 | try
                {
                    // On crée un nouvel objet SQLiteConnectionStringBuilder.
                    SQLiteConnectionStringBuilder SQLCSB = new SQLiteConnectionStringBuilder();
 
                    // On définit nos paramètres.
                    SQLCSB.DataSource = "base_proj.db"; // La base de données à utiliser
                    SQLCSB.FailIfMissing = false; // Si la base n'existe pas, alors on la crée automatiquement
 
                    string ConnectionString = SQLCSB.ToString();
 
                    // On crée une connexion, le constructeur prend en paramètre la ConnectionString.
                    SQLiteConnection SQLC = new SQLiteConnection(ConnectionString);
 
                    // On ouvre la connexion.
 
                    SQLC.Open();
 
                    // Requete de récupération des clients.
                    SQLiteCommand SQLCmd = SQLC.CreateCommand();
                    SQLCmd.CommandText = "SELECT idf_client FROM client WHERE idf_client IN (SELECT idf_client FROM accompagnateur WHERE idf_accompagnateur= " + idf_client + ");";
                    SQLiteDataReader SQLDReader = SQLCmd.ExecuteReader();
 
                    while (SQLDReader.Read()) // Suppression de la liste des clients qui l'accompagne (mahréme).
                    {                        
                        string idf_cl = string.Format("{0}", SQLDReader["idf_client"]);
 
                        SQLiteCommand SQLCmd3 = SQLC.CreateCommand();
                        SQLCmd3.CommandText = "DELETE FROM client WHERE idf_client= " + idf_cl + " ;";
                        int ii = Int32.Parse(SQLCmd3.ExecuteNonQuery().ToString());
 
                        SQLiteCommand SQLCmd4 = SQLC.CreateCommand();
                        SQLCmd4.CommandText = "DELETE FROM accompagnateur WHERE idf_client= " + idf_cl + " ;";
                        int ii2 = Int32.Parse(SQLCmd4.ExecuteNonQuery().ToString());
                    }
 
                    SQLiteCommand SQLCmd2 = SQLC.CreateCommand();
                    SQLCmd2.CommandText = "DELETE FROM client WHERE idf_client= " + idf_client + " ;";                    
                    int taille = Int32.Parse(SQLCmd2.ExecuteNonQuery().ToString());
 
                    // On ferme la connexion.
 
                    SQLC.Close();
                }
                catch (Exception Ex)
                {
                    // On affiche l'erreur.                    
                    MessageBox.Show("Erreur BD, erreur lors de la suppression du client");
                } | 
Partager