private void addToolStripMenuItem_Click(object sender, EventArgs e) { DepartmentDTO department = new DepartmentDTO();//обьект создается вызовом форм CourseForm courseForm = new CourseForm(); if (courseForm.ShowDialog(this) != DialogResult.OK) { return; } department.Courses = courseForm.CourcesDb; Registration registration = new Registration(); if (registration.ShowDialog(this) == DialogResult.OK) { department.Name = registration.textBoxName.Text; department.Head = registration.textBoxHead.Text; department.Password = registration.textBoxPassword.Text; } foreach (var it in department.Courses) { foreach (var item in it.Staff.Lecturers) { if (!Selected.Staff.ContainsStaff(item)) { Selected.Staff.AddLecturer(item); } } foreach (var item in it.Staff.Assistants) { if (!Selected.Staff.ContainsStaff(item)) { Selected.Staff.AddAssistant(item); } } } Db.Departments.Add(department); ToolStripMenuItem dbItem = new ToolStripMenuItem(department.Name); dbItem.Checked = true; dbItem.CheckState = CheckState.Unchecked; dbItem.Click += DbItem_Click; selectToolStripMenuItem.DropDownItems.Add(dbItem); saveAsToolStripMenuItem.Enabled = true; }
private void courcesToolStripMenuItem_Click(object sender, EventArgs e) { CourseForm courseForm = new CourseForm(); courseForm.CourcesDb = Selected.Courses; if (courseForm.ShowDialog(this) != DialogResult.OK) { return; } dataGridViewCources.Rows.Clear(); int index = 0; foreach (var it in Selected.Courses) { dataGridViewCources.Rows.Add(); dataGridViewCources.Rows[index].Cells[0].Value = it.Name; dataGridViewCources.Rows[index].Cells[1].Value = it.Code; dataGridViewCources.Rows[index].Cells[2].Value = it.Info.LectureHours; dataGridViewCources.Rows[index].Cells[3].Value = it.Info.PracticeHours; dataGridViewCources.Rows[index].Cells[4].Value = it.Info.LaboratoryHours; foreach (var item in it.Info.Groups) { ((DataGridViewComboBoxCell)dataGridViewCources.Rows[index].Cells[5]).Items.Add(item.ToString()); } foreach (var item in it.Staff.Lecturers) { ((DataGridViewComboBoxCell)dataGridViewCources.Rows[index].Cells[6]).Items.Add(item); } foreach (var item in it.Staff.Assistants) { ((DataGridViewComboBoxCell)dataGridViewCources.Rows[index].Cells[7]).Items.Add(item); } ++index; } }