Реализовал работу с таблицей связи на примере ученика
This commit is contained in:
@@ -6,9 +6,9 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
{
|
||||
public class StudentWork : IStudentWork
|
||||
{
|
||||
private readonly SubjectWork _subjectWork;
|
||||
private readonly ISubjectWork _subjectWork;
|
||||
|
||||
public StudentWork(SubjectWork subjectWork)
|
||||
public StudentWork(ISubjectWork subjectWork)
|
||||
{
|
||||
_subjectWork = subjectWork;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace ElectronicDiaryPostgresImplementation.WorkImplementation
|
||||
{
|
||||
public class TeacherWork : ITeacherWork
|
||||
{
|
||||
private readonly SubjectWork _subjectWork;
|
||||
private readonly ISubjectWork _subjectWork;
|
||||
|
||||
public TeacherWork(SubjectWork subjectWork)
|
||||
public TeacherWork(ISubjectWork subjectWork)
|
||||
{
|
||||
_subjectWork = subjectWork;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,13 @@
|
||||
<ProjectReference Include="..\ElectronicDiaryPostgresImplementation\ElectronicDiaryPostgresImplementation.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FormStudent.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="FormGrade.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
158
ElectronicDiary/ElectronicDiaryView/FormGrade.Designer.cs
generated
Normal file
158
ElectronicDiary/ElectronicDiaryView/FormGrade.Designer.cs
generated
Normal file
@@ -0,0 +1,158 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
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()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
textBoxName = new TextBox();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
label2 = new Label();
|
||||
comboBoxTeacher = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(741, 409);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(741, 360);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(741, 311);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(746, 13);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(232, 23);
|
||||
textBoxName.TabIndex = 21;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(596, 16);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(96, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Наименование: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(568, 426);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(596, 53);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(144, 45);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "Классный руководитель:\r\n\r\n\r\n";
|
||||
//
|
||||
// comboBoxTeacher
|
||||
//
|
||||
comboBoxTeacher.FormattingEnabled = true;
|
||||
comboBoxTeacher.Location = new Point(746, 50);
|
||||
comboBoxTeacher.Name = "comboBoxTeacher";
|
||||
comboBoxTeacher.Size = new Size(232, 23);
|
||||
comboBoxTeacher.TabIndex = 30;
|
||||
//
|
||||
// FormGrade
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(990, 450);
|
||||
Controls.Add(comboBoxTeacher);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormGrade";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Классы";
|
||||
Load += FormGrade_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxName;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxTeacher;
|
||||
}
|
||||
}
|
||||
119
ElectronicDiary/ElectronicDiaryView/FormGrade.cs
Normal file
119
ElectronicDiary/ElectronicDiaryView/FormGrade.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormGrade : Form
|
||||
{
|
||||
private readonly IGradeWork _gradeLogic;
|
||||
|
||||
private readonly ITeacherWork _teacherLogic;
|
||||
|
||||
public FormGrade(IGradeWork gradeLogic, ITeacherWork teacherLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_gradeLogic = gradeLogic;
|
||||
_teacherLogic = teacherLogic;
|
||||
}
|
||||
|
||||
private void FormGrade_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var grades = _gradeLogic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Name", "Наименование класса");
|
||||
dataGridView.Columns.Add("TeacherId", "TeacherId");
|
||||
dataGridView.Columns["TeacherId"].Visible = false;
|
||||
dataGridView.Columns.Add("TeacherName", "Классный руководитель");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["TeacherName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
comboBoxTeacher.DataSource = _teacherLogic.GetAll().Select(x =>
|
||||
new { x.Id, FullName = x.LastName + " " + x.FirstName + " " + x.Patronymic }
|
||||
).ToList();
|
||||
comboBoxTeacher.DisplayMember = "FullName";
|
||||
comboBoxTeacher.ValueMember = "Id";
|
||||
|
||||
foreach (var grade in grades)
|
||||
{
|
||||
var teacher = _teacherLogic.Get(grade.TeacherId);
|
||||
dataGridView.Rows.Add(grade.Id, grade.Name, grade.TeacherId, teacher?.LastName + " " + teacher?.FirstName + " " + teacher?.Patronymic);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Grade newGrade = new()
|
||||
{
|
||||
Name = textBoxName.Text,
|
||||
TeacherId = ((dynamic)comboBoxTeacher.SelectedItem).Id,
|
||||
};
|
||||
|
||||
_gradeLogic.Create(newGrade);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int gradeId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
Grade updatedGrade = new()
|
||||
{
|
||||
Id = gradeId,
|
||||
Name = textBoxName.Text,
|
||||
TeacherId = ((dynamic)comboBoxTeacher.SelectedItem).Id,
|
||||
};
|
||||
|
||||
_gradeLogic.Update(updatedGrade);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите класс, который необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int gradeId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_gradeLogic.Delete(gradeId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите класс, который необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
textBoxName.Text = row.Cells["Name"].Value.ToString();
|
||||
comboBoxTeacher.SelectedValue = Convert.ToInt32(row.Cells["TeacherId"].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ElectronicDiary/ElectronicDiaryView/FormGrade.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/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>
|
||||
@@ -30,13 +30,11 @@
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
предметToolStripMenuItem = new ToolStripMenuItem();
|
||||
carToolStripMenuItem = new ToolStripMenuItem();
|
||||
branchToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientToolStripMenuItem = new ToolStripMenuItem();
|
||||
rentalToolStripMenuItem = new ToolStripMenuItem();
|
||||
предметыToolStripMenuItem = new ToolStripMenuItem();
|
||||
классыToolStripMenuItem = new ToolStripMenuItem();
|
||||
замерВремениToolStripMenuItem = new ToolStripMenuItem();
|
||||
textBoxTest = new TextBox();
|
||||
ученикиToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -51,41 +49,24 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { предметToolStripMenuItem, carToolStripMenuItem, branchToolStripMenuItem, clientToolStripMenuItem, rentalToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { предметыToolStripMenuItem, классыToolStripMenuItem, ученикиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// предметToolStripMenuItem
|
||||
// предметыToolStripMenuItem
|
||||
//
|
||||
предметToolStripMenuItem.Name = "предметToolStripMenuItem";
|
||||
предметToolStripMenuItem.Size = new Size(122, 22);
|
||||
предметToolStripMenuItem.Text = "Предмет";
|
||||
предметToolStripMenuItem.Click += ПредметToolStripMenuItem_Click;
|
||||
предметыToolStripMenuItem.Name = "предметыToolStripMenuItem";
|
||||
предметыToolStripMenuItem.Size = new Size(180, 22);
|
||||
предметыToolStripMenuItem.Text = "Предметы";
|
||||
предметыToolStripMenuItem.Click += ПредметыToolStripMenuItem_Click;
|
||||
//
|
||||
// carToolStripMenuItem
|
||||
// классыToolStripMenuItem
|
||||
//
|
||||
carToolStripMenuItem.Name = "carToolStripMenuItem";
|
||||
carToolStripMenuItem.Size = new Size(122, 22);
|
||||
carToolStripMenuItem.Text = "car";
|
||||
//
|
||||
// branchToolStripMenuItem
|
||||
//
|
||||
branchToolStripMenuItem.Name = "branchToolStripMenuItem";
|
||||
branchToolStripMenuItem.Size = new Size(122, 22);
|
||||
branchToolStripMenuItem.Text = "branch";
|
||||
//
|
||||
// clientToolStripMenuItem
|
||||
//
|
||||
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
|
||||
clientToolStripMenuItem.Size = new Size(122, 22);
|
||||
clientToolStripMenuItem.Text = "client";
|
||||
//
|
||||
// rentalToolStripMenuItem
|
||||
//
|
||||
rentalToolStripMenuItem.Name = "rentalToolStripMenuItem";
|
||||
rentalToolStripMenuItem.Size = new Size(122, 22);
|
||||
rentalToolStripMenuItem.Text = "rental";
|
||||
классыToolStripMenuItem.Name = "классыToolStripMenuItem";
|
||||
классыToolStripMenuItem.Size = new Size(180, 22);
|
||||
классыToolStripMenuItem.Text = "Классы";
|
||||
классыToolStripMenuItem.Click += КлассыToolStripMenuItem_Click;
|
||||
//
|
||||
// замерВремениToolStripMenuItem
|
||||
//
|
||||
@@ -104,6 +85,13 @@
|
||||
textBoxTest.Size = new Size(296, 85);
|
||||
textBoxTest.TabIndex = 2;
|
||||
//
|
||||
// ученикиToolStripMenuItem
|
||||
//
|
||||
ученикиToolStripMenuItem.Name = "ученикиToolStripMenuItem";
|
||||
ученикиToolStripMenuItem.Size = new Size(180, 22);
|
||||
ученикиToolStripMenuItem.Text = "Ученики";
|
||||
ученикиToolStripMenuItem.Click += УченикиToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@@ -125,12 +113,10 @@
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem предметToolStripMenuItem;
|
||||
private ToolStripMenuItem carToolStripMenuItem;
|
||||
private ToolStripMenuItem branchToolStripMenuItem;
|
||||
private ToolStripMenuItem clientToolStripMenuItem;
|
||||
private ToolStripMenuItem rentalToolStripMenuItem;
|
||||
private ToolStripMenuItem предметыToolStripMenuItem;
|
||||
private TextBox textBoxTest;
|
||||
private ToolStripMenuItem замерВремениToolStripMenuItem;
|
||||
private ToolStripMenuItem классыToolStripMenuItem;
|
||||
private ToolStripMenuItem ученикиToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace ElectronicDiaryView
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ПредметToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ПредметыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSubject));
|
||||
if (service is FormSubject form)
|
||||
@@ -19,6 +19,24 @@ namespace ElectronicDiaryView
|
||||
}
|
||||
}
|
||||
|
||||
private void КлассыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormGrade));
|
||||
if (service is FormGrade form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void УченикиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStudent));
|
||||
if (service is FormStudent form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ЗамерВремениToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ISubjectWork));
|
||||
@@ -28,7 +46,7 @@ namespace ElectronicDiaryView
|
||||
int id = subjects.Last().Id;
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
subjectWork.Delete(id);
|
||||
subjectWork.Delete(id);
|
||||
DateTime endTime = DateTime.Now;
|
||||
|
||||
textBoxTest.Text = $"Время выполнения запроса: {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||||
|
||||
277
ElectronicDiary/ElectronicDiaryView/FormStudent.Designer.cs
generated
Normal file
277
ElectronicDiary/ElectronicDiaryView/FormStudent.Designer.cs
generated
Normal file
@@ -0,0 +1,277 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
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()
|
||||
{
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonCreate = new Button();
|
||||
textBoxLastName = new TextBox();
|
||||
label1 = new Label();
|
||||
dataGridView = new DataGridView();
|
||||
label2 = new Label();
|
||||
comboBoxGrade = new ComboBox();
|
||||
textBoxFirstName = new TextBox();
|
||||
label3 = new Label();
|
||||
textBoxPatronymic = new TextBox();
|
||||
labelPatronymic = new Label();
|
||||
buttonGetSubjects = new Button();
|
||||
buttonDeleteSubjects = new Button();
|
||||
comboBoxSubject = new ComboBox();
|
||||
label4 = new Label();
|
||||
buttonAddSubject = new Button();
|
||||
buttonDeleteSubject = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(802, 305);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(128, 30);
|
||||
buttonDelete.TabIndex = 28;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(802, 256);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(128, 30);
|
||||
buttonUpdate.TabIndex = 27;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(802, 207);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(128, 30);
|
||||
buttonCreate.TabIndex = 26;
|
||||
buttonCreate.Text = "Добавить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// textBoxLastName
|
||||
//
|
||||
textBoxLastName.Location = new Point(798, 10);
|
||||
textBoxLastName.Name = "textBoxLastName";
|
||||
textBoxLastName.Size = new Size(201, 23);
|
||||
textBoxLastName.TabIndex = 21;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(725, 13);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(64, 15);
|
||||
label1.TabIndex = 16;
|
||||
label1.Text = "Фамилия: ";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(13, 14);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(687, 608);
|
||||
dataGridView.TabIndex = 15;
|
||||
dataGridView.CellClick += DataGridView_CellClick;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(725, 142);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(42, 15);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "Класс:";
|
||||
//
|
||||
// comboBoxGrade
|
||||
//
|
||||
comboBoxGrade.FormattingEnabled = true;
|
||||
comboBoxGrade.Location = new Point(802, 139);
|
||||
comboBoxGrade.Name = "comboBoxGrade";
|
||||
comboBoxGrade.Size = new Size(197, 23);
|
||||
comboBoxGrade.TabIndex = 30;
|
||||
//
|
||||
// textBoxFirstName
|
||||
//
|
||||
textBoxFirstName.Location = new Point(800, 53);
|
||||
textBoxFirstName.Name = "textBoxFirstName";
|
||||
textBoxFirstName.Size = new Size(199, 23);
|
||||
textBoxFirstName.TabIndex = 32;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(725, 56);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(37, 15);
|
||||
label3.TabIndex = 31;
|
||||
label3.Text = "Имя: ";
|
||||
//
|
||||
// textBoxPatronymic
|
||||
//
|
||||
textBoxPatronymic.Location = new Point(802, 96);
|
||||
textBoxPatronymic.Name = "textBoxPatronymic";
|
||||
textBoxPatronymic.Size = new Size(197, 23);
|
||||
textBoxPatronymic.TabIndex = 34;
|
||||
//
|
||||
// labelPatronymic
|
||||
//
|
||||
labelPatronymic.AutoSize = true;
|
||||
labelPatronymic.Location = new Point(725, 99);
|
||||
labelPatronymic.Name = "labelPatronymic";
|
||||
labelPatronymic.Size = new Size(64, 15);
|
||||
labelPatronymic.TabIndex = 33;
|
||||
labelPatronymic.Text = "Отчество: ";
|
||||
//
|
||||
// buttonGetSubjects
|
||||
//
|
||||
buttonGetSubjects.Location = new Point(802, 421);
|
||||
buttonGetSubjects.Name = "buttonGetSubjects";
|
||||
buttonGetSubjects.Size = new Size(128, 30);
|
||||
buttonGetSubjects.TabIndex = 35;
|
||||
buttonGetSubjects.Text = "Предметы ученика";
|
||||
buttonGetSubjects.UseVisualStyleBackColor = true;
|
||||
buttonGetSubjects.Click += ButtonGetSubjects_Click;
|
||||
//
|
||||
// buttonDeleteSubjects
|
||||
//
|
||||
buttonDeleteSubjects.Location = new Point(802, 571);
|
||||
buttonDeleteSubjects.Name = "buttonDeleteSubjects";
|
||||
buttonDeleteSubjects.Size = new Size(128, 46);
|
||||
buttonDeleteSubjects.TabIndex = 36;
|
||||
buttonDeleteSubjects.Text = "Удалить все предметы";
|
||||
buttonDeleteSubjects.UseVisualStyleBackColor = true;
|
||||
buttonDeleteSubjects.Click += ButtonDeleteSubjects_Click;
|
||||
//
|
||||
// comboBoxSubject
|
||||
//
|
||||
comboBoxSubject.FormattingEnabled = true;
|
||||
comboBoxSubject.Location = new Point(808, 380);
|
||||
comboBoxSubject.Name = "comboBoxSubject";
|
||||
comboBoxSubject.Size = new Size(197, 23);
|
||||
comboBoxSubject.TabIndex = 38;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(731, 383);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(58, 15);
|
||||
label4.TabIndex = 37;
|
||||
label4.Text = "Предмет:";
|
||||
//
|
||||
// buttonAddSubject
|
||||
//
|
||||
buttonAddSubject.Location = new Point(802, 471);
|
||||
buttonAddSubject.Name = "buttonAddSubject";
|
||||
buttonAddSubject.Size = new Size(128, 30);
|
||||
buttonAddSubject.TabIndex = 39;
|
||||
buttonAddSubject.Text = "Добавить предмет";
|
||||
buttonAddSubject.UseVisualStyleBackColor = true;
|
||||
buttonAddSubject.Click += ButtonAddSubject_Click;
|
||||
//
|
||||
// buttonDeleteSubject
|
||||
//
|
||||
buttonDeleteSubject.Location = new Point(802, 521);
|
||||
buttonDeleteSubject.Name = "buttonDeleteSubject";
|
||||
buttonDeleteSubject.Size = new Size(128, 30);
|
||||
buttonDeleteSubject.TabIndex = 40;
|
||||
buttonDeleteSubject.Text = "Удалить предмет";
|
||||
buttonDeleteSubject.UseVisualStyleBackColor = true;
|
||||
buttonDeleteSubject.Click += ButtonDeleteSubject_Click;
|
||||
//
|
||||
// FormStudent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1014, 634);
|
||||
Controls.Add(buttonDeleteSubject);
|
||||
Controls.Add(buttonAddSubject);
|
||||
Controls.Add(comboBoxSubject);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(buttonDeleteSubjects);
|
||||
Controls.Add(buttonGetSubjects);
|
||||
Controls.Add(textBoxPatronymic);
|
||||
Controls.Add(labelPatronymic);
|
||||
Controls.Add(textBoxFirstName);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(comboBoxGrade);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(textBoxLastName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormStudent";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Ученики";
|
||||
Load += FormGrade_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCreate;
|
||||
private ComboBox comboBoxBodyType;
|
||||
private TextBox textBoxSeats;
|
||||
private TextBox textBoxYear;
|
||||
private TextBox textBoxModel;
|
||||
private TextBox textBoxLastName;
|
||||
private Label label5;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxGrade;
|
||||
private TextBox textBoxFirstName;
|
||||
private Label label3;
|
||||
private TextBox textBoxPatronymic;
|
||||
private Label labelPatronymic;
|
||||
private Button buttonGetSubjects;
|
||||
private Button buttonDeleteSubjects;
|
||||
private ComboBox comboBoxSubject;
|
||||
private Label label4;
|
||||
private Button buttonAddSubject;
|
||||
private Button buttonDeleteSubject;
|
||||
}
|
||||
}
|
||||
216
ElectronicDiary/ElectronicDiaryView/FormStudent.cs
Normal file
216
ElectronicDiary/ElectronicDiaryView/FormStudent.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
using ElectronicDiaryAbstractions.Models;
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormStudent : Form
|
||||
{
|
||||
private readonly IStudentWork _studentLogic;
|
||||
|
||||
private readonly IGradeWork _gradeLogic;
|
||||
|
||||
private readonly IUserWork _userLogic;
|
||||
|
||||
private readonly ISubjectWork _subjectLogic;
|
||||
|
||||
public FormStudent(IStudentWork studentLogic, IGradeWork gradeLogic, IUserWork userLogic, ISubjectWork subjectLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_studentLogic = studentLogic;
|
||||
_gradeLogic = gradeLogic;
|
||||
_userLogic = userLogic;
|
||||
_subjectLogic = subjectLogic;
|
||||
}
|
||||
|
||||
private void FormGrade_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var students = _studentLogic.GetAll();
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Name", "Имя ученика");
|
||||
dataGridView.Columns.Add("GradeId", "GradeId");
|
||||
dataGridView.Columns["GradeId"].Visible = false;
|
||||
dataGridView.Columns.Add("Grade", "Класс");
|
||||
dataGridView.Columns.Add("UserId", "UserId");
|
||||
dataGridView.Columns["UserId"].Visible = false;
|
||||
dataGridView.Columns.Add("UserLogin", "Логин");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Grade"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["UserLogin"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
comboBoxGrade.DataSource = _gradeLogic.GetAll();
|
||||
comboBoxGrade.DisplayMember = "Name";
|
||||
comboBoxGrade.ValueMember = "Id";
|
||||
|
||||
comboBoxSubject.DataSource = _subjectLogic.GetAll();
|
||||
comboBoxSubject.DisplayMember = "Name";
|
||||
comboBoxSubject.ValueMember = "Id";
|
||||
|
||||
foreach (var student in students)
|
||||
{
|
||||
dataGridView.Rows.Add(student.Id, student.LastName + " " + student.FirstName + " " + student.Patronymic, student.GradeId,
|
||||
_gradeLogic.Get(student.GradeId)?.Name, student.UserId, _userLogic.Get(student.UserId)?.Login);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
int someNumber = _userLogic.GetAll().Max(user => user.Id) + 1;
|
||||
User newUser = new()
|
||||
{
|
||||
Login = "login" + someNumber,
|
||||
Email = "email" + someNumber,
|
||||
Password = "password" + someNumber,
|
||||
PhoneNumber = "phonenumber" + someNumber,
|
||||
AccessLevel = "student",
|
||||
};
|
||||
_userLogic.Create(newUser);
|
||||
int newUserId = _userLogic.GetAll().Max(user => user.Id);
|
||||
|
||||
Student newStudent = new()
|
||||
{
|
||||
LastName = textBoxLastName.Text,
|
||||
FirstName = textBoxFirstName.Text,
|
||||
Patronymic = textBoxPatronymic.Text,
|
||||
GradeId = ((Grade)comboBoxGrade.SelectedItem).Id,
|
||||
UserId = newUserId,
|
||||
};
|
||||
|
||||
_studentLogic.Create(newStudent);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studentId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
Student updatedStudent = new()
|
||||
{
|
||||
Id = studentId,
|
||||
LastName = textBoxLastName.Text,
|
||||
FirstName = textBoxFirstName.Text,
|
||||
Patronymic = textBoxPatronymic.Text,
|
||||
GradeId = ((Grade)comboBoxGrade.SelectedItem).Id,
|
||||
};
|
||||
|
||||
_studentLogic.Update(updatedStudent);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите ученика, информацию о котором необходимо обновить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studentId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_studentLogic.Delete(studentId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите ученика, информацию о котором необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonGetSubjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSubjects));
|
||||
if (service is FormSubjects form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
form.IsStudent = true;
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите ученика, информацию о предметах которого необходимо посмотреть");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddSubject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studentId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_studentLogic.AddStudentSubject(studentId, ((Subject)comboBoxSubject.SelectedItem).Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите ученика, с которым необходимо связать предмет");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteSubject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studentId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_studentLogic.DeleteStudentSubject(studentId, ((Subject)comboBoxSubject.SelectedItem).Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите ученика, от которого необходимо отвязать предмет");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteSubjects_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count > 0)
|
||||
{
|
||||
DataGridViewRow selectedRow = dataGridView.SelectedRows[0];
|
||||
int studentId = Convert.ToInt32(selectedRow.Cells["Id"].Value);
|
||||
|
||||
_studentLogic.DeleteAllStudentSubjects(studentId);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Пожалуйста, выберите ученика, информацию о предметах которого необходимо удалить");
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex >= 0)
|
||||
{
|
||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||
string[] nameParts = (row != null && row.Cells["Name"] != null) ? row.Cells["Name"].Value.ToString().Split(' ') : new string[] { "", "", "" };
|
||||
textBoxLastName.Text = nameParts[0];
|
||||
textBoxFirstName.Text = nameParts[1];
|
||||
textBoxPatronymic.Text = nameParts[2];
|
||||
comboBoxGrade.SelectedValue = Convert.ToInt32(row.Cells["GradeId"].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ElectronicDiary/ElectronicDiaryView/FormStudent.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/FormStudent.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>
|
||||
67
ElectronicDiary/ElectronicDiaryView/FormSubjects.Designer.cs
generated
Normal file
67
ElectronicDiary/ElectronicDiaryView/FormSubjects.Designer.cs
generated
Normal file
@@ -0,0 +1,67 @@
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.Window;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(1, 0);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(568, 514);
|
||||
dataGridView.TabIndex = 16;
|
||||
//
|
||||
// FormSubjects
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(571, 516);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormSubjects";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Предметы";
|
||||
Load += FormSubjects_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
||||
56
ElectronicDiary/ElectronicDiaryView/FormSubjects.cs
Normal file
56
ElectronicDiary/ElectronicDiaryView/FormSubjects.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using ElectronicDiaryAbstractions.WorkAbstractions;
|
||||
|
||||
namespace ElectronicDiaryView
|
||||
{
|
||||
public partial class FormSubjects : Form
|
||||
{
|
||||
private readonly IStudentWork _studentLogic;
|
||||
private readonly ITeacherWork _teacherLogic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
private bool _isStudent;
|
||||
|
||||
public bool IsStudent { set { _isStudent = value; } }
|
||||
|
||||
public FormSubjects(IStudentWork studentLogic, ITeacherWork teacherLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_studentLogic = studentLogic;
|
||||
_teacherLogic = teacherLogic;
|
||||
}
|
||||
|
||||
private void FormSubjects_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _isStudent ? _studentLogic.GetAllStudentSubjects((int)_id) : _teacherLogic.GetAllTeacherSubjects((int)_id);
|
||||
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
if (dataGridView.ColumnCount == 0)
|
||||
{
|
||||
dataGridView.Columns.Add("Id", "ID");
|
||||
dataGridView.Columns.Add("Name", "Название предмета");
|
||||
}
|
||||
|
||||
dataGridView.Columns["Id"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
foreach (var subject in list)
|
||||
{
|
||||
dataGridView.Rows.Add(subject.Id, subject.Name);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ElectronicDiary/ElectronicDiaryView/FormSubjects.resx
Normal file
120
ElectronicDiary/ElectronicDiaryView/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>
|
||||
@@ -24,9 +24,20 @@ namespace ElectronicDiaryView
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IGradeWork, GradeWork>();
|
||||
services.AddTransient<IHomeworkWork, HomeworkWork>();
|
||||
services.AddTransient<ILessonWork, LessonWork>();
|
||||
services.AddTransient<IMarkWork, MarkWork>();
|
||||
services.AddTransient<IStudentWork, StudentWork>();
|
||||
services.AddTransient<IStudyAreaWork, StudyAreaWork>();
|
||||
services.AddTransient<ISubjectWork, SubjectWork>();
|
||||
services.AddTransient<ITeacherWork, TeacherWork>();
|
||||
services.AddTransient<IUserWork, UserWork>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormGrade>();
|
||||
services.AddTransient<FormStudent>();
|
||||
services.AddTransient<FormSubject>();
|
||||
services.AddTransient<FormSubjects>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user