Example #1
0
        private void ListeViewDocumentation_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string DocumentFullPath = "";

            try
            {
                DocumentSelectionne = ListeViewDocumentation.SelectedItem.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Selectionnez un document");
            }

            using (ApplicationDatabase context = new ApplicationDatabase())
            {
                var Doc = context.Database.SqlQuery <string>("SELECT DocumentPath FROM Exigences WHERE DocumentName = '" + DocumentSelectionne + "'").FirstOrDefault();
                DocumentFullPath = Doc;
            }

            try
            {
                String fileName = DocumentFullPath;
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = fileName;
                process.Start();
            }
            catch (Exception)
            {
                MessageBox.Show("Document introuvable");
            }
        }
Example #2
0
        private void BoutonSupprimer_Click(object sender, RoutedEventArgs e)
        {
            Norme tmp = NormeSelectionnee;

            if (NormeSelectionnee != null)
            {
                int IDSelected = NormeSelectionnee.Id;
                if (MessageBox.Show("Êtes-vous sûr de vouloir supprimer la norme " + NormeSelectionnee.Nom_Norme + " ?", "Supprimer", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                {
                    if (MessageBox.Show("Voulez - vous supprimer tous les documents associés à " + NormeSelectionnee.Nom_Norme + " ? ", "Suppression des documents", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                    {
                        using (ApplicationDatabase context = new ApplicationDatabase())
                        {
                            // supprime son document
                            var sonDoc = context.Database.SqlQuery <string>("SELECT DocumentPath FROM Normes WHERE Id = " + IDSelected).FirstOrDefault();
                            if (sonDoc != null)
                            {
                                File.Delete(sonDoc);
                            }

                            // supprime documents des exigences enfants
                            var ListeEnfant = context.Database.SqlQuery <string>("SELECT DocumentPath FROM Exigences WHERE ForeignKey_TO_Norme = " + IDSelected).ToList();
                            foreach (string item in ListeEnfant)
                            {
                                if (item != null)
                                {
                                    File.Delete(item);
                                }
                            }
                        }
                    }


                    mw.database.NormeDatabase.Remove(NormeSelectionnee);
                    mw.database.SaveChanges();


                    using (ApplicationDatabase context = new ApplicationDatabase())
                    {
                        var ListeEnfant = context.Database.SqlQuery <string>("SELECT Name FROM Exigences WHERE ForeignKey_TO_Norme = " + IDSelected).ToList();
                        foreach (string item in ListeEnfant)
                        {
                            // supprime la table à son nom
                            var x = context.Database.ExecuteSqlCommand("DROP TABLE " + dashb.SimpleQuoteFormater(dashb.FormaterToSQLRequest("_" + IDSelected + item)));

                            // supprime de Exigences
                            var zz = context.Database.ExecuteSqlCommand("DELETE FROM Exigences WHERE Name = '" + dashb.SimpleQuoteFormater(item) + "'");
                        }
                    }

                    dashb.ROOT_Normes.NormeObervCollec.Clear();
                    dashb.AfficherLesTreeView();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Selectionnez une norme à supprimer", "error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
Example #3
0
 public List <string> ChargerDocuments()
 {
     using (ApplicationDatabase context = new ApplicationDatabase())
     {
         var SelectAllDoc = context.Database.SqlQuery <string>("SELECT DocumentName FROM Exigences WHERE DocumentName IS NOT NULL UNION SELECT DocumentName FROM Normes WHERE DocumentName IS NOT NULL").ToList();
         return(SelectAllDoc);
     }
 }
Example #4
0
 public void CreateTable(string TableName)
 {
     TableName = dashb.TableFormater(dashb.SimpleQuoteFormater(dashb.FormaterToSQLRequest(TableName)));
     using (ApplicationDatabase context = new ApplicationDatabase())
     {
         var x = context.Database.ExecuteSqlCommand("CREATE TABLE " + TableName + " (ID INTEGER IDENTITY(1,1) PRIMARY KEY, ForeignKey INT, Titre VARCHAR(MAX), Description VARCHAR(MAX))");
     }
 }
Example #5
0
 public void SupprimerTable(string TableName)
 {
     TableName = dashb.TableFormater(dashb.SimpleQuoteFormater(dashb.FormaterToSQLRequest(TableName)));
     using (ApplicationDatabase context = new ApplicationDatabase())
     {
         var x = context.Database.ExecuteSqlCommand("DROP TABLE " + TableName);
     }
 }
Example #6
0
        public void RemplirTable(string TableName, int ForeignKey)
        {
            TableName = dashb.TableFormater(dashb.SimpleQuoteFormater(dashb.FormaterToSQLRequest(TableName)));

            if (TableName != "_Menu")
            {
                try
                {
                    using (ApplicationDatabase context = new ApplicationDatabase())
                    {
                        var x = context.Database.ExecuteSqlCommand("INSERT INTO " + TableName + " (ForeignKey, Titre, Description) VALUES (" + "'" + ForeignKey + "'" + "," + "'" + dashb.SimpleQuoteFormater(Title.Text) + "'" + "," + "'" + dashb.SimpleQuoteFormater(Content.Text) + "'" + ")");
                        Close();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Impossible d'ajouter à la table parent", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Example #7
0
        public void SuppressionTabEntant(string CurrentItem)
        {
            List <string> ListeGenerale = new List <string>();
            List <string> ListeEnfant   = new List <string>();

            using (ApplicationDatabase context = new ApplicationDatabase())
            {
                var RequestListEnfant = context.Database.SqlQuery <string>("Select Titre from " + CurrentItem).ToList();
                ListeEnfant = RequestListEnfant;
                foreach (string item in ListeEnfant)
                {
                    string tmp = "";
                    ListeGenerale.Add(item);
                    tmp = item;
                    SuppressionTabEntant(TableFormater(FormaterToSQLRequest(tmp)));
                }
                foreach (string item2 in ListeGenerale)
                {
                    if (SuprDoc == true)
                    {
                        var docASupr = context.Database.SqlQuery <string>("SELECT DocumentPath from Exigences WHERE Name = '" + SimpleQuoteFormater(item2) + "'").FirstOrDefault();
                        if (docASupr != null)
                        {
                            File.Delete(docASupr);
                        }
                        SuprDoc = false;
                    }

                    var suppenfantTableExigence = context.Database.ExecuteSqlCommand("DELETE FROM Exigences WHERE Name = '" + SimpleQuoteFormater(item2) + "'");

                    string tmp2 = "";
                    tmp2 = item2;
                    var suppenfant = context.Database.ExecuteSqlCommand("DROP TABLE " + TableFormater(SimpleQuoteFormater(FormaterToSQLRequest(tmp2))));
                }
                RequestListEnfant.Clear();
            }
            ListeGenerale.Clear();
            ListeEnfant.Clear();
        }
Example #8
0
        private void ModifierExigence_Click(object sender, RoutedEventArgs e)
        {
            if (Vue.ExigenceSelectionnee != null && Vue.ExigenceSelectionnee.Name != "Menu")
            {
                string CurrentItem        = Vue.dash.FormaterToSQLRequest("_" + Vue.dash.NormeSelectionnee.Id + Vue.ExigenceSelectionnee.Name);
                string CurrentDescription = Vue.dash.SimpleQuoteFormater(Content.Text);
                string CurrentTitle       = Vue.dash.SimpleQuoteFormater(Title.Text);

                using (ApplicationDatabase context = new ApplicationDatabase())
                {
                    string newTableName = Vue.dash.TableFormater(Vue.dash.SimpleQuoteFormater(Vue.dash.FormaterToSQLRequest(Title.Text)));
                    try
                    {
                        //renomme la table
                        var w = context.Database.ExecuteSqlCommand("EXEC sp_rename '" + CurrentItem + "', '" + newTableName + "'");

                        //modif dans la table Exigence
                        var yy = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Description = '" + Vue.dash.SimpleQuoteFormater(Content.Text) + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'");
                        var y  = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Name = '" + Vue.dash.SimpleQuoteFormater(Title.Text) + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'");

                        try
                        {
                            //modif dans table parents
                            var ParentName = context.Database.SqlQuery <string>("SELECT Name from Exigences WHERE Id= " + Vue.ExigenceSelectionnee.ForeignKey).FirstOrDefault();
                            if (ParentName != "Menu" && ParentName != null)
                            {
                                ParentName = Vue.dash.TableFormater(Vue.dash.SimpleQuoteFormater(Vue.dash.FormaterToSQLRequest(ParentName)));

                                var zz = context.Database.ExecuteSqlCommand("UPDATE " + ParentName + " SET Description = '" + Vue.dash.SimpleQuoteFormater(Content.Text) + "' WHERE Titre = '" + Vue.ExigenceSelectionnee.Name + "'");
                                var z  = context.Database.ExecuteSqlCommand("UPDATE " + ParentName + " SET Titre = '" + Vue.dash.SimpleQuoteFormater(Title.Text) + "' WHERE Titre = '" + Vue.ExigenceSelectionnee.Name + "'");
                            }

                            //actualise l'itemSleceted et la Vue grâce INotifyProperty
                            Vue.ExigenceSelectionnee.Name        = Title.Text;
                            Vue.ExigenceSelectionnee.Description = Content.Text;
                        }
                        catch (Exception)
                        {
                            var w2  = context.Database.ExecuteSqlCommand("EXEC sp_rename '" + newTableName + "', '" + CurrentItem + "'");
                            var yy2 = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Description = '" + CurrentDescription + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'");
                            var y2  = context.Database.ExecuteSqlCommand("UPDATE Exigences" + " SET Name = '" + CurrentTitle + "' WHERE Id = " + "'" + Vue.ExigenceSelectionnee.Id + "'");
                            MessageBox.Show("Modification impossible", "error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Impossible d'actualiser la BDD", "error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    //switch (ComboBoxStatus.Text)
                    //{
                    //    case "Non Évaluée":
                    //        Vue.ExigenceSelectionnee.Status = STATUS.non_evaluee;
                    //        break;
                    //    case "Non Appliquée":
                    //        Vue.ExigenceSelectionnee.Status = STATUS.non_appliquee;
                    //        break;
                    //    case "Programmée":
                    //        Vue.ExigenceSelectionnee.Status = STATUS.programmee;
                    //        break;
                    //    case "Appliquée":
                    //        Vue.ExigenceSelectionnee.Status = STATUS.appliquee;
                    //        break;
                    //    case "Non Applicable":
                    //        Vue.ExigenceSelectionnee.Status = STATUS.non_applicable;
                    //        break;
                    //    default:
                    //        break;
                    //}

                    mw.database.SaveChanges();
                    Vue.AfficherTreeViewExigences();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Selectionner une ligne", "error", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Example #9
0
 public MainWindow()
 {
     InitializeComponent();
     database = new ApplicationDatabase();
 }
Example #10
0
        private void Btn_supr_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (dash.Vue.ExigenceSelectionnee != null && dash.Vue.ExigenceSelectionnee.Name != "Menu")
            {
                if (MessageBox.Show("Voulez-vous supprimer " + dash.Vue.ExigenceSelectionnee.Name, "Suppression de l'exigence", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                {
                    string CurrentItem = dash.TableFormater(dash.SimpleQuoteFormater(dash.FormaterToSQLRequest(dash.Vue.ExigenceSelectionnee.Name)));

                    Exigence Ntmp = dash.Vue.ExigenceSelectionnee;

                    if (MessageBox.Show("Voulez - vous supprimer tous les documents associés à " + dash.Vue.ExigenceSelectionnee.Name + " ? ", "Suppression des documents", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.Yes)
                    {
                        dash.SuprDoc = true;
                        using (ApplicationDatabase context = new ApplicationDatabase())
                        {
                            //supprime son document associé
                            var docASupr = context.Database.SqlQuery <string>("SELECT DocumentPath from Exigences WHERE Id = " + Ntmp.Id).FirstOrDefault();
                            if (docASupr != null)
                            {
                                File.Delete(docASupr);
                            }

                            //supprime des documents enfant
                            // TODO
                        }
                    }

                    // Supprime de la DbSet, à mettre en 1er
                    dash.mw.database.ExigenceDatabase.Remove(Ntmp);
                    dash.mw.database.SaveChanges();


                    using (ApplicationDatabase context = new ApplicationDatabase())
                    {
                        //Quand suppression d'un parent => supprimer la table nominative des enfants
                        dash.SuppressionTabEntant(CurrentItem);

                        //supprime de la table parent
                        var ParentName = context.Database.SqlQuery <string>("SELECT Name from Exigences WHERE Id= " + Ntmp.ForeignKey).FirstOrDefault();

                        var ListeEnfant = context.Database.SqlQuery <string>("SELECT * FROM " + Ntmp);

                        if (ParentName != "Menu" && ParentName != null)
                        {
                            ParentName = dash.TableFormater(dash.FormaterToSQLRequest(ParentName));
                            var zz = context.Database.ExecuteSqlCommand("DELETE FROM " + ParentName + " WHERE Titre = '" + dash.SimpleQuoteFormater(Ntmp.Name) + "'");
                        }

                        // supprime la table à son nom
                        var x = context.Database.ExecuteSqlCommand("DROP TABLE " + CurrentItem);
                    }

                    // remove tous ses enfants de la collection Observable
                    Ntmp.ExigenceObervCollec.Clear();

                    // remove de la liste général dans le treeview
                    dash.Vue.ROOT_Exigences.ExigenceObervCollec.Remove(Ntmp);
                }
            }
            else
            {
                MessageBox.Show("Selectionner une ligne", "error", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }