コード例 #1
0
ファイル: ctrlExport.cs プロジェクト: idevelop-fr/PATIO_V3
        void InsertionLien()
        {
            ClassePHP cls = new ClassePHP();
            string    sql = "";
            int       n   = 0;

            List <Lien> ListeLien = Acces.Remplir_ListeLien_Niv0(Acces.type_PLAN, "");

            lst.Items.Add("Insertion Table Lien..." + ListeLien.Count().ToString());
            Application.DoEvents();

            Acces.Remplir_ListeElement(Acces.type_PLAN, "");
            List <Plan> listeplan = (List <Plan>)Acces.Remplir_ListeElement(Acces.type_PLAN, "");

            //Insertion des données

            foreach (Lien p in ListeLien)
            {
                //lst.Items.Add("Lien : " + p.Element1_Code + "-" + p.Element2_Code);
                Application.DoEvents();

                int    elementid0 = 0; int elementid1 = 0; int elementid2 = 0;
                string typeelement0  = DonneValeur("TYPE_ELEMENT", Acces.type_PLAN.Code, ref elementid0);
                string Element1_Type = DonneValeur("TYPE_ELEMENT", Acces.Trouver_TableValeur(p.Element1_Type).Code, ref elementid1);
                string Element2_Type = DonneValeur("TYPE_ELEMENT", Acces.Trouver_TableValeur(p.Element2_Type).Code, ref elementid2);

                sql  = "INSERT INTO lien (Element0_Type, Element0_Code, Element0_ID, Element1_Type, Element1_ID, Element1_Code,";
                sql += " Element2_Type, Element2_ID, Element2_Code, ordre, complement) VALUES (";
                sql += "'" + typeelement0 + "',";
                sql += "'" + DonneCodePlan(p.Element0_ID, listeplan) + "',";
                sql += "'" + p.Element0_ID + "',";
                sql += "'" + Element1_Type + "',";
                sql += "'" + p.Element1_ID + "',";
                sql += "'" + p.Element1_Code + "',";
                sql += "'" + Element2_Type + "',";
                sql += "'" + p.Element2_ID + "',";
                sql += "'" + p.Element2_Code + "',";
                sql += "'" + p.ordre + "',";
                sql += "'" + p.complement + "')";

                cls = new ClassePHP();
                cls.Execute(sql);
                if (cls.erreur.Length > 0)
                {
                    lst.Items.Add("Erreur : " + p.Element1_Code + "-" + p.Element2_Code);
                }
                else
                {
                    n++;
                }
            }

            lst.Items.Add(n + " lignes Table Lien...");
        }
コード例 #2
0
        public void Initialiser()
        {
            Afficher_ListeNom();
            if (ID > 0)
            {
                tv = Acces.Trouver_TableValeur(ID);

                lstNom.Text       = tv.Nom;
                lblCode.Text      = tv.Code;
                lblCodeTV.Text    = tv.Code;
                lblValeur.Text    = tv.Valeur;
                lblValeur6PO.Text = tv.Valeur6PO;
            }
        }
コード例 #3
0
        void Copier_tv()
        {
            if (DG_TV.SelectedRows.Count == 0)
            {
                return;
            }

            frmChoix      f     = new frmChoix();
            List <string> Liste = Acces.Remplir_ListeTableValeurNom();

            foreach (string l in Liste)
            {
                f.lst.Items.Add(l);
            }

            if (f.ShowDialog() == DialogResult.OK)
            {
                string nom = f.choix;
                nom = nom.ToUpper().Trim();
                if (nom.Length == 0)
                {
                    return;
                }

                table_valeur tv_src = Acces.Trouver_TableValeur(int.Parse(DG_TV.SelectedRows[0].Cells["ID"].Value.ToString()));
                if (nom == tv_src.Nom)
                {
                    MessageBox.Show("Table identique !"); return;
                }

                if (Acces.Trouver_TableValeur_Code(nom, tv_src.Code) != null)
                {
                    MessageBox.Show("Cet élément existe déjà pour la table de destination."); return;
                }

                //Création du nouvel élément
                table_valeur tv_dest = new table_valeur()
                {
                    Acces = Acces,
                };
                tv_dest.Nom       = nom;
                tv_dest.Code      = tv_src.Code;
                tv_dest.Valeur    = tv_src.Valeur;
                tv_dest.Valeur6PO = tv_src.Valeur6PO;

                tv_dest.Ajouter();
                Afficher_ListeTV();
            }
        }
