Exemplo n.º 1
0
        private void UpdateList(List <Training> newTraining)
        {
            listTrainings.Items.Clear();

            foreach (Training training in newTraining)
            {
                string name = training.Name;

                FitnessLevel           requiredFitnessLevel = training.RequiredFitnessLevel;
                FieldInfo              fi         = requiredFitnessLevel.GetType().GetField(requiredFitnessLevel.ToString());
                DescriptionAttribute[] attributes =
                    (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
                string requiredFitnessLevelString = attributes[0].Description;

                List <Exercise> exercises = training.Exercises;

                ListViewItem listItem = new ListViewItem(name);
                listItem.SubItems.Add(requiredFitnessLevelString);
                listItem.SubItems.Add(String.Join(", ", exercises.Select(exercise => exercise.Name)));

                listTrainings.Items.Add(listItem);
            }
        }
Exemplo n.º 2
0
        private void UpdateList(List <Client> newClients)
        {
            listClients.Items.Clear();

            foreach (Client client in newClients)
            {
                string   oib           = client.Oib;
                string   firstName     = client.FirstName;
                string   lastName      = client.LastName;
                DateTime dateOfBirth   = client.DateOfBirth;
                string   phoneNumber   = client.PhoneNumber;
                DateTime dateOfJoining = client.DateOfJoining;

                FitnessLevel           fitnessLevel = client.FitnessLevel;
                FieldInfo              fi           = fitnessLevel.GetType().GetField(fitnessLevel.ToString());
                DescriptionAttribute[] attributes   =
                    (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
                string fitnessLevelString = attributes[0].Description;

                string notes = client.Notes;
                List <TrainingGroup> inTrainingGroups = client.InTrainingGroups;

                ListViewItem listItem = new ListViewItem(oib);
                listItem.SubItems.Add(firstName);
                listItem.SubItems.Add(lastName);
                listItem.SubItems.Add(dateOfBirth.ToString("d", CultureInfo.CreateSpecificCulture("hr-HR")));
                listItem.SubItems.Add(phoneNumber);
                listItem.SubItems.Add(dateOfJoining.ToString("d", CultureInfo.CreateSpecificCulture("hr-HR")));
                listItem.SubItems.Add(fitnessLevelString);
                listItem.SubItems.Add(notes);
                listItem.SubItems.Add(string.Join(", ", inTrainingGroups.Select(group => group.Name)));

                listClients.Items.Add(listItem);
            }
        }
Exemplo n.º 3
0
        private void UpdateList(List <Exercise> newExercises)
        {
            listExercises.Items.Clear();

            foreach (Exercise exercise in newExercises)
            {
                string name = exercise.Name;

                FitnessLevel           requiredFitnessLevel = exercise.RequiredFitnessLevel;
                FieldInfo              fi         = requiredFitnessLevel.GetType().GetField(requiredFitnessLevel.ToString());
                DescriptionAttribute[] attributes =
                    (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
                string requiredFitnessLevelString = attributes[0].Description;

                string description = exercise.Description;

                ListViewItem listItem = new ListViewItem(name);
                listItem.SubItems.Add(requiredFitnessLevelString);
                listItem.SubItems.Add(description);

                listExercises.Items.Add(listItem);
            }
        }