Compare commits

...

3 Commits

66 changed files with 4945 additions and 75 deletions

49
2labOTP.sql Normal file
View File

@ -0,0 +1,49 @@
-- Таблица Teacher
CREATE TABLE Teacher (
ID SERIAL PRIMARY KEY,
Surname VARCHAR(255) NOT NULL,
Name VARCHAR(255) NOT NULL,
MiddleName VARCHAR(255)
);
-- Таблица Group
CREATE TABLE "Group" (
ID SERIAL PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Type INT NOT NULL
);
-- Таблица Student
CREATE TABLE Student (
ID SERIAL PRIMARY KEY,
Surname VARCHAR(255) NOT NULL,
Name VARCHAR(255) NOT NULL,
MiddleName VARCHAR(255),
GroupID INT NOT NULL REFERENCES "Group"(ID) ON DELETE CASCADE
);
-- Таблица Discipline
CREATE TABLE Discipline (
ID SERIAL PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Description TEXT NOT NULL,
Courses INT NOT NULL,
TeacherId INT NOT NULL REFERENCES Teacher(ID) ON DELETE CASCADE
);
-- Таблица Statement
CREATE TABLE Statement (
ID SERIAL PRIMARY KEY,
TeacherId INT NOT NULL REFERENCES Teacher(ID) ON DELETE CASCADE,
DisciplineId INT NOT NULL REFERENCES Discipline(ID) ON DELETE CASCADE,
Date DATE NOT NULL
);
-- Таблица StatementStudent (многие ко многим)
CREATE TABLE StatementStudent (
ID SERIAL PRIMARY KEY,
StudentId INT NOT NULL REFERENCES Student(ID) ON DELETE CASCADE,
StatementId INT NOT NULL REFERENCES Statement(ID) ON DELETE CASCADE,
Mark INT NOT NULL
);

View File

@ -0,0 +1,22 @@
using SessionResults_Kudyaeva.Entities.Enums;
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
};
}
}

View File

@ -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,
First = 1, // 1 курс
Second = 2, // 2 курс
Third = 4, // 3 курс
Fourth = 8 // 4 курс
}

View File

@ -0,0 +1,8 @@
namespace SessionResults_Kudyaeva.Entities.Enums;
public enum GroupType
{
Daytime, // Дневная
Evening, // Вечерняя
FullTimeDistance // Очно-заочная
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SessionResults_Kudyaeva.Entities.Enums;
public enum Mark
{
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5
}

View File

@ -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
};
}
}

View File

@ -0,0 +1,22 @@
namespace SessionResults_Kudyaeva.Entities;
public class Statement
{
public int Id { get; private set; }
public int TeacherId { get; private set; }
public int DisciplineId { get; private set; }
public DateTime Date { get; private set; }
public IEnumerable<StatementStudent> StatementStudents { get; private set; } = [];
public static Statement CreateOperation(int id, int teacherId, int disciplineId, IEnumerable<StatementStudent> statementStudents)
{
return new Statement
{
Id = id,
TeacherId = teacherId,
DisciplineId = disciplineId,
Date = DateTime.Now,
StatementStudents = statementStudents
};
}
}

View File

@ -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 StatementStudent
{
public int Id { get; private set; }
public int StudentId { get; private set; }
public Mark Mark { get; private set; }
public static StatementStudent CreateOperation(int id, int studentId, Mark mark)
{
return new StatementStudent
{
Id = id,
StudentId = studentId,
Mark = mark
};
}
}

View File

@ -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;
using static System.Runtime.InteropServices.JavaScript.JSType;
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 string DisplayName => $"{Surname} {Name[0]}. {MiddleName[0]}.";
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
};
}
}

View File

@ -0,0 +1,27 @@
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 string DisplayName => $"{Surname} {Name[0]}. {MiddleName[0]}.";
public static Teacher Create(int id, string surname, string name, string middleName)
{
return new Teacher
{
ID = id,
Surname = surname,
Name = name,
MiddleName = middleName
};
}
}

View File

@ -1,39 +0,0 @@
namespace SessionResults_Kudyaeva
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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
}
}

View File

