private void добавитьToolStripMenuItem_Click(object sender, EventArgs e) { var studentDetailsForm = new StudentProperties(this, _repo, 0, StudentDetailsMode.New); studentDetailsForm.Show(); }
private void EditToolStripMenuItem_Click(object sender, EventArgs e) { if (viewGrid.SelectedCells.Count == 0) return; var studentId = (int) viewGrid.Rows[viewGrid.SelectedCells[0].RowIndex].Cells["StudentId"].Value; var groupName = searchBox.Text; var studentDetailsForm = new StudentProperties(this, _repo, studentId, StudentDetailsMode.Edit); var result = studentDetailsForm.ShowDialog(); searchBox.Text = groupName; if (result == DialogResult.OK) { SearchBoxKeyDown(this, new KeyEventArgs(Keys.Enter)); } }
private void SearchBoxKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (searchBox.SelectedValue == null) { return; } var keyword = ((string) searchBox.SelectedValue).Split('@')[0]; var id = int.Parse(((string) searchBox.SelectedValue).Split('@')[1]); switch (keyword) { case "student": var studentDetailsForm = new StudentProperties(this, _repo, id, StudentDetailsMode.Edit); studentDetailsForm.Show(); Height = 85; Width = 670; break; case "studentGroup": var groupStudents = _repo .StudentsInGroups .GetFiltredStudentsInGroups( sig => sig.StudentGroup.StudentGroupId == id && !sig.Student.Expelled) .Select(sig => sig.Student) .OrderBy(s => s.Expelled) .ThenBy(s => s.F) .ThenBy(s => s.I) .ToList(); viewGrid.DataSource = groupStudents; FormatGroupView(); Height = 540; Width = 1090; break; } Left = (Screen.PrimaryScreen.Bounds.Width - Width)/2; Top = (Screen.PrimaryScreen.Bounds.Height - Height)/2; } if (e.KeyCode == Keys.Escape) { Close(); } }