diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/AddMark.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/AddMark.cs new file mode 100644 index 0000000..f3507da --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/AddMark.cs @@ -0,0 +1,31 @@ +using SessionResults_Kudyaeva.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities; + +public class AddMark +{ + public int Id { get; private set; } + public int StudentId { get; private set; } + public int GroupId { get; private set; } + public int DisciplineId { get; private set; } + public Mark? Mark { get; private set; } // Оставляем тип Mark + public DateTime Date { get; private set; } + + public static AddMark CreateOperation(int id, int studentId, int groupId, int disciplineId, Mark mark) + { + return new AddMark + { + Id = id, + StudentId = studentId, + GroupId = groupId, + DisciplineId = disciplineId, + Mark = mark, // Если `Mark` имеет значение по умолчанию, его можно обработать + Date = DateTime.Now + }; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Discipline.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Discipline.cs new file mode 100644 index 0000000..4e9b0e3 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Discipline.cs @@ -0,0 +1,27 @@ +using SessionResults_Kudyaeva.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities; + +public class Discipline +{ + public int ID { get; private set; } + public string Name { get; private set; } = string.Empty; + public string Description { get; private set; } = string.Empty; + public Course Courses { get; private set; } + + public static Discipline Create(int id, string name, string description, Course courses) + { + return new Discipline + { + ID = id, + Name = name, + Description = description, + Courses = courses + }; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/Course.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/Course.cs new file mode 100644 index 0000000..a074d75 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/Course.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities.Enums; + +[Flags] +public enum Course +{ + None = 0, + First = 1, // 1 курс + Second = 2, // 2 курс + Third = 4, // 3 курс + Fourth = 8 // 4 курс +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/GroupType.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/GroupType.cs new file mode 100644 index 0000000..4e13716 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/GroupType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities.Enums; + +public enum GroupType +{ + Daytime, // Дневная + Evening, // Вечерняя + FullTimeDistance // Очно-заочная +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/Mark.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/Mark.cs new file mode 100644 index 0000000..d368eee --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Enums/Mark.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities.Enums; + +public enum Mark +{ + None, + One = 1, + Two = 2, + Three = 3, + Four = 4, + Five = 5 +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Group.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Group.cs new file mode 100644 index 0000000..a8a64d1 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Group.cs @@ -0,0 +1,25 @@ +using SessionResults_Kudyaeva.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities; + +public class Group +{ + public int ID { get; private set; } + public string Name { get; private set; } = string.Empty; + public GroupType Type { get; private set; } + + public static Group Create(int id, string name, GroupType type) + { + return new Group + { + ID = id, + Name = name, + Type = type + }; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Student.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Student.cs new file mode 100644 index 0000000..44add56 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Student.cs @@ -0,0 +1,29 @@ +using SessionResults_Kudyaeva.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities; + +public class Student +{ + public int ID { get; private set; } + public string Surname { get; private set; } = string.Empty; + public string Name { get; private set; } = string.Empty; + public string MiddleName { get; private set; } = string.Empty; + public int GroupID { get; private set; } + + public static Student Create(int id, string surname, string name, string middleName, int groupID) + { + return new Student + { + ID = id, + Surname = surname, + Name = name, + MiddleName = middleName, + GroupID = groupID + }; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Teacher.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Teacher.cs new file mode 100644 index 0000000..06b9fbe --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Entities/Teacher.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Entities; + +public class Teacher +{ + public int ID { get; private set; } + public string Surname { get; private set; } = string.Empty; + public string Name { get; private set; } = string.Empty; + public string MiddleName { get; private set; } = string.Empty; + public int DisciplineID { get; private set; } + + public static Teacher Create(int id, string surname, string name, string middleName, int disciplineID) + { + return new Teacher + { + ID = id, + Surname = surname, + Name = name, + MiddleName = middleName, + DisciplineID = disciplineID + }; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.Designer.cs deleted file mode 100644 index 5f50fde..0000000 --- a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace SessionResults_Kudyaeva -{ - 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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.cs deleted file mode 100644 index ad0be2c..0000000 --- a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SessionResults_Kudyaeva -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.Designer.cs new file mode 100644 index 0000000..2681e00 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.Designer.cs @@ -0,0 +1,137 @@ +namespace SessionResults_Kudyaeva +{ + partial class FormSessionResults + { + /// + /// 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(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + StudentsToolStripMenuItem = new ToolStripMenuItem(); + GroupsToolStripMenuItem = new ToolStripMenuItem(); + TeachersToolStripMenuItem = new ToolStripMenuItem(); + DisciplinesToolStripMenuItem = new ToolStripMenuItem(); + опереToolStripMenuItem = new ToolStripMenuItem(); + AddMarksToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, опереToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { StudentsToolStripMenuItem, GroupsToolStripMenuItem, TeachersToolStripMenuItem, DisciplinesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // StudentsToolStripMenuItem + // + StudentsToolStripMenuItem.Name = "StudentsToolStripMenuItem"; + StudentsToolStripMenuItem.Size = new Size(159, 22); + StudentsToolStripMenuItem.Text = "Студенты"; + StudentsToolStripMenuItem.Click += StudentsToolStripMenuItem_Click; + // + // GroupsToolStripMenuItem + // + GroupsToolStripMenuItem.Name = "GroupsToolStripMenuItem"; + GroupsToolStripMenuItem.Size = new Size(159, 22); + GroupsToolStripMenuItem.Text = "Группы"; + GroupsToolStripMenuItem.Click += GroupsToolStripMenuItem_Click; + // + // TeachersToolStripMenuItem + // + TeachersToolStripMenuItem.Name = "TeachersToolStripMenuItem"; + TeachersToolStripMenuItem.Size = new Size(159, 22); + TeachersToolStripMenuItem.Text = "Преподаватели"; + TeachersToolStripMenuItem.Click += TeachersToolStripMenuItem_Click; + // + // DisciplinesToolStripMenuItem + // + DisciplinesToolStripMenuItem.Name = "DisciplinesToolStripMenuItem"; + DisciplinesToolStripMenuItem.Size = new Size(159, 22); + DisciplinesToolStripMenuItem.Text = "Дисциплины"; + DisciplinesToolStripMenuItem.Click += DisciplinesToolStripMenuItem_Click; + // + // опереToolStripMenuItem + // + опереToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AddMarksToolStripMenuItem }); + опереToolStripMenuItem.Name = "опереToolStripMenuItem"; + опереToolStripMenuItem.Size = new Size(75, 20); + опереToolStripMenuItem.Text = "Операции"; + // + // AddMarksToolStripMenuItem + // + AddMarksToolStripMenuItem.Name = "AddMarksToolStripMenuItem"; + AddMarksToolStripMenuItem.Size = new Size(184, 22); + AddMarksToolStripMenuItem.Text = "Добавление оценки"; + AddMarksToolStripMenuItem.Click += AddMarksToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // FormSessionResults + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.фон; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormSessionResults"; + StartPosition = FormStartPosition.CenterParent; + Text = "Ведомость"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem StudentsToolStripMenuItem; + private ToolStripMenuItem GroupsToolStripMenuItem; + private ToolStripMenuItem TeachersToolStripMenuItem; + private ToolStripMenuItem DisciplinesToolStripMenuItem; + private ToolStripMenuItem опереToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem AddMarksToolStripMenuItem; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.cs new file mode 100644 index 0000000..a494cd8 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.cs @@ -0,0 +1,84 @@ +using SessionResults_Kudyaeva.Forms; +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; +using Unity; + +namespace SessionResults_Kudyaeva; + +public partial class FormSessionResults : Form +{ + private readonly IUnityContainer _container; + + public FormSessionResults(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void StudentsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void GroupsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void TeachersToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void DisciplinesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void AddMarksToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.resx new file mode 100644 index 0000000..b48baf1 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/FormSessionResults.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 + + + 17, 17 + + \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.Designer.cs new file mode 100644 index 0000000..5ce10af --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.Designer.cs @@ -0,0 +1,218 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class AddMarkForm + { + /// + /// 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(); + label5 = new Label(); + label6 = new Label(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + comboBoxDiscipline = new ComboBox(); + comboBoxTeacher = new ComboBox(); + comboBoxStudent = new ComboBox(); + comboBoxGroup = new ComboBox(); + comboBoxMark = new ComboBox(); + dateTimePickerDate = new DateTimePicker(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(40, 42); + label1.Name = "label1"; + label1.Size = new Size(55, 15); + label1.TabIndex = 0; + label1.Text = "Предмет"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(40, 73); + label2.Name = "label2"; + label2.Size = new Size(91, 15); + label2.TabIndex = 1; + label2.Text = "Преподаватель"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(40, 105); + label3.Name = "label3"; + label3.Size = new Size(50, 15); + label3.TabIndex = 2; + label3.Text = "Студент"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(40, 137); + label4.Name = "label4"; + label4.Size = new Size(46, 15); + label4.TabIndex = 3; + label4.Text = "Группа"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(40, 195); + label5.Name = "label5"; + label5.Size = new Size(48, 15); + label5.TabIndex = 4; + label5.Text = "Оценка"; + // + // label6 + // + label6.AutoSize = true; + label6.Location = new Point(40, 233); + label6.Name = "label6"; + label6.Size = new Size(32, 15); + label6.TabIndex = 5; + label6.Text = "Дата"; + // + // ButtonSave + // + ButtonSave.Location = new Point(61, 284); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(96, 23); + ButtonSave.TabIndex = 10; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(234, 284); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(96, 23); + ButtonCancel.TabIndex = 11; + ButtonCancel.Text = "Отменить"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // comboBoxDiscipline + // + comboBoxDiscipline.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDiscipline.FormattingEnabled = true; + comboBoxDiscipline.Location = new Point(186, 39); + comboBoxDiscipline.Name = "comboBoxDiscipline"; + comboBoxDiscipline.Size = new Size(175, 23); + comboBoxDiscipline.TabIndex = 12; + // + // comboBoxTeacher + // + comboBoxTeacher.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxTeacher.FormattingEnabled = true; + comboBoxTeacher.Location = new Point(186, 70); + comboBoxTeacher.Name = "comboBoxTeacher"; + comboBoxTeacher.Size = new Size(175, 23); + comboBoxTeacher.TabIndex = 13; + // + // comboBoxStudent + // + comboBoxStudent.BackColor = Color.White; + comboBoxStudent.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStudent.FormattingEnabled = true; + comboBoxStudent.Location = new Point(186, 102); + comboBoxStudent.Name = "comboBoxStudent"; + comboBoxStudent.Size = new Size(175, 23); + comboBoxStudent.TabIndex = 14; + // + // comboBoxGroup + // + comboBoxGroup.BackColor = Color.White; + comboBoxGroup.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxGroup.FormattingEnabled = true; + comboBoxGroup.Location = new Point(186, 134); + comboBoxGroup.Name = "comboBoxGroup"; + comboBoxGroup.Size = new Size(175, 23); + comboBoxGroup.TabIndex = 15; + // + // comboBoxMark + // + comboBoxMark.BackColor = Color.White; + comboBoxMark.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxMark.FormattingEnabled = true; + comboBoxMark.Location = new Point(186, 192); + comboBoxMark.Name = "comboBoxMark"; + comboBoxMark.Size = new Size(175, 23); + comboBoxMark.TabIndex = 16; + // + // dateTimePickerDate + // + dateTimePickerDate.Location = new Point(186, 227); + dateTimePickerDate.Name = "dateTimePickerDate"; + dateTimePickerDate.Size = new Size(175, 23); + dateTimePickerDate.TabIndex = 17; + // + // AddMarkForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(407, 342); + Controls.Add(dateTimePickerDate); + Controls.Add(comboBoxMark); + Controls.Add(comboBoxGroup); + Controls.Add(comboBoxStudent); + Controls.Add(comboBoxTeacher); + Controls.Add(comboBoxDiscipline); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(label6); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "AddMarkForm"; + Text = "Добавить оценку"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private Label label5; + private Label label6; + private Button ButtonSave; + private Button ButtonCancel; + private ComboBox comboBoxDiscipline; + private ComboBox comboBoxTeacher; + private ComboBox comboBoxStudent; + private ComboBox comboBoxGroup; + private ComboBox comboBoxMark; + private DateTimePicker dateTimePickerDate; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.cs new file mode 100644 index 0000000..a54866d --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.cs @@ -0,0 +1,86 @@ +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Entities.Enums; +using SessionResults_Kudyaeva.Repositories; +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 SessionResults_Kudyaeva.Forms; + + +public partial class AddMarkForm : Form +{ + private readonly IAddMarkRepository _addMarkRepository; + private readonly IStudentRepository _studentRepository; + private readonly IGroupRepository _groupRepository; + private readonly ITeacherRepository _teacherRepository; + private readonly IDisciplineRepository _disciplineRepository; + + public AddMarkForm(IAddMarkRepository addMarkRepository, IStudentRepository studentRepository, IGroupRepository groupRepository, ITeacherRepository teacherRepository, IDisciplineRepository disciplineRepository) + { + InitializeComponent(); + + _addMarkRepository = addMarkRepository ?? throw new ArgumentNullException(nameof(addMarkRepository)); + _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); + _groupRepository = groupRepository ?? throw new ArgumentNullException(nameof(groupRepository)); + _teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository)); + _disciplineRepository = disciplineRepository ?? throw new ArgumentNullException(nameof(disciplineRepository)); + + + comboBoxStudent.DataSource = _studentRepository.GetAllStudents(); + comboBoxStudent.DisplayMember = "Name"; + comboBoxStudent.ValueMember = "Id"; + + comboBoxGroup.DataSource = _groupRepository.GetAllGroups(); + comboBoxGroup.DisplayMember = "Name"; + comboBoxGroup.ValueMember = "Id"; + + comboBoxTeacher.DataSource = _teacherRepository.GetAllTeachers(); + comboBoxTeacher.DisplayMember = "Name"; + comboBoxTeacher.ValueMember = "Id"; + + comboBoxDiscipline.DataSource = _disciplineRepository.GetAllDisciplines(); + comboBoxDiscipline.DisplayMember = "Name"; + comboBoxDiscipline.ValueMember = "Id"; + + comboBoxMark.DataSource = Enum.GetValues(typeof(Mark)); + + + dateTimePickerDate.Enabled = false; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxStudent.SelectedIndex < 0 || + comboBoxGroup.SelectedIndex < 0 || + comboBoxTeacher.SelectedIndex < 0 || + comboBoxDiscipline.SelectedIndex < 0 || + comboBoxMark.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + _addMarkRepository.CreateMark(AddMark.CreateOperation(0, + (int)comboBoxStudent.SelectedValue!, + (int)comboBoxGroup.SelectedValue!, + (int)comboBoxDiscipline.SelectedValue!, + (Mark)comboBoxMark.SelectedItem!)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.Designer.cs new file mode 100644 index 0000000..d9ff92c --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.Designer.cs @@ -0,0 +1,97 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class AddMarkListForm + { + /// + /// 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(); + ButtonAdd = new Button(); + dataGridViewData = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(845, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(114, 449); + panel1.TabIndex = 0; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.Add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(6, 43); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(100, 100); + ButtonAdd.TabIndex = 3; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(845, 449); + dataGridViewData.TabIndex = 4; + // + // AddMarkListForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(959, 449); + Controls.Add(dataGridViewData); + Controls.Add(panel1); + Name = "AddMarkListForm"; + Text = "Добавление оценок"; + Load += AddMarkListForm_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonAdd; + private DataGridView dataGridViewData; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.cs new file mode 100644 index 0000000..a8f3bd1 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.cs @@ -0,0 +1,45 @@ +using SessionResults_Kudyaeva.Repositories; +using Unity; + +namespace SessionResults_Kudyaeva.Forms; + +public partial class AddMarkListForm : Form +{ + private readonly IUnityContainer _container; + private readonly IAddMarkRepository _addMarkRepository; + + public AddMarkListForm(IUnityContainer container, IAddMarkRepository addMarkRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _addMarkRepository = addMarkRepository ?? throw new ArgumentNullException(nameof(addMarkRepository)); + } + + private void AddMarkListForm_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 LoadList() => dataGridViewData.DataSource = _addMarkRepository.GetAllMarks(); + +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.resx similarity index 93% rename from SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.resx rename to SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.resx index 1af7de1..af32865 100644 --- a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Form1.resx +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/AddMarkListForm.resx @@ -1,17 +1,17 @@  - diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.Designer.cs new file mode 100644 index 0000000..3f94ba8 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.Designer.cs @@ -0,0 +1,141 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class DisciplineForm + { + /// + /// 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(); + labelDescription = new Label(); + labelDisciplineType = new Label(); + textBoxName = new TextBox(); + textBoxDescription = new TextBox(); + checkedListBoxCourse = new CheckedListBox(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(41, 36); + labelName.Name = "labelName"; + labelName.Size = new Size(59, 15); + labelName.TabIndex = 0; + labelName.Text = "Название"; + // + // labelDescription + // + labelDescription.AutoSize = true; + labelDescription.Location = new Point(41, 74); + labelDescription.Name = "labelDescription"; + labelDescription.Size = new Size(62, 15); + labelDescription.TabIndex = 1; + labelDescription.Text = "Описание"; + // + // labelDisciplineType + // + labelDisciplineType.AutoSize = true; + labelDisciplineType.Location = new Point(41, 174); + labelDisciplineType.Name = "labelDisciplineType"; + labelDisciplineType.Size = new Size(78, 15); + labelDisciplineType.TabIndex = 2; + labelDisciplineType.Text = "Выбор курса"; + // + // textBoxName + // + textBoxName.Location = new Point(147, 33); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(184, 23); + textBoxName.TabIndex = 3; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(147, 71); + textBoxDescription.Multiline = true; + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(184, 85); + textBoxDescription.TabIndex = 4; + // + // checkedListBoxCourse + // + checkedListBoxCourse.FormattingEnabled = true; + checkedListBoxCourse.Location = new Point(147, 174); + checkedListBoxCourse.Name = "checkedListBoxCourse"; + checkedListBoxCourse.Size = new Size(184, 94); + checkedListBoxCourse.TabIndex = 5; + // + // ButtonSave + // + ButtonSave.Location = new Point(54, 298); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(96, 23); + ButtonSave.TabIndex = 10; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(210, 298); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(96, 23); + ButtonCancel.TabIndex = 11; + ButtonCancel.Text = "Отменить"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // DisciplineForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(372, 347); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(checkedListBoxCourse); + Controls.Add(textBoxDescription); + Controls.Add(textBoxName); + Controls.Add(labelDisciplineType); + Controls.Add(labelDescription); + Controls.Add(labelName); + Name = "DisciplineForm"; + Text = "Дисциплина"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private Label labelDescription; + private Label labelDisciplineType; + private TextBox textBoxName; + private TextBox textBoxDescription; + private CheckedListBox checkedListBoxCourse; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.cs new file mode 100644 index 0000000..4ee81a1 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.cs @@ -0,0 +1,102 @@ +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Repositories; +using SessionResults_Kudyaeva.Entities.Enums; +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 SessionResults_Kudyaeva.Forms; + +public partial class DisciplineForm : Form +{ + private readonly IDisciplineRepository _disciplineRepository; + private int? _disciplineId; + + public int Id + { + set + { + try + { + var discipline = _disciplineRepository.GetDisciplineById(value); + if (discipline == null) + { + throw new InvalidDataException(nameof(discipline)); + } + foreach (Course elem in Enum.GetValues(typeof(Course))) + { + if ((elem & discipline.Courses) != 0) + { + checkedListBoxCourse.SetItemChecked(checkedListBoxCourse.Items.IndexOf(elem), true); + } + } + textBoxName.Text = discipline.Name; + textBoxDescription.Text = discipline.Description; + _disciplineId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public DisciplineForm(IDisciplineRepository disciplineRepository) + { + InitializeComponent(); + + _disciplineRepository = disciplineRepository ?? throw new ArgumentNullException(nameof(disciplineRepository)); + + foreach (var elem in Enum.GetValues(typeof(Course))) + { + checkedListBoxCourse.Items.Add(elem); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(textBoxDescription.Text) || + checkedListBoxCourse.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_disciplineId.HasValue) + { + _disciplineRepository.UpdateDiscipline(CreateDiscipline(_disciplineId.Value)); + } + else + { + _disciplineRepository.AddDiscipline(CreateDiscipline(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Discipline CreateDiscipline(int id) + { + Course course = Course.None; + foreach (var elem in checkedListBoxCourse.CheckedItems) + { + course |= (Course)elem; + } + return Discipline.Create(id, textBoxName.Text, textBoxDescription.Text, course); + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.Designer.cs new file mode 100644 index 0000000..52b5042 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.Designer.cs @@ -0,0 +1,125 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class DisciplineListForm + { + /// + /// 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(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewDisciplines = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewDisciplines).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(800, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(134, 429); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.Del; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(13, 270); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(101, 100); + ButtonDel.TabIndex = 4; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.Upd; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(13, 164); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(100, 100); + ButtonUpd.TabIndex = 3; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.Add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(13, 58); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(100, 100); + ButtonAdd.TabIndex = 2; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewDisciplines + // + dataGridViewDisciplines.AllowUserToAddRows = false; + dataGridViewDisciplines.AllowUserToDeleteRows = false; + dataGridViewDisciplines.AllowUserToResizeColumns = false; + dataGridViewDisciplines.AllowUserToResizeRows = false; + dataGridViewDisciplines.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewDisciplines.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewDisciplines.Dock = DockStyle.Fill; + dataGridViewDisciplines.Location = new Point(0, 0); + dataGridViewDisciplines.MultiSelect = false; + dataGridViewDisciplines.Name = "dataGridViewDisciplines"; + dataGridViewDisciplines.ReadOnly = true; + dataGridViewDisciplines.RowHeadersVisible = false; + dataGridViewDisciplines.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewDisciplines.Size = new Size(800, 429); + dataGridViewDisciplines.TabIndex = 3; + // + // DisciplineListForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(934, 429); + Controls.Add(dataGridViewDisciplines); + Controls.Add(panel1); + Name = "DisciplineListForm"; + Text = "Дисциплины"; + Load += DisciplineListForm_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewDisciplines).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonAdd; + private Button ButtonUpd; + private Button ButtonDel; + private DataGridView dataGridViewDisciplines; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.cs new file mode 100644 index 0000000..b06d3cb --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.cs @@ -0,0 +1,107 @@ +using SessionResults_Kudyaeva.Repositories; +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; +using Unity; + +namespace SessionResults_Kudyaeva.Forms; + +public partial class DisciplineListForm : Form +{ + + private readonly IUnityContainer _container; + private readonly IDisciplineRepository _disciplineRepository; + + public DisciplineListForm(IUnityContainer container, IDisciplineRepository disciplineRepository) + { + InitializeComponent(); + + _container = container ?? throw new ArgumentNullException(nameof(container)); + _disciplineRepository = disciplineRepository ?? throw new ArgumentNullException(nameof(disciplineRepository)); + } + + private void DisciplineListForm_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 ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _disciplineRepository.DeleteDiscipline(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewDisciplines.DataSource = _disciplineRepository.GetAllDisciplines(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewDisciplines.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewDisciplines.SelectedRows[0].Cells["ID"].Value); + return true; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/DisciplineListForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.Designer.cs new file mode 100644 index 0000000..1c8d33b --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.Designer.cs @@ -0,0 +1,119 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class GroupForm + { + /// + /// 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(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + textBoxName = new TextBox(); + comboBoxType = new ComboBox(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(38, 38); + label1.Name = "label1"; + label1.Size = new Size(46, 15); + label1.TabIndex = 0; + label1.Text = "Группа"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(38, 68); + label2.Name = "label2"; + label2.Size = new Size(83, 15); + label2.TabIndex = 1; + label2.Text = "Тип обучения"; + // + // ButtonSave + // + ButtonSave.Location = new Point(53, 108); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(96, 23); + ButtonSave.TabIndex = 9; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(206, 108); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(96, 23); + ButtonCancel.TabIndex = 10; + ButtonCancel.Text = "Отменить"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // textBoxName + // + textBoxName.Location = new Point(154, 36); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(159, 23); + textBoxName.TabIndex = 11; + // + // comboBoxType + // + comboBoxType.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxType.FormattingEnabled = true; + comboBoxType.Location = new Point(155, 65); + comboBoxType.Name = "comboBoxType"; + comboBoxType.Size = new Size(159, 23); + comboBoxType.TabIndex = 12; + // + // GroupForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(360, 157); + Controls.Add(comboBoxType); + Controls.Add(textBoxName); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(label2); + Controls.Add(label1); + Name = "GroupForm"; + Text = "Группа"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Button ButtonSave; + private Button ButtonCancel; + private TextBox textBoxName; + private ComboBox comboBoxType; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.cs new file mode 100644 index 0000000..02681d8 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.cs @@ -0,0 +1,84 @@ +using SessionResults_Kudyaeva.Entities.Enums; +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Repositories; +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 SessionResults_Kudyaeva.Forms; + +public partial class GroupForm : Form +{ + private readonly IGroupRepository _groupRepository; + private int? _groupId; + + public int Id + { + set + { + try + { + var group = _groupRepository.GetGroupById(value); + if (group == null) + { + throw new InvalidDataException(nameof(group)); + } + textBoxName.Text = group.Name; + comboBoxType.SelectedItem = group.Type; + _groupId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public GroupForm(IGroupRepository groupRepository) + { + InitializeComponent(); + _groupRepository = groupRepository ?? + throw new ArgumentNullException(nameof(groupRepository)); + + comboBoxType.DataSource = Enum.GetValues(typeof(GroupType)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text) || comboBoxType.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_groupId.HasValue) + { + _groupRepository.UpdateGroup(CreateGroup(_groupId.Value)); + } + else + { + _groupRepository.AddGroup(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. + Create(id, textBoxName.Text, + (GroupType)comboBoxType.SelectedItem!); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.Designer.cs new file mode 100644 index 0000000..79b6468 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.Designer.cs @@ -0,0 +1,125 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class GroupsListForm + { + /// + /// 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(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewGroups = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewGroups).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(828, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(125, 439); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.Del; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(13, 278); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(101, 100); + ButtonDel.TabIndex = 3; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.Upd; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(13, 172); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(100, 100); + ButtonUpd.TabIndex = 2; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.Add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(13, 66); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(100, 100); + ButtonAdd.TabIndex = 1; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewGroups + // + dataGridViewGroups.AllowUserToAddRows = false; + dataGridViewGroups.AllowUserToDeleteRows = false; + dataGridViewGroups.AllowUserToResizeColumns = false; + dataGridViewGroups.AllowUserToResizeRows = false; + dataGridViewGroups.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewGroups.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewGroups.Dock = DockStyle.Fill; + dataGridViewGroups.Location = new Point(0, 0); + dataGridViewGroups.MultiSelect = false; + dataGridViewGroups.Name = "dataGridViewGroups"; + dataGridViewGroups.ReadOnly = true; + dataGridViewGroups.RowHeadersVisible = false; + dataGridViewGroups.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewGroups.Size = new Size(828, 439); + dataGridViewGroups.TabIndex = 2; + // + // GroupsListForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(953, 439); + Controls.Add(dataGridViewGroups); + Controls.Add(panel1); + Name = "GroupsListForm"; + Text = "Группы"; + Load += GroupList_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewGroups).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonAdd; + private Button ButtonUpd; + private Button ButtonDel; + private DataGridView dataGridViewGroups; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.cs new file mode 100644 index 0000000..467dcab --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.cs @@ -0,0 +1,109 @@ +using SessionResults_Kudyaeva.Repositories; +using SessionResults_Kudyaeva.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; +using System.Xml.Linq; +using Unity; + +namespace SessionResults_Kudyaeva.Forms; + +public partial class GroupsListForm : Form +{ + + private readonly IUnityContainer _container; + private readonly IGroupRepository _groupRepository; + + public GroupsListForm(IUnityContainer container, IGroupRepository groupRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _groupRepository = groupRepository ?? throw new ArgumentNullException(nameof(groupRepository)); + } + + private void GroupList_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 ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void 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() => dataGridViewGroups.DataSource = _groupRepository.GetAllGroups(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewGroups.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewGroups.SelectedRows[0].Cells["ID"].Value); + return true; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/GroupsListForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.Designer.cs new file mode 100644 index 0000000..110afe0 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.Designer.cs @@ -0,0 +1,163 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class StudentForm + { + /// + /// 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() + { + lblSurname = new Label(); + lblName = new Label(); + lblMiddleName = new Label(); + lblGroup = new Label(); + textBoxSurname = new TextBox(); + textBoxName = new TextBox(); + textBoxMiddleName = new TextBox(); + ButtonSave = new Button(); + ButtonCancel = new Button(); + comboBoxGroup = new ComboBox(); + SuspendLayout(); + // + // lblSurname + // + lblSurname.AutoSize = true; + lblSurname.Location = new Point(38, 39); + lblSurname.Name = "lblSurname"; + lblSurname.Size = new Size(61, 15); + lblSurname.TabIndex = 0; + lblSurname.Text = "Фамилия "; + // + // lblName + // + lblName.AutoSize = true; + lblName.Location = new Point(38, 69); + lblName.Name = "lblName"; + lblName.Size = new Size(31, 15); + lblName.TabIndex = 1; + lblName.Text = "Имя"; + // + // lblMiddleName + // + lblMiddleName.AutoSize = true; + lblMiddleName.Location = new Point(38, 98); + lblMiddleName.Name = "lblMiddleName"; + lblMiddleName.Size = new Size(58, 15); + lblMiddleName.TabIndex = 2; + lblMiddleName.Text = "Отчество"; + // + // lblGroup + // + lblGroup.AutoSize = true; + lblGroup.Location = new Point(38, 127); + lblGroup.Name = "lblGroup"; + lblGroup.Size = new Size(46, 15); + lblGroup.TabIndex = 3; + lblGroup.Text = "Группа"; + // + // textBoxSurname + // + textBoxSurname.Location = new Point(149, 36); + textBoxSurname.Name = "textBoxSurname"; + textBoxSurname.Size = new Size(141, 23); + textBoxSurname.TabIndex = 4; + // + // textBoxName + // + textBoxName.Location = new Point(149, 66); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(141, 23); + textBoxName.TabIndex = 5; + // + // textBoxMiddleName + // + textBoxMiddleName.Location = new Point(149, 95); + textBoxMiddleName.Name = "textBoxMiddleName"; + textBoxMiddleName.Size = new Size(141, 23); + textBoxMiddleName.TabIndex = 6; + // + // ButtonSave + // + ButtonSave.Location = new Point(49, 176); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(96, 23); + ButtonSave.TabIndex = 8; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + ButtonSave.Click += ButtonSave_Click; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(183, 176); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(96, 23); + ButtonCancel.TabIndex = 9; + ButtonCancel.Text = "Отменить"; + ButtonCancel.UseVisualStyleBackColor = true; + ButtonCancel.Click += ButtonCancel_Click; + // + // comboBoxGroup + // + comboBoxGroup.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxGroup.FormattingEnabled = true; + comboBoxGroup.Location = new Point(149, 124); + comboBoxGroup.Name = "comboBoxGroup"; + comboBoxGroup.Size = new Size(141, 23); + comboBoxGroup.TabIndex = 10; + // + // StudentForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(331, 224); + Controls.Add(comboBoxGroup); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Controls.Add(textBoxMiddleName); + Controls.Add(textBoxName); + Controls.Add(textBoxSurname); + Controls.Add(lblGroup); + Controls.Add(lblMiddleName); + Controls.Add(lblName); + Controls.Add(lblSurname); + Name = "StudentForm"; + Text = "StudentForm"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label lblSurname; + private Label lblName; + private Label lblMiddleName; + private Label lblGroup; + private TextBox textBoxSurname; + private TextBox textBoxName; + private TextBox textBoxMiddleName; + private Button ButtonSave; + private Button ButtonCancel; + private ComboBox comboBoxGroup; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.cs new file mode 100644 index 0000000..bd8fa45 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.cs @@ -0,0 +1,90 @@ +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Repositories; +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 SessionResults_Kudyaeva.Forms; + +public partial class StudentForm : Form +{ + private readonly IStudentRepository _studentRepository; + private int? _studentId; + + public int Id + { + set + { + try + { + var student = _studentRepository.GetStudentById(value); + if (student == null) + { + throw new InvalidDataException(nameof(student)); + } + textBoxSurname.Text = student.Surname; + textBoxName.Text = student.Name; + textBoxMiddleName.Text = student.MiddleName; + comboBoxGroup.SelectedValue = student.GroupID; + _studentId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public StudentForm(IStudentRepository studentRepository) + { + InitializeComponent(); + _studentRepository = studentRepository ?? + throw new ArgumentNullException(nameof(studentRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxSurname.Text) || + string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(textBoxMiddleName.Text) || + comboBoxGroup.SelectedItem == null) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_studentId.HasValue) + { + _studentRepository.UpdateStudent(CreateStudent(_studentId.Value)); + } + else + { + _studentRepository.AddStudent(CreateStudent(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Student CreateStudent(int id) => Student.Create( + id, + textBoxSurname.Text, + textBoxName.Text, + textBoxMiddleName.Text, + (int)comboBoxGroup.SelectedValue!); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.Designer.cs new file mode 100644 index 0000000..b2327ef --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.Designer.cs @@ -0,0 +1,126 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class StudentsList + { + /// + /// 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(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewStudents = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewStudents).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(840, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(126, 452); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.Del; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(12, 266); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(101, 100); + ButtonDel.TabIndex = 2; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.Upd; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(13, 160); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(100, 100); + ButtonUpd.TabIndex = 1; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.Add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(13, 54); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(100, 100); + ButtonAdd.TabIndex = 0; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewStudents + // + dataGridViewStudents.AllowUserToAddRows = false; + dataGridViewStudents.AllowUserToDeleteRows = false; + dataGridViewStudents.AllowUserToResizeColumns = false; + dataGridViewStudents.AllowUserToResizeRows = false; + dataGridViewStudents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewStudents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewStudents.Dock = DockStyle.Fill; + dataGridViewStudents.Location = new Point(0, 0); + dataGridViewStudents.MultiSelect = false; + dataGridViewStudents.Name = "dataGridViewStudents"; + dataGridViewStudents.ReadOnly = true; + dataGridViewStudents.RowHeadersVisible = false; + dataGridViewStudents.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewStudents.Size = new Size(840, 452); + dataGridViewStudents.TabIndex = 1; + // + // StudentsList + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(966, 452); + Controls.Add(dataGridViewStudents); + Controls.Add(panel1); + Name = "StudentsList"; + StartPosition = FormStartPosition.CenterParent; + Text = "Студенты"; + Load += StudentsList_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewStudents).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonDel; + private Button ButtonUpd; + private Button ButtonAdd; + private DataGridView dataGridViewStudents; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.cs new file mode 100644 index 0000000..a31f17f --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.cs @@ -0,0 +1,108 @@ +using SessionResults_Kudyaeva.Repositories; +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; +using Unity; + +namespace SessionResults_Kudyaeva.Forms; + +public partial class StudentsList : Form +{ + private readonly IUnityContainer _container; + private readonly IStudentRepository _studentRepository; + + public StudentsList(IUnityContainer container, IStudentRepository studentRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); + } + + + private void StudentsList_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 ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void 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() => dataGridViewStudents.DataSource = _studentRepository.GetAllStudents(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewStudents.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewStudents.SelectedRows[0].Cells["ID"].Value); + return true; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/StudentsList.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.Designer.cs new file mode 100644 index 0000000..ff22ac4 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.Designer.cs @@ -0,0 +1,161 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class TeacherForm + { + /// + /// 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() + { + ButtonSave = new Button(); + ButtonCancel = new Button(); + labelSurname = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + textBoxSurname = new TextBox(); + textBoxName = new TextBox(); + textBoxMiddleName = new TextBox(); + comboBoxDiscipline = new ComboBox(); + SuspendLayout(); + // + // ButtonSave + // + ButtonSave.Location = new Point(75, 195); + ButtonSave.Name = "ButtonSave"; + ButtonSave.Size = new Size(96, 23); + ButtonSave.TabIndex = 9; + ButtonSave.Text = "Сохранить"; + ButtonSave.UseVisualStyleBackColor = true; + // + // ButtonCancel + // + ButtonCancel.Location = new Point(223, 195); + ButtonCancel.Name = "ButtonCancel"; + ButtonCancel.Size = new Size(96, 23); + ButtonCancel.TabIndex = 10; + ButtonCancel.Text = "Отменить"; + ButtonCancel.UseVisualStyleBackColor = true; + // + // labelSurname + // + labelSurname.AutoSize = true; + labelSurname.Location = new Point(56, 55); + labelSurname.Name = "labelSurname"; + labelSurname.Size = new Size(58, 15); + labelSurname.TabIndex = 11; + labelSurname.Text = "Фамилия"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(56, 86); + label2.Name = "label2"; + label2.Size = new Size(31, 15); + label2.TabIndex = 12; + label2.Text = "Имя"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(56, 115); + label3.Name = "label3"; + label3.Size = new Size(58, 15); + label3.TabIndex = 13; + label3.Text = "Отчество"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(56, 144); + label4.Name = "label4"; + label4.Size = new Size(76, 15); + label4.TabIndex = 14; + label4.Text = "Дисциплина"; + // + // textBoxSurname + // + textBoxSurname.Location = new Point(200, 52); + textBoxSurname.Name = "textBoxSurname"; + textBoxSurname.Size = new Size(145, 23); + textBoxSurname.TabIndex = 15; + // + // textBoxName + // + textBoxName.Location = new Point(200, 83); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(145, 23); + textBoxName.TabIndex = 16; + // + // textBoxMiddleName + // + textBoxMiddleName.Location = new Point(200, 112); + textBoxMiddleName.Name = "textBoxMiddleName"; + textBoxMiddleName.Size = new Size(145, 23); + textBoxMiddleName.TabIndex = 17; + // + // comboBoxDiscipline + // + comboBoxDiscipline.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxDiscipline.FormattingEnabled = true; + comboBoxDiscipline.Location = new Point(200, 141); + comboBoxDiscipline.Name = "comboBoxDiscipline"; + comboBoxDiscipline.Size = new Size(145, 23); + comboBoxDiscipline.TabIndex = 18; + // + // TeacherForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(388, 249); + Controls.Add(comboBoxDiscipline); + Controls.Add(textBoxMiddleName); + Controls.Add(textBoxName); + Controls.Add(textBoxSurname); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(labelSurname); + Controls.Add(ButtonCancel); + Controls.Add(ButtonSave); + Name = "TeacherForm"; + Text = "Преподаватель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button ButtonSave; + private Button ButtonCancel; + private Label labelSurname; + private Label label2; + private Label label3; + private Label label4; + private TextBox textBoxSurname; + private TextBox textBoxName; + private TextBox textBoxMiddleName; + private ComboBox comboBoxDiscipline; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.cs new file mode 100644 index 0000000..51ed66f --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.cs @@ -0,0 +1,88 @@ +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Repositories; +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 SessionResults_Kudyaeva.Forms; + +public partial class TeacherForm : Form +{ + + private readonly ITeacherRepository _teacherRepository; + private int? _teacherId; + + public int Id + { + set + { + try + { + var teacher = _teacherRepository.GetTeacherById(value); + if (teacher == null) + { + throw new InvalidDataException(nameof(teacher)); + } + textBoxSurname.Text = teacher.Surname; + textBoxName.Text = teacher.Name; + textBoxMiddleName.Text = teacher.MiddleName; + comboBoxDiscipline.SelectedValue = teacher.DisciplineID; + _teacherId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public TeacherForm(ITeacherRepository teacherRepository) + { + InitializeComponent(); + _teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxSurname.Text) || + string.IsNullOrWhiteSpace(textBoxName.Text) || + string.IsNullOrWhiteSpace(textBoxMiddleName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_teacherId.HasValue) + { + _teacherRepository.UpdateTeacher(CreateTeacher(_teacherId.Value)); + } + else + { + _teacherRepository.AddTeacher(CreateTeacher(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Teacher CreateTeacher(int id) => Teacher.Create( + id, + textBoxSurname.Text, + textBoxName.Text, + textBoxMiddleName.Text, + (int)comboBoxDiscipline.SelectedValue!); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeacherForm.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.Designer.cs new file mode 100644 index 0000000..b586c93 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.Designer.cs @@ -0,0 +1,125 @@ +namespace SessionResults_Kudyaeva.Forms +{ + partial class TeachersList + { + /// + /// 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(); + ButtonUpd = new Button(); + ButtonAdd = new Button(); + dataGridViewTeachers = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewTeachers).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(ButtonDel); + panel1.Controls.Add(ButtonUpd); + panel1.Controls.Add(ButtonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(836, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(125, 431); + panel1.TabIndex = 0; + // + // ButtonDel + // + ButtonDel.BackgroundImage = Properties.Resources.Del; + ButtonDel.BackgroundImageLayout = ImageLayout.Stretch; + ButtonDel.Location = new Point(13, 266); + ButtonDel.Name = "ButtonDel"; + ButtonDel.Size = new Size(101, 100); + ButtonDel.TabIndex = 4; + ButtonDel.UseVisualStyleBackColor = true; + ButtonDel.Click += ButtonDel_Click; + // + // ButtonUpd + // + ButtonUpd.BackgroundImage = Properties.Resources.Upd; + ButtonUpd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonUpd.Location = new Point(13, 160); + ButtonUpd.Name = "ButtonUpd"; + ButtonUpd.Size = new Size(100, 100); + ButtonUpd.TabIndex = 3; + ButtonUpd.UseVisualStyleBackColor = true; + ButtonUpd.Click += ButtonUpd_Click; + // + // ButtonAdd + // + ButtonAdd.BackgroundImage = Properties.Resources.Add; + ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch; + ButtonAdd.Location = new Point(13, 54); + ButtonAdd.Name = "ButtonAdd"; + ButtonAdd.Size = new Size(100, 100); + ButtonAdd.TabIndex = 2; + ButtonAdd.UseVisualStyleBackColor = true; + ButtonAdd.Click += ButtonAdd_Click; + // + // dataGridViewTeachers + // + dataGridViewTeachers.AllowUserToAddRows = false; + dataGridViewTeachers.AllowUserToDeleteRows = false; + dataGridViewTeachers.AllowUserToResizeColumns = false; + dataGridViewTeachers.AllowUserToResizeRows = false; + dataGridViewTeachers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewTeachers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewTeachers.Dock = DockStyle.Fill; + dataGridViewTeachers.Location = new Point(0, 0); + dataGridViewTeachers.MultiSelect = false; + dataGridViewTeachers.Name = "dataGridViewTeachers"; + dataGridViewTeachers.ReadOnly = true; + dataGridViewTeachers.RowHeadersVisible = false; + dataGridViewTeachers.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewTeachers.Size = new Size(836, 431); + dataGridViewTeachers.TabIndex = 3; + // + // TeachersList + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(961, 431); + Controls.Add(dataGridViewTeachers); + Controls.Add(panel1); + Name = "TeachersList"; + Text = "Преподаватели"; + Load += TeachersList_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewTeachers).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button ButtonAdd; + private Button ButtonUpd; + private Button ButtonDel; + private DataGridView dataGridViewTeachers; + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.cs new file mode 100644 index 0000000..6c8688a --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.cs @@ -0,0 +1,106 @@ +using SessionResults_Kudyaeva.Repositories; +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; +using Unity; + +namespace SessionResults_Kudyaeva.Forms; + +public partial class TeachersList : Form +{ + private readonly IUnityContainer _container; + private readonly ITeacherRepository _teacherRepository; + + public TeachersList(IUnityContainer container, ITeacherRepository teacherRepository) + { + InitializeComponent(); + + _container = container ?? throw new ArgumentNullException(nameof(container)); + _teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository)); + } + + private void TeachersList_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 ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _teacherRepository.DeleteTeacher(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewTeachers.DataSource = _teacherRepository.GetAllTeachers(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewTeachers.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridViewTeachers.SelectedRows[0].Cells["ID"].Value); + return true; + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Forms/TeachersList.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/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Program.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Program.cs index d2e7923..fa75fdf 100644 --- a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Program.cs +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Program.cs @@ -1,3 +1,9 @@ +using SessionResults_Kudyaeva.Repositories.Implementations; +using SessionResults_Kudyaeva.Repositories; +using Unity.Lifetime; +using Unity; +using System.ComponentModel; + namespace SessionResults_Kudyaeva { internal static class Program @@ -11,7 +17,21 @@ namespace SessionResults_Kudyaeva // 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.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + // + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + + return container; } } } \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Properties/Resources.Designer.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Properties/Resources.Designer.cs new file mode 100644 index 0000000..18c2a5a --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace SessionResults_Kudyaeva.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [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() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [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("SessionResults_Kudyaeva.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Add { + get { + object obj = ResourceManager.GetObject("Add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Del { + get { + object obj = ResourceManager.GetObject("Del", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Upd { + get { + object obj = ResourceManager.GetObject("Upd", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap фон { + get { + object obj = ResourceManager.GetObject("фон", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Properties/Resources.resx b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Properties/Resources.resx new file mode 100644 index 0000000..f317a2a --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/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\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\фон.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Upd.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IAddMarkRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IAddMarkRepository.cs new file mode 100644 index 0000000..e9be827 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IAddMarkRepository.cs @@ -0,0 +1,17 @@ +using SessionResults_Kudyaeva.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Repositories; + +public interface IAddMarkRepository +{ + void CreateMark(AddMark addMark); + void UpdateMark(AddMark addMark); + void DeleteMark(int id); + AddMark GetMarkById(int id); + IEnumerable GetAllMarks(); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IDisciplineRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IDisciplineRepository.cs new file mode 100644 index 0000000..cfc43f2 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IDisciplineRepository.cs @@ -0,0 +1,17 @@ +using SessionResults_Kudyaeva.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Repositories; + +public interface IDisciplineRepository +{ + IEnumerable GetAllDisciplines(); + Discipline GetDisciplineById(int id); + void AddDiscipline(Discipline discipline); + void UpdateDiscipline(Discipline discipline); + void DeleteDiscipline(int id); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IGroupRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IGroupRepository.cs new file mode 100644 index 0000000..fba796e --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IGroupRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SessionResults_Kudyaeva.Entities; + +namespace SessionResults_Kudyaeva.Repositories; + +public interface IGroupRepository +{ + IEnumerable GetAllGroups(); + Group GetGroupById(int id); + void AddGroup(Group group); + void UpdateGroup(Group group); + void DeleteGroup(int id); +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IStudentRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IStudentRepository.cs new file mode 100644 index 0000000..d19df37 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/IStudentRepository.cs @@ -0,0 +1,17 @@ +using SessionResults_Kudyaeva.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Repositories; + +public interface IStudentRepository +{ + IEnumerable GetAllStudents(); + Student GetStudentById(int id); + void AddStudent(Student student); + void UpdateStudent(Student student); + void DeleteStudent(int id); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/ITeacherRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/ITeacherRepository.cs new file mode 100644 index 0000000..c04c5d7 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/ITeacherRepository.cs @@ -0,0 +1,17 @@ +using SessionResults_Kudyaeva.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Repositories; + +public interface ITeacherRepository +{ + IEnumerable GetAllTeachers(); + Teacher GetTeacherById(int id); + void AddTeacher(Teacher teacher); + void UpdateTeacher(Teacher teacher); + void DeleteTeacher(int id); +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/AddMarkRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/AddMarkRepository.cs new file mode 100644 index 0000000..d328f58 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/AddMarkRepository.cs @@ -0,0 +1,39 @@ +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SessionResults_Kudyaeva.Repositories.Implementations; + +public class AddMarkRepository : IAddMarkRepository +{ + public void CreateMark(AddMark addMark) + { + // Заглушка + } + + public void UpdateMark(AddMark addMark) + { + // Заглушка + } + + public void DeleteMark(int id) + { + // Заглушка + } + + public AddMark GetMarkById(int id) + { + // Возвращаем объект с фиктивными данными, убедившись, что Mark.One существует + return AddMark.CreateOperation(0, 0, 0, 0, Mark.One); // Убедитесь, что Mark.One определен + } + + public IEnumerable GetAllMarks() + { + // Заглушка + return new List(); + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/DisciplineRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/DisciplineRepository.cs new file mode 100644 index 0000000..c911c37 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/DisciplineRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Entities.Enums; + +namespace SessionResults_Kudyaeva.Repositories.Implementations; + + +public class DisciplineRepository : IDisciplineRepository +{ + public void AddDiscipline(Discipline discipline) + { + // Заглушка + } + + public void DeleteDiscipline(int id) + { + // Заглушка + } + + public IEnumerable GetAllDisciplines() + { + return new List(); + } + + public Discipline GetDisciplineById(int id) + { + return Discipline.Create(0, string.Empty, string.Empty, Course.None); + } + + public void UpdateDiscipline(Discipline discipline) + { + // Заглушка + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/GroupRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/GroupRepository.cs new file mode 100644 index 0000000..cd69813 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/GroupRepository.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Entities.Enums; + +namespace SessionResults_Kudyaeva.Repositories.Implementations; + + +public class GroupRepository : IGroupRepository +{ + public void AddGroup(Group group) + { + // Заглушка + } + + public void DeleteGroup(int id) + { + // Заглушка + } + + public IEnumerable GetAllGroups() + { + return new List(); + } + + public Group GetGroupById(int id) + { + return Group.Create(0, string.Empty, GroupType.Daytime); + } + + public void UpdateGroup(Group group) + { + // Заглушка + } +} diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/StudentRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/StudentRepository.cs new file mode 100644 index 0000000..1eeaf6f --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/StudentRepository.cs @@ -0,0 +1,39 @@ +using SessionResults_Kudyaeva.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SessionResults_Kudyaeva.Entities.Enums; + +namespace SessionResults_Kudyaeva.Repositories.Implementations; + +using System.Collections.Generic; + +public class StudentRepository : IStudentRepository +{ + public void AddStudent(Student student) + { + // Заглушка + } + + public void DeleteStudent(int id) + { + // Заглушка + } + + public IEnumerable GetAllStudents() + { + return new List(); + } + + public Student GetStudentById(int id) + { + return Student.Create(0, string.Empty, string.Empty, string.Empty, 0); + } + + public void UpdateStudent(Student student) + { + // Заглушка + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/TeacherRepository.cs b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/TeacherRepository.cs new file mode 100644 index 0000000..ea25683 --- /dev/null +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Repositories/Implementations/TeacherRepository.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SessionResults_Kudyaeva.Entities; +using SessionResults_Kudyaeva.Entities.Enums; + +namespace SessionResults_Kudyaeva.Repositories.Implementations; + + +using System.Collections.Generic; + +public class TeacherRepository : ITeacherRepository +{ + public void AddTeacher(Teacher teacher) + { + // Заглушка + } + + public void DeleteTeacher(int id) + { + // Заглушка + } + + public IEnumerable GetAllTeachers() + { + return new List(); + } + + public Teacher GetTeacherById(int id) + { + return Teacher.Create(0, string.Empty, string.Empty, string.Empty, 0); + } + + public void UpdateTeacher(Teacher teacher) + { + // Заглушка + } +} \ No newline at end of file diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Add.png b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Add.png new file mode 100644 index 0000000..079cda0 Binary files /dev/null and b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Add.png differ diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Del.png b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Del.png new file mode 100644 index 0000000..2b4c356 Binary files /dev/null and b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Del.png differ diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Upd.png b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Upd.png new file mode 100644 index 0000000..79dd85f Binary files /dev/null and b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/Upd.png differ diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/фон.jpg b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/фон.jpg new file mode 100644 index 0000000..524291c Binary files /dev/null and b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/Resources/фон.jpg differ diff --git a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/SessionResults_Kudyaeva.csproj b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/SessionResults_Kudyaeva.csproj index 663fdb8..accbdf0 100644 --- a/SessionResults_Kudyaeva/SessionResults_Kudyaeva/SessionResults_Kudyaeva.csproj +++ b/SessionResults_Kudyaeva/SessionResults_Kudyaeva/SessionResults_Kudyaeva.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file