示例#1
0
        private void participate_Click(object sender, EventArgs e)
        {
            bool alreadyRegistered = manageInscription.RechercherInscription(eventClicked.id, personLogged.id);

            if (alreadyRegistered == false)
            {
                if (eventClicked.nb_participant < eventClicked.capacité_max)
                {
                    inscri newInscription = new inscri();
                    newInscription.id_evennement = eventClicked.id;
                    newInscription.id_personne   = this.personLogged.id;
                    manageInscription.Ajouterinscription(newInscription);

                    eventClicked.nb_participant++;
                    manageEvent.ModifierEvennement(eventClicked);

                    MessageBox.Show("You now participate in this event", "registration succed", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.DialogResult = DialogResult.Yes;
                }
                else
                {
                    MessageBox.Show("There is too much participant in this event", "registration failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("You already participate in this event", "registration ok", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void deleteEvent_Click(object sender, EventArgs e)
        {
            evennement ev = manageEvent.RechercherEvennement(eventClicked.id);


            var listParticipant = manageEvent.FindAllParticipants(ev);

            foreach (personne p in listParticipant)
            {
                inscri inscription = manageInscription.RechercherInscription(ev, p);
                manageInscription.SupprimerInscription(inscription);
            }

            manageEvent.SupprimerEvennement(ev);

            this.DialogResult = DialogResult.No;
        }
示例#3
0
        public evennement SupprimerInscription(inscri Inscription)
        {
            if (Inscription != null)
            {
                // Supprime le produit dans l'ORM
                model.inscris.Remove(Inscription);
                model.SaveChanges();

                int        nb = manageEvent.CountAllParticipants(Inscription.id_evennement);
                evennement ev = manageEvent.RechercherEvennement(Inscription.id_evennement);
                ev.nb_participant = nb;
                manageEvent.ModifierEvennement(ev);

                return(ev);
            }

            return(null);
        }
示例#4
0
        private void Unregistered(evennement eventclicked, personne personLogged)
        {
            string i = eventclicked.titre;
            string p = personLogged.prenom;

            var result = MessageBox.Show("Do u want to unregister to this event?", "Confirmation",
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                inscri registration = manageRegistration.RechercherInscription(eventclicked, personLogged);
                if (registration != null)
                {
                    // Validation du formulaire : modification dans la listview
                    var ev = manageRegistration.SupprimerInscription(registration);

                    lvEvennement2.RemoveEvent(eventclicked);
                    lvEvennement.UpdateEvent(ev);
                }
            }
        }
示例#5
0
        public inscri Ajouterinscription(inscri inscription)
        {
            // Ajoute la inscriptionne à l'ORM EF
            model.inscris.Add(inscription);

            // Valide les changement dans la base de données
            try
            {
                if (model.SaveChanges() > 0)
                {
                    int        nb = manageEvent.CountAllParticipants(inscription.id_evennement);
                    evennement ev = manageEvent.RechercherEvennement(inscription.id_evennement);
                    ev.nb_participant = nb;
                    manageEvent.ModifierEvennement(ev);

                    return(inscription);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }


            return(null);
        }