Exemplo n.º 1
0
        private void inscribirButton_Click(object sender, EventArgs e)
        {
            if (comboBoxActividades.SelectedIndex == -1)
            {
                DialogResult ans = MessageBox.Show(this,                                 // Owner
                                                   "Se debe seleccionar una actividad.", // Message
                                                   "Error",                              // Title
                                                   MessageBoxButtons.AbortRetryIgnore,   // Buttons included
                                                   MessageBoxIcon.Exclamation);          // Icon
                return;
            }
            else if (usuarioSeleccionado == null)
            {
                if (añadirUsrButton.Enabled)
                {
                    DialogResult ans = MessageBox.Show(this,                                                 // Owner
                                                       "Usuario no registrado, puede añadirlo si lo desea.", // Message
                                                       "Error",                                              // Title
                                                       MessageBoxButtons.AbortRetryIgnore,                   // Buttons included
                                                       MessageBoxIcon.Exclamation);                          // Icon
                    return;
                }
                else
                {
                    DialogResult ans = MessageBox.Show(this,                               // Owner
                                                       "DNI no válido.",                   // Message
                                                       "Error",                            // Title
                                                       MessageBoxButtons.AbortRetryIgnore, // Buttons included
                                                       MessageBoxIcon.Exclamation);        // Icon
                    return;
                }
            }
            Payment pago = new Payment(DateTime.Today, "First quota", precio);

            ciudad.AddPayment(pago);
            Enrollment matricula = new Enrollment(DateTime.Today, actividadSeleccionada, pago, usuarioSeleccionado);

            service.AddEnrollment(matricula);
            DialogResult answer = MessageBox.Show(this,                              // Owner
                                                  "Usuario inscrito correctamente.", // Message
                                                  "Información",                     // Title
                                                  MessageBoxButtons.OK,              // Buttons included
                                                  MessageBoxIcon.Information);       // Icon

            textBoxDNI.Text = "";
        }
Exemplo n.º 2
0
        void AddUsers()
        {
            Console.WriteLine();
            Console.WriteLine("ADDING USERS...");

            try
            {
                CityHall c = service.FindCityHallByName("Valencia");

                Gym g = c.FindGymByName("Gym1");

                Activity a = g.FindActivityByName("Yoga 101");

                // User(String address, String IBAN, String id, String name, int zipCode, DateTime birthDate, bool retired)
                User u = new User("Cansado Perpetuo's address", "ES891234121234567890", "123456789B", "Cansado Perpetuo", 46002, new DateTime(1990, 6, 5), false);
                c.AddPerson(u);
                service.AddUser(u);
                double priceForUser = a.GetPriceForUser(g, u);
                // Payment(DateTime date, string description, double quantity)
                Payment p = new Payment(DateTime.Today, "First quota", priceForUser);
                c.AddPayment(p);
                // Enrollment(DateTime enrollmentDate, Activity activity, Payment payment, User user)
                Enrollment e = new Enrollment(new DateTime(2020, 09, 16), a, p, u);
                service.AddEnrollment(e);

                u = new User("Faemino Saavedra's address", "ES891234121234567891", "123456780W", "Faemino Saavedra", 46002, new DateTime(1979, 4, 12), false);
                c.AddPerson(u);
                service.AddUser(u);
                priceForUser = a.GetPriceForUser(g, u);
                p            = new Payment(DateTime.Today, "First quota", priceForUser);
                c.AddPayment(p);
                e = new Enrollment(new DateTime(2020, 10, 08), a, p, u);
                service.AddEnrollment(e);

                u = new User("Rubén Doblas Gundersen's address", "ES891234121234567892", "123456782W", "Rubén Doblas Gundersen", 46003, new DateTime(1990, 2, 13), false);
                c.AddPerson(u);
                service.AddUser(u);
                priceForUser = a.GetPriceForUser(g, u);
                p            = new Payment(DateTime.Today, "First quota", priceForUser);
                c.AddPayment(p);
                e = new Enrollment(new DateTime(2020, 09, 28), a, p, u);
                service.AddEnrollment(e);

                u = new User("Rigoberto's address", "ES891234121234567893", "123456783M", "Rigoberto", 46122, new DateTime(1995, 2, 28), false);
                c.AddPerson(u);
                service.AddUser(u);
                priceForUser = a.GetPriceForUser(g, u);
                p            = new Payment(DateTime.Today, "First quota", priceForUser);
                c.AddPayment(p);
                e = new Enrollment(new DateTime(2020, 10, 02), a, p, u);
                service.AddEnrollment(e);

                u = new User("Lazaro's address", "ES891234121234567894", "567890123K", "Lazaro", 46122, new DateTime(1900, 1, 1), true);
                c.AddPerson(u);
                service.AddUser(u);
                priceForUser = a.GetPriceForUser(g, u);
                p            = new Payment(DateTime.Today, "First quota", priceForUser);
                c.AddPayment(p);
                e = new Enrollment(new DateTime(2017, 09, 29), a, p, u);
                service.AddEnrollment(e);

                // Checking Users enrolled
                Console.WriteLine("  Users enrolled in the activity " + a.Description + " with instructor " + a.Instructor.Name);
                foreach (Enrollment en in a.Enrollments)
                {
                    Console.WriteLine("   " + en.User.Name + " enrolled");
                }
            }
            catch (Exception e)
            {
                printError(e);
            }
        }