Esempio n. 1
0
        public void TrierPlatTest()
        {
            List <Plat> listPlat = new List <Plat>()
            {
                new Plat {
                    TypePlat = "Sucrerie", PlatId = 1001, NbrBouchee = 3
                },
                new Plat {
                    TypePlat = "Carnivore", PlatId = 1001, NbrBouchee = 4
                },
                new Plat {
                    TypePlat = "Végéterien", PlatId = 1001, NbrBouchee = 4
                },
                new Plat {
                    TypePlat = "Carnivore", PlatId = 1001, NbrBouchee = 4
                },
                new Plat {
                    TypePlat = "Sucrerie", PlatId = 1001, NbrBouchee = 4
                },
                new Plat {
                    TypePlat = "Végéterien", PlatId = 1001, NbrBouchee = 4
                }
            };

            Serpent kaa = new Serpent();
            Plat    p   = kaa.TrierPlat(listPlat);

            Assert.AreEqual(listPlat[0], p);
        }
Esempio n. 2
0
        private void btnNotezlePlat_Click(object sender, RoutedEventArgs e)
        {
            if (lstMenus.SelectedItem == null)
            {
                MessageBox.Show("Selectionnez un menu", "probleme de selection", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                if (lstPlats.SelectedItem == null)
                {
                    MessageBox.Show("Selectionnez un plat", "probleme de selection", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    if (txtNote.Text == "")
                    {
                        MessageBox.Show("Donnez une note", "probleme de selection", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        Plat selectedPlat = lstPlats.SelectedItem as Plat;
                        // selectedPlat.NoterUnPlat(int.Parse(txtNote.Text));
                        selectedPlat.NoterUnPlat(Convert.ToInt16(txtNote.Text));

                        txtNotesMenu.Text = (lstMenus.SelectedItem as RestaurantMetier.Menu).CalculerNote().ToString();
                        lstPlats.Items.Refresh();
                    }
                }
            }
            sliderNote.Value = 0;
        }
Esempio n. 3
0
        /**
         * Return the plat with the Id gived
         */
        public object getById(int id)
        {
            MySqlCommand cmd = dbConn.CreateCommand();

            cmd.CommandText = "select id,titre,image,description,price from plat where id =" + id;

            try
            {
                dbConn.Open();
            } catch (Exception erro) {
                Console.WriteLine(erro);
            }

            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                var ret = new Plat()
                {
                    Id          = reader.GetInt16(0),
                    Titre       = reader.GetString(1),
                    Image       = reader.GetString(2),
                    Description = reader.GetString(3),
                    Price       = reader.GetDecimal(4)
                };

                return(ret);
            }
            throw new Exception("Aucune donnée trouvé");
        }
Esempio n. 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Msgnum != 0)
            {
                hash ^= Msgnum.GetHashCode();
            }
            if (Plat != 0)
            {
                hash ^= Plat.GetHashCode();
            }
            if (Username.Length != 0)
            {
                hash ^= Username.GetHashCode();
            }
            if (Token.Length != 0)
            {
                hash ^= Token.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 5
0
        /**
         *  Return all Plat from MySql
         */
        public List <object> All()
        {
            MySqlCommand cmd = dbConn.CreateCommand();

            cmd.CommandText = "SELECT id,titre,image,description,price from plat";

            try
            {
                dbConn.Open();
            } catch (Exception erro) {
                Console.WriteLine(erro);
            }

            MySqlDataReader reader = cmd.ExecuteReader();
            var             ret    = new List <object>();

            while (reader.Read())
            {
                var plat = new Plat()
                {
                    Id          = reader.GetInt16(0),
                    Titre       = reader.GetString(1),
                    Image       = reader.GetString(2),
                    Description = reader.GetString(3),
                    Price       = reader.GetDecimal(4)
                };
                ret.Add(plat);
            }
            return(ret);
        }
Esempio n. 6
0
        /// <summary>
        /// Constructeur par défaut de la classe.
        /// </summary>
        public FenetreVote(Plat plat)
        {
            InitializeComponent();

            PlatService     = ServiceFactory.Instance.GetService <IPlatService>();
            PlatSelectionne = plat;
        }
Esempio n. 7
0
        /// <summary>
        /// Constructeur par défaut de la classe.
        /// </summary>
        public FenetreVote(Plat plat)
        {
            InitializeComponent();

            PlatService = ServiceFactory.Instance.GetService<IPlatService>();
            PlatSelectionne = plat;
        }
Esempio n. 8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Msgnum != 0)
            {
                hash ^= Msgnum.GetHashCode();
            }
            if (Uin.Length != 0)
            {
                hash ^= Uin.GetHashCode();
            }
            if (Sessionid.Length != 0)
            {
                hash ^= Sessionid.GetHashCode();
            }
            if (Plat != 0)
            {
                hash ^= Plat.GetHashCode();
            }
            if (LoginSuccess != 0)
            {
                hash ^= LoginSuccess.GetHashCode();
            }
            if (Nsid != 0)
            {
                hash ^= Nsid.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>
        /// Constructeur par défaut de la classe.
        /// </summary>
        /// <param name="plat">Un plat.</param>
        /// <param name="nbPersonnes">Le nombre de personnes.</param>
        public FenetreIngredients(Plat plat, int nbPersonnes)
        {
            CultureManager.UICultureChanged += CultureManager_UICultureChanged;

            InitializeComponent();

            PlatCourant = plat;
            NbrPersonnes = nbPersonnes;

            int nbRangees = plat.ListeIngredients.Count + 1;

            GenererRangees(nbRangees);

            Label entete = new Label();
            entete.FontSize = 18;
            entete.FontWeight = FontWeights.Bold;
            entete.Content = plat.Nom;
            grdIngredients.Children.Add(entete);

            AfficherIngredients(new List<Aliment>(PlatCourant.ListeIngredients), nbPersonnes);

            btnCalculatrice = new Button();
            btnCalculatrice.Content = Nutritia.UI.Ressources.Localisation.FenetreIngredient.Calculatrice;
            btnCalculatrice.Width = 150;
            btnCalculatrice.Height = 25;
            btnCalculatrice.FontSize = 16;
            Thickness margin = new Thickness();
            margin.Top = 10;
            btnCalculatrice.Margin = margin;
            btnCalculatrice.Style = FindResource("fontNutritia") as Style;
            btnCalculatrice.Click += new RoutedEventHandler(btnCalculatrice_Click);
            Grid.SetRow(btnCalculatrice, nbRangees);
            grdIngredients.Children.Add(btnCalculatrice);
        }
 bool IsFileForOtherPlatform(FileReference InputFile)
 {
     foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
     {
         bool bMatchesIniPlatform    = (InputFile.HasExtension(".ini") && Plat == StageTargetPlatform.IniPlatformType);          // filter ini files for the ini file platform
         bool bMatchesTargetPlatform = (Plat == StageTargetPlatform.PlatformType || Plat == UnrealTargetPlatform.Unknown);       // filter platform files for the target platform
         if (!bMatchesIniPlatform && !bMatchesTargetPlatform)
         {
             FileSystemName PlatformName = new FileSystemName(Plat.ToString());
             if (InputFile.IsUnderDirectory(ProjectRoot))
             {
                 if (InputFile.ContainsName(PlatformName, ProjectRoot))
                 {
                     return(true);
                 }
             }
             else if (InputFile.IsUnderDirectory(LocalRoot))
             {
                 if (InputFile.ContainsName(PlatformName, LocalRoot))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 public override int GetHashCode()
 {
     unchecked
     {
         return((Plat.GetHashCode() * 397) ^ Rkh.GetHashCode());
     }
 }
Esempio n. 12
0
        public static bool IsPlatInComanda(Plat p)
        {
            if (p == null || p.Id <= 0)
            {
                return(false);
            }
            try
            {
                using (ContextDB context = new ContextDB())
                {
                    using (var connexio = context.Database.GetDbConnection())
                    {
                        connexio.Open();

                        using (var consulta = connexio.CreateCommand())
                        {
                            consulta.CommandText =
                                $@"   SELECT * FROM `LINIES_COMANDA` WHERE `PLAT` = @plat_id and `ESTAT` = `EN_PREPARACIO`";
                            BD_Utils.CreateParameter(consulta, "plat_id", p.Id, DbType.Int32);

                            var reader = consulta.ExecuteReader();
                            return(reader.Read());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 13
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lesCartes = new List <Carte>();
            Carte cartePrintemps = new Carte(1, "Carte de printemps");
            Carte carteHiver     = new Carte(2, "Carte d'hiver");

            RestaurantMetier.Menu menuBio      = new RestaurantMetier.Menu(1, "Menu Bio");
            RestaurantMetier.Menu menuVIP      = new RestaurantMetier.Menu(1, "Menu VIP");
            RestaurantMetier.Menu menuGourmand = new RestaurantMetier.Menu(1, "Menu gourmand");

            Plat entree1  = new Plat(1, "Salade verte", 0, "Images/Salade.jpg");
            Plat entree2  = new Plat(2, "Escargots de bourgogne", 0, "Images/Escargot.jpg");
            Plat entree3  = new Plat(3, "Terrine de canard", 0, "Images/Terrine.jpg");
            Plat plat1    = new Plat(4, "Pièce du boucher", 0, "Images/Boucher.jpg");
            Plat plat2    = new Plat(5, "Poisson aux citrons", 0, "Images/Poisson.jpg");
            Plat plat3    = new Plat(6, "Pizza", 0, "Images/Pizza.jpg");
            Plat dessert1 = new Plat(7, "Tarte aux pommes", 0, "Images/Tarte.jpg");
            Plat dessert2 = new Plat(8, "Sorbet vanille", 0, "Images/Sorbet.jpg");
            Plat dessert3 = new Plat(9, "Gâteau chocolat", 0, "Images/Gateau.jpg");
            Plat dessert4 = new Plat(10, "Crème caramel", 0, "Images/Creme.jpg");

            menuBio.AjouterPlat(entree1); menuBio.AjouterPlat(plat2); menuBio.AjouterPlat(dessert2);

            menuVIP.AjouterPlat(entree1); menuVIP.AjouterPlat(entree2); menuVIP.AjouterPlat(plat1);
            menuVIP.AjouterPlat(dessert1); menuVIP.AjouterPlat(dessert4);

            menuGourmand.AjouterPlat(entree3); menuGourmand.AjouterPlat(plat3); menuGourmand.AjouterPlat(dessert3);

            carteHiver.AjouterMenu(menuGourmand); carteHiver.AjouterMenu(menuVIP);
            cartePrintemps.AjouterMenu(menuBio);

            lesCartes.Add(cartePrintemps); lesCartes.Add(carteHiver);

            lstCartes.ItemsSource = lesCartes;
        }
Esempio n. 14
0
        public JsonResult Edit(Plat model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return Json(new
                    {
                        Result = "ERROR",
                        Message = "Le formulaire n'est pas valide"
                    });
                }

                var plat = this.RavenSession.Load<Plat>(model.Id);

                plat.Nom = model.Nom;
                plat.Description = model.Description;
                plat.Prix = model.Prix;

                RavenSession.SaveChanges();

                return Json(new { Result = "OK" });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }
Esempio n. 15
0
        public JsonResult Create(Plat model, string menuId)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return Json(new
                    {
                        Result = "ERROR",
                        Message = "Le formulaire n'est pas valide"
                    });
                }

                var menu = this.RavenSession.Load<Menu>(Convert.ToInt32(menuId));

                menu.Plat.Add(model);
                RavenSession.SaveChanges();

                this.RavenSession.Store(model);

                // Warning message
                // if (model.Description == String.Empty)
                //{
                    //var confirmUser = String.Format("Aucune description n'est offert!");
                    //TempData["AlertMessage"] = confirmUser;
                //}

                return Json(new { Result = "OK", Record = model });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }
        public static bool DeletePlat(Plat p)
        {
            MySqlCommand cmd = conn.CreateCommand();

            cmd.CommandText = "DELETE FROM plat WHERE nom = @nom";
            cmd.Parameters.Add("@nom", MySqlDbType.VarChar).Value = p.GetNom();
            return(cmd.ExecuteNonQuery() == 1);
        }
Esempio n. 17
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            allPlats = Plat.getListPlats();
            CargaLlistes();

            btnDelPlat.IsEnabled   = false;
            grdPlatForm.Visibility = Visibility.Collapsed;
        }
Esempio n. 18
0
        private void grvPlats_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Plat p = (Plat)grvPlats.SelectedItem;

            platSelected = (p != null);

            btnDelPlat.IsEnabled = platSelected;
        }
Esempio n. 19
0
        /// <summary>
        /// retourne la liste des top plats de la semaine
        /// </summary>
        /// <returns></returns>
        public List <Plat> TopPlatSemaine()
        {
            List <Commande> commande_semaine    = Commande.commandeSurDuree(7);
            List <Plat>     platCommandeSemaine = Commande.ListPlatDansListCommande(commande_semaine);

            platCommandeSemaine = Plat.TriePlat(platCommandeSemaine);
            return(platCommandeSemaine);
        }
Esempio n. 20
0
        /// <summary>
        /// Événement lancé sur un clique du bouton "Informations".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInformations_Click(object sender, RoutedEventArgs e)
        {
            Plat platSelectionne = (Plat)dgPlats.SelectedItem;

            FenetreIngredients fenetreIngredients = new FenetreIngredients(platSelectionne, 1);

            fenetreIngredients.Show();
        }
Esempio n. 21
0
            public void Dump(List <UnrealTargetPlatform> InHostPlatforms)
            {
                CommandUtils.Log("    ShortName:    " + GameName);
                CommandUtils.Log("      FilePath          : " + FilePath);
                CommandUtils.Log("      bIsCodeBasedProject  : " + (Properties.bIsCodeBasedProject ? "YES" : "NO"));
                CommandUtils.Log("      bUsesSteam  : " + (Properties.bUsesSteam ? "YES" : "NO"));
                CommandUtils.Log("      bUsesCEF3   : " + (Properties.bUsesCEF3 ? "YES" : "NO"));
                CommandUtils.Log("      bUsesSlate  : " + (Properties.bUsesSlate ? "YES" : "NO"));
                foreach (var HostPlatform in InHostPlatforms)
                {
                    CommandUtils.Log("      For Host : " + HostPlatform.ToString());
                    if (Properties.bIsCodeBasedProject)
                    {
                        CommandUtils.Log("          Promoted  : " + (Options(HostPlatform).bIsPromotable ? "YES" : "NO"));
                        CommandUtils.Log("          SeparatePromotable  : " + (Options(HostPlatform).bSeparateGamePromotion ? "YES" : "NO"));
                        CommandUtils.Log("          Test With Shared  : " + (Options(HostPlatform).bTestWithShared ? "YES" : "NO"));
                    }
                    CommandUtils.Log("          Targets {0}:", Properties.Targets.Count);
                    foreach (var ThisTarget in Properties.Targets)
                    {
                        CommandUtils.Log("            TargetName          : " + ThisTarget.Value.TargetName);
                        CommandUtils.Log("              Type          : " + ThisTarget.Key.ToString());
                        CommandUtils.Log("              bUsesSteam  : " + (ThisTarget.Value.Rules.bUsesSteam ? "YES" : "NO"));
                        CommandUtils.Log("              bUsesCEF3   : " + (ThisTarget.Value.Rules.bUsesCEF3 ? "YES" : "NO"));
                        CommandUtils.Log("              bUsesSlate  : " + (ThisTarget.Value.Rules.bUsesSlate ? "YES" : "NO"));
                        if (Array.IndexOf(MonolithicKinds, ThisTarget.Key) >= 0)
                        {
                            var Platforms           = ThisTarget.Value.Rules.GUBP_GetPlatforms_MonolithicOnly(HostPlatform);
                            var AdditionalPlatforms = ThisTarget.Value.Rules.GUBP_GetBuildOnlyPlatforms_MonolithicOnly(HostPlatform);
                            var AllPlatforms        = Platforms.Union(AdditionalPlatforms);
                            foreach (var Plat in AllPlatforms)
                            {
                                var Configs = ThisTarget.Value.Rules.GUBP_GetConfigs_MonolithicOnly(HostPlatform, Plat);
                                foreach (var Config in Configs)
                                {
                                    CommandUtils.Log("                Config  : " + Plat.ToString() + " " + Config.ToString());
                                }
                            }
                        }
                    }
                    CommandUtils.Log("      Programs {0}:", Properties.Programs.Count);
                    foreach (var ThisTarget in Properties.Programs)
                    {
                        bool bInternalToolOnly;
                        bool SeparateNode;
                        bool CrossCompile;
                        bool Tool = ThisTarget.Rules.GUBP_AlwaysBuildWithTools(HostPlatform, false, out bInternalToolOnly, out SeparateNode, out CrossCompile);

                        CommandUtils.Log("            TargetName                    : " + ThisTarget.TargetName);
                        CommandUtils.Log("              Build With Editor           : " + (ThisTarget.Rules.GUBP_AlwaysBuildWithBaseEditor() ? "YES" : "NO"));
                        CommandUtils.Log("              Build With Tools            : " + (Tool && !bInternalToolOnly ? "YES" : "NO"));
                        CommandUtils.Log("              Build With Internal Tools   : " + (Tool && bInternalToolOnly ? "YES" : "NO"));
                        CommandUtils.Log("              Separate Node               : " + (Tool && SeparateNode ? "YES" : "NO"));
                        CommandUtils.Log("              Cross Compile               : " + (Tool && CrossCompile ? "YES" : "NO"));
                    }
                }
            }
Esempio n. 22
0
 public ActionResult <string> Insert([FromBody] Plat plat)
 {
     if (plat.Id.HasValue)
     {
         return(NotFound("Objet non valide"));
     }
     repository.Save(plat);
     return(Created($"/platapi/get/{plat.Id}", plat));
 }
Esempio n. 23
0
        public void NoterUnPlatTest()
        {
            Plat p1 = new Plat(1, "Pizza", 0, "ImagePizza");

            p1.NoterUnPlat(5);
            Assert.AreEqual(5, p1.NotePlat);
            p1.NoterUnPlat(4);
            Assert.AreEqual(9, p1.NotePlat);
        }
Esempio n. 24
0
        /// <summary>
        /// Événement lancé sur un clique du bouton "Voter".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnVoter_Click(object sender, RoutedEventArgs e)
        {
            Plat platSelectionne = (Plat)dgPlats.SelectedItem;

            FenetreVote popupVote = new FenetreVote(platSelectionne);

            popupVote.ShowDialog();

            Rafraichir();
        }
Esempio n. 25
0
        public void NoterUnPlatTest()
        {
            Plat p1 = new Plat(1, "image.png", "pizza", 10);

            p1.NoterUnPlat(5);

            int noteDuPlat = p1.NotePlat;

            Assert.AreEqual(noteDuPlat, 5);
        }
        /// <summary>
        /// Méthode permettant de générer les valeurs nutritionnelles d'un aliment dans un tooltip. (Prise de Guillaume)
        /// </summary>
        /// <param name="item">Un aliment ou un plat dépendant du contexte de l'apelle</param>
        /// <returns>Un tooltip contenant les valeurs nutritionnelles de l'aliment.</returns>
        private ToolTip GenererToolTipValeursNutritive(object item)
        {
            Plat plat = new Plat(); // Assignation temporaire ...

            if (item is Plat)
            {
                plat = (Plat)item;
            }

            else // On cast l'aliment dans la liste de notre plat vide
            {
                plat.ListeIngredients = new List <Aliment>();
                plat.ListeIngredients.Add((Aliment)item);
            }

            // Construction du Tooltip

            ToolTip    ttValeurNut = new ToolTip();
            StackPanel spValeurNut = new StackPanel();

            Label lblEntete = new Label();

            lblEntete.Content = FenetreCalculatriceNutritionnelle.ValeurNutritive;
            spValeurNut.Children.Add(lblEntete);

            ValeurNutritive = new Dictionary <string, double>();

            ValeurNutritive = ConstruireDicValeurNutritive(null, ValeurNutritive);

            double poidPlat = 0;

            foreach (var aliment in plat.ListeIngredients)
            {
                ValeurNutritive = ConstruireDicValeurNutritive(aliment, ValeurNutritive);
                poidPlat       += aliment.Quantite;
            }

            StringBuilder sbValeurNut = new StringBuilder();

            sbValeurNut.Append("1 ").Append(item is Plat ? plat.Nom : plat.ListeIngredients[0].Nom).AppendLine(" de " + poidPlat + " g").AppendLine(); // Affichage du nom du plat ou de l'aliment
            sbValeurNut.Append(ValeurNutritionnelle.Energie + " : ").Append(ValeurNutritive["Calorie"].ToString("N")).AppendLine(" cal");
            sbValeurNut.Append(ValeurNutritionnelle.Glucides + " : ").Append(ValeurNutritive["Glucides"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Fibres + " : ").Append(ValeurNutritive["Fibres"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Proteines + " : ").Append(ValeurNutritive["Proteines"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Lipides + " : ").Append(ValeurNutritive["Lipides"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Cholesterol + " : ").Append(ValeurNutritive["Cholesterol"].ToString("N")).AppendLine(" mg");
            sbValeurNut.Append(ValeurNutritionnelle.Sodium + " : ").Append(ValeurNutritive["Sodium"].ToString("N")).Append(" mg");
            Label lblValeurNut = new Label();

            lblValeurNut.Content = sbValeurNut.ToString();

            spValeurNut.Children.Add(lblValeurNut);
            ttValeurNut.Content = spValeurNut;
            return(ttValeurNut);
        }
Esempio n. 27
0
        public void CalculerNoteTest()
        {
            Menu menu1 = new Menu(1, "Menu 1");

            Plat plat1 = new Plat(1, "Plat 1", 0, "ImagesPlat1");
            Plat plat2 = new Plat(2, "Plat 2", 4, "ImagesPlat1");
            Plat plat3 = new Plat(3, "Plat 3", 7, "ImagesPlat1");

            menu1.AjouterPlat(plat1); menu1.AjouterPlat(plat2); menu1.AjouterPlat(plat3);

            Assert.AreEqual(11, menu1.CalculerNote());
        }
        private void btValiderModif_Click(object sender, EventArgs e)
        {
            Plat p = (Plat)lbPlats.SelectedItem;

            if (p == null)
            {
                MessageBox.Show("Veuillez choisir un plat svp");
                return;
            }

            Categorie categorie = (Categorie)cbCat.SelectedItem;
            string    prix      = tbPrix.Text;
            string    cal       = tbCal.Text;

            if (!string.IsNullOrEmpty(tbNom.Text))
            {
                MessageBox.Show("Vous ne pouvez pas modifier le nom d'un plat");
                return;
            }

            if (!string.IsNullOrEmpty(prix))
            {
                p.SetPrix(Convert.ToInt16(prix));
            }

            if (!string.IsNullOrEmpty(cal))
            {
                p.SetNbCalories(Convert.ToInt16(cal));
            }

            if (cbVegan.Checked)
            {
                p.SetVegan(true);
            }
            else
            {
                p.SetVegan(false);
            }

            if (cbGlutenFree.Checked)
            {
                p.SetGlutenFree(true);
            }
            else
            {
                p.SetGlutenFree(false);
            }

            p.SetCategorie(categorie);
            listePlatsModif.Add(p);
            MessageBox.Show("Les modifications sont bien prises en compte");
        }
Esempio n. 29
0
 public Distiller(string InDestBaseDir, string InDestBaseDirSymbols = null, string InSourceBaseDir = null, DateTime?InDestinationTime = null, List <UnrealTargetPlatform> InAllLegalPlatforms = null, bool AllowNoRedist = false)
 {
     DestBaseDir   = CommandUtils.CombinePaths(InDestBaseDir);
     SourceBaseDir = InSourceBaseDir;
     if (SourceBaseDir == null)
     {
         SourceBaseDir = CommandUtils.CmdEnv.LocalRoot;
     }
     SourceBaseDir = CommandUtils.CombinePaths(SourceBaseDir);
     if (InDestinationTime == null)
     {
         DestinationTime = DateTime.Now;
     }
     else
     {
         DestinationTime = InDestinationTime.Value;
     }
     DestBaseDirSymbols = InDestBaseDirSymbols;
     if (DestBaseDirSymbols != null)
     {
         DestBaseDirSymbols = CommandUtils.CombinePaths(DestBaseDirSymbols);
     }
     AllLegalPlatforms = InAllLegalPlatforms;
     if (AllLegalPlatforms == null)
     {
         AllLegalPlatforms = new List <UnrealTargetPlatform>();
         foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
         {
             AllLegalPlatforms.Add(Plat);
         }
     }
     RejectStrings = new List <string>
     {
         CommandUtils.CombinePaths("/CarefullyRedist/"),
         CommandUtils.CombinePaths("/NotForLicensees/"),
     };
     if (!AllowNoRedist)
     {
         RejectStrings.Add(CommandUtils.CombinePaths("/NoRedist/"));
     }
     foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform)))
     {
         if (!AllLegalPlatforms.Contains(Plat))
         {
             RejectStrings.Add(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"));
         }
     }
     if (!AllLegalPlatforms.Contains(UnrealTargetPlatform.Win64) && !AllLegalPlatforms.Contains(UnrealTargetPlatform.Win32))
     {
         RejectStrings.Add(CommandUtils.CombinePaths("/Windows/"));
     }
 }
Esempio n. 30
0
        public static ObservableCollection <LiniaComanda> GetLiniesComanda(Comanda c)
        {
            if (c.Id <= 0)
            {
                return(new ObservableCollection <LiniaComanda>());
            }
            try
            {
                using (ContextDB context = new ContextDB())
                {
                    using (var connexio = context.Database.GetDbConnection())
                    {
                        connexio.Open();

                        using (var consulta = connexio.CreateCommand())
                        {
                            consulta.CommandText =
                                $@"   SELECT * FROM `linies_comanda` WHERE COMANDA = @id ";
                            BD_Utils.CreateParameter(consulta, "id", c.Id, DbType.Int32);

                            var reader = consulta.ExecuteReader();
                            ObservableCollection <LiniaComanda> linies = new ObservableCollection <LiniaComanda>();
                            while (reader.Read())
                            {
                                LiniaComanda l = new LiniaComanda();
                                BD_Utils.Llegeix(reader, out l.id, "LINIA_COM_ID");
                                BD_Utils.Llegeix(reader, out l.quantitat, "QUANTITAT");
                                BD_Utils.Llegeix(reader, out l.estat, "ESTAT");

                                long platId = 0;
                                BD_Utils.Llegeix(reader, out platId, "PLAT");
                                Plat p = PlatBD.GetPlat(platId);
                                l.Plat = p;

                                l.Comanda = c;

                                linies.Add(l);
                            }

                            linies = new ObservableCollection <LiniaComanda>(linies.OrderBy(i => i));
                            connexio.Close();
                            return(linies);
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                return(new ObservableCollection <LiniaComanda>());
            }
        }
        /// <summary>
        /// Supprime la ligne de Plat/Aliment si l'utilisateur clique sur le bouton
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnControlSupprimer_Click(object sender, RoutedEventArgs e)
        {
            Button  btn        = (Button)sender;
            Plat    monPlat    = new Plat();
            Aliment monAliment = new Aliment();

            bool estPlat = Convert.ToInt32(btn.Uid) > 0;

            // On compte le nbr de plat ou aliment présent dans le plateau pour controller sa suppréssion
            int nbrItemActuel = (estPlat ?
                                 PlateauPlat.Count(P => P.IdPlat == Convert.ToInt32(btn.Uid)) :
                                 PlateauAliment.Count(A => A.IdAliment == Convert.ToInt32(btn.Uid) * -1));
            int iteration = 1;

            if (Keyboard.Modifiers == ModifierKeys.Control)
            {
                iteration = (nbrItemActuel < 10 ?
                             nbrItemActuel :
                             10);
            }

            else if (Keyboard.Modifiers == ModifierKeys.Shift)
            {
                iteration = nbrItemActuel;
            }


            // On supprime 1 / 10 / ou tous le items qui correspondent à l'objet cliqué
            if (estPlat)
            {
                // Si on vide ce plat, il faut enlever son id de la liste des plats à dérouler
                if (nbrItemActuel == iteration)
                {
                    LstIdPlatExplose.Remove(Convert.ToInt32(btn.Uid));
                }
                for (int i = 0; i < iteration; i++)
                {
                    PlateauPlat.Remove(PlateauPlat.Last(P => P.IdPlat == Convert.ToInt32(btn.Uid)));
                }
            }


            else
            {
                for (int i = 0; i < iteration; i++)
                {
                    PlateauAliment.Remove(PlateauAliment.Last(P => P.IdAliment == Convert.ToInt32(btn.Uid) * -1));
                }
            }

            DessinerPlateau();
        }
        public FenetreCalculatriceNutritionelle(Plat platEnvoye)
        {
            App.Current.MainWindow.Title = FenetreCalculatriceNutritionnelle.Titre;

            CultureManager.UICultureChanged += CultureManager_UICultureChanged;
            InitializeComponent();
            Initialiser();

            // On déssine le plateau s'il a un plat passé en paramètre (apellé ailleur que dans les menus principaux)
            PlateauPlat.Add(platEnvoye);

            ConfigurerCalculatrice();
        }
Esempio n. 33
0
        /// <summary>
        /// retourne vrai si le plat a tester en entré est contenue dans une des commandes donné par la liste de commande.
        /// </summary>
        /// <param name="contenant"></param>
        /// <param name="atester"></param>
        /// <returns></returns>
        static public bool Contient(List <Commande> contenant, Plat atester)
        {
            bool rep = false;

            for (int i = 0; i < contenant.Count; i++)
            {
                if (atester.NomR == contenant[i].NomR)
                {
                    rep = true;
                }
            }
            return(rep);
        }
        /// <summary>
        /// Constructeur qui accepte un plat pour l'envoyer dans le plateau à la construction
        /// </summary>
        /// <param name="platEnvoye"></param>
        public FenetreCalculatriceNutritionelle(Plat platEnvoye)
        {
            App.Current.MainWindow.Title = FenetreCalculatriceNutritionnelle.Titre;

            CultureManager.UICultureChanged += CultureManager_UICultureChanged;
            InitializeComponent();
            Initialiser();

            // On déssine le plateau s'il a un plat passé en paramètre (appellé ailleur que dans les menus principaux)
            PlateauPlat.Add(platEnvoye);

            ConfigurerCalculatrice();
        }
Esempio n. 35
0
        private void CreateNewPlat()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
            Plat plat = new Plat(0, _dateEffet, _dateFin, _selectedCategory, _nom, _tarif);

            try
            {
                _platBusiness.AddPlat(plat);
            }
            catch (Exception ex)
            {
                DialogService.ShowErrorWindow(ex.Message);
            }
        }
        /// <summary>
        /// Méthode d'insertion dans la base de données d'un nouvel aliment.
        /// </summary>
        private void Inserer_Plat()
        {
            Plat nouveauPlat = new Plat();

            //----------------------------------------Enregistrement des valeurs nutritionnelles----------------------------------------

            // Conversion automatisée de la première lettre du nom de l'aliment.
            if (char.IsLower(Nom_plat.Text[0]))
            {
                Nom_plat.Text = char.ToUpper(Nom_plat.Text[0]) + Nom_plat.Text.Substring(1);
            }

            nouveauPlat.Nom = Nom_plat.Text;
            nouveauPlat.Createur = App.MembreCourant.NomUtilisateur;
            nouveauPlat.TypePlat = cbo_type.SelectionBoxItem.ToString();

            if (Description.Text.Length == 0 || Description.Text == null)
            {
                nouveauPlat.Description = "Aucune description.";
            }
            else
            {
                nouveauPlat.Description = Description.Text;
            }

            nouveauPlat.ListeIngredients = listeAlimentsPlateau;

            //----------------------------------------Enregistrement du chemin de l'image----------------------------------------
            string chemin = img_plat.Source.ToString();
            int position = chemin.LastIndexOf('/');
            string image = chemin.Substring(position + 1);
            string actuel;

            int positionPack = chemin.IndexOf("pack");

            if (positionPack == -1)
            {
                chemin = chemin.Substring(8);
                actuel = Directory.GetCurrentDirectory();
                int positionDest = actuel.LastIndexOf('\\');
                actuel = actuel.Substring(0, actuel.Length - (actuel.Length - positionDest));
                positionDest = actuel.LastIndexOf('\\');
                actuel = actuel.Substring(0, actuel.Length - (actuel.Length - positionDest));
                actuel += "\\UI\\Images\\" + image;

                if (!File.Exists(actuel))
                {
                    System.IO.File.Copy(chemin, actuel);
                }

                nouveauPlat.ImageUrl = "pack://application:,,,/UI/Images/" + image;
            }
            else
            {
                nouveauPlat.ImageUrl = chemin;
            }

            //----------------------------------------Insertion en BD----------------------------------------
            ServiceFactory.Instance.GetService<IPlatService>().Insert(nouveauPlat);
            listePlats = ServiceFactory.Instance.GetService<IPlatService>().RetrieveAll();

            //----------------------------------------Remise à neuf des champs de saisie----------------------------------------
            Nom_plat.Text = "";
            cbo_type.SelectedIndex = -1;
            Description.Text = "";
            img_plat.Source = new BitmapImage(new Uri("pack://application:,,,/UI/Images/nonDisponible.png"));
            listeAlimentsPlateau = new List<Aliment>();
            composition_plat.Children.Clear();
        }
        /// <summary>
        /// Méthode permettant de générer les valeurs nutritionnelles d'un aliment dans un tooltip. (Prise de Guillaume)
        /// </summary>
        /// <param name="item">Un aliment ou un plat dépendant du contexte de l'apelle</param>
        /// <returns>Un tooltip contenant les valeurs nutritionnelles de l'aliment.</returns>
        private ToolTip GenererToolTipValeursNutritive(object item)
        {
            Plat plat = new Plat(); // Assignation temporaire ...
            if (item is Plat)
            {
                plat = (Plat)item;
            }

            else // On cast l'aliment dans la liste de notre plat vide
            {

                plat.ListeIngredients = new List<Aliment>();
                plat.ListeIngredients.Add((Aliment)item);

            }

            // Construction du Tooltip

            ToolTip ttValeurNut = new ToolTip();
            StackPanel spValeurNut = new StackPanel();

            Label lblEntete = new Label();
            lblEntete.Content = FenetreCalculatriceNutritionnelle.ValeurNutritive;
            spValeurNut.Children.Add(lblEntete);

            ValeurNutritive = new Dictionary<string, double>();

            ValeurNutritive = ConstruireDicValeurNutritive(null, ValeurNutritive);

            int poidPlat = 0;

            foreach (var aliment in plat.ListeIngredients)
            {
                ValeurNutritive = ConstruireDicValeurNutritive(aliment, ValeurNutritive);
                poidPlat += aliment.Mesure;
            }

            StringBuilder sbValeurNut = new StringBuilder();
            sbValeurNut.Append("1 ").Append(item is Plat ? plat.Nom : plat.ListeIngredients[0].Nom).AppendLine(" de " + poidPlat + " g").AppendLine(); // Affichage du nom du plat ou de l'aliment
            sbValeurNut.Append(ValeurNutritionnelle.Energie + " : ").Append(ValeurNutritive["Calorie"].ToString("N")).AppendLine(" cal");
            sbValeurNut.Append(ValeurNutritionnelle.Glucides + " : ").Append(ValeurNutritive["Glucides"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Fibres + " : ").Append(ValeurNutritive["Fibres"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Proteines + " : ").Append(ValeurNutritive["Proteines"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Lipides + " : ").Append(ValeurNutritive["Lipides"].ToString("N")).AppendLine(" g");
            sbValeurNut.Append(ValeurNutritionnelle.Cholesterol + " : ").Append(ValeurNutritive["Cholesterol"].ToString("N")).AppendLine(" mg");
            sbValeurNut.Append(ValeurNutritionnelle.Sodium + " : ").Append(ValeurNutritive["Sodium"].ToString("N")).Append(" mg");
            Label lblValeurNut = new Label();
            lblValeurNut.Content = sbValeurNut.ToString();

            spValeurNut.Children.Add(lblValeurNut);
            ttValeurNut.Content = spValeurNut;
            return ttValeurNut;
        }
        /// <summary>
        /// Supprime la ligne de Plat/Aliment si l'utilisateur clique sur le bouton
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnControlSupprimer_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;
            Plat monPlat = new Plat();
            Aliment monAliment = new Aliment();

            bool estPlat = Convert.ToInt32(btn.Uid) > 0;

            // On compte le nbr de plat ou aliment présent dans le plateau pour controller sa suppréssion
            int nbrItemActuel = (estPlat ?
                                PlateauPlat.Count(P => P.IdPlat == Convert.ToInt32(btn.Uid)) :
                                PlateauAliment.Count(A => A.IdAliment == Convert.ToInt32(btn.Uid) * -1));
            int iteration = 1;
            if (Keyboard.Modifiers == ModifierKeys.Control)
                iteration = (nbrItemActuel < 10 ?
                            nbrItemActuel :
                            10);

            else if (Keyboard.Modifiers == ModifierKeys.Shift)
                iteration = nbrItemActuel;

            // On supprime 1 / 10 / ou tous le items qui correspondent à l'objet cliqué
            if (estPlat)
            {
                // Si on vide ce plat, il faut enlever son id de la liste des plats à dérouler
                if (nbrItemActuel == iteration)
                    LstIdPlatADerouler.Remove(Convert.ToInt32(btn.Uid));
                for (int i = 0; i < iteration; i++)
                    PlateauPlat.Remove(PlateauPlat.Last(P => P.IdPlat == Convert.ToInt32(btn.Uid)));

            }

            else
                for (int i = 0; i < iteration; i++)
                    PlateauAliment.Remove(PlateauAliment.Last(P => P.IdAliment == Convert.ToInt32(btn.Uid) * -1));

            DessinerPlateau();
        }
        /// <summary>
        /// Méthode d'insertion dans la base de données d'un nouvel aliment.
        /// </summary>
        private void Modifier_Plat()
        {
            Plat modifPlat = new Plat();

            // Conversion automatisée de la première lettre du nom de l'aliment.
            if (char.IsLower(Nom_plat_modif.Text[0]))
            {
                Nom_plat_modif.Text = char.ToUpper(Nom_plat_modif.Text[0]) + Nom_plat_modif.Text.Substring(1);
            }

            modifPlat.IdPlat = idPlatModif;
            modifPlat.Nom = Nom_plat_modif.Text;
            modifPlat.TypePlat = cbo_type_modif.SelectionBoxItem.ToString();
            modifPlat.NbVotes = nbrVotes;
            modifPlat.Note = note;

            if (Description_modif.Text.Length == 0 || Description_modif.Text == null)
            {
                modifPlat.Description = "Aucune description.";
            }
            else
            {
                modifPlat.Description = Description_modif.Text;
            }

            modifPlat.ListeIngredients = listeAlimentsPlateauModification;

            //----------------------------------------Enregistrement du chemin de l'image----------------------------------------
            modifPlat.ImageUrl = Sauvegarder_Image_Plat(modifPlat, img_plat_modif);

            //----------------------------------------Modification en BD----------------------------------------
            ServiceFactory.Instance.GetService<IPlatService>().Update(modifPlat);
            listePlats = ServiceFactory.Instance.GetService<IPlatService>().RetrieveAll();

            //----------------------------------------Remise à neuf des champs de saisie----------------------------------------
            Search_plat.Text = "";
            Nom_plat_modif.Text = "";
            cbo_type_modif.SelectedIndex = -1;
            Description_modif.Text = "";
            img_plat_modif.Source = new BitmapImage(new Uri("pack://application:,,,/UI/Images/nonDisponible.png"));
            listeAlimentsPlateauModification = new List<Aliment>();
            composition_plat_modif.Children.Clear();
        }
        /// <summary>
        /// Méthode d'insertion dans la base de données d'un nouvel aliment.
        /// </summary>
        private void Inserer_Plat()
        {
            Plat nouveauPlat = new Plat();

            // Conversion automatisée de la première lettre du nom de l'aliment.
            if (char.IsLower(Nom_plat.Text[0]))
            {
                Nom_plat.Text = char.ToUpper(Nom_plat.Text[0]) + Nom_plat.Text.Substring(1);
            }

            nouveauPlat.Nom = Nom_plat.Text;
            nouveauPlat.Createur = App.MembreCourant.NomUtilisateur;
            nouveauPlat.TypePlat = cbo_type.SelectionBoxItem.ToString();

            if (Description.Text.Length == 0 || Description.Text == null)
            {
                nouveauPlat.Description = "Aucune description.";
            }
            else
            {
                nouveauPlat.Description = Description.Text;
            }

            nouveauPlat.ListeIngredients = listeAlimentsPlateau;

            //----------------------------------------Enregistrement du chemin de l'image----------------------------------------
            nouveauPlat.ImageUrl = Sauvegarder_Image_Plat(nouveauPlat, img_plat);

            //----------------------------------------Insertion en BD----------------------------------------
            ServiceFactory.Instance.GetService<IPlatService>().Insert(nouveauPlat);
            listePlats = ServiceFactory.Instance.GetService<IPlatService>().RetrieveAll();

            //----------------------------------------Remise à neuf des champs de saisie----------------------------------------
            Nom_plat.Text = "";
            cbo_type.SelectedIndex = -1;
            Description.Text = "";
            img_plat.Source = new BitmapImage(new Uri("pack://application:,,,/UI/Images/nonDisponible.png"));
            listeAlimentsPlateau = new List<Aliment>();
            composition_plat.Children.Clear();
        }
        /// <summary>
        /// Méthode qui copie dans le répertoire de l'application l'image du plat.
        /// </summary>
        /// <param name="unAliment"></param>
        /// <param name="uneImage"></param>
        /// <returns></returns>
        private string Sauvegarder_Image_Plat(Plat unPlat, Image uneImage)
        {
            string chemin = uneImage.Source.ToString();
            int position = chemin.LastIndexOf('/');
            string image = chemin.Substring(position + 1);
            string actuel;

            int positionPack = chemin.IndexOf("pack");

            if (positionPack == -1)
            {
                chemin = chemin.Substring(8);
                actuel = Directory.GetCurrentDirectory();

                actuel += cheminSauvegarde;

                bool dossierExiste = System.IO.Directory.Exists(actuel);
                if (!dossierExiste)
                    System.IO.Directory.CreateDirectory(actuel);

                actuel += image;

                if (!File.Exists(actuel))
                {
                    System.IO.File.Copy(chemin, actuel);
                }

                unPlat.ImageUrl = "pack://application:,,,/UI/Images/" + image;
            }
            else
            {
                unPlat.ImageUrl = chemin;
            }

            return unPlat.ImageUrl;
        }