Пример #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="tableau"></param>
        public CResultAErreur SetDataTable(DataTable tableau)
        {
            CResultAErreur result = CResultAErreur.True;

            if (tableau.Rows.Count != ElementsLignes.Count)
            {
                result.EmpileErreur("Error");
                return(result);
            }

            int i;

            for (i = 0; i < tableau.Rows.Count; i++)
            {
                DataRow row = tableau.Rows[i];
                CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)ElementsLignes[i];

                foreach (DataColumn col in tableau.Columns)
                {
                    if (row[col] is CDataPlanning)
                    {
                        CDataPlanning       data   = (CDataPlanning)row[col];
                        CEOplanifiee_Acteur planif = new CEOplanifiee_Acteur(m_typeTableauPlanning.ContexteDonnee);

                        if (planif.ReadIfExists(new CFiltreData(
                                                    CEntiteOrganisationnelle.c_champId + " =@1 and " +
                                                    CEOplanifiee_Acteur.c_champDate + " =@2 and " +
                                                    CHoraireJournalier_Tranche.c_champId + " =@3",
                                                    eo.Id,
                                                    ((DateTime)col.ExtendedProperties[c_strDatePourColonne]).Date,
                                                    ((CHoraireJournalier_Tranche)col.ExtendedProperties[c_strTrancheHorairePourColonne]).Id
                                                    ), false))
                        {
                            planif.Acteur = (CActeur)data.Element;
                            if (planif.Acteur == null && planif.IsValide())
                            {
                                result = planif.Delete();
                                if (!result)
                                {
                                    return(result);
                                }
                            }
                        }
                        else
                        {
                            if (data.Element != null)
                            {
                                planif.CreateNewInCurrentContexte();
                                planif.Acteur = (CActeur)data.Element;
                                planif.EntiteOrganisationnelle = eo;
                                planif.TrancheHoraire          = (CHoraireJournalier_Tranche)col.ExtendedProperties[c_strTrancheHorairePourColonne];
                                planif.Date = ((DateTime)col.ExtendedProperties[c_strDatePourColonne]).Date;
                            }
                        }
                    }
                }
            }

            return(result);
        }
Пример #2
0
        //------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTable()
        {
            DataTable tableau = new DataTable();

            if (m_typeTableauPlanning == null)
            {
                return(new DataTable());
            }

            CListeObjetsDonnees relTranchesHoraires = m_typeTableauPlanning.RelationsTranchesHoraires;

            // Ajout de la première colonne EO
            string nomCol1 = m_typeTableauPlanning.NomPremiereColonne;

            if (nomCol1 == String.Empty)
            {
                nomCol1 = DynamicClassAttribute.GetNomConvivial(typeof(CEntiteOrganisationnelle));
            }
            DataColumn colonne0 = new DataColumn(nomCol1);

            colonne0.DataType = typeof(string);
            tableau.Columns.Add(colonne0);

            // Construction des colonnes / Date / tranche
            for (DateTime date = DateDebut; date <= DateFin; date = date.AddDays(1))
            {
                foreach (CTypeTableauPlanning_TrancheHoraire rel in relTranchesHoraires)
                {
                    if (rel.EvaluerFormuleConditionnelle(date))
                    {
                        string     nomColone = date.ToShortDateString() + "\n" + rel.Libelle;
                        DataColumn colonne   = new DataColumn(nomColone);
                        colonne.ExtendedProperties.Add(c_strDatePourColonne, date);
                        colonne.ExtendedProperties.Add(c_strTrancheHorairePourColonne, rel.TrancheHoraire);
                        if (rel.TrancheHoraire.TypeOccupationHoraireAppliquee != null)
                        {
                            colonne.ExtendedProperties.Add(c_strCouleurPourColonne, Color.FromArgb(rel.TrancheHoraire.TypeOccupationHoraireAppliquee.Couleur));
                        }
                        colonne.DataType = typeof(CDataPlanning);
                        tableau.Columns.Add(colonne);
                    }
                }
            }

            // Construction des lignes du DataTable
            int i;

            for (i = 0; i < ElementsLignes.Count; i++)
            {
                DataRow row = tableau.NewRow();
                tableau.Rows.Add(row);

                object obj = ElementsLignes[i];
                if (obj is CEntiteOrganisationnelle)
                {
                    CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)obj;
                    int j;
                    for (j = 0; j < tableau.Columns.Count; j++)
                    {
                        if (j == 0)
                        {
                            // La première colonne contient les Elements de ligne (des EO)
                            row[0] = (ElementsLignes[i]).Libelle;
                        }
                        else
                        {
                            CEOplanifiee_Acteur planif = new CEOplanifiee_Acteur(m_typeTableauPlanning.ContexteDonnee);

                            if (planif.ReadIfExists(new CFiltreData(
                                                        CEntiteOrganisationnelle.c_champId + " =@1 and " +
                                                        CEOplanifiee_Acteur.c_champDate + " =@2 and " +
                                                        CHoraireJournalier_Tranche.c_champId + " =@3",
                                                        eo.Id,
                                                        ((DateTime)(tableau.Columns[j]).ExtendedProperties[c_strDatePourColonne]).Date,
                                                        ((CHoraireJournalier_Tranche)(tableau.Columns[j]).ExtendedProperties[c_strTrancheHorairePourColonne]).Id
                                                        ), false))
                            {
                                row[(tableau.Columns[j])] = new CDataPlanning(typeof(CActeur), planif.Acteur);
                            }
                            else
                            {
                                row[(tableau.Columns[j])] = null;
                            }
                        }
                    }
                }
            }



            return(tableau);
        }