コード例 #4
0
        void Ajouter_Contenu_Phase(TreeNode Nod, string recherche, string Tag)
        {
            Nod.Nodes.Clear();
            List <int> lDonnee = new List <int>();
            bool       ok;

            TreeNode Nd_Entrant = new TreeNode("Données entrantes", 4, 0);
            TreeNode Nd_Sortant = new TreeNode("Données sortantes", 5, 0);

            foreach (Process p in ListeProcessus)
            {
                if (p.Code.Contains(recherche))
                {
                    foreach (int k in p.DonneeSortante)
                    {
                        ok = true;
                        foreach (int i in lDonnee)
                        {
                            if (i == k)
                            {
                                ok = false; break;
                            }
                        }
                        if (ok)
                        {
                            Nd_Sortant.Nodes.Add(Tag + k, Acces.Trouver_TableValeur(k).Valeur); lDonnee.Add(k);
                        }
                    }

                    foreach (int k in p.DonneeEntrante)
                    {
                        ok = true;
                        foreach (int i in lDonnee)
                        {
                            if (i == k)
                            {
                                ok = false; break;
                            }
                        }
                        if (ok)
                        {
                            Nd_Entrant.Nodes.Add(Tag + k, Acces.Trouver_TableValeur(k).Valeur); lDonnee.Add(k);
                        }
                    }
                }
            }

            Nd_Entrant.Expand();
            Nd_Sortant.Expand();
            Nod.Nodes.Add(Nd_Entrant);
            Nod.Nodes.Add(Nd_Sortant);
        }
