Готово 2

This commit is contained in:
Ь Ъ 2025-01-30 02:43:59 +04:00
parent ad006f8af0
commit 77fa33ef78
8 changed files with 56 additions and 59 deletions

View File

@ -13,6 +13,7 @@ namespace Academic_Performance.Entities
public int SubjectId { get; private set; } public int SubjectId { get; private set; }
public int TeacherId{ get; private set; } public int TeacherId{ get; private set; }
public DateTime Date { get; private set; }
public IEnumerable<Mark> Mark{ get; private set; } = []; public IEnumerable<Mark> Mark{ get; private set; } = [];
public static Statement CreateOperation(int id, int subjectId, int teacherId, IEnumerable<Mark> mark) public static Statement CreateOperation(int id, int subjectId, int teacherId, IEnumerable<Mark> mark)
{return new Statement {return new Statement
@ -20,7 +21,7 @@ namespace Academic_Performance.Entities
Id = id, Id = id,
SubjectId = subjectId, SubjectId = subjectId,
TeacherId = teacherId, TeacherId = teacherId,
Date = DateTime.Now,
Mark = mark Mark = mark
}; };
} }

View File

@ -30,10 +30,8 @@
{ {
buttonSave = new Button(); buttonSave = new Button();
buttonEx = new Button(); buttonEx = new Button();
label1 = new Label();
label2 = new Label(); label2 = new Label();
label3 = new Label(); label3 = new Label();
dateTimePicker1 = new DateTimePicker();
comboBoxType = new ComboBox(); comboBoxType = new ComboBox();
textBoxInf = new TextBox(); textBoxInf = new TextBox();
comboBoxIdStudent = new ComboBox(); comboBoxIdStudent = new ComboBox();
@ -42,10 +40,10 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(64, 310); buttonSave.Location = new Point(130, 259);
buttonSave.Margin = new Padding(2); buttonSave.Margin = new Padding(2);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(90, 27); buttonSave.Size = new Size(127, 27);
buttonSave.TabIndex = 1; buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить"; buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = true;
@ -53,57 +51,40 @@
// //
// buttonEx // buttonEx
// //
buttonEx.Location = new Point(458, 323); buttonEx.Location = new Point(367, 259);
buttonEx.Margin = new Padding(2); buttonEx.Margin = new Padding(2);
buttonEx.Name = "buttonEx"; buttonEx.Name = "buttonEx";
buttonEx.Size = new Size(90, 27); buttonEx.Size = new Size(115, 27);
buttonEx.TabIndex = 2; buttonEx.TabIndex = 2;
buttonEx.Text = "Отмена"; buttonEx.Text = "Отмена";
buttonEx.UseVisualStyleBackColor = true; buttonEx.UseVisualStyleBackColor = true;
buttonEx.Click += buttonEx_Click; buttonEx.Click += buttonEx_Click;
// //
// label1
//
label1.AutoSize = true;
label1.Location = new Point(50, 25);
label1.Margin = new Padding(2, 0, 2, 0);
label1.Name = "label1";
label1.Size = new Size(41, 20);
label1.TabIndex = 3;
label1.Text = "Дата";
//
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(56, 83); label2.Location = new Point(83, 19);
label2.Margin = new Padding(2, 0, 2, 0); label2.Margin = new Padding(2, 0, 2, 0);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(35, 20); label2.Size = new Size(35, 20);
label2.TabIndex = 4; label2.TabIndex = 4;
label2.Text = "Тип"; label2.Text = "Тип";
label2.Click += label2_Click;
// //
// label3 // label3
// //
label3.AutoSize = true; label3.AutoSize = true;
label3.Location = new Point(22, 150); label3.Location = new Point(35, 94);
label3.Margin = new Padding(2, 0, 2, 0); label3.Margin = new Padding(2, 0, 2, 0);
label3.Name = "label3"; label3.Name = "label3";
label3.Size = new Size(102, 20); label3.Size = new Size(102, 20);
label3.TabIndex = 5; label3.TabIndex = 5;
label3.Text = "Информация"; label3.Text = "Информация";
// //
// dateTimePicker1
//
dateTimePicker1.Location = new Point(147, 21);
dateTimePicker1.Margin = new Padding(2);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(241, 27);
dateTimePicker1.TabIndex = 6;
//
// comboBoxType // comboBoxType
// //
comboBoxType.FormattingEnabled = true; comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(147, 83); comboBoxType.Location = new Point(157, 11);
comboBoxType.Margin = new Padding(2); comboBoxType.Margin = new Padding(2);
comboBoxType.Name = "comboBoxType"; comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(414, 28); comboBoxType.Size = new Size(414, 28);
@ -111,7 +92,7 @@
// //
// textBoxInf // textBoxInf
// //
textBoxInf.Location = new Point(140, 154); textBoxInf.Location = new Point(157, 87);
textBoxInf.Margin = new Padding(2); textBoxInf.Margin = new Padding(2);
textBoxInf.Name = "textBoxInf"; textBoxInf.Name = "textBoxInf";
textBoxInf.Size = new Size(421, 27); textBoxInf.Size = new Size(421, 27);
@ -120,7 +101,7 @@
// comboBoxIdStudent // comboBoxIdStudent
// //
comboBoxIdStudent.FormattingEnabled = true; comboBoxIdStudent.FormattingEnabled = true;
comboBoxIdStudent.Location = new Point(140, 214); comboBoxIdStudent.Location = new Point(157, 164);
comboBoxIdStudent.Margin = new Padding(2); comboBoxIdStudent.Margin = new Padding(2);
comboBoxIdStudent.Name = "comboBoxIdStudent"; comboBoxIdStudent.Name = "comboBoxIdStudent";
comboBoxIdStudent.Size = new Size(421, 28); comboBoxIdStudent.Size = new Size(421, 28);
@ -129,7 +110,7 @@
// label4 // label4
// //
label4.AutoSize = true; label4.AutoSize = true;
label4.Location = new Point(11, 217); label4.Location = new Point(35, 172);
label4.Margin = new Padding(2, 0, 2, 0); label4.Margin = new Padding(2, 0, 2, 0);
label4.Name = "label4"; label4.Name = "label4";
label4.Size = new Size(107, 20); label4.Size = new Size(107, 20);
@ -140,15 +121,13 @@
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(640, 360); ClientSize = new Size(640, 308);
Controls.Add(label4); Controls.Add(label4);
Controls.Add(comboBoxIdStudent); Controls.Add(comboBoxIdStudent);
Controls.Add(textBoxInf); Controls.Add(textBoxInf);
Controls.Add(comboBoxType); Controls.Add(comboBoxType);
Controls.Add(dateTimePicker1);
Controls.Add(label3); Controls.Add(label3);
Controls.Add(label2); Controls.Add(label2);
Controls.Add(label1);
Controls.Add(buttonEx); Controls.Add(buttonEx);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Margin = new Padding(2); Margin = new Padding(2);
@ -164,10 +143,8 @@
private Button buttonSave; private Button buttonSave;
private Button buttonEx; private Button buttonEx;
private Label label1;
private Label label2; private Label label2;
private Label label3; private Label label3;
private DateTimePicker dateTimePicker1;
private ComboBox comboBoxType; private ComboBox comboBoxType;
private TextBox textBoxInf; private TextBox textBoxInf;
private ComboBox comboBoxIdStudent; private ComboBox comboBoxIdStudent;

View File

@ -93,5 +93,15 @@ namespace Academic_Performance.Forms
{ {
} }
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
} }
} }

