示例#1
0
        public static void ShowAll()
        //where U : ScientificAssociation<Student>
        //where V : ScientificAssociation<Employee>
        {
            bool flag = false;

            WriteLine("( AssociationID, TypeOfAssociation, Title, StudyArea )");

            foreach (object ourAssotiation in Journal)
            {
                if (ourAssotiation is ScientificAssociation <Student> )
                {
                    ScientificAssociation <Student> tmp = ourAssotiation as ScientificAssociation <Student>;
                    tmp.ShowInfo();
                    flag = true;
                }
                else if (ourAssotiation is ScientificAssociation <Employee> )
                {
                    ScientificAssociation <Employee> tmp = ourAssotiation as ScientificAssociation <Employee>;
                    tmp.ShowInfo();
                    flag = true;
                }
            }

            MainActions.NoExistMassege(flag, TypeOfEntity.Association, AmountOfEntities.Several);
        }
示例#2
0
        public static void AddAssocation()
        {
            int amountOfParticipants;

            MainActions.ChoosenTypeOfAssociation(out TypeOfEntity ourTypeOfEntity);

            switch (ourTypeOfEntity)
            {
            case TypeOfEntity.Student:
            {
                ScientificAssociation <Student> ourAssociation =
                    new ScientificAssociation <Student>(TypeOfEntity.Student);

                ourAssociation.SetInfo();

                Write("Кол-во студентов(1-6) : ");

                amountOfParticipants = MainActions.GetCorrectPositiveInt(1, 6);

                for (int i = 0; i < amountOfParticipants; i++)
                {
                    int  ourID;
                    bool flag = false;

SomeException:
                    Write($"Введите ID студента №{i + 1} : ");

                    ourID = MainActions.GetCorrectPositiveInt();

                    foreach (Student ourStudent in ListOfStudents.Journal)
                    {
                        if (ourID == ourStudent.PersonID)
                        {
                            ourAssociation.Add(ourStudent);
                            flag = true;
                        }
                    }

                    MainActions.NoExistMassege(flag, TypeOfEntity.Student, AmountOfEntities.One);

                    if (flag == false)
                    {
                        goto SomeException;
                    }
                }

                ListOfAssociations.Add(ourAssociation);
            }
            break;

            case TypeOfEntity.Employee:
            {
                ScientificAssociation <Employee> ourAssociation =
                    new ScientificAssociation <Employee>(TypeOfEntity.Employee);

                ourAssociation.SetInfo();

                Write("Кол-во преподавателей(1-6) : ");

                amountOfParticipants = MainActions.GetCorrectPositiveInt(1, 6);

                for (int i = 0; i < amountOfParticipants; i++)
                {
                    int  ourID;
                    bool flag = false;

SomeException:
                    Write($"Введите ID преподавателя №{i + 1} : ");

                    ourID = MainActions.GetCorrectPositiveInt();

                    foreach (Employee ourEmployee in ListOfEmployees.Journal)
                    {
                        if (ourID == ourEmployee.PersonID)
                        {
                            ourAssociation.Add(ourEmployee);
                            flag = true;
                        }
                    }

                    MainActions.NoExistMassege(flag, TypeOfEntity.Employee, AmountOfEntities.One);
                    if (flag == false)
                    {
                        goto SomeException;
                    }
                }

                ListOfAssociations.Add(ourAssociation);
            }
            break;
            }
        }