コード例 #5
0
        public void Editer_Fiche_Direction()
        {
            if (lstDirection.SelectedIndex < 0)
            {
                return;
            }

            //Extrait les informations de l'arborescence
            List <Element> Liste = new List <Element>();

            foreach (TreeNode nd in tree.Nodes)
            {
                if (nd.Checked)
                {
                    Extrait_Info(nd, ref Liste);
                }
            }

            //Création de l'application Excel
            app = new Microsoft.Office.Interop.Excel.Application();
            app.DisplayAlerts = false;

            var modele  = Chemin + "\\Modeles\\Fiche_PLAN_DIRECTION.xltx";
            var fichier = Chemin + "\\Fichiers\\" + "FD-" + ListeDirection[lstDirection.SelectedIndex].Code + "-" + string.Format("{0:yyMMddHHmmss}", DateTime.Now);

            app.Workbooks.Open(modele);

            Workbooks wk = app.Workbooks;
            Workbook  wb = app.ActiveWorkbook;
            Worksheet ws = wb.Sheets[1];
            Range     r;

            r       = ws.Cells[2, 5];
            r.Value = lstDirection.Text;
            r       = ws.Cells[3, 5];
            r.Value = string.Format("{0:dd/MM/yyyy}", DateTime.Now); //Groupe interne

            //Affichage des éléments
            int n_ligne = 7;

            //Efface la zone
            ws.Range["A8:Y10000"].Clear();

            //Traitement de la liste des éléments extraits
            foreach (Element e in Liste)
            {
                if (e.Element_Type == Acces.type_PLAN.id)
                {
                    Plan plan1 = (Plan)Acces.Trouver_Element(Acces.type_PLAN.id, e.ID);

                    n_ligne++;
                    r       = ws.Cells[n_ligne, 1];
                    r.Value = plan1.Libelle;
                    r       = ws.Cells[n_ligne, 2];
                    string pilote = "";
                    pilote  = (plan1.Pilote != null) ? "\n" + plan1.Pilote.Nom + " " + plan1.Pilote.Prenom : "";
                    r.Value = pilote;

                    r       = ws.Cells[n_ligne, 24];
                    r.Value = plan1.Code.Replace("PAR-", "");
                }

                if (e.Element_Type == Acces.type_OBJECTIF.id)
                {
                    Objectif obj = (Objectif)Acces.Trouver_Element(Acces.type_OBJECTIF.id, e.ID);

                    n_ligne++;
                    r       = ws.Cells[n_ligne, 3];
                    r.Value = obj.Libelle;

                    r       = ws.Cells[n_ligne, 24];
                    r.Value = obj.Code.Replace("OBJ-", "");
                }

                if (e.Element_Type == Acces.type_ACTION.id)
                {
                    PATIO.Classes.Action action = (PATIO.Classes.Action)Acces.Trouver_Element(Acces.type_ACTION.id, e.ID);

                    if (action.TypeAction == TypeAction.ACTION)
                    {
                        n_ligne++;
                        r       = ws.Cells[n_ligne, 4];
                        r.Value = action.Libelle;

                        r = ws.Cells[n_ligne, 5];
                        string pilote = "";
                        pilote  = Acces.Donner_Chaine_Liste(action.DirectionPilote, "DIRECTION_METIER", "", true);
                        pilote += (action.Pilote != null) ? "\n" + action.Pilote.Nom + " " + action.Pilote.Prenom : "";
                        r.Value = pilote;

                        r       = ws.Cells[n_ligne, 24];
                        r.Value = action.Code.Replace("ACT-", "");
                    }

                    if (action.TypeAction == TypeAction.OPERATION)
                    {
                        n_ligne++;
                        r       = ws.Cells[n_ligne, 6];
                        r.Value = action.Libelle;

                        r = ws.Cells[n_ligne, 7];
                        string pilote = "";
                        pilote  = Acces.Donner_Chaine_Liste(action.DirectionPilote, "DIRECTION_METIER", "", true);
                        pilote += (action.Pilote != null) ? "\n" + action.Pilote.Nom + " " + action.Pilote.Prenom : "";
                        r.Value = pilote;

                        r       = ws.Cells[n_ligne, 24];
                        r.Value = action.Code.Replace("OPE-", "");
                    }

                    r       = ws.Cells[n_ligne, 8];
                    r.Value = Acces.Donner_Chaine_Liste(action.DirectionAssocie, "DIRECTION_METIER", "", true);

                    r       = ws.Cells[n_ligne, 9];
                    r.Value = (action.ActionPhare ? "X" : "");
                    if (action.OrdreActionPhare > 0)
                    {
                        r.Value = Acces.Trouver_TableValeur(action.OrdreActionPhare).Valeur;
                    }

                    r = ws.Cells[n_ligne, 10]; //Année 2018
                    r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2018") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r.Value          = action.Mt_2018;
                    r = ws.Cells[n_ligne, 11]; //Année 2019
                    r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2019") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r.Value          = action.Mt_2019;
                    r = ws.Cells[n_ligne, 12]; //Année 2020
                    r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2020") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r.Value          = action.Mt_2020;
                    r = ws.Cells[n_ligne, 13]; //Année 2021
                    r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2021") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r.Value          = action.Mt_2021;
                    r = ws.Cells[n_ligne, 14]; //Année 2022
                    r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2022") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r.Value          = action.Mt_2022;
                    r = ws.Cells[n_ligne, 15]; //Année 2023
                    r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2023") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r.Value          = action.Mt_2023;
                    r       = ws.Cells[n_ligne, 16]; //Financement
                    r.Value = action.CoutFinancier;
                    if (action.Mt_Total != null)
                    {
                        if (action.Mt_Total.Length > 0)
                        {
                            r.Value += "\n TOTAL : " + action.Mt_Total + " k€";
                        }
                    }

                    r                = ws.Cells[n_ligne, 17]; //TDS MF
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "TS591") ? "X" : "";
                    r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_591", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r                = ws.Cells[n_ligne, 18]; //TDS Hainaut
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "TS592") ? "X" : "";
                    r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_592", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r                = ws.Cells[n_ligne, 19]; //TDS 62
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "TS62") ? "X" : "";
                    r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_62", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r                = ws.Cells[n_ligne, 20]; //TDS 80
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "TS80") ? "X" : "";
                    r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_80", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r                = ws.Cells[n_ligne, 21]; //TDS 60
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "TS60") ? "X" : "";
                    r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_60", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r                = ws.Cells[n_ligne, 22]; //TDS 02
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "TS02") ? "X" : "";
                    r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_02", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                    r                = ws.Cells[n_ligne, 23]; //REGION
                    r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "REGION") ? "X" : "";
                }
            }

            //Tri des lignes
            Range r_data = ws.Range["A8:Y" + n_ligne];

            r_data.Sort(r_data.Columns[24, Type.Missing], Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending);

            r_data.Cells.VerticalAlignment = XlVAlign.xlVAlignCenter;

            //Mise en forme
            {
                r_data.WrapText = true; //Renvoie à la ligne
                //Bordures
                Borders border = r_data.Borders;

                border.LineStyle = XlLineStyle.xlContinuous;
                border.Weight    = 2d;
                border[XlBordersIndex.xlEdgeLeft].LineStyle   = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                border[XlBordersIndex.xlEdgeTop].LineStyle    = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                border[XlBordersIndex.xlEdgeBottom].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                border[XlBordersIndex.xlEdgeRight].LineStyle  = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;

                //Alignement
                ws.Columns[2].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[5].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[7].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[8].HorizontalAlignment = XlHAlign.xlHAlignCenter;

                ws.Columns[9].HorizontalAlignment  = XlHAlign.xlHAlignCenter;
                ws.Columns[10].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[11].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[12].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[13].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[14].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[15].HorizontalAlignment = XlHAlign.xlHAlignCenter;

                ws.Columns[17].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[18].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[19].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[20].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[21].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[22].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[23].HorizontalAlignment = XlHAlign.xlHAlignCenter;

                //Colonnes masquées
                ws.Columns["X"].Hidden = true; //Colonne Code
            }

            //Sauvegarde du fichier
            wb.SaveAs(fichier + ".xlsx");
            wb.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, fichier + ".pdf");

            wb.Close(false);
            wk.Close();

            //Fermeture de l'application Excel
            app.Quit();
            app = null;

            Process.Start(fichier + ".xlsx");
        }
