Example #1
0
 public DisciplineName(int disciplineNameId, Discipline discipline, StudentGroup studentGroup, string name)
 {
     DisciplineNameId = disciplineNameId;
     Discipline = discipline;
     StudentGroup = studentGroup;
     Name = name;
 }
Example #2
0
        private void AddClick(object sender, EventArgs e)
        {
            int audHours;
            int.TryParse(AuditoriumHours.Text, out audHours);
            int lecHours;
            int.TryParse(LectureHours.Text, out lecHours);
            int practHours;
            int.TryParse(PracticalHours.Text, out practHours);
            if (_repo.FindDiscipline(DisciplineName.Text, Attestation.SelectedIndex,
                audHours, lecHours, practHours, Group.Text) != null)
            {
                MessageBox.Show("Такая дисциплина уже есть.");
                return;
            }

            if (Attestation.SelectedIndex == -1)
            {
                Attestation.SelectedIndex = Constants.Constants.Attestation.Where(a => a.Value == "-").FirstOrDefault().Key;
            }

            var disciplineGroup = _repo.FindStudentGroup(Group.Text);
            if (disciplineGroup == null)
            {
                disciplineGroup = new StudentGroup { Name = Group.Text };
                _repo.AddStudentGroup(disciplineGroup);
            }

            var newDiscipline = new Discipline
            {
                Attestation = Attestation.SelectedIndex,
                AuditoriumHours = audHours,
                LectureHours = lecHours,
                PracticalHours = practHours,
                Name = DisciplineName.Text,
                StudentGroup = disciplineGroup
            };

            _repo.AddDiscipline(newDiscipline);

            RefreshView();
        }
Example #3
0
        private void ImportFromTextClick(object sender, EventArgs e)
        {
            _repo.RecreateDB();
            _repo.Dispose();

            _repo = new ScheduleRepository();

            const string basePath = @"D:\BS\csprogs\Schedule\Schedule.TxtImport\bin\Debug\Import\old\";
            //const string basePath = @"E:\csprogs\Schedule\Schedule.TxtImport\bin\Debug\Import\old\";

            var auds = ScheduleTxtImport.ImportAuditoriums(basePath);
            _repo.AddAuditoriumRange(auds);

            var studentGroups = ScheduleTxtImport.ImportStudentsWithBaseGroups(basePath);
            foreach (var group in studentGroups)
            {
                var groupToAdd = _repo.FindStudentGroup(group.Key);
                if (groupToAdd == null)
                {
                    groupToAdd = new StudentGroup { Name = group.Key };
                    _repo.AddStudentGroup(groupToAdd);
                }

                foreach (var student in group.Value)
                {
                    _repo.AddStudent(student);

                    _repo.AddStudentsInGroups(new StudentsInGroups { Student = student, StudentGroup = groupToAdd });
                }
            }

            var disciplines = ScheduleTxtImport.ImportDisciplines(basePath);
            foreach (var disc in disciplines)
            {
                var group = _repo.FindStudentGroup(disc.StudentGroup.Name);

                if (group == null)
                {
                    group = new StudentGroup { Name = disc.StudentGroup.Name };
                    _repo.AddStudentGroup(group);
                }

                disc.StudentGroup = group;
            }
            _repo.AddDisciplineRange(disciplines);

            var rings = ScheduleTxtImport.ImportRings(basePath);
            _repo.AddRingRange(rings);

            /*
            var teachers = ScheduleTxtImport.ImportTeacherList();
            _repo.AddTeacherRange(teachers);
             */
        }
