Compare commits
No commits in common. "aa5c773d5a7bab4d8c255622c4e457ccc47d6876" and "d5889f7b3e3c1d7961a003167e9f85342ee78280" have entirely different histories.
aa5c773d5a
...
d5889f7b3e
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StudentProgressRecord.Entity.Enums
|
||||
{
|
||||
[Flags]
|
||||
public enum Direction
|
||||
{
|
||||
None = 0,
|
||||
PI = 1 << 0,
|
||||
Ivt = 1 << 1,
|
||||
Is = 1 << 2,
|
||||
Ist = 1 << 3
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using StudentProgressRecord.Entity.Enums;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -13,15 +12,12 @@ namespace StudentProgressRecord.Entity
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public Direction direction { get; set; }
|
||||
|
||||
public static Subject CreateEntity(long id, string name, Direction direction)
|
||||
public static Subject CreateEntity(long id, string name)
|
||||
{
|
||||
return new Subject
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
direction = direction
|
||||
Name = name
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,6 @@
|
||||
textBoxSubject = new TextBox();
|
||||
buttonAply = new Button();
|
||||
buttonCancel = new Button();
|
||||
checkedListBoxDir = new CheckedListBox();
|
||||
label1 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelSubject
|
||||
@ -54,7 +52,7 @@
|
||||
//
|
||||
// buttonAply
|
||||
//
|
||||
buttonAply.Location = new Point(12, 259);
|
||||
buttonAply.Location = new Point(13, 39);
|
||||
buttonAply.Name = "buttonAply";
|
||||
buttonAply.Size = new Size(117, 29);
|
||||
buttonAply.TabIndex = 2;
|
||||
@ -64,7 +62,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(135, 259);
|
||||
buttonCancel.Location = new Point(136, 39);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(112, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
@ -72,30 +70,11 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// checkedListBoxDir
|
||||
//
|
||||
checkedListBoxDir.FormattingEnabled = true;
|
||||
checkedListBoxDir.Location = new Point(91, 39);
|
||||
checkedListBoxDir.Name = "checkedListBoxDir";
|
||||
checkedListBoxDir.Size = new Size(228, 158);
|
||||
checkedListBoxDir.TabIndex = 4;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 39);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(73, 20);
|
||||
label1.TabIndex = 5;
|
||||
label1.Text = "Предмет:";
|
||||
//
|
||||
// FormSubject
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(412, 316);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(checkedListBoxDir);
|
||||
ClientSize = new Size(261, 77);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAply);
|
||||
Controls.Add(textBoxSubject);
|
||||
@ -113,7 +92,5 @@
|
||||
private TextBox textBoxSubject;
|
||||
private Button buttonAply;
|
||||
private Button buttonCancel;
|
||||
private CheckedListBox checkedListBoxDir;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using StudentProgressRecord.Entity;
|
||||
using StudentProgressRecord.Entity.Enums;
|
||||
using StudentProgressRecord.Entity;
|
||||
using StudentProgressRecord.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -33,13 +31,6 @@ namespace StudentProgressRecord
|
||||
}
|
||||
textBoxSubject.Text = subject.Name;
|
||||
_subjectId = value;
|
||||
foreach (Direction elem in Enum.GetValues(typeof(Direction)))
|
||||
{
|
||||
if ((elem & subject.direction) != 0)
|
||||
{
|
||||
checkedListBoxDir.SetItemChecked(checkedListBoxDir.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -52,10 +43,6 @@ namespace StudentProgressRecord
|
||||
{
|
||||
InitializeComponent();
|
||||
_subjectRepository = subjectRepository ?? throw new ArgumentNullException(nameof(subjectRepository));
|
||||
foreach (var elem in Enum.GetValues(typeof(Direction)))
|
||||
{
|
||||
checkedListBoxDir.Items.Add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAply_Click(object sender, EventArgs e)
|
||||
@ -63,7 +50,7 @@ namespace StudentProgressRecord
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxSubject.Text) ||
|
||||
checkedListBoxDir.CheckedItems.Count == 0)
|
||||
string.IsNullOrWhiteSpace(textBoxSubject.Text))
|
||||
{
|
||||
throw new Exception("Имя не может быть пустым");
|
||||
}
|
||||
@ -90,14 +77,7 @@ namespace StudentProgressRecord
|
||||
{
|
||||
Close();
|
||||
}
|
||||
private Subject CreateSubject(long id)
|
||||
{
|
||||
Direction direction = Direction.None;
|
||||
foreach (var elem in checkedListBoxDir.CheckedItems)
|
||||
{
|
||||
direction |= (Direction)elem;
|
||||
}
|
||||
return Subject.CreateEntity(id, textBoxSubject.Text, direction);
|
||||
}
|
||||
private Subject CreateSubject(long id) => Subject.CreateEntity(id, textBoxSubject.Text);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@
|
||||
StudentToolStripMenuItem = new ToolStripMenuItem();
|
||||
TeacherToolStripMenuItem = new ToolStripMenuItem();
|
||||
SubjectToolStripMenuItem = new ToolStripMenuItem();
|
||||
StatementToolStripMenuItem = new ToolStripMenuItem();
|
||||
OperationToolStripMenuItem = new ToolStripMenuItem();
|
||||
TransientToolStripMenuItem = new ToolStripMenuItem();
|
||||
StatementToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -53,7 +53,7 @@
|
||||
//
|
||||
// HandbookToolStripMenuItem
|
||||
//
|
||||
HandbookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { StudentToolStripMenuItem, TeacherToolStripMenuItem, SubjectToolStripMenuItem });
|
||||
HandbookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { StudentToolStripMenuItem, TeacherToolStripMenuItem, SubjectToolStripMenuItem, StatementToolStripMenuItem });
|
||||
HandbookToolStripMenuItem.Name = "HandbookToolStripMenuItem";
|
||||
HandbookToolStripMenuItem.Size = new Size(117, 24);
|
||||
HandbookToolStripMenuItem.Text = "Справочники";
|
||||
@ -79,9 +79,16 @@
|
||||
SubjectToolStripMenuItem.Text = "Предметы";
|
||||
SubjectToolStripMenuItem.Click += SubjectToolStripMenuItem_Click;
|
||||
//
|
||||
// StatementToolStripMenuItem
|
||||
//
|
||||
StatementToolStripMenuItem.Name = "StatementToolStripMenuItem";
|
||||
StatementToolStripMenuItem.Size = new Size(201, 26);
|
||||
StatementToolStripMenuItem.Text = "Ведомость";
|
||||
StatementToolStripMenuItem.Click += StatementToolStripMenuItem_Click;
|
||||
//
|
||||
// OperationToolStripMenuItem
|
||||
//
|
||||
OperationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { TransientToolStripMenuItem, StatementToolStripMenuItem });
|
||||
OperationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { TransientToolStripMenuItem });
|
||||
OperationToolStripMenuItem.Name = "OperationToolStripMenuItem";
|
||||
OperationToolStripMenuItem.Size = new Size(95, 24);
|
||||
OperationToolStripMenuItem.Text = "Операции";
|
||||
@ -91,14 +98,7 @@
|
||||
TransientToolStripMenuItem.Name = "TransientToolStripMenuItem";
|
||||
TransientToolStripMenuItem.Size = new Size(224, 26);
|
||||
TransientToolStripMenuItem.Text = "Перемещения";
|
||||
TransientToolStripMenuItem.Click += TransientToolStripMenuItem_Click_1;
|
||||
//
|
||||
// StatementToolStripMenuItem
|
||||
//
|
||||
StatementToolStripMenuItem.Name = "StatementToolStripMenuItem";
|
||||
StatementToolStripMenuItem.Size = new Size(224, 26);
|
||||
StatementToolStripMenuItem.Text = "Ведомость";
|
||||
StatementToolStripMenuItem.Click += StatementToolStripMenuItem_Click;
|
||||
TransientToolStripMenuItem.Click += this.TransientToolStripMenuItem_Click_1;
|
||||
//
|
||||
// ReportToolStripMenuItem
|
||||
//
|
||||
@ -131,7 +131,7 @@
|
||||
private ToolStripMenuItem StudentToolStripMenuItem;
|
||||
private ToolStripMenuItem TeacherToolStripMenuItem;
|
||||
private ToolStripMenuItem SubjectToolStripMenuItem;
|
||||
private ToolStripMenuItem TransientToolStripMenuItem;
|
||||
private ToolStripMenuItem StatementToolStripMenuItem;
|
||||
private ToolStripMenuItem TransientToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -86,7 +86,5 @@ namespace StudentProgressRecord
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,13 @@ using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using StudentProgressRecord.Entity;
|
||||
using StudentProgressRecord.Entity.Enums;
|
||||
using StudentProgressRecord.IRepositories;
|
||||
using StudentProgressRecord.Repositories;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StudentProgressRecord.RepositoryImp
|
||||
{
|
||||
@ -29,8 +32,8 @@ namespace StudentProgressRecord.RepositoryImp
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.GetConnectionString());
|
||||
var query = @"
|
||||
INSERT INTO Subject (direction, Name)
|
||||
VALUES (@direction ,@Name)";
|
||||
INSERT INTO Subject (Name)
|
||||
VALUES (@Name)";
|
||||
connection.Execute(query, subject);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -61,7 +64,24 @@ namespace StudentProgressRecord.RepositoryImp
|
||||
|
||||
public Subject ReadSubjectById(long id)
|
||||
{
|
||||
return Subject.CreateEntity(0, string.Empty, Direction.None);
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.GetConnectionString());
|
||||
var querySelect = @"
|
||||
SELECT * FROM Subject
|
||||
WHERE Id=@id";
|
||||
var obj = connection.QueryFirst<Subject>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(obj));
|
||||
return obj;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Subject> ReadSubjects()
|
||||
|
Loading…
Reference in New Issue
Block a user