//------------------------------------------
        public void FillFromTable(CODEQBase objetDeRequete)
        {
            CEasyQuery query = objetDeRequete.Query;

            if (query == null)
            {
                return;
            }
            IdObjetDeQuerySource = objetDeRequete.Id;
            HashSet <string> champsASupprimer = new HashSet <string>();

            foreach (IChampEntiteSNMP champ in Champs.ToArray())
            {
                if (champ is CChampEntiteSnmpStandard)
                {
                    champsASupprimer.Add(champ.Id);
                }
            }
            foreach (IColumnDeEasyQuery col in objetDeRequete.Columns)
            {
                CChampEntiteFromQuery champ = Champs.FirstOrDefault(c =>
                                                                    c is CChampEntiteFromQuery && ((CChampEntiteFromQuery)c).ColonneSource.Id == col.Id) as CChampEntiteFromQuery;
                if (champ == null)
                {
                    champ = new CChampEntiteFromQuery();
                    ChampsListe.Add(champ);
                }
                champ.InitFromColonneSource(col, objetDeRequete);
            }
        }
        public void BuildChampControl(Champs c)
        {
            this.InitGrid();
            int num = 0;

            foreach (ChampGenerique current in c)
            {
                // Abonnement du control au lost focus du champ
                current.Event += Event_LostFocus;
                // Data Context du champ est lié à l'objet courant de la grille.
                Binding binding = new Binding("CurrentElement");
                binding.NotifyOnSourceUpdated = true;
                binding.UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged;
                binding.Mode   = BindingMode.TwoWay;
                binding.Source = this;
                current.SetBinding(UserControl.DataContextProperty, binding);
                // Titre du champ
                Label label = new Label();
                label.Content = current.NomChamp;
                label.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                this.GridRoot.RowDefinitions.Add(new RowDefinition());
                Grid.SetColumn(label, 0);
                Grid.SetRow(label, num);
                this.GridRoot.Children.Add(label);
                // UserControl = Champ
                current.SetValue(FrameworkElement.MarginProperty, new Thickness(15.0, 5.0, 5.0, 10.0));
                current.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                Grid.SetColumn(current, 1);
                Grid.SetRow(current, num);
                this.GridRoot.Children.Add(current);
                num++;
            }
        }
 //------------------------------------------
 public bool AddChamp(IChampEntiteSNMP champ)
 {
     if (Champs.FirstOrDefault(c => c.NomChamp.ToUpper() == champ.NomChamp.ToUpper()) == null)
     {
         ChampsListe.Add(champ);
         return(true);
     }
     return(false);
 }
Example #4
0
        public void RetirerChamp(string nomChamp)
        {
            int indexChamp = Champs.FindIndex(c => c.Nom == nomChamp);

            if (indexChamp >= 0)
            {
                Champs.RemoveAt(indexChamp);
            }
        }
Example #5
0
 public Relation(Point location, Size size, Color couleurBordure, int épaisseur, DataTable table)
     : base(location, size, couleurBordure, épaisseur)
 {
     texte = table.TableName;
     for (int i = 0; i < table.Columns.Count; i++)
     {
         Champs.Add(new Champ(table.Columns[i].ColumnName, table.Columns[i].DataType, table.Columns[i].MaxLength, table.Columns[i].Unique, table.Columns[i].AutoIncrement, table.Columns[i].AllowDBNull, 0));
     }
     policeChamp = new Font("Arial", 10);
 }
Example #6
0
        public Champ GetChamp(string nomChamp)
        {
            int indexExistant;

            if ((indexExistant = Champs.FindIndex(c => c.Nom == nomChamp)) < 0)
            {
                return(null);
            }

            return(Champs[indexExistant]);
        }
Example #7
0
        /// <summary>
        /// Ajoute un champs à une table
        /// </summary>
        /// <param name="nom">Nom du champs</param>
        /// <param name="idTable">Id de la table parent</param>
        /// <param name="table">Table parent</param>
        /// <param name="type">type du champs</param>
        public void AddChampsToTable(string nom, int idTable, Table table, TypeEnum type)
        {
            var newChamps = new Champs
            {
                Name     = nom,
                TableId  = idTable,
                Table    = table,
                TypeEnum = type,
            };

            Context.Champs.Add(newChamps);
            Context.SaveChanges();
        }
