Добавьте файлы проекта.
This commit is contained in:
parent
1b8a1a795a
commit
9b56b9e0f5
49
Journal.sln
Normal file
49
Journal.sln
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.9.34714.143
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JournalView", "Journal\JournalView.csproj", "{2B4A5A98-6D06-4461-8D41-363CED12B9C2}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JournalDataModels", "JournalDataModels\JournalDataModels.csproj", "{C373ED9F-747E-47D0-9B7C-B65E062CD537}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JournalContracts", "JournalContracts\JournalContracts.csproj", "{1FD289B3-1422-4535-8969-2F320754517B}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JournalBusinessLogic", "JournalBusinessLogic\JournalBusinessLogic.csproj", "{9CB0FFA6-FA25-440C-8B6A-B6DF2F0639F5}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JournalDatabaseImplement", "JournalDatabaseImplement\JournalDatabaseImplement.csproj", "{E62F051D-30D6-4F1C-B02E-C814B7D03F86}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{2B4A5A98-6D06-4461-8D41-363CED12B9C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2B4A5A98-6D06-4461-8D41-363CED12B9C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2B4A5A98-6D06-4461-8D41-363CED12B9C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2B4A5A98-6D06-4461-8D41-363CED12B9C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C373ED9F-747E-47D0-9B7C-B65E062CD537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C373ED9F-747E-47D0-9B7C-B65E062CD537}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C373ED9F-747E-47D0-9B7C-B65E062CD537}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C373ED9F-747E-47D0-9B7C-B65E062CD537}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1FD289B3-1422-4535-8969-2F320754517B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1FD289B3-1422-4535-8969-2F320754517B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1FD289B3-1422-4535-8969-2F320754517B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1FD289B3-1422-4535-8969-2F320754517B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9CB0FFA6-FA25-440C-8B6A-B6DF2F0639F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9CB0FFA6-FA25-440C-8B6A-B6DF2F0639F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9CB0FFA6-FA25-440C-8B6A-B6DF2F0639F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9CB0FFA6-FA25-440C-8B6A-B6DF2F0639F5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E62F051D-30D6-4F1C-B02E-C814B7D03F86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E62F051D-30D6-4F1C-B02E-C814B7D03F86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E62F051D-30D6-4F1C-B02E-C814B7D03F86}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{E62F051D-30D6-4F1C-B02E-C814B7D03F86}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {86A1AF32-AD3E-4D5E-B57B-4AE61FD58DF7}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
149
Journal/FormGrade.Designer.cs
generated
Normal file
149
Journal/FormGrade.Designer.cs
generated
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormGrade
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
textBoxMark = new TextBox();
|
||||||
|
comboBoxSubject = new ComboBox();
|
||||||
|
comboBoxType = new ComboBox();
|
||||||
|
label3 = new Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(14, 12);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(70, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Предмет";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(15, 92);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(61, 20);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Оценка";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(269, 139);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(103, 35);
|
||||||
|
buttonCancel.TabIndex = 12;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(159, 139);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(103, 35);
|
||||||
|
buttonSave.TabIndex = 11;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// textBoxMark
|
||||||
|
//
|
||||||
|
textBoxMark.Location = new Point(88, 88);
|
||||||
|
textBoxMark.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxMark.Name = "textBoxMark";
|
||||||
|
textBoxMark.Size = new Size(284, 27);
|
||||||
|
textBoxMark.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// comboBoxSubject
|
||||||
|
//
|
||||||
|
comboBoxSubject.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxSubject.FormattingEnabled = true;
|
||||||
|
comboBoxSubject.Location = new Point(88, 8);
|
||||||
|
comboBoxSubject.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxSubject.Name = "comboBoxSubject";
|
||||||
|
comboBoxSubject.Size = new Size(284, 28);
|
||||||
|
comboBoxSubject.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// comboBoxType
|
||||||
|
//
|
||||||
|
comboBoxType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxType.FormattingEnabled = true;
|
||||||
|
comboBoxType.Location = new Point(88, 52);
|
||||||
|
comboBoxType.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxType.Name = "comboBoxType";
|
||||||
|
comboBoxType.Size = new Size(284, 28);
|
||||||
|
comboBoxType.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(14, 56);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(39, 20);
|
||||||
|
label3.TabIndex = 13;
|
||||||
|
label3.Text = "Тип ";
|
||||||
|
//
|
||||||
|
// FormGrade
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(422, 201);
|
||||||
|
Controls.Add(comboBoxType);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(textBoxMark);
|
||||||
|
Controls.Add(comboBoxSubject);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormGrade";
|
||||||
|
Text = "Оценка";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private TextBox textBoxMark;
|
||||||
|
private ComboBox comboBoxSubject;
|
||||||
|
private ComboBox comboBoxType;
|
||||||
|
private Label label3;
|
||||||
|
}
|
||||||
|
}
|
99
Journal/FormGrade.cs
Normal file
99
Journal/FormGrade.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataModels.Enum;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography.Xml;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormGrade : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly List<SubjectViewModel>? _list;
|
||||||
|
public int Id { get { return Convert.ToInt32(comboBoxSubject.SelectedValue); } set { comboBoxSubject.SelectedValue = value; } }
|
||||||
|
|
||||||
|
public ISubjectModel? SubjectModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _list)
|
||||||
|
{
|
||||||
|
if (elem.Id == Id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExamType Type { get { return (ExamType)comboBoxType.SelectedIndex; } set {
|
||||||
|
comboBoxType.SelectedValue = (int)value;
|
||||||
|
Console.WriteLine(value.ToString());
|
||||||
|
} }
|
||||||
|
|
||||||
|
public int Mark { get { return Convert.ToInt32(textBoxMark.Text); } set { textBoxMark.Text = value.ToString(); } }
|
||||||
|
public FormGrade(ISubjectLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_list = logic.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxSubject.DisplayMember = "SubjectName";
|
||||||
|
comboBoxSubject.ValueMember = "Id";
|
||||||
|
comboBoxSubject.DataSource = _list;
|
||||||
|
comboBoxSubject.SelectedItem = null;
|
||||||
|
}
|
||||||
|
List<KOSTILISHE> kostil = new List<KOSTILISHE>();
|
||||||
|
foreach (ExamType value in Enum.GetValues(typeof(ExamType)))
|
||||||
|
{
|
||||||
|
kostil.Add(new KOSTILISHE (value));
|
||||||
|
}
|
||||||
|
comboBoxType.DisplayMember = "pole";
|
||||||
|
comboBoxType.ValueMember = "pomogi";
|
||||||
|
comboBoxType.DataSource = kostil;
|
||||||
|
comboBoxType.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxMark.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Оценка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxSubject.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите предмет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxType.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите тип", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormGrade.resx
Normal file
120
Journal/FormGrade.resx
Normal 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>
|
123
Journal/FormGroup.Designer.cs
generated
Normal file
123
Journal/FormGroup.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormGroup
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
textBoxCourse = new TextBox();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(14, 12);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(77, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Название";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(14, 62);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(41, 20);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Курс";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(103, 8);
|
||||||
|
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(249, 27);
|
||||||
|
textBoxName.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxCourse
|
||||||
|
//
|
||||||
|
textBoxCourse.Location = new Point(103, 55);
|
||||||
|
textBoxCourse.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxCourse.Name = "textBoxCourse";
|
||||||
|
textBoxCourse.Size = new Size(249, 27);
|
||||||
|
textBoxCourse.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(264, 104);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(88, 40);
|
||||||
|
buttonCancel.TabIndex = 7;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(169, 104);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(95, 40);
|
||||||
|
buttonSave.TabIndex = 6;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// FormGroup
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(367, 158);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(textBoxCourse);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormGroup";
|
||||||
|
Text = "Группа";
|
||||||
|
Load += FormMenu_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxCourse;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
}
|
||||||
|
}
|
86
Journal/FormGroup.cs
Normal file
86
Journal/FormGroup.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormGroup : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IGroupLogic _logic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormGroup(IGroupLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMenu_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new GroupSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.GroupName;
|
||||||
|
textBoxCourse.Text = view.Course.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text) || string.IsNullOrEmpty(textBoxCourse.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new GroupBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
GroupName = textBoxName.Text,
|
||||||
|
Course = Convert.ToInt32(textBoxCourse.Text),
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormGroup.resx
Normal file
120
Journal/FormGroup.resx
Normal 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>
|
112
Journal/FormGroups.Designer.cs
generated
Normal file
112
Journal/FormGroups.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormGroups
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(625, 151);
|
||||||
|
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(135, 47);
|
||||||
|
buttonDel.TabIndex = 7;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += buttonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(625, 83);
|
||||||
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(135, 47);
|
||||||
|
buttonUpd.TabIndex = 6;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(625, 16);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(135, 47);
|
||||||
|
buttonAdd.TabIndex = 5;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(563, 600);
|
||||||
|
dataGridView.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// FormGroups
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(811, 600);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(buttonUpd);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormGroups";
|
||||||
|
Text = "Группы";
|
||||||
|
Load += FormGroups_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
100
Journal/FormGroups.cs
Normal file
100
Journal/FormGroups.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalView;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormGroups : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IGroupLogic _logic;
|
||||||
|
|
||||||
|
public FormGroups(IGroupLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormGroups_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGroup));
|
||||||
|
if (service is FormGroup form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGroup));
|
||||||
|
if (service is FormGroup form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new GroupBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormGroups.resx
Normal file
120
Journal/FormGroups.resx
Normal 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>
|
259
Journal/FormMain.Designer.cs
generated
Normal file
259
Journal/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
namespace SushiBarView
|
||||||
|
{
|
||||||
|
partial class FormMain
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
studentToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
teacherToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
groupToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
subjectToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
buttonTestGroup100 = new Button();
|
||||||
|
buttonTestSubject100 = new Button();
|
||||||
|
buttonTestTeacher100 = new Button();
|
||||||
|
buttonTestStudent1000 = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonTestJoinGroups = new Button();
|
||||||
|
buttonTestStudentD1000 = new Button();
|
||||||
|
buttonTestTeacherD100 = new Button();
|
||||||
|
buttonTestSubjectD100 = new Button();
|
||||||
|
buttonTestGroupD100 = new Button();
|
||||||
|
menuStrip1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// menuStrip1
|
||||||
|
//
|
||||||
|
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
|
menuStrip1.Items.AddRange(new ToolStripItem[] { объектыToolStripMenuItem });
|
||||||
|
menuStrip1.Location = new Point(0, 0);
|
||||||
|
menuStrip1.Name = "menuStrip1";
|
||||||
|
menuStrip1.Padding = new Padding(7, 3, 0, 3);
|
||||||
|
menuStrip1.Size = new Size(1387, 30);
|
||||||
|
menuStrip1.TabIndex = 0;
|
||||||
|
menuStrip1.Text = "menuStrip1";
|
||||||
|
//
|
||||||
|
// объектыToolStripMenuItem
|
||||||
|
//
|
||||||
|
объектыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { studentToolStripMenuItem, teacherToolStripMenuItem, groupToolStripMenuItem, subjectToolStripMenuItem });
|
||||||
|
объектыToolStripMenuItem.Name = "объектыToolStripMenuItem";
|
||||||
|
объектыToolStripMenuItem.Size = new Size(84, 24);
|
||||||
|
объектыToolStripMenuItem.Text = "Объекты";
|
||||||
|
//
|
||||||
|
// studentToolStripMenuItem
|
||||||
|
//
|
||||||
|
studentToolStripMenuItem.Name = "studentToolStripMenuItem";
|
||||||
|
studentToolStripMenuItem.Size = new Size(200, 26);
|
||||||
|
studentToolStripMenuItem.Text = "Студент";
|
||||||
|
studentToolStripMenuItem.Click += studentToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// teacherToolStripMenuItem
|
||||||
|
//
|
||||||
|
teacherToolStripMenuItem.Name = "teacherToolStripMenuItem";
|
||||||
|
teacherToolStripMenuItem.Size = new Size(200, 26);
|
||||||
|
teacherToolStripMenuItem.Text = "Преподаватель";
|
||||||
|
teacherToolStripMenuItem.Click += teacherToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// groupToolStripMenuItem
|
||||||
|
//
|
||||||
|
groupToolStripMenuItem.Name = "groupToolStripMenuItem";
|
||||||
|
groupToolStripMenuItem.Size = new Size(200, 26);
|
||||||
|
groupToolStripMenuItem.Text = "Группа";
|
||||||
|
groupToolStripMenuItem.Click += groupToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// subjectToolStripMenuItem
|
||||||
|
//
|
||||||
|
subjectToolStripMenuItem.Name = "subjectToolStripMenuItem";
|
||||||
|
subjectToolStripMenuItem.Size = new Size(200, 26);
|
||||||
|
subjectToolStripMenuItem.Text = "Предмет";
|
||||||
|
subjectToolStripMenuItem.Click += subjectToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// buttonTestGroup100
|
||||||
|
//
|
||||||
|
buttonTestGroup100.Location = new Point(1106, 275);
|
||||||
|
buttonTestGroup100.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestGroup100.Name = "buttonTestGroup100";
|
||||||
|
buttonTestGroup100.Size = new Size(226, 37);
|
||||||
|
buttonTestGroup100.TabIndex = 11;
|
||||||
|
buttonTestGroup100.Text = "Создать 100 групп";
|
||||||
|
buttonTestGroup100.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestGroup100.Click += buttonTestGroup100_Click;
|
||||||
|
//
|
||||||
|
// buttonTestSubject100
|
||||||
|
//
|
||||||
|
buttonTestSubject100.Location = new Point(1106, 205);
|
||||||
|
buttonTestSubject100.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestSubject100.Name = "buttonTestSubject100";
|
||||||
|
buttonTestSubject100.Size = new Size(226, 37);
|
||||||
|
buttonTestSubject100.TabIndex = 10;
|
||||||
|
buttonTestSubject100.Text = "Создать 100 предметов";
|
||||||
|
buttonTestSubject100.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestSubject100.Click += buttonTestSubject100_Click;
|
||||||
|
//
|
||||||
|
// buttonTestTeacher100
|
||||||
|
//
|
||||||
|
buttonTestTeacher100.Location = new Point(1106, 133);
|
||||||
|
buttonTestTeacher100.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestTeacher100.Name = "buttonTestTeacher100";
|
||||||
|
buttonTestTeacher100.Size = new Size(226, 37);
|
||||||
|
buttonTestTeacher100.TabIndex = 9;
|
||||||
|
buttonTestTeacher100.Text = "Создать 100 преподавателей";
|
||||||
|
buttonTestTeacher100.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestTeacher100.Click += buttonTestTeacher100_Click;
|
||||||
|
//
|
||||||
|
// buttonTestStudent1000
|
||||||
|
//
|
||||||
|
buttonTestStudent1000.Location = new Point(1106, 61);
|
||||||
|
buttonTestStudent1000.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestStudent1000.Name = "buttonTestStudent1000";
|
||||||
|
buttonTestStudent1000.Size = new Size(226, 37);
|
||||||
|
buttonTestStudent1000.TabIndex = 8;
|
||||||
|
buttonTestStudent1000.Text = "Создать 1000 студентов";
|
||||||
|
buttonTestStudent1000.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestStudent1000.Click += buttonTestStudent1000_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 30);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(1049, 622);
|
||||||
|
dataGridView.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonTestJoinGroups
|
||||||
|
//
|
||||||
|
buttonTestJoinGroups.Location = new Point(1106, 349);
|
||||||
|
buttonTestJoinGroups.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestJoinGroups.Name = "buttonTestJoinGroups";
|
||||||
|
buttonTestJoinGroups.Size = new Size(226, 37);
|
||||||
|
buttonTestJoinGroups.TabIndex = 12;
|
||||||
|
buttonTestJoinGroups.Text = "JOIN STUDENT GROUP";
|
||||||
|
buttonTestJoinGroups.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestJoinGroups.Click += buttonTestJoinGroups_Click;
|
||||||
|
//
|
||||||
|
// buttonTestStudentD1000
|
||||||
|
//
|
||||||
|
buttonTestStudentD1000.Location = new Point(1106, 424);
|
||||||
|
buttonTestStudentD1000.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestStudentD1000.Name = "buttonTestStudentD1000";
|
||||||
|
buttonTestStudentD1000.Size = new Size(226, 37);
|
||||||
|
buttonTestStudentD1000.TabIndex = 13;
|
||||||
|
buttonTestStudentD1000.Text = "Удалить 1000 студентов";
|
||||||
|
buttonTestStudentD1000.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestStudentD1000.Click += buttonTestStudentD1000_Click;
|
||||||
|
//
|
||||||
|
// buttonTestTeacherD100
|
||||||
|
//
|
||||||
|
buttonTestTeacherD100.Location = new Point(1106, 489);
|
||||||
|
buttonTestTeacherD100.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestTeacherD100.Name = "buttonTestTeacherD100";
|
||||||
|
buttonTestTeacherD100.Size = new Size(226, 37);
|
||||||
|
buttonTestTeacherD100.TabIndex = 14;
|
||||||
|
buttonTestTeacherD100.Text = "Удалить 100 преподавателей";
|
||||||
|
buttonTestTeacherD100.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestTeacherD100.Click += buttonTestTeacherD100_Click;
|
||||||
|
//
|
||||||
|
// buttonTestSubjectD100
|
||||||
|
//
|
||||||
|
buttonTestSubjectD100.Location = new Point(1106, 551);
|
||||||
|
buttonTestSubjectD100.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestSubjectD100.Name = "buttonTestSubjectD100";
|
||||||
|
buttonTestSubjectD100.Size = new Size(226, 37);
|
||||||
|
buttonTestSubjectD100.TabIndex = 15;
|
||||||
|
buttonTestSubjectD100.Text = "Удалить 100 предметов";
|
||||||
|
buttonTestSubjectD100.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestSubjectD100.Click += buttonTestSubjectD100_Click;
|
||||||
|
//
|
||||||
|
// buttonTestGroupD100
|
||||||
|
//
|
||||||
|
buttonTestGroupD100.Location = new Point(1106, 602);
|
||||||
|
buttonTestGroupD100.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonTestGroupD100.Name = "buttonTestGroupD100";
|
||||||
|
buttonTestGroupD100.Size = new Size(226, 37);
|
||||||
|
buttonTestGroupD100.TabIndex = 16;
|
||||||
|
buttonTestGroupD100.Text = "Удалить 100 групп";
|
||||||
|
buttonTestGroupD100.UseVisualStyleBackColor = true;
|
||||||
|
buttonTestGroupD100.Click += buttonTestGroupD100_Click;
|
||||||
|
//
|
||||||
|
// FormMain
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1387, 652);
|
||||||
|
Controls.Add(buttonTestGroupD100);
|
||||||
|
Controls.Add(buttonTestSubjectD100);
|
||||||
|
Controls.Add(buttonTestTeacherD100);
|
||||||
|
Controls.Add(buttonTestStudentD1000);
|
||||||
|
Controls.Add(buttonTestJoinGroups);
|
||||||
|
Controls.Add(buttonTestGroup100);
|
||||||
|
Controls.Add(buttonTestSubject100);
|
||||||
|
Controls.Add(buttonTestTeacher100);
|
||||||
|
Controls.Add(buttonTestStudent1000);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(menuStrip1);
|
||||||
|
MainMenuStrip = menuStrip1;
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormMain";
|
||||||
|
Text = "Главное окно";
|
||||||
|
Load += FormMain_Load;
|
||||||
|
menuStrip1.ResumeLayout(false);
|
||||||
|
menuStrip1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private MenuStrip menuStrip1;
|
||||||
|
private ToolStripMenuItem объектыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem studentToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem teacherToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem groupToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem subjectToolStripMenuItem;
|
||||||
|
private Button buttonTestGroup100;
|
||||||
|
private Button buttonTestSubject100;
|
||||||
|
private Button buttonTestTeacher100;
|
||||||
|
private Button buttonTestStudent1000;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonTestJoinGroups;
|
||||||
|
private Button buttonTestStudentD1000;
|
||||||
|
private Button buttonTestTeacherD100;
|
||||||
|
private Button buttonTestSubjectD100;
|
||||||
|
private Button buttonTestGroupD100;
|
||||||
|
}
|
||||||
|
}
|
302
Journal/FormMain.cs
Normal file
302
Journal/FormMain.cs
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataBaseImplement;
|
||||||
|
using JournalDataBaseImplement.Models;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using JournalView;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SushiBarView
|
||||||
|
{
|
||||||
|
public partial class FormMain : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ITeacherLogic _TLogic;
|
||||||
|
private readonly IGroupLogic _GLogic;
|
||||||
|
private readonly IStudentLogic _StLogic;
|
||||||
|
private readonly ISubjectLogic _SLogic;
|
||||||
|
|
||||||
|
public FormMain(ITeacherLogic tLogic, IStudentLogic stLogic, ISubjectLogic sLogic, IGroupLogic gLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_TLogic = tLogic;
|
||||||
|
_GLogic = gLogic;
|
||||||
|
_StLogic = stLogic;
|
||||||
|
_SLogic = sLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void studentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStudents));
|
||||||
|
if (service is FormStudents form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void teacherToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormTeachers));
|
||||||
|
if (service is FormTeachers form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void subjectToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSubjects));
|
||||||
|
if (service is FormSubjects form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void groupToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGroups));
|
||||||
|
if (service is FormGroups form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestGroup100_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_GLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
GroupViewModel fs = _GLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 100; i++)
|
||||||
|
{
|
||||||
|
GroupBindingModel model = new GroupBindingModel()
|
||||||
|
{
|
||||||
|
Course = i % 4 + 1,
|
||||||
|
GroupName = "Пибдоры номер " + i,
|
||||||
|
|
||||||
|
};
|
||||||
|
_GLogic.Create(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Создание 100 групп заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestSubject100_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_SLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
SubjectViewModel fs = _SLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 100; i++)
|
||||||
|
{
|
||||||
|
SubjectBindingModel model = new SubjectBindingModel()
|
||||||
|
{
|
||||||
|
Hours = 3 * i,
|
||||||
|
SubjectName = "Точно не математика номер " + i + id,
|
||||||
|
|
||||||
|
};
|
||||||
|
_SLogic.Create(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Создание 100 предметов заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestTeacher100_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_TLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
TeacherViewModel fs = _TLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 100; i++)
|
||||||
|
{
|
||||||
|
TeacherBindingModel model = new TeacherBindingModel()
|
||||||
|
{
|
||||||
|
Cafedra = "ФИСТ " + i,
|
||||||
|
Experience = (i + 10) / 2,
|
||||||
|
Position = "Заместитель по работе номер" + i + id,
|
||||||
|
TeacherName = "Иванов Иван Такойтов " + i + id,
|
||||||
|
|
||||||
|
};
|
||||||
|
_TLogic.Create(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Создание 100 преподавателей заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestStudent1000_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_StLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
StudentViewModel fs = _StLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 10000; i++)
|
||||||
|
{
|
||||||
|
StudentBindingModel model = new StudentBindingModel()
|
||||||
|
{
|
||||||
|
BookNumber = i + 10000,
|
||||||
|
Email = "pochta" + i + "@ulstu.ru",
|
||||||
|
GroupId = i % 100 + 1,
|
||||||
|
StudentName = "Григорьев Гриша Гришевич " + i + id,
|
||||||
|
|
||||||
|
};
|
||||||
|
_StLogic.Create(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Создание 1000 студентов заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestGroupD100_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_GLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
GroupViewModel fs = _GLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 100; i++)
|
||||||
|
{
|
||||||
|
GroupBindingModel model = new GroupBindingModel()
|
||||||
|
{
|
||||||
|
Id = i + id,
|
||||||
|
};
|
||||||
|
_GLogic.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Удаление 100 групп заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestSubjectD100_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_SLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
SubjectViewModel fs = _SLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 100; i++)
|
||||||
|
{
|
||||||
|
SubjectBindingModel model = new SubjectBindingModel()
|
||||||
|
{
|
||||||
|
Id = i + id,
|
||||||
|
|
||||||
|
};
|
||||||
|
_SLogic.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Удаление 100 предметов заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestTeacherD100_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_TLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
TeacherViewModel fs = _TLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 100; i++)
|
||||||
|
{
|
||||||
|
TeacherBindingModel model = new TeacherBindingModel()
|
||||||
|
{
|
||||||
|
Id = i + id,
|
||||||
|
};
|
||||||
|
_TLogic.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Удаление 100 преподавателей заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestStudentD1000_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
if (_StLogic.ReadList(null).Count > 0)
|
||||||
|
{
|
||||||
|
StudentViewModel fs = _StLogic.ReadList(null).First();
|
||||||
|
id = fs.Id - 1;
|
||||||
|
}
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 1; i <= 1000; i++)
|
||||||
|
{
|
||||||
|
StudentBindingModel model = new StudentBindingModel()
|
||||||
|
{
|
||||||
|
Id = i + id,
|
||||||
|
};
|
||||||
|
_StLogic.Delete(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan Time = stop - start;
|
||||||
|
MessageBox.Show($"Удаление 1000 студентов заняло: {Time.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonTestJoinGroups_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
using (var db = new JournalDataBase())
|
||||||
|
{
|
||||||
|
var query = from student in db.Students
|
||||||
|
join groupp in db.Groups on student.GroupId equals groupp.Id
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
student.Id,
|
||||||
|
student.StudentName,
|
||||||
|
student.BookNumber,
|
||||||
|
groupp.GroupName,
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = query.ToList();
|
||||||
|
|
||||||
|
DateTime stop = DateTime.Now;
|
||||||
|
TimeSpan queryTime = stop - start;
|
||||||
|
|
||||||
|
dataGridView.DataSource = result;
|
||||||
|
|
||||||
|
MessageBox.Show($"Присоединение групп к студентам заняло {queryTime.TotalMilliseconds}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
123
Journal/FormMain.resx
Normal file
123
Journal/FormMain.resx
Normal 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>
|
102
Journal/FormSelectSubject.Designer.cs
generated
Normal file
102
Journal/FormSelectSubject.Designer.cs
generated
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormSelectSubject
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
comboBoxSubject = new ComboBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(14, 12);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(70, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Предмет";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(260, 62);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(103, 35);
|
||||||
|
buttonCancel.TabIndex = 12;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(150, 62);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(103, 35);
|
||||||
|
buttonSave.TabIndex = 11;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// comboBoxSubject
|
||||||
|
//
|
||||||
|
comboBoxSubject.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxSubject.FormattingEnabled = true;
|
||||||
|
comboBoxSubject.Location = new Point(88, 8);
|
||||||
|
comboBoxSubject.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxSubject.Name = "comboBoxSubject";
|
||||||
|
comboBoxSubject.Size = new Size(284, 28);
|
||||||
|
comboBoxSubject.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// FormSelectSubject
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(390, 114);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(comboBoxSubject);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormSelectSubject";
|
||||||
|
Text = "Выберите предмет";
|
||||||
|
Load += FormSelectSubject_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private ComboBox comboBoxSubject;
|
||||||
|
}
|
||||||
|
}
|
88
Journal/FormSelectSubject.cs
Normal file
88
Journal/FormSelectSubject.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormSelectSubject : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly List<SubjectViewModel>? _list;
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(comboBoxSubject.SelectedValue);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxSubject.SelectedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISubjectModel? SubjectModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _list)
|
||||||
|
{
|
||||||
|
if (elem.Id == Id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FormSelectSubject(ISubjectLogic Logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_list = Logic.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxSubject.DisplayMember = "SubjectName";
|
||||||
|
comboBoxSubject.ValueMember = "Id";
|
||||||
|
comboBoxSubject.DataSource = _list;
|
||||||
|
comboBoxSubject.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxSubject.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите предмет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormSelectSubject_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormSelectSubject.resx
Normal file
120
Journal/FormSelectSubject.resx
Normal 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>
|
286
Journal/FormStudent.Designer.cs
generated
Normal file
286
Journal/FormStudent.Designer.cs
generated
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormStudent
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
label3 = new Label();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
label4 = new Label();
|
||||||
|
textBoxFCS = new TextBox();
|
||||||
|
textBoxBookNumber = new TextBox();
|
||||||
|
textBoxEmail = new TextBox();
|
||||||
|
comboBoxGroup = new ComboBox();
|
||||||
|
ColumnId = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnSubjectName = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnType = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnGrade = new DataGridViewTextBoxColumn();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(18, 12);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(42, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "ФИО";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(18, 56);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(114, 20);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Номер зачетки";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(18, 101);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(46, 20);
|
||||||
|
label3.TabIndex = 2;
|
||||||
|
label3.Text = "Email";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(buttonDel);
|
||||||
|
groupBox1.Controls.Add(buttonUpd);
|
||||||
|
groupBox1.Controls.Add(buttonAdd);
|
||||||
|
groupBox1.Controls.Add(dataGridView);
|
||||||
|
groupBox1.Location = new Point(14, 136);
|
||||||
|
groupBox1.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox1.Size = new Size(709, 448);
|
||||||
|
groupBox1.TabIndex = 7;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Оценки";
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(549, 164);
|
||||||
|
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(135, 47);
|
||||||
|
buttonDel.TabIndex = 10;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += buttonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(549, 96);
|
||||||
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(135, 47);
|
||||||
|
buttonUpd.TabIndex = 9;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(549, 29);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(135, 47);
|
||||||
|
buttonAdd.TabIndex = 8;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnSubjectName, ColumnType, ColumnGrade });
|
||||||
|
dataGridView.Location = new Point(7, 29);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(515, 411);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(617, 592);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(135, 47);
|
||||||
|
buttonCancel.TabIndex = 12;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(475, 592);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(135, 47);
|
||||||
|
buttonSave.TabIndex = 11;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(21, 608);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(58, 20);
|
||||||
|
label4.TabIndex = 13;
|
||||||
|
label4.Text = "Группа";
|
||||||
|
//
|
||||||
|
// textBoxFCS
|
||||||
|
//
|
||||||
|
textBoxFCS.Location = new Point(138, 12);
|
||||||
|
textBoxFCS.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxFCS.Name = "textBoxFCS";
|
||||||
|
textBoxFCS.Size = new Size(351, 27);
|
||||||
|
textBoxFCS.TabIndex = 15;
|
||||||
|
//
|
||||||
|
// textBoxBookNumber
|
||||||
|
//
|
||||||
|
textBoxBookNumber.Location = new Point(138, 53);
|
||||||
|
textBoxBookNumber.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxBookNumber.Name = "textBoxBookNumber";
|
||||||
|
textBoxBookNumber.Size = new Size(351, 27);
|
||||||
|
textBoxBookNumber.TabIndex = 16;
|
||||||
|
//
|
||||||
|
// textBoxEmail
|
||||||
|
//
|
||||||
|
textBoxEmail.Location = new Point(138, 94);
|
||||||
|
textBoxEmail.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxEmail.Name = "textBoxEmail";
|
||||||
|
textBoxEmail.Size = new Size(351, 27);
|
||||||
|
textBoxEmail.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// comboBoxGroup
|
||||||
|
//
|
||||||
|
comboBoxGroup.FormattingEnabled = true;
|
||||||
|
comboBoxGroup.Location = new Point(100, 605);
|
||||||
|
comboBoxGroup.Name = "comboBoxGroup";
|
||||||
|
comboBoxGroup.Size = new Size(151, 28);
|
||||||
|
comboBoxGroup.TabIndex = 18;
|
||||||
|
//
|
||||||
|
// ColumnId
|
||||||
|
//
|
||||||
|
ColumnId.HeaderText = "Id";
|
||||||
|
ColumnId.MinimumWidth = 6;
|
||||||
|
ColumnId.Name = "ColumnId";
|
||||||
|
ColumnId.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnSubjectName
|
||||||
|
//
|
||||||
|
ColumnSubjectName.HeaderText = "Предмет";
|
||||||
|
ColumnSubjectName.MinimumWidth = 6;
|
||||||
|
ColumnSubjectName.Name = "ColumnSubjectName";
|
||||||
|
ColumnSubjectName.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnType
|
||||||
|
//
|
||||||
|
ColumnType.HeaderText = "Тип";
|
||||||
|
ColumnType.MinimumWidth = 6;
|
||||||
|
ColumnType.Name = "ColumnType";
|
||||||
|
ColumnType.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnGrade
|
||||||
|
//
|
||||||
|
ColumnGrade.HeaderText = "Оценка";
|
||||||
|
ColumnGrade.MinimumWidth = 6;
|
||||||
|
ColumnGrade.Name = "ColumnGrade";
|
||||||
|
ColumnGrade.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// FormStudent
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(766, 653);
|
||||||
|
Controls.Add(comboBoxGroup);
|
||||||
|
Controls.Add(textBoxEmail);
|
||||||
|
Controls.Add(textBoxBookNumber);
|
||||||
|
Controls.Add(textBoxFCS);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormStudent";
|
||||||
|
Text = "Студент";
|
||||||
|
Load += FormStudent_Load;
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Label label4;
|
||||||
|
private TextBox textBoxFCS;
|
||||||
|
private TextBox textBoxBookNumber;
|
||||||
|
private TextBox textBoxEmail;
|
||||||
|
private ComboBox comboBoxGroup;
|
||||||
|
private DataGridViewTextBoxColumn ColumnId;
|
||||||
|
private DataGridViewTextBoxColumn ColumnSubjectName;
|
||||||
|
private DataGridViewTextBoxColumn ColumnType;
|
||||||
|
private DataGridViewTextBoxColumn ColumnGrade;
|
||||||
|
}
|
||||||
|
}
|
199
Journal/FormStudent.cs
Normal file
199
Journal/FormStudent.cs
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalDataModels.Enum;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using JournalView;
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormStudent : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ISubjectLogic _logicS;
|
||||||
|
private readonly ITeacherLogic _logicT;
|
||||||
|
private readonly IStudentLogic _logicSt;
|
||||||
|
private readonly IGroupLogic _logicG;
|
||||||
|
private int? _id;
|
||||||
|
private Dictionary<int, (ISubjectModel, ExamType, int)> _studentGrades;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormStudent(ISubjectLogic slogic, ITeacherLogic tlogic, IStudentLogic stlogic, IGroupLogic glogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logicT = tlogic;
|
||||||
|
_logicS = slogic;
|
||||||
|
_logicG = glogic;
|
||||||
|
_logicSt = stlogic;
|
||||||
|
_studentGrades = new Dictionary<int, (ISubjectModel, ExamType, int)>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormStudent_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var _listG = _logicG.ReadList(null);
|
||||||
|
if (_listG != null)
|
||||||
|
{
|
||||||
|
comboBoxGroup.DisplayMember = "GroupName";
|
||||||
|
comboBoxGroup.ValueMember = "Id";
|
||||||
|
comboBoxGroup.DataSource = _listG;
|
||||||
|
comboBoxGroup.SelectedItem = null;
|
||||||
|
}
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logicSt.ReadElement(new StudentSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxBookNumber.Text = view.BookNumber.ToString();
|
||||||
|
textBoxFCS.Text = view.StudentName;
|
||||||
|
textBoxEmail.Text = view.Email;
|
||||||
|
comboBoxGroup.SelectedIndex = view.GroupId - 1;
|
||||||
|
_studentGrades = view.StudentGrades ?? new Dictionary<int, (ISubjectModel, ExamType, int)>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_studentGrades != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var rc in _studentGrades)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { rc.Key, rc.Value.Item1.SubjectName, rc.Value.Item2.ToString(), rc.Value.Item3});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGrade));
|
||||||
|
if (service is FormGrade form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.SubjectModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_studentGrades.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_studentGrades[form.Id] = (form.SubjectModel, (ExamType)form.Type, form.Mark);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_studentGrades.Add(form.Id, (form.SubjectModel, (ExamType)form.Type, form.Mark));
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormGrade));
|
||||||
|
if (service is FormGrade form)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Mark = _studentGrades[id].Item3;
|
||||||
|
form.Type = _studentGrades[id].Item2;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.SubjectModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_studentGrades[form.Id] = (form.SubjectModel, (ExamType)form.Type, form.Mark);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_studentGrades?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_studentGrades == null || _studentGrades.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните оценки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new StudentBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
BookNumber = Convert.ToInt32(textBoxBookNumber.Text),
|
||||||
|
Email = textBoxEmail.Text,
|
||||||
|
StudentName = textBoxFCS.Text,
|
||||||
|
GroupId = comboBoxGroup.SelectedIndex + 1,
|
||||||
|
StudentGrades = _studentGrades,
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logicSt.Update(model) : _logicSt.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
132
Journal/FormStudent.resx
Normal file
132
Journal/FormStudent.resx
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?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="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnSubjectName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnGrade.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
113
Journal/FormStudents.Designer.cs
generated
Normal file
113
Journal/FormStudents.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormStudents
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.ShowCellToolTips = false;
|
||||||
|
dataGridView.ShowEditingIcon = false;
|
||||||
|
dataGridView.Size = new Size(1141, 600);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(1147, 148);
|
||||||
|
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(135, 47);
|
||||||
|
buttonDel.TabIndex = 7;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += buttonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(1147, 80);
|
||||||
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(135, 47);
|
||||||
|
buttonUpd.TabIndex = 6;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(1147, 13);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(135, 47);
|
||||||
|
buttonAdd.TabIndex = 5;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// FormStudents
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1328, 600);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(buttonUpd);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormStudents";
|
||||||
|
Text = "Студенты";
|
||||||
|
Load += FormBuyers_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
}
|
||||||
|
}
|
103
Journal/FormStudents.cs
Normal file
103
Journal/FormStudents.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalView;
|
||||||
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormStudents : Form
|
||||||
|
{
|
||||||
|
private readonly IStudentLogic _logic;
|
||||||
|
public FormStudents(IStudentLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormBuyers_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["GroupId"].Visible = false;
|
||||||
|
dataGridView.Columns["GroupName"].Visible = false;
|
||||||
|
dataGridView.Columns["StudentGrades"].Visible = false;
|
||||||
|
dataGridView.Columns["StudentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||||
|
if (service is FormStudent form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||||
|
if (service is FormStudent form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new StudentBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormStudents.resx
Normal file
120
Journal/FormStudents.resx
Normal 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>
|
123
Journal/FormSubject.Designer.cs
generated
Normal file
123
Journal/FormSubject.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormSubject
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
textBoxHours = new TextBox();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(14, 24);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(148, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Название предмета";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(14, 64);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(102, 20);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Кол-во часов";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(231, 21);
|
||||||
|
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(193, 27);
|
||||||
|
textBoxName.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxHours
|
||||||
|
//
|
||||||
|
textBoxHours.Location = new Point(231, 64);
|
||||||
|
textBoxHours.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxHours.Name = "textBoxHours";
|
||||||
|
textBoxHours.Size = new Size(193, 27);
|
||||||
|
textBoxHours.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(231, 117);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(88, 40);
|
||||||
|
buttonCancel.TabIndex = 7;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(136, 117);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(95, 40);
|
||||||
|
buttonSave.TabIndex = 6;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// FormSubject
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(510, 186);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(textBoxHours);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormSubject";
|
||||||
|
Text = "Предмет";
|
||||||
|
Load += FormSubject_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxHours;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
}
|
||||||
|
}
|
86
Journal/FormSubject.cs
Normal file
86
Journal/FormSubject.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.BindingModels;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormSubject : Form
|
||||||
|
{
|
||||||
|
private readonly ISubjectLogic _logic;
|
||||||
|
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormSubject(ISubjectLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormSubject_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new SubjectSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.SubjectName;
|
||||||
|
textBoxHours.Text = view.Hours.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text) || string.IsNullOrEmpty(textBoxHours.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new SubjectBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
SubjectName = textBoxName.Text,
|
||||||
|
Hours = Convert.ToInt32(textBoxHours.Text)
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormSubject.resx
Normal file
120
Journal/FormSubject.resx
Normal 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>
|
114
Journal/FormSubjects.Designer.cs
generated
Normal file
114
Journal/FormSubjects.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormSubjects
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(413, 157);
|
||||||
|
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(135, 47);
|
||||||
|
buttonDel.TabIndex = 8;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += buttonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(413, 89);
|
||||||
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(135, 47);
|
||||||
|
buttonUpd.TabIndex = 7;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(413, 23);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(135, 47);
|
||||||
|
buttonAdd.TabIndex = 6;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(378, 600);
|
||||||
|
dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormSubjects
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(578, 600);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(buttonUpd);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormSubjects";
|
||||||
|
Text = "Предметы";
|
||||||
|
Load += FormSubjects_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
101
Journal/FormSubjects.cs
Normal file
101
Journal/FormSubjects.cs
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalView;
|
||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormSubjects : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ISubjectLogic _logic;
|
||||||
|
|
||||||
|
public FormSubjects(ISubjectLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormSubjects_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = true;
|
||||||
|
dataGridView.Columns["SubjectName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["Hours"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSubject));
|
||||||
|
if (service is FormSubject form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSubject));
|
||||||
|
if (service is FormSubject form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new SubjectBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormSubjects.resx
Normal file
120
Journal/FormSubjects.resx
Normal 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>
|
268
Journal/FormTeacher.Designer.cs
generated
Normal file
268
Journal/FormTeacher.Designer.cs
generated
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
partial class FormTeacher
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
label3 = new Label();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
textBoxExperience = new TextBox();
|
||||||
|
label4 = new Label();
|
||||||
|
textBoxFCS = new TextBox();
|
||||||
|
textBoxPosition = new TextBox();
|
||||||
|
textBoxCafedra = new TextBox();
|
||||||
|
ColumnId = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnSubjectName = new DataGridViewTextBoxColumn();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(18, 12);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(42, 20);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "ФИО";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(18, 56);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(86, 20);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Должность";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(18, 101);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(69, 20);
|
||||||
|
label3.TabIndex = 2;
|
||||||
|
label3.Text = "Кафедра";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(buttonDel);
|
||||||
|
groupBox1.Controls.Add(buttonUpd);
|
||||||
|
groupBox1.Controls.Add(buttonAdd);
|
||||||
|
groupBox1.Controls.Add(dataGridView);
|
||||||
|
groupBox1.Location = new Point(14, 136);
|
||||||
|
groupBox1.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(3, 4, 3, 4);
|
||||||
|
groupBox1.Size = new Size(709, 448);
|
||||||
|
groupBox1.TabIndex = 7;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Предметы";
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(549, 164);
|
||||||
|
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(135, 47);
|
||||||
|
buttonDel.TabIndex = 10;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += buttonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(549, 96);
|
||||||
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(135, 47);
|
||||||
|
buttonUpd.TabIndex = 9;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(549, 29);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(135, 47);
|
||||||
|
buttonAdd.TabIndex = 8;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnSubjectName });
|
||||||
|
dataGridView.Location = new Point(7, 29);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(515, 411);
|
||||||
|
dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(617, 592);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(135, 47);
|
||||||
|
buttonCancel.TabIndex = 12;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(475, 592);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(135, 47);
|
||||||
|
buttonSave.TabIndex = 11;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// textBoxExperience
|
||||||
|
//
|
||||||
|
textBoxExperience.Location = new Point(537, 17);
|
||||||
|
textBoxExperience.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxExperience.Name = "textBoxExperience";
|
||||||
|
textBoxExperience.Size = new Size(161, 27);
|
||||||
|
textBoxExperience.TabIndex = 14;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(423, 20);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(102, 20);
|
||||||
|
label4.TabIndex = 13;
|
||||||
|
label4.Text = "Опыт работы";
|
||||||
|
//
|
||||||
|
// textBoxFCS
|
||||||
|
//
|
||||||
|
textBoxFCS.Location = new Point(114, 12);
|
||||||
|
textBoxFCS.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxFCS.Name = "textBoxFCS";
|
||||||
|
textBoxFCS.Size = new Size(280, 27);
|
||||||
|
textBoxFCS.TabIndex = 15;
|
||||||
|
//
|
||||||
|
// textBoxPosition
|
||||||
|
//
|
||||||
|
textBoxPosition.Location = new Point(114, 56);
|
||||||
|
textBoxPosition.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxPosition.Name = "textBoxPosition";
|
||||||
|
textBoxPosition.Size = new Size(280, 27);
|
||||||
|
textBoxPosition.TabIndex = 16;
|
||||||
|
//
|
||||||
|
// textBoxCafedra
|
||||||
|
//
|
||||||
|
textBoxCafedra.Location = new Point(114, 101);
|
||||||
|
textBoxCafedra.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxCafedra.Name = "textBoxCafedra";
|
||||||
|
textBoxCafedra.Size = new Size(280, 27);
|
||||||
|
textBoxCafedra.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// ColumnId
|
||||||
|
//
|
||||||
|
ColumnId.HeaderText = "Id";
|
||||||
|
ColumnId.MinimumWidth = 6;
|
||||||
|
ColumnId.Name = "ColumnId";
|
||||||
|
ColumnId.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnSubjectName
|
||||||
|
//
|
||||||
|
ColumnSubjectName.HeaderText = "Название";
|
||||||
|
ColumnSubjectName.MinimumWidth = 6;
|
||||||
|
ColumnSubjectName.Name = "ColumnSubjectName";
|
||||||
|
ColumnSubjectName.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// FormTeacher
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(766, 653);
|
||||||
|
Controls.Add(textBoxCafedra);
|
||||||
|
Controls.Add(textBoxPosition);
|
||||||
|
Controls.Add(textBoxFCS);
|
||||||
|
Controls.Add(textBoxExperience);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormTeacher";
|
||||||
|
Text = "Преподаватель";
|
||||||
|
Load += FormTeacher_Load;
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private TextBox textBoxExperience;
|
||||||
|
private Label label4;
|
||||||
|
private TextBox textBoxFCS;
|
||||||
|
private TextBox textBoxPosition;
|
||||||
|
private TextBox textBoxCafedra;
|
||||||
|
private DataGridViewTextBoxColumn ColumnId;
|
||||||
|
private DataGridViewTextBoxColumn ColumnSubjectName;
|
||||||
|
}
|
||||||
|
}
|
185
Journal/FormTeacher.cs
Normal file
185
Journal/FormTeacher.cs
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using JournalView;
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
public partial class FormTeacher : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly ISubjectLogic _logicP;
|
||||||
|
private readonly ITeacherLogic _logicC;
|
||||||
|
private int? _id;
|
||||||
|
private Dictionary<int, ISubjectModel> _teacherSubjects;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormTeacher(ISubjectLogic plogic, ITeacherLogic clogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logicP = plogic;
|
||||||
|
_logicC = clogic;
|
||||||
|
_teacherSubjects = new Dictionary<int, ISubjectModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormTeacher_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logicC.ReadElement(new TeacherSearchModel { Id = _id.Value });
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxFCS.Text = view.TeacherName;
|
||||||
|
textBoxCafedra.Text = view.Cafedra;
|
||||||
|
textBoxPosition.Text = view.Position;
|
||||||
|
textBoxExperience.Text = view.Experience.ToString();
|
||||||
|
_teacherSubjects = view.TeacherSubjects ?? new Dictionary<int, ISubjectModel>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_teacherSubjects != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var rc in _teacherSubjects)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] {rc.Key ,rc.Value.SubjectName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSelectSubject));
|
||||||
|
if (service is FormSelectSubject form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.SubjectModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_teacherSubjects.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_teacherSubjects[form.Id] = form.SubjectModel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_teacherSubjects.Add(form.Id, form.SubjectModel);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSelectSubject));
|
||||||
|
if (service is FormSelectSubject form)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.SubjectModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_teacherSubjects[form.Id] = form.SubjectModel;
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_teacherSubjects?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_teacherSubjects == null || _teacherSubjects.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните предметы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new TeacherBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
TeacherName = textBoxFCS.Text,
|
||||||
|
TeacherSubjects = _teacherSubjects,
|
||||||
|
Cafedra = textBoxCafedra.Text,
|
||||||
|
Experience = Convert.ToInt32(textBoxExperience.Text),
|
||||||
|
Position = textBoxPosition.Text,
|
||||||
|
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logicC.Update(model) : _logicC.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
126
Journal/FormTeacher.resx
Normal file
126
Journal/FormTeacher.resx
Normal 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="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnSubjectName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
114
Journal/FormTeachers.Designer.cs
generated
Normal file
114
Journal/FormTeachers.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace SushiBarView
|
||||||
|
{
|
||||||
|
partial class FormTeachers
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(656, 155);
|
||||||
|
buttonDel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(135, 47);
|
||||||
|
buttonDel.TabIndex = 11;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += buttonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(656, 87);
|
||||||
|
buttonUpd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(135, 47);
|
||||||
|
buttonUpd.TabIndex = 10;
|
||||||
|
buttonUpd.Text = "Изменить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += buttonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(656, 20);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(135, 47);
|
||||||
|
buttonAdd.TabIndex = 9;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.BackgroundColor = Color.White;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.ShowCellToolTips = false;
|
||||||
|
dataGridView.ShowEditingIcon = false;
|
||||||
|
dataGridView.Size = new Size(600, 600);
|
||||||
|
dataGridView.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// FormTeachers
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(842, 600);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(buttonUpd);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "FormTeachers";
|
||||||
|
Text = "Преподаватели";
|
||||||
|
Load += FormTeachers_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
102
Journal/FormTeachers.cs
Normal file
102
Journal/FormTeachers.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalView;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SushiBarView
|
||||||
|
{
|
||||||
|
public partial class FormTeachers : Form
|
||||||
|
{
|
||||||
|
private readonly ITeacherLogic _logic;
|
||||||
|
|
||||||
|
public FormTeachers(ITeacherLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormTeachers_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["TeacherName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["TeacherSubjects"].Visible = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormTeacher));
|
||||||
|
if (service is FormTeacher form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormTeacher));
|
||||||
|
if (service is FormTeacher form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new TeacherBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Journal/FormTeachers.resx
Normal file
120
Journal/FormTeachers.resx
Normal 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>
|
37
Journal/JournalView.csproj
Normal file
37
Journal/JournalView.csproj
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\JournalBusinessLogic\JournalBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\JournalContracts\JournalContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\JournalDataBaseImplement\JournalDataBaseImplement.csproj" />
|
||||||
|
<ProjectReference Include="..\JournalDataModels\JournalDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="FormSelectSubject.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="FormStudent.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
56
Journal/Program.cs
Normal file
56
Journal/Program.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using JournalBusinessLogic.BusinessLogics;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalDataBaseImplement.Implements;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SushiBarView;
|
||||||
|
|
||||||
|
namespace JournalView
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
private static ServiceProvider? _serviceProvider;
|
||||||
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<IStudentStorage, StudentStorage>();
|
||||||
|
services.AddTransient<ITeacherStorage, TeacherStorage>();
|
||||||
|
services.AddTransient<IGroupStorage, GroupStorage>();
|
||||||
|
services.AddTransient<ISubjectStorage, SubjectStorage>();
|
||||||
|
|
||||||
|
services.AddTransient<IStudentLogic, StudentLogic>();
|
||||||
|
services.AddTransient<ITeacherLogic, TeacherLogic>();
|
||||||
|
services.AddTransient<IGroupLogic, GroupLogic>();
|
||||||
|
services.AddTransient<ISubjectLogic, SubjectLogic>();
|
||||||
|
|
||||||
|
services.AddTransient<FormMain>();
|
||||||
|
services.AddTransient<FormStudents>();
|
||||||
|
services.AddTransient<FormStudent>();
|
||||||
|
services.AddTransient<FormTeachers>();
|
||||||
|
services.AddTransient<FormTeacher>();
|
||||||
|
services.AddTransient<FormSubject>();
|
||||||
|
services.AddTransient<FormSubjects>();
|
||||||
|
services.AddTransient<FormSelectSubject>();
|
||||||
|
services.AddTransient<FormGroups>();
|
||||||
|
services.AddTransient<FormGroup>();
|
||||||
|
services.AddTransient<FormTeacher>();
|
||||||
|
services.AddTransient<FormGrade>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
JournalBusinessLogic/BusinessLogics/GroupLogic.cs
Normal file
93
JournalBusinessLogic/BusinessLogics/GroupLogic.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class GroupLogic : IGroupLogic
|
||||||
|
{
|
||||||
|
private readonly IGroupStorage _groupStorage;
|
||||||
|
|
||||||
|
public GroupLogic(IGroupStorage groupStorage)
|
||||||
|
{
|
||||||
|
_groupStorage = groupStorage;
|
||||||
|
}
|
||||||
|
public GroupViewModel? ReadElement(GroupSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _groupStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GroupViewModel>? ReadList(GroupSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _groupStorage.GetFullList() : _groupStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_groupStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_groupStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_groupStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(GroupBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.GroupName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.GroupName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
JournalBusinessLogic/BusinessLogics/StudentLogic.cs
Normal file
94
JournalBusinessLogic/BusinessLogics/StudentLogic.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class StudentLogic : IStudentLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IStudentStorage _studentStorage;
|
||||||
|
|
||||||
|
public StudentLogic(IStudentStorage studentStorage)
|
||||||
|
{
|
||||||
|
_studentStorage = studentStorage;
|
||||||
|
}
|
||||||
|
public StudentViewModel? ReadElement(StudentSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _studentStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StudentViewModel>? ReadList(StudentSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _studentStorage.GetFullList() : _studentStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_studentStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_studentStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_studentStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(StudentBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.StudentName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.StudentName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
JournalBusinessLogic/BusinessLogics/SubjectLogic.cs
Normal file
93
JournalBusinessLogic/BusinessLogics/SubjectLogic.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class SubjectLogic : ISubjectLogic
|
||||||
|
{
|
||||||
|
private readonly ISubjectStorage _subjectStorage;
|
||||||
|
|
||||||
|
public SubjectLogic(ISubjectStorage subjectStorage)
|
||||||
|
{
|
||||||
|
_subjectStorage = subjectStorage;
|
||||||
|
}
|
||||||
|
public SubjectViewModel? ReadElement(SubjectSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _subjectStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubjectViewModel>? ReadList(SubjectSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _subjectStorage.GetFullList() : _subjectStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_subjectStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_subjectStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_subjectStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(SubjectBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.SubjectName.ToString()))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.SubjectName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
JournalBusinessLogic/BusinessLogics/TeacherLogic.cs
Normal file
93
JournalBusinessLogic/BusinessLogics/TeacherLogic.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.BusinessLogicContracts;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class TeacherLogic : ITeacherLogic
|
||||||
|
{
|
||||||
|
private readonly ITeacherStorage _teacherStorage;
|
||||||
|
|
||||||
|
public TeacherLogic(ITeacherStorage teacherStorage)
|
||||||
|
{
|
||||||
|
_teacherStorage = teacherStorage;
|
||||||
|
}
|
||||||
|
public TeacherViewModel? ReadElement(TeacherSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
var element = _teacherStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TeacherViewModel>? ReadList(TeacherSearchModel? model)
|
||||||
|
{
|
||||||
|
var list = model == null ? _teacherStorage.GetFullList() : _teacherStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_teacherStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
if (_teacherStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_teacherStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(TeacherBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.TeacherName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия", nameof(model.TeacherName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
JournalBusinessLogic/JournalBusinessLogic.csproj
Normal file
14
JournalBusinessLogic/JournalBusinessLogic.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\JournalContracts\JournalContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\JournalDataModels\JournalDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
17
JournalContracts/BindingModels/GroupBindingModel.cs
Normal file
17
JournalContracts/BindingModels/GroupBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace JournalContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class GroupBindingModel : IGroupModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string GroupName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Course { get; set; }
|
||||||
|
}
|
||||||
|
}
|
25
JournalContracts/BindingModels/StudentBindingModel.cs
Normal file
25
JournalContracts/BindingModels/StudentBindingModel.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalDataModels.Enum;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace JournalContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class StudentBindingModel : IStudentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string StudentName { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
public string? Email { get; set; }
|
||||||
|
|
||||||
|
public int BookNumber { get; set; }
|
||||||
|
|
||||||
|
public int GroupId { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (ISubjectModel, ExamType, int)> StudentGrades { get; set; } = new ();
|
||||||
|
}
|
||||||
|
}
|
19
JournalContracts/BindingModels/SubjectBindingModel.cs
Normal file
19
JournalContracts/BindingModels/SubjectBindingModel.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
|
||||||
|
namespace JournalContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class SubjectBindingModel : ISubjectModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string SubjectName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Hours { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
24
JournalContracts/BindingModels/TeacherBindingModel.cs
Normal file
24
JournalContracts/BindingModels/TeacherBindingModel.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class TeacherBindingModel : ITeacherModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string TeacherName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Experience { get; set; }
|
||||||
|
|
||||||
|
public string Position { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Cafedra { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Dictionary<int, ISubjectModel> TeacherSubjects { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
21
JournalContracts/BusinessLogicContracts/IGroupLogic.cs
Normal file
21
JournalContracts/BusinessLogicContracts/IGroupLogic.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IGroupLogic
|
||||||
|
{
|
||||||
|
List<GroupViewModel>? ReadList(GroupSearchModel? model);
|
||||||
|
GroupViewModel? ReadElement(GroupSearchModel model);
|
||||||
|
|
||||||
|
bool Create(GroupBindingModel model);
|
||||||
|
bool Update(GroupBindingModel model);
|
||||||
|
bool Delete(GroupBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
20
JournalContracts/BusinessLogicContracts/IStudentLogic.cs
Normal file
20
JournalContracts/BusinessLogicContracts/IStudentLogic.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace JournalContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface IStudentLogic
|
||||||
|
{
|
||||||
|
List<StudentViewModel>? ReadList(StudentSearchModel? model);
|
||||||
|
StudentViewModel? ReadElement(StudentSearchModel model);
|
||||||
|
|
||||||
|
bool Create(StudentBindingModel model);
|
||||||
|
bool Update(StudentBindingModel model);
|
||||||
|
bool Delete(StudentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
JournalContracts/BusinessLogicContracts/ISubjectLogic.cs
Normal file
21
JournalContracts/BusinessLogicContracts/ISubjectLogic.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface ISubjectLogic
|
||||||
|
{
|
||||||
|
List<SubjectViewModel>? ReadList(SubjectSearchModel? model);
|
||||||
|
SubjectViewModel? ReadElement(SubjectSearchModel model);
|
||||||
|
|
||||||
|
bool Create(SubjectBindingModel model);
|
||||||
|
bool Update(SubjectBindingModel model);
|
||||||
|
bool Delete(SubjectBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
21
JournalContracts/BusinessLogicContracts/ITeacherLogic.cs
Normal file
21
JournalContracts/BusinessLogicContracts/ITeacherLogic.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.BusinessLogicContracts
|
||||||
|
{
|
||||||
|
public interface ITeacherLogic
|
||||||
|
{
|
||||||
|
List<TeacherViewModel>? ReadList(TeacherSearchModel? model);
|
||||||
|
TeacherViewModel? ReadElement(TeacherSearchModel model);
|
||||||
|
|
||||||
|
bool Create(TeacherBindingModel model);
|
||||||
|
bool Update(TeacherBindingModel model);
|
||||||
|
bool Delete(TeacherBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
13
JournalContracts/JournalContracts.csproj
Normal file
13
JournalContracts/JournalContracts.csproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\JournalDataModels\JournalDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
14
JournalContracts/SearchModels/GroupSearchModel.cs
Normal file
14
JournalContracts/SearchModels/GroupSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class GroupSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? GroupName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
JournalContracts/SearchModels/StudentSearchModel.cs
Normal file
14
JournalContracts/SearchModels/StudentSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class StudentSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? StudentName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
JournalContracts/SearchModels/SubjectSearchModel.cs
Normal file
14
JournalContracts/SearchModels/SubjectSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class SubjectSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? SubjectName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
JournalContracts/SearchModels/TeacherSearchModel.cs
Normal file
14
JournalContracts/SearchModels/TeacherSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class TeacherSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? TeacherName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
22
JournalContracts/StoragesContracts/IGroupStorage.cs
Normal file
22
JournalContracts/StoragesContracts/IGroupStorage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IGroupStorage
|
||||||
|
{
|
||||||
|
List<GroupViewModel> GetFullList();
|
||||||
|
List<GroupViewModel> GetFilteredList(GroupSearchModel model);
|
||||||
|
|
||||||
|
GroupViewModel? GetElement(GroupSearchModel model);
|
||||||
|
GroupViewModel? Insert(GroupBindingModel model);
|
||||||
|
GroupViewModel? Update(GroupBindingModel model);
|
||||||
|
GroupViewModel? Delete(GroupBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
22
JournalContracts/StoragesContracts/IStudentStorage.cs
Normal file
22
JournalContracts/StoragesContracts/IStudentStorage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IStudentStorage
|
||||||
|
{
|
||||||
|
List<StudentViewModel> GetFullList();
|
||||||
|
List<StudentViewModel> GetFilteredList(StudentSearchModel model);
|
||||||
|
|
||||||
|
StudentViewModel? GetElement(StudentSearchModel model);
|
||||||
|
StudentViewModel? Insert(StudentBindingModel model);
|
||||||
|
StudentViewModel? Update(StudentBindingModel model);
|
||||||
|
StudentViewModel? Delete(StudentBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
22
JournalContracts/StoragesContracts/ISubjectStorage.cs
Normal file
22
JournalContracts/StoragesContracts/ISubjectStorage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ISubjectStorage
|
||||||
|
{
|
||||||
|
List<SubjectViewModel> GetFullList();
|
||||||
|
List<SubjectViewModel> GetFilteredList(SubjectSearchModel model);
|
||||||
|
|
||||||
|
SubjectViewModel? GetElement(SubjectSearchModel model);
|
||||||
|
SubjectViewModel? Insert(SubjectBindingModel model);
|
||||||
|
SubjectViewModel? Update(SubjectBindingModel model);
|
||||||
|
SubjectViewModel? Delete(SubjectBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
22
JournalContracts/StoragesContracts/ITeacherStorage.cs
Normal file
22
JournalContracts/StoragesContracts/ITeacherStorage.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface ITeacherStorage
|
||||||
|
{
|
||||||
|
List<TeacherViewModel> GetFullList();
|
||||||
|
List<TeacherViewModel> GetFilteredList(TeacherSearchModel model);
|
||||||
|
|
||||||
|
TeacherViewModel? GetElement(TeacherSearchModel model);
|
||||||
|
TeacherViewModel? Insert(TeacherBindingModel model);
|
||||||
|
TeacherViewModel? Update(TeacherBindingModel model);
|
||||||
|
TeacherViewModel? Delete(TeacherBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
20
JournalContracts/ViewModels/GroupViewModel.cs
Normal file
20
JournalContracts/ViewModels/GroupViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class GroupViewModel : IGroupModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название группы")]
|
||||||
|
public string GroupName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Номер курса")]
|
||||||
|
public int Course { get; set; }
|
||||||
|
}
|
||||||
|
}
|
28
JournalContracts/ViewModels/StudentViewModel.cs
Normal file
28
JournalContracts/ViewModels/StudentViewModel.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using JournalDataModels.Enum;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class StudentViewModel : IStudentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Имя студента")]
|
||||||
|
public string StudentName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Почта")]
|
||||||
|
public string? Email { get; set; }
|
||||||
|
[DisplayName("Номер книжки")]
|
||||||
|
public int BookNumber { get; set; }
|
||||||
|
public int GroupId { get; set; }
|
||||||
|
[DisplayName("Группа")]
|
||||||
|
public int GroupName { get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (ISubjectModel, ExamType, int)> StudentGrades { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
20
JournalContracts/ViewModels/SubjectViewModel.cs
Normal file
20
JournalContracts/ViewModels/SubjectViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class SubjectViewModel : ISubjectModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название предмета")]
|
||||||
|
public string SubjectName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Кол-во часов")]
|
||||||
|
public int Hours { get; set; }
|
||||||
|
}
|
||||||
|
}
|
27
JournalContracts/ViewModels/TeacherViewModel.cs
Normal file
27
JournalContracts/ViewModels/TeacherViewModel.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class TeacherViewModel : ITeacherModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("ФИО преподавателя")]
|
||||||
|
public string TeacherName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Опыт работы")]
|
||||||
|
public int Experience { get; set; }
|
||||||
|
[DisplayName("Должность")]
|
||||||
|
public string Position { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Кафедра")]
|
||||||
|
public string Cafedra { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Dictionary<int, ISubjectModel> TeacherSubjects { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
14
JournalDataModels/Enum/ExamType.cs
Normal file
14
JournalDataModels/Enum/ExamType.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace JournalDataModels.Enum
|
||||||
|
{
|
||||||
|
public enum ExamType
|
||||||
|
{
|
||||||
|
|
||||||
|
Лекция = 0,
|
||||||
|
|
||||||
|
Зачет = 1,
|
||||||
|
|
||||||
|
Экзамен = 2,
|
||||||
|
|
||||||
|
Лабораторная = 3
|
||||||
|
}
|
||||||
|
}
|
18
JournalDataModels/Enum/KOSTILISHE.cs
Normal file
18
JournalDataModels/Enum/KOSTILISHE.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JournalDataModels.Enum
|
||||||
|
{
|
||||||
|
public class KOSTILISHE
|
||||||
|
{
|
||||||
|
public ExamType pole { get; set; }
|
||||||
|
public int pomogi { get; set; }
|
||||||
|
public KOSTILISHE(ExamType ex) {
|
||||||
|
pole = ex;
|
||||||
|
pomogi = (int)pole;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
JournalDataModels/IId.cs
Normal file
13
JournalDataModels/IId.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataModels
|
||||||
|
{
|
||||||
|
public interface IId
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
}
|
||||||
|
}
|
9
JournalDataModels/JournalDataModels.csproj
Normal file
9
JournalDataModels/JournalDataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
16
JournalDataModels/Models/IGroupModel.cs
Normal file
16
JournalDataModels/Models/IGroupModel.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using JournalDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IGroupModel : IId
|
||||||
|
{
|
||||||
|
string GroupName { get; }
|
||||||
|
|
||||||
|
int Course { get; }
|
||||||
|
}
|
||||||
|
}
|
23
JournalDataModels/Models/IStudentModel.cs
Normal file
23
JournalDataModels/Models/IStudentModel.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using JournalDataModels;
|
||||||
|
using JournalDataModels.Enum;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace JournalDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IStudentModel : IId
|
||||||
|
{
|
||||||
|
string StudentName { get; }
|
||||||
|
//чиним BirthDate
|
||||||
|
|
||||||
|
string? Email { get; }
|
||||||
|
|
||||||
|
int BookNumber { get; }
|
||||||
|
|
||||||
|
int GroupId { get; }
|
||||||
|
|
||||||
|
Dictionary<int, (ISubjectModel, ExamType, int)> StudentGrades { get; }
|
||||||
|
}
|
||||||
|
}
|
15
JournalDataModels/Models/ISubjectModel.cs
Normal file
15
JournalDataModels/Models/ISubjectModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using JournalDataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace JournalDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ISubjectModel : IId
|
||||||
|
{
|
||||||
|
string SubjectName { get; }
|
||||||
|
|
||||||
|
int Hours { get; }
|
||||||
|
}
|
||||||
|
}
|
12
JournalDataModels/Models/ITeacherModel.cs
Normal file
12
JournalDataModels/Models/ITeacherModel.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace JournalDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ITeacherModel : IId
|
||||||
|
{
|
||||||
|
string TeacherName { get; }
|
||||||
|
string Position { get; }
|
||||||
|
int Experience { get; }
|
||||||
|
string Cafedra { get; }
|
||||||
|
|
||||||
|
Dictionary<int, ISubjectModel> TeacherSubjects { get; }
|
||||||
|
}
|
||||||
|
}
|
78
JournalDatabaseImplement/Implements/GroupStorage.cs
Normal file
78
JournalDatabaseImplement/Implements/GroupStorage.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class GroupStorage : IGroupStorage
|
||||||
|
{
|
||||||
|
public GroupViewModel? Delete(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var element = context.Groups.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Groups.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupViewModel? GetElement(GroupSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Groups.FirstOrDefault(x => !string.IsNullOrEmpty(model.GroupName) && x.GroupName == model.GroupName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GroupViewModel> GetFilteredList(GroupSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.GroupName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Groups.Where(x => x.GroupName.Contains(model.GroupName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GroupViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Groups.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupViewModel? Insert(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
var newMenu = Group.Create(model);
|
||||||
|
if (newMenu == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
context.Groups.Add(newMenu);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newMenu.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupViewModel? Update(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var component = context.Groups.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
82
JournalDatabaseImplement/Implements/StudentStorage.cs
Normal file
82
JournalDatabaseImplement/Implements/StudentStorage.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class StudentStorage : IStudentStorage
|
||||||
|
{
|
||||||
|
|
||||||
|
public List<StudentViewModel> GetFilteredList(StudentSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.StudentName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Students.Include(x => x.Grades).Where(x => x.StudentName.Contains(model.StudentName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StudentViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Students.Include(x => x.Grades).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentViewModel? Delete(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var element = context.Students
|
||||||
|
.Include(x => x.Grades)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Students.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentViewModel? GetElement(StudentSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Students.Include(x => x.Grades).FirstOrDefault(x => !string.IsNullOrEmpty(model.StudentName) && x.StudentName == model.StudentName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentViewModel? Insert(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var newStudent = Student.Create(context,model);
|
||||||
|
if (newStudent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Students.Add(newStudent);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newStudent.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentViewModel? Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var component = context.Students.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
component.UpdateGrades(context, model);
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
87
JournalDatabaseImplement/Implements/SubjectStorage.cs
Normal file
87
JournalDatabaseImplement/Implements/SubjectStorage.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataBaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class SubjectStorage : ISubjectStorage
|
||||||
|
{
|
||||||
|
public SubjectViewModel? Delete(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var element = context.Subjects.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Subjects.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubjectViewModel? GetElement(SubjectSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Subjects.FirstOrDefault(x => !string.IsNullOrEmpty(model.SubjectName.ToString()) && x.SubjectName.ToString() == model.SubjectName.ToString() || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubjectViewModel> GetFilteredList(SubjectSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.SubjectName.ToString()))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Subjects.Where(x => x.SubjectName.ToString().Contains(model.SubjectName.ToString())).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SubjectViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Subjects.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubjectViewModel? Insert(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
var newSubject = Subject.Create(model);
|
||||||
|
if (newSubject == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
context.Subjects.Add(newSubject);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newSubject.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubjectViewModel? Update(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var component = context.Subjects.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
JournalDatabaseImplement/Implements/TeacherStorage.cs
Normal file
99
JournalDatabaseImplement/Implements/TeacherStorage.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.SearchModels;
|
||||||
|
using JournalContracts.StoragesContracts;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class TeacherStorage : ITeacherStorage
|
||||||
|
{
|
||||||
|
public TeacherViewModel? Delete(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var element = context.Teachers
|
||||||
|
.Include(x => x.Subjects)
|
||||||
|
.ThenInclude(x => x.Subject)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Teachers.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeacherViewModel? GetElement(TeacherSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Teachers
|
||||||
|
.Include(x => x.Subjects)
|
||||||
|
.ThenInclude(x => x.Subject)
|
||||||
|
.FirstOrDefault(x => !string.IsNullOrEmpty(model.TeacherName) && x.TeacherName == model.TeacherName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TeacherViewModel> GetFilteredList(TeacherSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.TeacherName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Teachers
|
||||||
|
.Include(x => x.Subjects)
|
||||||
|
.ThenInclude(x => x.Subject)
|
||||||
|
.Where(x => x.TeacherName.Contains(model.TeacherName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TeacherViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
return context.Teachers.Include(x => x.Subjects).ThenInclude(x => x.Subject).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeacherViewModel? Insert(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
var newTeacher = Teacher.Create(context,model);
|
||||||
|
if (newTeacher == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Teachers.Add(newTeacher);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newTeacher.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeacherViewModel? Update(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new JournalDataBase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var component = context.Teachers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (component == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
component.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
component.UpdateSubjects(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return component.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
JournalDatabaseImplement/JournalDataBase.cs
Normal file
31
JournalDatabaseImplement/JournalDataBase.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using JournalDataBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.Common;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement
|
||||||
|
{
|
||||||
|
public class JournalDataBase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseNpgsql(@"Host=localhost;Database=JournalDataBase;Username=postgres;Password=postgres");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||||
|
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Student> Students { get; set; }
|
||||||
|
public virtual DbSet<Teacher> Teachers { get; set; }
|
||||||
|
public virtual DbSet<Group> Groups { get; set; }
|
||||||
|
public virtual DbSet<Subject> Subjects { get; set; }
|
||||||
|
public virtual DbSet<Grade> StudentGrades { get; set; }
|
||||||
|
public virtual DbSet<TeacherSubject> TeacherSubjects { get; set; }
|
||||||
|
}
|
||||||
|
}
|
29
JournalDatabaseImplement/JournalDatabaseImplement.csproj
Normal file
29
JournalDatabaseImplement/JournalDatabaseImplement.csproj
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\JournalBusinessLogic\JournalBusinessLogic.csproj" />
|
||||||
|
<ProjectReference Include="..\JournalContracts\JournalContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\JournalDataModels\JournalDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Migrations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
230
JournalDatabaseImplement/Migrations/20240503203216_pereehali.Designer.cs
generated
Normal file
230
JournalDatabaseImplement/Migrations/20240503203216_pereehali.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using JournalDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace JournalDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(JournalDataBase))]
|
||||||
|
[Migration("20240503203216_pereehali")]
|
||||||
|
partial class pereehali
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Grade", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Mark")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("StudentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SubjectId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StudentId");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.ToTable("StudentGrades");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Group", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Course")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("GroupName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Groups");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Student", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BookNumber")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("GroupId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("StudentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Students");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Hours")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("SubjectName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Subjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Teacher", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cafedra")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Experience")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Position")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("TeacherName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Teachers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.TeacherSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("SubjectId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("TeacherId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.HasIndex("TeacherId");
|
||||||
|
|
||||||
|
b.ToTable("TeacherSubjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Grade", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Student", "Student")
|
||||||
|
.WithMany("Grades")
|
||||||
|
.HasForeignKey("StudentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Subject", "Subject")
|
||||||
|
.WithMany("Grade")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Student");
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.TeacherSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Subject", "Subject")
|
||||||
|
.WithMany("TeacherSubjects")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Teacher", "Teacher")
|
||||||
|
.WithMany("Subjects")
|
||||||
|
.HasForeignKey("TeacherId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
|
||||||
|
b.Navigation("Teacher");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Student", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Grades");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Grade");
|
||||||
|
|
||||||
|
b.Navigation("TeacherSubjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Teacher", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Subjects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
171
JournalDatabaseImplement/Migrations/20240503203216_pereehali.cs
Normal file
171
JournalDatabaseImplement/Migrations/20240503203216_pereehali.cs
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace JournalDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class pereehali : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Groups",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
GroupName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Course = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Groups", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Students",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
StudentName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Email = table.Column<string>(type: "text", nullable: true),
|
||||||
|
BookNumber = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
GroupId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Students", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Subjects",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
SubjectName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Hours = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Subjects", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Teachers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
TeacherName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Experience = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Position = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Cafedra = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Teachers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "StudentGrades",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
StudentId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
SubjectId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Type = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Mark = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_StudentGrades", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_StudentGrades_Students_StudentId",
|
||||||
|
column: x => x.StudentId,
|
||||||
|
principalTable: "Students",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_StudentGrades_Subjects_SubjectId",
|
||||||
|
column: x => x.SubjectId,
|
||||||
|
principalTable: "Subjects",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "TeacherSubjects",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
SubjectId = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
TeacherId = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_TeacherSubjects", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_TeacherSubjects_Subjects_SubjectId",
|
||||||
|
column: x => x.SubjectId,
|
||||||
|
principalTable: "Subjects",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_TeacherSubjects_Teachers_TeacherId",
|
||||||
|
column: x => x.TeacherId,
|
||||||
|
principalTable: "Teachers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_StudentGrades_StudentId",
|
||||||
|
table: "StudentGrades",
|
||||||
|
column: "StudentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_StudentGrades_SubjectId",
|
||||||
|
table: "StudentGrades",
|
||||||
|
column: "SubjectId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_TeacherSubjects_SubjectId",
|
||||||
|
table: "TeacherSubjects",
|
||||||
|
column: "SubjectId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_TeacherSubjects_TeacherId",
|
||||||
|
table: "TeacherSubjects",
|
||||||
|
column: "TeacherId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Groups");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "StudentGrades");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "TeacherSubjects");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Students");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Subjects");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Teachers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,227 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using JournalDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace JournalDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(JournalDataBase))]
|
||||||
|
partial class JournalDataBaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Grade", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Mark")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("StudentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("SubjectId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StudentId");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.ToTable("StudentGrades");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Group", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Course")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("GroupName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Groups");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Student", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BookNumber")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("GroupId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("StudentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Students");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Hours")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("SubjectName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Subjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Teacher", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Cafedra")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Experience")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Position")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("TeacherName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Teachers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.TeacherSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("SubjectId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("TeacherId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SubjectId");
|
||||||
|
|
||||||
|
b.HasIndex("TeacherId");
|
||||||
|
|
||||||
|
b.ToTable("TeacherSubjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Grade", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Student", "Student")
|
||||||
|
.WithMany("Grades")
|
||||||
|
.HasForeignKey("StudentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Subject", "Subject")
|
||||||
|
.WithMany("Grade")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Student");
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.TeacherSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Subject", "Subject")
|
||||||
|
.WithMany("TeacherSubjects")
|
||||||
|
.HasForeignKey("SubjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("JournalDataBaseImplement.Models.Teacher", "Teacher")
|
||||||
|
.WithMany("Subjects")
|
||||||
|
.HasForeignKey("TeacherId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Subject");
|
||||||
|
|
||||||
|
b.Navigation("Teacher");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Student", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Grades");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Subject", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Grade");
|
||||||
|
|
||||||
|
b.Navigation("TeacherSubjects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("JournalDataBaseImplement.Models.Teacher", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Subjects");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
JournalDatabaseImplement/Models/Grade.cs
Normal file
29
JournalDatabaseImplement/Models/Grade.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataBaseImplement;
|
||||||
|
using JournalDataModels.Enum;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Grade
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int StudentId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int SubjectId { get; set; }
|
||||||
|
public ExamType Type { get; set; }
|
||||||
|
public int Mark { get; set; }
|
||||||
|
public virtual Subject Subject { get; set; } = new();
|
||||||
|
public virtual Student Student { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
48
JournalDatabaseImplement/Models/Group.cs
Normal file
48
JournalDatabaseImplement/Models/Group.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Group : IGroupModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string GroupName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int Course { get; set; }
|
||||||
|
public static Group? Create(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new Group()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
GroupName = model.GroupName,
|
||||||
|
Course = model.Course,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(GroupBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
Id = model.Id;
|
||||||
|
GroupName = model.GroupName;
|
||||||
|
Course = model.Course;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
GroupName = GroupName,
|
||||||
|
Course = Course,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
99
JournalDatabaseImplement/Models/Student.cs
Normal file
99
JournalDatabaseImplement/Models/Student.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataModels.Enum;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Student : IStudentModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string StudentName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string? Email { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int BookNumber { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int GroupId { get; set; }
|
||||||
|
[ForeignKey("StudentId")]
|
||||||
|
public virtual List<Grade> Grades { get; set; } = new();
|
||||||
|
|
||||||
|
private Dictionary<int, (ISubjectModel, ExamType, int)>? _studentGrades = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, (ISubjectModel,ExamType, int)> StudentGrades {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_studentGrades == null)
|
||||||
|
{
|
||||||
|
_studentGrades = Grades.ToDictionary(recPC => recPC.SubjectId, recPC =>
|
||||||
|
(recPC.Subject as ISubjectModel, recPC.Type, recPC.Mark));
|
||||||
|
}
|
||||||
|
return _studentGrades;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Student? Create(JournalDataBase context, StudentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
return new Student()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
StudentName = model.StudentName,
|
||||||
|
Email = model.Email,
|
||||||
|
BookNumber = model.BookNumber,
|
||||||
|
GroupId = model.GroupId,
|
||||||
|
Grades = model.StudentGrades.Select(x => new Grade
|
||||||
|
{
|
||||||
|
Subject = context.Subjects.First(y => y.Id == x.Key),
|
||||||
|
Type = x.Value.Item2,
|
||||||
|
Mark = x.Value.Item3
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(StudentBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
StudentName = model.StudentName;
|
||||||
|
Email = model.Email;
|
||||||
|
BookNumber = model.BookNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StudentViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
StudentName = StudentName,
|
||||||
|
Email = Email,
|
||||||
|
BookNumber = BookNumber,
|
||||||
|
GroupId = GroupId,
|
||||||
|
StudentGrades = StudentGrades
|
||||||
|
};
|
||||||
|
public void UpdateGrades(JournalDataBase context, StudentBindingModel model)
|
||||||
|
{
|
||||||
|
|
||||||
|
var student = context.Students.First(x => x.Id == Id);
|
||||||
|
foreach (var rc in model.StudentGrades)
|
||||||
|
{
|
||||||
|
context.StudentGrades.Add(new Grade
|
||||||
|
{
|
||||||
|
Student = student,
|
||||||
|
Subject = context.Subjects.First(x => x.Id == rc.Key),
|
||||||
|
Mark = rc.Value.Item3,
|
||||||
|
Type = rc.Value.Item2
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_studentGrades = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
JournalDatabaseImplement/Models/Subject.cs
Normal file
54
JournalDatabaseImplement/Models/Subject.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Subject : ISubjectModel
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string SubjectName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int Hours { get; set; }
|
||||||
|
[ForeignKey("SubjectId")]
|
||||||
|
public virtual List<TeacherSubject> TeacherSubjects { get; set; } = new();
|
||||||
|
[ForeignKey("SubjectId")]
|
||||||
|
public virtual List<Grade> Grade { get; set; } = new();
|
||||||
|
public static Subject? Create(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Subject()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
SubjectName = model.SubjectName,
|
||||||
|
Hours = model.Hours
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(SubjectBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
SubjectName = model.SubjectName;
|
||||||
|
Hours = model.Hours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubjectViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
SubjectName = SubjectName,
|
||||||
|
Hours = Hours
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
92
JournalDatabaseImplement/Models/Teacher.cs
Normal file
92
JournalDatabaseImplement/Models/Teacher.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
using JournalContracts.BindingModels;
|
||||||
|
using JournalContracts.ViewModels;
|
||||||
|
using JournalDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Teacher : ITeacherModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string TeacherName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Experience { get; set; }
|
||||||
|
|
||||||
|
public string Position { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Cafedra { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
private Dictionary<int, ISubjectModel>? _teacherSubjects = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, ISubjectModel> TeacherSubjects {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_teacherSubjects == null)
|
||||||
|
{
|
||||||
|
_teacherSubjects = Subjects.ToDictionary(recPC => recPC.SubjectId, recPC =>
|
||||||
|
recPC.Subject as ISubjectModel);
|
||||||
|
}
|
||||||
|
return _teacherSubjects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[ForeignKey("TeacherId")]
|
||||||
|
public virtual List<TeacherSubject> Subjects { get; set; } = new();
|
||||||
|
public static Teacher? Create(JournalDataBase context, TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return null;
|
||||||
|
return new Teacher()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
TeacherName = model.TeacherName,
|
||||||
|
Experience = model.Experience,
|
||||||
|
Position = model.Position,
|
||||||
|
Cafedra = model.Cafedra,
|
||||||
|
Subjects = model.TeacherSubjects.Select(x => new TeacherSubject
|
||||||
|
{
|
||||||
|
Subject = context.Subjects.First(y => y.Id == x.Key),
|
||||||
|
}).ToList(),
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null) return;
|
||||||
|
TeacherName = model.TeacherName;
|
||||||
|
Experience = model.Experience;
|
||||||
|
Position = model.Position;
|
||||||
|
Cafedra = model.Cafedra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeacherViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
TeacherName = TeacherName,
|
||||||
|
TeacherSubjects = TeacherSubjects,
|
||||||
|
Experience = Experience,
|
||||||
|
Position = Position,
|
||||||
|
Cafedra = Cafedra,
|
||||||
|
};
|
||||||
|
public void UpdateSubjects(JournalDataBase context, TeacherBindingModel model)
|
||||||
|
{
|
||||||
|
var teacher = context.Teachers.First(x => x.Id == Id);
|
||||||
|
foreach (var rc in model.TeacherSubjects)
|
||||||
|
{
|
||||||
|
context.TeacherSubjects.Add(new TeacherSubject
|
||||||
|
{
|
||||||
|
Teacher = teacher,
|
||||||
|
Subject = context.Subjects.First(x => x.Id == rc.Key),
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_teacherSubjects = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
JournalDatabaseImplement/Models/TeacherSubject.cs
Normal file
20
JournalDatabaseImplement/Models/TeacherSubject.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace JournalDataBaseImplement.Models
|
||||||
|
{
|
||||||
|
public class TeacherSubject
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int SubjectId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int TeacherId { get; set; }
|
||||||
|
public virtual Subject Subject { get; set; } = new();
|
||||||
|
public virtual Teacher Teacher { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user