@ -1,10 +0,0 @@
namespace SessionResults_Kudyaeva
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,137 @@
namespace SessionResults_Kudyaeva
{
partial class FormSessionResults
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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(180, 22);
StudentsToolStripMenuItem.Text = "Студенты";
StudentsToolStripMenuItem.Click += StudentsToolStripMenuItem_Click;
//
// GroupsToolStripMenuItem
//
GroupsToolStripMenuItem.Name = "GroupsToolStripMenuItem";
GroupsToolStripMenuItem.Size = new Size(180, 22);
GroupsToolStripMenuItem.Text = "Группы";
GroupsToolStripMenuItem.Click += GroupsToolStripMenuItem_Click;
//
// TeachersToolStripMenuItem
//
TeachersToolStripMenuItem.Name = "TeachersToolStripMenuItem";
TeachersToolStripMenuItem.Size = new Size(180, 22);
TeachersToolStripMenuItem.Text = "Преподаватели";
TeachersToolStripMenuItem.Click += TeachersToolStripMenuItem_Click;
//
// DisciplinesToolStripMenuItem
//
DisciplinesToolStripMenuItem.Name = "DisciplinesToolStripMenuItem";
DisciplinesToolStripMenuItem.Size = new Size(180, 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(236, 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;
}
}

View File

@ -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<StudentsList>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void GroupsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<GroupsListForm>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TeachersToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<TeachersList>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DisciplinesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<DisciplineListForm>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddMarksToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<StatementListForm>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,141 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class DisciplineForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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(41, 349);
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(235, 349);
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, 384);
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;
}
}

View File

@ -0,0 +1,105 @@
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);
}
}

View File

@ -0,0 +1,125 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class DisciplineListForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<DisciplineForm>().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<DisciplineForm>();
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;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,119 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class GroupForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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!);
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,125 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class GroupsListForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<GroupForm>().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<GroupForm>();
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;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,172 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class StatementForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
label1 = new Label();
label2 = new Label();
ButtonSave = new Button();
ButtonCancel = new Button();
comboBoxDiscipline = new ComboBox();
comboBoxTeacher = new ComboBox();
dataGridView = new DataGridView();
groupBox1 = new GroupBox();
ColumnStudent = new DataGridViewComboBoxColumn();
ColumnMark = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
groupBox1.SuspendLayout();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(53, 19);
label1.Name = "label1";
label1.Size = new Size(55, 15);
label1.TabIndex = 0;
label1.Text = "Предмет";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(17, 57);
label2.Name = "label2";
label2.Size = new Size(91, 15);
label2.TabIndex = 1;
label2.Text = "Преподаватель";
//
// ButtonSave
//
ButtonSave.Location = new Point(12, 307);
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(217, 307);
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(114, 16);
comboBoxDiscipline.Name = "comboBoxDiscipline";
comboBoxDiscipline.Size = new Size(196, 23);
comboBoxDiscipline.TabIndex = 12;
//
// comboBoxTeacher
//
comboBoxTeacher.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxTeacher.FormattingEnabled = true;
comboBoxTeacher.Location = new Point(114, 54);
comboBoxTeacher.Name = "comboBoxTeacher";
comboBoxTeacher.Size = new Size(196, 23);
comboBoxTeacher.TabIndex = 13;
//
// dataGridView
//
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnStudent, ColumnMark });
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(3, 19);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(295, 157);
dataGridView.TabIndex = 14;
//
// groupBox1
//
groupBox1.Controls.Add(dataGridView);
groupBox1.Location = new Point(12, 99);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(301, 179);
groupBox1.TabIndex = 15;
groupBox1.TabStop = false;
groupBox1.Text = "Студенты";
//
// ColumnStudent
//
ColumnStudent.HeaderText = "Студенты";
ColumnStudent.Name = "ColumnStudent";
//
// ColumnMark
//
ColumnMark.HeaderText = "Оценки";
ColumnMark.Name = "ColumnMark";
ColumnMark.Resizable = DataGridViewTriState.True;
ColumnMark.SortMode = DataGridViewColumnSortMode.NotSortable;
//
// StatementForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(324, 342);
Controls.Add(groupBox1);
Controls.Add(comboBoxTeacher);
Controls.Add(comboBoxDiscipline);
Controls.Add(ButtonCancel);
Controls.Add(ButtonSave);
Controls.Add(label2);
Controls.Add(label1);
Name = "StatementForm";
Text = "Результат сессии";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
groupBox1.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Button ButtonSave;
private Button ButtonCancel;
private ComboBox comboBoxDiscipline;
private ComboBox comboBoxTeacher;
private DataGridView dataGridView;
private GroupBox groupBox1;
private DataGridViewComboBoxColumn ColumnStudent;
private DataGridViewTextBoxColumn ColumnMark;
}
}

