예제 #1
0
        public void DefinirEnClePrimaire(CColonneTableParametrable col)
        {
            if (!ColonneExiste(col))
            {
                return;
            }

            if (col.PrimaryKeyPosition == null)
            {
                col.PrimaryKeyPosition = ColonnesClePrimaires.Count;
            }
        }
예제 #2
0
        public bool ColonneExiste(CColonneTableParametrable col)
        {
            foreach (CColonneTableParametrable c in Colonnes)
            {
                if (col == c)
                {
                    return(true);
                }
            }

            return(false);
        }
        private static int NombreMappageColonneDestination(CColonneTableParametrable col, List <CMappageColonneTableParametrableColonneTableParametrable> mappages)
        {
            int nb = 0;

            foreach (CMappageColonneTableParametrableColonneTableParametrable map in mappages)
            {
                if (map.ColonneB == col)
                {
                    nb++;
                }
            }
            return(nb);
        }
예제 #4
0
        public void DefinirSansClePrimaire(CColonneTableParametrable col)
        {
            if (!ColonneExiste(col))
            {
                return;
            }

            foreach (CColonneTableParametrable c in ColonnesClePrimaires)
            {
                if (c.PrimaryKeyPosition < col.PrimaryKeyPosition)
                {
                    MonterOrdreClePrimaire(c);
                }
            }

            col.PrimaryKeyPosition = null;
        }
예제 #5
0
        public void DescendreOrdreClePrimaire(CColonneTableParametrable col)
        {
            if (col.PrimaryKeyPosition == ColonnesClePrimaires.CountNoLoad - 1)
            {
                return;
            }

            foreach (CColonneTableParametrable c in ColonnesClePrimaires)
            {
                if (c.PrimaryKeyPosition == col.PrimaryKeyPosition + 1)
                {
                    c.PrimaryKeyPosition = col.PrimaryKeyPosition;
                }
            }

            col.PrimaryKeyPosition++;
        }
예제 #6
0
        //Cle Primaire
        public void MonterOrdreClePrimaire(CColonneTableParametrable col)
        {
            if (col.PrimaryKeyPosition == 0)
            {
                return;
            }

            foreach (CColonneTableParametrable c in ColonnesClePrimaires)
            {
                if (c.PrimaryKeyPosition == col.PrimaryKeyPosition - 1)
                {
                    c.PrimaryKeyPosition = col.PrimaryKeyPosition;
                }
            }

            col.PrimaryKeyPosition--;
        }
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CColonneTableParametrable col = (CColonneTableParametrable)objet;
                if (col.TypeDonneeChamp == null)
                {
                    result.EmpileErreur(I.T("Column Data Type must be defined|377"));
                }
                if (col.Position < 0)
                {
                    result.EmpileErreur(I.T("Invalid Column position|378"));
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
 private static bool ColonneDestinationMappee(CColonneTableParametrable col, List <CMappageColonneTableParametrableColonneTableParametrable> mappages)
 {
     return(NombreMappageColonneDestination(col, mappages) > 0);
 }
예제 #9
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CTypeTableParametrable tp = (CTypeTableParametrable)objet;

                if (tp.Libelle == "")
                {
                    result.EmpileErreur(I.T("Custom Table Type label cannot be empty|375"));
                }

                CListeObjetsDonnees lst = new CListeObjetsDonnees(tp.ContexteDonnee, typeof(CTypeTableParametrable));

                lst.Filtre = new CFiltreData(CTypeTableParametrable.c_champLibelle + " = @1 AND " + CTypeTableParametrable.c_champId + " <> @2", tp.Libelle, tp.Id);
                if (lst.Count != 0)
                {
                    result.EmpileErreur(I.T("The Custom Table Type '@1' already exists|376", tp.Libelle));
                }



                //Verif ordre des colonnes
                CListeObjetsDonnees lstcol = tp.Colonnes;
                bool bColChanged           = false;
                for (int i = 0; i < lstcol.Count; i++)
                {
                    bool find = false;
                    CColonneTableParametrable colIdx = (CColonneTableParametrable)lstcol[i];
                    foreach (CColonneTableParametrable c in lstcol)
                    {
                        if (c.Row.RowState != DataRowState.Unchanged)
                        {
                            bColChanged = true;
                        }
                        if (c.Libelle == colIdx.Libelle && !colIdx.Equals(c))
                        {
                            result.EmpileErreur(I.T("Column name @1 is used several times|395", colIdx.Libelle));
                        }

                        if (c.Position == i)
                        {
                            if (find)
                            {
                                result.EmpileErreur(I.T("Error : multiple position @1|367", i.ToString()));
                                i = lstcol.Count;
                                break;
                            }
                            else
                            {
                                find = true;
                            }
                        }
                        if (i > 0 && c.Position >= lstcol.Count)
                        {
                            result.EmpileErreur(I.T("The position @1 of the Column '@2' is out of range|364", c.Position.ToString(), c.Libelle));
                        }
                    }
                    if (!find)
                    {
                        result.EmpileErreur(I.T("No column defined at position @1|365", i.ToString()));
                        break;
                    }
                }

                //Verif Ordre Colonne Primaires
                int cptPKCol = 0;
                foreach (CColonneTableParametrable col in tp.ColonnesClePrimaires)
                {
                    if (col.PrimaryKeyPosition != cptPKCol)
                    {
                        result.EmpileErreur(I.T("Column @1 is part of primary key but its position in the key is @2 instead of @3|396", col.Libelle, col.PrimaryKeyPosition.Value.ToString(), cptPKCol.ToString()));
                        break;
                    }
                    cptPKCol++;
                }

                //Si les colonnes ont bougés
                if (bColChanged)
                {
                    CFiltreData         filtre     = new CFiltreData(CTypeTableParametrable.c_champId + " = @1", tp.Id);
                    CListeObjetsDonnees lstAttache = new CListeObjetsDonnees(objet.ContexteDonnee, typeof(CTableParametrable), filtre);
                    if (lstAttache.Count > 0)
                    {
                        foreach (CTableParametrable tableliee in lstAttache)
                        {
                            result.EmpileErreur(I.T("Columns changes error : The table @1 uses this type|366", tableliee.Libelle));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }