From 77fa33ef789589738746beb99d97acd4b65a28aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AC=20=D0=AA?= Date: Thu, 30 Jan 2025 02:43:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Statement.cs | 5 +- .../Forms/FormOrder.Designer.cs | 47 +++++-------------- .../Academic_Performance/Forms/FormOrder.cs | 10 ++++ .../Academic_Performance/Forms/FormStudent.cs | 23 ++++++--- .../Repositories/IOrderRepository.cs | 2 +- .../Repositories/IStatementRepository.cs | 2 +- .../Implementations/OrderRepository.cs | 12 ++--- .../Implementations/StatementRepository.cs | 14 +++--- 8 files changed, 56 insertions(+), 59 deletions(-) diff --git a/Academic_Performance/Academic_Performance/Entities/Statement.cs b/Academic_Performance/Academic_Performance/Entities/Statement.cs index 087d328..55a81c7 100644 --- a/Academic_Performance/Academic_Performance/Entities/Statement.cs +++ b/Academic_Performance/Academic_Performance/Entities/Statement.cs @@ -12,7 +12,8 @@ namespace Academic_Performance.Entities { public int Id { get; private set; } public int SubjectId { get; private set; } public int TeacherId{ get; private set; } - + + public DateTime Date { get; private set; } public IEnumerable Mark{ get; private set; } = []; public static Statement CreateOperation(int id, int subjectId, int teacherId, IEnumerable mark) {return new Statement @@ -20,7 +21,7 @@ namespace Academic_Performance.Entities Id = id, SubjectId = subjectId, TeacherId = teacherId, - + Date = DateTime.Now, Mark = mark }; } diff --git a/Academic_Performance/Academic_Performance/Forms/FormOrder.Designer.cs b/Academic_Performance/Academic_Performance/Forms/FormOrder.Designer.cs index f1e0eda..080356d 100644 --- a/Academic_Performance/Academic_Performance/Forms/FormOrder.Designer.cs +++ b/Academic_Performance/Academic_Performance/Forms/FormOrder.Designer.cs @@ -30,10 +30,8 @@ { buttonSave = new Button(); buttonEx = new Button(); - label1 = new Label(); label2 = new Label(); label3 = new Label(); - dateTimePicker1 = new DateTimePicker(); comboBoxType = new ComboBox(); textBoxInf = new TextBox(); comboBoxIdStudent = new ComboBox(); @@ -42,10 +40,10 @@ // // buttonSave // - buttonSave.Location = new Point(64, 310); + buttonSave.Location = new Point(130, 259); buttonSave.Margin = new Padding(2); buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(90, 27); + buttonSave.Size = new Size(127, 27); buttonSave.TabIndex = 1; buttonSave.Text = "Сохранить"; buttonSave.UseVisualStyleBackColor = true; @@ -53,57 +51,40 @@ // // buttonEx // - buttonEx.Location = new Point(458, 323); + buttonEx.Location = new Point(367, 259); buttonEx.Margin = new Padding(2); buttonEx.Name = "buttonEx"; - buttonEx.Size = new Size(90, 27); + buttonEx.Size = new Size(115, 27); buttonEx.TabIndex = 2; buttonEx.Text = "Отмена"; buttonEx.UseVisualStyleBackColor = true; 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.AutoSize = true; - label2.Location = new Point(56, 83); + label2.Location = new Point(83, 19); label2.Margin = new Padding(2, 0, 2, 0); label2.Name = "label2"; label2.Size = new Size(35, 20); label2.TabIndex = 4; label2.Text = "Тип"; + label2.Click += label2_Click; // // label3 // label3.AutoSize = true; - label3.Location = new Point(22, 150); + label3.Location = new Point(35, 94); label3.Margin = new Padding(2, 0, 2, 0); label3.Name = "label3"; label3.Size = new Size(102, 20); label3.TabIndex = 5; 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.FormattingEnabled = true; - comboBoxType.Location = new Point(147, 83); + comboBoxType.Location = new Point(157, 11); comboBoxType.Margin = new Padding(2); comboBoxType.Name = "comboBoxType"; comboBoxType.Size = new Size(414, 28); @@ -111,7 +92,7 @@ // // textBoxInf // - textBoxInf.Location = new Point(140, 154); + textBoxInf.Location = new Point(157, 87); textBoxInf.Margin = new Padding(2); textBoxInf.Name = "textBoxInf"; textBoxInf.Size = new Size(421, 27); @@ -120,7 +101,7 @@ // comboBoxIdStudent // comboBoxIdStudent.FormattingEnabled = true; - comboBoxIdStudent.Location = new Point(140, 214); + comboBoxIdStudent.Location = new Point(157, 164); comboBoxIdStudent.Margin = new Padding(2); comboBoxIdStudent.Name = "comboBoxIdStudent"; comboBoxIdStudent.Size = new Size(421, 28); @@ -129,7 +110,7 @@ // label4 // label4.AutoSize = true; - label4.Location = new Point(11, 217); + label4.Location = new Point(35, 172); label4.Margin = new Padding(2, 0, 2, 0); label4.Name = "label4"; label4.Size = new Size(107, 20); @@ -140,15 +121,13 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(640, 360); + ClientSize = new Size(640, 308); Controls.Add(label4); Controls.Add(comboBoxIdStudent); Controls.Add(textBoxInf); Controls.Add(comboBoxType); - Controls.Add(dateTimePicker1); Controls.Add(label3); Controls.Add(label2); - Controls.Add(label1); Controls.Add(buttonEx); Controls.Add(buttonSave); Margin = new Padding(2); @@ -164,10 +143,8 @@ private Button buttonSave; private Button buttonEx; - private Label label1; private Label label2; private Label label3; - private DateTimePicker dateTimePicker1; private ComboBox comboBoxType; private TextBox textBoxInf; private ComboBox comboBoxIdStudent; diff --git a/Academic_Performance/Academic_Performance/Forms/FormOrder.cs b/Academic_Performance/Academic_Performance/Forms/FormOrder.cs index 5a0ea62..20291ea 100644 --- a/Academic_Performance/Academic_Performance/Forms/FormOrder.cs +++ b/Academic_Performance/Academic_Performance/Forms/FormOrder.cs @@ -93,5 +93,15 @@ namespace Academic_Performance.Forms { } + + private void dateTimePicker1_ValueChanged(object sender, EventArgs e) + { + + } + + private void label2_Click(object sender, EventArgs e) + { + + } } } diff --git a/Academic_Performance/Academic_Performance/Forms/FormStudent.cs b/Academic_Performance/Academic_Performance/Forms/FormStudent.cs index 285f6f5..e63855b 100644 --- a/Academic_Performance/Academic_Performance/Forms/FormStudent.cs +++ b/Academic_Performance/Academic_Performance/Forms/FormStudent.cs @@ -39,7 +39,7 @@ namespace Academic_Performance.Forms } textBoxName.Text = student.Name; textBoxFlow.Text = student.Flow; - checkedListBoxGroup.SelectedItem =student.Groupp; + _studentId = value; } catch (Exception ex) @@ -55,7 +55,7 @@ namespace Academic_Performance.Forms InitializeComponent(); _studentRepository = studentRepository ?? throw new ArgumentNullException(nameof(studentRepository)); - + foreach (var elem in Enum.GetValues(typeof(Groupp))) { checkedListBoxGroup.Items.Add(elem); @@ -66,7 +66,7 @@ namespace Academic_Performance.Forms { try { - if (string.IsNullOrWhiteSpace(textBoxName.Text)|| string.IsNullOrWhiteSpace(textBoxFlow.Text)) + if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxFlow.Text)) { throw new Exception("Имеются незаполненные поля"); } @@ -88,10 +88,19 @@ namespace Academic_Performance.Forms } } - private Student CreateStudent(int id) => Student.CreateEntity( - id, - textBoxName.Text, textBoxFlow.Text, (Groupp)checkedListBoxGroup.SelectedItem! - ); + private Student CreateStudent(int id) + { + + Groupp groupp = Groupp.None; + foreach (var elem in checkedListBoxGroup.CheckedItems) + { + groupp |= (Groupp)elem; + } + + + + return Student.CreateEntity(id, textBoxName.Text, textBoxFlow.Text, groupp); + } } diff --git a/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs b/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs index 657be6e..05432bc 100644 --- a/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs +++ b/Academic_Performance/Academic_Performance/Repositories/IOrderRepository.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Academic_Performance.Repositories { public interface IOrderRepository - { IEnumerable ReadOrder(); + { IEnumerable ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null); Order GetOrderById(int id); void AddOrder(Order order); void UpdateOrder(Order order); diff --git a/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs b/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs index 68d76a6..834e5b3 100644 --- a/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs +++ b/Academic_Performance/Academic_Performance/Repositories/IStatementRepository.cs @@ -9,7 +9,7 @@ namespace Academic_Performance.Repositories { public interface IStatementRepository { - IEnumerable ReadStatement(); + IEnumerable ReadStatement(DateTime? dateForm = null, DateTime? dateTo = null); void CreateStatement(Statement statement); void DeleteStatement(int id); } diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs index 230ebea..7d09d2e 100644 --- a/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/OrderRepository.cs @@ -28,7 +28,7 @@ namespace Academic_Performance.Repositories.Implementations try { 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)"; connection.Execute(queryInsert, order); } @@ -46,7 +46,7 @@ namespace Academic_Performance.Repositories.Implementations try { 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 }); } catch (Exception ex) @@ -66,7 +66,7 @@ namespace Academic_Performance.Repositories.Implementations try { 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(querySelect, new { id @@ -90,7 +90,7 @@ namespace Academic_Performance.Repositories.Implementations try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var queryUpdate = @"UPDATE Orderr SET + var queryUpdate = @"UPDATE Orderrr SET Information=@Information, TypeS=@TypeS, Date=@Date, @@ -104,13 +104,13 @@ namespace Academic_Performance.Repositories.Implementations throw; } } - IEnumerable IOrderRepository.ReadOrder() + IEnumerable IOrderRepository.ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null) { _logger.LogInformation("Получение всех объектов"); try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT * FROM Orderr"; + var querySelect = "SELECT * FROM Orderrr"; var order = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(order)); diff --git a/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs b/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs index eb7b25e..5a9a9cd 100644 --- a/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs +++ b/Academic_Performance/Academic_Performance/Repositories/Implementations/StatementRepository.cs @@ -30,9 +30,9 @@ namespace Academic_Performance.Repositories.Implementations using var connection = new NpgsqlConnection(_connectionString.ConnectionString); connection.Open(); using var transaction = connection.BeginTransaction(); - var queryInsert = @"INSERT INTO Statemant (TeacherId,SubjectId) - VALUES (@TeacherId, @SubjectId); - SELECT MAX(Id) FROM Statemant"; + var queryInsert = @"INSERT INTO Statement11 (TeacherId,SubjectId,Date) + VALUES (@TeacherId, @SubjectId,@Date); + SELECT MAX(Id) FROM Statement11"; var statementId = connection.QueryFirst(queryInsert, statement, transaction); var querySubInsert = @"INSERT INTO Markkk(Value,StudentId) VALUES (@Value,@StudentId)"; @@ -62,7 +62,7 @@ namespace Academic_Performance.Repositories.Implementations { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var queryDelete = @"DELETE FROM Statemant + var queryDelete = @"DELETE FROM Statement11 WHERE Id=@id"; connection.Execute(queryDelete, new { id }); } @@ -79,7 +79,7 @@ namespace Academic_Performance.Repositories.Implementations try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT * FROM Statemant"; + var querySelect = @"SELECT * FROM Statement11"; var statements = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(statements)); @@ -92,13 +92,13 @@ namespace Academic_Performance.Repositories.Implementations } } - public IEnumerable ReadStatement() + public IEnumerable ReadStatement(DateTime? dateForm = null, DateTime? dateTo = null) { _logger.LogInformation("Получение всех объектов"); try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT * FROM Statemant"; + var querySelect = "SELECT * FROM Statement11"; var statements = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(statements));