コード例 #6
0
ファイル: ctrlCompare.cs プロジェクト: idevelop-fr/PATIO_V3
        /// <summary>
        /// Repositionne les éléments selon la hiérarchie définie
        /// </summary>
        void Repositionner(Plan plan)
        {
            int nbObjectif = 0; int nbAction = 0; int nbOpération = 0; int nbIndicateur = 0;

            //Placement des objectifs/sous-objectifs
            listeLien = Acces.Remplir_ListeLien_Niv0(Acces.type_PLAN, plan.ID.ToString());
            listeLien.Sort();

            //On balaye la liste des éléments
            //On crée l'élément sous le parent
            foreach (var p in listeLien)
            {
                //Recherche du parent
                string   Parent    = Acces.Trouver_TableValeur(p.Element1_Type).Code + "-" + p.Element1_ID.ToString();
                TreeNode NodParent = NodG;

                if (!(Parent == NodG.Name))
                {
                    TreeNode[] NodP = NodG.Nodes.Find(Parent, true);
                    if (NodP.Length > 0)
                    {
                        NodParent = NodP[0];
                    }
                }

                string Enfant = Acces.Trouver_TableValeur(p.Element2_Type).Code + "-" + p.Element2_ID.ToString();
                if (!(Enfant is null))
                {
                    Boolean Ajoute = true;
                    //Création de l'élément enfant
                    TreeNode NodEnfant = new TreeNode()
                    {
                        Name = Enfant,
                        Tag  = p,
                    };

                    if (p.Element2_Type == Acces.type_OBJECTIF.ID)
                    //if (p.Element2_Type == Acces.Trouver_TableValeur_ID("TYPE_ELEMENT", p.Element1_Type.ToString()))
                    {
                        Objectif q = (Objectif)Acces.Trouver_Element(Acces.type_OBJECTIF, p.Element2_ID);
                        if (!(q is null))
                        {
                            NodEnfant.Text        = q.Libelle;
                            NodEnfant.Name        = Acces.type_OBJECTIF.Code + "-" + q.ID;
                            NodEnfant.ImageIndex  = Donner_ImageIndex(Acces.type_OBJECTIF, p.Element2_ID);
                            NodEnfant.ToolTipText = q.Code;
                            nbObjectif++;
                        }
                        else
                        {
                            Console.Ajouter("[Objectif non trouvé] ID:" + p.Element2_ID + " Code :" + p.Element2_Code);
                        }
                    }

                    if (p.Element2_Type == Acces.type_ACTION.ID)
                    {
                        PATIO.CAPA.Classes.Action q = (PATIO.CAPA.Classes.Action)Acces.Trouver_Element(Acces.type_ACTION, p.Element2_ID);
                        if (!(q is null))
                        {
                            NodEnfant.Text       = q.Libelle;
                            NodEnfant.Name       = Acces.type_ACTION.Code + "-" + q.ID;
                            NodEnfant.ImageIndex = Donner_ImageIndex(Acces.type_ACTION, p.Element2_ID);
                            if (q.ActionPhare)
                            {
                                NodEnfant.ImageIndex = imgs[PosImageActionPhare].Id;
                            }
                            NodEnfant.ToolTipText = q.Code + " [" + p.ordre + "]";
                            if (q.TypeAction == TypeAction.ACTION)
                            {
                                nbAction++;
                            }
                            if (q.TypeAction == TypeAction.OPERATION)
                            {
                                nbOpération++;
                            }
                        }
                        else
                        {
                            Console.Ajouter("[Action non trouvée] ID:" + p.Element2_ID + " CODE:" + p.Element2_Code);
                        }
                    }

                    if (p.Element2_Type == Acces.type_INDICATEUR.ID)
                    {
                        Indicateur q = (Indicateur)Acces.Trouver_Element(Acces.type_INDICATEUR, p.Element2_ID);
                        if (!(q is null))
                        {
                            NodEnfant.Text        = q.Libelle;
                            NodEnfant.Name        = Acces.type_INDICATEUR.Code + "-" + q.ID;
                            NodEnfant.ImageIndex  = Donner_ImageIndex(Acces.type_INDICATEUR, p.Element2_ID);
                            NodEnfant.ToolTipText = q.Code;
                            nbIndicateur++;
                        }
                        else
                        {
                            Console.Ajouter("[Indicateur non trouvée] ID:" + p.Element2_ID + " CODE:" + p.Element2_Code);
                        }
                    }
コード例 #7
0
        /// <summary>
        /// Edition de la fiche pour un plan
        /// </summary>
        public string Editer_Fiche_Plan()
        {
            //Création de l'application Excel
            app = new Microsoft.Office.Interop.Excel.Application();
            app.DisplayAlerts = false;

            Plan plan = (Plan)Acces.Trouver_Element(Acces.type_PLAN, id_element);

            var modele  = Chemin + "\\Modeles\\Fiche_PLAN.xltx";
            var fichier = Chemin + "\\Fichiers\\" + "FP-" + plan.Code + "-" + string.Format("{0:yyMMddHHmmss}", DateTime.Now);

            app.Workbooks.Open(modele);

            Workbooks wk = app.Workbooks;
            Workbook  wb = app.ActiveWorkbook;
            Worksheet ws = wb.Sheets[1];
            Range     r;

            r       = ws.Cells[2, 4];
            r.Value = plan.Libelle;
            r       = ws.Cells[3, 4];
            if (plan.Pilote != null)
            {
                r.Value = plan.Pilote.Nom + " " + plan.Pilote.Prenom;
            }
            r       = ws.Cells[4, 4];
            r.Value = Acces.Donner_Chaine_Liste_Utilisateur(plan.Equipe);; //Groupe interne
            r       = ws.Cells[5, 4];
            r.Value = plan.GroupeExterne;                                  //Groupe externe
            r       = ws.Cells[6, 4];
            r.Value = string.Format("{0:dd/MM/yyyy}", DateTime.Now);       //Groupe interne
            r       = ws.Cells[6, 14];
            r.Value = plan.Code;

            //Affichage des éléments
            int n_ligne = 10;

            //Efface la zone
            ws.Range["A11:Z10000"].Clear();

            List <Lien> listeLien = Acces.Remplir_ListeLien_Niv0(Acces.type_PLAN, plan.ID.ToString());

            listeLien.Sort();

            //Passe 1 : les objectifs
            foreach (Lien l in listeLien)
            {
                if (l.Element2_Type != Acces.type_OBJECTIF.ID)
                {
                    goto Suite1;
                }

                Objectif obj = (Objectif)Acces.Trouver_Element(Acces.type_OBJECTIF, l.Element2_ID);

                n_ligne++;
                r       = ws.Cells[n_ligne, 1];
                r.Value = obj._op;
                r       = ws.Cells[n_ligne, 2];
                r.Value = obj.Libelle;

                r       = ws.Cells[n_ligne, 22];
                r.Value = obj.Code.Replace("OBJ-", "");
                Suite1 :;
            }

            //Passe 2 : les actions
            foreach (Lien l in listeLien)
            {
                if (l.Element2_Type != Acces.type_ACTION.ID)
                {
                    goto Suite2;
                }

                PATIO.CAPA.Classes.Action action = (PATIO.CAPA.Classes.Action)Acces.Trouver_Element(Acces.type_ACTION, l.Element2_ID);

                if (action.TypeAction != TypeAction.ACTION)
                {
                    goto Suite2;
                }
                n_ligne++;
                r       = ws.Cells[n_ligne, 3];
                r.Value = action.Libelle;

                r = ws.Cells[n_ligne, 4];
                string pilote = "";
                pilote  = Acces.Donner_Chaine_Liste(action.DirectionPilote, "DIRECTION_METIER", "", true);
                pilote += (action.Pilote != null) ? "\n" + action.Pilote.Nom + " " + action.Pilote.Prenom : plan.Pilote.Nom + " " + plan.Pilote.Prenom;
                r.Value = pilote;

                r       = ws.Cells[n_ligne, 7];
                r.Value = (action.ActionPhare ? "X" : "");
                if (action.OrdreActionPhare > 0)
                {
                    r.Value = Acces.Trouver_TableValeur(action.OrdreActionPhare).Valeur;
                }

                r = ws.Cells[n_ligne, 8]; //Année 2018
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2018", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2018;
                r = ws.Cells[n_ligne, 9]; //Année 2019
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2019", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2019;
                r = ws.Cells[n_ligne, 10]; //Année 2020
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2020", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2020;
                r = ws.Cells[n_ligne, 11]; //Année 2021
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2021", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2021;
                r = ws.Cells[n_ligne, 12]; //Année 2022
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2022", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2022;
                r = ws.Cells[n_ligne, 13]; //Année 2023
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2023", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2023;
                r       = ws.Cells[n_ligne, 14]; //Financement
                r.Value = action.CoutFinancier;
                if (action.Mt_Total != null)
                {
                    if (action.Mt_Total.Length > 0)
                    {
                        r.Value += "\n TOTAL : " + action.Mt_Total + " k€";
                    }
                }

                r                = ws.Cells[n_ligne, 15]; //TDS MF
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS591") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_591", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 16]; //TDS Hainaut
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS592") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_592", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 17]; //TDS 62
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS62") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_62", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 18]; //TDS 80
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS80") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_80", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 19]; //TDS 60
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS60") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_60", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 20]; //TDS 02
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS02") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_02", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 21]; //REGION
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "REGION", "") ? "X" : "";

                r       = ws.Cells[n_ligne, 22];
                r.Value = action.Code.Replace("ACT-", "");
                Suite2 :;
            }

            //Passe 3 : les opérations
            foreach (Lien l in listeLien)
            {
                if (l.Element2_Type != Acces.type_ACTION.ID)
                {
                    goto Suite3;
                }

                PATIO.CAPA.Classes.Action action = (PATIO.CAPA.Classes.Action)Acces.Trouver_Element(Acces.type_ACTION, l.Element2_ID);

                if (action.TypeAction != TypeAction.OPERATION)
                {
                    goto Suite3;
                }
                n_ligne++;
                r       = ws.Cells[n_ligne, 5];
                r.Value = action.Libelle;

                r = ws.Cells[n_ligne, 6];
                string pilote = "";
                pilote  = Acces.Donner_Chaine_Liste(action.DirectionPilote, "DIRECTION_METIER", "", true);
                pilote += (action.Pilote != null) ? "\n" + action.Pilote.Nom + " " + action.Pilote.Prenom : plan.Pilote.Nom + " " + plan.Pilote.Prenom;
                r.Value = pilote;

                r       = ws.Cells[n_ligne, 7];
                r.Value = (action.ActionPhare ? "X" : "");
                if (action.OrdreActionPhare > 0)
                {
                    r.Value = Acces.Trouver_TableValeur(action.OrdreActionPhare).Valeur;
                }

                r = ws.Cells[n_ligne, 8]; //Année 2018
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2018", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2018;
                r = ws.Cells[n_ligne, 9]; //Année 2019
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2019", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2019;
                r = ws.Cells[n_ligne, 10]; //Année 2020
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2020", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2020;
                r = ws.Cells[n_ligne, 11]; //Année 2021
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2021", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2021;
                r = ws.Cells[n_ligne, 12]; //Année 2022
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2022", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2022;
                r = ws.Cells[n_ligne, 13]; //Année 2023
                r.Interior.Color = Acces.Exister_Valeur(action.AnneeMiseOeuvre, "ANNEE_MO", "2023", "") ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r.Value          = action.Mt_2023;
                r       = ws.Cells[n_ligne, 14]; //Financement
                r.Value = action.CoutFinancier;
                if (action.Mt_Total != null)
                {
                    if (action.Mt_Total.Length > 0)
                    {
                        r.Value += "\n TOTAL : " + action.Mt_Total + " k€";
                    }
                }

                r                = ws.Cells[n_ligne, 15]; //TDS MF
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS591") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_591", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 16]; //TDS Hainaut
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS592") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_592", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 17]; //TDS 62
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS62") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_62", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 18]; //TDS 80
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS80") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_80", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 19]; //TDS 60
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS60") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_60", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 20]; //TDS 02
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "", "TS02") ? "X" : "";
                r.Interior.Color = Acces.Exister_Valeur(action.Priorite_CTS, "PRIO_CTS_02", "", "", true) ? XlRgbColor.rgbLightBlue : XlRgbColor.rgbWhite;
                r                = ws.Cells[n_ligne, 21]; //REGION
                r.Value          = Acces.Exister_Valeur(action.TSante, "TSANTE", "REGION", "") ? "X" : "";

                //Définition de l'ordre : différent d'action car la structure diffère avec les directions métier
                r = ws.Cells[n_ligne, 22];
                PATIO.CAPA.Classes.Action parent = (PATIO.CAPA.Classes.Action)Acces.Trouver_Element(Acces.type_ACTION, l.Element1_ID);
                string ordre = parent.Code.Replace("ACT-", "") + "-" + string.Format("{0:x3}", l.ordre);
                r.Value = ordre;
                //r.Value = action.Code.Replace("OPE-", "");
                Suite3 :;
            }

            //Tri des lignes
            Range r_data = ws.Range["A11:W" + n_ligne];

            r_data.Sort(r_data.Columns[22, Type.Missing], Microsoft.Office.Interop.Excel.XlSortOrder.xlAscending);

            r_data.Cells.VerticalAlignment = XlVAlign.xlVAlignCenter;

            //Mise en forme
            {
                r_data.WrapText = true; //Renvoie à la ligne
                //Bordures
                Borders border = r_data.Borders;

                border.LineStyle = XlLineStyle.xlContinuous;
                border.Weight    = 2d;
                border[XlBordersIndex.xlEdgeLeft].LineStyle   = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                border[XlBordersIndex.xlEdgeTop].LineStyle    = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                border[XlBordersIndex.xlEdgeBottom].LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
                border[XlBordersIndex.xlEdgeRight].LineStyle  = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;

                //Alignement
                ws.Columns[1].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[4].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[6].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[7].HorizontalAlignment = XlHAlign.xlHAlignCenter;

                ws.Columns[8].HorizontalAlignment  = XlHAlign.xlHAlignCenter;
                ws.Columns[9].HorizontalAlignment  = XlHAlign.xlHAlignCenter;
                ws.Columns[10].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[11].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[12].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[13].HorizontalAlignment = XlHAlign.xlHAlignCenter;

                ws.Columns[15].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[16].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[17].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[18].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[19].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[20].HorizontalAlignment = XlHAlign.xlHAlignCenter;
                ws.Columns[21].HorizontalAlignment = XlHAlign.xlHAlignCenter;

                //Colonnes masquées
                ws.Columns["A"].Hidden = true;
                ws.Columns["V"].Hidden = true;
            }

            //Sauvegarde du fichier
            wb.SaveAs(fichier + ".xlsx");
            wb.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, fichier + ".pdf");

            wb.Close(false);
            wk.Close();

            //Fermeture de l'application Excel
            app.Quit();
            app = null;

            if (OuvertureAuto)
            {
                OuvertureFichier(fichier + ".pdf");
            }

            return(fichier);
        }
