Esempio n. 1
0
 public MainWindow()
 {
     InitializeComponent();
     //Affichage.Content = new AffichageMenu();
     this.commandes = new List <Commande> {
     };
     this.clients   = Client.LectureFichier();
     this.commis    = Commis.LectureFichier();
     this.livreurs  = Livreur.LectureFichier();
     //VoirCommandes.Content = "Commandes\n   en cours";
 }
 private void inscription_Click(object sender, RoutedEventArgs e)
 {
     if (prenom.Text != null && prenom.Text != "Entrez ici votre prénom" && nom.Text != null && nom.Text != "Entrez ici votre nom" && adresse.Text != null && adresse.Text != "Entrez ici votre adresse")
     {
         bool success = int.TryParse(numtel.Text, out id);
         if (!success)
         {
             MessageBox.Show("Veuillez rentrer un numéro de téléphone valide");
         }
         else
         {
             if (this.clients == null || this.clients.Count <= 0)
             {
                 if (etat.Text != null && etat.Text != "Entrez ici votre état d'activité" && (etat.Text == "Sur place" || etat.Text == "En congés" || etat.Text == "En livraison"))
                 {
                     if (this.livreurs == null || this.livreurs.Count <= 0 && (etat.Text == "Sur place" || etat.Text == "En congés"))
                     {
                         Commis commis = new Commis(nom.Text, prenom.Text, adresse.Text, id, etat.Text, DateTime.Now);
                         if (VerifOccurenceListeCommis(commis) == false)
                         {
                             Commis.AjoutCommisCSV(commis);
                             main.GoBackToStartPageInscriptionCommis(commis);
                         }
                         else
                         {
                             MessageBox.Show("Ce commis existe déjà !");
                         }
                     }
                     else
                     {
                         if (vehicule.Text == "scooter" || vehicule.Text == "trotinette" || vehicule.Text == "velo")
                         {
                             Livreur livreur = new Livreur(nom.Text, prenom.Text, adresse.Text, id, etat.Text, vehicule.Text);
                             if (VerifOccurenceListeLivreur(livreur) == false)
                             {
                                 Livreur.AjoutLivreurCSV(livreur);
                                 main.GoBackToStartPageInscriptionLivreur(livreur);
                             }
                             else
                             {
                                 MessageBox.Show("Ce livreur existe déjà !");
                             }
                         }
                     }
                 }
             }
             else
             {
                 Client client = new Client(nom.Text, prenom.Text, adresse.Text, id);
                 if (VerifOccurenceListe(client) == false)
                 {
                     Client.AjoutClientCSV(client);
                     main.GoBackToStartPageInscription(client);
                 }
                 else
                 {
                     MessageBox.Show("Client déjà existant");
                 }
             }
         }
     }
 }
 private bool VerifOccurenceListeLivreur(Livreur livreur)
 {
     return(livreurs.Contains(livreur));
 }
