Compare commits
No commits in common. "09a8bc1857afe257ee27c9c6e68e18e20054d99f" and "8563387642f75f185a16b039a5cc34f8e879450a" have entirely different histories.
09a8bc1857
...
8563387642
@ -2,6 +2,8 @@
|
|||||||
{
|
{
|
||||||
public record StudentSessionDTO
|
public record StudentSessionDTO
|
||||||
{
|
{
|
||||||
|
public Guid Id { get; init; }
|
||||||
|
|
||||||
public decimal Score { get; init; }
|
public decimal Score { get; init; }
|
||||||
|
|
||||||
public int Number { get; init; }
|
public int Number { get; init; }
|
||||||
|
@ -9,8 +9,7 @@ namespace Lab3.Database.MappingProfiles
|
|||||||
public SessionMappingProfile()
|
public SessionMappingProfile()
|
||||||
{
|
{
|
||||||
_ = CreateMap<StudentSession, StudentSessionDTO>();
|
_ = CreateMap<StudentSession, StudentSessionDTO>();
|
||||||
_ = CreateMap<StudentSessionDTO, StudentSession>()
|
_ = CreateMap<StudentSessionDTO, StudentSession>();
|
||||||
.ForMember(s => s.Id, opt => opt.MapFrom(s => Guid.NewGuid()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Lab3.Database.Context;
|
using Lab3.Database.Context;
|
||||||
using Lab3.Database.DTO;
|
using Lab3.Database.DTO;
|
||||||
using Lab3.Database.Models;
|
|
||||||
using Lab3.Database.Repository.Interfaces;
|
using Lab3.Database.Repository.Interfaces;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
@ -19,19 +18,10 @@ namespace Lab3.Database.Repository.Implementations
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<StudentDTO> CreateAsync(StudentDTO studentDTO)
|
public Task<List<StudentDTO>> Create(StudentDTO studentDTO) => throw new NotImplementedException();
|
||||||
{
|
public Task<StudentDTO> Delete(Guid id) => throw new NotImplementedException();
|
||||||
var student = _mapper.Map<Student>(studentDTO);
|
|
||||||
|
|
||||||
var result = await _context.Students.AddAsync(student);
|
public async Task<List<StudentDTO>> Get(int limit = 10000, int offset = 0)
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
return _mapper.Map<StudentDTO>(result.Entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<StudentDTO> DeleteAsync(Guid id) => throw new NotImplementedException();
|
|
||||||
|
|
||||||
public async Task<List<StudentDTO>> GetAsync(int limit = 10000, int offset = 0)
|
|
||||||
=> _mapper.Map<List<StudentDTO>>(
|
=> _mapper.Map<List<StudentDTO>>(
|
||||||
await _context.Students
|
await _context.Students
|
||||||
.Include(s => s.StudentSessions)
|
.Include(s => s.StudentSessions)
|
||||||
@ -39,38 +29,7 @@ namespace Lab3.Database.Repository.Implementations
|
|||||||
.Take(limit)
|
.Take(limit)
|
||||||
.ToListAsync());
|
.ToListAsync());
|
||||||
|
|
||||||
public async Task<StudentDTO?> GetAsync(Guid id)
|
public Task<StudentDTO> Get(Guid id) => throw new NotImplementedException();
|
||||||
{
|
public Task<StudentDTO> Update(StudentDTO studentDTO) => throw new NotImplementedException();
|
||||||
return _mapper.Map<StudentDTO>(
|
|
||||||
await _context.Students
|
|
||||||
.Include(s => s.StudentSessions)
|
|
||||||
.FirstOrDefaultAsync());
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO)
|
|
||||||
{
|
|
||||||
var student = _mapper.Map<Student>(studentDTO);
|
|
||||||
|
|
||||||
var currStudent = await _context.Students.FindAsync(student.Id);
|
|
||||||
|
|
||||||
if (currStudent == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
currStudent.Name = student.Name;
|
|
||||||
currStudent.StartEducation = student.StartEducation;
|
|
||||||
currStudent.EducationForm = student.EducationForm;
|
|
||||||
|
|
||||||
foreach (var session in currStudent.StudentSessions)
|
|
||||||
{
|
|
||||||
session.Score = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == session.Number)?.Score ?? session.Score;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
return _mapper.Map<StudentDTO>(currStudent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@ namespace Lab3.Database.Repository.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IStudentRepository
|
public interface IStudentRepository
|
||||||
{
|
{
|
||||||
Task<List<StudentDTO>> GetAsync(int limit = 10000, int offset = 0);
|
public Task<List<StudentDTO>> Get(int limit = 10000, int offset = 0);
|
||||||
|
|
||||||
Task<StudentDTO?> GetAsync(Guid id);
|
public Task<StudentDTO> Get(Guid id);
|
||||||
|
|
||||||
Task<StudentDTO?> UpdateAsync(StudentDTO studentDTO);
|
public Task<StudentDTO> Update(StudentDTO studentDTO);
|
||||||
|
|
||||||
Task<StudentDTO> DeleteAsync(Guid id);
|
public Task<StudentDTO> Delete(Guid id);
|
||||||
|
|
||||||
Task<StudentDTO> CreateAsync(StudentDTO studentDTO);
|
public Task<List<StudentDTO>> Create(StudentDTO studentDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
using Lab3.Database.Extensions;
|
||||||
using Lab3.Database.Extensions;
|
|
||||||
using Lab3.Database.Repository.Interfaces;
|
|
||||||
using Lab3.Forms;
|
using Lab3.Forms;
|
||||||
using Lab3.MappingProfiles;
|
using Lab3.MappingProfiles;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -25,13 +23,7 @@ namespace Lab3.Extensions
|
|||||||
this IServiceCollection services)
|
this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddScoped<MainForm>();
|
services.AddScoped<MainForm>();
|
||||||
|
services.AddScoped<CreateForm>();
|
||||||
services.AddScoped<Func<Guid?, CreateForm>>(sp => (id
|
|
||||||
=> new CreateForm(
|
|
||||||
sp.GetRequiredService<IStudentRepository>(),
|
|
||||||
sp.GetRequiredService<IEducationFormRepository>(),
|
|
||||||
id
|
|
||||||
)));
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
257
Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs
generated
257
Cop.Borovkov.Var3/Lab3/Forms/CreateForm.Designer.cs
generated
@ -28,52 +28,52 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
StartEducationDataPicker = new CustomsComponentsVar2.CustomDateTimePicker();
|
customDateTimePicker1 = new CustomsComponentsVar2.CustomDateTimePicker();
|
||||||
FormSelector = new ComponentsLab.VisualSelectionComponent();
|
visualSelectionComponent1 = new ComponentsLab.VisualSelectionComponent();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
NameTextBox = new TextBox();
|
textBox1 = new TextBox();
|
||||||
label3 = new Label();
|
label3 = new Label();
|
||||||
session1Score = new NumericUpDown();
|
numericUpDown1 = new NumericUpDown();
|
||||||
label4 = new Label();
|
label4 = new Label();
|
||||||
label5 = new Label();
|
label5 = new Label();
|
||||||
label6 = new Label();
|
label6 = new Label();
|
||||||
session2Score = new NumericUpDown();
|
numericUpDown2 = new NumericUpDown();
|
||||||
label7 = new Label();
|
label7 = new Label();
|
||||||
session3Score = new NumericUpDown();
|
numericUpDown3 = new NumericUpDown();
|
||||||
label8 = new Label();
|
label8 = new Label();
|
||||||
session6Score = new NumericUpDown();
|
numericUpDown4 = new NumericUpDown();
|
||||||
label9 = new Label();
|
label9 = new Label();
|
||||||
session5Score = new NumericUpDown();
|
numericUpDown5 = new NumericUpDown();
|
||||||
label10 = new Label();
|
label10 = new Label();
|
||||||
session4Score = new NumericUpDown();
|
numericUpDown6 = new NumericUpDown();
|
||||||
ButtonSave = new Button();
|
button1 = new Button();
|
||||||
buttonCancel = new Button();
|
button2 = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)session1Score).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session2Score).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session3Score).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown3).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session6Score).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown4).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session5Score).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown5).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session4Score).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown6).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// StartEducationDataPicker
|
// customDateTimePicker1
|
||||||
//
|
//
|
||||||
StartEducationDataPicker.Location = new Point(430, 32);
|
customDateTimePicker1.Location = new Point(430, 32);
|
||||||
StartEducationDataPicker.Name = "StartEducationDataPicker";
|
customDateTimePicker1.Name = "customDateTimePicker1";
|
||||||
StartEducationDataPicker.Size = new Size(456, 55);
|
customDateTimePicker1.Size = new Size(456, 55);
|
||||||
StartEducationDataPicker.TabIndex = 0;
|
customDateTimePicker1.TabIndex = 0;
|
||||||
StartEducationDataPicker.Value = new DateTime(2024, 11, 6, 22, 54, 54, 353);
|
customDateTimePicker1.Value = new DateTime(2024, 11, 6, 22, 54, 54, 353);
|
||||||
//
|
//
|
||||||
// FormSelector
|
// visualSelectionComponent1
|
||||||
//
|
//
|
||||||
FormSelector.BorderStyle = BorderStyle.FixedSingle;
|
visualSelectionComponent1.BorderStyle = BorderStyle.FixedSingle;
|
||||||
FormSelector.ComboBoxSelectedValue = "";
|
visualSelectionComponent1.comboBoxSelectedValue = "";
|
||||||
FormSelector.Location = new Point(436, 133);
|
visualSelectionComponent1.Location = new Point(430, 114);
|
||||||
FormSelector.Margin = new Padding(3, 4, 3, 4);
|
visualSelectionComponent1.Margin = new Padding(3, 4, 3, 4);
|
||||||
FormSelector.Name = "FormSelector";
|
visualSelectionComponent1.Name = "visualSelectionComponent1";
|
||||||
FormSelector.Size = new Size(352, 31);
|
visualSelectionComponent1.Size = new Size(211, 109);
|
||||||
FormSelector.TabIndex = 1;
|
visualSelectionComponent1.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
@ -87,18 +87,18 @@
|
|||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
label2.Location = new Point(436, 101);
|
label2.Location = new Point(436, 90);
|
||||||
label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
label2.Size = new Size(128, 20);
|
label2.Size = new Size(128, 20);
|
||||||
label2.TabIndex = 3;
|
label2.TabIndex = 3;
|
||||||
label2.Text = "Форма обучения";
|
label2.Text = "Форма обучения";
|
||||||
//
|
//
|
||||||
// NameTextBox
|
// textBox1
|
||||||
//
|
//
|
||||||
NameTextBox.Location = new Point(12, 60);
|
textBox1.Location = new Point(12, 60);
|
||||||
NameTextBox.Name = "NameTextBox";
|
textBox1.Name = "textBox1";
|
||||||
NameTextBox.Size = new Size(315, 27);
|
textBox1.Size = new Size(315, 27);
|
||||||
NameTextBox.TabIndex = 4;
|
textBox1.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
@ -109,15 +109,15 @@
|
|||||||
label3.TabIndex = 5;
|
label3.TabIndex = 5;
|
||||||
label3.Text = "ФИО";
|
label3.Text = "ФИО";
|
||||||
//
|
//
|
||||||
// session1Score
|
// numericUpDown1
|
||||||
//
|
//
|
||||||
session1Score.DecimalPlaces = 2;
|
numericUpDown1.DecimalPlaces = 2;
|
||||||
session1Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
numericUpDown1.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
session1Score.Location = new Point(12, 156);
|
numericUpDown1.Location = new Point(12, 156);
|
||||||
session1Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
numericUpDown1.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
||||||
session1Score.Name = "session1Score";
|
numericUpDown1.Name = "numericUpDown1";
|
||||||
session1Score.Size = new Size(150, 27);
|
numericUpDown1.Size = new Size(150, 27);
|
||||||
session1Score.TabIndex = 6;
|
numericUpDown1.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// label4
|
// label4
|
||||||
//
|
//
|
||||||
@ -146,15 +146,15 @@
|
|||||||
label6.TabIndex = 10;
|
label6.TabIndex = 10;
|
||||||
label6.Text = "Сессия2";
|
label6.Text = "Сессия2";
|
||||||
//
|
//
|
||||||
// session2Score
|
// numericUpDown2
|
||||||
//
|
//
|
||||||
session2Score.DecimalPlaces = 2;
|
numericUpDown2.DecimalPlaces = 2;
|
||||||
session2Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
numericUpDown2.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
session2Score.Location = new Point(12, 211);
|
numericUpDown2.Location = new Point(12, 211);
|
||||||
session2Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
numericUpDown2.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
||||||
session2Score.Name = "session2Score";
|
numericUpDown2.Name = "numericUpDown2";
|
||||||
session2Score.Size = new Size(150, 27);
|
numericUpDown2.Size = new Size(150, 27);
|
||||||
session2Score.TabIndex = 9;
|
numericUpDown2.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// label7
|
// label7
|
||||||
//
|
//
|
||||||
@ -165,15 +165,15 @@
|
|||||||
label7.TabIndex = 12;
|
label7.TabIndex = 12;
|
||||||
label7.Text = "Сессия3";
|
label7.Text = "Сессия3";
|
||||||
//
|
//
|
||||||
// session3Score
|
// numericUpDown3
|
||||||
//
|
//
|
||||||
session3Score.DecimalPlaces = 2;
|
numericUpDown3.DecimalPlaces = 2;
|
||||||
session3Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
numericUpDown3.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
session3Score.Location = new Point(12, 270);
|
numericUpDown3.Location = new Point(12, 270);
|
||||||
session3Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
numericUpDown3.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
||||||
session3Score.Name = "session3Score";
|
numericUpDown3.Name = "numericUpDown3";
|
||||||
session3Score.Size = new Size(150, 27);
|
numericUpDown3.Size = new Size(150, 27);
|
||||||
session3Score.TabIndex = 11;
|
numericUpDown3.TabIndex = 11;
|
||||||
//
|
//
|
||||||
// label8
|
// label8
|
||||||
//
|
//
|
||||||
@ -184,15 +184,15 @@
|
|||||||
label8.TabIndex = 18;
|
label8.TabIndex = 18;
|
||||||
label8.Text = "Сессия6";
|
label8.Text = "Сессия6";
|
||||||
//
|
//
|
||||||
// session6Score
|
// numericUpDown4
|
||||||
//
|
//
|
||||||
session6Score.DecimalPlaces = 2;
|
numericUpDown4.DecimalPlaces = 2;
|
||||||
session6Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
numericUpDown4.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
session6Score.Location = new Point(177, 270);
|
numericUpDown4.Location = new Point(177, 270);
|
||||||
session6Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
numericUpDown4.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
||||||
session6Score.Name = "session6Score";
|
numericUpDown4.Name = "numericUpDown4";
|
||||||
session6Score.Size = new Size(150, 27);
|
numericUpDown4.Size = new Size(150, 27);
|
||||||
session6Score.TabIndex = 17;
|
numericUpDown4.TabIndex = 17;
|
||||||
//
|
//
|
||||||
// label9
|
// label9
|
||||||
//
|
//
|
||||||
@ -203,15 +203,15 @@
|
|||||||
label9.TabIndex = 16;
|
label9.TabIndex = 16;
|
||||||
label9.Text = "Сессия5";
|
label9.Text = "Сессия5";
|
||||||
//
|
//
|
||||||
// session5Score
|
// numericUpDown5
|
||||||
//
|
//
|
||||||
session5Score.DecimalPlaces = 2;
|
numericUpDown5.DecimalPlaces = 2;
|
||||||
session5Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
numericUpDown5.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
session5Score.Location = new Point(177, 211);
|
numericUpDown5.Location = new Point(177, 211);
|
||||||
session5Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
numericUpDown5.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
||||||
session5Score.Name = "session5Score";
|
numericUpDown5.Name = "numericUpDown5";
|
||||||
session5Score.Size = new Size(150, 27);
|
numericUpDown5.Size = new Size(150, 27);
|
||||||
session5Score.TabIndex = 15;
|
numericUpDown5.TabIndex = 15;
|
||||||
//
|
//
|
||||||
// label10
|
// label10
|
||||||
//
|
//
|
||||||
@ -222,96 +222,95 @@
|
|||||||
label10.TabIndex = 14;
|
label10.TabIndex = 14;
|
||||||
label10.Text = "Сессия4";
|
label10.Text = "Сессия4";
|
||||||
//
|
//
|
||||||
// session4Score
|
// numericUpDown6
|
||||||
//
|
//
|
||||||
session4Score.DecimalPlaces = 2;
|
numericUpDown6.DecimalPlaces = 2;
|
||||||
session4Score.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
numericUpDown6.Increment = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||||
session4Score.Location = new Point(177, 156);
|
numericUpDown6.Location = new Point(177, 156);
|
||||||
session4Score.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
numericUpDown6.Maximum = new decimal(new int[] { 5, 0, 0, 0 });
|
||||||
session4Score.Name = "session4Score";
|
numericUpDown6.Name = "numericUpDown6";
|
||||||
session4Score.Size = new Size(150, 27);
|
numericUpDown6.Size = new Size(150, 27);
|
||||||
session4Score.TabIndex = 13;
|
numericUpDown6.TabIndex = 13;
|
||||||
//
|
//
|
||||||
// ButtonSave
|
// button1
|
||||||
//
|
//
|
||||||
ButtonSave.Location = new Point(430, 258);
|
button1.Location = new Point(430, 258);
|
||||||
ButtonSave.Name = "ButtonSave";
|
button1.Name = "button1";
|
||||||
ButtonSave.Size = new Size(164, 39);
|
button1.Size = new Size(164, 39);
|
||||||
ButtonSave.TabIndex = 19;
|
button1.TabIndex = 19;
|
||||||
ButtonSave.Text = "Сохранить";
|
button1.Text = "Сохранить";
|
||||||
ButtonSave.UseVisualStyleBackColor = true;
|
button1.UseVisualStyleBackColor = true;
|
||||||
ButtonSave.Click += ButtonSave_ClickAsync;
|
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// button2
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(624, 258);
|
button2.Location = new Point(624, 258);
|
||||||
buttonCancel.Name = "buttonCancel";
|
button2.Name = "button2";
|
||||||
buttonCancel.Size = new Size(164, 39);
|
button2.Size = new Size(164, 39);
|
||||||
buttonCancel.TabIndex = 20;
|
button2.TabIndex = 20;
|
||||||
buttonCancel.Text = "Отмена";
|
button2.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
button2.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// CreateForm
|
// CreateForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 309);
|
ClientSize = new Size(800, 309);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(button2);
|
||||||
Controls.Add(ButtonSave);
|
Controls.Add(button1);
|
||||||
Controls.Add(label8);
|
Controls.Add(label8);
|
||||||
Controls.Add(session6Score);
|
Controls.Add(numericUpDown4);
|
||||||
Controls.Add(label9);
|
Controls.Add(label9);
|
||||||
Controls.Add(session5Score);
|
Controls.Add(numericUpDown5);
|
||||||
Controls.Add(label10);
|
Controls.Add(label10);
|
||||||
Controls.Add(session4Score);
|
Controls.Add(numericUpDown6);
|
||||||
Controls.Add(label7);
|
Controls.Add(label7);
|
||||||
Controls.Add(session3Score);
|
Controls.Add(numericUpDown3);
|
||||||
Controls.Add(label6);
|
Controls.Add(label6);
|
||||||
Controls.Add(session2Score);
|
Controls.Add(numericUpDown2);
|
||||||
Controls.Add(label5);
|
Controls.Add(label5);
|
||||||
Controls.Add(label4);
|
Controls.Add(label4);
|
||||||
Controls.Add(session1Score);
|
Controls.Add(numericUpDown1);
|
||||||
Controls.Add(label3);
|
Controls.Add(label3);
|
||||||
Controls.Add(NameTextBox);
|
Controls.Add(textBox1);
|
||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(StartEducationDataPicker);
|
Controls.Add(customDateTimePicker1);
|
||||||
Controls.Add(FormSelector);
|
Controls.Add(visualSelectionComponent1);
|
||||||
Name = "CreateForm";
|
Name = "CreateForm";
|
||||||
Text = "CreateForm";
|
Text = "CreateForm";
|
||||||
Load += CreateForm_LoadAsync;
|
Load += CreateForm_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)session1Score).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session2Score).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session3Score).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown3).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session6Score).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown4).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session5Score).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown5).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)session4Score).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDown6).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private CustomsComponentsVar2.CustomDateTimePicker StartEducationDataPicker;
|
private CustomsComponentsVar2.CustomDateTimePicker customDateTimePicker1;
|
||||||
private ComponentsLab.VisualSelectionComponent FormSelector;
|
private ComponentsLab.VisualSelectionComponent visualSelectionComponent1;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private TextBox NameTextBox;
|
private TextBox textBox1;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private NumericUpDown session1Score;
|
private NumericUpDown numericUpDown1;
|
||||||
private Label label4;
|
private Label label4;
|
||||||
private Label label5;
|
private Label label5;
|
||||||
private Label label6;
|
private Label label6;
|
||||||
private NumericUpDown session2Score;
|
private NumericUpDown numericUpDown2;
|
||||||
private Label label7;
|
private Label label7;
|
||||||
private NumericUpDown session3Score;
|
private NumericUpDown numericUpDown3;
|
||||||
private Label label8;
|
private Label label8;
|
||||||
private NumericUpDown session6Score;
|
private NumericUpDown numericUpDown4;
|
||||||
private Label label9;
|
private Label label9;
|
||||||
private NumericUpDown session5Score;
|
private NumericUpDown numericUpDown5;
|
||||||
private Label label10;
|
private Label label10;
|
||||||
private NumericUpDown session4Score;
|
private NumericUpDown numericUpDown6;
|
||||||
private Button ButtonSave;
|
private Button button1;
|
||||||
private Button buttonCancel;
|
private Button button2;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,110 +1,17 @@
|
|||||||
using Lab3.Database.DTO;
|
using Lab3.Database.Repository.Interfaces;
|
||||||
using Lab3.Database.Models;
|
|
||||||
using Lab3.Database.Repository.Interfaces;
|
|
||||||
|
|
||||||
namespace Lab3.Forms
|
namespace Lab3.Forms
|
||||||
{
|
{
|
||||||
public partial class CreateForm : Form
|
public partial class CreateForm : Form
|
||||||
{
|
{
|
||||||
private readonly IStudentRepository _studentRepository;
|
public CreateForm(IStudentRepository student)
|
||||||
|
|
||||||
private readonly IEducationFormRepository _educationFormRepository;
|
|
||||||
|
|
||||||
private readonly Guid? _updatedStudentGuid = null;
|
|
||||||
|
|
||||||
public CreateForm(
|
|
||||||
IStudentRepository studentRepository,
|
|
||||||
IEducationFormRepository educationFormRepository,
|
|
||||||
Guid? updatedStudentGuid)
|
|
||||||
{
|
{
|
||||||
_studentRepository = studentRepository;
|
|
||||||
_educationFormRepository = educationFormRepository;
|
|
||||||
|
|
||||||
_updatedStudentGuid = updatedStudentGuid;
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void CreateForm_LoadAsync(object sender, EventArgs e)
|
private void CreateForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
FormSelector.Fill(await _educationFormRepository.Get());
|
|
||||||
StartEducationDataPicker.DateStart = DateTime.Now.AddYears(-6);
|
|
||||||
StartEducationDataPicker.DateEnd = DateTime.Now;
|
|
||||||
|
|
||||||
if (_updatedStudentGuid == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var student = await _studentRepository.GetAsync(_updatedStudentGuid.Value);
|
|
||||||
|
|
||||||
NameTextBox.Text = student.Name;
|
|
||||||
StartEducationDataPicker.Value = student.StartEducation;
|
|
||||||
FormSelector.ComboBoxSelectedValue = student.EducationForm;
|
|
||||||
|
|
||||||
session1Score.Value = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == 1)?.Score ?? decimal.Zero;
|
|
||||||
session2Score.Value = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == 2)?.Score ?? decimal.Zero;
|
|
||||||
session3Score.Value = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == 3)?.Score ?? decimal.Zero;
|
|
||||||
session4Score.Value = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == 4)?.Score ?? decimal.Zero;
|
|
||||||
session5Score.Value = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == 5)?.Score ?? decimal.Zero;
|
|
||||||
session6Score.Value = student.StudentSessions
|
|
||||||
.FirstOrDefault(s => s.Number == 6)?.Score ?? decimal.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void ButtonSave_ClickAsync(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(NameTextBox.Text)
|
|
||||||
|| string.IsNullOrEmpty(FormSelector.ComboBoxSelectedValue))
|
|
||||||
{
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
StudentDTO student = new()
|
|
||||||
{
|
|
||||||
Id = _updatedStudentGuid ?? Guid.NewGuid(),
|
|
||||||
Name = NameTextBox.Text,
|
|
||||||
StartEducation = StartEducationDataPicker.Value,
|
|
||||||
EducationForm = FormSelector.ComboBoxSelectedValue,
|
|
||||||
StudentSessions = [
|
|
||||||
new(){
|
|
||||||
Score = session1Score.Value,
|
|
||||||
Number = 1,
|
|
||||||
},
|
|
||||||
new(){
|
|
||||||
Score = session2Score.Value,
|
|
||||||
Number = 2,
|
|
||||||
},
|
|
||||||
new(){
|
|
||||||
Score = session3Score.Value,
|
|
||||||
Number = 3,
|
|
||||||
},
|
|
||||||
new(){
|
|
||||||
Score = session4Score.Value,
|
|
||||||
Number = 4,
|
|
||||||
},
|
|
||||||
new(){
|
|
||||||
Score = session5Score.Value,
|
|
||||||
Number = 5,
|
|
||||||
},
|
|
||||||
new(){
|
|
||||||
Score = session6Score.Value,
|
|
||||||
Number = 6,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_updatedStudentGuid != null)
|
|
||||||
{
|
|
||||||
await _studentRepository.UpdateAsync(student);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await _studentRepository.CreateAsync(student);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace Lab3.Forms
|
|||||||
|
|
||||||
private async void MainForm_LoadAsync(object sender, EventArgs e)
|
private async void MainForm_LoadAsync(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var students = _mapper.Map<List<StudentViewModel>>(await _studentRepository.GetAsync());
|
var students = _mapper.Map<List<StudentViewModel>>(await _studentRepository.Get());
|
||||||
StudentsListBox.FillListBox(students);
|
StudentsListBox.FillListBox(students);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ComponentsLibraryLab1" Version="8.0.2" />
|
<PackageReference Include="ComponentsLibraryLab1" Version="1.0.0" />
|
||||||
<PackageReference Include="ComponentsLibraryLab2" Version="8.0.1" />
|
<PackageReference Include="ComponentsLibraryLab2" Version="1.0.0" />
|
||||||
<PackageReference Include="Cop.Borovkov.Var3" Version="8.0.1" />
|
<PackageReference Include="Cop.Borovkov.Var3" Version="8.0.1" />
|
||||||
<PackageReference Include="CustomComponentsVar2" Version="8.0.2" />
|
<PackageReference Include="CustomComponentsVar2" Version="8.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
|
@ -21,7 +21,7 @@ namespace Lab3
|
|||||||
|
|
||||||
var app = CreateHostBuilder().Build();
|
var app = CreateHostBuilder().Build();
|
||||||
|
|
||||||
Application.Run(app.Services.GetRequiredService<MainForm>());
|
Application.Run(app.Services.GetRequiredService<CreateForm>());
|
||||||
}
|
}
|
||||||
|
|
||||||
static IHostBuilder CreateHostBuilder()
|
static IHostBuilder CreateHostBuilder()
|
||||||
|
Loading…
Reference in New Issue
Block a user