//------------------------------------------------------------------- public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = base.TraitementAvantSauvegarde(contexte); DataTable table = contexte.Tables[CTypeEntiteOrganisationnelle.c_nomTable]; if (table == null) { return(result); } ArrayList lst = new ArrayList(table.Rows); foreach (DataRow row in lst) { if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added) { CTypeEntiteOrganisationnelle typeTest = new CTypeEntiteOrganisationnelle(row); if (typeTest.TypeParent != null) { CTypeEntiteOrganisationnelle typeParent = typeTest.TypeParent; foreach (CTypeEntiteOrganisationnelle typeFilsDeParent in typeParent.TypesFils) { if (!typeFilsDeParent.Equals(typeTest)) { result.EmpileErreur(I.T("Impossible to assign two types of entities to the same parent|100")); } } } } } return(result); }
protected override CResultAErreur MyInitChamps() { CResultAErreur result = base.MyInitChamps(); m_arbreParents.AfficheHierarchie(TypeEntiteOrganisationnelle); if (TypeEntiteOrganisationnelle.IsNew() && TypeEntiteOrganisationnelle.TypeParent == null) { TypeEntiteOrganisationnelle.TypeParent = m_lastType; } m_lastType = TypeEntiteOrganisationnelle.TypeParent; CTypeEntiteOrganisationnelle typeFils = TypeEntiteOrganisationnelle.TypeFils; if (typeFils == null) { m_lnkEntiteFille.Text = I.T("Not (click for create)|112"); } else { m_lnkEntiteFille.Text = typeFils.Libelle; } AffecterTitre(I.T("Organizational entity type @1|114", ((CTypeEntiteOrganisationnelle)ObjetEdite).Libelle)); return(result); }
//------------------------------------------------------------------------- private void FillItemTypeEO( TreeNode node, CTypeEntiteOrganisationnelle typeEO, Hashtable tableSel) { node.Text = typeEO.Libelle; COptionCorrespondanceEO option = new COptionCorrespondanceEO(typeEO, EModeComparaisonEO.FillesUniquement); if (tableSel.Contains(typeEO)) { node.Checked = true; option = new COptionCorrespondanceEO(typeEO, (EModeComparaisonEO)tableSel[typeEO]); } node.Tag = option; RedrawNode(node); foreach (CTypeEntiteOrganisationnelle tp in typeEO.TypesFils) { TreeNode newNode = new TreeNode(); FillItemTypeEO(newNode, tp, tableSel); node.Nodes.Add(newNode); if (newNode.Checked || newNode.IsExpanded) { node.Expand(); } } }
private void m_lnkEntiteFille_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { CTypeEntiteOrganisationnelle typeFils = TypeEntiteOrganisationnelle.TypeFils; if (typeFils == null) { typeFils = new CTypeEntiteOrganisationnelle(TypeEntiteOrganisationnelle.ContexteDonnee); typeFils.CreateNew(); typeFils.TypeParent = TypeEntiteOrganisationnelle; } CTimosApp.Navigateur.AffichePage(new CFormEditionTypeEntiteOrganisationnelle(typeFils)); }
//------------------------------------------------------------------- public override CResultAErreur VerifieDonnees(CObjetDonnee objet) { CResultAErreur result = CResultAErreur.True; try { CTypeSite type_site = (CTypeSite)objet; // Verifie le champ "Libelle" if (type_site.Libelle == "") { result.EmpileErreur(I.T("Site Type label cannot be empty|368")); } // Si le parent est obligatoire, il faut définir les Parent possibles if (type_site.ParentObligatoire) { if (type_site.RelationTypesContenants.Count == 0) { result.EmpileErreur(I.T("Site Type must have one or more relation with a contained type (Can be included)|369")); } } //Verifier si le TypEntiteOrganisationnelleDeCoordonnee //a été modifié qu'il n'y a pas de site utilisant... if (type_site.Row.HasVersion(DataRowVersion.Original)) { CTypeEntiteOrganisationnelle newval = type_site.TypeEntiteOrganisationnelleDeCoordonnee; type_site.VersionToReturn = DataRowVersion.Original; CTypeEntiteOrganisationnelle oldval = type_site.TypeEntiteOrganisationnelleDeCoordonnee; if (newval != oldval) { //Dans les sites de ce types site //si il y en a un qui a EoCoor != null on bloque CFiltreData filtreSites = new CFiltreData(CTypeSite.c_champId + " = @1 AND " + CSite.c_champEOCoor + " is not null", type_site.Id); CListeObjetsDonnees lstSites = new CListeObjetsDonnees(type_site.ContexteDonnee, typeof(CSite), filtreSites); if (lstSites.CountNoLoad > 0) { result.EmpileErreur(I.T("One or more sites already use the Organisational Entity '@1' to define their coordinates : You cannot modify it|372", oldval.DescriptionElement)); } } } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
public CResultAErreur InitChamps(CTypeEntiteOrganisationnelle typeEntite) { CResultAErreur result = CResultAErreur.True; if (typeEntite != null) { Visible = true; if (!m_bComboFormInit) { CListeObjetsDonnees lste = new CListeObjetsDonnees(typeEntite.ContexteDonnee, typeof(CFormulaire)); lste.Filtre = CFormulaire.GetFiltreFormulairesForRole(CRelationElement_EO.c_roleChampCustom); //lste.Filtre = new CFiltreData(CFormulaire.c_champCodeRole + "=@1", CRelationElement_EO.c_roleChampCustom); m_comboFormulaire.Init(lste, "Libelle", false); } m_typeEntiteOrganisationnelle = typeEntite; CListeObjetsDonnees rels = typeEntite.RelationsFormulairesParType; rels.Filtre = new CFiltreData(CRelationTypeEO_FormulaireParType.c_champType + "=@1", m_typeAssocie.ToString()); if (rels.Count == 1) { CRelationTypeEO_FormulaireParType rel = (CRelationTypeEO_FormulaireParType)rels[0]; m_comboFormulaire.ElementSelectionne = rel.Formulaire; m_relationEditee = rel; } else { m_comboFormulaire.ElementSelectionne = null; m_relationEditee = null; } } else { Visible = false; m_typeEntiteOrganisationnelle = null; m_relationEditee = null; } return(result); }
//------------------------------------------------------------------- public override CResultAErreur VerifieDonnees(CObjetDonnee objet) { CResultAErreur result = CResultAErreur.True; try { CTypeEntiteOrganisationnelle typeEntiteOrganisationnelle = (CTypeEntiteOrganisationnelle)objet; if (typeEntiteOrganisationnelle.Libelle == "") { result.EmpileErreur(I.T("Organisational Entity Type label cannot be empty|305")); } //Vérifie l'unicité du TypeEntiteOrganisationnelle dans son parent if (typeEntiteOrganisationnelle.TypeParent != null) { CListeObjetsDonnees liste = new CListeObjetsDonnees(objet.ContexteDonnee, typeof(CTypeEntiteOrganisationnelle)); liste.Filtre = new CFiltreData(CTypeEntiteOrganisationnelle.c_champIdParent + "=@1 and " + CTypeEntiteOrganisationnelle.c_champLibelle + "=@2 and " + CTypeEntiteOrganisationnelle.c_champId + "<>@3", typeEntiteOrganisationnelle.TypeParent.Id, typeEntiteOrganisationnelle.Libelle, typeEntiteOrganisationnelle.Id); if (liste.CountNoLoad > 0) { result.EmpileErreur(I.T("The Organisational Entity Type '@1' already exists|304", typeEntiteOrganisationnelle.Libelle)); } } else //Vérifie l'unicité du TypeEntiteOrganisationnelle { CListeObjetsDonnees liste = new CListeObjetsDonnees(objet.ContexteDonnee, typeof(CTypeEntiteOrganisationnelle)); liste.Filtre = new CFiltreData( CTypeEntiteOrganisationnelle.c_champLibelle + "=@1 and " + CTypeEntiteOrganisationnelle.c_champId + "<>@2 and " + CTypeEntiteOrganisationnelle.c_champNiveau + "=@3", typeEntiteOrganisationnelle.Libelle, typeEntiteOrganisationnelle.Id, 0); if (liste.CountNoLoad > 0) { result.EmpileErreur(I.T("The Organisational Entity Type '@1' already exists|304", typeEntiteOrganisationnelle.Libelle)); } } //Vérifie que le parent n'a qu'un fils if (typeEntiteOrganisationnelle.TypeParent != null) { CListeObjetsDonnees listeFils = typeEntiteOrganisationnelle.TypeParent.TypesFils; foreach (CTypeEntiteOrganisationnelle tp in listeFils) { if (!tp.Equals(typeEntiteOrganisationnelle)) { result.EmpileErreur(I.T("Impossible to assign two types of entities to the same parent|100")); } } } //Si on est en modification et que ce type d'entité //dispose d'entite > Verification d'un changement de format de numérotation //if (typeEntiteOrganisationnelle.Row.HasVersion(DataRowVersion.Original) && typeEntiteOrganisationnelle.HasEntitesOrganisationnelles()) //{ // bool coorObligatoire = typeEntiteOrganisationnelle.CoordonneeObligatoire; // CFormatNumerotation frmActuel = typeEntiteOrganisationnelle.FormatNumerotation; // typeEntiteOrganisationnelle.VersionToReturn = DataRowVersion.Original; // if(coorObligatoire && !typeEntiteOrganisationnelle.CoordonneeObligatoire) // result.EmpileErreur(I.T( "Impossible de rendre les coordonnées obligatoires car des entitées sont déjà affiliées")); // if (typeEntiteOrganisationnelle.FormatNumerotation != frmActuel) // result.EmpileErreur(I.T( "Impossible de modifier le format de numérotation car des entitées sont déjà affiliées")); //} } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = base.TraitementAvantSauvegarde(contexte); if (!result) { return(result); } DataTable dt = contexte.Tables[CSite.c_nomTable]; ArrayList rows = new ArrayList(dt.Rows); foreach (DataRow row in rows) { CSite site = new CSite(row); result = SObjetAFilsACoordonneeServeur.TraitementAvantSauvegarde(site); //Verification des Eos pour la localisation par coordonnee if (row.RowState != DataRowState.Deleted && site.TypeSite != null && row.RowState == DataRowState.Modified) { CTypeEntiteOrganisationnelle typeEO = site.TypeSite.TypeEntiteOrganisationnelleDeCoordonnee; if (typeEO != null && site.EOdeCoordonnee == null) { List <CEntiteOrganisationnelle> lsteos = CUtilElementAEO.GetToutesEOs(site); List <CEntiteOrganisationnelle> lsteosRacine = new List <CEntiteOrganisationnelle>(); List <CEntiteOrganisationnelle> lsteosFilles = new List <CEntiteOrganisationnelle>(); //Recuperation des EOs du niveau Racine foreach (CEntiteOrganisationnelle eo in lsteos) { if (eo.TypeEntite == typeEO) { lsteosRacine.Add(eo); } } foreach (CEntiteOrganisationnelle eo in lsteos) { if (eo.TypeEntite != typeEO) { foreach (CEntiteOrganisationnelle eoracine in lsteosRacine) { if (eo.IsChildOf(eoracine)) { lsteosFilles.Add(eo); } } } } int totalPoss = lsteosRacine.Count + lsteosFilles.Count; if (totalPoss > 1) { result.EmpileErreur(I.T("Several organisational entities can affect this site coordinate : please select the default one|30001")); } else if (totalPoss == 1 && lsteosRacine.Count == 1) { site.EOdeCoordonnee = lsteosRacine[0]; } else if (totalPoss == 1 && lsteosFilles.Count == 1) { site.EOdeCoordonnee = lsteosFilles[0]; } } } if (!result) { return(result); } } return(result); }
//------------------------------------------------------------------------- public CFormEditionTypeEntiteOrganisationnelle(CTypeEntiteOrganisationnelle typeEO, CListeObjetsDonnees liste) : base(typeEO, liste) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); }
//------------------------------------------------------------------------- public CFormEditionTypeEntiteOrganisationnelle(CTypeEntiteOrganisationnelle groupe) : base(groupe) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); }
public void SetUptTest() { CResultAErreur result = CResultAErreur.True; CTimosTestMetierApp.AssureInit(); m_contexteDonnee = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false); //Création de l'acteur de test CActeur acteur = new CActeur(m_contexteDonnee); if (!acteur.ReadIfExists(new CFiltreData(CActeur.c_champNom + "=@1", c_strNomActeur))) { acteur.CreateNew(); acteur.Nom = c_strNomActeur; acteur.Prenom = "Youcef"; result = acteur.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdActeur = acteur.Id; // Création des Types d'occupation horraire // Repos CTypeOccupationHoraire toRepos = new CTypeOccupationHoraire(m_contexteDonnee); if (!toRepos.ReadIfExists( new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strRepos))) { toRepos.CreateNew(); toRepos.Libelle = c_strRepos; toRepos.Priorite = 10; result = toRepos.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdOccupationRepos = toRepos.Id; // Jour CTypeOccupationHoraire toJour = new CTypeOccupationHoraire(m_contexteDonnee); if (!toJour.ReadIfExists( new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strJour))) { toJour.CreateNew(); toJour.Libelle = c_strJour; toJour.Priorite = 50; result = toJour.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdOccupationJour = toJour.Id; // Astreinte CTypeOccupationHoraire toAstreinte = new CTypeOccupationHoraire(m_contexteDonnee); if (!toAstreinte.ReadIfExists( new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strAstreinte))) { toAstreinte.CreateNew(); toAstreinte.Libelle = c_strAstreinte; toAstreinte.Priorite = 100; result = toAstreinte.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdOccupationAstreinte = toAstreinte.Id; // Création de l'Horaire journalier CHoraireJournalier horaire = new CHoraireJournalier(m_contexteDonnee); if (!horaire.ReadIfExists( new CFiltreData(CHoraireJournalier.c_champLibelle + "=@1", c_strLabelHoraireJournalier))) { horaire.CreateNew(); horaire.Libelle = c_strLabelHoraireJournalier; result = horaire.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdHoraireJournalier = horaire.Id; // Création du Calendier CCalendrier calendrier = new CCalendrier(m_contexteDonnee); if (!calendrier.ReadIfExists( new CFiltreData(CCalendrier.c_champLibelle + "=@1", c_strLabelCalendrier))) { calendrier.CreateNew(); calendrier.Libelle = c_strLabelCalendrier; calendrier.Acteur = acteur; calendrier.HoraireParDefaut = horaire; result = calendrier.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdCalendrier = calendrier.Id; // CRéation de l'EO de test CTypeEntiteOrganisationnelle tpEO = new CTypeEntiteOrganisationnelle(m_contexteDonnee); if (!tpEO.ReadIfExists( new CFiltreData(CTypeEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelTypeEO))) { tpEO.CreateNew(); tpEO.Libelle = c_strLabelTypeEO; Assert.IsTrue(tpEO.CommitEdit()); } m_nIdTypeEO = tpEO.Id; CEntiteOrganisationnelle eo = new CEntiteOrganisationnelle(m_contexteDonnee); if (!eo.ReadIfExists( new CFiltreData(CEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelEO))) { eo.CreateNew(); eo.Libelle = c_strLabelEO; eo.TypeEntite = tpEO; Assert.IsTrue(eo.CommitEdit()); } m_nIdEO = eo.Id; // Affecte l'EO à l'acteur de test acteur.AjouterEO(m_nIdEO); }