Esempio n. 4
0
 public void GoBackToStartPageInscriptionLivreur(Livreur livreur)
 {
     Affichage.Content = null;
     this.livreurs.Add(livreur);
 }
        public PageResumeCommandes(List <Commande> commandes, MainWindow main, List <Livreur> livreurs)
        {
            InitializeComponent();
            this.com        = commandes;
            this.mainWindow = main;
            this.livreurs   = livreurs;
            if (commandes == null || commandes.Count <= 0 /*|| (commandes.Count == 1 && commandes[0] == null)*/)
            {
                TextBlock text = new TextBlock
                {
                    Text = "\n          Pas de commande active, revenez plus tard !"
                };
                Border rec = new Border()
                {
                    Height       = 50,
                    Width        = 300,
                    Background   = Brushes.LightGray,
                    BorderBrush  = Brushes.LightGray,
                    CornerRadius = new CornerRadius(20),
                };
                grid.Children.Add(text);
                grid.Children.Add(rec);
                Grid.SetRow(rec, 3);
                Grid.SetColumn(rec, 1);
                Grid.SetZIndex(rec, 0);
                Grid.SetRow(text, 3);
                Grid.SetColumn(text, 1);
                Grid.SetZIndex(text, 1);
            }
            else
            {
                List <TextBlock> tx        = new List <TextBlock> {
                };
                List <TextBlock> txCom     = new List <TextBlock> {
                };
                List <TextBlock> txEtat    = new List <TextBlock> {
                };
                List <TextBlock> txPrix    = new List <TextBlock> {
                };
                List <TextBlock> txLivreur = new List <TextBlock> {
                };
                int compteur = 1;
                foreach (Commande commande in commandes)
                {
                    Livreur tamp = new Livreur();
                    for (int i = 0; i < livreurs.Count; i++)
                    {
                        if (livreurs[i].Commandedulivreur.NumeroDeCommande == commande.NumeroDeCommande)
                        {
                            tamp = livreurs[i];
                        }
                        else
                        {
                        }
                    }
                    txCom.Add(new TextBlock()
                    {
                        Text = "Commande n°" + commande.NumeroDeCommande, FontFamily = new FontFamily("Arial"), FontSize = 20, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 5, 0, 0)
                    });
                    tx.Add(new TextBlock()
                    {
                        Text = "\n" + commande.ToString(), FontFamily = new FontFamily("Arial"), HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 20, 0, 0)
                    });
                    txEtat.Add(new TextBlock()
                    {
                        Text = commande.EtatCommande, FontFamily = new FontFamily("Arial"), FontSize = 14, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 10, 10, 0)
                    });
                    txPrix.Add(new TextBlock()
                    {
                        Text = commande.Prix.ToString() + "€", FontFamily = new FontFamily("Arial"), FontSize = 14, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 25, 10, 0)
                    });
                    txLivreur.Add(new TextBlock()
                    {
                        Text = "Livreur : " + tamp.NomFamille + " " + tamp.Prenom, FontFamily = new FontFamily("Arial"), FontSize = 14, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 30, 10, 0)
                    });
                    Border rec = new Border()
                    {
                        Height       = ((commande.Pizzas.Length + commande.Boisson.Count + 2) * 15) + 10,
                        MinHeight    = 70,
                        Width        = 300,
                        Background   = Brushes.LightGray,
                        BorderBrush  = Brushes.LightGray,
                        CornerRadius = new CornerRadius(20),
                    };
                    grid.Children.Add(txCom[compteur - 1]);
                    grid.Children.Add(tx[compteur - 1]);
                    grid.Children.Add(txEtat[compteur - 1]);
                    grid.Children.Add(txPrix[compteur - 1]);
                    grid.Children.Add(txLivreur[compteur - 1]);
                    grid.Children.Add(rec);

                    Grid.SetRow(txCom[compteur - 1], 1 + 2 * compteur);
                    Grid.SetColumn(txCom[compteur - 1], 1);
                    Grid.SetZIndex(txCom[compteur - 1], 1);

                    Grid.SetRow(rec, 1 + 2 * compteur);
                    Grid.SetColumn(rec, 1);
                    Grid.SetZIndex(rec, 0);

                    Grid.SetRow(tx[compteur - 1], 1 + 2 * compteur);
                    Grid.SetColumn(tx[compteur - 1], 1);
                    Grid.SetZIndex(tx[compteur - 1], 1);

                    Grid.SetRow(txEtat[compteur - 1], 1 + 2 * compteur);
                    Grid.SetColumn(txEtat[compteur - 1], 1);
                    Grid.SetZIndex(txEtat[compteur - 1], 1);

                    Grid.SetRow(txPrix[compteur - 1], 1 + 2 * compteur);
                    Grid.SetColumn(txPrix[compteur - 1], 1);
                    Grid.SetZIndex(txPrix[compteur - 1], 1);

                    Grid.SetRow(txLivreur[compteur - 1], 1 + 2 * compteur);
                    Grid.SetColumn(txLivreur[compteur - 1], 1);
                    Grid.SetZIndex(txLivreur[compteur - 1], 1);
                    compteur++;
                }
                int compt = 0;
                while (compt < commandes.Count)
                {
                    this.EnLivraisonChange(commandes[compt], txEtat[compt]);
                    compt++;
                }
                int compt2 = 0;
                while (compt2 < commandes.Count)
                {
                    this.ArriveChange(commandes[compt2], txEtat[compt2]);
                    compt2++;
                }
                int compt3 = 0;
                while (compt3 < commandes.Count)
                {
                    this.FermerCommande(commandes[compt3], txCom[compt3], tx[compt3], txEtat[compt3], txPrix[compt3], txLivreur[compt3], txCom, tx, txEtat, txPrix, txLivreur);
                    compt3++;
                }
            }
        }