diff --git a/Academic_Performance/Academic_Performance/Academic_Performance.csproj b/Academic_Performance/Academic_Performance/Academic_Performance.csproj index 663fdb8..accbdf0 100644 --- a/Academic_Performance/Academic_Performance/Academic_Performance.csproj +++ b/Academic_Performance/Academic_Performance/Academic_Performance.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Entities/Enums/Group.cs b/Academic_Performance/Academic_Performance/Entities/Enums/Group.cs new file mode 100644 index 0000000..96f5708 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Enums/Group.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities.Enums +{ + + [Flags] + public enum Group + { + None = 0, + First = 1, + Second = 2, + Third = 4, + Fourth = 8 + } + +} diff --git a/Academic_Performance/Academic_Performance/Entities/Enums/Type.cs b/Academic_Performance/Academic_Performance/Entities/Enums/Type.cs new file mode 100644 index 0000000..9817419 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Enums/Type.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities.Enums +{ + public enum Type + { + None = 0, + One = 1, + Two = 2, + Three = 3, + Four = 4, + Five = 5 + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Enums/TypeS.cs b/Academic_Performance/Academic_Performance/Entities/Enums/TypeS.cs new file mode 100644 index 0000000..fbb08b7 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Enums/TypeS.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities.Enums +{ + + public enum TypeS + { + None = 0, + One = 1, + Two = 2, + Three = 3, + Four = 4, + Five = 5 + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Enums/Value.cs b/Academic_Performance/Academic_Performance/Entities/Enums/Value.cs new file mode 100644 index 0000000..374f06d --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Enums/Value.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities.Enums +{ + public enum Value + { + None=0, + One = 1, + Two = 2, + Three = 3, + Four = 4, + Five = 5 + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Mark.cs b/Academic_Performance/Academic_Performance/Entities/Mark.cs new file mode 100644 index 0000000..4b4a0f1 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Mark.cs @@ -0,0 +1,31 @@ +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities +{ + public class Mark + { + public int Id { get; private set; } + public int StudentId { get; private set; } + public int StatmentTeacherId { get; private set; } + public int StatmentSubjectId { get; private set; } + public Value? Value { get; private set; } + public DateTime Date { get; private set; } + + public static Mark CreateOperation(int id, int studentId, int statmentSubjectId, int statmentTeacherId, Value value) + { + return new Mark + { + Id = id, + StudentId = studentId, + StatmentSubjectId = statmentSubjectId, + StatmentTeacherId = statmentTeacherId, + Value = value, + }; + } + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Order.cs b/Academic_Performance/Academic_Performance/Entities/Order.cs new file mode 100644 index 0000000..d5f1db4 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Order.cs @@ -0,0 +1,32 @@ +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities +{ + public class Order + { + public int Id { get; private set; } + public int StudentId { get; private set; } + public string Information { get; private set; } + public TypeS? TypeS { get; private set; } + + public DateTime Date { get; private set; } + + public static Order CreateOperation(int id, int studentId, string information,TypeS types) + { + return new Order + { + Id = id, + StudentId = studentId, + Information = information, + TypeS = types, + + Date = DateTime.Now + }; + } + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Statement.cs b/Academic_Performance/Academic_Performance/Entities/Statement.cs new file mode 100644 index 0000000..56831f0 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Statement.cs @@ -0,0 +1,30 @@ +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities +{ + public class Statement + { + public int Id { get; private set; } + public int SubjecttId { get; private set; } + public int TeacherId{ get; private set; } + + public DateTime Date { get; private set; } + + public static Statement CreateOperation(int id, int subjecttId, int teacherId) + { + return new Statement + { + Id = id, + SubjecttId = subjecttId, + TeacherId = teacherId , + + Date = DateTime.Now + }; + } + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Student.cs b/Academic_Performance/Academic_Performance/Entities/Student.cs new file mode 100644 index 0000000..ef76e15 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Student.cs @@ -0,0 +1,29 @@ +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities +{ + public class Student + { + public int Id{ get; private set; } + public Group? Group { get; private set; } + public string Name { get; private set; } = string.Empty; + public string Flow { get; private set; } = string.Empty; + + public static Student CreateEntity(int id, string name,string flow, Group group) + { + return new Student + { + Id = id, + Name = name, + + Flow=flow, + Group = group, + }; + } + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Subject.cs b/Academic_Performance/Academic_Performance/Entities/Subject.cs new file mode 100644 index 0000000..ff8c74b --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Subject.cs @@ -0,0 +1,22 @@ +using Microsoft.VisualBasic.Devices; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities; + +public class Subject +{ + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + public static Subject Create(int id, string name) + { + return new Subject + { + Id = id, + Name = name + }; + } +} diff --git a/Academic_Performance/Academic_Performance/Entities/Teacher.cs b/Academic_Performance/Academic_Performance/Entities/Teacher.cs new file mode 100644 index 0000000..578588d --- /dev/null +++ b/Academic_Performance/Academic_Performance/Entities/Teacher.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Entities; + +public class Teacher +{ + public int Id { get; private set; } + public string Name{ get; private set; } = string.Empty; + + public static Teacher CreateEntity(int id, string name) + { + return new Teacher + { + Id = id, + Name = name, + }; + } + + + +} diff --git a/Academic_Performance/Academic_Performance/Form1.Designer.cs b/Academic_Performance/Academic_Performance/Form1.Designer.cs index 429521b..e6a3eb3 100644 --- a/Academic_Performance/Academic_Performance/Form1.Designer.cs +++ b/Academic_Performance/Academic_Performance/Form1.Designer.cs @@ -28,12 +28,115 @@ /// 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"; + menuStrip = new MenuStrip(); + cToolStripMenuItem = new ToolStripMenuItem(); + studentToolStripMenuItem = new ToolStripMenuItem(); + препToolStripMenuItem = new ToolStripMenuItem(); + предметыToolStripMenuItem = new ToolStripMenuItem(); + оценкиToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + добавлениеToolStripMenuItem = new ToolStripMenuItem(); + ведомостьToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(24, 24); + menuStrip.Items.AddRange(new ToolStripItem[] { cToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(778, 33); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // cToolStripMenuItem + // + cToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { studentToolStripMenuItem, препToolStripMenuItem, предметыToolStripMenuItem, оценкиToolStripMenuItem }); + cToolStripMenuItem.Name = "cToolStripMenuItem"; + cToolStripMenuItem.Size = new Size(139, 29); + cToolStripMenuItem.Text = "Справочники"; + // + // studentToolStripMenuItem + // + studentToolStripMenuItem.Name = "studentToolStripMenuItem"; + studentToolStripMenuItem.Size = new Size(270, 34); + studentToolStripMenuItem.Text = "Студенты"; + studentToolStripMenuItem.Click += studentToolStripMenuItem_Click; + // + // препToolStripMenuItem + // + препToolStripMenuItem.Name = "препToolStripMenuItem"; + препToolStripMenuItem.Size = new Size(270, 34); + препToolStripMenuItem.Text = "Преподаватели"; + // + // предметыToolStripMenuItem + // + предметыToolStripMenuItem.Name = "предметыToolStripMenuItem"; + предметыToolStripMenuItem.Size = new Size(270, 34); + предметыToolStripMenuItem.Text = "Предметы"; + // + // оценкиToolStripMenuItem + // + оценкиToolStripMenuItem.Name = "оценкиToolStripMenuItem"; + оценкиToolStripMenuItem.Size = new Size(270, 34); + оценкиToolStripMenuItem.Text = "Оценки"; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { добавлениеToolStripMenuItem, ведомостьToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(112, 29); + операцииToolStripMenuItem.Text = "Операции"; + // + // добавлениеToolStripMenuItem + // + добавлениеToolStripMenuItem.Name = "добавлениеToolStripMenuItem"; + добавлениеToolStripMenuItem.Size = new Size(202, 34); + добавлениеToolStripMenuItem.Text = "Приказ"; + // + // ведомостьToolStripMenuItem + // + ведомостьToolStripMenuItem.Name = "ведомостьToolStripMenuItem"; + ведомостьToolStripMenuItem.Size = new Size(202, 34); + ведомостьToolStripMenuItem.Text = "Ведомость"; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(88, 29); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // Form1 + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.unnamed; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(778, 450); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "Form1"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Form1"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); } #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem cToolStripMenuItem; + private ToolStripMenuItem studentToolStripMenuItem; + private ToolStripMenuItem препToolStripMenuItem; + private ToolStripMenuItem предметыToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem добавлениеToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem оценкиToolStripMenuItem; + private ToolStripMenuItem ведомостьToolStripMenuItem; } } diff --git a/Academic_Performance/Academic_Performance/Form1.cs b/Academic_Performance/Academic_Performance/Form1.cs index 08292b9..52a4a33 100644 --- a/Academic_Performance/Academic_Performance/Form1.cs +++ b/Academic_Performance/Academic_Performance/Form1.cs @@ -1,10 +1,33 @@ +using Academic_Performance.Forms; +using Unity; + namespace Academic_Performance { public partial class Form1 : Form { - public Form1() + private readonly IUnityContainer _container; + + public Form1(IUnityContainer container) { InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void ToolStripMenuItem_Click(object sender, EventArgs e) + { + } + + private void studentToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, " ", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } } diff --git a/Academic_Performance/Academic_Performance/Form1.resx b/Academic_Performance/Academic_Performance/Form1.resx index 1af7de1..31084d5 100644 --- a/Academic_Performance/Academic_Performance/Form1.resx +++ b/Academic_Performance/Academic_Performance/Form1.resx @@ -1,17 +1,17 @@  - @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudent.Designer.cs b/Academic_Performance/Academic_Performance/Forms/FormStudent.Designer.cs new file mode 100644 index 0000000..622878c --- /dev/null +++ b/Academic_Performance/Academic_Performance/Forms/FormStudent.Designer.cs @@ -0,0 +1,142 @@ +namespace Academic_Performance.Forms +{ + partial class FormStudent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label = new Label(); + label2 = new Label(); + label3 = new Label(); + textBoxName = new TextBox(); + button1 = new Button(); + button2 = new Button(); + textBoxFlow = new TextBox(); + comboBox1 = new ComboBox(); + SuspendLayout(); + // + // label + // + label.AutoSize = true; + label.Location = new Point(39, 31); + label.Name = "label"; + label.Size = new Size(126, 25); + label.TabIndex = 0; + label.Text = "ФИО студента"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(46, 126); + label2.Name = "label2"; + label2.Size = new Size(69, 25); + label2.TabIndex = 1; + label2.Text = "Группа"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(43, 208); + label3.Name = "label3"; + label3.Size = new Size(63, 25); + label3.TabIndex = 2; + label3.Text = "Поток"; + // + // textBoxName + // + textBoxName.Location = new Point(171, 27); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(385, 31); + textBoxName.TabIndex = 3; + textBoxName.TextChanged += textBox1_TextChanged; + // + // button1 + // + button1.Location = new Point(68, 316); + button1.Name = "button1"; + button1.Size = new Size(112, 34); + button1.TabIndex = 6; + button1.Text = "Сохранить"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + // + // button2 + // + button2.Location = new Point(291, 316); + button2.Name = "button2"; + button2.Size = new Size(112, 34); + button2.TabIndex = 7; + button2.Text = "Отмена"; + button2.UseVisualStyleBackColor = true; + // + // textBoxFlow + // + textBoxFlow.Location = new Point(171, 126); + textBoxFlow.Name = "textBoxFlow"; + textBoxFlow.Size = new Size(397, 31); + textBoxFlow.TabIndex = 8; + // + // comboBox1 + // + comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; + comboBox1.FormattingEnabled = true; + comboBox1.Location = new Point(171, 245); + comboBox1.Name = "comboBox1"; + comboBox1.Size = new Size(182, 33); + comboBox1.TabIndex = 9; + // + // FormStudent + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(602, 388); + Controls.Add(comboBox1); + Controls.Add(textBoxFlow); + Controls.Add(button2); + Controls.Add(button1); + Controls.Add(textBoxName); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label); + Name = "FormStudent"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Студент"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label; + private Label label2; + private Label label3; + private TextBox textBoxName; + private Button button1; + private Button button2; + private TextBox textBoxFlow; + private ComboBox comboBox1; + } +} \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudent.cs b/Academic_Performance/Academic_Performance/Forms/FormStudent.cs new file mode 100644 index 0000000..049ba4d --- /dev/null +++ b/Academic_Performance/Academic_Performance/Forms/FormStudent.cs @@ -0,0 +1,94 @@ +using Academic_Performance.Repositories; +using Academic_Performance.Entities; +using Academic_Performance.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Academic_Performance.Entities.Enums; + +namespace Academic_Performance.Forms +{ + public partial class FormStudent : Form + { + private readonly IStudentRepository _studentRepository; + private int? _studentId; + + public int Id + { + set + { + try + { + var student = _studentRepository.GetStudentById(value); + if (student == null) + { + throw new InvalidDataException(nameof(student)); + } + textBoxName.Text = student.Name; + textBoxFlow.Text = student.Flow; + comboBox1.SelectedItem =student.Group; + _studentId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormStudent(IStudentRepository studentRepository) + { + + InitializeComponent(); + _studentRepository = studentRepository ?? + throw new ArgumentNullException(nameof(studentRepository)); + comboBox1.DataSource =Enum.GetValues(typeof(Group)); + + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxName.Text)|| string.IsNullOrWhiteSpace(textBoxFlow.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_studentId.HasValue) + { + _studentRepository.UpdateStudent(CreateStudent(_studentId.Value)); + } + else + { + _studentRepository.AddStudent(CreateStudent(0)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private Student CreateStudent(int id) => Student.CreateEntity( + id, + textBoxName.Text, textBoxFlow.Text, (Group)comboBox1.SelectedItem! + ); + } + + +} diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudent.resx b/Academic_Performance/Academic_Performance/Forms/FormStudent.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Forms/FormStudent.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudents.Designer.cs b/Academic_Performance/Academic_Performance/Forms/FormStudents.Designer.cs new file mode 100644 index 0000000..7f6e408 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Forms/FormStudents.Designer.cs @@ -0,0 +1,122 @@ +namespace Academic_Performance.Forms +{ + partial class FormStudents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + button3 = new Button(); + button2 = new Button(); + button1 = new Button(); + dataGridView1 = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(button3); + panel1.Controls.Add(button2); + panel1.Controls.Add(button1); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(591, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(209, 450); + panel1.TabIndex = 0; + // + // button3 + // + button3.Location = new Point(52, 324); + button3.Name = "button3"; + button3.Size = new Size(112, 34); + button3.TabIndex = 2; + button3.Text = "button3"; + button3.UseVisualStyleBackColor = true; + button3.Click += button3_Click; + // + // button2 + // + button2.Location = new Point(52, 173); + button2.Name = "button2"; + button2.Size = new Size(112, 34); + button2.TabIndex = 1; + button2.Text = "button2"; + button2.UseVisualStyleBackColor = true; + button2.Click += button2_Click; + // + // button1 + // + button1.Location = new Point(52, 28); + button1.Name = "button1"; + button1.Size = new Size(112, 34); + button1.TabIndex = 0; + button1.Text = "button1"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.AllowUserToResizeColumns = false; + dataGridView1.AllowUserToResizeRows = false; + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.MultiSelect = false; + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.RowHeadersVisible = false; + dataGridView1.RowHeadersWidth = 62; + dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView1.Size = new Size(591, 450); + dataGridView1.TabIndex = 1; + // + // FormStudents + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView1); + Controls.Add(panel1); + Name = "FormStudents"; + Text = "FormStudents"; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button button3; + private Button button2; + private Button button1; + private DataGridView dataGridView1; + } +} \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudents.cs b/Academic_Performance/Academic_Performance/Forms/FormStudents.cs new file mode 100644 index 0000000..b5c6407 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Forms/FormStudents.cs @@ -0,0 +1,98 @@ +using Academic_Performance.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace Academic_Performance.Forms +{ + public partial class FormStudents : Form + { + private readonly IUnityContainer _container; + private readonly IStudentRepository _studentRepository; + + public FormStudents(IUnityContainer container, IStudentRepository studentRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); + } + + private void button1_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridView1.DataSource = _studentRepository.GetAllStudents(); + + private void button2_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView1.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["ID"].Value); + return true; + } + + private void button3_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + + } + + private void StudentsList_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudents.resx b/Academic_Performance/Academic_Performance/Forms/FormStudents.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Forms/FormStudents.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Program.cs b/Academic_Performance/Academic_Performance/Program.cs index 1d46e8b..0745e53 100644 --- a/Academic_Performance/Academic_Performance/Program.cs +++ b/Academic_Performance/Academic_Performance/Program.cs @@ -1,3 +1,8 @@ +using Unity.Lifetime; +using Unity; +using Academic_Performance.Repositories; +using Academic_Performance.Repositories.Implementations; + namespace Academic_Performance { internal static class Program @@ -11,7 +16,29 @@ namespace Academic_Performance // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); } + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new + TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + return container; + + } + + + + + } + } \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Properties/Resources.Designer.cs b/Academic_Performance/Academic_Performance/Properties/Resources.Designer.cs new file mode 100644 index 0000000..34b368d --- /dev/null +++ b/Academic_Performance/Academic_Performance/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Academic_Performance.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Academic_Performance.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap unnamed { + get { + object obj = ResourceManager.GetObject("unnamed", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Academic_Performance/Academic_Performance/Properties/Resources.resx b/Academic_Performance/Academic_Performance/Properties/Resources.resx new file mode 100644 index 0000000..1ab58a0 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\unnamed.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Academic_Performance/Academic_Performance/Repositories/IMarkRepository.cs b/Academic_Performance/Academic_Performance/Repositories/IMarkRepository.cs new file mode 100644 index 0000000..2960950 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/IMarkRepository.cs @@ -0,0 +1,18 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories +{ + public interface IMarkRepository + { + IEnumerable GetAllMarks(); + Mark GetMarkById(int id); + void AddMark(Mark mark); + void UpdateMark(Mark mark); + void DeleteMark(int id); + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs b/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs new file mode 100644 index 0000000..3518d82 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs @@ -0,0 +1,18 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories +{ + public interface IOrderRepository + { + IEnumerable GetAllOrders(); + Order GetOrderById(int id); + void AddOrder(Order order); + void UpdateOrder(Order order); + void DeleteOrder(int id); + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs b/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs new file mode 100644 index 0000000..fea46c8 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs @@ -0,0 +1,18 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories +{ + public interface IStatementRepository + { + IEnumerable GetAllStatements(); + Statement GetStatementById(int id); + void AddStatement(Statement statement); + void UpdateStatement(Statement statement); + void DeleteStatement(int id); + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/IStudentRepository.cs b/Academic_Performance/Academic_Performance/Repositories/IStudentRepository.cs new file mode 100644 index 0000000..edd939b --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/IStudentRepository.cs @@ -0,0 +1,18 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories +{ + public interface IStudentRepository + { + IEnumerable GetAllStudents(); + Student GetStudentById(int id); + void AddStudent(Student student); + void UpdateStudent(Student student); + void DeleteStudent(int id); + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/ISubjectRepository.cs b/Academic_Performance/Academic_Performance/Repositories/ISubjectRepository.cs new file mode 100644 index 0000000..7c01890 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/ISubjectRepository.cs @@ -0,0 +1,18 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories +{ + public interface ISubjectRepository + { + IEnumerable GetAllSubjects(); + Subject GetSubjectById(int id); + void AddSubject(Subject subject); + void UpdateSubject(Subject subject); + void DeleteSubject(int id); + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/ITeacherRepository.cs b/Academic_Performance/Academic_Performance/Repositories/ITeacherRepository.cs new file mode 100644 index 0000000..c609dbc --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/ITeacherRepository.cs @@ -0,0 +1,18 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories +{ + public interface ITeacherRepository + { + IEnumerable GetAllTeachers(); + Teacher GetTeacherById(int id); + void AddTeacher(Teacher teacher); + void UpdateTeacher(Teacher teacher); + void DeleteTeacher(int id); + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/MarkRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/MarkRepository.cs new file mode 100644 index 0000000..6cf2602 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/MarkRepository.cs @@ -0,0 +1,45 @@ +using Academic_Performance.Entities; +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories.Implementations +{ + + public class MarkRepository : IMarkRepository + { + public void CreateMark(Mark Mark) + { + // Заглушка + } + + public void UpdateMark(Mark Mark) + { + // Заглушка + } + + public void DeleteMark(int id) + { + // Заглушка + } + + public Mark GetMarkById(int id) + { + // Возвращаем объект с фиктивными данными, убедившись, что Mark.One существует + return Mark.CreateOperation(0, 0, 0, 0, Value.One); // Убедитесь, что Mark.One определен + } + + public IEnumerable GetAllMarks() + { + // Заглушка + return new List(); + } + public void AddMark(Mark mark) + { + // Заглушка + } + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs new file mode 100644 index 0000000..4be2da7 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs @@ -0,0 +1,38 @@ +using Academic_Performance.Entities; +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories.Implementations +{ + public class OrderRepository : IOrderRepository + { + public void AddOrder(Order order) + { + // Заглушка + } + + public void DeleteOrder(int id) + { + // Заглушка + } + + public IEnumerable GetAllOrders() + { + return new List(); + } + + public Order GetOrderById(int id) + { + return Order.CreateOperation(0,0, string.Empty,TypeS.None); + } + + public void UpdateOrder(Order order) + { + // Заглушка + } + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs new file mode 100644 index 0000000..8b4d87c --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs @@ -0,0 +1,37 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories.Implementations +{ + public class StatementRepository : IStatementRepository + { + public void AddStatement(Statement statement) + { + // Заглушка + } + + public void DeleteStatement(int id) + { + // Заглушка + } + + public IEnumerable GetAllStatements() + { + return new List(); + } + + public Statement GetStatementById(int id) + { + return Statement.CreateOperation(0, 0, 0); + } + + public void UpdateStatement(Statement statment) + { + // Заглушка + } + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/StudentRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/StudentRepository.cs new file mode 100644 index 0000000..0916be7 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/StudentRepository.cs @@ -0,0 +1,39 @@ +using Academic_Performance.Entities; +using Academic_Performance.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories.Implementations +{ + public class StudentRepository : IStudentRepository + { + public void AddStudent(Student subject) + { + // Заглушка + } + + public void DeleteStudent(int id) + { + // Заглушка + } + + public IEnumerable GetAllStudents() + { + return new List(); + } + + public Student GetStudentById(int id) + { + return Student.CreateEntity(0, string.Empty,string.Empty ,Group.None); + } + + public void UpdateStudent(Student student) + { + // Заглушка + } + } +} + diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/SubjectRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/SubjectRepository.cs new file mode 100644 index 0000000..9459100 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/SubjectRepository.cs @@ -0,0 +1,38 @@ +using Academic_Performance.Entities; +using Microsoft.VisualBasic.Devices; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories.Implementations +{ + public class SubjectRepository : ISubjectRepository + { + public void AddSubject(Subject subject) + { + // Заглушка + } + + public void DeleteSubject(int id) + { + // Заглушка + } + + public IEnumerable GetAllSubjects() + { + return new List(); + } + + public Subject GetSubjectById(int id) + { + return Subject.Create(0, string.Empty); + } + + public void UpdateSubject(Subject subject) + { + // Заглушка + } + } +} diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/TeacherRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/TeacherRepository.cs new file mode 100644 index 0000000..4e72f49 --- /dev/null +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/TeacherRepository.cs @@ -0,0 +1,37 @@ +using Academic_Performance.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Academic_Performance.Repositories.Implementations +{ + public class TeacherRepository : ITeacherRepository + { + public void AddTeacher(Teacher teacher) + { + // Заглушка + } + + public void DeleteTeacher(int id) + { + // Заглушка + } + + public IEnumerable GetAllTeachers() + { + return new List(); + } + + public Teacher GetTeacherById(int id) + { + return Teacher.CreateEntity(0, string.Empty); + } + + public void UpdateTeacher(Teacher teacher) + { + // Заглушка + } + } +} diff --git a/Academic_Performance/Academic_Performance/Resources/unnamed.jpg b/Academic_Performance/Academic_Performance/Resources/unnamed.jpg new file mode 100644 index 0000000..4851441 Binary files /dev/null and b/Academic_Performance/Academic_Performance/Resources/unnamed.jpg differ