public override void Load() { if (reading) { try { DbOperations dbo = new DbOperations(); CellContentCorrection ccc = new CellContentCorrection(); int departmentID = dbo.getDepartmentID("ПМ"); for (int i = 0; i < disciplines.Count; i++) { int disciplineID = dbo.getDisciplineID(disciplines[i].ToString()); dbo.insertLesson(disciplineID, lessonsType[i].ToString(), Convert.ToInt32(hours[i]), lessonsControl[i].ToString(), departmentID); int lastLessonID = dbo.getLastLessonID(); string suggestedAuditories = auditories[i].ToString(); if (suggestedAuditories.Length != 0) { suggestedAuditories = ccc.correctAuditories(suggestedAuditories); string [] separatedAuditories = suggestedAuditories.Split(new char[] { ',', ';' }); for (int j = 0; j < separatedAuditories.Length; j++) { int auditoryID = dbo.getAuditoryID(separatedAuditories[j]); dbo.insertLesson_Auditory(lastLessonID, auditoryID); } } string teachersRecord = teachers[i].ToString(); teachersRecord = ccc.correctTeachers(teachersRecord); string [] separatedTeachers = teachersRecord.Split(new char[] { ',', ';' }); for (int j = 0; j < separatedTeachers.Length; j++) { separatedTeachers[j] = separatedTeachers[j].Trim(); int teacherID = dbo.getTeacherID(separatedTeachers[j]); dbo.insertLesson_Teacher(lastLessonID, teacherID); } string groupsInCell = groups[i].ToString(); if (groupsInCell.Length != 0) { groupsInCell = ccc.correctGroups(groupsInCell); string [] separatedGroups = groupsInCell.Split(new char[] { ',', ';' }); ArrayList studyGroups = dbo.getStudy_groups(); for (int j = 0; j < separatedGroups.Length; j++) { if (studyGroups.Contains(separatedGroups[j]) == false) { GroupCode gc = new GroupCode(); string code = gc.getGroupCode(separatedGroups[j]); dbo.insertStudy_group(departmentID, separatedGroups[j], code); } int groupID = dbo.getStudy_groupID(separatedGroups[j]); dbo.insertLesson_group(lastLessonID, groupID); } } } } catch (Exception ex) { MessageBox.Show("Виникла помилка під час завантаження відомостей доручень до бази даних!" + "\n" + ex.Message); } } }