View File

@ -39,7 +39,7 @@ namespace Academic_Performance.Forms
} }
textBoxName.Text = student.Name; textBoxName.Text = student.Name;
textBoxFlow.Text = student.Flow; textBoxFlow.Text = student.Flow;
checkedListBoxGroup.SelectedItem =student.Groupp;
_studentId = value; _studentId = value;
} }
catch (Exception ex) catch (Exception ex)
@ -66,7 +66,7 @@ namespace Academic_Performance.Forms
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(textBoxName.Text)|| string.IsNullOrWhiteSpace(textBoxFlow.Text)) if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxFlow.Text))
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
@ -88,10 +88,19 @@ namespace Academic_Performance.Forms
} }
} }
private Student CreateStudent(int id) => Student.CreateEntity( private Student CreateStudent(int id)
id, {
textBoxName.Text, textBoxFlow.Text, (Groupp)checkedListBoxGroup.SelectedItem!
); Groupp groupp = Groupp.None;
foreach (var elem in checkedListBoxGroup.CheckedItems)
{
groupp |= (Groupp)elem;
}
return Student.CreateEntity(id, textBoxName.Text, textBoxFlow.Text, groupp);
}
} }

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Academic_Performance.Repositories namespace Academic_Performance.Repositories
{ {
public interface IOrderRepository public interface IOrderRepository
{ IEnumerable<Order> ReadOrder(); { IEnumerable<Order> ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null);
Order GetOrderById(int id); Order GetOrderById(int id);
void AddOrder(Order order); void AddOrder(Order order);
void UpdateOrder(Order order); void UpdateOrder(Order order);

View File

@ -9,7 +9,7 @@ namespace Academic_Performance.Repositories
{ {
public interface IStatementRepository public interface IStatementRepository
{ {
IEnumerable<Statement> ReadStatement(); IEnumerable<Statement> ReadStatement(DateTime? dateForm = null, DateTime? dateTo = null);
void CreateStatement(Statement statement); void CreateStatement(Statement statement);
void DeleteStatement(int id); void DeleteStatement(int id);
} }

View File

@ -28,7 +28,7 @@ namespace Academic_Performance.Repositories.Implementations
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"INSERT INTO Orderr(TypeS,Date,StudentId,Information) var queryInsert = @"INSERT INTO Orderrr(TypeS,Date,StudentId,Information)
VALUES (@TypeS,@Date,@StudentId,@Information)"; VALUES (@TypeS,@Date,@StudentId,@Information)";
connection.Execute(queryInsert, order); connection.Execute(queryInsert, order);
} }
@ -46,7 +46,7 @@ namespace Academic_Performance.Repositories.Implementations
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"DELETE FROM Orderr WHERE Id=@id"; var queryDelete = @"DELETE FROM Orderrr WHERE Id=@id";
connection.Execute(queryDelete, new { id }); connection.Execute(queryDelete, new { id });
} }
catch (Exception ex) catch (Exception ex)
@ -66,7 +66,7 @@ namespace Academic_Performance.Repositories.Implementations
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT * FROM Orderr WHERE Id=@id"; var querySelect = @"SELECT * FROM Orderrr WHERE Id=@id";
var order = connection.QueryFirst<Order>(querySelect, new var order = connection.QueryFirst<Order>(querySelect, new
{ {
id id
@ -90,7 +90,7 @@ namespace Academic_Performance.Repositories.Implementations
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"UPDATE Orderr SET var queryUpdate = @"UPDATE Orderrr SET
Information=@Information, Information=@Information,
TypeS=@TypeS, TypeS=@TypeS,
Date=@Date, Date=@Date,
@ -104,13 +104,13 @@ namespace Academic_Performance.Repositories.Implementations
throw; throw;
} }
} }
IEnumerable<Order> IOrderRepository.ReadOrder() IEnumerable<Order> IOrderRepository.ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null)
{ {
_logger.LogInformation("Получение всех объектов"); _logger.LogInformation("Получение всех объектов");
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Orderr"; var querySelect = "SELECT * FROM Orderrr";
var order = connection.Query<Order>(querySelect); var order = connection.Query<Order>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", _logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(order)); JsonConvert.SerializeObject(order));

View File

@ -30,9 +30,9 @@ namespace Academic_Performance.Repositories.Implementations
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open(); connection.Open();
using var transaction = connection.BeginTransaction(); using var transaction = connection.BeginTransaction();
var queryInsert = @"INSERT INTO Statemant (TeacherId,SubjectId) var queryInsert = @"INSERT INTO Statement11 (TeacherId,SubjectId,Date)
VALUES (@TeacherId, @SubjectId); VALUES (@TeacherId, @SubjectId,@Date);
SELECT MAX(Id) FROM Statemant"; SELECT MAX(Id) FROM Statement11";
var statementId = connection.QueryFirst<int>(queryInsert, statement, transaction); var statementId = connection.QueryFirst<int>(queryInsert, statement, transaction);
var querySubInsert = @"INSERT INTO Markkk(Value,StudentId) var querySubInsert = @"INSERT INTO Markkk(Value,StudentId)
VALUES (@Value,@StudentId)"; VALUES (@Value,@StudentId)";
@ -62,7 +62,7 @@ namespace Academic_Performance.Repositories.Implementations
{ {
using var connection = new using var connection = new
NpgsqlConnection(_connectionString.ConnectionString); NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"DELETE FROM Statemant var queryDelete = @"DELETE FROM Statement11
WHERE Id=@id"; WHERE Id=@id";
connection.Execute(queryDelete, new { id }); connection.Execute(queryDelete, new { id });
} }
@ -79,7 +79,7 @@ namespace Academic_Performance.Repositories.Implementations
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT * FROM Statemant"; var querySelect = @"SELECT * FROM Statement11";
var statements = connection.Query<Statement>(querySelect); var statements = connection.Query<Statement>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", _logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(statements)); JsonConvert.SerializeObject(statements));
@ -92,13 +92,13 @@ namespace Academic_Performance.Repositories.Implementations
} }
} }
public IEnumerable<Statement> ReadStatement() public IEnumerable<Statement> ReadStatement(DateTime? dateForm = null, DateTime? dateTo = null)
{ {
_logger.LogInformation("Получение всех объектов"); _logger.LogInformation("Получение всех объектов");
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Statemant"; var querySelect = "SELECT * FROM Statement11";
var statements = connection.Query<Statement>(querySelect); var statements = connection.Query<Statement>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", _logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(statements)); JsonConvert.SerializeObject(statements));