private void InstallApp() { StudyType Ochnaja = new StudyType { Name = "очная" }; StudyType Zaochnaja = new StudyType { Name = "заочная" }; StudyType unnamed3 = new StudyType { Name = "unnamed3" }; StudyType unnamed4 = new StudyType { Name = "unnamed4" }; Faculty IiVT = new Faculty { Name = "Информатика и вычислительная техника", Abbreviation = "ИиВТ", }; FieldOfStudy Specialist = new FieldOfStudy { Name = "специалист" }; FieldOfStudy Bakalavr = new FieldOfStudy { Name = "бакалавр" }; FieldOfStudy Magistr = new FieldOfStudy { Name = "магистр" }; LessonsType Lections = new LessonsType { Id = 1, Name = "лекция" }; LessonsType Practics = new LessonsType { Id = 2, Name = "практика" }; LessonsType Labs = new LessonsType { Id = 3, Name = "лабораторные" }; LessonsSubType Comp = new LessonsSubType { Name = "компьютеры", LessonsTypeId = Labs.Id }; LessonsSubType Stanki = new LessonsSubType { Name = "станки", LessonsTypeId = Labs.Id }; Title prepod = new Title { Name = "преподаватель" }; Faculty fac = new Faculty { Name = "факультет", Abbreviation = "фак" }; Ring first = new Ring { Begin = "8:30", End = "9:50" }; Ring second = new Ring { Begin = "10:00", End = "11:20" }; Ring third = new Ring { Begin = "11:20", End = "12:50" }; Ring fourth = new Ring { Begin = "13:30", End = "14:50" }; Ring fifth = new Ring { Begin = "15:00", End = "16:20" }; Ring sixth = new Ring { Begin = "16:30", End = "17:50" }; Ring seventh = new Ring { Begin = "18:10", End = "19:30" }; Auditorium a = new Auditorium { Building = 1, Number = "1-490", Seats = 50, OpeningDate = "", ClosingDate = "", DepartmentId = 1, }; Degree d = new Degree { Name = "degree", }; using (UniversitySheduleContainer cnt = new UniversitySheduleContainer("name=UniversitySheduleContainer")) { cnt.StudyTypes.AddObject(Ochnaja); cnt.StudyTypes.AddObject(Zaochnaja); cnt.StudyTypes.AddObject(unnamed3); cnt.StudyTypes.AddObject(unnamed4); cnt.Faculties.AddObject(IiVT); cnt.FieldsOfStudy.AddObject(Specialist); cnt.FieldsOfStudy.AddObject(Bakalavr); cnt.FieldsOfStudy.AddObject(Magistr); cnt.LessonsTypes.AddObject(Lections); cnt.LessonsTypes.AddObject(Practics); cnt.LessonsTypes.AddObject(Labs); cnt.LessonsSubTypes.AddObject(Comp); cnt.LessonsSubTypes.AddObject(Stanki); cnt.Titles.AddObject(prepod); cnt.Faculties.AddObject(fac); cnt.Rings.AddObject(first); cnt.Rings.AddObject(second); cnt.Rings.AddObject(third); cnt.Rings.AddObject(fourth); cnt.Rings.AddObject(fifth); cnt.Rings.AddObject(sixth); cnt.Rings.AddObject(seventh); cnt.Degrees.AddObject(d); //cnt.Auditoriums.AddObject(a); // И финальный аккорд - сохраняем все изменения в БД cnt.SaveChanges(); } }
// проверяет, подходит ли аудитория по размеру для заданного занятия bool AuditoriumSizeOk(int regactionID, Auditorium auditorium, out int need_seats) { need_seats = 0; using (UniversitySheduleContainer cnt = new UniversitySheduleContainer("name=UniversitySheduleContainer")) { var res = (from c in cnt.Curriculums.Include("Group") where c.RegulatoryActionId == regactionID select c); foreach (var c in res) { need_seats += c.Group.StudCount; } } if (need_seats > auditorium.Seats) { return false; } return true; }
/// <summary> /// Deprecated Method for adding a new object to the Auditoriums EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAuditoriums(Auditorium auditorium) { base.AddObject("Auditoriums", auditorium); }
/// <summary> /// Create a new Auditorium object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="building">Initial value of the Building property.</param> /// <param name="number">Initial value of the Number property.</param> /// <param name="seats">Initial value of the Seats property.</param> /// <param name="openingDate">Initial value of the OpeningDate property.</param> /// <param name="closingDate">Initial value of the ClosingDate property.</param> /// <param name="departmentId">Initial value of the DepartmentId property.</param> public static Auditorium CreateAuditorium(global::System.Int32 id, global::System.Int32 building, global::System.String number, global::System.Int32 seats, global::System.String openingDate, global::System.String closingDate, global::System.Int32 departmentId) { Auditorium auditorium = new Auditorium(); auditorium.Id = id; auditorium.Building = building; auditorium.Number = number; auditorium.Seats = seats; auditorium.OpeningDate = openingDate; auditorium.ClosingDate = closingDate; auditorium.DepartmentId = departmentId; return auditorium; }
public void Import() { using (UniversitySheduleContainer cnt = new UniversitySheduleContainer("name=UniversitySheduleContainer")) { foreach (var g in readeddepartment) { if (g.Add) { Department newDepartment = new Department() { Abbreviation = g.Name, Name = g.Name, //Id = g.Id, FacultyId = 1, }; cnt.Departments.AddObject(newDepartment); } } cnt.SaveChanges(); Department virtualDepartment = new Department() { Abbreviation = "VIRT", Name = "Virtual", FacultyId = 1, }; cnt.Departments.AddObject(virtualDepartment); Auditorium virtualAudit = new Auditorium() { Building = 1, Number = "VIRTUAL", Seats = 9999999, Department = virtualDepartment, OpeningDate = "", ClosingDate = "", }; cnt.Auditoriums.AddObject(virtualAudit); cnt.SaveChanges(); } }
public void Import() { using (UniversitySheduleContainer cnt = new UniversitySheduleContainer("name=UniversitySheduleContainer")) { foreach (var g in readedauditoriums) { if (g.Add) { var deps = (from lt in cnt.Departments where lt.Id == g.Chair select lt); if (deps.Count() == 0) continue; Auditorium newAudit = new Auditorium() { Building = g.Corpus, Department = deps.First(), Seats = g.Capacity, Number = g.CorAndNum, OpeningDate = "", ClosingDate = "", }; cnt.Auditoriums.AddObject(newAudit); } } cnt.SaveChanges(); } }