Example #4
0
        private void ImportStudentData(string filename)
        {
            var studentList = new List<Student>();
            var studentGroups = new List<StudentGroup>();
            var studentsInGroups = new List<StudentsInGroups>();

            var sr = new StreamReader(filename);

            string line;

            var maxStudentId = _repo
                .GetAllStudents()
                .Select(s => s.StudentId)
                .Max();
            maxStudentId++;

            var StudentIdRemap = new Dictionary<int, int>();

            sr.ReadLine();
            while ((line = sr.ReadLine()) != "StudentGroups")
            {
                var studentParts = line.Split('@');
                var student = new Student() {
                    StudentId = maxStudentId,
                    F = studentParts[1],
                    I = studentParts[2],
                    O = studentParts[3],
                    Address = "",
                    BirthDate = new DateTime(2000,1,1),
                    Expelled = false,
                    NFactor = false,
                    Orders = "",
                    PaidEdu = false,
                    Phone = "",
                    Starosta = false,
                    ZachNumber = ""
                };

                StudentIdRemap.Add(int.Parse(studentParts[0]), maxStudentId);

                studentList.Add(student);

                _repo.AddStudent(student);

                maxStudentId++;
            }

            StudentGroup group = null;
            var maxGroupId = _repo
                .GetAllStudentGroups()
                .Select(s => s.StudentGroupId)
                .Max();
            maxGroupId++;

            var groupIdRemap = new Dictionary<int, int>();
            while ((line = sr.ReadLine()) != "StudentsInGroups")
            {
                var groupParts = line.Split('@');

                if (!_repo.GetFiltredStudentGroups(sg => sg.Name == groupParts[1]).Any())
                {
                    group = new StudentGroup()
                    {
                        StudentGroupId = maxGroupId,
                        Name = groupParts[1]
                    };

                    groupIdRemap.Add(int.Parse(groupParts[0]), maxGroupId);

                    studentGroups.Add(group);

                    _repo.AddStudentGroup(group);

                    maxGroupId++;
                }
                else
                {
                    var gr = _repo.GetFirstFiltredStudentGroups(sg => sg.Name == groupParts[1]);
                    studentGroups.Add(gr);

                    groupIdRemap.Add(int.Parse(groupParts[0]), gr.StudentGroupId);
                }
            }

            while ((line = sr.ReadLine()) != null)
            {
                var sigParts = line.Split('@');

                var studentId = int.Parse(sigParts[0]);
                studentId = StudentIdRemap[studentId];

                var studentGroupId = int.Parse(sigParts[1]);
                if (groupIdRemap.ContainsKey(studentGroupId))
                {
                    studentGroupId = groupIdRemap[studentGroupId];
                }
                else
                {
                    studentGroupId = _repo.GetFirstFiltredStudentGroups( sg => sg.Name ==
                        studentGroups.FirstOrDefault(stg => stg.StudentGroupId == studentGroupId).Name).StudentGroupId;
                }

                var sig = new StudentsInGroups()
                {
                    Student = _repo.GetStudent(studentId),
                    StudentGroup = _repo.GetStudentGroup(studentGroupId)
                };

                studentsInGroups.Add(sig);

                _repo.AddStudentsInGroups(sig);
            }

            sr.Close();
        }
        public StudentGroup AddStudentGroup(StudentGroup studentGroup)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                studentGroup.StudentGroupId = 0;

                context.StudentGroups.Add(studentGroup);
                context.SaveChanges();

                return studentGroup;
            }
        }
 public GroupsInFaculty FindGroupsInFaculty(StudentGroup sg, Faculty f)
 {
     using (var context = new ScheduleContext(ConnectionString))
     {
         return context.GroupsInFaculties
             .Include(gif => gif.StudentGroup)
             .Include(gif => gif.Faculty)
             .FirstOrDefault(gif => gif.StudentGroup.StudentGroupId == sg.StudentGroupId &&
                                    gif.Faculty.FacultyId == f.FacultyId);
     }
 }
        public void UpdateStudentGroup(StudentGroup studentGroup)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                var curStudentGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == studentGroup.StudentGroupId);

                curStudentGroup.Name = studentGroup.Name;

                context.SaveChanges();
            }
        }
 public StudentsInGroups FindStudentsInGroups(Student s, StudentGroup sg)
 {
     using (var context = new ScheduleContext(ConnectionString))
     {
         return context.StudentsInGroups.Include(sig => sig.Student).Include(sig => sig.StudentGroup).FirstOrDefault(sig => sig.Student.StudentId == s.StudentId && sig.StudentGroup.StudentGroupId == sg.StudentGroupId);
     }
 }
Example #9
0
        private void add_Click(object sender, EventArgs e)
        {
            if (_repo.StudentGroups.FindStudentGroup(StudentGroupName.Text) != null)
            {
                MessageBox.Show("Такая группа уже есть.");
                return;
            }

            var newStudentGroup = new StudentGroup { Name = StudentGroupName.Text };
            _repo.StudentGroups.AddStudentGroup(newStudentGroup);

            RefreshView((int)RefreshType.GroupsOnly);
        }
Example #10
0
        private void AddClick(object sender, EventArgs e)
        {
            int audHours;
            int.TryParse(AuditoriumHours.Text, out audHours);
            int audHoursPerWeek;
            int.TryParse(AuditoriumHoursPerWeek.Text, out audHoursPerWeek);
            int lecHours;
            int.TryParse(LectureHours.Text, out lecHours);
            int practHours;
            int.TryParse(PracticalHours.Text, out practHours);

            if ((checkForDoubleDiscsOnAdding.Checked) &&
                (_repo.Disciplines.FindDiscipline(DisciplineName.Text, Attestation.SelectedIndex,
                audHours, lecHours, practHours, Group.Text) != null))
            {
                var dialogResult = MessageBox.Show("Такая дисциплина уже есть", "Всё равно добавить?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    //do something, in this case nothing
                }
                else if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            if (Attestation.SelectedIndex == -1)
            {
                Attestation.SelectedIndex = Constants.Attestation.FirstOrDefault(a => a.Value == "-").Key;
            }

            var disciplineGroup = _repo.StudentGroups.FindStudentGroup(Group.Text);
            if (disciplineGroup == null)
            {
                disciplineGroup = new StudentGroup { Name = Group.Text };
                _repo.StudentGroups.AddStudentGroup(disciplineGroup);
            }

            var newDiscipline = new Discipline
            {
                Attestation = Attestation.SelectedIndex,
                AuditoriumHours = audHours,
                AuditoriumHoursPerWeek = audHoursPerWeek,
                LectureHours = lecHours,
                PracticalHours = practHours,
                Name = DisciplineName.Text,
                StudentGroup = disciplineGroup,
                TypeSequence = TypeSequence.Text
            };

            _repo.Disciplines.AddDiscipline(newDiscipline);

            RefreshView();
        }
 public CustomStudentGroupAttribute(StudentGroup studentGroup, string key, string value)
 {
     StudentGroup = studentGroup;
     Key = key;
     Value = value;
 }