private void groupsBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <Subject_Group> subjectsGroupsList = otherData.GetAllSubject_Group();
            List <Group>         groupsList         = otherData.GetAllGroups();
            List <Subject>       subjectsList       = otherData.GetAllSubjects();

            foreach (Subject subject in subjectsList)
            {
                subjectsListBox.Items.Remove(subject.Title);
            }

            foreach (Group group in groupsList)
            {
                if (groupsBox.Text == group.Name)
                {
                    foreach (Subject subject in subjectsList)
                    {
                        subjectsListBox.Items.Add(subject.Title);
                        foreach (Subject_Group subject_Group in subjectsGroupsList)
                        {
                            if (subject_Group.Subject_id == subject.Id && subject_Group.Group_id == group.Id)
                            {
                                subjectsListBox.Items.Remove(subject.Title);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void subjectsBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedSubject = null;
            foreach (Subject subject in currentSubjectsList)
            {
                if (subject.Title == subjectsBox.Text)
                {
                    selectedSubject = subject;
                }
            }
            groupsBox.SelectedIndex   = -1;
            studentsBox.SelectedIndex = -1;
            groupsBox.Items.Clear();
            studentsBox.Items.Clear();
            currentGroupsList.Clear();
            List <Group>         groupsList        = otherData.GetAllGroups();
            List <Subject_Group> subject_groupList = otherData.GetAllSubject_Group();

            foreach (Subject subject in currentSubjectsList)
            {
                if (subject.Title == subjectsBox.Text)
                {
                    foreach (Subject_Group subject_Group in subject_groupList)
                    {
                        if (subject_Group.Subject_id == subject.Id)
                        {
                            groupsBox.Items.Add(otherData.FindGroupNameById(subject_Group.Group_id));
                            Group group = new Group(subject_Group.Group_id, otherData.FindGroupNameById(subject_Group.Group_id));
                            currentGroupsList.Add(group);
                            groupsBox.Visible     = true;
                            groupsLabel.Visible   = true;
                            groupsLabel.Text      = "PASIRINKITE STUDENTŲ GRUPĘ:";
                            studentsLabel.Visible = false;
                            GradeStudentLabelsAndButtonFalse();
                        }
                    }
                }
            }
            if (groupsBox.Items.Count == 0)
            {
                groupsBox.Visible     = false;
                groupsLabel.Visible   = true;
                groupsLabel.Text      = "ŠIS DĖSTOMAS DALYKAS NETURI PRISKIRTŲ GRUPIŲ";
                studentsLabel.Visible = false;
                studentsBox.Visible   = false;
                GradeStudentLabelsAndButtonFalse();
            }
        }
Пример #3
0
        public StudentWindow()
        {
            InitializeComponent();
            int groupId = otherData.GetStudentsGroup(student.Name, student.Surname);

            userLabel.Text += student.Name + " " + student.Surname;

            List <Subject_Group> allSubjectsAndGroups        = otherData.GetAllSubject_Group();
            List <Subject>       allAssignedsubjectsList     = otherData.GetAllAssignedSubjects();
            List <Subject_Group> studentsSubjectsAndGroupIds = new List <Subject_Group>();
            List <Subject>       studentSubjects             = new List <Subject>();

            foreach (Subject_Group subject_Group in allSubjectsAndGroups)
            {
                if (subject_Group.Group_id == groupId)
                {
                    studentsSubjectsAndGroupIds.Add(subject_Group); // Pridedami į listą visi studento subjectsid
                }
            }

            foreach (Subject subject in allAssignedsubjectsList)
            {
                foreach (Subject_Group subject_Group in studentsSubjectsAndGroupIds)
                {
                    if (subject_Group.Subject_id == subject.Id)
                    {
                        studentSubjects.Add(subject); // Pridedami į listą visi studento subjects
                    }
                }
            }

            int width = SubjectsLayoutPanel.Width - 7;

            foreach (Subject subject in studentSubjects)
            {
                Button subjectButton = new Button();
                subjectButton.Text  = subject.Title;
                subjectButton.Width = width;
                subjectButton.UseVisualStyleBackColor = true;
                subjectButton.Tag    = subject;
                subjectButton.Click += SubjectButton_Click;
                SubjectsLayoutPanel.Controls.Add(subjectButton);
            }
        }