готова 1 лаба

This commit is contained in:
Aleksandr4350 2024-11-20 19:31:06 +04:00
parent 09705a3190
commit 7cb433c586
45 changed files with 1338 additions and 743 deletions

View File

@ -8,7 +8,6 @@
public string Author { get; private set; } = string.Empty; public string Author { get; private set; } = string.Empty;
public string Name { get; private set; } = string.Empty; public string Name { get; private set; } = string.Empty;
public BookType Type { get; private set; } = BookType.None; public BookType Type { get; private set; } = BookType.None;
public int LibraryID { get; private set; } public int LibraryID { get; private set; }
public static Book CreateEntity(int id, string author, string name, BookType type, int libraryID) public static Book CreateEntity(int id, string author, string name, BookType type, int libraryID)

View File

@ -1,10 +1,4 @@
using System; namespace ProjectLibrary.Entites
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLibrary.Entites
{ {
public class Book_Library public class Book_Library
{ {
@ -12,9 +6,7 @@ namespace ProjectLibrary.Entites
public int LibraryID { get; private set; } public int LibraryID { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public static Book_Library CreateEntity(int libraryID, int bookID, int count)
public static Book_Library CreateEntity(int bookID, int libraryID, int count)
{ {
return new Book_Library return new Book_Library
{ {

View File

@ -1,15 +1,8 @@
using System; namespace ProjectLibrary.Entites
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLibrary.Entites
{ {
public class TicketExtensions public class TicketExtensions
{ {
public int ReaderID { get; private set; } public int ReaderID { get; private set; }
public int ExtensionID { get; private set; }
public DateTime LastUpdateDate { get; private set; } public DateTime LastUpdateDate { get; private set; }
public DateTime NextUpdateDate { get; private set; } public DateTime NextUpdateDate { get; private set; }

View File

@ -35,8 +35,8 @@
библиотекиToolStripMenuItem = new ToolStripMenuItem(); библиотекиToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem(); операцииToolStripMenuItem = new ToolStripMenuItem();
обновлениеБилетаToolStripMenuItem = new ToolStripMenuItem(); обновлениеБилетаToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
заказатьКнигиToolStripMenuItem = new ToolStripMenuItem(); заказатьКнигиToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout(); menuStrip1.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@ -47,7 +47,8 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0); menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1"; menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(832, 28); menuStrip1.Padding = new Padding(5, 2, 0, 2);
menuStrip1.Size = new Size(728, 24);
menuStrip1.TabIndex = 0; menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip"; menuStrip1.Text = "menuStrip";
// //
@ -55,63 +56,67 @@
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { книгаToolStripMenuItem, читателиToolStripMenuItem, библиотекиToolStripMenuItem }); справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { книгаToolStripMenuItem, читателиToolStripMenuItem, библиотекиToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники"; справочникиToolStripMenuItem.Text = "Справочники";
// //
// книгаToolStripMenuItem // книгаToolStripMenuItem
// //
книгаToolStripMenuItem.Name = "книгаToolStripMenuItem"; книгаToolStripMenuItem.Name = "книгаToolStripMenuItem";
книгаToolStripMenuItem.Size = new Size(175, 26); книгаToolStripMenuItem.Size = new Size(180, 22);
книгаToolStripMenuItem.Text = "Книга"; книгаToolStripMenuItem.Text = "Книга";
книгаToolStripMenuItem.Click += книгаToolStripMenuItem_Click;
// //
// читателиToolStripMenuItem // читателиToolStripMenuItem
// //
читателиToolStripMenuItem.Name = "читателиToolStripMenuItem"; читателиToolStripMenuItem.Name = "читателиToolStripMenuItem";
читателиToolStripMenuItem.Size = new Size(175, 26); читателиToolStripMenuItem.Size = new Size(180, 22);
читателиToolStripMenuItem.Text = "Читатели"; читателиToolStripMenuItem.Text = "Читатели";
читателиToolStripMenuItem.Click += читателиToolStripMenuItem_Click; читателиToolStripMenuItem.Click += читателиToolStripMenuItem_Click;
// //
// библиотекиToolStripMenuItem // библиотекиToolStripMenuItem
// //
библиотекиToolStripMenuItem.Name = "библиотекиToolStripMenuItem"; библиотекиToolStripMenuItem.Name = "библиотекиToolStripMenuItem";
библиотекиToolStripMenuItem.Size = new Size(175, 26); библиотекиToolStripMenuItem.Size = new Size(180, 22);
библиотекиToolStripMenuItem.Text = "Библиотеки"; библиотекиToolStripMenuItem.Text = "Библиотеки";
библиотекиToolStripMenuItem.Click += библиотекиToolStripMenuItem_Click;
// //
// операцииToolStripMenuItem // операцииToolStripMenuItem
// //
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { обновлениеБилетаToolStripMenuItem, заказатьКнигиToolStripMenuItem }); операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { обновлениеБилетаToolStripMenuItem, заказатьКнигиToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24); операцииToolStripMenuItem.Size = new Size(75, 20);
операцииToolStripMenuItem.Text = "Операции"; операцииToolStripMenuItem.Text = "Операции";
// //
// обновлениеБилетаToolStripMenuItem // обновлениеБилетаToolStripMenuItem
// //
обновлениеБилетаToolStripMenuItem.Name = "обновлениеБилетаToolStripMenuItem"; обновлениеБилетаToolStripMenuItem.Name = "обновлениеБилетаToolStripMenuItem";
обновлениеБилетаToolStripMenuItem.Size = new Size(232, 26); обновлениеБилетаToolStripMenuItem.Size = new Size(184, 22);
обновлениеБилетаToolStripMenuItem.Text = "Обновление билета"; обновлениеБилетаToolStripMenuItem.Text = "Обновление билета";
// обновлениеБилетаToolStripMenuItem.Click += обновлениеБилетаToolStripMenuItem_Click;
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
// //
// заказатьКнигиToolStripMenuItem // заказатьКнигиToolStripMenuItem
// //
заказатьКнигиToolStripMenuItem.Name = аказатьКнигиToolStripMenuItem"; заказатьКнигиToolStripMenuItem.Name = аказатьКнигиToolStripMenuItem";
заказатьКнигиToolStripMenuItem.Size = new Size(232, 26); заказатьКнигиToolStripMenuItem.Size = new Size(184, 22);
заказатьКнигиToolStripMenuItem.Text = "Заказать книги"; заказатьКнигиToolStripMenuItem.Text = "Заказать книги";
заказатьКнигиToolStripMenuItem.Click += заказатьКнигиToolStripMenuItem_Click; заказатьКнигиToolStripMenuItem.Click += заказатьКнигиToolStripMenuItem_Click;
// //
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormLibrary // FormLibrary
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ButtonHighlight; BackColor = SystemColors.ButtonHighlight;
BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_19_132940; BackgroundImage = Properties.Resources.Снимок_экрана_2024_11_19_132940;
ClientSize = new Size(832, 453); ClientSize = new Size(728, 340);
Controls.Add(menuStrip1); Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1; MainMenuStrip = menuStrip1;
Margin = new Padding(3, 2, 3, 2);
Name = "FormLibrary"; Name = "FormLibrary";
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
Text = "Библиотека"; Text = "Библиотека";

View File

@ -1,4 +1,3 @@
using System.ComponentModel;
using Unity; using Unity;
namespace ProjectLibrary namespace ProjectLibrary
@ -13,11 +12,6 @@ namespace ProjectLibrary
_container = container ?? throw new ArgumentNullException(nameof(container)); _container = container ?? throw new ArgumentNullException(nameof(container));
} }
private void êàðòàÑîòðóäíèêàToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void ÷èòàòåëèToolStripMenuItem_Click(object sender, EventArgs e) private void ÷èòàòåëèToolStripMenuItem_Click(object sender, EventArgs e)
{ {
try try
@ -41,5 +35,41 @@ namespace ProjectLibrary
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void êíèãàToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<Forms.FBooks>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void áèáëèîòåêèToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<Forms.FLibraries>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void îáíîâëåíèåÁèëåòàToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<Forms.FTiclet_Extensions>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View File

@ -28,8 +28,6 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
lblId = new Label();
txtId = new TextBox();
lblAuthor = new Label(); lblAuthor = new Label();
txtAuthor = new TextBox(); txtAuthor = new TextBox();
lblName = new Label(); lblName = new Label();
@ -37,66 +35,49 @@
lblType = new Label(); lblType = new Label();
cmbType = new ComboBox(); cmbType = new ComboBox();
lblLibraryId = new Label(); lblLibraryId = new Label();
txtLibraryId = new TextBox();
btnSave = new Button(); btnSave = new Button();
buttonCancel_Click = new Button(); buttonCancel_Click = new Button();
comboBoxLibrary = new ComboBox();
SuspendLayout(); SuspendLayout();
// //
// lblId
//
lblId.AutoSize = true;
lblId.Location = new Point(20, 20);
lblId.Name = "lblId";
lblId.Size = new Size(27, 20);
lblId.TabIndex = 0;
lblId.Text = "ID:";
//
// txtId
//
txtId.Location = new Point(100, 20);
txtId.Name = "txtId";
txtId.ReadOnly = true;
txtId.Size = new Size(200, 27);
txtId.TabIndex = 1;
//
// lblAuthor // lblAuthor
// //
lblAuthor.AutoSize = true; lblAuthor.AutoSize = true;
lblAuthor.Location = new Point(20, 60); lblAuthor.Location = new Point(19, 25);
lblAuthor.Name = "lblAuthor"; lblAuthor.Name = "lblAuthor";
lblAuthor.Size = new Size(54, 20); lblAuthor.Size = new Size(43, 15);
lblAuthor.TabIndex = 2; lblAuthor.TabIndex = 2;
lblAuthor.Text = "Автор:"; lblAuthor.Text = "Автор:";
// //
// txtAuthor // txtAuthor
// //
txtAuthor.Location = new Point(100, 60); txtAuthor.Location = new Point(115, 25);
txtAuthor.Name = "txtAuthor"; txtAuthor.Name = "txtAuthor";
txtAuthor.Size = new Size(200, 27); txtAuthor.Size = new Size(200, 23);
txtAuthor.TabIndex = 3; txtAuthor.TabIndex = 3;
// //
// lblName // lblName
// //
lblName.AutoSize = true; lblName.AutoSize = true;
lblName.Location = new Point(20, 100); lblName.Location = new Point(19, 65);
lblName.Name = "lblName"; lblName.Name = "lblName";
lblName.Size = new Size(80, 20); lblName.Size = new Size(62, 15);
lblName.TabIndex = 4; lblName.TabIndex = 4;
lblName.Text = "Название:"; lblName.Text = "Название:";
// //
// txtName // txtName
// //
txtName.Location = new Point(100, 100); txtName.Location = new Point(115, 65);
txtName.Name = "txtName"; txtName.Name = "txtName";
txtName.Size = new Size(200, 27); txtName.Size = new Size(200, 23);
txtName.TabIndex = 5; txtName.TabIndex = 5;
// //
// lblType // lblType
// //
lblType.AutoSize = true; lblType.AutoSize = true;
lblType.Location = new Point(20, 140); lblType.Location = new Point(19, 105);
lblType.Name = "lblType"; lblType.Name = "lblType";
lblType.Size = new Size(38, 20); lblType.Size = new Size(30, 15);
lblType.TabIndex = 6; lblType.TabIndex = 6;
lblType.Text = "Тип:"; lblType.Text = "Тип:";
// //
@ -105,51 +86,54 @@
cmbType.DropDownStyle = ComboBoxStyle.DropDownList; cmbType.DropDownStyle = ComboBoxStyle.DropDownList;
cmbType.FormattingEnabled = true; cmbType.FormattingEnabled = true;
cmbType.Items.AddRange(new object[] { "Fiction", "Non-Fiction", "Science", "Biography" }); cmbType.Items.AddRange(new object[] { "Fiction", "Non-Fiction", "Science", "Biography" });
cmbType.Location = new Point(100, 140); cmbType.Location = new Point(115, 102);
cmbType.Name = "cmbType"; cmbType.Name = "cmbType";
cmbType.Size = new Size(200, 28); cmbType.Size = new Size(200, 23);
cmbType.TabIndex = 7; cmbType.TabIndex = 7;
// //
// lblLibraryId // lblLibraryId
// //
lblLibraryId.AutoSize = true; lblLibraryId.AutoSize = true;
lblLibraryId.Location = new Point(20, 180); lblLibraryId.Location = new Point(19, 145);
lblLibraryId.Name = "lblLibraryId"; lblLibraryId.Name = "lblLibraryId";
lblLibraryId.Size = new Size(114, 20); lblLibraryId.Size = new Size(90, 15);
lblLibraryId.TabIndex = 8; lblLibraryId.TabIndex = 8;
lblLibraryId.Text = "ID библиотеки:"; lblLibraryId.Text = "ID библиотеки:";
// //
// txtLibraryId
//
txtLibraryId.Location = new Point(140, 177);
txtLibraryId.Name = "txtLibraryId";
txtLibraryId.Size = new Size(200, 27);
txtLibraryId.TabIndex = 9;
//
// btnSave // btnSave
// //
btnSave.Location = new Point(20, 220); btnSave.Location = new Point(19, 185);
btnSave.Name = "btnSave"; btnSave.Name = "btnSave";
btnSave.Size = new Size(100, 30); btnSave.Size = new Size(100, 30);
btnSave.TabIndex = 10; btnSave.TabIndex = 10;
btnSave.Text = "Сохранить"; btnSave.Text = "Сохранить";
btnSave.UseVisualStyleBackColor = true; btnSave.UseVisualStyleBackColor = true;
btnSave.Click += btnSave_Click;
// //
// buttonCancel_Click // buttonCancel_Click
// //
buttonCancel_Click.Location = new Point(240, 220); buttonCancel_Click.Location = new Point(239, 185);
buttonCancel_Click.Name = "buttonCancel_Click"; buttonCancel_Click.Name = "buttonCancel_Click";
buttonCancel_Click.Size = new Size(100, 30); buttonCancel_Click.Size = new Size(100, 30);
buttonCancel_Click.TabIndex = 11; buttonCancel_Click.TabIndex = 11;
buttonCancel_Click.Text = "Отмена"; buttonCancel_Click.Text = "Отмена";
buttonCancel_Click.Click += buttonCancel_Click_Click; buttonCancel_Click.Click += ButtonCancel_Click;
//
// comboBoxLibrary
//
comboBoxLibrary.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxLibrary.FormattingEnabled = true;
comboBoxLibrary.Items.AddRange(new object[] { "Fiction", "Non-Fiction", "Science", "Biography" });
comboBoxLibrary.Location = new Point(115, 145);
comboBoxLibrary.Name = "comboBoxLibrary";
comboBoxLibrary.Size = new Size(200, 23);
comboBoxLibrary.TabIndex = 12;
// //
// FBook // FBook
// //
ClientSize = new Size(400, 300); ClientSize = new Size(400, 300);
Controls.Add(comboBoxLibrary);
Controls.Add(buttonCancel_Click); Controls.Add(buttonCancel_Click);
Controls.Add(lblId);
Controls.Add(txtId);
Controls.Add(lblAuthor); Controls.Add(lblAuthor);
Controls.Add(txtAuthor); Controls.Add(txtAuthor);
Controls.Add(lblName); Controls.Add(lblName);
@ -157,7 +141,6 @@
Controls.Add(lblType); Controls.Add(lblType);
Controls.Add(cmbType); Controls.Add(cmbType);
Controls.Add(lblLibraryId); Controls.Add(lblLibraryId);
Controls.Add(txtLibraryId);
Controls.Add(btnSave); Controls.Add(btnSave);
Name = "FBook"; Name = "FBook";
Text = "Книга"; Text = "Книга";
@ -166,9 +149,6 @@
} }
#endregion #endregion
private System.Windows.Forms.Label lblId;
private System.Windows.Forms.TextBox txtId;
private System.Windows.Forms.Label lblAuthor; private System.Windows.Forms.Label lblAuthor;
private System.Windows.Forms.TextBox txtAuthor; private System.Windows.Forms.TextBox txtAuthor;
private System.Windows.Forms.Label lblName; private System.Windows.Forms.Label lblName;
@ -176,8 +156,8 @@
private System.Windows.Forms.Label lblType; private System.Windows.Forms.Label lblType;
private System.Windows.Forms.ComboBox cmbType; private System.Windows.Forms.ComboBox cmbType;
private System.Windows.Forms.Label lblLibraryId; private System.Windows.Forms.Label lblLibraryId;
private System.Windows.Forms.TextBox txtLibraryId;
private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnSave;
private Button buttonCancel_Click; private Button buttonCancel_Click;
private ComboBox comboBoxLibrary;
} }
} }

View File

@ -1,124 +1,84 @@
namespace ProjectLibrary.Forms using ProjectLibrary.Entities;
using ProjectLibrary.Entities.Enums;
using ProjectLibrary.Repositores;
using ProjectLibrary.Repositories;
namespace ProjectLibrary.Forms
{ {
public partial class FBook : Form public partial class FBook : Form
{ {
public FBook() private readonly IBookRepository _bookRepository;
private int? _bookId;
public int Id
{
set
{
try
{
var book = _bookRepository.ReadBookById(value);
if (book == null)
{
throw new InvalidOperationException("Книга не найдена.");
}
txtAuthor.Text = book.Author;
txtName.Text = book.Name;
cmbType.SelectedItem = book.Type;
comboBoxLibrary.SelectedItem = book.LibraryID;
_bookId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
public FBook(IBookRepository bookRepository, ILibraryRepository libraryRepository)
{ {
InitializeComponent(); InitializeComponent();
InitializeFormElements(); _bookRepository = bookRepository ?? throw new ArgumentNullException(nameof(bookRepository));
comboBoxLibrary.DataSource = libraryRepository.ReadLibraries();
} }
private void InitializeFormElements() private void btnSave_Click(object sender, EventArgs e)
{ {
// Заголовок формы try
this.Text = "Книга";
// Создание метки и текстового поля для Id
Label lblId = new Label
{ {
Text = "ID:", if (string.IsNullOrWhiteSpace(txtAuthor.Text) || string.IsNullOrWhiteSpace(txtName.Text) || comboBoxLibrary.SelectedItem == null)
Location = new System.Drawing.Point(20, 20),
AutoSize = true
};
TextBox txtId = new TextBox
{ {
Location = new System.Drawing.Point(100, 20), throw new Exception("Имеются незаполненные поля.");
Width = 200,
ReadOnly = true // ID обычно только для чтения
};
// Создание метки и текстового поля для Author
Label lblAuthor = new Label
{
Text = "Автор:",
Location = new System.Drawing.Point(20, 60),
AutoSize = true
};
TextBox txtAuthor = new TextBox
{
Location = new System.Drawing.Point(100, 60),
Width = 200
};
// Создание метки и текстового поля для Name
Label lblName = new Label
{
Text = "Название:",
Location = new System.Drawing.Point(20, 100),
AutoSize = true
};
TextBox txtName = new TextBox
{
Location = new System.Drawing.Point(100, 100),
Width = 200
};
// Создание метки и выпадающего списка для Type
Label lblType = new Label
{
Text = "Тип:",
Location = new System.Drawing.Point(20, 140),
AutoSize = true
};
ComboBox cmbType = new ComboBox
{
Location = new System.Drawing.Point(100, 140),
Width = 200,
DropDownStyle = ComboBoxStyle.DropDownList
};
cmbType.Items.AddRange(new string[] { "Fiction", "Non-Fiction", "Science", "Biography" }); // Пример данных
// Создание метки и текстового поля для LibraryID
Label lblLibraryId = new Label
{
Text = "ID библиотеки:",
Location = new System.Drawing.Point(20, 180),
AutoSize = true
};
TextBox txtLibraryId = new TextBox
{
Location = new System.Drawing.Point(100, 180),
Width = 200
};
// Кнопка "Сохранить"
Button btnSave = new Button
{
Text = "Сохранить",
Location = new System.Drawing.Point(100, 220),
Width = 100
};
btnSave.Click += (sender, e) => SaveData(txtId.Text, txtAuthor.Text, txtName.Text, cmbType.SelectedItem?.ToString(), txtLibraryId.Text);
// Добавление элементов на форму
this.Controls.Add(lblId);
this.Controls.Add(txtId);
this.Controls.Add(lblAuthor);
this.Controls.Add(txtAuthor);
this.Controls.Add(lblName);
this.Controls.Add(txtName);
this.Controls.Add(lblType);
this.Controls.Add(cmbType);
this.Controls.Add(lblLibraryId);
this.Controls.Add(txtLibraryId);
this.Controls.Add(btnSave);
} }
private void SaveData(string id, string author, string name, string type, string libraryId) var book = Book.CreateEntity(
_bookId ?? 0,
txtAuthor.Text,
txtName.Text,
(BookType)cmbType.SelectedValue,
Convert.ToInt32(comboBoxLibrary.SelectedItem)
);
if (_bookId.HasValue)
{ {
// Логика сохранения данных (например, в базу данных) _bookRepository.UpdateBook(book);
MessageBox.Show("Данные сохранены:\n" + }
$"ID: {id}\n" + else
$"Автор: {author}\n" + {
$"Название: {name}\n" + _bookRepository.CreateBook(book);
$"Тип: {type}\n" +
$"ID библиотеки: {libraryId}");
} }
private void buttonCancel_Click_Click(object sender, EventArgs e) Close();
}
catch (Exception ex)
{ {
// Закрытие формы без сохранения MessageBox.Show(ex.Message, "Ошибка при сохранении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close(); }
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
} }
} }
} }

View File

@ -1,126 +0,0 @@
namespace ProjectLibrary.Forms
{
partial class FBook_library
{
private System.ComponentModel.IContainer components = null;
private Label lblBookID;
private TextBox txtBookID;
private Label lblLibraryID;
private TextBox txtLibraryID;
private Label lblCount;
private TextBox txtCount;
private Button btnSave;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
lblBookID = new Label();
txtBookID = new TextBox();
lblLibraryID = new Label();
txtLibraryID = new TextBox();
lblCount = new Label();
txtCount = new TextBox();
btnSave = new Button();
buttonCancel_Click = new Button();
SuspendLayout();
//
// lblBookID
//
lblBookID.AutoSize = true;
lblBookID.Location = new Point(20, 20);
lblBookID.Name = "lblBookID";
lblBookID.Size = new Size(71, 20);
lblBookID.TabIndex = 0;
lblBookID.Text = "ID книги:";
//
// txtBookID
//
txtBookID.Location = new Point(140, 20);
txtBookID.Name = "txtBookID";
txtBookID.ReadOnly = true;
txtBookID.Size = new Size(200, 27);
txtBookID.TabIndex = 1;
//
// lblLibraryID
//
lblLibraryID.AutoSize = true;
lblLibraryID.Location = new Point(20, 60);
lblLibraryID.Name = "lblLibraryID";
lblLibraryID.Size = new Size(114, 20);
lblLibraryID.TabIndex = 2;
lblLibraryID.Text = "ID библиотеки:";
//
// txtLibraryID
//
txtLibraryID.Location = new Point(140, 57);
txtLibraryID.Name = "txtLibraryID";
txtLibraryID.ReadOnly = true;
txtLibraryID.Size = new Size(200, 27);
txtLibraryID.TabIndex = 3;
//
// lblCount
//
lblCount.AutoSize = true;
lblCount.Location = new Point(20, 100);
lblCount.Name = "lblCount";
lblCount.Size = new Size(93, 20);
lblCount.TabIndex = 4;
lblCount.Text = "Количество:";
//
// txtCount
//
txtCount.Location = new Point(140, 93);
txtCount.Name = "txtCount";
txtCount.Size = new Size(200, 27);
txtCount.TabIndex = 5;
//
// btnSave
//
btnSave.Location = new Point(20, 140);
btnSave.Name = "btnSave";
btnSave.Size = new Size(100, 30);
btnSave.TabIndex = 6;
btnSave.Text = "Сохранить";
btnSave.Click += btnSave_Click;
//
// buttonCancel_Click
//
buttonCancel_Click.Location = new Point(240, 140);
buttonCancel_Click.Name = "buttonCancel_Click";
buttonCancel_Click.Size = new Size(100, 30);
buttonCancel_Click.TabIndex = 10;
buttonCancel_Click.Text = "Отмена";
buttonCancel_Click.Click += buttonCancel_Click_Click;
//
// FBook_library
//
ClientSize = new Size(400, 200);
Controls.Add(buttonCancel_Click);
Controls.Add(lblBookID);
Controls.Add(txtBookID);
Controls.Add(lblLibraryID);
Controls.Add(txtLibraryID);
Controls.Add(lblCount);
Controls.Add(txtCount);
Controls.Add(btnSave);
Name = "FBook_library";
Text = "Книга в библиотеке";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel_Click;
}
}

View File

@ -1,44 +0,0 @@
using ProjectLibrary.Entites;
namespace ProjectLibrary.Forms
{
public partial class FBook_library : Form
{
private Book_Library _bookLibrary;
public FBook_library(Book_Library bookLibrary)
{
InitializeComponent();
_bookLibrary = bookLibrary;
LoadLibraryData();
}
private void LoadLibraryData()
{
txtBookID.Text = _bookLibrary.BookID.ToString();
txtLibraryID.Text = _bookLibrary.LibraryID.ToString();
txtCount.Text = _bookLibrary.Count.ToString();
}
private void btnSave_Click(object sender, EventArgs e)
{
// Создание новой сущности с измененными данными
var updatedBookLibrary = Book_Library.CreateEntity(
int.Parse(txtBookID.Text),
int.Parse(txtLibraryID.Text),
int.Parse(txtCount.Text)
);
// Обновление внутренней переменной
_bookLibrary = updatedBookLibrary;
MessageBox.Show("Данные успешно сохранены!");
}
private void buttonCancel_Click_Click(object sender, EventArgs e)
{
// Закрытие формы без сохранения
this.Close();
}
}
}

106
ProjectLibrary/Forms/FBooks.Designer.cs generated Normal file
View File

@ -0,0 +1,106 @@
namespace ProjectLibrary.Forms
{
partial class FBooks
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridViewBooks = new DataGridView();
buttonAdd = new Button();
buttonUpdate = new Button();
buttonRemove = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewBooks).BeginInit();
SuspendLayout();
//
// dataGridViewBooks
//
dataGridViewBooks.AllowUserToAddRows = false;
dataGridViewBooks.AllowUserToDeleteRows = false;
dataGridViewBooks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewBooks.Location = new Point(10, 9);
dataGridViewBooks.Margin = new Padding(3, 2, 3, 2);
dataGridViewBooks.Name = "dataGridViewBooks";
dataGridViewBooks.ReadOnly = true;
dataGridViewBooks.RowHeadersWidth = 51;
dataGridViewBooks.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewBooks.Size = new Size(602, 254);
dataGridViewBooks.TabIndex = 8;
//
// buttonAdd
//
buttonAdd.Location = new Point(27, 267);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(161, 37);
buttonAdd.TabIndex = 9;
buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(247, 267);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(161, 37);
buttonUpdate.TabIndex = 10;
buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonRemove
//
buttonRemove.Location = new Point(452, 267);
buttonRemove.Margin = new Padding(3, 2, 3, 2);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(161, 37);
buttonRemove.TabIndex = 11;
buttonRemove.Text = "Удалить";
buttonRemove.Click += buttonRemove_Click;
//
// FBooks
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(700, 338);
Controls.Add(dataGridViewBooks);
Controls.Add(buttonAdd);
Controls.Add(buttonUpdate);
Controls.Add(buttonRemove);
Margin = new Padding(3, 2, 3, 2);
Name = "FBooks";
Text = "FBooks";
Load += FBooks_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewBooks).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewBooks;
private Button buttonAdd;
private Button buttonUpdate;
private Button buttonRemove;
}
}

View File

@ -0,0 +1,104 @@
using ProjectLibrary.Repositores;
using Unity;
namespace ProjectLibrary.Forms
{
public partial class FBooks : Form
{
private readonly IUnityContainer _container;
private readonly IBookRepository _bookRepository;
public FBooks(IUnityContainer container, IBookRepository bookRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_bookRepository = bookRepository ?? throw new ArgumentNullException(nameof(bookRepository));
}
private void LoadList()
{
dataGridViewBooks.DataSource = _bookRepository.ReadBooks();
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewBooks.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewBooks.SelectedRows[0].Cells["Id"].Value);
return true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FBook>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FBook>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_bookRepository.DeleteBook(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FBooks_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,105 @@
namespace ProjectLibrary.Forms
{
partial class FLibraries
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridViewOrders = new DataGridView();
buttonAdd = new Button();
buttonUpdate = new Button();
buttonRemove = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit();
SuspendLayout();
//
// dataGridViewOrders
//
dataGridViewOrders.AllowUserToAddRows = false;
dataGridViewOrders.AllowUserToDeleteRows = false;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Location = new Point(12, 11);
dataGridViewOrders.Margin = new Padding(3, 2, 3, 2);
dataGridViewOrders.Name = "dataGridViewOrders";
dataGridViewOrders.ReadOnly = true;
dataGridViewOrders.RowHeadersWidth = 51;
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewOrders.Size = new Size(525, 225);
dataGridViewOrders.TabIndex = 8;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 251);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(88, 22);
buttonAdd.TabIndex = 9;
buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(227, 251);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(88, 22);
buttonUpdate.TabIndex = 10;
buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonRemove
//
buttonRemove.Location = new Point(450, 251);
buttonRemove.Margin = new Padding(3, 2, 3, 2);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(88, 22);
buttonRemove.TabIndex = 11;
buttonRemove.Text = "Удалить";
buttonRemove.Click += buttonRemove_Click;
//
// FLibraries
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(562, 283);
Controls.Add(dataGridViewOrders);
Controls.Add(buttonAdd);
Controls.Add(buttonUpdate);
Controls.Add(buttonRemove);
Name = "FLibraries";
Text = "FLibraries";
Load += FLibraries_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewOrders;
private Button buttonAdd;
private Button buttonUpdate;
private Button buttonRemove;
}
}

View File

@ -0,0 +1,102 @@
using ProjectLibrary.Repositories;
using Unity;
namespace ProjectLibrary.Forms
{
public partial class FLibraries : Form
{
private readonly IUnityContainer _container;
private readonly ILibraryRepository _libraryRepository;
public FLibraries(IUnityContainer container, ILibraryRepository libraryRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_libraryRepository = libraryRepository ?? throw new ArgumentNullException(nameof(libraryRepository));
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FLibrary>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FLibrary>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_libraryRepository.DeleteLibrary(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FLibraries_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridViewOrders.DataSource = _libraryRepository.ReadLibraries();
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewOrders.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -3,14 +3,11 @@
partial class FLibrary partial class FLibrary
{ {
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
private Label lblId;
private TextBox txtId;
private Label lblName; private Label lblName;
private TextBox txtName; private TextBox txtName;
private Label lblAddress; private Label lblAddress;
private TextBox txtAddress; private TextBox txtAddress;
private Button btnSave; private Button ButtonSave;
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
@ -23,100 +20,113 @@
private void InitializeComponent() private void InitializeComponent()
{ {
lblId = new Label();
txtId = new TextBox();
lblName = new Label(); lblName = new Label();
txtName = new TextBox(); txtName = new TextBox();
lblAddress = new Label(); lblAddress = new Label();
txtAddress = new TextBox(); txtAddress = new TextBox();
btnSave = new Button(); ButtonSave = new Button();
buttonCancel_Click = new Button(); buttonCancel_Click = new Button();
dataGridView = new DataGridView();
Book = new DataGridViewComboBoxColumn();
Count = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// lblId
//
lblId.AutoSize = true;
lblId.Location = new Point(20, 20);
lblId.Name = "lblId";
lblId.Size = new Size(27, 20);
lblId.TabIndex = 0;
lblId.Text = "ID:";
//
// txtId
//
txtId.Location = new Point(100, 20);
txtId.Name = "txtId";
txtId.ReadOnly = true;
txtId.Size = new Size(200, 27);
txtId.TabIndex = 1;
//
// lblName // lblName
// //
lblName.AutoSize = true; lblName.AutoSize = true;
lblName.Location = new Point(20, 60); lblName.Location = new Point(20, 9);
lblName.Name = "lblName"; lblName.Name = "lblName";
lblName.Size = new Size(42, 20); lblName.Size = new Size(62, 15);
lblName.TabIndex = 2; lblName.TabIndex = 2;
lblName.Text = "Имя:"; lblName.Text = "Название:";
// //
// txtName // txtName
// //
txtName.Location = new Point(100, 60); txtName.Location = new Point(100, 12);
txtName.Name = "txtName"; txtName.Name = "txtName";
txtName.Size = new Size(200, 27); txtName.Size = new Size(200, 23);
txtName.TabIndex = 3; txtName.TabIndex = 3;
// //
// lblAddress // lblAddress
// //
lblAddress.AutoSize = true; lblAddress.AutoSize = true;
lblAddress.Location = new Point(20, 100); lblAddress.Location = new Point(20, 49);
lblAddress.Name = "lblAddress"; lblAddress.Name = "lblAddress";
lblAddress.Size = new Size(54, 20); lblAddress.Size = new Size(43, 15);
lblAddress.TabIndex = 4; lblAddress.TabIndex = 4;
lblAddress.Text = "Адрес:"; lblAddress.Text = "Адрес:";
// //
// txtAddress // txtAddress
// //
txtAddress.Location = new Point(100, 100); txtAddress.Location = new Point(100, 49);
txtAddress.Name = "txtAddress"; txtAddress.Name = "txtAddress";
txtAddress.Size = new Size(200, 27); txtAddress.Size = new Size(200, 23);
txtAddress.TabIndex = 5; txtAddress.TabIndex = 5;
// //
// btnSave // ButtonSave
// //
btnSave.Location = new Point(20, 133); ButtonSave.Location = new Point(20, 224);
btnSave.Name = "btnSave"; ButtonSave.Name = "ButtonSave";
btnSave.Size = new Size(100, 30); ButtonSave.Size = new Size(100, 27);
btnSave.TabIndex = 6; ButtonSave.TabIndex = 14;
btnSave.Text = "Сохранить"; ButtonSave.Text = "Сохранить";
btnSave.Click += btnSave_Click; ButtonSave.Click += ButtonSave_Click;
// //
// buttonCancel_Click // buttonCancel_Click
// //
buttonCancel_Click.Location = new Point(200, 133); buttonCancel_Click.Location = new Point(200, 222);
buttonCancel_Click.Name = "buttonCancel_Click"; buttonCancel_Click.Name = "buttonCancel_Click";
buttonCancel_Click.Size = new Size(100, 30); buttonCancel_Click.Size = new Size(100, 30);
buttonCancel_Click.TabIndex = 10; buttonCancel_Click.TabIndex = 10;
buttonCancel_Click.Text = "Отмена"; buttonCancel_Click.Text = "Отмена";
buttonCancel_Click.Click += buttonCancel_Click_Click; buttonCancel_Click.Click += buttonCancel_Click_Click;
// //
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Book, Count });
dataGridView.Location = new Point(20, 93);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(280, 123);
dataGridView.TabIndex = 13;
//
// Book
//
Book.HeaderText = "Book";
Book.MinimumWidth = 6;
Book.Name = "Book";
Book.SortMode = DataGridViewColumnSortMode.Automatic;
Book.Width = 125;
//
// Count
//
Count.HeaderText = "Count";
Count.MinimumWidth = 6;
Count.Name = "Count";
Count.Width = 125;
//
// FLibrary // FLibrary
// //
ClientSize = new Size(400, 200); ClientSize = new Size(400, 436);
Controls.Add(dataGridView);
Controls.Add(buttonCancel_Click); Controls.Add(buttonCancel_Click);
Controls.Add(lblId);
Controls.Add(txtId);
Controls.Add(lblName); Controls.Add(lblName);
Controls.Add(txtName); Controls.Add(txtName);
Controls.Add(lblAddress); Controls.Add(lblAddress);
Controls.Add(txtAddress); Controls.Add(txtAddress);
Controls.Add(btnSave); Controls.Add(ButtonSave);
Name = "FLibrary"; Name = "FLibrary";
Text = "Библиотека"; Text = "Библиотека";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
private Button buttonCancel_Click; private Button buttonCancel_Click;
private DataGridView dataGridView;
private DataGridViewComboBoxColumn Book;
private DataGridViewTextBoxColumn Count;
} }
} }

View File

@ -1,36 +1,94 @@
using System; using ProjectLibrary.Entites;
using ProjectLibrary.Repositories;
using ProjectLibrary.Repositories.Implementations;
using System.Windows.Forms; using System.Windows.Forms;
using ProjectLibrary.Entites;
namespace ProjectLibrary.Forms namespace ProjectLibrary.Forms
{ {
public partial class FLibrary : Form public partial class FLibrary : Form
{ {
private Library _library; private readonly ILibraryRepository _libraryRepository;
private int? _orderId;
public int Id
{
set
{
try
{
var library = _libraryRepository.ReadLibraryById(value);
if (library == null)
{
throw new InvalidOperationException("Заказ не найден.");
}
public FLibrary(Library library) txtName.Text = library.Name;
txtAddress.Text = library.Address;
dataGridView.DataSource = library.BookLibrary;
_orderId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
public FLibrary(ILibraryRepository libraryRepository)
{ {
InitializeComponent(); InitializeComponent();
_library = library; _libraryRepository = libraryRepository ?? throw new ArgumentNullException(nameof(libraryRepository));
LoadLibraryData();
} }
private void LoadLibraryData() private void ButtonSave_Click(object sender, EventArgs e)
{ {
txtId.Text = _library.Id.ToString(); try
txtName.Text = _library.Name; {
txtAddress.Text = _library.Address; if (string.IsNullOrWhiteSpace(txtName.Text) || string.IsNullOrWhiteSpace(txtAddress.Text))
{
throw new Exception("Не все поля заполнены.");
} }
private void btnSave_Click(object sender, EventArgs e) var library = Library.CreateEntity(
{ _orderId ?? 0,
txtName.Text,
txtAddress.Text,
CreateListBooksFromDataGrid()
);
if (_orderId.HasValue)
{
_libraryRepository.UpdateLibrary(library);
}
else
{
_libraryRepository.CreateLibrary(library);
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
private void buttonCancel_Click_Click(object sender, EventArgs e) private void buttonCancel_Click_Click(object sender, EventArgs e)
{ {
// Закрытие формы без сохранения
this.Close(); this.Close();
} }
private List<Book_Library> CreateListBooksFromDataGrid()
{
var list = new List<Book_Library>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["Book"].Value == null || row.Cells["Count"].Value == null)
{
continue;
}
list.Add(Book_Library.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnBook"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
} }
} }

View File

@ -117,4 +117,10 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="Book.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -30,10 +30,10 @@
lblBookID = new Label(); lblBookID = new Label();
btnSave = new Button(); btnSave = new Button();
buttonCancel_Click = new Button(); buttonCancel_Click = new Button();
comboBox1 = new ComboBox(); comboBox = new ComboBox();
dataGridViewIDBook = new DataGridView(); dataGridViewBook = new DataGridView();
Book = new DataGridViewComboBoxColumn(); Book = new DataGridViewComboBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridViewIDBook).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewBook).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// lblOrderDate // lblOrderDate
@ -41,7 +41,7 @@
lblOrderDate.AutoSize = true; lblOrderDate.AutoSize = true;
lblOrderDate.Location = new Point(12, 25); lblOrderDate.Location = new Point(12, 25);
lblOrderDate.Name = "lblOrderDate"; lblOrderDate.Name = "lblOrderDate";
lblOrderDate.Size = new Size(93, 20); lblOrderDate.Size = new Size(72, 15);
lblOrderDate.TabIndex = 2; lblOrderDate.TabIndex = 2;
lblOrderDate.Text = "Дата заказа:"; lblOrderDate.Text = "Дата заказа:";
// //
@ -49,7 +49,7 @@
// //
txtOrderDate.Location = new Point(129, 25); txtOrderDate.Location = new Point(129, 25);
txtOrderDate.Name = "txtOrderDate"; txtOrderDate.Name = "txtOrderDate";
txtOrderDate.Size = new Size(200, 27); txtOrderDate.Size = new Size(200, 23);
txtOrderDate.TabIndex = 3; txtOrderDate.TabIndex = 3;
// //
// lblReturnDate // lblReturnDate
@ -57,7 +57,7 @@
lblReturnDate.AutoSize = true; lblReturnDate.AutoSize = true;
lblReturnDate.Location = new Point(12, 65); lblReturnDate.Location = new Point(12, 65);
lblReturnDate.Name = "lblReturnDate"; lblReturnDate.Name = "lblReturnDate";
lblReturnDate.Size = new Size(111, 20); lblReturnDate.Size = new Size(86, 15);
lblReturnDate.TabIndex = 4; lblReturnDate.TabIndex = 4;
lblReturnDate.Text = "Дата возврата:"; lblReturnDate.Text = "Дата возврата:";
// //
@ -65,7 +65,7 @@
// //
txtReturnDate.Location = new Point(129, 65); txtReturnDate.Location = new Point(129, 65);
txtReturnDate.Name = "txtReturnDate"; txtReturnDate.Name = "txtReturnDate";
txtReturnDate.Size = new Size(200, 27); txtReturnDate.Size = new Size(200, 23);
txtReturnDate.TabIndex = 5; txtReturnDate.TabIndex = 5;
// //
// lblReaderID // lblReaderID
@ -73,7 +73,7 @@
lblReaderID.AutoSize = true; lblReaderID.AutoSize = true;
lblReaderID.Location = new Point(12, 105); lblReaderID.Location = new Point(12, 105);
lblReaderID.Name = "lblReaderID"; lblReaderID.Name = "lblReaderID";
lblReaderID.Size = new Size(92, 20); lblReaderID.Size = new Size(73, 15);
lblReaderID.TabIndex = 6; lblReaderID.TabIndex = 6;
lblReaderID.Text = "ID читателя:"; lblReaderID.Text = "ID читателя:";
// //
@ -82,7 +82,7 @@
lblBookID.AutoSize = true; lblBookID.AutoSize = true;
lblBookID.Location = new Point(12, 145); lblBookID.Location = new Point(12, 145);
lblBookID.Name = "lblBookID"; lblBookID.Name = "lblBookID";
lblBookID.Size = new Size(71, 20); lblBookID.Size = new Size(56, 15);
lblBookID.TabIndex = 8; lblBookID.TabIndex = 8;
lblBookID.Text = "ID книги:"; lblBookID.Text = "ID книги:";
// //
@ -94,7 +94,6 @@
btnSave.TabIndex = 10; btnSave.TabIndex = 10;
btnSave.Text = "Сохранить"; btnSave.Text = "Сохранить";
btnSave.Click += ButtonSave_Click; btnSave.Click += ButtonSave_Click;
// //
// buttonCancel_Click // buttonCancel_Click
// //
@ -105,22 +104,22 @@
buttonCancel_Click.Text = "Отмена"; buttonCancel_Click.Text = "Отмена";
buttonCancel_Click.Click += ButtonCancel_Click; buttonCancel_Click.Click += ButtonCancel_Click;
// //
// comboBox1 // comboBox
// //
comboBox1.Location = new Point(129, 108); comboBox.Location = new Point(129, 108);
comboBox1.Name = "comboBox1"; comboBox.Name = "comboBox";
comboBox1.Size = new Size(203, 28); comboBox.Size = new Size(203, 23);
comboBox1.TabIndex = 0; comboBox.TabIndex = 0;
// //
// dataGridViewIDBook // dataGridViewBook
// //
dataGridViewIDBook.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewBook.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewIDBook.Columns.AddRange(new DataGridViewColumn[] { Book }); dataGridViewBook.Columns.AddRange(new DataGridViewColumn[] { Book });
dataGridViewIDBook.Location = new Point(129, 151); dataGridViewBook.Location = new Point(129, 151);
dataGridViewIDBook.Name = "dataGridViewIDBook"; dataGridViewBook.Name = "dataGridViewBook";
dataGridViewIDBook.RowHeadersWidth = 51; dataGridViewBook.RowHeadersWidth = 51;
dataGridViewIDBook.Size = new Size(200, 81); dataGridViewBook.Size = new Size(200, 81);
dataGridViewIDBook.TabIndex = 12; dataGridViewBook.TabIndex = 12;
// //
// Book // Book
// //
@ -129,11 +128,11 @@
Book.Name = "Book"; Book.Name = "Book";
Book.Width = 125; Book.Width = 125;
// //
// FOrders // FOrder
// //
ClientSize = new Size(372, 332); ClientSize = new Size(372, 332);
Controls.Add(dataGridViewIDBook); Controls.Add(dataGridViewBook);
Controls.Add(comboBox1); Controls.Add(comboBox);
Controls.Add(buttonCancel_Click); Controls.Add(buttonCancel_Click);
Controls.Add(lblOrderDate); Controls.Add(lblOrderDate);
Controls.Add(txtOrderDate); Controls.Add(txtOrderDate);
@ -142,16 +141,16 @@
Controls.Add(lblReaderID); Controls.Add(lblReaderID);
Controls.Add(lblBookID); Controls.Add(lblBookID);
Controls.Add(btnSave); Controls.Add(btnSave);
Name = "FOrders"; Name = "FOrder";
Text = "Заказы"; Text = "Заказы";
((System.ComponentModel.ISupportInitialize)dataGridViewIDBook).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewBook).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
private Button buttonCancel_Click; private Button buttonCancel_Click;
private ComboBox comboBox1; private ComboBox comboBox;
private DataGridView dataGridViewIDBook; private DataGridView dataGridViewBook;
private DataGridViewComboBoxColumn Book; private DataGridViewComboBoxColumn Book;
} }
} }

View File

@ -1,111 +1,84 @@
using ProjectLibrary.Repositories; using ProjectLibrary.Repositories;
using Unity;
using ProjectLibrary.Entites; using ProjectLibrary.Entites;
using System.Xml.Linq;
namespace ProjectLibrary.Forms namespace ProjectLibrary.Forms
{ {
public partial class FOrder : Form public partial class FOrder : Form
{ {
private readonly IUnityContainer _container;
private readonly IOrderRepository _orderRepository; private readonly IOrderRepository _orderRepository;
private int? _orderId; private int? _orderId;
public FOrder(IUnityContainer container, IOrderRepository orderRepository, IBookOrderRepository bookOrderRepository) public FOrder(IOrderRepository orderRepository)
{ {
InitializeComponent(); InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
} }
private void FOrder_Load(object sender, EventArgs e) public int Id
{
set
{ {
try try
{ {
if (_orderId.HasValue) var order = _orderRepository.ReadOrderById(value);
if (order == null)
{ {
LoadOrderData(_orderId.Value); throw new InvalidOperationException("Заказ не найден.");
} }
txtOrderDate.Text = order.OrderDate.ToString();
txtReturnDate.Text = order.ReturnDate.ToString();
comboBox.SelectedItem = order.ReaderID;
dataGridViewBook.DataSource = order.BookOrders;
_orderId = value;
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
public int OrderID
{
set
{
_orderId = value;
}
} }
private void LoadOrderData(int orderId) private List<Book_Orders> CreateListBooksFromDataGrid()
{
var order = _orderRepository.ReadOrderById(orderId);
//var bookOrders = _bookOrderRepository.GetBookOrderByOrderId(orderId);
if (order == null)
{
throw new InvalidOperationException("Данные заказа не найдены.");
}
txtOrderDate.Text = order.OrderDate.ToString("yyyy-MM-dd");
txtReturnDate.Text = order.ReturnDate.ToString("yyyy-MM-dd");
comboBox1.SelectedItem = order.ReaderID.ToString();
dataGridViewIDBook.Rows.Clear();
//foreach (var bookOrder in bookOrders)
//{
// dataGridViewIDBook.Rows.Add(bookOrder.BookID);
//}
}
private List<Book_Orders> CreateListMaterialFromDataGrid()
{ {
var list = new List<Book_Orders>(); var list = new List<Book_Orders>();
foreach (DataGridViewRow row in dataGridViewIDBook.Rows) foreach (DataGridViewRow row in dataGridViewBook.Rows)
{ {
if (row.Cells["ColumnMaterials"].Value == null || row.Cells["ColumnCount"].Value == null) if (row.Cells["ColumnBook"].Value == null)
{ {
continue; continue;
} }
list.Add(Book_Orders.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnMaterials"].Value))); list.Add(Book_Orders.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnBook"].Value)));
} }
return list; return list;
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(txtOrderDate.Text) || string.IsNullOrWhiteSpace(txtReturnDate.Text)) if (string.IsNullOrWhiteSpace(txtOrderDate.Text) || string.IsNullOrWhiteSpace(txtReturnDate.Text) || comboBox.SelectedItem == null)
{ {
throw new Exception("Не все поля заполнены."); throw new Exception("Не все поля заполнены.");
} }
var order = Orders.CreateEntity(
var updatedOrder = Orders.CreateEntity(
_orderId ?? 0, _orderId ?? 0,
DateTime.Parse(txtOrderDate.Text), DateTime.Parse(txtOrderDate.Text),
DateTime.Parse(txtReturnDate.Text), DateTime.Parse(txtReturnDate.Text),
int.Parse(comboBox1.SelectedItem.ToString()), int.Parse(comboBox.SelectedItem.ToString()),
CreateListMaterialFromDataGrid() CreateListBooksFromDataGrid()
); );
if (_orderId.HasValue) if (_orderId.HasValue)
{ {
_orderRepository.UpdateOrder(updatedOrder); _orderRepository.UpdateOrder(order);
} }
else else
{ {
_orderRepository.CreateOrder(updatedOrder); _orderRepository.CreateOrder(order);
} }
MessageBox.Show("Данные успешно сохранены.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -120,4 +120,7 @@
<metadata name="Book.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Book.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Book.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -40,52 +40,58 @@
dataGridViewOrders.AllowUserToAddRows = false; dataGridViewOrders.AllowUserToAddRows = false;
dataGridViewOrders.AllowUserToDeleteRows = false; dataGridViewOrders.AllowUserToDeleteRows = false;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Location = new Point(12, 12); dataGridViewOrders.Location = new Point(10, 9);
dataGridViewOrders.Margin = new Padding(3, 2, 3, 2);
dataGridViewOrders.Name = "dataGridViewOrders"; dataGridViewOrders.Name = "dataGridViewOrders";
dataGridViewOrders.ReadOnly = true; dataGridViewOrders.ReadOnly = true;
dataGridViewOrders.RowHeadersWidth = 51; dataGridViewOrders.RowHeadersWidth = 51;
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewOrders.Size = new Size(600, 300); dataGridViewOrders.Size = new Size(525, 225);
dataGridViewOrders.TabIndex = 4; dataGridViewOrders.TabIndex = 4;
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(12, 332); buttonAdd.Location = new Point(10, 249);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(100, 30); buttonAdd.Size = new Size(88, 22);
buttonAdd.TabIndex = 5; buttonAdd.TabIndex = 5;
buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click; buttonAdd.Click += buttonAdd_Click;
// //
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Location = new Point(132, 332); buttonUpdate.Location = new Point(225, 249);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(100, 30); buttonUpdate.Size = new Size(88, 22);
buttonUpdate.TabIndex = 6; buttonUpdate.TabIndex = 6;
buttonUpdate.Text = "Изменить"; buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click; buttonUpdate.Click += buttonUpdate_Click;
// //
// buttonRemove // buttonRemove
// //
buttonRemove.Location = new Point(252, 332); buttonRemove.Location = new Point(448, 249);
buttonRemove.Margin = new Padding(3, 2, 3, 2);
buttonRemove.Name = "buttonRemove"; buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(100, 30); buttonRemove.Size = new Size(88, 22);
buttonRemove.TabIndex = 7; buttonRemove.TabIndex = 7;
buttonRemove.Text = "Удалить"; buttonRemove.Text = "Удалить";
buttonRemove.Click += buttonRemove_Click; buttonRemove.Click += buttonRemove_Click;
// //
// FOrders // FOrders
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(630, 412); ClientSize = new Size(551, 309);
Controls.Add(dataGridViewOrders); Controls.Add(dataGridViewOrders);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(buttonUpdate); Controls.Add(buttonUpdate);
Controls.Add(buttonRemove); Controls.Add(buttonRemove);
Margin = new Padding(3, 2, 3, 2);
Name = "FOrders"; Name = "FOrders";
Text = "FOrders"; Text = "FOrders";
Load += FOrders_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -1,6 +1,4 @@
using ProjectLibrary.Entites; using ProjectLibrary.Repositories;
using ProjectLibrary.Repositories;
using System.Windows.Forms;
using Unity; using Unity;
namespace ProjectLibrary.Forms namespace ProjectLibrary.Forms
@ -24,7 +22,6 @@ namespace ProjectLibrary.Forms
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
try try
{ {
_container.Resolve<FOrder>().ShowDialog(); _container.Resolve<FOrder>().ShowDialog();
@ -58,8 +55,8 @@ namespace ProjectLibrary.Forms
try try
{ {
var form = _container.Resolve<FReader>(); var form = _container.Resolve<FOrder>();
form.ID = findId; form.Id = findId;
form.ShowDialog(); form.ShowDialog();
LoadList(); LoadList();
} }
@ -91,5 +88,17 @@ namespace ProjectLibrary.Forms
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void FOrders_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View File

@ -7,7 +7,7 @@ namespace ProjectLibrary.Forms
{ {
public partial class FReader : Form public partial class FReader : Form
{ {
private readonly IReaderRepository _readerRepository; // Интерфейс для работы с репозиторием private readonly IReaderRepository _readerRepository;
private int? _readerId; private int? _readerId;
public int ID public int ID
@ -16,7 +16,7 @@ namespace ProjectLibrary.Forms
{ {
try try
{ {
var reader = _readerRepository.GetReaderById(value); var reader = _readerRepository.ReadReaderById(value);
if (reader == null) if (reader == null)
{ {
@ -60,10 +60,9 @@ namespace ProjectLibrary.Forms
} }
else else
{ {
_readerRepository.AddReader(reader); _readerRepository.CreateReader(reader);
} }
MessageBox.Show("Данные успешно сохранены!", "[ Success ]", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -3,9 +3,6 @@
partial class FTicket_Extension partial class FTicket_Extension
{ {
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
private Label lblReaderID;
private TextBox txtReaderID;
private Label lblLastUpdateDate; private Label lblLastUpdateDate;
private DateTimePicker dtpLastUpdateDate; private DateTimePicker dtpLastUpdateDate;
private Label lblNextUpdateDate; private Label lblNextUpdateDate;
@ -24,39 +21,22 @@
private void InitializeComponent() private void InitializeComponent()
{ {
lblReaderID = new Label();
txtReaderID = new TextBox();
lblLastUpdateDate = new Label(); lblLastUpdateDate = new Label();
dtpLastUpdateDate = new DateTimePicker(); dtpLastUpdateDate = new DateTimePicker();
lblNextUpdateDate = new Label(); lblNextUpdateDate = new Label();
dtpNextUpdateDate = new DateTimePicker(); dtpNextUpdateDate = new DateTimePicker();
btnSave = new Button(); btnSave = new Button();
btnCancel = new Button(); btnCancel = new Button();
labelId = new Label();
comboBoxId = new ComboBox();
SuspendLayout(); SuspendLayout();
// //
// lblReaderID
//
lblReaderID.AutoSize = true;
lblReaderID.Location = new Point(20, 20);
lblReaderID.Name = "lblReaderID";
lblReaderID.Size = new Size(92, 20);
lblReaderID.TabIndex = 0;
lblReaderID.Text = "ID читателя:";
//
// txtReaderID
//
txtReaderID.Location = new Point(140, 20);
txtReaderID.Name = "txtReaderID";
txtReaderID.ReadOnly = true;
txtReaderID.Size = new Size(200, 27);
txtReaderID.TabIndex = 1;
//
// lblLastUpdateDate // lblLastUpdateDate
// //
lblLastUpdateDate.AutoSize = true; lblLastUpdateDate.AutoSize = true;
lblLastUpdateDate.Location = new Point(20, 64); lblLastUpdateDate.Location = new Point(20, 64);
lblLastUpdateDate.Name = "lblLastUpdateDate"; lblLastUpdateDate.Name = "lblLastUpdateDate";
lblLastUpdateDate.Size = new Size(219, 20); lblLastUpdateDate.Size = new Size(172, 15);
lblLastUpdateDate.TabIndex = 4; lblLastUpdateDate.TabIndex = 4;
lblLastUpdateDate.Text = "Дата последнего обновления:"; lblLastUpdateDate.Text = "Дата последнего обновления:";
// //
@ -64,7 +44,7 @@
// //
dtpLastUpdateDate.Location = new Point(276, 59); dtpLastUpdateDate.Location = new Point(276, 59);
dtpLastUpdateDate.Name = "dtpLastUpdateDate"; dtpLastUpdateDate.Name = "dtpLastUpdateDate";
dtpLastUpdateDate.Size = new Size(200, 27); dtpLastUpdateDate.Size = new Size(200, 23);
dtpLastUpdateDate.TabIndex = 5; dtpLastUpdateDate.TabIndex = 5;
// //
// lblNextUpdateDate // lblNextUpdateDate
@ -72,7 +52,7 @@
lblNextUpdateDate.AutoSize = true; lblNextUpdateDate.AutoSize = true;
lblNextUpdateDate.Location = new Point(20, 104); lblNextUpdateDate.Location = new Point(20, 104);
lblNextUpdateDate.Name = "lblNextUpdateDate"; lblNextUpdateDate.Name = "lblNextUpdateDate";
lblNextUpdateDate.Size = new Size(223, 20); lblNextUpdateDate.Size = new Size(178, 15);
lblNextUpdateDate.TabIndex = 6; lblNextUpdateDate.TabIndex = 6;
lblNextUpdateDate.Text = "Дата следующего обновления:"; lblNextUpdateDate.Text = "Дата следующего обновления:";
// //
@ -80,7 +60,7 @@
// //
dtpNextUpdateDate.Location = new Point(276, 99); dtpNextUpdateDate.Location = new Point(276, 99);
dtpNextUpdateDate.Name = "dtpNextUpdateDate"; dtpNextUpdateDate.Name = "dtpNextUpdateDate";
dtpNextUpdateDate.Size = new Size(200, 27); dtpNextUpdateDate.Size = new Size(200, 23);
dtpNextUpdateDate.TabIndex = 7; dtpNextUpdateDate.TabIndex = 7;
// //
// btnSave // btnSave
@ -90,7 +70,7 @@
btnSave.Size = new Size(100, 30); btnSave.Size = new Size(100, 30);
btnSave.TabIndex = 8; btnSave.TabIndex = 8;
btnSave.Text = "Сохранить"; btnSave.Text = "Сохранить";
btnSave.Click += SaveBtn_Click; btnSave.Click += btnSave_Click;
// //
// btnCancel // btnCancel
// //
@ -99,13 +79,29 @@
btnCancel.Size = new Size(100, 30); btnCancel.Size = new Size(100, 30);
btnCancel.TabIndex = 9; btnCancel.TabIndex = 9;
btnCancel.Text = "Отмена"; btnCancel.Text = "Отмена";
btnCancel.Click += DiscardBtn_Click; btnCancel.Click += btnCancel_Click;
//
// labelId
//
labelId.AutoSize = true;
labelId.Location = new Point(20, 19);
labelId.Name = "labelId";
labelId.Size = new Size(17, 15);
labelId.TabIndex = 10;
labelId.Text = "id";
//
// comboBoxId
//
comboBoxId.Location = new Point(273, 16);
comboBoxId.Name = "comboBoxId";
comboBoxId.Size = new Size(203, 23);
comboBoxId.TabIndex = 11;
// //
// FTicket_Extension // FTicket_Extension
// //
ClientSize = new Size(797, 250); ClientSize = new Size(573, 250);
Controls.Add(lblReaderID); Controls.Add(comboBoxId);
Controls.Add(txtReaderID); Controls.Add(labelId);
Controls.Add(lblLastUpdateDate); Controls.Add(lblLastUpdateDate);
Controls.Add(dtpLastUpdateDate); Controls.Add(dtpLastUpdateDate);
Controls.Add(lblNextUpdateDate); Controls.Add(lblNextUpdateDate);
@ -117,5 +113,8 @@
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
private Label labelId;
private ComboBox comboBoxId;
} }
} }

View File

@ -1,8 +1,5 @@
using System; using ProjectLibrary.Entites;
using System.Windows.Forms; using ProjectLibrary.Repositores;
using ProjectLibrary.Entites;
using ProjectLibrary.Entities;
using ProjectLibrary.Repositories;
namespace ProjectLibrary.Forms namespace ProjectLibrary.Forms
{ {
@ -11,79 +8,68 @@ namespace ProjectLibrary.Forms
private readonly ITicketExtensionsRepository _ticketExtensionsRepository; private readonly ITicketExtensionsRepository _ticketExtensionsRepository;
private int? _extensionId; private int? _extensionId;
public int ID public int Id
{ {
set set
{ {
try try
{ {
var ticketExtension = _ticketExtensionsRepository.GetTicketExtensionById(value); var ticket = _ticketExtensionsRepository.ReadTicketExtensionById(value);
if (ticket == null)
if (ticketExtension == null)
{ {
throw new InvalidOperationException($"Ticket extension with ID {value} not found."); throw new InvalidOperationException("Заказ не найден.");
} }
comboBoxId.SelectedItem = ticket.ReaderID;
txtReaderID.Text = ticketExtension.ReaderID.ToString(); dtpLastUpdateDate.Text = ticket.LastUpdateDate.ToString();
dtpLastUpdateDate.Value = ticketExtension.LastUpdateDate; dtpNextUpdateDate.Text = ticket.NextUpdateDate.ToString();
dtpNextUpdateDate.Value = ticketExtension.NextUpdateDate;
_extensionId = value; _extensionId = value;
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "[ Error : wrong data ]", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
public FTicket_Extension(ITicketExtensionsRepository ticketRepository)
public FTicket_Extension(ITicketExtensionsRepository ticketExtensionsRepository)
{ {
InitializeComponent(); InitializeComponent();
_ticketExtensionsRepository = ticketExtensionsRepository ?? throw new ArgumentNullException(nameof(ticketExtensionsRepository)); _ticketExtensionsRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
} }
private void SaveBtn_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
try try
{ {
if (string.IsNullOrWhiteSpace(txtReaderID.Text)) if (string.IsNullOrWhiteSpace(dtpLastUpdateDate.Text) || string.IsNullOrWhiteSpace(dtpNextUpdateDate.Text) || comboBoxId.SelectedItem == null)
{ {
throw new Exception("[ Error : blank spaces were left, not enough information ]"); throw new Exception("Не все поля заполнены.");
} }
var ticketExtension = CreateTicketExtension(); var ticket = TicketExtensions.CreateEntity(
_extensionId ?? 0,
DateTime.Parse(dtpLastUpdateDate.Text),
DateTime.Parse(dtpNextUpdateDate.Text)
);
if (_extensionId.HasValue) if (_extensionId.HasValue)
{ {
_ticketExtensionsRepository.UpdateTicketExtension(ticketExtension); _ticketExtensionsRepository.UpdateTicketExtension(ticket);
} }
else else
{ {
_ticketExtensionsRepository.AddTicketExtension(ticketExtension); _ticketExtensionsRepository.CreateTicketExtension(ticket);
} }
MessageBox.Show("Данные успешно сохранены!", "[ Success ]", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "[ Error : while saving ]", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка при сохранении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void DiscardBtn_Click(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e)
{ {
Close(); this.Close();
}
private TicketExtensions CreateTicketExtension()
{
return TicketExtensions.CreateEntity(
int.Parse(txtReaderID.Text),
dtpLastUpdateDate.Value,
dtpNextUpdateDate.Value
);
} }
} }
} }

View File

@ -0,0 +1,92 @@
namespace ProjectLibrary.Forms
{
partial class FTiclet_Extensions
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
buttonAdd = new Button();
buttonUpdate = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 11);
dataGridView.Margin = new Padding(3, 2, 3, 2);
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(525, 225);
dataGridView.TabIndex = 8;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 251);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(88, 22);
buttonAdd.TabIndex = 9;
buttonAdd.Text = "Добавить";
buttonAdd.Click += buttonAdd_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(227, 251);
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(88, 22);
buttonUpdate.TabIndex = 10;
buttonUpdate.Text = "Изменить";
buttonUpdate.Click += buttonUpdate_Click;
//
// FTiclet_Extensions
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(569, 293);
Controls.Add(dataGridView);
Controls.Add(buttonAdd);
Controls.Add(buttonUpdate);
Name = "FTiclet_Extensions";
Text = "FTiclet_Extensions";
Load += FTiclet_Extensions_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpdate;
}
}

View File

@ -0,0 +1,79 @@
using ProjectLibrary.Repositores;
using ProjectLibrary.Repositories;
using Unity;
namespace ProjectLibrary.Forms
{
public partial class FTiclet_Extensions : Form
{
private readonly IUnityContainer _container;
private readonly ITicketExtensionsRepository _ticketRepository;
public FTiclet_Extensions(IUnityContainer container, ITicketExtensionsRepository ticketRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_ticketRepository = ticketRepository ?? throw new ArgumentNullException(nameof(ticketRepository));
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FTicket_Extension>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FTicket_Extension>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FTiclet_Extensions_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList()
{
dataGridView.DataSource = _ticketRepository.ReadTicketExtensions();
}
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,6 +1,7 @@
using ProjectLibrary.Repositories.Implementations; using ProjectLibrary.Repositories.Implementations;
using ProjectLibrary.Repositories; using ProjectLibrary.Repositories;
using Unity; using Unity;
using ProjectLibrary.Repositores;
namespace ProjectLibrary namespace ProjectLibrary
{ {
@ -28,10 +29,7 @@ namespace ProjectLibrary
container.RegisterType<IReaderRepository, ReaderRepository>(); container.RegisterType<IReaderRepository, ReaderRepository>();
container.RegisterType<IOrderRepository, OrderRepository>(); container.RegisterType<IOrderRepository, OrderRepository>();
container.RegisterType<ITicketExtensionsRepository, TicketExtensionsRepository>(); container.RegisterType<ITicketExtensionsRepository, TicketExtensionsRepository>();
container.RegisterType<IBookOrderRepository, BookOrderRepository>();
return container; return container;
} }
} }
} }

View File

@ -1,15 +0,0 @@
using ProjectLibrary.Entites;
using ProjectLibrary.Entities;
using System.Collections.Generic;
namespace ProjectLibrary.Repositories
{
public interface IBookOrderRepository
{
Book_Orders GetBookOrderByOrderId(int orderId); // Получить книгу по ID заказа
void AddBookOrder(Book_Orders bookOrder); // Добавить книгу к заказу
void UpdateBookOrder(Book_Orders bookOrder); // Обновить данные о книге в заказе
void DeleteBookOrder(int bookId, int orderId); // Удалить книгу из заказа
List<Book_Orders> ReadBookOrders(); // Получить все записи о книгах в заказах
}
}

View File

@ -1,4 +1,4 @@
namespace ProjectLibrary.Repositories namespace ProjectLibrary.Repositores
{ {
using ProjectLibrary.Entities; using ProjectLibrary.Entities;

View File

@ -5,10 +5,10 @@
public interface IReaderRepository public interface IReaderRepository
{ {
Reader GetReaderById(int id); Reader ReadReaderById(int id);
void AddReader(Reader reader); void CreateReader(Reader reader);
void UpdateReader(Reader reader); void UpdateReader(Reader reader);
void DeleteReader(int id); // Метод для удаления void DeleteReader(int id);
List<Reader> ReadReaders(); // Метод для чтения всех читателей List<Reader> ReadReaders();
} }
} }

View File

@ -0,0 +1,11 @@
using ProjectLibrary.Entites;
namespace ProjectLibrary.Repositores;
public interface ITicketExtensionsRepository
{
TicketExtensions ReadTicketExtensionById(int id);
List<TicketExtensions> ReadTicketExtensions();
void CreateTicketExtension(TicketExtensions ticketExtension);
void UpdateTicketExtension(TicketExtensions ticketExtension);
}

View File

@ -1,13 +0,0 @@
namespace ProjectLibrary.Repositories
{
using ProjectLibrary.Entites;
using ProjectLibrary.Entities;
public interface ITicketExtensionsRepository
{
TicketExtensions GetTicketExtensionById(int id);
void AddTicketExtension(TicketExtensions ticketExtension);
void UpdateTicketExtension(TicketExtensions ticketExtension);
}
}

View File

@ -1,37 +0,0 @@
using ProjectLibrary.Entites;
using ProjectLibrary.Entities;
using System.Collections.Generic;
using System.Linq;
namespace ProjectLibrary.Repositories
{
public class BookOrderRepository : IBookOrderRepository
{
public Book_Orders GetBookOrderByOrderId(int orderId)
{
return Book_Orders.CreateEntity(orderId,0);
}
public void AddBookOrder(Book_Orders bookOrder)
{
}
public void UpdateBookOrder(Book_Orders bookOrder)
{
}
public void DeleteBookOrder(int bookId, int orderId)
{
}
public List<Book_Orders> ReadBookOrders()
{
return [];
}
}
}

View File

@ -1,19 +1,21 @@
using ProjectLibrary.Entities; using ProjectLibrary.Entities;
using ProjectLibrary.Entities.Enums; using ProjectLibrary.Entities.Enums;
using ProjectLibrary.Repositories; using ProjectLibrary.Repositores;
using System.Collections.Generic;
using System.Linq;
namespace ProjectLibrary.Repositories.Implementations namespace ProjectLibrary.Repositories.Implementations
{ {
public class BookRepository : IBookRepository public class BookRepository : IBookRepository
{ {
public void CreateBook(Book book) public void CreateBook(Book book)
{ {
} }
public void UpdateBook(Book book)
{
}
public void DeleteBook(int id) public void DeleteBook(int id)
{ {
@ -29,10 +31,5 @@ namespace ProjectLibrary.Repositories.Implementations
{ {
return []; return [];
} }
public void UpdateBook(Book book)
{
}
} }
} }

View File

@ -5,13 +5,16 @@ namespace ProjectLibrary.Repositories.Implementations
{ {
public class LibraryRepository : ILibraryRepository public class LibraryRepository : ILibraryRepository
{ {
public void CreateLibrary(Library library) public void CreateLibrary(Library library)
{ {
} }
public void UpdateLibrary(Library library)
{
}
public void DeleteLibrary(int id) public void DeleteLibrary(int id)
{ {
@ -26,10 +29,5 @@ namespace ProjectLibrary.Repositories.Implementations
{ {
return []; return [];
} }
public void UpdateLibrary(Library library)
{
}
} }
} }

View File

@ -1,18 +1,16 @@
using ProjectLibrary.Entites; using ProjectLibrary.Entites;
using ProjectLibrary.Entities;
using ProjectLibrary.Repositories;
using System.Collections.Generic;
using System.Linq;
namespace ProjectLibrary.Repositories.Implementations namespace ProjectLibrary.Repositories.Implementations
{ {
public class OrderRepository : IOrderRepository public class OrderRepository : IOrderRepository
{ {
public void CreateOrder(Orders order) public void CreateOrder(Orders order)
{ {
}
public void UpdateOrder(Orders order)
{
} }
public void DeleteOrder(int id) public void DeleteOrder(int id)
@ -29,10 +27,5 @@ namespace ProjectLibrary.Repositories.Implementations
{ {
return [] ; return [] ;
} }
public void UpdateOrder(Orders order)
{
}
} }
} }

View File

@ -1,19 +1,10 @@
using System.Collections.Generic; using ProjectLibrary.Entities;
using System.Linq;
using ProjectLibrary.Entities;
namespace ProjectLibrary.Repositories namespace ProjectLibrary.Repositories
{ {
public class ReaderRepository : IReaderRepository public class ReaderRepository : IReaderRepository
{ {
public void CreateReader(Reader reader)
public Reader GetReaderById(int id)
{
return Reader.CreateEntity(id, "", 0);
}
public void AddReader(Reader reader)
{ {
} }
@ -27,6 +18,10 @@ namespace ProjectLibrary.Repositories
{ {
} }
public Reader ReadReaderById(int id)
{
return Reader.CreateEntity(id, "", 0);
}
public List<Reader> ReadReaders() public List<Reader> ReadReaders()
{ {

View File

@ -1,16 +1,9 @@
using ProjectLibrary.Entites; using ProjectLibrary.Entites;
using ProjectLibrary.Repositories; using ProjectLibrary.Repositores;
public class TicketExtensionsRepository : ITicketExtensionsRepository public class TicketExtensionsRepository : ITicketExtensionsRepository
{ {
public void CreateTicketExtension(TicketExtensions ticketExtension)
public TicketExtensions GetTicketExtensionById(int id)
{
return TicketExtensions.CreateEntity(0, DateTime.Now, DateTime.Now);
}
public void AddTicketExtension(TicketExtensions ticketExtension)
{ {
} }
@ -19,4 +12,14 @@ public class TicketExtensionsRepository : ITicketExtensionsRepository
{ {
} }
public TicketExtensions ReadTicketExtensionById(int id)
{
return TicketExtensions.CreateEntity(0, DateTime.Now, DateTime.Now);
}
public List<TicketExtensions> ReadTicketExtensions()
{
return [];
}
} }