diff --git a/StudentProgress/StudentProgress/Entities/Enums/DisLectE.cs b/StudentProgress/StudentProgress/Entities/Enums/DisLectE.cs new file mode 100644 index 0000000..952a150 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Enums/DisLectE.cs @@ -0,0 +1,9 @@ +namespace StudentProgress.Entities.Enums; + +public enum DisLectE +{ + None = 0, + Praktika = 1, + Lecturer = 2, + Labaratory = 3 +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/Enums/Grade.cs b/StudentProgress/StudentProgress/Entities/Enums/Grade.cs new file mode 100644 index 0000000..cdad9ee --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Enums/Grade.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StudentProgress.Entities.Enums; + +public enum Grade +{ + None = 0, //пересдача + Two = 1, + Three = 2, + Four = 3, + Five = 4, + Zachet = 5 +} diff --git a/StudentProgress/StudentProgress/Entities/Enums/TypeOfWork.cs b/StudentProgress/StudentProgress/Entities/Enums/TypeOfWork.cs new file mode 100644 index 0000000..ace312a --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Enums/TypeOfWork.cs @@ -0,0 +1,10 @@ +namespace StudentProgress.Entities.Enums; +[Flags] +public enum TypeOfWork +{ + None = 0, //неизвестная работа + Exam = 1, + Zachet = 2, + Referat = 4, + Laba = 8, +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/Grades.cs b/StudentProgress/StudentProgress/Entities/Grades.cs new file mode 100644 index 0000000..7d77a90 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Grades.cs @@ -0,0 +1,20 @@ +namespace StudentProgress.Entities; + +public class Grades +{ + public int Id { get; private set; } + public int SubjectsId { get; private set; } + public int ProfessorsId { get; private set; } + public DateTime Date { get; private set; } + + public static Grades CreateEntity(int id, int subjectsId, int professorsId, DateTime date) + { + return new Grades + { + Id = id, + SubjectsId = subjectsId, + ProfessorsId = professorsId, + Date = date + }; + } +} diff --git a/StudentProgress/StudentProgress/Entities/Group.cs b/StudentProgress/StudentProgress/Entities/Group.cs new file mode 100644 index 0000000..8f88960 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Group.cs @@ -0,0 +1,17 @@ +namespace StudentProgress.Entities +{ + public class Group + { + public int Id { get; private set; } + public string NameGroup { get; set; } = string.Empty; + + public static Group CreateEntity(int id, string nameGroup) + { + return new Group + { + Id = id, + NameGroup = nameGroup ?? string.Empty + }; + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/Lectures.cs b/StudentProgress/StudentProgress/Entities/Lectures.cs new file mode 100644 index 0000000..0011c5c --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Lectures.cs @@ -0,0 +1,35 @@ +namespace StudentProgress.Entities +{ + public class Lectures + { + public int LectureId { get; private set; } + public int ProfessorsId { get; private set; } + public DateTime Date { get; private set; } + public string Auditorium { get; private set; } + + public Lectures() + { + Auditorium = string.Empty; // Инициализация свойства Auditorium + } + + public void SetProfessorsId(int professorsId) + { + ProfessorsId = professorsId; + } + + public void SetDate(DateTime date) + { + Date = date; + } + + public void SetLectureId(int lectureId) + { + LectureId = lectureId; + } + + public void SetAuditorium(string auditorium) + { + Auditorium = auditorium; + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/Professors.cs b/StudentProgress/StudentProgress/Entities/Professors.cs new file mode 100644 index 0000000..44584d4 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Professors.cs @@ -0,0 +1,17 @@ +namespace StudentProgress.Entities; + +public class Professors +{ + public int Id { get; set; } + public string FirstNameProfessor { get; set; } = string.Empty; + public string SurnameProfessor { get; set; } = string.Empty; + public static Professors CreateEntity(int id, string firstName, string SurnameProfessor) + { + return new Professors + { + Id = id, + FirstNameProfessor = firstName ?? string.Empty, + SurnameProfessor = SurnameProfessor ?? string.Empty + }; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/Student.cs b/StudentProgress/StudentProgress/Entities/Student.cs new file mode 100644 index 0000000..564c195 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Student.cs @@ -0,0 +1,21 @@ +namespace StudentProgress.Entities +{ + public class Student + { + public int Id { get; private set; } + public string Name { get; set; } = string.Empty; + public string Surname { get; set; } = string.Empty; + public int GroupId { get; set; } + + public static Student CreateEntity(int id, string name, string surname, int groupId) + { + return new Student + { + Id = id, + Name = name ?? string.Empty, + Surname = surname ?? string.Empty, + GroupId = groupId + }; + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/StudentGrades.cs b/StudentProgress/StudentProgress/Entities/StudentGrades.cs new file mode 100644 index 0000000..fd5c062 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/StudentGrades.cs @@ -0,0 +1,19 @@ +using StudentProgress.Entities.Enums; + +namespace StudentProgress.Entities; + +public class StudentGrades +{ + public int Id { get; private set; } + public int StudentID { get; private set; } + public Grade Grade { get; private set; } + public static StudentGrades CreateEntity(int id, int studentID, Grade grade) + { + return new StudentGrades + { + Id = id, + StudentID = studentID, + Grade = grade + }; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Entities/Subjects.cs b/StudentProgress/StudentProgress/Entities/Subjects.cs new file mode 100644 index 0000000..2e68186 --- /dev/null +++ b/StudentProgress/StudentProgress/Entities/Subjects.cs @@ -0,0 +1,17 @@ +namespace StudentProgress.Entities; + +public class Subjects +{ + public int Id { get; private set; } + public string NameSubject { get; private set; } = string.Empty; + + public static Subjects CreateEntity_(int id, string nameSubject) + { + return new Subjects + { + Id = id, + NameSubject = nameSubject ?? string.Empty, + + }; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Form1.Designer.cs b/StudentProgress/StudentProgress/Form1.Designer.cs deleted file mode 100644 index fa0784d..0000000 --- a/StudentProgress/StudentProgress/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace StudentProgress -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/StudentProgress/StudentProgress/Form1.cs b/StudentProgress/StudentProgress/Form1.cs deleted file mode 100644 index 62ad3ac..0000000 --- a/StudentProgress/StudentProgress/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace StudentProgress -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/StudentProgress/StudentProgress/FormStudentProgress.Designer.cs b/StudentProgress/StudentProgress/FormStudentProgress.Designer.cs new file mode 100644 index 0000000..8790753 --- /dev/null +++ b/StudentProgress/StudentProgress/FormStudentProgress.Designer.cs @@ -0,0 +1,149 @@ +namespace StudentProgress +{ + partial class FormStudentProgress + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + DirectoriesToolStripMenuItem = new ToolStripMenuItem(); + GroupsToolStripMenuItem = new ToolStripMenuItem(); + StudentsToolStripMenuItem = new ToolStripMenuItem(); + ProfessorsToolStripMenuItem = new ToolStripMenuItem(); + SubjectsToolStripMenuItem = new ToolStripMenuItem(); + OperationsToolStripMenuItem = new ToolStripMenuItem(); + GradesToolStripMenuItem = new ToolStripMenuItem(); + LecturesCountToolStripMenuItem = new ToolStripMenuItem(); + ReportsToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(32, 32); + menuStrip1.Items.AddRange(new ToolStripItem[] { DirectoriesToolStripMenuItem, OperationsToolStripMenuItem, ReportsToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Padding = new Padding(13, 5, 0, 5); + menuStrip1.Size = new Size(915, 48); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // DirectoriesToolStripMenuItem + // + DirectoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { GroupsToolStripMenuItem, StudentsToolStripMenuItem, ProfessorsToolStripMenuItem, SubjectsToolStripMenuItem }); + DirectoriesToolStripMenuItem.Name = "DirectoriesToolStripMenuItem"; + DirectoriesToolStripMenuItem.Size = new Size(184, 38); + DirectoriesToolStripMenuItem.Text = "Справочники"; + // + // GroupsToolStripMenuItem + // + GroupsToolStripMenuItem.Name = "GroupsToolStripMenuItem"; + GroupsToolStripMenuItem.Size = new Size(359, 44); + GroupsToolStripMenuItem.Text = "Группы"; + GroupsToolStripMenuItem.Click += GroupToolStripMenuItem_Click; + // + // StudentsToolStripMenuItem + // + StudentsToolStripMenuItem.Name = "StudentsToolStripMenuItem"; + StudentsToolStripMenuItem.Size = new Size(359, 44); + StudentsToolStripMenuItem.Text = "Студенты"; + StudentsToolStripMenuItem.Click += StudentToolStripMenuItem_Click; + // + // ProfessorsToolStripMenuItem + // + ProfessorsToolStripMenuItem.Name = "ProfessorsToolStripMenuItem"; + ProfessorsToolStripMenuItem.Size = new Size(359, 44); + ProfessorsToolStripMenuItem.Text = "Преподаватели"; + ProfessorsToolStripMenuItem.Click += ProfessorToolStripMenuItem_Click; + // + // SubjectsToolStripMenuItem + // + SubjectsToolStripMenuItem.Name = "SubjectsToolStripMenuItem"; + SubjectsToolStripMenuItem.Size = new Size(359, 44); + SubjectsToolStripMenuItem.Text = "Предметы"; + SubjectsToolStripMenuItem.Click += SubjectToolStripMenuItem_Click; + // + // OperationsToolStripMenuItem + // + OperationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { GradesToolStripMenuItem, LecturesCountToolStripMenuItem }); + OperationsToolStripMenuItem.Name = "OperationsToolStripMenuItem"; + OperationsToolStripMenuItem.Size = new Size(147, 38); + OperationsToolStripMenuItem.Text = "Операции"; + // + // GradesToolStripMenuItem + // + GradesToolStripMenuItem.Name = "GradesToolStripMenuItem"; + GradesToolStripMenuItem.Size = new Size(285, 44); + GradesToolStripMenuItem.Text = "Оценки"; + GradesToolStripMenuItem.Click += GradeToolStripMenuItem_Click; + // + // LecturesCountToolStripMenuItem + // + LecturesCountToolStripMenuItem.Name = "LecturesCountToolStripMenuItem"; + LecturesCountToolStripMenuItem.Size = new Size(285, 44); + LecturesCountToolStripMenuItem.Text = "Учет лекций"; + LecturesCountToolStripMenuItem.Click += LecturesCountToolStripMenuItem_Click; + // + // ReportsToolStripMenuItem + // + ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"; + ReportsToolStripMenuItem.Size = new Size(116, 38); + ReportsToolStripMenuItem.Text = "Отчеты"; + // + // FormStudentProgress + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.BackGround; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(915, 559); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Margin = new Padding(6, 7, 6, 7); + Name = "FormStudentProgress"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Учет успеваемости студентов"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem DirectoriesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem GroupsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem StudentsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem ProfessorsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem SubjectsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem OperationsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem GradesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem LecturesCountToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem ReportsToolStripMenuItem; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/FormStudentProgress.cs b/StudentProgress/StudentProgress/FormStudentProgress.cs new file mode 100644 index 0000000..27b7e61 --- /dev/null +++ b/StudentProgress/StudentProgress/FormStudentProgress.cs @@ -0,0 +1,102 @@ +using StudentProgress.Forms; +using Unity; +using System; +using System.Windows.Forms; + +namespace StudentProgress +{ + public partial class FormStudentProgress : Form + { + private readonly IUnityContainer _container; + + public FormStudentProgress(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void GroupToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void StudentToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void SubjectToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void GradeToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ProfessorToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void RecordLectureToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LecturesCountToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/FormStudentProgress.resx b/StudentProgress/StudentProgress/FormStudentProgress.resx new file mode 100644 index 0000000..66777ad --- /dev/null +++ b/StudentProgress/StudentProgress/FormStudentProgress.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 25 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGrade.Designer.cs b/StudentProgress/StudentProgress/Forms/FormGrade.Designer.cs new file mode 100644 index 0000000..ba4e515 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGrade.Designer.cs @@ -0,0 +1,219 @@ +namespace StudentProgress.Forms +{ + partial class FormGrade + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + dateTimePicker1 = new DateTimePicker(); + comboBoxSubject = new ComboBox(); + comboBoxProfessor = new ComboBox(); + checkedListBoxType = new CheckedListBox(); + groupBox1 = new GroupBox(); + groupBox2 = new GroupBox(); + dataGridView1 = new DataGridView(); + ColumnStudent = new DataGridViewComboBoxColumn(); + groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(62, 49); + label1.Name = "label1"; + label1.Size = new Size(94, 32); + label1.TabIndex = 0; + label1.Text = "Работа:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(62, 272); + label2.Name = "label2"; + label2.Size = new Size(116, 32); + label2.TabIndex = 1; + label2.Text = "Предмет:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(62, 370); + label3.Name = "label3"; + label3.Size = new Size(191, 32); + label3.TabIndex = 2; + label3.Text = "Преподователь:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(62, 481); + label4.Name = "label4"; + label4.Size = new Size(70, 32); + label4.TabIndex = 3; + label4.Text = "Дата:"; + // + // buttonSave + // + buttonSave.Location = new Point(62, 625); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 46); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(357, 625); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 46); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // dateTimePicker1 + // + dateTimePicker1.Location = new Point(178, 481); + dateTimePicker1.Name = "dateTimePicker1"; + dateTimePicker1.Size = new Size(400, 39); + dateTimePicker1.TabIndex = 6; + // + // comboBoxSubject + // + comboBoxSubject.FormattingEnabled = true; + comboBoxSubject.Location = new Point(267, 272); + comboBoxSubject.Name = "comboBoxSubject"; + comboBoxSubject.Size = new Size(242, 40); + comboBoxSubject.TabIndex = 8; + // + // comboBoxProfessor + // + comboBoxProfessor.FormattingEnabled = true; + comboBoxProfessor.Location = new Point(267, 370); + comboBoxProfessor.Name = "comboBoxProfessor"; + comboBoxProfessor.Size = new Size(242, 40); + comboBoxProfessor.TabIndex = 9; + // + // checkedListBoxType + // + checkedListBoxType.FormattingEnabled = true; + checkedListBoxType.Location = new Point(267, 49); + checkedListBoxType.Name = "checkedListBoxType"; + checkedListBoxType.Size = new Size(240, 184); + checkedListBoxType.TabIndex = 10; + // + // groupBox1 + // + groupBox1.Location = new Point(680, 158); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(400, 200); + groupBox1.TabIndex = 11; + groupBox1.TabStop = false; + groupBox1.Text = "groupBox1"; + // + // groupBox2 + // + groupBox2.Controls.Add(dataGridView1); + groupBox2.Location = new Point(627, 49); + groupBox2.Margin = new Padding(6); + groupBox2.Name = "groupBox2"; + groupBox2.Padding = new Padding(6); + groupBox2.Size = new Size(519, 622); + groupBox2.TabIndex = 12; + groupBox2.TabStop = false; + groupBox2.Text = "Оценка"; + // + // dataGridView1 + // + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnStudent }); + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(6, 38); + dataGridView1.Margin = new Padding(6); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowHeadersWidth = 82; + dataGridView1.Size = new Size(507, 578); + dataGridView1.TabIndex = 0; + // + // ColumnStudent + // + ColumnStudent.HeaderText = "Студент"; + ColumnStudent.MinimumWidth = 10; + ColumnStudent.Name = "ColumnStudent"; + // + // FormGrade + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1161, 779); + Controls.Add(groupBox2); + Controls.Add(groupBox1); + Controls.Add(checkedListBoxType); + Controls.Add(comboBoxProfessor); + Controls.Add(comboBoxSubject); + Controls.Add(dateTimePicker1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormGrade"; + Text = "Оценка"; + Load += FormGrade_Load; + groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private Button buttonSave; + private Button buttonCancel; + private DateTimePicker dateTimePicker1; + private ComboBox comboBoxSubject; + private ComboBox comboBoxProfessor; + private CheckedListBox checkedListBoxType; + private GroupBox groupBox1; + private GroupBox groupBox2; + private DataGridView dataGridView1; + private DataGridViewComboBoxColumn ColumnStudent; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGrade.cs b/StudentProgress/StudentProgress/Forms/FormGrade.cs new file mode 100644 index 0000000..3f43ae9 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGrade.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; +using StudentProgress.Entities; +using StudentProgress.Entities.Enums; +using StudentProgress.Repositories; + +namespace StudentProgress.Forms +{ + public partial class FormGrade : Form + { + private readonly IGradesRepository _gradesRepository; + private readonly ISubjectsRepository _subjectsRepository; + private readonly IProfessorsNameRepository _professorsRepository; + private readonly IStudentRepository _studentRepository; + + public FormGrade(IGradesRepository gradesRepository, ISubjectsRepository subjectsRepository, + IProfessorsNameRepository professorsRepository, IStudentRepository studentRepository) + { + InitializeComponent(); + _gradesRepository = gradesRepository ?? throw new ArgumentNullException(nameof(gradesRepository)); + _subjectsRepository = subjectsRepository ?? throw new ArgumentNullException(nameof(subjectsRepository)); + _professorsRepository = professorsRepository ?? throw new ArgumentNullException(nameof(professorsRepository)); + _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); + + LoadWorkTypes(); + LoadSubjects(); + LoadProfessors(); + LoadStudents(); + } + + private void LoadWorkTypes() + { + foreach (var elem in Enum.GetValues(typeof(TypeOfWork))) + { + checkedListBoxType.Items.Add(elem); + } + } + + private void LoadSubjects() + { + var subjects = _subjectsRepository.ReadSubjects(); + comboBoxSubject.DataSource = subjects; + comboBoxSubject.DisplayMember = "NameSubject"; + comboBoxSubject.ValueMember = "Id"; + } + + private void LoadProfessors() + { + var professors = _professorsRepository.ReadProfessorsName(); + comboBoxProfessor.DataSource = professors; + comboBoxProfessor.DisplayMember = "FirstNameProfessor"; + comboBoxProfessor.ValueMember = "Id"; + } + + private void LoadStudents() + { + var students = _studentRepository.ReadStudents(); + ColumnStudent.DataSource = students; + ColumnStudent.DisplayMember = "Name"; + ColumnStudent.ValueMember = "Id"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxSubject.SelectedIndex < 0 || checkedListBoxType.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + CreateGrade(0); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Grades CreateGrade(int id) + { + TypeOfWork typeOfWork = TypeOfWork.None; + foreach (var elem in checkedListBoxType.CheckedItems) + { + typeOfWork |= (TypeOfWork)elem; + } + return Grades.CreateEntity(id, (int)comboBoxSubject.SelectedValue, (int)comboBoxProfessor.SelectedValue, dateTimePicker1.Value); + } + + private void FormGrade_Load(object sender, EventArgs e) + { + var columnGrade = new DataGridViewComboBoxColumn + { + Name = "ColumnGrade", + HeaderText = "Оценка", + DataSource = Enum.GetValues(typeof(Grade)) + }; + + if (dataGridView1.Columns["ColumnGrade"] != null) + { + dataGridView1.Columns.Remove("ColumnGrade"); + } + + dataGridView1.Columns.Add(columnGrade); + } + + private List CreateListFeedFeedReplenishmentsFromDataGrid() + { + var list = new List(); + foreach (DataGridViewRow row in dataGridView1.Rows) + { + if (row.Cells["ColumnStudent"].Value == null || row.Cells["ColumnGrade"].Value == null) + { + continue; + } + list.Add(StudentGrades.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnStudent"].Value), (Grade)(row.Cells["ColumnGrade"].Value))); + } + return list; + } + } +} diff --git a/StudentProgress/StudentProgress/Forms/FormGrade.resx b/StudentProgress/StudentProgress/Forms/FormGrade.resx new file mode 100644 index 0000000..831d2a4 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGrade.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 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/StudentProgress/StudentProgress/Forms/FormGrades.Designer.cs b/StudentProgress/StudentProgress/Forms/FormGrades.Designer.cs new file mode 100644 index 0000000..971a6ae --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGrades.Designer.cs @@ -0,0 +1,110 @@ +namespace StudentProgress.Forms +{ + partial class FormGrades + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(548, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(75, 271); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(7, 93); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(56, 53); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(7, 34); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(56, 53); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + 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.Size = new Size(548, 271); + dataGridView.TabIndex = 1; + // + // FormGrades + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(623, 271); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormGrades"; + Text = "Оценки"; + Load += FormGrades_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonDel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGrades.cs b/StudentProgress/StudentProgress/Forms/FormGrades.cs new file mode 100644 index 0000000..a1a42ba --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGrades.cs @@ -0,0 +1,80 @@ +using System; +using System.Windows.Forms; +using Unity; +using StudentProgress.Repositories; + +namespace StudentProgress.Forms +{ + public partial class FormGrades : Form + { + private readonly IUnityContainer _container; + private readonly IGradesRepository _gradesRepository; + + public FormGrades(IUnityContainer container, IGradesRepository gradesRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _gradesRepository = gradesRepository ?? throw new ArgumentNullException(nameof(gradesRepository)); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormGrades_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _gradesRepository.ReadGrades(); + + 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; + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _gradesRepository.DeleteGrade(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Form1.resx b/StudentProgress/StudentProgress/Forms/FormGrades.resx similarity index 92% rename from StudentProgress/StudentProgress/Form1.resx rename to StudentProgress/StudentProgress/Forms/FormGrades.resx index 1af7de1..8b2ff64 100644 --- a/StudentProgress/StudentProgress/Form1.resx +++ b/StudentProgress/StudentProgress/Forms/FormGrades.resx @@ -1,17 +1,17 @@  - diff --git a/StudentProgress/StudentProgress/Forms/FormGroup.Designer.cs b/StudentProgress/StudentProgress/Forms/FormGroup.Designer.cs new file mode 100644 index 0000000..a8e7978 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGroup.Designer.cs @@ -0,0 +1,108 @@ +using static System.Net.Mime.MediaTypeNames; +using System.Drawing.Printing; +using System.Windows.Forms; +using System.Xml.Linq; + +namespace StudentProgress.Forms +{ + partial class FormGroup + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + textBoxNameGroup = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(76, 68); + label1.Margin = new Padding(6, 0, 6, 0); + label1.Name = "label1"; + label1.Size = new Size(212, 32); + label1.TabIndex = 0; + label1.Text = "Название группы:"; + // + // textBoxNameGroup + // + textBoxNameGroup.Location = new Point(338, 61); + textBoxNameGroup.Margin = new Padding(6); + textBoxNameGroup.Name = "textBoxNameGroup"; + textBoxNameGroup.Size = new Size(232, 39); + textBoxNameGroup.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(74, 373); + buttonSave.Margin = new Padding(6); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(189, 62); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(338, 373); + buttonCancel.Margin = new Padding(6); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(189, 62); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + + // + // FormGroup + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(644, 461); + + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxNameGroup); + Controls.Add(label1); + Margin = new Padding(6); + Name = "FormGroup"; + StartPosition = FormStartPosition.CenterParent; + Text = "Группа"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private TextBox textBoxNameGroup; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGroup.cs b/StudentProgress/StudentProgress/Forms/FormGroup.cs new file mode 100644 index 0000000..bcc2fbd --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGroup.cs @@ -0,0 +1,83 @@ +using StudentProgress.Entities; +using StudentProgress.Entities.Enums; +using StudentProgress.Repositories; +using StudentProgress.Repositories.Implementations; + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + public partial class FormGroup : Form + { + private readonly IGroupRepository _groupRepository; + private int? _groupId; + + public FormGroup(IGroupRepository groupRepository) + { + InitializeComponent(); + _groupRepository = groupRepository ?? throw new ArgumentNullException(nameof(groupRepository)); + + } + + public int Id + { + set + { + try + { + var group = _groupRepository.ReadGroupById(value); + if (group == null) + { + throw new + InvalidDataException(nameof(group)); + } + textBoxNameGroup.Text = group.NameGroup; + _groupId = value; + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxNameGroup.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_groupId.HasValue) + { + _groupRepository.UpdateGroup(CreateGroup(_groupId.Value)); + } + else + { + _groupRepository.CreateGroup(CreateGroup(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + private Group CreateGroup(int id) => Group.CreateEntity(id, textBoxNameGroup.Text); + } +} diff --git a/StudentProgress/StudentProgress/Forms/FormGroup.resx b/StudentProgress/StudentProgress/Forms/FormGroup.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGroup.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGroups.Designer.cs b/StudentProgress/StudentProgress/Forms/FormGroups.Designer.cs new file mode 100644 index 0000000..39004b1 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGroups.Designer.cs @@ -0,0 +1,122 @@ +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + partial class FormGroups + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonPencil = new Button(); + buttonDel = new Button(); + panel1 = new Panel(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(26, 30); + dataGridView.Margin = new Padding(6, 7, 6, 7); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 82; + dataGridView.Size = new Size(635, 569); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 37); + buttonAdd.Margin = new Padding(6, 7, 6, 7); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(162, 115); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonPencil + // + buttonPencil.BackgroundImage = Properties.Resources.Pencil; + buttonPencil.BackgroundImageLayout = ImageLayout.Stretch; + buttonPencil.Location = new Point(28, 224); + buttonPencil.Margin = new Padding(6, 7, 6, 7); + buttonPencil.Name = "buttonPencil"; + buttonPencil.Size = new Size(162, 127); + buttonPencil.TabIndex = 2; + buttonPencil.UseVisualStyleBackColor = true; + buttonPencil.Click += buttonPencil_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(28, 390); + buttonDel.Margin = new Padding(6, 7, 6, 7); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(162, 127); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonPencil); + panel1.Location = new Point(693, 30); + panel1.Name = "panel1"; + panel1.Size = new Size(214, 569); + panel1.TabIndex = 4; + // + // FormGroups + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(919, 628); + Controls.Add(panel1); + Controls.Add(dataGridView); + Margin = new Padding(6, 7, 6, 7); + Name = "FormGroups"; + Text = "Группы"; + Load += FormGroups_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridView; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.Button buttonPencil; + private System.Windows.Forms.Button buttonDel; + private Panel panel1; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGroups.cs b/StudentProgress/StudentProgress/Forms/FormGroups.cs new file mode 100644 index 0000000..4eb8d99 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGroups.cs @@ -0,0 +1,103 @@ +using StudentProgress.Forms; +using StudentProgress.Repositories; +using Unity; + +namespace StudentProgress.Forms +{ + public partial class FormGroups : Form + { + private readonly IUnityContainer _container; + private readonly IGroupRepository _groupRepository; + + public FormGroups(IUnityContainer container, IGroupRepository groupRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _groupRepository = groupRepository ?? throw new ArgumentNullException(nameof(groupRepository)); + } + private void FormGroups_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonPencil_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.ShowDialog(); + form.Id = findId; + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _groupRepository.DeleteGroup(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _groupRepository.ReadGroup(); + + 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; + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormGroups.resx b/StudentProgress/StudentProgress/Forms/FormGroups.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormGroups.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormLecturesCount.Designer.cs b/StudentProgress/StudentProgress/Forms/FormLecturesCount.Designer.cs new file mode 100644 index 0000000..349cc40 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormLecturesCount.Designer.cs @@ -0,0 +1,106 @@ +namespace StudentProgress.Forms +{ + partial class FormLecturesCount + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + LecturesDataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonDel = new Button(); + panel1 = new Panel(); + ((System.ComponentModel.ISupportInitialize)LecturesDataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // LecturesDataGridView + // + LecturesDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + LecturesDataGridView.Location = new Point(15, 16); + LecturesDataGridView.Margin = new Padding(6, 7, 6, 7); + LecturesDataGridView.Name = "LecturesDataGridView"; + LecturesDataGridView.RowHeadersWidth = 82; + LecturesDataGridView.Size = new Size(841, 459); + LecturesDataGridView.TabIndex = 0; + LecturesDataGridView.CellContentClick += LecturesDataGridView_CellContentClick; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 36); + buttonAdd.Margin = new Padding(13, 17, 13, 17); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(155, 128); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(25, 281); + buttonDel.Margin = new Padding(13, 17, 13, 17); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(158, 138); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Controls.Add(buttonDel); + panel1.Location = new Point(885, 16); + panel1.Name = "panel1"; + panel1.Size = new Size(216, 452); + panel1.TabIndex = 3; + // + // FormLecturesCount + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1112, 493); + Controls.Add(panel1); + Controls.Add(LecturesDataGridView); + Margin = new Padding(6, 7, 6, 7); + Name = "FormLecturesCount"; + Text = "Учет лекций"; + Load += FormLecturesCount_Load; + ((System.ComponentModel.ISupportInitialize)LecturesDataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.DataGridView LecturesDataGridView; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.Button buttonDel; + private Panel panel1; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormLecturesCount.cs b/StudentProgress/StudentProgress/Forms/FormLecturesCount.cs new file mode 100644 index 0000000..c9fe297 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormLecturesCount.cs @@ -0,0 +1,96 @@ +using StudentProgress.Entities; +using StudentProgress.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + public partial class FormLecturesCount : Form + { + private readonly IProfessorsNameRepository _professorsRepository; + private readonly ILecturesRepository _lecturesRepository; + + public FormLecturesCount(IProfessorsNameRepository professorsRepository, ILecturesRepository lecturesRepository) + { + InitializeComponent(); + _professorsRepository = professorsRepository; + _lecturesRepository = lecturesRepository; + } + + private void FormLecturesCount_Load(object sender, EventArgs e) + { + LoadLectures(); + } + + private void LoadLectures() + { + var lectures = _lecturesRepository.ReadLectures(); + var lectureViewModels = new List(); + + foreach (var lecture in lectures) + { + var professor = _professorsRepository.ReadProfessorsNameById(lecture.ProfessorsId); + lectureViewModels.Add(new LectureViewModel + { + LectureId = lecture.LectureId, + ProfessorName = $"{professor.FirstNameProfessor} {professor.SurnameProfessor}", + Auditorium = lecture.Auditorium, + Date = lecture.Date + }); + } + + LecturesDataGridView.DataSource = lectureViewModels; + } + private void buttonAdd_Click(object sender, EventArgs e) + { + using (var formRecordLecture = new FormRecordLecture(_professorsRepository, _lecturesRepository)) + { + formRecordLecture.ShowDialog(); + LoadLectures(); // Обновляем данные после закрытия формы + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (LecturesDataGridView.SelectedRows.Count > 0) + { + var selectedRow = LecturesDataGridView.SelectedRows[0]; + var lectureViewModel = selectedRow.DataBoundItem as LectureViewModel; + + if (lectureViewModel != null) + { + // Логика удаления лекции + _lecturesRepository.DeleteLecture(lectureViewModel.LectureId); + + MessageBox.Show("Лекция успешно удалена!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + LoadLectures(); // Обновляем данные после удаления + } + } + else + { + MessageBox.Show("Выберите лекцию для удаления.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void LecturesDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + } + + public class LectureViewModel + { + public int LectureId { get; set; } + public string ProfessorName { get; set; } + public string Auditorium { get; set; } + public DateTime Date { get; set; } + + public LectureViewModel() + { + ProfessorName = string.Empty; // Инициализация свойства ProfessorName + Auditorium = string.Empty; // Инициализация свойства Auditorium + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormLecturesCount.resx b/StudentProgress/StudentProgress/Forms/FormLecturesCount.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormLecturesCount.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormProfesor.Designer.cs b/StudentProgress/StudentProgress/Forms/FormProfesor.Designer.cs new file mode 100644 index 0000000..e7785f5 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormProfesor.Designer.cs @@ -0,0 +1,124 @@ +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + partial class FormProfessor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + textBoxFirstName = new TextBox(); + textBoxSurname = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + label1 = new Label(); + label2 = new Label(); + SuspendLayout(); + // + // textBoxFirstName + // + textBoxFirstName.Location = new Point(235, 28); + textBoxFirstName.Margin = new Padding(6, 7, 6, 7); + textBoxFirstName.Name = "textBoxFirstName"; + textBoxFirstName.Size = new Size(252, 39); + textBoxFirstName.TabIndex = 0; + // + // textBoxSurname + // + textBoxSurname.Location = new Point(235, 105); + textBoxSurname.Margin = new Padding(6, 7, 6, 7); + textBoxSurname.Name = "textBoxSurname"; + textBoxSurname.Size = new Size(306, 39); + textBoxSurname.TabIndex = 1; + // + // buttonSave + // + buttonSave.Location = new Point(53, 233); + buttonSave.Margin = new Padding(6, 7, 6, 7); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(162, 57); + buttonSave.TabIndex = 2; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(286, 233); + buttonCancel.Margin = new Padding(6, 7, 6, 7); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(162, 57); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(53, 31); + label1.Name = "label1"; + label1.Size = new Size(66, 32); + label1.TabIndex = 4; + label1.Text = "Имя:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(53, 105); + label2.Name = "label2"; + label2.Size = new Size(113, 32); + label2.TabIndex = 5; + label2.Text = "Фамилия"; + // + // FormProfessor + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(695, 354); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxSurname); + Controls.Add(textBoxFirstName); + Margin = new Padding(6, 7, 6, 7); + Name = "FormProfessor"; + Text = "Преподаватель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.TextBox textBoxFirstName; + private System.Windows.Forms.TextBox textBoxSurname; + private System.Windows.Forms.Button buttonSave; + private System.Windows.Forms.Button buttonCancel; + private Label label1; + private Label label2; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormProfesor.cs b/StudentProgress/StudentProgress/Forms/FormProfesor.cs new file mode 100644 index 0000000..51b5532 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormProfesor.cs @@ -0,0 +1,71 @@ +using StudentProgress.Entities; +using StudentProgress.Repositories; +using System; +using System.IO; +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + public partial class FormProfessor : Form + { + private readonly IProfessorsNameRepository _professorsRepository; + private int? _professorId; + + public int Id + { + set + { + try + { + var professor = _professorsRepository.ReadProfessorsNameById(value); + if (professor == null) + { + throw new InvalidDataException(nameof(professor)); + } + textBoxFirstName.Text = professor.FirstNameProfessor; + textBoxSurname.Text = professor.SurnameProfessor; + _professorId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormProfessor(IProfessorsNameRepository professorsRepository) + { + InitializeComponent(); + _professorsRepository = professorsRepository ?? throw new ArgumentNullException(nameof(professorsRepository)); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) || string.IsNullOrWhiteSpace(textBoxSurname.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_professorId.HasValue) + { + _professorsRepository.UpdateProfessorsName(CreateProfessor(_professorId.Value)); + } + else + { + _professorsRepository.CreateProfessorsName(CreateProfessor(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private Professors CreateProfessor(int id) => Professors.CreateEntity(id, textBoxFirstName.Text, textBoxSurname.Text); + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormProfesor.resx b/StudentProgress/StudentProgress/Forms/FormProfesor.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormProfesor.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormProfessors.Designer.cs b/StudentProgress/StudentProgress/Forms/FormProfessors.Designer.cs new file mode 100644 index 0000000..474138e --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormProfessors.Designer.cs @@ -0,0 +1,110 @@ +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + partial class FormProfessors + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonPencil = new Button(); + buttonDel = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(26, 30); + dataGridView.Margin = new Padding(6, 7, 6, 7); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 82; + dataGridView.Size = new Size(867, 492); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.BackgroundImage = StudentProgress.Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(935, 30); + buttonAdd.Margin = new Padding(6, 7, 6, 7); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(162, 118); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // buttonPencil + // + buttonPencil.BackgroundImage = StudentProgress.Properties.Resources.Pencil; + buttonPencil.BackgroundImageLayout = ImageLayout.Stretch; + buttonPencil.Location = new Point(935, 224); + buttonPencil.Margin = new Padding(6, 7, 6, 7); + buttonPencil.Name = "buttonPencil"; + buttonPencil.Size = new Size(162, 118); + buttonPencil.TabIndex = 2; + buttonPencil.UseVisualStyleBackColor = true; + buttonPencil.Click += buttonPencil_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = StudentProgress.Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(935, 396); + buttonDel.Margin = new Padding(6, 7, 6, 7); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(162, 126); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // FormProfessors + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1148, 628); + Controls.Add(buttonDel); + Controls.Add(buttonPencil); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Margin = new Padding(6, 7, 6, 7); + Name = "FormProfessors"; + Text = "Преподаватели"; + Load += FormProfessors_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridView; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.Button buttonPencil; + private System.Windows.Forms.Button buttonDel; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormProfessors.cs b/StudentProgress/StudentProgress/Forms/FormProfessors.cs new file mode 100644 index 0000000..caa8a76 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormProfessors.cs @@ -0,0 +1,99 @@ +using StudentProgress.Repositories; +using Unity; +using System; +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + public partial class FormProfessors : Form + { + private readonly IUnityContainer _container; + private readonly IProfessorsNameRepository _professorsRepository; + + public FormProfessors(IUnityContainer container, IProfessorsNameRepository professorsRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _professorsRepository = professorsRepository ?? throw new ArgumentNullException(nameof(professorsRepository)); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonPencil_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 buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _professorsRepository.DeleteProfessorsName(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormProfessors_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _professorsRepository.ReadProfessorsName(); + + 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; + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormProfessors.resx b/StudentProgress/StudentProgress/Forms/FormProfessors.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormProfessors.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormRecordLecture.Designer.cs b/StudentProgress/StudentProgress/Forms/FormRecordLecture.Designer.cs new file mode 100644 index 0000000..adacbb6 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormRecordLecture.Designer.cs @@ -0,0 +1,129 @@ +namespace StudentProgress.Forms +{ + partial class FormRecordLecture + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.ProfessorsComboBox = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.DatePicker = new System.Windows.Forms.DateTimePicker(); + this.RecordLectureButton = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.AuditoriumTextBox = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 20); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(78, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Преподаватель:"; + // + // ProfessorsComboBox + // + this.ProfessorsComboBox.FormattingEnabled = true; + this.ProfessorsComboBox.Location = new System.Drawing.Point(96, 17); + this.ProfessorsComboBox.Name = "ProfessorsComboBox"; + this.ProfessorsComboBox.Size = new System.Drawing.Size(200, 21); + this.ProfessorsComboBox.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 50); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(36, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Дата:"; + // + // DatePicker + // + this.DatePicker.Location = new System.Drawing.Point(96, 47); + this.DatePicker.Name = "DatePicker"; + this.DatePicker.Size = new System.Drawing.Size(200, 20); + this.DatePicker.TabIndex = 3; + // + // RecordLectureButton + // + this.RecordLectureButton.Location = new System.Drawing.Point(96, 110); + this.RecordLectureButton.Name = "RecordLectureButton"; + this.RecordLectureButton.Size = new System.Drawing.Size(200, 23); + this.RecordLectureButton.TabIndex = 4; + this.RecordLectureButton.Text = "Записать лекцию"; + this.RecordLectureButton.UseVisualStyleBackColor = true; + this.RecordLectureButton.Click += new System.EventHandler(this.RecordLectureButton_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 80); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(64, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Аудитория:"; + // + // AuditoriumTextBox + // + this.AuditoriumTextBox.Location = new System.Drawing.Point(96, 77); + this.AuditoriumTextBox.Name = "AuditoriumTextBox"; + this.AuditoriumTextBox.Size = new System.Drawing.Size(200, 20); + this.AuditoriumTextBox.TabIndex = 6; + // + // FormRecordLecture + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(314, 151); + this.Controls.Add(this.AuditoriumTextBox); + this.Controls.Add(this.label3); + this.Controls.Add(this.RecordLectureButton); + this.Controls.Add(this.DatePicker); + this.Controls.Add(this.label2); + this.Controls.Add(this.ProfessorsComboBox); + this.Controls.Add(this.label1); + this.Name = "FormRecordLecture"; + this.Text = "Запись лекции"; + this.Load += new System.EventHandler(this.FormRecordLecture_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox ProfessorsComboBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.DateTimePicker DatePicker; + private System.Windows.Forms.Button RecordLectureButton; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox AuditoriumTextBox; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormRecordLecture.cs b/StudentProgress/StudentProgress/Forms/FormRecordLecture.cs new file mode 100644 index 0000000..cfe2fad --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormRecordLecture.cs @@ -0,0 +1,47 @@ +using StudentProgress.Entities; +using StudentProgress.Repositories; +using System; +using System.Windows.Forms; + +namespace StudentProgress.Forms +{ + public partial class FormRecordLecture : Form + { + private readonly IProfessorsNameRepository _professorsRepository; + private readonly ILecturesRepository _lecturesRepository; + + public FormRecordLecture(IProfessorsNameRepository professorsRepository, ILecturesRepository lecturesRepository) + { + InitializeComponent(); + _professorsRepository = professorsRepository; + _lecturesRepository = lecturesRepository; + } + + private void FormRecordLecture_Load(object sender, EventArgs e) + { + LoadProfessors(); + } + + private void LoadProfessors() + { + var professors = _professorsRepository.ReadProfessorsName(); + ProfessorsComboBox.DataSource = professors; + ProfessorsComboBox.DisplayMember = "FirstNameProfessor"; + ProfessorsComboBox.ValueMember = "Id"; + } + + private void RecordLectureButton_Click(object sender, EventArgs e) + { + if (ProfessorsComboBox.SelectedItem is Professors selectedProfessor) + { + var lecture = new Lectures(); + lecture.SetProfessorsId(selectedProfessor.Id); + lecture.SetDate(DatePicker.Value); + lecture.SetAuditorium(AuditoriumTextBox.Text); // Устанавливаем аудиторию + + _lecturesRepository.CreateLecture(lecture); + MessageBox.Show("Лекция успешно записана!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormRecordLecture.resx b/StudentProgress/StudentProgress/Forms/FormRecordLecture.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormRecordLecture.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormStudent.Designer.cs b/StudentProgress/StudentProgress/Forms/FormStudent.Designer.cs new file mode 100644 index 0000000..c3e1261 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormStudent.Designer.cs @@ -0,0 +1,140 @@ +namespace StudentProgress.Forms +{ + partial class FormStudent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelName = new Label(); + labelSurname = new Label(); + labelGroup = new Label(); + textBoxName = new TextBox(); + textBoxSurname = new TextBox(); + comboBoxGroup = new ComboBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(12, 19); + labelName.Name = "labelName"; + labelName.Size = new Size(49, 20); + labelName.TabIndex = 0; + labelName.Text = "Имя:"; + // + // labelSurname + // + labelSurname.AutoSize = true; + labelSurname.Location = new Point(12, 69); + labelSurname.Name = "labelSurname"; + labelSurname.Size = new Size(81, 20); + labelSurname.TabIndex = 1; + labelSurname.Text = "Фамилия:"; + // + // labelGroup + // + labelGroup.AutoSize = true; + labelGroup.Location = new Point(12, 119); + labelGroup.Name = "labelGroup"; + labelGroup.Size = new Size(61, 20); + labelGroup.TabIndex = 2; + labelGroup.Text = "Группа:"; + // + // textBoxName + // + textBoxName.Location = new Point(100, 16); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(200, 27); + textBoxName.TabIndex = 3; + // + // textBoxSurname + // + textBoxSurname.Location = new Point(100, 66); + textBoxSurname.Name = "textBoxSurname"; + textBoxSurname.Size = new Size(200, 27); + textBoxSurname.TabIndex = 4; + // + // comboBoxGroup + // + comboBoxGroup.FormattingEnabled = true; + comboBoxGroup.Location = new Point(100, 116); + comboBoxGroup.Name = "comboBoxGroup"; + comboBoxGroup.Size = new Size(200, 28); + comboBoxGroup.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(12, 169); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(206, 169); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(94, 29); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // FormStudent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(312, 210); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxGroup); + Controls.Add(textBoxSurname); + Controls.Add(textBoxName); + Controls.Add(labelGroup); + Controls.Add(labelSurname); + Controls.Add(labelName); + Name = "FormStudent"; + Text = "Студент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelSurname; + private Label labelGroup; + private TextBox textBoxName; + private TextBox textBoxSurname; + private ComboBox comboBoxGroup; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormStudent.cs b/StudentProgress/StudentProgress/Forms/FormStudent.cs new file mode 100644 index 0000000..bb96eb9 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormStudent.cs @@ -0,0 +1,52 @@ +using System; +using System.Windows.Forms; +using StudentProgress.Repositories; +using StudentProgress.Entities; + +namespace StudentProgress.Forms +{ + public partial class FormStudent : Form + { + private readonly IStudentRepository _studentRepository; + private readonly IGroupRepository _groupRepository; + + public FormStudent(IStudentRepository studentRepository, IGroupRepository groupRepository) + { + InitializeComponent(); + _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); + _groupRepository = groupRepository ?? throw new ArgumentNullException(nameof(groupRepository)); + + LoadGroups(); + } + + private void LoadGroups() + { + var groups = _groupRepository.ReadGroup(); + comboBoxGroup.DataSource = groups; + comboBoxGroup.DisplayMember = "NameGroup"; + comboBoxGroup.ValueMember = "Id"; + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxSurname.Text) || comboBoxGroup.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + var student = Student.CreateEntity(0, textBoxName.Text, textBoxSurname.Text, (int)comboBoxGroup.SelectedValue); + _studentRepository.CreateStudent(student); + MessageBox.Show("Студент успешно добавлен", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormStudent.resx b/StudentProgress/StudentProgress/Forms/FormStudent.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormStudent.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormStudents.Designer.cs b/StudentProgress/StudentProgress/Forms/FormStudents.Designer.cs new file mode 100644 index 0000000..fa130c6 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormStudents.Designer.cs @@ -0,0 +1,124 @@ +namespace StudentProgress.Forms +{ + partial class FormStudents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonPencil = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonPencil); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(548, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(75, 271); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(7, 172); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(56, 53); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonPencil + // + buttonPencil.BackgroundImage = Properties.Resources.Pencil; + buttonPencil.BackgroundImageLayout = ImageLayout.Stretch; + buttonPencil.Location = new Point(7, 93); + buttonPencil.Name = "buttonPencil"; + buttonPencil.Size = new Size(56, 53); + buttonPencil.TabIndex = 1; + buttonPencil.UseVisualStyleBackColor = true; + buttonPencil.Click += buttonPencil_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(7, 34); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(56, 53); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + 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.Size = new Size(548, 271); + dataGridView.TabIndex = 1; + // + // FormStudents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(623, 271); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormStudents"; + Text = "Студенты"; + Load += FormStudents_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonDel; + private Button buttonPencil; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormStudents.cs b/StudentProgress/StudentProgress/Forms/FormStudents.cs new file mode 100644 index 0000000..9b1fe2d --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormStudents.cs @@ -0,0 +1,99 @@ +using System; +using System.Windows.Forms; +using Unity; +using StudentProgress.Repositories; + +namespace StudentProgress.Forms +{ + public partial class FormStudents : Form + { + private readonly IUnityContainer _container; + private readonly IStudentRepository _studentRepository; + + public FormStudents(IUnityContainer container, IStudentRepository studentRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); + } + + private void FormStudents_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonPencil_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + // Здесь нужно добавить логику для загрузки данных в форму редактирования + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _studentRepository.DeleteStudent(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _studentRepository.ReadStudents(); + + 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; + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormStudents.resx b/StudentProgress/StudentProgress/Forms/FormStudents.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormStudents.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormSubject.Designer.cs b/StudentProgress/StudentProgress/Forms/FormSubject.Designer.cs new file mode 100644 index 0000000..4ac615a --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormSubject.Designer.cs @@ -0,0 +1,136 @@ + +namespace StudentPerformance.Forms +{ + partial class FormSubject + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + textBoxName = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + labelName = new Label(); + groupBox = new GroupBox(); + dataGridView = new DataGridView(); + ColumnLast = new DataGridViewComboBoxColumn(); + groupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // textBoxName + // + textBoxName.Location = new Point(183, 47); + textBoxName.Margin = new Padding(6, 7, 6, 7); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(343, 39); + textBoxName.TabIndex = 0; + // + // buttonSave + // + buttonSave.Location = new Point(32, 579); + buttonSave.Margin = new Padding(6, 7, 6, 7); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(162, 57); + buttonSave.TabIndex = 1; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(370, 597); + buttonCancel.Margin = new Padding(6, 7, 6, 7); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(162, 57); + buttonCancel.TabIndex = 2; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(32, 47); + labelName.Margin = new Padding(6, 0, 6, 0); + labelName.Name = "labelName"; + labelName.Size = new Size(111, 32); + labelName.TabIndex = 3; + labelName.Text = "Предмет"; + // + // groupBox + // + groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + groupBox.Controls.Add(dataGridView); + groupBox.Location = new Point(32, 111); + groupBox.Margin = new Padding(6); + groupBox.Name = "groupBox"; + groupBox.Padding = new Padding(6); + groupBox.Size = new Size(494, 435); + groupBox.TabIndex = 3; + groupBox.TabStop = false; + groupBox.Text = "Преподаватели"; + // + // dataGridView + // + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnLast }); + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(6, 38); + dataGridView.Margin = new Padding(6); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(482, 391); + dataGridView.TabIndex = 0; + // + // ColumnLast + // + ColumnLast.HeaderText = "Фамилия преподавателя"; + ColumnLast.MinimumWidth = 10; + ColumnLast.Name = "ColumnLast"; + ColumnLast.Width = 200; + // + // FormSubject + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(590, 719); + Controls.Add(groupBox); + Controls.Add(labelName); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Margin = new Padding(6, 7, 6, 7); + Name = "FormSubject"; + Text = "Предметы"; + Load += FormSubject_Load; + groupBox.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + private System.Windows.Forms.TextBox textBoxName; + private System.Windows.Forms.Button buttonSave; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelName; + private GroupBox groupBox; + private DataGridView dataGridView; + private DataGridViewComboBoxColumn ColumnLast; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormSubject.cs b/StudentProgress/StudentProgress/Forms/FormSubject.cs new file mode 100644 index 0000000..bcea12a --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormSubject.cs @@ -0,0 +1,44 @@ +using StudentProgress.Entities; +using StudentProgress.Repositories; +using System; +using System.Windows.Forms; + +namespace StudentPerformance.Forms +{ + public partial class FormSubject : Form + { + private readonly ISubjectsRepository _subjectsRepository; + + public FormSubject(ISubjectsRepository subjectsRepository) + { + InitializeComponent(); + _subjectsRepository = subjectsRepository ?? throw new ArgumentNullException(nameof(subjectsRepository)); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text)) + { + throw new Exception("Имя предмета не может быть пустым"); + } + + var subject = Subjects.CreateEntity_(0, textBoxName.Text); + _subjectsRepository.CreateSubjects_(subject); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + private void FormSubject_Load(object sender, EventArgs e) + { + // Инициализация формы, если необходимо + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormSubject.resx b/StudentProgress/StudentProgress/Forms/FormSubject.resx new file mode 100644 index 0000000..e9e4f13 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormSubject.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormSubjects.Designer.cs b/StudentProgress/StudentProgress/Forms/FormSubjects.Designer.cs new file mode 100644 index 0000000..8836a53 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormSubjects.Designer.cs @@ -0,0 +1,120 @@ +using static System.Net.Mime.MediaTypeNames; +using System.Windows.Forms; +using System.Xml.Linq; + +namespace StudentProgress.Forms +{ + partial class FormSubjects + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(1018, 0); + panel1.Margin = new Padding(6, 6, 6, 6); + panel1.Name = "panel1"; + panel1.Size = new Size(139, 578); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.Del; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(13, 367); + buttonDel.Margin = new Padding(6, 6, 6, 6); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(104, 113); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.Add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(13, 73); + buttonAdd.Margin = new Padding(6, 6, 6, 6); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(104, 113); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridView + // + 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.Margin = new Padding(6, 6, 6, 6); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.RowHeadersWidth = 82; + dataGridView.Size = new Size(1018, 578); + dataGridView.TabIndex = 1; + // + // FormSubjects + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1157, 578); + Controls.Add(dataGridView); + Controls.Add(panel1); + Margin = new Padding(6, 6, 6, 6); + Name = "FormSubjects"; + Text = "Предметы"; + Load += FormSubjects__Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonDel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormSubjects.cs b/StudentProgress/StudentProgress/Forms/FormSubjects.cs new file mode 100644 index 0000000..c53ec9c --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormSubjects.cs @@ -0,0 +1,58 @@ +using System; +using System.Windows.Forms; +using StudentPerformance.Forms; +using StudentProgress.Repositories; +using StudentProgress.Repositories.Implementations; + +namespace StudentProgress.Forms +{ + public partial class FormSubjects : Form + { + private readonly ISubjectsRepository _subjectsRepository; + + public FormSubjects(ISubjectsRepository subjectsRepository) + { + InitializeComponent(); + _subjectsRepository = subjectsRepository ?? throw new ArgumentNullException(nameof(subjectsRepository)); + } + + private void FormSubjects__Load(object sender, EventArgs e) + { + // Загрузка данных в DataGridView + LoadData(); + } + + private void LoadData() + { + // Пример загрузки данных из репозитория + var subjects = _subjectsRepository.ReadSubjects(); + dataGridView.DataSource = subjects; + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + // Логика добавления нового предмета + using (var form = new FormSubject(new SubjectsRepository())) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + // Логика удаления выбранного предмета + if (dataGridView.SelectedRows.Count > 0) + { + var selectedSubject = dataGridView.SelectedRows[0].DataBoundItem as Entities.Subjects; + if (selectedSubject != null) + { + _subjectsRepository.DeleteSubjects(selectedSubject.Id); + LoadData(); + } + } + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Forms/FormSubjects.resx b/StudentProgress/StudentProgress/Forms/FormSubjects.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/StudentProgress/StudentProgress/Forms/FormSubjects.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Program.cs b/StudentProgress/StudentProgress/Program.cs index f8a0af0..a264a2b 100644 --- a/StudentProgress/StudentProgress/Program.cs +++ b/StudentProgress/StudentProgress/Program.cs @@ -1,17 +1,40 @@ +using StudentProgress.Forms; +using StudentProgress.Repositories; +using StudentProgress.Repositories.Implementations; +using Unity; +using System; +using System.Windows.Forms; + namespace StudentProgress { - internal static class Program + static class Program { - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + var container = new UnityContainer(); + + // + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + // + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + Application.Run(container.Resolve()); } } } \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Properties/Resources.Designer.cs b/StudentProgress/StudentProgress/Properties/Resources.Designer.cs new file mode 100644 index 0000000..95bee35 --- /dev/null +++ b/StudentProgress/StudentProgress/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace StudentProgress.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StudentProgress.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Add { + get { + object obj = ResourceManager.GetObject("Add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BackGround { + get { + object obj = ResourceManager.GetObject("BackGround", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Del { + get { + object obj = ResourceManager.GetObject("Del", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Pencil { + get { + object obj = ResourceManager.GetObject("Pencil", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/StudentProgress/StudentProgress/Properties/Resources.resx b/StudentProgress/StudentProgress/Properties/Resources.resx new file mode 100644 index 0000000..f7da744 --- /dev/null +++ b/StudentProgress/StudentProgress/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\Del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\BackGround.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Pencil.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/IGradesRepository.cs b/StudentProgress/StudentProgress/Repositories/IGradesRepository.cs new file mode 100644 index 0000000..5163c43 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/IGradesRepository.cs @@ -0,0 +1,10 @@ +using StudentProgress.Entities; + +namespace StudentProgress.Repositories; + +public interface IGradesRepository +{ + IEnumerable ReadGrades(DateTime? dateFrom = null, DateTime? dateTo = null, int? subjectsId = null, int? professorsId = null); + void CreateGrade(Grades grade); + void DeleteGrade(int id); +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/IGroupRepository.cs b/StudentProgress/StudentProgress/Repositories/IGroupRepository.cs new file mode 100644 index 0000000..0d4c062 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/IGroupRepository.cs @@ -0,0 +1,12 @@ +using StudentProgress.Entities; + +namespace StudentProgress.Repositories; + +public interface IGroupRepository +{ + IEnumerable ReadGroup(); + Group ReadGroupById(int id); + void CreateGroup(Group group); + void UpdateGroup(Group group); + void DeleteGroup(int id); +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/ILecturesRepository.cs b/StudentProgress/StudentProgress/Repositories/ILecturesRepository.cs new file mode 100644 index 0000000..25c2dd2 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/ILecturesRepository.cs @@ -0,0 +1,12 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories +{ + public interface ILecturesRepository + { + IEnumerable ReadLectures(); + void CreateLecture(Lectures lecture); + void DeleteLecture(int lectureId); + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/IProfessorsNameRepository.cs b/StudentProgress/StudentProgress/Repositories/IProfessorsNameRepository.cs new file mode 100644 index 0000000..672d629 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/IProfessorsNameRepository.cs @@ -0,0 +1,13 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories; + +public interface IProfessorsNameRepository +{ + IEnumerable ReadProfessorsName(); + Professors ReadProfessorsNameById(int id); + void CreateProfessorsName(Professors professorsName); + void UpdateProfessorsName(Professors professorsName); + void DeleteProfessorsName(int id); +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/IStudentsRepository.cs b/StudentProgress/StudentProgress/Repositories/IStudentsRepository.cs new file mode 100644 index 0000000..abe4453 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/IStudentsRepository.cs @@ -0,0 +1,13 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories; + +public interface IStudentRepository +{ + IEnumerable ReadStudents(int? groupID = null); + Student ReadStudentById(int id); + void CreateStudent(Student student); + void UpdateStudent(Student student); + void DeleteStudent(int id); +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/ISubjectsRepository.cs b/StudentProgress/StudentProgress/Repositories/ISubjectsRepository.cs new file mode 100644 index 0000000..d0c8d98 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/ISubjectsRepository.cs @@ -0,0 +1,10 @@ +using StudentProgress.Entities; + +namespace StudentProgress.Repositories; + +public interface ISubjectsRepository +{ + IEnumerable ReadSubjects(int? professorsNameId = null); + void CreateSubjects_(Subjects subject); + void DeleteSubjects(int id); +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/Implementations/GradesRepository.cs b/StudentProgress/StudentProgress/Repositories/Implementations/GradesRepository.cs new file mode 100644 index 0000000..3cb0a6e --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/Implementations/GradesRepository.cs @@ -0,0 +1,29 @@ +using StudentProgress.Entities; +using System; +using System.Collections.Generic; + +namespace StudentProgress.Repositories.Implementations; + +public class GradesRepository : IGradesRepository +{ + public void CreateGrade(Grades grade) + { + // Логика создания оценки + } + + public void DeleteGrade(int id) + { + // Логика удаления оценки по идентификатору + } + + public IEnumerable ReadGrades(DateTime? dateFrom = null, DateTime? dateTo = null, int? subjectsId = null, int? professorsId = null) + { + // Логика чтения оценок с возможностью фильтрации по дате, идентификатору предмета и идентификатору преподавателя + return new List(); + } + + public void UpdateGrade(Grades grade) + { + // Логика обновления оценки + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/Implementations/GroupRepository.cs b/StudentProgress/StudentProgress/Repositories/Implementations/GroupRepository.cs new file mode 100644 index 0000000..0d147a2 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/Implementations/GroupRepository.cs @@ -0,0 +1,50 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories.Implementations +{ + public class GroupRepository : IGroupRepository + { + private readonly List _groups; + + public GroupRepository() + { + // Инициализация тестовых данных + _groups = new List(); + } + + public void CreateGroup(Group group) + { + // Логика создания группы + _groups.Add(group); + } + + public void DeleteGroup(int id) + { + // Логика удаления группы по идентификатору + _groups.RemoveAll(g => g.Id == id); + } + + public IEnumerable ReadGroup() + { + // Логика чтения всех групп + return _groups; + } + + public Group ReadGroupById(int id) + { + // Логика чтения группы по идентификатору + return _groups.Find(g => g.Id == id); + } + + public void UpdateGroup(Group group) + { + // Логика обновления группы + var existingGroup = _groups.Find(g => g.Id == group.Id); + if (existingGroup != null) + { + existingGroup.NameGroup = group.NameGroup; + } + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/Implementations/LecturesRepository.cs b/StudentProgress/StudentProgress/Repositories/Implementations/LecturesRepository.cs new file mode 100644 index 0000000..c7d973f --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/Implementations/LecturesRepository.cs @@ -0,0 +1,32 @@ +using StudentProgress.Entities; +using System.Collections.Generic; +using System.Linq; + +namespace StudentProgress.Repositories.Implementations +{ + public class LecturesRepository : ILecturesRepository + { + private readonly List _lectures = new List(); + + public IEnumerable ReadLectures() + { + return _lectures; + } + + public void CreateLecture(Lectures lecture) + { + int newLectureId = _lectures.Count > 0 ? _lectures.Max(l => l.LectureId) + 1 : 1; + lecture.SetLectureId(newLectureId); + _lectures.Add(lecture); + } + + public void DeleteLecture(int lectureId) + { + var lectureToRemove = _lectures.FirstOrDefault(l => l.LectureId == lectureId); + if (lectureToRemove != null) + { + _lectures.Remove(lectureToRemove); + } + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/Implementations/ProfessorsNameRepository.cs b/StudentProgress/StudentProgress/Repositories/Implementations/ProfessorsNameRepository.cs new file mode 100644 index 0000000..1b5cbf4 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/Implementations/ProfessorsNameRepository.cs @@ -0,0 +1,34 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories.Implementations; + +public class ProfessorsNameRepository : IProfessorsNameRepository +{ + public void CreateProfessorsName(Professors professorsName) + { + // Логика создания преподавателя + } + + public void DeleteProfessorsName(int id) + { + // Логика удаления преподавателя по идентификатору + } + + public IEnumerable ReadProfessorsName() + { + // Логика чтения всех преподавателей + return new List(); + } + + public Professors ReadProfessorsNameById(int id) + { + // Логика чтения преподавателя по идентификатору + return Professors.CreateEntity(id, "Unknown", "Unknown"); + } + + public void UpdateProfessorsName(Professors professorsName) + { + // Логика обновления преподавателя + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/Implementations/StudentRepository.cs b/StudentProgress/StudentProgress/Repositories/Implementations/StudentRepository.cs new file mode 100644 index 0000000..826e429 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/Implementations/StudentRepository.cs @@ -0,0 +1,56 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories.Implementations +{ + public class StudentRepository : IStudentRepository + { + private readonly List _students; + + public StudentRepository() + { + // Инициализация пустого списка студентов + _students = new List(); + } + + public void CreateStudent(Student student) + { + // Логика создания студента + _students.Add(student); + } + + public void DeleteStudent(int id) + { + // Логика удаления студента по идентификатору + _students.RemoveAll(s => s.Id == id); + } + + public Student ReadStudentById(int id) + { + // Логика чтения студента по идентификатору + return _students.Find(s => s.Id == id); + } + + public IEnumerable ReadStudents(int? groupID = null) + { + // Логика чтения всех студентов с возможностью фильтрации по идентификатору группы + if (groupID.HasValue) + { + return _students.FindAll(s => s.GroupId == groupID.Value); + } + return _students; + } + + public void UpdateStudent(Student student) + { + // Логика обновления студента + var existingStudent = _students.Find(s => s.Id == student.Id); + if (existingStudent != null) + { + existingStudent.Name = student.Name; + existingStudent.Surname = student.Surname; + existingStudent.GroupId = student.GroupId; + } + } + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Repositories/Implementations/SubjectsRepository.cs b/StudentProgress/StudentProgress/Repositories/Implementations/SubjectsRepository.cs new file mode 100644 index 0000000..bb88b56 --- /dev/null +++ b/StudentProgress/StudentProgress/Repositories/Implementations/SubjectsRepository.cs @@ -0,0 +1,28 @@ +using StudentProgress.Entities; +using System.Collections.Generic; + +namespace StudentProgress.Repositories.Implementations; + +public class SubjectsRepository : ISubjectsRepository +{ + public void CreateSubjects(Subjects subject) + { + // Логика создания предмета + } + + public void CreateSubjects_(Subjects subject) + { + throw new NotImplementedException(); + } + + public void DeleteSubjects(int id) + { + // Логика удаления предмета по идентификатору + } + + public IEnumerable ReadSubjects(int? lecturerNameId = null) + { + // Логика чтения предметов с возможностью фильтрации по идентификатору преподавателя + return new List(); + } +} \ No newline at end of file diff --git a/StudentProgress/StudentProgress/Resources/Add.png b/StudentProgress/StudentProgress/Resources/Add.png new file mode 100644 index 0000000..fb970a6 Binary files /dev/null and b/StudentProgress/StudentProgress/Resources/Add.png differ diff --git a/StudentProgress/StudentProgress/Resources/BackGround.jpg b/StudentProgress/StudentProgress/Resources/BackGround.jpg new file mode 100644 index 0000000..6472ee1 Binary files /dev/null and b/StudentProgress/StudentProgress/Resources/BackGround.jpg differ diff --git a/StudentProgress/StudentProgress/Resources/Del.png b/StudentProgress/StudentProgress/Resources/Del.png new file mode 100644 index 0000000..16d32a5 Binary files /dev/null and b/StudentProgress/StudentProgress/Resources/Del.png differ diff --git a/StudentProgress/StudentProgress/Resources/Pencil.png b/StudentProgress/StudentProgress/Resources/Pencil.png new file mode 100644 index 0000000..ea2236b Binary files /dev/null and b/StudentProgress/StudentProgress/Resources/Pencil.png differ diff --git a/StudentProgress/StudentProgress/StudentProgress.csproj b/StudentProgress/StudentProgress/StudentProgress.csproj index 663fdb8..accbdf0 100644 --- a/StudentProgress/StudentProgress/StudentProgress.csproj +++ b/StudentProgress/StudentProgress/StudentProgress.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file