View File

@ -0,0 +1,75 @@
using SessionResults_Kudyaeva.Entities;
using SessionResults_Kudyaeva.Entities.Enums;
using SessionResults_Kudyaeva.Repositories;
namespace SessionResults_Kudyaeva.Forms;
public partial class StatementForm : Form
{
private readonly IStatementRepository _statementRepository;
private readonly ITeacherRepository _teacherRepository;
private readonly IDisciplineRepository _disciplineRepository;
public StatementForm(IStatementRepository statementRepository, ITeacherRepository teacherRepository, IDisciplineRepository disciplineRepository, IStudentRepository studentRepository)
{
InitializeComponent();
_statementRepository = statementRepository ?? throw new ArgumentNullException(nameof(statementRepository));
_teacherRepository = teacherRepository ?? throw new ArgumentNullException(nameof(teacherRepository));
_disciplineRepository = disciplineRepository ?? throw new ArgumentNullException(nameof(disciplineRepository));
comboBoxTeacher.DataSource = _teacherRepository.GetAllTeachers();
comboBoxTeacher.DisplayMember = "Name";
comboBoxTeacher.ValueMember = "Id";
comboBoxDiscipline.DataSource = _disciplineRepository.GetAllDisciplines();
comboBoxDiscipline.DisplayMember = "Name";
comboBoxDiscipline.ValueMember = "Id";
ColumnStudent.DataSource = studentRepository.GetAllStudents();
ColumnStudent.DisplayMember = "DisplayName";
ColumnStudent.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxTeacher.SelectedIndex < 0 || comboBoxDiscipline.SelectedIndex < 0 || dataGridView.RowCount < 1)
{
throw new Exception("Имеются незаполненные поля");
}
_statementRepository.CreateStatement(Statement.CreateOperation(0,
(int)comboBoxTeacher.SelectedValue!,
(int)comboBoxDiscipline.SelectedValue!,
CreateListStatementStudentFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private List<StatementStudent> CreateListStatementStudentFromDataGrid()
{
var list = new List<StatementStudent>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnStudent"].Value == null ||
row.Cells["ColumnMark"].Value == null)
{
continue;
}
list.Add(StatementStudent.CreateOperation(0,
Convert.ToInt32(row.Cells["ColumnStudent"].Value),
(Mark)Convert.ToInt32(row.Cells["ColumnMark"].Value)));
}
return list;
}
}

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnStudent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnMark.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,97 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class StatementListForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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, 12);
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;
//
// StatementListForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(959, 449);
Controls.Add(dataGridViewData);
Controls.Add(panel1);
Name = "StatementListForm";
Text = "Создание результатов сессии";
Load += AddMarkListForm_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button ButtonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,45 @@
using SessionResults_Kudyaeva.Repositories;
using Unity;
namespace SessionResults_Kudyaeva.Forms;
public partial class StatementListForm : Form
{
private readonly IUnityContainer _container;
private readonly IStatementRepository _statementRepository;
public StatementListForm(IUnityContainer container, IStatementRepository statementRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_statementRepository = statementRepository ?? throw new ArgumentNullException(nameof(statementRepository));
}
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<StatementForm>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _statementRepository.GetAllStatements();
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,163 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class StudentForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -0,0 +1,97 @@
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 readonly IGroupRepository _groupRepository;
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, IGroupRepository groupRepository)
{
InitializeComponent();
comboBoxGroup.DataSource = groupRepository.GetAllGroups();
comboBoxGroup.DisplayMember = "Name";
comboBoxGroup.ValueMember = "Id";
_studentRepository = studentRepository ??
throw new ArgumentNullException(nameof(studentRepository));
_groupRepository = groupRepository ??
throw new ArgumentNullException(nameof(groupRepository));
}
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!);
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,126 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class StudentsList
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<StudentForm>().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<StudentForm>();
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;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,138 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class TeacherForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
ButtonSave = new Button();
ButtonCancel = new Button();
labelSurname = new Label();
label2 = new Label();
label3 = new Label();
textBoxSurname = new TextBox();
textBoxName = new TextBox();
textBoxMiddleName = new TextBox();
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;
ButtonSave.Click += ButtonSave_Click;
//
// 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 = "Отчество";
//
// 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;
//
// TeacherForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(388, 249);
Controls.Add(textBoxMiddleName);
Controls.Add(textBoxName);
Controls.Add(textBoxSurname);
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 TextBox textBoxSurname;
private TextBox textBoxName;
private TextBox textBoxMiddleName;
}
}