コード例 #8
0
        /// <summary>
        /// Repositionne les éléments selon la hiérarchie définie
        /// </summary>
        void CreeStructure()
        {
            int nbObjectif = 0; int nbAction = 0; int nbOpération = 0; int nbIndicateur = 0;

            //Affichage de la structure actuelle du plan d'actions
            tree.Nodes.Clear();
            TreeNode NodG = new TreeNode()
            {
                Text       = "Plan d'actions de " + plan.NiveauPlan,
                Name       = Acces.type_PLAN.code + "-" + plan.ID,
                ImageIndex = 1,
                Tag        = Acces.type_PLAN.id,
            };

            NodG.Expand();
            n = 1;

            //Placement des objectifs/sous-objectifs
            List <Lien> listeLien = Acces.Remplir_ListeLien(Acces.type_PLAN, plan.ID.ToString());

            listeLien.Sort();

            //On balaye la liste des éléments
            //On crée l'élément sous le parent
            foreach (var p in listeLien)
            {
                //Recherche du parent
                string   Parent    = Acces.Trouver_TableValeur(p.element1_type).Code + "-" + p.element1_id.ToString();
                TreeNode NodParent = NodG;

                if (!(Parent == NodG.Name))
                {
                    TreeNode[] NodP = NodG.Nodes.Find(Parent, true);
                    if (NodP.Length > 0)
                    {
                        NodParent = NodP[0];
                    }
                }

                string Enfant = Acces.Trouver_TableValeur(p.element2_type).Code + "-" + p.element2_id.ToString();
                if (!(Enfant is null))
                {
                    Boolean Ajoute = true;
                    //Création de l'élément enfant
                    TreeNode NodEnfant = new TreeNode()
                    {
                        Name = Enfant,
                        Tag  = p,
                    };

                    if (p.element2_type == Acces.type_OBJECTIF.id)
                    //if (p.element2_type == Acces.Trouver_TableValeur_ID("TYPE_ELEMENT", p.element1_type.ToString()))
                    {
                        Objectif q = (Objectif)Acces.Trouver_Element(Acces.type_OBJECTIF.id, p.element2_id);
                        if (!(q is null))
                        {
                            NodEnfant.Text = q.Libelle;
                            NodEnfant.Name = Acces.type_OBJECTIF.code + "-" + q.ID;
                            //NodEnfant.ImageIndex = Donner_ImageIndex(Acces.type_OBJECTIF.id, p.element2_id);
                            NodEnfant.ToolTipText = q.Code;
                            nbObjectif++;
                        }
                        else
                        {
                            Console.Ajouter("[Objectif non trouvé] ID:" + p.element2_id + " Code :" + p.element2_code);
                        }
                    }

                    if (p.element2_type == Acces.type_ACTION.id)
                    {
                        PATIO.Classes.Action q = (PATIO.Classes.Action)Acces.Trouver_Element(Acces.type_ACTION.id, p.element2_id);
                        if (!optOpération.Checked)
                        {
                            Ajoute = (q.TypeAction == TypeAction.ACTION);
                        }
                        if (!(q is null))
                        {
                            NodEnfant.Text = q.Libelle;
                            NodEnfant.Name = Acces.type_ACTION.code + "-" + q.ID;
                            //NodEnfant.ImageIndex = Donner_ImageIndex(Acces.type_ACTION.id, p.element2_id);
                            //if (q.ActionPhare) { NodEnfant.ImageIndex = imgs[PosImageActionPhare].Id; }
                            NodEnfant.ToolTipText = q.Code + " [" + p.ordre + "]";
                            if (q.TypeAction == TypeAction.ACTION)
                            {
                                nbAction++;
                            }
                            if (q.TypeAction == TypeAction.OPERATION)
                            {
                                nbOpération++;
                            }
                        }
                        else
                        {
                            Console.Ajouter("[Action non trouvée] ID:" + p.element2_id + " CODE:" + p.element2_code);
                        }
                    }

                    if (p.element2_type == Acces.type_INDICATEUR.id)
                    {
                        Ajoute = optIndicateur.Checked;
                        Indicateur q = (Indicateur)Acces.Trouver_Element(Acces.type_INDICATEUR.id, p.element2_id);
                        if (!(q is null))
                        {
                            NodEnfant.Text = q.Libelle;
                            NodEnfant.Name = Acces.type_INDICATEUR.code + "-" + q.ID;
                            //NodEnfant.ImageIndex = Donner_ImageIndex(Acces.type_INDICATEUR.id, p.element2_id);
                            NodEnfant.ToolTipText = q.Code;
                            nbIndicateur++;
                        }
                        else
                        {
                            Console.Ajouter("[Indicateur non trouvée] ID:" + p.element2_id + " CODE:" + p.element2_code);
                        }
                    }