Example #8
0
 public void LoadChampions()
 {
     try
     {
         string[] lines = File.ReadAllLines(ApplicationInstance.Instance.BaseDirectory + @"Champions\Champions.txt");
         foreach (string ln in lines)
         {
             string[] l = ln.Split(',');
             Champs.Add(int.Parse(l[0]), l[1]);
             RevChamps.Add(l[1].ToLower(), int.Parse(l[0]));
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #9
0
        public void AddTeam()
        {
            using (var TC = new TeamContext())
            {
                Console.Clear();
                TeamOperations teamOps = new TeamOperations();
                Team           newTeam = new Team();
                Venue          venue   = new Venue();


                Console.WriteLine("What would you like them to be called?");
                newTeam.TeamName = Console.ReadLine();
                Console.WriteLine("What sport do they play?");
                newTeam.sport = Console.ReadLine();
                Console.WriteLine("Where in Minnesota would they be located?");
                venue.City = Console.ReadLine();
                Console.WriteLine("What about a mascot?");
                newTeam.Mascot = Console.ReadLine();



                var years = new Years()
                {
                    YearsFounded  = null,
                    YearDisbanded = null
                };

                var championships = new Champs()
                {
                    ChampYear = null,
                    Title     = null
                };

                TC.Championships.Add(championships);
                TC.Years.Add(years);
                TC.Venues.Add(venue);
                TC.Teams.Add(newTeam);

                TC.SaveChanges();
            }
        }
Example #10
0
        public T GetValeurChamp <T>(string nomChamp)
        {
            T   valeurParDefault = default(T);
            int index;

            if ((index = Champs.FindIndex(c => c.Nom == nomChamp)) < 0 || Champs[index].Valeur.GetType() == DBNull.Value.GetType())
            {
                return(valeurParDefault);
            }

            try
            {
                return((T)Global.ConvertirValeur <T>(Champs[index].Valeur));
            }
            catch (InvalidCastException ex)
            {
                Outils.Journal.EcrireException("Erreur de conversion dans la table '" + NomTable + "' pour le champ '" + nomChamp + "'.", ex);
            }

            return(valeurParDefault);
        }
Example #11
0
        public void AjouterChamp(Champ champ, string nomChampSuivant)
        {
            if (champ == null || champ.Nom == null || champ.Nom.Length <= 0)
            {
                Outils.Journal.EcrireMessage("Tentative d'ajout d'un champ null dans la table '" + NomTable + "'.");
                return;
            }

            int indexExistant;

            if ((indexExistant = Champs.FindIndex(c => c.Nom == champ.Nom)) != -1)
            {
                Champs[indexExistant].Valeur = champ.Valeur;
                return;
            }

            if ((indexExistant = Champs.FindIndex(c => c.Nom == nomChampSuivant)) != -1)
            {
                Champs.Insert(indexExistant, champ);
                return;
            }

            Champs.Add(champ);
        }
Example #12
0
        /// <summary>
        /// Créer des champs pour un nouvel utilisateur
        /// </summary>
        /// <param name="listeId"></param>
        public void CreateChampsForNewUser(List <int> listeId)
        {
            foreach (var id in listeId)
            {
                if (id == listeId.ElementAt(0))
                {
                    var newChamps = new Champs
                    {
                        Name     = "Nom",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(newChamps);
                    Context.SaveChanges();

                    var mail = new Champs
                    {
                        Name     = "Mail",
                        TableId  = id,
                        TypeEnum = TypeEnum.String
                    };
                    Context.Champs.Add(mail);
                    Context.SaveChanges();

                    var date = new Champs
                    {
                        Name     = "Date de création",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(date);
                    Context.SaveChanges();
                }
                if (id == listeId.ElementAt(1))
                {
                    var newChamps = new Champs
                    {
                        Name     = "Référence client",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(newChamps);
                    Context.SaveChanges();

                    var dateenvoie = new Champs
                    {
                        Name     = "Date d'émission",
                        TableId  = id,
                        TypeEnum = TypeEnum.String
                    };
                    Context.Champs.Add(dateenvoie);
                    Context.SaveChanges();

                    var paie = new Champs
                    {
                        Name     = "Payé ?",
                        TableId  = id,
                        TypeEnum = TypeEnum.Boolean,
                    };
                    Context.Champs.Add(paie);
                    Context.SaveChanges();

                    var datepaiement = new Champs
                    {
                        Name     = "Date de paiment",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(datepaiement);
                    Context.SaveChanges();

                    var prix = new Champs
                    {
                        Name     = "Prix",
                        TableId  = id,
                        TypeEnum = TypeEnum.String
                    };
                    Context.Champs.Add(prix);
                    Context.SaveChanges();

                    var refProduct = new Champs
                    {
                        Name     = "Référence à un produit",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(refProduct);
                    Context.SaveChanges();
                }
                if (id == listeId.ElementAt(2))
                {
                    var nom = new Champs
                    {
                        Name     = "Nom",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(nom);
                    Context.SaveChanges();

                    var stock = new Champs
                    {
                        Name     = "Stock",
                        TableId  = id,
                        TypeEnum = TypeEnum.Int,
                    };
                    Context.Champs.Add(stock);
                    Context.SaveChanges();

                    var prix = new Champs
                    {
                        Name     = "Prix",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(prix);
                    Context.SaveChanges();

                    var refFacture = new Champs
                    {
                        Name     = "Référence à une facture",
                        TableId  = id,
                        TypeEnum = TypeEnum.String,
                    };
                    Context.Champs.Add(refFacture);
                    Context.SaveChanges();
                }
            }
        }