From 3f8ca06b3f61b1938a678e57c108625193354111 Mon Sep 17 00:00:00 2001 From: Garifullin-Farid <95081032+Garifullin-Farid@users.noreply.github.com> Date: Tue, 26 Nov 2024 21:35:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sDistribution.cs => DisciplineTeachers.cs} | 6 +- .../Entities/Enum/TeacherDispline.cs | 21 ----- .../Entities/Enum/TypeAttestation.cs | 4 +- .../ProjectSession/Entities/Exam.cs | 9 +- .../ProjectSession/Entities/Student.cs | 14 +-- .../Entities/StudentGradeBook.cs | 25 ------ .../ProjectSession/Entities/Teacher.cs | 11 ++- .../Entities/TeachersDistribution.cs | 21 ----- .../Forms/FormDiscipline.Designer.cs | 4 +- .../Forms/FormDisciplines.Designer.cs | 8 +- .../ProjectSession/Forms/FormExam.Designer.cs | 87 ++++++++++++++----- .../ProjectSession/Forms/FormExam.cs | 40 +++++++-- .../ProjectSession/Forms/FormExam.resx | 6 ++ .../Forms/FormExams.Designer.cs | 49 ++++++----- .../ProjectSession/Forms/FormExams.cs | 46 ++++++++-- .../Forms/FormGroups.Designer.cs | 8 +- .../Forms/FormStudent.Designer.cs | 55 +----------- .../ProjectSession/Forms/FormStudent.cs | 20 +---- .../ProjectSession/Forms/FormStudent.resx | 12 --- .../Forms/FormStudents.Designer.cs | 8 +- .../ProjectSession/Forms/FormTeacher.cs | 4 +- .../Forms/FormTeachers.Designer.cs | 8 +- .../IStudentGradeBookRepository.cs | 17 ---- .../ITeachersDistributionRepository.cs | 11 --- .../Implementations/ExamRepository.cs | 2 +- .../StudentGradeBookRepository.cs | 20 ----- .../Implementations/StudentRepository.cs | 2 +- .../TeachersDistributionRepository.cs | 25 ------ 28 files changed, 224 insertions(+), 319 deletions(-) rename ProjectSession/ProjectSession/Entities/{DisciplineTeachersDistribution.cs => DisciplineTeachers.cs} (63%) delete mode 100644 ProjectSession/ProjectSession/Entities/Enum/TeacherDispline.cs delete mode 100644 ProjectSession/ProjectSession/Entities/StudentGradeBook.cs delete mode 100644 ProjectSession/ProjectSession/Entities/TeachersDistribution.cs delete mode 100644 ProjectSession/ProjectSession/Repositories/IStudentGradeBookRepository.cs delete mode 100644 ProjectSession/ProjectSession/Repositories/ITeachersDistributionRepository.cs delete mode 100644 ProjectSession/ProjectSession/Repositories/Implementations/StudentGradeBookRepository.cs delete mode 100644 ProjectSession/ProjectSession/Repositories/Implementations/TeachersDistributionRepository.cs diff --git a/ProjectSession/ProjectSession/Entities/DisciplineTeachersDistribution.cs b/ProjectSession/ProjectSession/Entities/DisciplineTeachers.cs similarity index 63% rename from ProjectSession/ProjectSession/Entities/DisciplineTeachersDistribution.cs rename to ProjectSession/ProjectSession/Entities/DisciplineTeachers.cs index 14841eb..925bf6a 100644 --- a/ProjectSession/ProjectSession/Entities/DisciplineTeachersDistribution.cs +++ b/ProjectSession/ProjectSession/Entities/DisciplineTeachers.cs @@ -1,13 +1,13 @@ namespace ProjectSession.Entities { - public class DisciplineTeachersDistribution + public class DisciplineTeachers { public int Id { get; private set; } public int DisciplineId { get; private set; } public int NumberHours { get; private set; } - public static DisciplineTeachersDistribution CreateElement(int id, int disciplineId, int numberHours) + public static DisciplineTeachers CreateElement(int id, int disciplineId, int numberHours) { - return new DisciplineTeachersDistribution + return new DisciplineTeachers { Id = id, DisciplineId = disciplineId, diff --git a/ProjectSession/ProjectSession/Entities/Enum/TeacherDispline.cs b/ProjectSession/ProjectSession/Entities/Enum/TeacherDispline.cs deleted file mode 100644 index 8411941..0000000 --- a/ProjectSession/ProjectSession/Entities/Enum/TeacherDispline.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace ProjectSession.Entities.Enum -{ - public class TeacherDispline - { - public int Id { get; private set; } - public int TeacherId { get; private set; } - public int DisciplineId { get; private set; } - public int Mark { get; private set; } - public static TeacherDispline CreateElement(int id, int disciplineId, int teacherId, int mark) - { - return new TeacherDispline - { - Id = id, - TeacherId = teacherId, - DisciplineId = disciplineId, - Mark = mark - - }; - } - } -} diff --git a/ProjectSession/ProjectSession/Entities/Enum/TypeAttestation.cs b/ProjectSession/ProjectSession/Entities/Enum/TypeAttestation.cs index a93a177..06ddf42 100644 --- a/ProjectSession/ProjectSession/Entities/Enum/TypeAttestation.cs +++ b/ProjectSession/ProjectSession/Entities/Enum/TypeAttestation.cs @@ -16,11 +16,11 @@ namespace ProjectSession.Entities.Enum /// /// дифференцированный зачет /// - DifferentiatedCredit = 0, + DifferentiatedCredit = 1, /// /// экзамен /// - Exam = 1, + Exam = 2, } } diff --git a/ProjectSession/ProjectSession/Entities/Exam.cs b/ProjectSession/ProjectSession/Entities/Exam.cs index 2195b4c..49b5eca 100644 --- a/ProjectSession/ProjectSession/Entities/Exam.cs +++ b/ProjectSession/ProjectSession/Entities/Exam.cs @@ -16,15 +16,18 @@ namespace ProjectSession.Entities public DateTime DateTime { get; private set; } - - public static Exam CreateOpeartion(int id,int teacherId,int disciplineId, DateTime dateTime) + public IEnumerable ExamGradeBook { get; private set; } = []; + + + public static Exam CreateOpeartion(int id,int teacherId,int disciplineId, DateTime dateTime, IEnumerable examGradeBook) { return new Exam { Id = id, TeacherId = teacherId, DisciplineId = disciplineId, - DateTime = dateTime + DateTime = dateTime, + ExamGradeBook = examGradeBook }; } diff --git a/ProjectSession/ProjectSession/Entities/Student.cs b/ProjectSession/ProjectSession/Entities/Student.cs index 42119f3..6adc7cd 100644 --- a/ProjectSession/ProjectSession/Entities/Student.cs +++ b/ProjectSession/ProjectSession/Entities/Student.cs @@ -1,6 +1,4 @@ - - -using ProjectSession.Entities.Enum; +using ProjectSession.Entities.Enum; namespace ProjectSession.Entities { @@ -18,11 +16,15 @@ namespace ProjectSession.Entities public int GroupID { get; private set; } + public string FullName + { + get { return $"{FirstName} {LastName}"; } + } + public StudentStatus Status { get; private set; } - public IEnumerable ExamGradeBook { get; private set; } = []; - public static Student CreateEntity(int id,string firstName,string lastName,int groupId, StudentStatus studentStatus, IEnumerable examGradeBook) + public static Student CreateEntity(int id,string firstName,string lastName,int groupId, StudentStatus studentStatus) { return new Student { @@ -31,7 +33,7 @@ namespace ProjectSession.Entities LastName = lastName, GroupID = groupId, Status = studentStatus, - ExamGradeBook = examGradeBook + }; } } diff --git a/ProjectSession/ProjectSession/Entities/StudentGradeBook.cs b/ProjectSession/ProjectSession/Entities/StudentGradeBook.cs deleted file mode 100644 index d57a507..0000000 --- a/ProjectSession/ProjectSession/Entities/StudentGradeBook.cs +++ /dev/null @@ -1,25 +0,0 @@ - -namespace ProjectSession.Entities -{ - public class StudentGradeBook - { - public int Id { get; private set; } - - public int StudentId { get; private set; } - - public IEnumerable ExamGradeBook{ get; private set;} = []; - - public static StudentGradeBook CreateOpeartion(int id, int studentId, - - IEnumerable examGradeBook) - { - return new StudentGradeBook - { - Id = id, - StudentId = studentId, - ExamGradeBook = examGradeBook - }; - } - - } -} diff --git a/ProjectSession/ProjectSession/Entities/Teacher.cs b/ProjectSession/ProjectSession/Entities/Teacher.cs index 4b8f930..d4fd2a6 100644 --- a/ProjectSession/ProjectSession/Entities/Teacher.cs +++ b/ProjectSession/ProjectSession/Entities/Teacher.cs @@ -15,12 +15,17 @@ namespace ProjectSession.Entities public string LastName { get; private set; } = string.Empty; - + public string FullName + { + get { return $"{FirstName} {LastName}"; } + } + + public TeacherPost TeacherPost { get; private set; } - public IEnumerable DisciplineTeachersDistribution { get; private set; } = []; + public IEnumerable DisciplineTeachersDistribution { get; private set; } = []; - public static Teacher CreateEntity(int id,string FirstName,string LastName,TeacherPost teacherPost, IEnumerable disciplineTeachersDistribution) + public static Teacher CreateEntity(int id,string FirstName,string LastName,TeacherPost teacherPost, IEnumerable disciplineTeachersDistribution) { return new Teacher { diff --git a/ProjectSession/ProjectSession/Entities/TeachersDistribution.cs b/ProjectSession/ProjectSession/Entities/TeachersDistribution.cs deleted file mode 100644 index 98655ca..0000000 --- a/ProjectSession/ProjectSession/Entities/TeachersDistribution.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace ProjectSession.Entities -{ - public class TeachersDistribution - { - public int Id { get; private set; } - - public int TeacherId { get; private set; } - - public IEnumerable DisciplineTeachersDistribution { get; private set;} = []; - - public static TeachersDistribution CreateOpeartion(int id, int teacherId, IEnumerable disciplineTeachersDistribution) - { - return new TeachersDistribution - { - Id = id, - TeacherId = teacherId, - DisciplineTeachersDistribution = disciplineTeachersDistribution - }; - } - } -} diff --git a/ProjectSession/ProjectSession/Forms/FormDiscipline.Designer.cs b/ProjectSession/ProjectSession/Forms/FormDiscipline.Designer.cs index 89b286a..7b5f76d 100644 --- a/ProjectSession/ProjectSession/Forms/FormDiscipline.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormDiscipline.Designer.cs @@ -61,14 +61,14 @@ comboBoxType.FormattingEnabled = true; comboBoxType.Location = new Point(33, 99); comboBoxType.Name = "comboBoxType"; - comboBoxType.Size = new Size(100, 23); + comboBoxType.Size = new Size(109, 23); comboBoxType.TabIndex = 13; // // textBoxName // textBoxName.Location = new Point(33, 53); textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(100, 23); + textBoxName.Size = new Size(109, 23); textBoxName.TabIndex = 12; // // label2 diff --git a/ProjectSession/ProjectSession/Forms/FormDisciplines.Designer.cs b/ProjectSession/ProjectSession/Forms/FormDisciplines.Designer.cs index 8b053bc..ab47547 100644 --- a/ProjectSession/ProjectSession/Forms/FormDisciplines.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormDisciplines.Designer.cs @@ -52,7 +52,7 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersVisible = false; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(664, 450); + dataGridView.Size = new Size(1008, 448); dataGridView.TabIndex = 5; // // panel1 @@ -61,9 +61,9 @@ panel1.Controls.Add(buttonDell); panel1.Controls.Add(buttonAdd); panel1.Dock = DockStyle.Right; - panel1.Location = new Point(664, 0); + panel1.Location = new Point(1008, 0); panel1.Name = "panel1"; - panel1.Size = new Size(136, 450); + panel1.Size = new Size(136, 448); panel1.TabIndex = 4; // // buttonUpd @@ -103,7 +103,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(1144, 448); Controls.Add(dataGridView); Controls.Add(panel1); Name = "FormDisciplines"; diff --git a/ProjectSession/ProjectSession/Forms/FormExam.Designer.cs b/ProjectSession/ProjectSession/Forms/FormExam.Designer.cs index b172adb..8102919 100644 --- a/ProjectSession/ProjectSession/Forms/FormExam.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormExam.Designer.cs @@ -30,18 +30,24 @@ { comboBoxTeacher = new ComboBox(); comboBoxDiscipline = new ComboBox(); - dateTimePickerExam = new DateTimePicker(); label1 = new Label(); label2 = new Label(); label3 = new Label(); buttonCancel = new Button(); buttonSave = new Button(); + groupBoxStidentMark = new GroupBox(); + dataGridViewExams = new DataGridView(); + ColumnStudent = new DataGridViewComboBoxColumn(); + ColumnMark = new DataGridViewTextBoxColumn(); + dateTimePicker = new DateTimePicker(); + groupBoxStidentMark.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewExams).BeginInit(); SuspendLayout(); // // comboBoxTeacher // comboBoxTeacher.FormattingEnabled = true; - comboBoxTeacher.Location = new Point(125, 83); + comboBoxTeacher.Location = new Point(125, 51); comboBoxTeacher.Name = "comboBoxTeacher"; comboBoxTeacher.Size = new Size(175, 23); comboBoxTeacher.TabIndex = 0; @@ -49,24 +55,15 @@ // comboBoxDiscipline // comboBoxDiscipline.FormattingEnabled = true; - comboBoxDiscipline.Location = new Point(125, 130); + comboBoxDiscipline.Location = new Point(125, 98); comboBoxDiscipline.Name = "comboBoxDiscipline"; comboBoxDiscipline.Size = new Size(175, 23); comboBoxDiscipline.TabIndex = 1; // - // dateTimePickerExam - // - dateTimePickerExam.CustomFormat = " d.MM.yyyy HH:m"; - dateTimePickerExam.Format = DateTimePickerFormat.Custom; - dateTimePickerExam.Location = new Point(125, 181); - dateTimePickerExam.Name = "dateTimePickerExam"; - dateTimePickerExam.Size = new Size(175, 23); - dateTimePickerExam.TabIndex = 2; - // // label1 // label1.AutoSize = true; - label1.Location = new Point(24, 86); + label1.Location = new Point(24, 51); label1.Name = "label1"; label1.Size = new Size(89, 15); label1.TabIndex = 3; @@ -75,7 +72,7 @@ // label2 // label2.AutoSize = true; - label2.Location = new Point(24, 133); + label2.Location = new Point(24, 98); label2.Name = "label2"; label2.Size = new Size(74, 15); label2.TabIndex = 4; @@ -84,7 +81,7 @@ // label3 // label3.AutoSize = true; - label3.Location = new Point(24, 187); + label3.Location = new Point(24, 147); label3.Name = "label3"; label3.Size = new Size(77, 15); label3.TabIndex = 5; @@ -92,7 +89,7 @@ // // buttonCancel // - buttonCancel.Location = new Point(166, 261); + buttonCancel.Location = new Point(200, 527); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(100, 48); buttonCancel.TabIndex = 11; @@ -102,7 +99,7 @@ // // buttonSave // - buttonSave.Location = new Point(42, 261); + buttonSave.Location = new Point(24, 527); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(100, 48); buttonSave.TabIndex = 10; @@ -110,23 +107,69 @@ buttonSave.UseVisualStyleBackColor = true; buttonSave.Click += ButtonSave_Click; // + // groupBoxStidentMark + // + groupBoxStidentMark.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBoxStidentMark.Controls.Add(dataGridViewExams); + groupBoxStidentMark.Location = new Point(12, 223); + groupBoxStidentMark.Name = "groupBoxStidentMark"; + groupBoxStidentMark.Size = new Size(314, 249); + groupBoxStidentMark.TabIndex = 14; + groupBoxStidentMark.TabStop = false; + groupBoxStidentMark.Text = "оценки "; + // + // dataGridViewExams + // + dataGridViewExams.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridViewExams.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewExams.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewExams.Columns.AddRange(new DataGridViewColumn[] { ColumnStudent, ColumnMark }); + dataGridViewExams.Location = new Point(16, 23); + dataGridViewExams.Margin = new Padding(3, 4, 3, 4); + dataGridViewExams.MultiSelect = false; + dataGridViewExams.Name = "dataGridViewExams"; + dataGridViewExams.RowHeadersWidth = 51; + dataGridViewExams.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewExams.Size = new Size(292, 219); + dataGridViewExams.TabIndex = 0; + // + // ColumnStudent + // + ColumnStudent.HeaderText = "студент"; + ColumnStudent.Name = "ColumnStudent"; + // + // ColumnMark + // + ColumnMark.HeaderText = "Оценка"; + ColumnMark.Name = "ColumnMark"; + // + // dateTimePicker + // + dateTimePicker.Location = new Point(120, 147); + dateTimePicker.Name = "dateTimePicker"; + dateTimePicker.Size = new Size(180, 23); + dateTimePicker.TabIndex = 15; + // // FormExam // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(312, 362); + ClientSize = new Size(341, 587); + Controls.Add(dateTimePicker); + Controls.Add(groupBoxStidentMark); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(label3); Controls.Add(label2); Controls.Add(label1); - Controls.Add(dateTimePickerExam); Controls.Add(comboBoxDiscipline); Controls.Add(comboBoxTeacher); KeyPreview = true; Name = "FormExam"; StartPosition = FormStartPosition.CenterScreen; Text = "экзамен"; + groupBoxStidentMark.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewExams).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -135,11 +178,15 @@ private ComboBox comboBoxTeacher; private ComboBox comboBoxDiscipline; - private DateTimePicker dateTimePickerExam; private Label label1; private Label label2; private Label label3; private Button buttonCancel; private Button buttonSave; + private GroupBox groupBoxStidentMark; + private DataGridView dataGridViewExams; + private DataGridViewComboBoxColumn ColumnStudent; + private DataGridViewTextBoxColumn ColumnMark; + private DateTimePicker dateTimePicker; } } \ No newline at end of file diff --git a/ProjectSession/ProjectSession/Forms/FormExam.cs b/ProjectSession/ProjectSession/Forms/FormExam.cs index 5da0f26..91a3520 100644 --- a/ProjectSession/ProjectSession/Forms/FormExam.cs +++ b/ProjectSession/ProjectSession/Forms/FormExam.cs @@ -1,5 +1,7 @@ using ProjectSession.Entities; using ProjectSession.Repositories; +using ProjectSession.Repositories.Implementations; +using System.Windows.Forms; namespace ProjectSession.Forms { @@ -7,29 +9,37 @@ namespace ProjectSession.Forms { private readonly IExamRepository _examRepository; - public FormExam( IExamRepository ExamRepository, ITeacherRepository teacherRepository, IDisciplineRepository disciplineRepository) + public FormExam( IExamRepository ExamRepository, ITeacherRepository teacherRepository, IDisciplineRepository disciplineRepository,IStudentRepository studentRepository) { InitializeComponent(); _examRepository = ExamRepository ?? throw new ArgumentNullException(nameof(ExamRepository)); comboBoxDiscipline.DataSource = disciplineRepository.ReadDiscipline(); comboBoxDiscipline.DisplayMember = "Name"; comboBoxDiscipline.ValueMember = "Id"; + comboBoxTeacher.DataSource = teacherRepository.ReadTeacher(); - comboBoxTeacher.DisplayMember = "FirstName"; - comboBoxTeacher.DisplayMember = "LastName"; + comboBoxTeacher.DisplayMember = "FullName"; comboBoxTeacher.ValueMember = "Id"; - + + ColumnStudent.DataSource = studentRepository.ReadStudent(); + ColumnStudent.DisplayMember = "FullName"; + ColumnStudent.ValueMember = "Id"; + + dateTimePicker.Format = DateTimePickerFormat.Custom; + dateTimePicker.CustomFormat = "yyyy-MM-dd HH:mm:ss"; + dateTimePicker.Value = DateTime.Now; + } private void ButtonSave_Click(object sender, EventArgs e) { try { - if (comboBoxDiscipline.SelectedIndex < 0 ||comboBoxTeacher.SelectedIndex < 0) + if (comboBoxDiscipline.SelectedIndex < 0 ||comboBoxTeacher.SelectedIndex < 0 || dataGridViewExams.RowCount < 1) { throw new Exception("Имеются незаполненные поля"); } - _examRepository.CreateExam(Exam.CreateOpeartion(0,(int)comboBoxTeacher.SelectedValue!, - (int)comboBoxDiscipline.SelectedValue!,dateTimePickerExam.Value)); + _examRepository.CreateExam(Exam.CreateOpeartion(0, (int)comboBoxTeacher.SelectedValue!, + (int)comboBoxDiscipline.SelectedValue!, dateTimePicker.Value, CreateListExamGradeBookFromDataGrid())); Close(); } catch (Exception ex) @@ -38,5 +48,21 @@ namespace ProjectSession.Forms } } private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private List CreateListExamGradeBookFromDataGrid(){ + var list = new List(); + foreach (DataGridViewRow row in dataGridViewExams.Rows) + { + if (row.Cells["ColumnExam"].Value == null || + row.Cells["ColumnExam"].Value == null) + { + continue; + } + list.Add(ExamGradeBook.CreateElement(0, + Convert.ToInt32(row.Cells["ColumnExam"].Value), + Convert.ToInt32(row.Cells["ColumnMark"].Value))); + } + return list; + } } } diff --git a/ProjectSession/ProjectSession/Forms/FormExam.resx b/ProjectSession/ProjectSession/Forms/FormExam.resx index af32865..944be8a 100644 --- a/ProjectSession/ProjectSession/Forms/FormExam.resx +++ b/ProjectSession/ProjectSession/Forms/FormExam.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + \ No newline at end of file diff --git a/ProjectSession/ProjectSession/Forms/FormExams.Designer.cs b/ProjectSession/ProjectSession/Forms/FormExams.Designer.cs index 04e06bf..6541fa4 100644 --- a/ProjectSession/ProjectSession/Forms/FormExams.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormExams.Designer.cs @@ -28,40 +28,40 @@ /// private void InitializeComponent() { - dataGridViewData = new DataGridView(); + dataGridView = new DataGridView(); panel1 = new Panel(); buttonUpd = new Button(); buttonAdd = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); panel1.SuspendLayout(); SuspendLayout(); // - // dataGridViewData + // dataGridView // - dataGridViewData.AllowUserToAddRows = false; - dataGridViewData.AllowUserToDeleteRows = false; - dataGridViewData.AllowUserToResizeColumns = false; - dataGridViewData.AllowUserToResizeRows = false; - dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewData.Dock = DockStyle.Fill; - dataGridViewData.Location = new Point(0, 0); - dataGridViewData.MultiSelect = false; - dataGridViewData.Name = "dataGridViewData"; - dataGridViewData.ReadOnly = true; - dataGridViewData.RowHeadersVisible = false; - dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridViewData.Size = new Size(664, 450); - dataGridViewData.TabIndex = 7; + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(1021, 446); + dataGridView.TabIndex = 7; // // panel1 // panel1.Controls.Add(buttonUpd); panel1.Controls.Add(buttonAdd); panel1.Dock = DockStyle.Right; - panel1.Location = new Point(664, 0); + panel1.Location = new Point(1021, 0); panel1.Name = "panel1"; - panel1.Size = new Size(136, 450); + panel1.Size = new Size(136, 446); panel1.TabIndex = 6; // // buttonUpd @@ -73,6 +73,7 @@ buttonUpd.Size = new Size(75, 70); buttonUpd.TabIndex = 3; buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; // // buttonAdd // @@ -89,21 +90,21 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(dataGridViewData); + ClientSize = new Size(1157, 446); + Controls.Add(dataGridView); Controls.Add(panel1); Name = "FormExams"; StartPosition = FormStartPosition.CenterScreen; Text = "экзамены"; Load += FormExam_Load; - ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); panel1.ResumeLayout(false); ResumeLayout(false); } #endregion - private DataGridView dataGridViewData; + private DataGridView dataGridView; private Panel panel1; private Button buttonAdd; private Button buttonUpd; diff --git a/ProjectSession/ProjectSession/Forms/FormExams.cs b/ProjectSession/ProjectSession/Forms/FormExams.cs index e17642a..10070e6 100644 --- a/ProjectSession/ProjectSession/Forms/FormExams.cs +++ b/ProjectSession/ProjectSession/Forms/FormExams.cs @@ -1,6 +1,7 @@ using Unity; using ProjectSession.Repositories; + namespace ProjectSession.Forms { public partial class FormExams : Form @@ -11,11 +12,8 @@ namespace ProjectSession.Forms public FormExams(IUnityContainer container, IExamRepository examRepository) { InitializeComponent(); - _container = container ?? - throw new ArgumentNullException(nameof(container)); - _examRepository = examRepository ?? - throw new - ArgumentNullException(nameof(examRepository)); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _examRepository = examRepository ?? throw new ArgumentNullException(nameof(examRepository)); } private void FormExam_Load(object sender, EventArgs e) { @@ -41,8 +39,40 @@ namespace ProjectSession.Forms MessageBox.Show(ex.Message, "Ошибка при добавлении",MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void LoadList() => dataGridViewData.DataSource = - _examRepository.ReadExam(); + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } - + + + private void LoadList() => dataGridView.DataSource = _examRepository.ReadExam(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } + + } diff --git a/ProjectSession/ProjectSession/Forms/FormGroups.Designer.cs b/ProjectSession/ProjectSession/Forms/FormGroups.Designer.cs index 29842c8..c7a2263 100644 --- a/ProjectSession/ProjectSession/Forms/FormGroups.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormGroups.Designer.cs @@ -52,7 +52,7 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersVisible = false; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(664, 450); + dataGridView.Size = new Size(1009, 436); dataGridView.TabIndex = 3; // // panel1 @@ -61,9 +61,9 @@ panel1.Controls.Add(buttonDell); panel1.Controls.Add(buttonAdd); panel1.Dock = DockStyle.Right; - panel1.Location = new Point(664, 0); + panel1.Location = new Point(1009, 0); panel1.Name = "panel1"; - panel1.Size = new Size(136, 450); + panel1.Size = new Size(136, 436); panel1.TabIndex = 2; // // buttonUpd @@ -103,7 +103,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(1145, 436); Controls.Add(dataGridView); Controls.Add(panel1); Name = "FormGroups"; diff --git a/ProjectSession/ProjectSession/Forms/FormStudent.Designer.cs b/ProjectSession/ProjectSession/Forms/FormStudent.Designer.cs index 121b2e8..fd07868 100644 --- a/ProjectSession/ProjectSession/Forms/FormStudent.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormStudent.Designer.cs @@ -38,12 +38,6 @@ label3 = new Label(); comboBoxStudentGroup = new ComboBox(); label4 = new Label(); - groupBoxExam = new GroupBox(); - dataGridViewExams = new DataGridView(); - ColumnExam = new DataGridViewComboBoxColumn(); - ColumnMark = new DataGridViewTextBoxColumn(); - groupBoxExam.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridViewExams).BeginInit(); SuspendLayout(); // // label1 @@ -80,7 +74,7 @@ // // buttonSave // - buttonSave.Location = new Point(12, 551); + buttonSave.Location = new Point(39, 306); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(100, 48); buttonSave.TabIndex = 6; @@ -90,7 +84,7 @@ // // buttonCancel // - buttonCancel.Location = new Point(226, 551); + buttonCancel.Location = new Point(222, 306); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(100, 48); buttonCancel.TabIndex = 7; @@ -132,49 +126,12 @@ label4.TabIndex = 12; label4.Text = "группа"; // - // groupBoxExam - // - groupBoxExam.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - groupBoxExam.Controls.Add(dataGridViewExams); - groupBoxExam.Location = new Point(23, 263); - groupBoxExam.Name = "groupBoxExam"; - groupBoxExam.Size = new Size(314, 249); - groupBoxExam.TabIndex = 13; - groupBoxExam.TabStop = false; - groupBoxExam.Text = "экзамены"; - // - // dataGridViewExams - // - dataGridViewExams.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - dataGridViewExams.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridViewExams.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewExams.Columns.AddRange(new DataGridViewColumn[] { ColumnExam, ColumnMark }); - dataGridViewExams.Location = new Point(16, 23); - dataGridViewExams.Margin = new Padding(3, 4, 3, 4); - dataGridViewExams.MultiSelect = false; - dataGridViewExams.Name = "dataGridViewExams"; - dataGridViewExams.RowHeadersWidth = 51; - dataGridViewExams.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridViewExams.Size = new Size(283, 219); - dataGridViewExams.TabIndex = 0; - // - // ColumnExam - // - ColumnExam.HeaderText = "экзамен"; - ColumnExam.Name = "ColumnExam"; - // - // ColumnMark - // - ColumnMark.HeaderText = "Оценка"; - ColumnMark.Name = "ColumnMark"; - // // FormStudent // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; AutoValidate = AutoValidate.EnableAllowFocusChange; - ClientSize = new Size(364, 611); - Controls.Add(groupBoxExam); + ClientSize = new Size(361, 407); Controls.Add(label4); Controls.Add(comboBoxStudentGroup); Controls.Add(label3); @@ -188,8 +145,6 @@ Name = "FormStudent"; StartPosition = FormStartPosition.CenterScreen; Text = "Студент"; - groupBoxExam.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridViewExams).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -206,9 +161,5 @@ private Label label3; private ComboBox comboBoxStudentGroup; private Label label4; - private GroupBox groupBoxExam; - private DataGridView dataGridViewExams; - private DataGridViewComboBoxColumn ColumnExam; - private DataGridViewTextBoxColumn ColumnMark; } } \ No newline at end of file diff --git a/ProjectSession/ProjectSession/Forms/FormStudent.cs b/ProjectSession/ProjectSession/Forms/FormStudent.cs index dce6ebe..4c09867 100644 --- a/ProjectSession/ProjectSession/Forms/FormStudent.cs +++ b/ProjectSession/ProjectSession/Forms/FormStudent.cs @@ -53,9 +53,7 @@ namespace ProjectSession.Forms comboBoxStudentGroup.DataSource = groupRepository.ReadGroup(); comboBoxStudentGroup.DisplayMember = "Name"; comboBoxStudentGroup.ValueMember = "Id"; - ColumnExam.DataSource = examRepository.ReadExam(); - ColumnExam.DisplayMember = "Name"; - ColumnExam.ValueMember = "Id"; + foreach (var elem in Enum.GetValues(typeof(StudentStatus))) { @@ -68,7 +66,7 @@ namespace ProjectSession.Forms { try { - if (string.IsNullOrWhiteSpace(textBoxStudentFirstName.Text) || string.IsNullOrWhiteSpace(textBoxStudentLastName.Text) || comboBoxStudentGroup.SelectedIndex < 0|| dataGridViewExams.RowCount < 1) + if (string.IsNullOrWhiteSpace(textBoxStudentFirstName.Text) || string.IsNullOrWhiteSpace(textBoxStudentLastName.Text) || comboBoxStudentGroup.SelectedIndex < 0) { throw new Exception("Имеются незаполненныеполя"); } @@ -94,25 +92,13 @@ namespace ProjectSession.Forms private Student CreateStudent(int id) { - var list = new List(); - foreach (DataGridViewRow row in dataGridViewExams.Rows) - { - if (row.Cells["ColumnExam"].Value == null || - row.Cells["ColumnExam"].Value == null) - { - continue; - } - list.Add(ExamGradeBook.CreateElement(0, - Convert.ToInt32(row.Cells["ColumnExam"].Value), - Convert.ToInt32(row.Cells["ColumnMark"].Value))); - } StudentStatus studentStatus = StudentStatus.None; foreach (var elem in checkedListBoxStudentStatus.CheckedItems) { studentStatus |= (StudentStatus)elem; } - return Student.CreateEntity(id, textBoxStudentFirstName.Text, textBoxStudentLastName.Text, (int)comboBoxStudentGroup.SelectedValue!, studentStatus,list); + return Student.CreateEntity(id, textBoxStudentFirstName.Text, textBoxStudentLastName.Text, (int)comboBoxStudentGroup.SelectedValue!, studentStatus); } } diff --git a/ProjectSession/ProjectSession/Forms/FormStudent.resx b/ProjectSession/ProjectSession/Forms/FormStudent.resx index 92dcece..af32865 100644 --- a/ProjectSession/ProjectSession/Forms/FormStudent.resx +++ b/ProjectSession/ProjectSession/Forms/FormStudent.resx @@ -117,16 +117,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - - - True - \ No newline at end of file diff --git a/ProjectSession/ProjectSession/Forms/FormStudents.Designer.cs b/ProjectSession/ProjectSession/Forms/FormStudents.Designer.cs index 8f28dfd..fecdb70 100644 --- a/ProjectSession/ProjectSession/Forms/FormStudents.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormStudents.Designer.cs @@ -43,9 +43,9 @@ panel1.Controls.Add(buttonDell); panel1.Controls.Add(buttonAdd); panel1.Dock = DockStyle.Right; - panel1.Location = new Point(681, 0); + panel1.Location = new Point(1034, 0); panel1.Name = "panel1"; - panel1.Size = new Size(136, 459); + panel1.Size = new Size(136, 448); panel1.TabIndex = 0; // // buttonUpd @@ -96,14 +96,14 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersVisible = false; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(681, 459); + dataGridView.Size = new Size(1034, 448); dataGridView.TabIndex = 1; // // FormStudents // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(817, 459); + ClientSize = new Size(1170, 448); Controls.Add(dataGridView); Controls.Add(panel1); Name = "FormStudents"; diff --git a/ProjectSession/ProjectSession/Forms/FormTeacher.cs b/ProjectSession/ProjectSession/Forms/FormTeacher.cs index e2cd8ae..ae78bbb 100644 --- a/ProjectSession/ProjectSession/Forms/FormTeacher.cs +++ b/ProjectSession/ProjectSession/Forms/FormTeacher.cs @@ -80,7 +80,7 @@ namespace ProjectSession.Forms private Teacher CreateTeacher(int id) { - var list = new List(); + var list = new List(); foreach (DataGridViewRow row in dataGridViewDisciplines.Rows) { if (row.Cells["ColumnDiscipline"].Value == null || @@ -88,7 +88,7 @@ namespace ProjectSession.Forms { continue; } - list.Add(DisciplineTeachersDistribution.CreateElement(0, + list.Add(DisciplineTeachers.CreateElement(0, Convert.ToInt32(row.Cells["ColumnDiscipline"].Value), Convert.ToInt32(row.Cells["ColumnNumberHours"].Value))); } diff --git a/ProjectSession/ProjectSession/Forms/FormTeachers.Designer.cs b/ProjectSession/ProjectSession/Forms/FormTeachers.Designer.cs index 83aff9b..cfc7caf 100644 --- a/ProjectSession/ProjectSession/Forms/FormTeachers.Designer.cs +++ b/ProjectSession/ProjectSession/Forms/FormTeachers.Designer.cs @@ -52,7 +52,7 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersVisible = false; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(664, 450); + dataGridView.Size = new Size(1052, 494); dataGridView.TabIndex = 3; // // panel1 @@ -61,9 +61,9 @@ panel1.Controls.Add(buttonDell); panel1.Controls.Add(buttonAdd); panel1.Dock = DockStyle.Right; - panel1.Location = new Point(664, 0); + panel1.Location = new Point(1052, 0); panel1.Name = "panel1"; - panel1.Size = new Size(136, 450); + panel1.Size = new Size(136, 494); panel1.TabIndex = 2; // // buttonUpd @@ -103,7 +103,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(1188, 494); Controls.Add(dataGridView); Controls.Add(panel1); Name = "FormTeachers"; diff --git a/ProjectSession/ProjectSession/Repositories/IStudentGradeBookRepository.cs b/ProjectSession/ProjectSession/Repositories/IStudentGradeBookRepository.cs deleted file mode 100644 index 926dba7..0000000 --- a/ProjectSession/ProjectSession/Repositories/IStudentGradeBookRepository.cs +++ /dev/null @@ -1,17 +0,0 @@ -using ProjectSession.Entities; -using ProjectSession.Repositories.Implementations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectSession.Repositories -{ - public interface IStudentGradeBookRepository - { - IEnumerable ReadStudentGradeBook(int? studentId = null, int? examId = null); - void CreateStudentGradeBook(StudentGradeBook studentGradeBook); - void DeleteStudentGradeBook(int id); - } -} diff --git a/ProjectSession/ProjectSession/Repositories/ITeachersDistributionRepository.cs b/ProjectSession/ProjectSession/Repositories/ITeachersDistributionRepository.cs deleted file mode 100644 index a3b36c5..0000000 --- a/ProjectSession/ProjectSession/Repositories/ITeachersDistributionRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using ProjectSession.Entities; - -namespace ProjectSession.Repositories -{ - public interface ITeachersDistributionRepository - { - IEnumerable ReadStudentTeachersDistribution(int? teacherId = null, int? disciplineId = null); - void CreateTeachersDistribution(TeachersDistribution teachersDistribution); - void DeleteTeachersDistribution(int id); - } -} diff --git a/ProjectSession/ProjectSession/Repositories/Implementations/ExamRepository.cs b/ProjectSession/ProjectSession/Repositories/Implementations/ExamRepository.cs index 62e9806..0347863 100644 --- a/ProjectSession/ProjectSession/Repositories/Implementations/ExamRepository.cs +++ b/ProjectSession/ProjectSession/Repositories/Implementations/ExamRepository.cs @@ -6,7 +6,7 @@ namespace ProjectSession.Repositories.Implementations { public void CreateExam(Exam exam) { - + } public IEnumerable ReadExam(DateTime? dateTime = null, int? examId = null, string? name = null) diff --git a/ProjectSession/ProjectSession/Repositories/Implementations/StudentGradeBookRepository.cs b/ProjectSession/ProjectSession/Repositories/Implementations/StudentGradeBookRepository.cs deleted file mode 100644 index df9b25a..0000000 --- a/ProjectSession/ProjectSession/Repositories/Implementations/StudentGradeBookRepository.cs +++ /dev/null @@ -1,20 +0,0 @@ -using ProjectSession.Entities; - -namespace ProjectSession.Repositories.Implementations -{ - public class StudentGradeBookRepository : IStudentGradeBookRepository - { - public void CreateStudentGradeBook(StudentGradeBook studentGradeBook) - { - } - - public void DeleteStudentGradeBook(int id) - { - } - - public IEnumerable ReadStudentGradeBook( int? studentId = null, int? examId = null) - { - return []; - } - } -} diff --git a/ProjectSession/ProjectSession/Repositories/Implementations/StudentRepository.cs b/ProjectSession/ProjectSession/Repositories/Implementations/StudentRepository.cs index d56428a..ee2b50c 100644 --- a/ProjectSession/ProjectSession/Repositories/Implementations/StudentRepository.cs +++ b/ProjectSession/ProjectSession/Repositories/Implementations/StudentRepository.cs @@ -23,7 +23,7 @@ namespace ProjectSession.Repositories.Implementations public Student ReadStudentById(int id) { - return Student.CreateEntity(0, string.Empty,string.Empty,0, StudentStatus.None, []); + return Student.CreateEntity(0, string.Empty,string.Empty,0, StudentStatus.None); } public void UpdateStudent(Student student) diff --git a/ProjectSession/ProjectSession/Repositories/Implementations/TeachersDistributionRepository.cs b/ProjectSession/ProjectSession/Repositories/Implementations/TeachersDistributionRepository.cs deleted file mode 100644 index ee80e6e..0000000 --- a/ProjectSession/ProjectSession/Repositories/Implementations/TeachersDistributionRepository.cs +++ /dev/null @@ -1,25 +0,0 @@ -using ProjectSession.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectSession.Repositories.Implementations -{ - internal class TeachersDistributionRepository : ITeachersDistributionRepository - { - public void CreateTeachersDistribution(TeachersDistribution teachersDistribution) - { - } - - public void DeleteTeachersDistribution(int id) - { - } - - public IEnumerable ReadStudentTeachersDistribution(int? teacherId = null, int? disciplineId = null) - { - return []; - } - } -}