Форма для факультета

This commit is contained in:
funa4i 2024-10-28 21:38:22 +04:00
parent d78c16662f
commit c75709899e
20 changed files with 9469 additions and 61 deletions

View File

@ -13,15 +13,15 @@ namespace StudentProgressRecord.Entity
public string DepartmentName { get; set; }
public long facultyId { get; set; }
public long FacultyId { get; set; }
public static Department CreateDepartment(long id, string DepartmentName, long facultyId)
public static Department CreateEntity(long id, string DepartmentName, long facultyId)
{
return new Department
{
Id = id,
DepartmentName = DepartmentName,
facultyId = facultyId
FacultyId = facultyId
};
}
}

View File

@ -12,7 +12,7 @@ namespace StudentProgressRecord.Entity
public string FacultyName { get; set; }
public static Faculty CreateFaculty(long id, string facultyName)
public static Faculty CreateEntity(long id, string facultyName)
{
return new Faculty()
{

View File

@ -14,7 +14,7 @@ namespace StudentProgressRecord.Entity
public long DepartmentId { get; set; }
public static Group CreateGroup(long id, string groupName, long departmentId)
public static Group CreateEntity(long id, string groupName, long departmentId)
{
return new Group
{

View File

@ -16,18 +16,18 @@ namespace StudentProgressRecord.Entity
public long StudentId { get; set; }
public DateTime date { get; set; }
public DateTime Date { get; set; }
public int Mark { get; set; }
public static Statement CreateStatement(long subjectId, long teacherId, long studentId, DateTime timeStamp, int mark)
public static Statement CreateEntity(long subjectId, long teacherId, long studentId, DateTime timeStamp, int mark)
{
return new Statement
{
SubjectId = subjectId,
TeacherId = teacherId,
StudentId = studentId,
date = timeStamp,
Date = timeStamp,
Mark = mark };
}
}

View File

@ -19,7 +19,7 @@ namespace StudentProgressRecord.Entity
public long GroupId { get; set; }
public static Student CreateStudent(long id, string fio, bool familyPos, bool domitory, long groupId)
public static Student CreateEntity(long id, string fio, bool familyPos, bool domitory, long groupId)
{
return new Student
{

View File

@ -12,7 +12,7 @@ namespace StudentProgressRecord.Entity
public string Name { get; set; }
public static Subject CreateSubject(long id, string name)
public static Subject CreateEntity(long id, string name)
{
return new Subject
{

View File

@ -14,7 +14,7 @@ namespace StudentProgressRecord.Entity
public long DepartmentID { get; set; }
public static Teacher CreateTeacher(long id, string Fio, long departmentId)
public static Teacher CreateEntity(long id, string Fio, long departmentId)
{
return new Teacher
{

View File

@ -1,39 +0,0 @@
namespace StudentProgressRecord
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

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

View File

@ -0,0 +1,93 @@
namespace StudentProgressRecord
{
partial class FormFaculty
{
/// <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()
{
labelFaculty = new Label();
textBoxFaculty = new TextBox();
buttonApply = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// labelFaculty
//
labelFaculty.AutoSize = true;
labelFaculty.Location = new Point(12, 95);
labelFaculty.Name = "labelFaculty";
labelFaculty.Size = new Size(157, 20);
labelFaculty.TabIndex = 0;
labelFaculty.Text = "Название факультета";
//
// textBoxFaculty
//
textBoxFaculty.Location = new Point(175, 92);
textBoxFaculty.Name = "textBoxFaculty";
textBoxFaculty.Size = new Size(348, 27);
textBoxFaculty.TabIndex = 1;
//
// buttonApply
//
buttonApply.Location = new Point(85, 144);
buttonApply.Name = "buttonApply";
buttonApply.Size = new Size(180, 29);
buttonApply.TabIndex = 2;
buttonApply.Text = "Сохранить";
buttonApply.UseVisualStyleBackColor = true;
//
// buttonCancel
//
buttonCancel.Location = new Point(271, 144);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(180, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// FormFaculty
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(535, 263);
Controls.Add(buttonCancel);
Controls.Add(buttonApply);
Controls.Add(textBoxFaculty);
Controls.Add(labelFaculty);
Name = "FormFaculty";
Text = "Факультет";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelFaculty;
private TextBox textBoxFaculty;
private Button buttonApply;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,74 @@
using StudentProgressRecord.Entity;
using StudentProgressRecord.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StudentProgressRecord
{
public partial class FormFaculty : Form
{
private readonly IFacultyRepository _facultyRepository;
private int? _facultyId;
public int Id
{
set
{
try
{
var faculty =
_facultyRepository.ReadFacultyById(value);
if (faculty == null)
{
throw new InvalidDataException(nameof(faculty));
}
textBoxFaculty.Text = faculty.FacultyName;
_facultyId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при полученииданных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormFaculty(IFacultyRepository facultyRepository)
{
InitializeComponent();
_facultyRepository = facultyRepository ?? throw new ArgumentNullException(nameof(facultyRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxFaculty.Text))
{
throw new Exception("Название факультета не может быть пустым");
}
if (_facultyId.HasValue)
{
_facultyRepository.UpdateFaculty(CreateFaculty(_facultyId.Value));
}
else
{
_facultyRepository.CreateFaculty(CreateFaculty(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Faculty CreateFaculty(int id) => Faculty.CreateEntity(id, textBoxFaculty.Text);
}
}

View File

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

View File

@ -1,4 +1,9 @@
using StudentProgressRecord.Repositories;
using StudentProgressRecord.RepositoryImp;
using Unity;
using Unity.Lifetime;
namespace StudentProgressRecord
{
internal static class Program
@ -12,7 +17,37 @@ namespace StudentProgressRecord
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new University());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IDepartmentRepository, DepartmentRepository>
(new TransientLifetimeManager());
container.RegisterType<IFacultyRepository, FacultyRepository>
(new TransientLifetimeManager());
container.RegisterType<IGroupRepository, GroupRepository>
(new TransientLifetimeManager());
container.RegisterType<IStatementRepository, StatementRepository>
(new TransientLifetimeManager());
container.RegisterType<IStudentRepository, StudentRepository>
(new TransientLifetimeManager());
container.RegisterType<ISubjectRepository, SubjectRepository>
(new TransientLifetimeManager());
container.RegisterType<ITeacherRepository, TeacherRepository>
(new TransientLifetimeManager());
return container;
}
}

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace StudentProgressRecord.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StudentProgressRecord.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 KiB

View File

@ -8,4 +8,25 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Abstractions" Version="5.11.7" />
<PackageReference Include="Unity.Container" Version="5.11.11" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,147 @@
namespace StudentProgressRecord
{
partial class University
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(University));
menuStrip1 = new MenuStrip();
HandbookToolStripMenuItem = new ToolStripMenuItem();
FacultyToolStripMenuItem = new ToolStripMenuItem();
OperationToolStripMenuItem = new ToolStripMenuItem();
ReportToolStripMenuItem = new ToolStripMenuItem();
DepartmentToolStripMenuItem = new ToolStripMenuItem();
GroupToolStripMenuItem = new ToolStripMenuItem();
StudentToolStripMenuItem = new ToolStripMenuItem();
TeacherToolStripMenuItem = new ToolStripMenuItem();
SubjectToolStripMenuItem = new ToolStripMenuItem();
StatementToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { HandbookToolStripMenuItem, OperationToolStripMenuItem, ReportToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(1200, 28);
menuStrip1.TabIndex = 1;
menuStrip1.Text = "menuStrip1";
//
// HandbookToolStripMenuItem
//
HandbookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { FacultyToolStripMenuItem, DepartmentToolStripMenuItem, GroupToolStripMenuItem, StudentToolStripMenuItem, TeacherToolStripMenuItem, SubjectToolStripMenuItem, StatementToolStripMenuItem });
HandbookToolStripMenuItem.Name = "HandbookToolStripMenuItem";
HandbookToolStripMenuItem.Size = new Size(117, 24);
HandbookToolStripMenuItem.Text = "Справочники";
//
// FacultyToolStripMenuItem
//
FacultyToolStripMenuItem.Name = "FacultyToolStripMenuItem";
FacultyToolStripMenuItem.Size = new Size(201, 26);
FacultyToolStripMenuItem.Text = "Факультеты";
//
// OperationToolStripMenuItem
//
OperationToolStripMenuItem.Name = "OperationToolStripMenuItem";
OperationToolStripMenuItem.Size = new Size(95, 24);
OperationToolStripMenuItem.Text = "Операции";
//
// ReportToolStripMenuItem
//
ReportToolStripMenuItem.Name = "ReportToolStripMenuItem";
ReportToolStripMenuItem.Size = new Size(73, 24);
ReportToolStripMenuItem.Text = "Отчеты";
//
// DepartmentToolStripMenuItem
//
DepartmentToolStripMenuItem.Name = "DepartmentToolStripMenuItem";
DepartmentToolStripMenuItem.Size = new Size(201, 26);
DepartmentToolStripMenuItem.Text = "Кафедры";
//
// GroupToolStripMenuItem
//
GroupToolStripMenuItem.Name = "GroupToolStripMenuItem";
GroupToolStripMenuItem.Size = new Size(201, 26);
GroupToolStripMenuItem.Text = "Группы";
//
// StudentToolStripMenuItem
//
StudentToolStripMenuItem.Name = "StudentToolStripMenuItem";
StudentToolStripMenuItem.Size = new Size(201, 26);
StudentToolStripMenuItem.Text = "Студенты";
//
// TeacherToolStripMenuItem
//
TeacherToolStripMenuItem.Name = "TeacherToolStripMenuItem";
TeacherToolStripMenuItem.Size = new Size(201, 26);
TeacherToolStripMenuItem.Text = "Преподаватели";
//
// SubjectToolStripMenuItem
//
SubjectToolStripMenuItem.Name = "SubjectToolStripMenuItem";
SubjectToolStripMenuItem.Size = new Size(201, 26);
SubjectToolStripMenuItem.Text = "Предметы";
//
// StatementToolStripMenuItem
//
StatementToolStripMenuItem.Name = "StatementToolStripMenuItem";
StatementToolStripMenuItem.Size = new Size(201, 26);
StatementToolStripMenuItem.Text = "Ведомость";
//
// University
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(1200, 599);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "University";
Text = "University";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem HandbookToolStripMenuItem;
private ToolStripMenuItem FacultyToolStripMenuItem;
private ToolStripMenuItem OperationToolStripMenuItem;
private ToolStripMenuItem ReportToolStripMenuItem;
private ToolStripMenuItem DepartmentToolStripMenuItem;
private ToolStripMenuItem GroupToolStripMenuItem;
private ToolStripMenuItem StudentToolStripMenuItem;
private ToolStripMenuItem TeacherToolStripMenuItem;
private ToolStripMenuItem SubjectToolStripMenuItem;
private ToolStripMenuItem StatementToolStripMenuItem;
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StudentProgressRecord
{
public partial class University : Form
{
public University()
{
InitializeComponent();
}
}
}

File diff suppressed because it is too large Load Diff