View File

@ -0,0 +1,86 @@
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;
_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);
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,125 @@
namespace SessionResults_Kudyaeva.Forms
{
partial class TeachersList
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<TeacherForm>().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<TeacherForm>();
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;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,3 +1,14 @@
using SessionResults_Kudyaeva.Repositories.Implementations;
using SessionResults_Kudyaeva.Repositories;
using Unity.Lifetime;
using Unity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
using Unity.Microsoft.Logging;
using ProjectGasStation.Repositories.Implementations;
using ProjectGasStation.Repositories;
namespace SessionResults_Kudyaeva
{
internal static class Program
@ -11,7 +22,36 @@ 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<FormSessionResults>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
// Ðåãèñòðàöèÿ ðåïîçèòîðèåâ
container.RegisterType<IStudentRepository, StudentRepository>(new TransientLifetimeManager());
container.RegisterType<IGroupRepository, GroupRepository>(new TransientLifetimeManager());
container.RegisterType<ITeacherRepository, TeacherRepository>(new TransientLifetimeManager());
container.RegisterType<IDisciplineRepository, DisciplineRepository>(new TransientLifetimeManager());
container.RegisterType<IStatementRepository, StatementRepository>(new TransientLifetimeManager());
container.RegisterType<IConnectionString, ConnectionString>();
return container;
}
private static LoggerFactory CreateLoggerFactory()
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build())
.CreateLogger());
return loggerFactory;
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SessionResults_Kudyaeva.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом 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() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[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;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Add {
get {
object obj = ResourceManager.GetObject("Add", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Del {
get {
object obj = ResourceManager.GetObject("Del", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Upd {
get {
object obj = ResourceManager.GetObject("Upd", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap фон {
get {
object obj = ResourceManager.GetObject("фон", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="фон" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\фон.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Del" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Upd" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Upd.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IConnectionString
{
public string ConnectionString { get; }
}

View File

@ -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<Discipline> GetAllDisciplines();
Discipline GetDisciplineById(int id);
void AddDiscipline(Discipline discipline);
void UpdateDiscipline(Discipline discipline);
void DeleteDiscipline(int id);
}

View File

@ -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<Group> GetAllGroups();
Group GetGroupById(int id);
void AddGroup(Group group);
void UpdateGroup(Group group);
void DeleteGroup(int id);
}

View File

@ -0,0 +1,14 @@
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 IStatementRepository
{
void CreateStatement(Statement statement);
IEnumerable<Statement> GetAllStatements();
}

View File

@ -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<Student> GetAllStudents();
Student GetStudentById(int id);
void AddStudent(Student student);
void UpdateStudent(Student student);
void DeleteStudent(int id);
}

View File

@ -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<Teacher> GetAllTeachers();
Teacher GetTeacherById(int id);
void AddTeacher(Teacher teacher);
void UpdateTeacher(Teacher teacher);
void DeleteTeacher(int id);
}

View File

@ -0,0 +1,6 @@
namespace ProjectGasStation.Repositories.Implementations;
public class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=student;Password=030405;Database=OTP3";
}

View File

@ -0,0 +1,125 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectGasStation.Repositories;
using SessionResults_Kudyaeva.Entities;
namespace SessionResults_Kudyaeva.Repositories.Implementations;
public class DisciplineRepository : IDisciplineRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<DisciplineRepository> _logger;
public DisciplineRepository(IConnectionString connectionString, ILogger<DisciplineRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void AddDiscipline(Discipline discipline)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(discipline));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Discipline (Name, Description, Courses)
VALUES (@Name, @Description, @Courses)";
connection.Execute(queryInsert, discipline);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteDiscipline(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Discipline
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Discipline> GetAllDisciplines()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Discipline";
var disciplines = connection.Query<Discipline>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(disciplines));
return disciplines;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Discipline GetDisciplineById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Discipline
WHERE Id=@id";
var discipline = connection.QueryFirst<Discipline>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(discipline));
return discipline;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateDiscipline(Discipline discipline)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(discipline));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Discipline
SET
Name=@Name,
Description=@Description,
Courses=@Courses
WHERE Id=@Id";
connection.Execute(queryUpdate, discipline);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,124 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectGasStation.Repositories;
using SessionResults_Kudyaeva.Entities;
namespace SessionResults_Kudyaeva.Repositories.Implementations;
public class GroupRepository : IGroupRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<GroupRepository> _logger;
public GroupRepository(IConnectionString connectionString, ILogger<GroupRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void AddGroup(Group group)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(group));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO ""Group"" (Name, Type)
VALUES (@Name, @Type)";
connection.Execute(queryInsert, group);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteGroup(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM ""Group""
WHERE ID = @id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Group> GetAllGroups()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM \"Group\"";
var groups = connection.Query<Group>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(groups));
return groups;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Group GetGroupById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM ""Group""
WHERE Id=@id";
var group = connection.QueryFirst<Group>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(group));
return group;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateGroup(Group group)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(group));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE ""Group""
SET
Name=@Name,
Type=@Type
WHERE Id=@Id";
connection.Execute(queryUpdate, group);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,76 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectGasStation.Repositories;
using SessionResults_Kudyaeva.Entities;
namespace SessionResults_Kudyaeva.Repositories.Implementations;
public class StatementRepository : IStatementRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<StatementRepository> _logger;
public StatementRepository(IConnectionString connectionString, ILogger<StatementRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateStatement(Statement statement)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(statement));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Statement (TeacherId, DisciplineId, Date)
VALUES (@TeacherId, @DisciplineId, @Date);
SELECT MAX(Id) FROM Statement";
var statementId =
connection.QueryFirst<int>(queryInsert, statement, transaction);
var querySubInsert = @"
INSERT INTO StatementStudent (StatementId, StudentId, Mark)
VALUES (@StatementId, @StudentId, @Mark)";
foreach (var elem in statement.StatementStudents)
{
connection.Execute(querySubInsert, new
{
statementId,
elem.StudentId,
elem.Mark
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public IEnumerable<Statement> GetAllStatements()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Statement";
var statements = connection.Query<Statement>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(statements));
return statements;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,125 @@
using SessionResults_Kudyaeva.Entities;
using Microsoft.Extensions.Logging;
using ProjectGasStation.Repositories;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace SessionResults_Kudyaeva.Repositories.Implementations;
public class StudentRepository : IStudentRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<StudentRepository> _logger;
public StudentRepository(IConnectionString connectionString, ILogger<StudentRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void AddStudent(Student student)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(student));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Student (Surname, Name, MiddleName, GroupID)
VALUES (@Surname, @Name, @MiddleName, @GroupID)";
connection.Execute(queryInsert, student);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteStudent(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Student
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Student> GetAllStudents()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Student";
var students = connection.Query<Student>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(students));
return students;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Student GetStudentById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Student
WHERE Id=@id";
var student = connection.QueryFirst<Student>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(student));
return student;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateStudent(Student student)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(student));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Student
SET
Surname=@Surname,
Name=@Name,
MiddleName=@MiddleName,
GroupID=@GroupID
WHERE Id=@Id";
connection.Execute(queryUpdate, student);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,123 @@
using SessionResults_Kudyaeva.Entities;
using Microsoft.Extensions.Logging;
using ProjectGasStation.Repositories;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace SessionResults_Kudyaeva.Repositories.Implementations;
public class TeacherRepository : ITeacherRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<TeacherRepository> _logger;
public TeacherRepository(IConnectionString connectionString, ILogger<TeacherRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void AddTeacher(Teacher teacher)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(teacher));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Teacher (Surname, Name, MiddleName)
VALUES (@Surname, @Name, @MiddleName)";
connection.Execute(queryInsert, teacher);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteTeacher(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Teacher
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Teacher> GetAllTeachers()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Teacher";
var teachers = connection.Query<Teacher>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(teachers));
return teachers;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Teacher GetTeacherById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Teacher
WHERE Id=@id";
var teacher = connection.QueryFirst<Teacher>(querySelect, new { id });
_logger.LogDebug("Найденный объект: {json}",
JsonConvert.SerializeObject(teacher));
return teacher;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateTeacher(Teacher teacher)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(teacher));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Teacher
SET
Surname=@Surname,
Name=@Name,
MiddleName=@MiddleName
WHERE Id=@Id";
connection.Execute(queryUpdate, teacher);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -8,4 +8,34 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs/gas_log.txt",
"rollingInterval": "Day"
}
}
]
}
}