Исправления, FOrder(s) and FReader(s) READY
This commit is contained in:
parent
039c2676cc
commit
09705a3190
@ -11,7 +11,7 @@ namespace ProjectLibrary.Entites
|
|||||||
public int BookID { get; private set; }
|
public int BookID { get; private set; }
|
||||||
public int OrderID { get; private set; }
|
public int OrderID { get; private set; }
|
||||||
|
|
||||||
public static Book_Orders CreateEntity(int bookID, int orderID)
|
public static Book_Orders CreateEntity(int orderID,int bookID )
|
||||||
{
|
{
|
||||||
return new Book_Orders
|
return new Book_Orders
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,8 @@ 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 bookID, int libraryID, int count)
|
public static Book_Library CreateEntity(int bookID, int libraryID, int count)
|
||||||
{
|
{
|
||||||
return new Book_Library
|
return new Book_Library
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using ProjectLibrary.Forms;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -11,14 +12,20 @@ namespace ProjectLibrary.Entites
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
public string Address { get; private set; } = string.Empty;
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
public IEnumerable<Book_Library> BookLibrary
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = [];
|
||||||
|
|
||||||
public static Library CreateEntity(int id, string name, string address)
|
public static Library CreateEntity(int id, string name, string address, IEnumerable<Book_Library> bookLibrary)
|
||||||
{
|
{
|
||||||
return new Library
|
return new Library
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Name = name ?? string.Empty,
|
Name = name ?? string.Empty,
|
||||||
Address = address ?? string.Empty
|
Address = address ?? string.Empty,
|
||||||
|
BookLibrary = bookLibrary
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Microsoft.VisualBasic;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -9,18 +10,26 @@ namespace ProjectLibrary.Entites
|
|||||||
public class Orders
|
public class Orders
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int OrderDate { get; private set; }
|
public DateTime OrderDate { get; private set; }
|
||||||
public int ReturnDate { get; private set; }
|
public DateTime ReturnDate { get; private set; }
|
||||||
public int ReaderID { get; private set; }
|
public int ReaderID { get; private set; }
|
||||||
|
|
||||||
public static Orders CreateEntity(int id, int orderDate, int returnDate, int readerID)
|
public IEnumerable<Book_Orders> BookOrders
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = [];
|
||||||
|
|
||||||
|
|
||||||
|
public static Orders CreateEntity(int id, DateTime orderDate, DateTime returnDate, int readerID, IEnumerable<Book_Orders> bookOrders)
|
||||||
{
|
{
|
||||||
return new Orders
|
return new Orders
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
OrderDate = orderDate,
|
OrderDate = orderDate,
|
||||||
ReturnDate = returnDate,
|
ReturnDate = returnDate,
|
||||||
ReaderID = readerID
|
ReaderID = readerID,
|
||||||
|
BookOrders = bookOrders
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
public int ReaderTicket { get; private set; }
|
public int ReaderTicket { get; private set; }
|
||||||
public DateTime RegistrationDateRT { get; private set; } // Изменение на DateTime
|
public DateTime RegistrationDateRT { get; private set; } // Изменение на DateTime
|
||||||
|
|
||||||
public static Reader CreateEntity(int id, string name, int readerTicket, DateTime registrationDateRT)
|
public static Reader CreateEntity(int id, string name, int readerTicket)
|
||||||
{
|
{
|
||||||
return new Reader
|
return new Reader
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Name = name ?? string.Empty,
|
Name = name ?? string.Empty,
|
||||||
ReaderTicket = readerTicket,
|
ReaderTicket = readerTicket,
|
||||||
RegistrationDateRT = registrationDateRT
|
RegistrationDateRT = DateTime.Now
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,11 @@ namespace ProjectLibrary.Entites
|
|||||||
public DateTime LastUpdateDate { get; private set; }
|
public DateTime LastUpdateDate { get; private set; }
|
||||||
public DateTime NextUpdateDate { get; private set; }
|
public DateTime NextUpdateDate { get; private set; }
|
||||||
|
|
||||||
public static TicketExtensions CreateEntity(int readerID, int extensionID, DateTime lastUpdateDate, DateTime nextUpdateDate)
|
public static TicketExtensions CreateEntity(int readerID, DateTime lastUpdateDate, DateTime nextUpdateDate)
|
||||||
{
|
{
|
||||||
return new TicketExtensions
|
return new TicketExtensions
|
||||||
{
|
{
|
||||||
ReaderID = readerID,
|
ReaderID = readerID,
|
||||||
ExtensionID = extensionID,
|
|
||||||
LastUpdateDate = lastUpdateDate,
|
LastUpdateDate = lastUpdateDate,
|
||||||
NextUpdateDate = nextUpdateDate
|
NextUpdateDate = nextUpdateDate
|
||||||
};
|
};
|
||||||
|
55
ProjectLibrary/FormLibrary.Designer.cs
generated
55
ProjectLibrary/FormLibrary.Designer.cs
generated
@ -30,13 +30,13 @@
|
|||||||
{
|
{
|
||||||
menuStrip1 = new MenuStrip();
|
menuStrip1 = new MenuStrip();
|
||||||
справочники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();
|
||||||
оформлениеБилетаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
обновлениеБилетаToolStripMenuItem = new ToolStripMenuItem();
|
обновлениеБилетаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
заказатьКнигиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -53,47 +53,41 @@
|
|||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
справочники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(117, 24);
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
//
|
//
|
||||||
// читательскийБилетToolStripMenuItem
|
|
||||||
//
|
|
||||||
читательскийБилетToolStripMenuItem.Name = "читательскийБилетToolStripMenuItem";
|
|
||||||
читательскийБилетToolStripMenuItem.Size = new Size(231, 26);
|
|
||||||
читательскийБилетToolStripMenuItem.Text = "Читательский билет";
|
|
||||||
//
|
|
||||||
// книгаToolStripMenuItem
|
// книгаToolStripMenuItem
|
||||||
//
|
//
|
||||||
книгаToolStripMenuItem.Name = "книгаToolStripMenuItem";
|
книгаToolStripMenuItem.Name = "книгаToolStripMenuItem";
|
||||||
книгаToolStripMenuItem.Size = new Size(231, 26);
|
книгаToolStripMenuItem.Size = new Size(175, 26);
|
||||||
книгаToolStripMenuItem.Text = "Книга";
|
книгаToolStripMenuItem.Text = "Книга";
|
||||||
//
|
//
|
||||||
// картаСотрудникаToolStripMenuItem
|
// читателиToolStripMenuItem
|
||||||
//
|
//
|
||||||
картаСотрудникаToolStripMenuItem.Name = "картаСотрудникаToolStripMenuItem";
|
читателиToolStripMenuItem.Name = "читателиToolStripMenuItem";
|
||||||
картаСотрудникаToolStripMenuItem.Size = new Size(231, 26);
|
читателиToolStripMenuItem.Size = new Size(175, 26);
|
||||||
картаСотрудникаToolStripMenuItem.Text = "Сотрудники";
|
читателиToolStripMenuItem.Text = "Читатели";
|
||||||
картаСотрудникаToolStripMenuItem.Click += картаСотрудникаToolStripMenuItem_Click;
|
читателиToolStripMenuItem.Click += читателиToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// библиотекиToolStripMenuItem
|
||||||
|
//
|
||||||
|
библиотекиToolStripMenuItem.Name = "библиотекиToolStripMenuItem";
|
||||||
|
библиотекиToolStripMenuItem.Size = new Size(175, 26);
|
||||||
|
библиотекиToolStripMenuItem.Text = "Библиотеки";
|
||||||
//
|
//
|
||||||
// операции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(95, 24);
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
операцииToolStripMenuItem.Text = "Операции";
|
||||||
//
|
//
|
||||||
// оформлениеБилетаToolStripMenuItem
|
|
||||||
//
|
|
||||||
оформлениеБилетаToolStripMenuItem.Name = "оформлениеБилетаToolStripMenuItem";
|
|
||||||
оформлениеБилетаToolStripMenuItem.Size = new Size(240, 26);
|
|
||||||
оформлениеБилетаToolStripMenuItem.Text = "Оформление билета ";
|
|
||||||
//
|
|
||||||
// обновлениеБилетаToolStripMenuItem
|
// обновлениеБилетаToolStripMenuItem
|
||||||
//
|
//
|
||||||
обновлениеБилетаToolStripMenuItem.Name = "обновлениеБилетаToolStripMenuItem";
|
обновлениеБилетаToolStripMenuItem.Name = "обновлениеБилетаToolStripMenuItem";
|
||||||
обновлениеБилетаToolStripMenuItem.Size = new Size(240, 26);
|
обновлениеБилетаToolStripMenuItem.Size = new Size(232, 26);
|
||||||
обновлениеБилетаToolStripMenuItem.Text = "Обновление билета";
|
обновлениеБилетаToolStripMenuItem.Text = "Обновление билета";
|
||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
@ -102,6 +96,13 @@
|
|||||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
|
// заказатьКнигиToolStripMenuItem
|
||||||
|
//
|
||||||
|
заказатьКнигиToolStripMenuItem.Name = "заказатьКнигиToolStripMenuItem";
|
||||||
|
заказатьКнигиToolStripMenuItem.Size = new Size(232, 26);
|
||||||
|
заказатьКнигиToolStripMenuItem.Text = "Заказать книги";
|
||||||
|
заказатьКнигиToolStripMenuItem.Click += заказатьКнигиToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// FormLibrary
|
// FormLibrary
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -124,12 +125,12 @@
|
|||||||
|
|
||||||
private MenuStrip menuStrip1;
|
private MenuStrip menuStrip1;
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
private ToolStripMenuItem читательскийБилетToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem книгаToolStripMenuItem;
|
private ToolStripMenuItem книгаToolStripMenuItem;
|
||||||
private ToolStripMenuItem картаСотрудникаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||||
private ToolStripMenuItem оформлениеБилетаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem обновлениеБилетаToolStripMenuItem;
|
private ToolStripMenuItem обновлениеБилетаToolStripMenuItem;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem читателиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem библиотекиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem заказатьКнигиToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,45 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectLibrary
|
namespace ProjectLibrary
|
||||||
{
|
{
|
||||||
public partial class FormLibrary : Form
|
public partial class FormLibrary : Form
|
||||||
{
|
{
|
||||||
public FormLibrary()
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormLibrary(IUnityContainer container)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_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
|
||||||
|
{
|
||||||
|
_container.Resolve<Forms.FReaders>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void çàêàçàòüÊíèãèToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<Forms.FOrders>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
101
ProjectLibrary/Forms/FBook_Orders.Designer.cs
generated
101
ProjectLibrary/Forms/FBook_Orders.Designer.cs
generated
@ -1,101 +0,0 @@
|
|||||||
namespace ProjectLibrary.Forms
|
|
||||||
{
|
|
||||||
partial class FBook_Orders
|
|
||||||
{
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
private Label lblBookID;
|
|
||||||
private TextBox txtBookID;
|
|
||||||
private Label lblOrderID;
|
|
||||||
private TextBox txtOrderID;
|
|
||||||
private Button btnSave;
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
lblBookID = new Label();
|
|
||||||
txtBookID = new TextBox();
|
|
||||||
lblOrderID = new Label();
|
|
||||||
txtOrderID = 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(100, 20);
|
|
||||||
txtBookID.Name = "txtBookID";
|
|
||||||
txtBookID.ReadOnly = true;
|
|
||||||
txtBookID.Size = new Size(200, 27);
|
|
||||||
txtBookID.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// lblOrderID
|
|
||||||
//
|
|
||||||
lblOrderID.AutoSize = true;
|
|
||||||
lblOrderID.Location = new Point(20, 60);
|
|
||||||
lblOrderID.Name = "lblOrderID";
|
|
||||||
lblOrderID.Size = new Size(76, 20);
|
|
||||||
lblOrderID.TabIndex = 2;
|
|
||||||
lblOrderID.Text = "ID заказа:";
|
|
||||||
//
|
|
||||||
// txtOrderID
|
|
||||||
//
|
|
||||||
txtOrderID.Location = new Point(100, 60);
|
|
||||||
txtOrderID.Name = "txtOrderID";
|
|
||||||
txtOrderID.ReadOnly = true;
|
|
||||||
txtOrderID.Size = new Size(200, 27);
|
|
||||||
txtOrderID.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// btnSave
|
|
||||||
//
|
|
||||||
btnSave.Location = new Point(20, 93);
|
|
||||||
btnSave.Name = "btnSave";
|
|
||||||
btnSave.Size = new Size(100, 30);
|
|
||||||
btnSave.TabIndex = 4;
|
|
||||||
btnSave.Text = "Сохранить";
|
|
||||||
btnSave.Click += btnSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel_Click
|
|
||||||
//
|
|
||||||
buttonCancel_Click.Location = new Point(200, 93);
|
|
||||||
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_Orders
|
|
||||||
//
|
|
||||||
ClientSize = new Size(400, 200);
|
|
||||||
Controls.Add(buttonCancel_Click);
|
|
||||||
Controls.Add(lblBookID);
|
|
||||||
Controls.Add(txtBookID);
|
|
||||||
Controls.Add(lblOrderID);
|
|
||||||
Controls.Add(txtOrderID);
|
|
||||||
Controls.Add(btnSave);
|
|
||||||
Name = "FBook_Orders";
|
|
||||||
Text = "Книга и заказ";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Button buttonCancel_Click;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using ProjectLibrary.Entites;
|
|
||||||
|
|
||||||
namespace ProjectLibrary.Forms
|
|
||||||
{
|
|
||||||
public partial class FBook_Orders : Form
|
|
||||||
{
|
|
||||||
private Book_Orders _bookOrders;
|
|
||||||
|
|
||||||
public FBook_Orders(Book_Orders bookOrders)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_bookOrders = bookOrders;
|
|
||||||
LoadOrderData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadOrderData()
|
|
||||||
{
|
|
||||||
txtBookID.Text = _bookOrders.BookID.ToString();
|
|
||||||
txtOrderID.Text = _bookOrders.OrderID.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// Создание новой сущности с обновленными данными
|
|
||||||
var updatedBookOrders = Book_Orders.CreateEntity(
|
|
||||||
int.Parse(txtBookID.Text),
|
|
||||||
int.Parse(txtOrderID.Text)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Обновление внутренней переменной
|
|
||||||
_bookOrders = updatedBookOrders;
|
|
||||||
|
|
||||||
MessageBox.Show("Данные успешно сохранены!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// Закрытие формы без сохранения
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,17 +24,7 @@ namespace ProjectLibrary.Forms
|
|||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Создание новой сущности с обновленными данными
|
|
||||||
var updatedLibrary = Library.CreateEntity(
|
|
||||||
int.Parse(txtId.Text),
|
|
||||||
txtName.Text,
|
|
||||||
txtAddress.Text
|
|
||||||
);
|
|
||||||
|
|
||||||
// Обновление внутренней переменной
|
|
||||||
_library = updatedLibrary;
|
|
||||||
|
|
||||||
MessageBox.Show("Данные успешно сохранены!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
||||||
|
157
ProjectLibrary/Forms/FOrder.Designer.cs
generated
Normal file
157
ProjectLibrary/Forms/FOrder.Designer.cs
generated
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
namespace ProjectLibrary.Forms
|
||||||
|
{
|
||||||
|
partial class FOrder
|
||||||
|
{
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
private Label lblOrderDate;
|
||||||
|
private TextBox txtOrderDate;
|
||||||
|
private Label lblReturnDate;
|
||||||
|
private TextBox txtReturnDate;
|
||||||
|
private Label lblReaderID;
|
||||||
|
private Label lblBookID;
|
||||||
|
private Button btnSave;
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
lblOrderDate = new Label();
|
||||||
|
txtOrderDate = new TextBox();
|
||||||
|
lblReturnDate = new Label();
|
||||||
|
txtReturnDate = new TextBox();
|
||||||
|
lblReaderID = new Label();
|
||||||
|
lblBookID = new Label();
|
||||||
|
btnSave = new Button();
|
||||||
|
buttonCancel_Click = new Button();
|
||||||
|
comboBox1 = new ComboBox();
|
||||||
|
dataGridViewIDBook = new DataGridView();
|
||||||
|
Book = new DataGridViewComboBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewIDBook).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblOrderDate
|
||||||
|
//
|
||||||
|
lblOrderDate.AutoSize = true;
|
||||||
|
lblOrderDate.Location = new Point(12, 25);
|
||||||
|
lblOrderDate.Name = "lblOrderDate";
|
||||||
|
lblOrderDate.Size = new Size(93, 20);
|
||||||
|
lblOrderDate.TabIndex = 2;
|
||||||
|
lblOrderDate.Text = "Дата заказа:";
|
||||||
|
//
|
||||||
|
// txtOrderDate
|
||||||
|
//
|
||||||
|
txtOrderDate.Location = new Point(129, 25);
|
||||||
|
txtOrderDate.Name = "txtOrderDate";
|
||||||
|
txtOrderDate.Size = new Size(200, 27);
|
||||||
|
txtOrderDate.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// lblReturnDate
|
||||||
|
//
|
||||||
|
lblReturnDate.AutoSize = true;
|
||||||
|
lblReturnDate.Location = new Point(12, 65);
|
||||||
|
lblReturnDate.Name = "lblReturnDate";
|
||||||
|
lblReturnDate.Size = new Size(111, 20);
|
||||||
|
lblReturnDate.TabIndex = 4;
|
||||||
|
lblReturnDate.Text = "Дата возврата:";
|
||||||
|
//
|
||||||
|
// txtReturnDate
|
||||||
|
//
|
||||||
|
txtReturnDate.Location = new Point(129, 65);
|
||||||
|
txtReturnDate.Name = "txtReturnDate";
|
||||||
|
txtReturnDate.Size = new Size(200, 27);
|
||||||
|
txtReturnDate.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// lblReaderID
|
||||||
|
//
|
||||||
|
lblReaderID.AutoSize = true;
|
||||||
|
lblReaderID.Location = new Point(12, 105);
|
||||||
|
lblReaderID.Name = "lblReaderID";
|
||||||
|
lblReaderID.Size = new Size(92, 20);
|
||||||
|
lblReaderID.TabIndex = 6;
|
||||||
|
lblReaderID.Text = "ID читателя:";
|
||||||
|
//
|
||||||
|
// lblBookID
|
||||||
|
//
|
||||||
|
lblBookID.AutoSize = true;
|
||||||
|
lblBookID.Location = new Point(12, 145);
|
||||||
|
lblBookID.Name = "lblBookID";
|
||||||
|
lblBookID.Size = new Size(71, 20);
|
||||||
|
lblBookID.TabIndex = 8;
|
||||||
|
lblBookID.Text = "ID книги:";
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Location = new Point(23, 238);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(100, 30);
|
||||||
|
btnSave.TabIndex = 10;
|
||||||
|
btnSave.Text = "Сохранить";
|
||||||
|
btnSave.Click += ButtonSave_Click;
|
||||||
|
|
||||||
|
//
|
||||||
|
// buttonCancel_Click
|
||||||
|
//
|
||||||
|
buttonCancel_Click.Location = new Point(232, 238);
|
||||||
|
buttonCancel_Click.Name = "buttonCancel_Click";
|
||||||
|
buttonCancel_Click.Size = new Size(100, 30);
|
||||||
|
buttonCancel_Click.TabIndex = 11;
|
||||||
|
buttonCancel_Click.Text = "Отмена";
|
||||||
|
buttonCancel_Click.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// comboBox1
|
||||||
|
//
|
||||||
|
comboBox1.Location = new Point(129, 108);
|
||||||
|
comboBox1.Name = "comboBox1";
|
||||||
|
comboBox1.Size = new Size(203, 28);
|
||||||
|
comboBox1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dataGridViewIDBook
|
||||||
|
//
|
||||||
|
dataGridViewIDBook.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridViewIDBook.Columns.AddRange(new DataGridViewColumn[] { Book });
|
||||||
|
dataGridViewIDBook.Location = new Point(129, 151);
|
||||||
|
dataGridViewIDBook.Name = "dataGridViewIDBook";
|
||||||
|
dataGridViewIDBook.RowHeadersWidth = 51;
|
||||||
|
dataGridViewIDBook.Size = new Size(200, 81);
|
||||||
|
dataGridViewIDBook.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// Book
|
||||||
|
//
|
||||||
|
Book.HeaderText = "Book";
|
||||||
|
Book.MinimumWidth = 6;
|
||||||
|
Book.Name = "Book";
|
||||||
|
Book.Width = 125;
|
||||||
|
//
|
||||||
|
// FOrders
|
||||||
|
//
|
||||||
|
ClientSize = new Size(372, 332);
|
||||||
|
Controls.Add(dataGridViewIDBook);
|
||||||
|
Controls.Add(comboBox1);
|
||||||
|
Controls.Add(buttonCancel_Click);
|
||||||
|
Controls.Add(lblOrderDate);
|
||||||
|
Controls.Add(txtOrderDate);
|
||||||
|
Controls.Add(lblReturnDate);
|
||||||
|
Controls.Add(txtReturnDate);
|
||||||
|
Controls.Add(lblReaderID);
|
||||||
|
Controls.Add(lblBookID);
|
||||||
|
Controls.Add(btnSave);
|
||||||
|
Name = "FOrders";
|
||||||
|
Text = "Заказы";
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewIDBook).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button buttonCancel_Click;
|
||||||
|
private ComboBox comboBox1;
|
||||||
|
private DataGridView dataGridViewIDBook;
|
||||||
|
private DataGridViewComboBoxColumn Book;
|
||||||
|
}
|
||||||
|
}
|
122
ProjectLibrary/Forms/FOrder.cs
Normal file
122
ProjectLibrary/Forms/FOrder.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
using ProjectLibrary.Repositories;
|
||||||
|
using Unity;
|
||||||
|
using ProjectLibrary.Entites;
|
||||||
|
|
||||||
|
namespace ProjectLibrary.Forms
|
||||||
|
{
|
||||||
|
public partial class FOrder : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
|
|
||||||
|
private int? _orderId;
|
||||||
|
|
||||||
|
public FOrder(IUnityContainer container, IOrderRepository orderRepository, IBookOrderRepository bookOrderRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FOrder_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_orderId.HasValue)
|
||||||
|
{
|
||||||
|
LoadOrderData(_orderId.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int OrderID
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_orderId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadOrderData(int orderId)
|
||||||
|
{
|
||||||
|
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>();
|
||||||
|
foreach (DataGridViewRow row in dataGridViewIDBook.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnMaterials"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(Book_Orders.CreateEntity(0, Convert.ToInt32(row.Cells["ColumnMaterials"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(txtOrderDate.Text) || string.IsNullOrWhiteSpace(txtReturnDate.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Не все поля заполнены.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var updatedOrder = Orders.CreateEntity(
|
||||||
|
_orderId ?? 0,
|
||||||
|
DateTime.Parse(txtOrderDate.Text),
|
||||||
|
DateTime.Parse(txtReturnDate.Text),
|
||||||
|
int.Parse(comboBox1.SelectedItem.ToString()),
|
||||||
|
CreateListMaterialFromDataGrid()
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
if (_orderId.HasValue)
|
||||||
|
{
|
||||||
|
_orderRepository.UpdateOrder(updatedOrder);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_orderRepository.CreateOrder(updatedOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Данные успешно сохранены.", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,4 +117,7 @@
|
|||||||
<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>
|
||||||
</root>
|
</root>
|
197
ProjectLibrary/Forms/FOrders.Designer.cs
generated
197
ProjectLibrary/Forms/FOrders.Designer.cs
generated
@ -2,20 +2,15 @@
|
|||||||
{
|
{
|
||||||
partial class FOrders
|
partial class FOrders
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
private Label lblOrderID;
|
/// <summary>
|
||||||
private TextBox txtOrderID;
|
/// Clean up any resources being used.
|
||||||
private Label lblOrderDate;
|
/// </summary>
|
||||||
private TextBox txtOrderDate;
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
private Label lblReturnDate;
|
|
||||||
private TextBox txtReturnDate;
|
|
||||||
private Label lblReaderID;
|
|
||||||
private TextBox txtReaderID;
|
|
||||||
private Label lblBookID;
|
|
||||||
private TextBox txtBookID;
|
|
||||||
private Button btnSave;
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && (components != null))
|
if (disposing && (components != null))
|
||||||
@ -25,143 +20,81 @@
|
|||||||
base.Dispose(disposing);
|
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()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
lblOrderID = new Label();
|
dataGridViewOrders = new DataGridView();
|
||||||
txtOrderID = new TextBox();
|
buttonAdd = new Button();
|
||||||
lblOrderDate = new Label();
|
buttonUpdate = new Button();
|
||||||
txtOrderDate = new TextBox();
|
buttonRemove = new Button();
|
||||||
lblReturnDate = new Label();
|
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit();
|
||||||
txtReturnDate = new TextBox();
|
|
||||||
lblReaderID = new Label();
|
|
||||||
txtReaderID = new TextBox();
|
|
||||||
lblBookID = new Label();
|
|
||||||
txtBookID = new TextBox();
|
|
||||||
btnSave = new Button();
|
|
||||||
buttonCancel_Click = new Button();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// lblOrderID
|
// dataGridViewOrders
|
||||||
//
|
//
|
||||||
lblOrderID.AutoSize = true;
|
dataGridViewOrders.AllowUserToAddRows = false;
|
||||||
lblOrderID.Location = new Point(20, 20);
|
dataGridViewOrders.AllowUserToDeleteRows = false;
|
||||||
lblOrderID.Name = "lblOrderID";
|
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
lblOrderID.Size = new Size(76, 20);
|
dataGridViewOrders.Location = new Point(12, 12);
|
||||||
lblOrderID.TabIndex = 0;
|
dataGridViewOrders.Name = "dataGridViewOrders";
|
||||||
lblOrderID.Text = "ID заказа:";
|
dataGridViewOrders.ReadOnly = true;
|
||||||
|
dataGridViewOrders.RowHeadersWidth = 51;
|
||||||
|
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridViewOrders.Size = new Size(600, 300);
|
||||||
|
dataGridViewOrders.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// txtOrderID
|
// buttonAdd
|
||||||
//
|
//
|
||||||
txtOrderID.Location = new Point(137, 20);
|
buttonAdd.Location = new Point(12, 332);
|
||||||
txtOrderID.Name = "txtOrderID";
|
buttonAdd.Name = "buttonAdd";
|
||||||
txtOrderID.ReadOnly = true;
|
buttonAdd.Size = new Size(100, 30);
|
||||||
txtOrderID.Size = new Size(200, 27);
|
buttonAdd.TabIndex = 5;
|
||||||
txtOrderID.TabIndex = 1;
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
//
|
//
|
||||||
// lblOrderDate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
lblOrderDate.AutoSize = true;
|
buttonUpdate.Location = new Point(132, 332);
|
||||||
lblOrderDate.Location = new Point(20, 60);
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
lblOrderDate.Name = "lblOrderDate";
|
buttonUpdate.Size = new Size(100, 30);
|
||||||
lblOrderDate.Size = new Size(93, 20);
|
buttonUpdate.TabIndex = 6;
|
||||||
lblOrderDate.TabIndex = 2;
|
buttonUpdate.Text = "Изменить";
|
||||||
lblOrderDate.Text = "Дата заказа:";
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
//
|
//
|
||||||
// txtOrderDate
|
// buttonRemove
|
||||||
//
|
//
|
||||||
txtOrderDate.Location = new Point(137, 60);
|
buttonRemove.Location = new Point(252, 332);
|
||||||
txtOrderDate.Name = "txtOrderDate";
|
buttonRemove.Name = "buttonRemove";
|
||||||
txtOrderDate.Size = new Size(200, 27);
|
buttonRemove.Size = new Size(100, 30);
|
||||||
txtOrderDate.TabIndex = 3;
|
buttonRemove.TabIndex = 7;
|
||||||
//
|
buttonRemove.Text = "Удалить";
|
||||||
// lblReturnDate
|
buttonRemove.Click += buttonRemove_Click;
|
||||||
//
|
|
||||||
lblReturnDate.AutoSize = true;
|
|
||||||
lblReturnDate.Location = new Point(20, 100);
|
|
||||||
lblReturnDate.Name = "lblReturnDate";
|
|
||||||
lblReturnDate.Size = new Size(111, 20);
|
|
||||||
lblReturnDate.TabIndex = 4;
|
|
||||||
lblReturnDate.Text = "Дата возврата:";
|
|
||||||
//
|
|
||||||
// txtReturnDate
|
|
||||||
//
|
|
||||||
txtReturnDate.Location = new Point(137, 100);
|
|
||||||
txtReturnDate.Name = "txtReturnDate";
|
|
||||||
txtReturnDate.Size = new Size(200, 27);
|
|
||||||
txtReturnDate.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// lblReaderID
|
|
||||||
//
|
|
||||||
lblReaderID.AutoSize = true;
|
|
||||||
lblReaderID.Location = new Point(20, 140);
|
|
||||||
lblReaderID.Name = "lblReaderID";
|
|
||||||
lblReaderID.Size = new Size(92, 20);
|
|
||||||
lblReaderID.TabIndex = 6;
|
|
||||||
lblReaderID.Text = "ID читателя:";
|
|
||||||
//
|
|
||||||
// txtReaderID
|
|
||||||
//
|
|
||||||
txtReaderID.Location = new Point(137, 140);
|
|
||||||
txtReaderID.Name = "txtReaderID";
|
|
||||||
txtReaderID.Size = new Size(200, 27);
|
|
||||||
txtReaderID.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// lblBookID
|
|
||||||
//
|
|
||||||
lblBookID.AutoSize = true;
|
|
||||||
lblBookID.Location = new Point(20, 180);
|
|
||||||
lblBookID.Name = "lblBookID";
|
|
||||||
lblBookID.Size = new Size(71, 20);
|
|
||||||
lblBookID.TabIndex = 8;
|
|
||||||
lblBookID.Text = "ID книги:";
|
|
||||||
//
|
|
||||||
// txtBookID
|
|
||||||
//
|
|
||||||
txtBookID.Location = new Point(137, 177);
|
|
||||||
txtBookID.Name = "txtBookID";
|
|
||||||
txtBookID.ReadOnly = true;
|
|
||||||
txtBookID.Size = new Size(200, 27);
|
|
||||||
txtBookID.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// btnSave
|
|
||||||
//
|
|
||||||
btnSave.Location = new Point(20, 222);
|
|
||||||
btnSave.Name = "btnSave";
|
|
||||||
btnSave.Size = new Size(100, 30);
|
|
||||||
btnSave.TabIndex = 10;
|
|
||||||
btnSave.Text = "Сохранить";
|
|
||||||
btnSave.Click += btnSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel_Click
|
|
||||||
//
|
|
||||||
buttonCancel_Click.Location = new Point(237, 222);
|
|
||||||
buttonCancel_Click.Name = "buttonCancel_Click";
|
|
||||||
buttonCancel_Click.Size = new Size(100, 30);
|
|
||||||
buttonCancel_Click.TabIndex = 11;
|
|
||||||
buttonCancel_Click.Text = "Отмена";
|
|
||||||
buttonCancel_Click.Click += buttonCancel_Click_Click;
|
|
||||||
//
|
//
|
||||||
// FOrders
|
// FOrders
|
||||||
//
|
//
|
||||||
ClientSize = new Size(400, 300);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
Controls.Add(buttonCancel_Click);
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
Controls.Add(lblOrderID);
|
ClientSize = new Size(630, 412);
|
||||||
Controls.Add(txtOrderID);
|
Controls.Add(dataGridViewOrders);
|
||||||
Controls.Add(lblOrderDate);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(txtOrderDate);
|
Controls.Add(buttonUpdate);
|
||||||
Controls.Add(lblReturnDate);
|
Controls.Add(buttonRemove);
|
||||||
Controls.Add(txtReturnDate);
|
|
||||||
Controls.Add(lblReaderID);
|
|
||||||
Controls.Add(txtReaderID);
|
|
||||||
Controls.Add(lblBookID);
|
|
||||||
Controls.Add(txtBookID);
|
|
||||||
Controls.Add(btnSave);
|
|
||||||
Name = "FOrders";
|
Name = "FOrders";
|
||||||
Text = "Заказы";
|
Text = "FOrders";
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button buttonCancel_Click;
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridViewOrders;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonRemove;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,57 +1,95 @@
|
|||||||
using System;
|
using ProjectLibrary.Entites;
|
||||||
|
using ProjectLibrary.Repositories;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ProjectLibrary.Entites;
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectLibrary.Forms
|
namespace ProjectLibrary.Forms
|
||||||
{
|
{
|
||||||
public partial class FOrders : Form
|
public partial class FOrders : Form
|
||||||
{
|
{
|
||||||
private Orders _order;
|
private readonly IUnityContainer _container;
|
||||||
private Book_Orders _bookOrder;
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
public FOrders(Orders order, Book_Orders bookOrder)
|
public FOrders(IUnityContainer container, IOrderRepository orderRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_order = order;
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
_bookOrder = bookOrder;
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
LoadOrderData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadOrderData()
|
private void LoadList()
|
||||||
{
|
{
|
||||||
txtOrderID.Text = _order.Id.ToString();
|
dataGridViewOrders.DataSource = _orderRepository.ReadOrders();
|
||||||
txtOrderDate.Text = _order.OrderDate.ToString();
|
|
||||||
txtReturnDate.Text = _order.ReturnDate.ToString();
|
|
||||||
txtReaderID.Text = _order.ReaderID.ToString();
|
|
||||||
txtBookID.Text = _bookOrder.BookID.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Создание обновленных данных
|
|
||||||
var updatedOrder = Orders.CreateEntity(
|
|
||||||
int.Parse(txtOrderID.Text),
|
|
||||||
int.Parse(txtOrderDate.Text),
|
|
||||||
int.Parse(txtReturnDate.Text),
|
|
||||||
int.Parse(txtReaderID.Text)
|
|
||||||
);
|
|
||||||
|
|
||||||
var updatedBookOrder = Book_Orders.CreateEntity(
|
try
|
||||||
int.Parse(txtBookID.Text),
|
{
|
||||||
int.Parse(txtOrderID.Text)
|
_container.Resolve<FOrder>().ShowDialog();
|
||||||
);
|
LoadList();
|
||||||
|
}
|
||||||
// Обновление объектов
|
catch (Exception ex)
|
||||||
_order = updatedOrder;
|
{
|
||||||
_bookOrder = updatedBookOrder;
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
MessageBox.Show("Данные успешно сохранены!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
// Закрытие формы без сохранения
|
id = 0;
|
||||||
this.Close();
|
if (dataGridViewOrders.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FReader>();
|
||||||
|
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
|
||||||
|
{
|
||||||
|
_orderRepository.DeleteOrder(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
68
ProjectLibrary/Forms/FReader.Designer.cs
generated
68
ProjectLibrary/Forms/FReader.Designer.cs
generated
@ -3,15 +3,10 @@
|
|||||||
partial class FReader
|
partial class FReader
|
||||||
{
|
{
|
||||||
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 lblReaderTicket;
|
private Label lblReaderTicket;
|
||||||
private TextBox txtReaderTicket;
|
private TextBox txtReaderTicket;
|
||||||
private Label lblRegistrationDate;
|
|
||||||
private TextBox txtRegistrationDate;
|
|
||||||
private Button btnSave;
|
private Button btnSave;
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
@ -25,39 +20,18 @@
|
|||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
lblId = new Label();
|
|
||||||
txtId = new TextBox();
|
|
||||||
lblName = new Label();
|
lblName = new Label();
|
||||||
txtName = new TextBox();
|
txtName = new TextBox();
|
||||||
lblReaderTicket = new Label();
|
lblReaderTicket = new Label();
|
||||||
txtReaderTicket = new TextBox();
|
txtReaderTicket = new TextBox();
|
||||||
lblRegistrationDate = new Label();
|
|
||||||
txtRegistrationDate = new TextBox();
|
|
||||||
btnSave = new Button();
|
btnSave = new Button();
|
||||||
buttonCancel_Click = new Button();
|
buttonCancel_Click = new Button();
|
||||||
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(177, 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(22, 22);
|
||||||
lblName.Name = "lblName";
|
lblName.Name = "lblName";
|
||||||
lblName.Size = new Size(42, 20);
|
lblName.Size = new Size(42, 20);
|
||||||
lblName.TabIndex = 2;
|
lblName.TabIndex = 2;
|
||||||
@ -65,15 +39,15 @@
|
|||||||
//
|
//
|
||||||
// txtName
|
// txtName
|
||||||
//
|
//
|
||||||
txtName.Location = new Point(177, 60);
|
txtName.Location = new Point(179, 22);
|
||||||
txtName.Name = "txtName";
|
txtName.Name = "txtName";
|
||||||
txtName.Size = new Size(200, 27);
|
txtName.Size = new Size(238, 27);
|
||||||
txtName.TabIndex = 3;
|
txtName.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// lblReaderTicket
|
// lblReaderTicket
|
||||||
//
|
//
|
||||||
lblReaderTicket.AutoSize = true;
|
lblReaderTicket.AutoSize = true;
|
||||||
lblReaderTicket.Location = new Point(20, 100);
|
lblReaderTicket.Location = new Point(22, 62);
|
||||||
lblReaderTicket.Name = "lblReaderTicket";
|
lblReaderTicket.Name = "lblReaderTicket";
|
||||||
lblReaderTicket.Size = new Size(151, 20);
|
lblReaderTicket.Size = new Size(151, 20);
|
||||||
lblReaderTicket.TabIndex = 4;
|
lblReaderTicket.TabIndex = 4;
|
||||||
@ -81,57 +55,37 @@
|
|||||||
//
|
//
|
||||||
// txtReaderTicket
|
// txtReaderTicket
|
||||||
//
|
//
|
||||||
txtReaderTicket.Location = new Point(177, 100);
|
txtReaderTicket.Location = new Point(179, 62);
|
||||||
txtReaderTicket.Name = "txtReaderTicket";
|
txtReaderTicket.Name = "txtReaderTicket";
|
||||||
txtReaderTicket.Size = new Size(200, 27);
|
txtReaderTicket.Size = new Size(238, 27);
|
||||||
txtReaderTicket.TabIndex = 5;
|
txtReaderTicket.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// lblRegistrationDate
|
|
||||||
//
|
|
||||||
lblRegistrationDate.AutoSize = true;
|
|
||||||
lblRegistrationDate.Location = new Point(20, 140);
|
|
||||||
lblRegistrationDate.Name = "lblRegistrationDate";
|
|
||||||
lblRegistrationDate.Size = new Size(137, 20);
|
|
||||||
lblRegistrationDate.TabIndex = 6;
|
|
||||||
lblRegistrationDate.Text = "Дата регистрации:";
|
|
||||||
//
|
|
||||||
// txtRegistrationDate
|
|
||||||
//
|
|
||||||
txtRegistrationDate.Location = new Point(177, 140);
|
|
||||||
txtRegistrationDate.Name = "txtRegistrationDate";
|
|
||||||
txtRegistrationDate.Size = new Size(200, 27);
|
|
||||||
txtRegistrationDate.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// btnSave
|
// btnSave
|
||||||
//
|
//
|
||||||
btnSave.Location = new Point(20, 181);
|
btnSave.Location = new Point(22, 111);
|
||||||
btnSave.Name = "btnSave";
|
btnSave.Name = "btnSave";
|
||||||
btnSave.Size = new Size(100, 30);
|
btnSave.Size = new Size(100, 30);
|
||||||
btnSave.TabIndex = 8;
|
btnSave.TabIndex = 8;
|
||||||
btnSave.Text = "Сохранить";
|
btnSave.Text = "Сохранить";
|
||||||
btnSave.Click += btnSave_Click;
|
btnSave.Click += SaveBtn_Click;
|
||||||
//
|
//
|
||||||
// buttonCancel_Click
|
// buttonCancel_Click
|
||||||
//
|
//
|
||||||
buttonCancel_Click.Location = new Point(277, 181);
|
buttonCancel_Click.Location = new Point(317, 111);
|
||||||
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 += DiscardBtn_Click;
|
||||||
//
|
//
|
||||||
// FReader
|
// FReader
|
||||||
//
|
//
|
||||||
ClientSize = new Size(400, 250);
|
ClientSize = new Size(438, 180);
|
||||||
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(lblReaderTicket);
|
Controls.Add(lblReaderTicket);
|
||||||
Controls.Add(txtReaderTicket);
|
Controls.Add(txtReaderTicket);
|
||||||
Controls.Add(lblRegistrationDate);
|
|
||||||
Controls.Add(txtRegistrationDate);
|
|
||||||
Controls.Add(btnSave);
|
Controls.Add(btnSave);
|
||||||
Name = "FReader";
|
Name = "FReader";
|
||||||
Text = "Читатель";
|
Text = "Читатель";
|
||||||
|
@ -1,49 +1,89 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml.Linq;
|
|
||||||
using ProjectLibrary.Entities;
|
using ProjectLibrary.Entities;
|
||||||
|
using ProjectLibrary.Repositories;
|
||||||
|
|
||||||
namespace ProjectLibrary.Forms
|
namespace ProjectLibrary.Forms
|
||||||
{
|
{
|
||||||
public partial class FReader : Form
|
public partial class FReader : Form
|
||||||
{
|
{
|
||||||
private Reader _reader;
|
private readonly IReaderRepository _readerRepository; // Интерфейс для работы с репозиторием
|
||||||
|
private int? _readerId;
|
||||||
|
|
||||||
public FReader(Reader reader)
|
public int ID
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var reader = _readerRepository.GetReaderById(value);
|
||||||
|
|
||||||
|
if (reader == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Reader with ID {value} not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
txtName.Text = reader.Name;
|
||||||
|
txtReaderTicket.Text = reader.ReaderTicket.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
_readerId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error : wrong data ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FReader(IReaderRepository readerRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_reader = reader;
|
_readerRepository = readerRepository ?? throw new ArgumentNullException(nameof(readerRepository));
|
||||||
LoadReaderData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadReaderData()
|
private void SaveBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
txtId.Text = _reader.Id.ToString();
|
try
|
||||||
txtName.Text = _reader.Name;
|
{
|
||||||
txtReaderTicket.Text = _reader.ReaderTicket.ToString();
|
if (string.IsNullOrWhiteSpace(txtName.Text) || string.IsNullOrWhiteSpace(txtReaderTicket.Text))
|
||||||
txtRegistrationDate.Text = _reader.RegistrationDateRT.ToShortDateString();
|
{
|
||||||
|
throw new Exception("[ Error : blank spaces were left, not enough information ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
var reader = CreateReader();
|
||||||
|
|
||||||
|
if (_readerId.HasValue)
|
||||||
{
|
{
|
||||||
// Создание новой сущности с обновленными данными
|
_readerRepository.UpdateReader(reader);
|
||||||
var updatedReader = Reader.CreateEntity(
|
}
|
||||||
int.Parse(txtId.Text),
|
else
|
||||||
|
{
|
||||||
|
_readerRepository.AddReader(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Данные успешно сохранены!", "[ Success ]", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error : while saving ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DiscardBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Reader CreateReader()
|
||||||
|
{
|
||||||
|
return Reader.CreateEntity(
|
||||||
|
_readerId ?? 0,
|
||||||
txtName.Text,
|
txtName.Text,
|
||||||
int.Parse(txtReaderTicket.Text),
|
int.Parse(txtReaderTicket.Text)
|
||||||
DateTime.Parse(txtRegistrationDate.Text)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Обновление внутренней переменной
|
|
||||||
_reader = updatedReader;
|
|
||||||
|
|
||||||
MessageBox.Show("Данные успешно сохранены!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// Закрытие формы без сохранения
|
|
||||||
this.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
72
ProjectLibrary/Forms/FReaders.Designer.cs
generated
Normal file
72
ProjectLibrary/Forms/FReaders.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
namespace ProjectLibrary.Forms
|
||||||
|
{
|
||||||
|
partial class FReaders
|
||||||
|
{
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
private DataGridView dataGridViewReaders;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonRemove;
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.dataGridViewReaders = new DataGridView();
|
||||||
|
this.buttonAdd = new Button();
|
||||||
|
this.buttonUpdate = new Button();
|
||||||
|
this.buttonRemove = new Button();
|
||||||
|
|
||||||
|
this.SuspendLayout();
|
||||||
|
|
||||||
|
// dataGridViewReaders
|
||||||
|
this.dataGridViewReaders.AllowUserToAddRows = false;
|
||||||
|
this.dataGridViewReaders.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridViewReaders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridViewReaders.Location = new System.Drawing.Point(20, 20);
|
||||||
|
this.dataGridViewReaders.Name = "dataGridViewReaders";
|
||||||
|
this.dataGridViewReaders.ReadOnly = true;
|
||||||
|
this.dataGridViewReaders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
this.dataGridViewReaders.Size = new System.Drawing.Size(600, 300);
|
||||||
|
this.Controls.Add(this.dataGridViewReaders);
|
||||||
|
|
||||||
|
// buttonAdd
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(20, 340);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(100, 30);
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.Click += new EventHandler(this.ButtonAdd_Click);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
|
||||||
|
// buttonUpdate
|
||||||
|
this.buttonUpdate.Location = new System.Drawing.Point(140, 340);
|
||||||
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
|
this.buttonUpdate.Size = new System.Drawing.Size(100, 30);
|
||||||
|
this.buttonUpdate.Text = "Изменить";
|
||||||
|
this.buttonUpdate.Click += new EventHandler(this.ButtonUpdate_Click);
|
||||||
|
this.Controls.Add(this.buttonUpdate);
|
||||||
|
|
||||||
|
// buttonRemove
|
||||||
|
this.buttonRemove.Location = new System.Drawing.Point(260, 340);
|
||||||
|
this.buttonRemove.Name = "buttonRemove";
|
||||||
|
this.buttonRemove.Size = new System.Drawing.Size(100, 30);
|
||||||
|
this.buttonRemove.Text = "Удалить";
|
||||||
|
this.buttonRemove.Click += new EventHandler(this.ButtonRemove_Click);
|
||||||
|
this.Controls.Add(this.buttonRemove);
|
||||||
|
|
||||||
|
// FReaders
|
||||||
|
this.ClientSize = new System.Drawing.Size(650, 400);
|
||||||
|
this.Name = "FReaders";
|
||||||
|
this.Text = "Список читателей";
|
||||||
|
this.Load += new EventHandler(this.FReaders_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
104
ProjectLibrary/Forms/FReaders.cs
Normal file
104
ProjectLibrary/Forms/FReaders.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using ProjectLibrary.Repositories;
|
||||||
|
using Unity;
|
||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ProjectLibrary.Forms
|
||||||
|
{
|
||||||
|
public partial class FReaders : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IReaderRepository _readerRepository;
|
||||||
|
|
||||||
|
public FReaders(IUnityContainer container, IReaderRepository readerRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_readerRepository = readerRepository ?? throw new ArgumentNullException(nameof(readerRepository));
|
||||||
|
}
|
||||||
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewReaders.DataSource = _readerRepository.ReadReaders();
|
||||||
|
}
|
||||||
|
private void FReaders_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FReader>().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
|
||||||
|
{
|
||||||
|
_readerRepository.DeleteReader(findId);
|
||||||
|
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<FReader>();
|
||||||
|
form.ID = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridViewReaders.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridViewReaders.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectLibrary/Forms/FReaders.resx
Normal file
120
ProjectLibrary/Forms/FReaders.resx
Normal 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>
|
88
ProjectLibrary/Forms/FTicket_Extension.Designer.cs
generated
88
ProjectLibrary/Forms/FTicket_Extension.Designer.cs
generated
@ -6,13 +6,12 @@
|
|||||||
|
|
||||||
private Label lblReaderID;
|
private Label lblReaderID;
|
||||||
private TextBox txtReaderID;
|
private TextBox txtReaderID;
|
||||||
private Label lblExtensionID;
|
|
||||||
private TextBox txtExtensionID;
|
|
||||||
private Label lblLastUpdateDate;
|
private Label lblLastUpdateDate;
|
||||||
private TextBox txtLastUpdateDate;
|
private DateTimePicker dtpLastUpdateDate;
|
||||||
private Label lblNextUpdateDate;
|
private Label lblNextUpdateDate;
|
||||||
private TextBox txtNextUpdateDate;
|
private DateTimePicker dtpNextUpdateDate;
|
||||||
private Button btnSave;
|
private Button btnSave;
|
||||||
|
private Button btnCancel;
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
@ -27,14 +26,12 @@
|
|||||||
{
|
{
|
||||||
lblReaderID = new Label();
|
lblReaderID = new Label();
|
||||||
txtReaderID = new TextBox();
|
txtReaderID = new TextBox();
|
||||||
lblExtensionID = new Label();
|
|
||||||
txtExtensionID = new TextBox();
|
|
||||||
lblLastUpdateDate = new Label();
|
lblLastUpdateDate = new Label();
|
||||||
txtLastUpdateDate = new TextBox();
|
dtpLastUpdateDate = new DateTimePicker();
|
||||||
lblNextUpdateDate = new Label();
|
lblNextUpdateDate = new Label();
|
||||||
txtNextUpdateDate = new TextBox();
|
dtpNextUpdateDate = new DateTimePicker();
|
||||||
btnSave = new Button();
|
btnSave = new Button();
|
||||||
buttonCancel_Click = new Button();
|
btnCancel = new Button();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// lblReaderID
|
// lblReaderID
|
||||||
@ -48,98 +45,77 @@
|
|||||||
//
|
//
|
||||||
// txtReaderID
|
// txtReaderID
|
||||||
//
|
//
|
||||||
txtReaderID.Location = new Point(255, 13);
|
txtReaderID.Location = new Point(140, 20);
|
||||||
txtReaderID.Name = "txtReaderID";
|
txtReaderID.Name = "txtReaderID";
|
||||||
txtReaderID.ReadOnly = true;
|
txtReaderID.ReadOnly = true;
|
||||||
txtReaderID.Size = new Size(200, 27);
|
txtReaderID.Size = new Size(200, 27);
|
||||||
txtReaderID.TabIndex = 1;
|
txtReaderID.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// lblExtensionID
|
|
||||||
//
|
|
||||||
lblExtensionID.AutoSize = true;
|
|
||||||
lblExtensionID.Location = new Point(20, 60);
|
|
||||||
lblExtensionID.Name = "lblExtensionID";
|
|
||||||
lblExtensionID.Size = new Size(110, 20);
|
|
||||||
lblExtensionID.TabIndex = 2;
|
|
||||||
lblExtensionID.Text = "ID Продления:";
|
|
||||||
//
|
|
||||||
// txtExtensionID
|
|
||||||
//
|
|
||||||
txtExtensionID.Location = new Point(255, 57);
|
|
||||||
txtExtensionID.Name = "txtExtensionID";
|
|
||||||
txtExtensionID.ReadOnly = true;
|
|
||||||
txtExtensionID.Size = new Size(200, 27);
|
|
||||||
txtExtensionID.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// lblLastUpdateDate
|
// lblLastUpdateDate
|
||||||
//
|
//
|
||||||
lblLastUpdateDate.AutoSize = true;
|
lblLastUpdateDate.AutoSize = true;
|
||||||
lblLastUpdateDate.Location = new Point(20, 100);
|
lblLastUpdateDate.Location = new Point(20, 64);
|
||||||
lblLastUpdateDate.Name = "lblLastUpdateDate";
|
lblLastUpdateDate.Name = "lblLastUpdateDate";
|
||||||
lblLastUpdateDate.Size = new Size(219, 20);
|
lblLastUpdateDate.Size = new Size(219, 20);
|
||||||
lblLastUpdateDate.TabIndex = 4;
|
lblLastUpdateDate.TabIndex = 4;
|
||||||
lblLastUpdateDate.Text = "Дата последнего обновления:";
|
lblLastUpdateDate.Text = "Дата последнего обновления:";
|
||||||
//
|
//
|
||||||
// txtLastUpdateDate
|
// dtpLastUpdateDate
|
||||||
//
|
//
|
||||||
txtLastUpdateDate.Location = new Point(255, 100);
|
dtpLastUpdateDate.Location = new Point(276, 59);
|
||||||
txtLastUpdateDate.Name = "txtLastUpdateDate";
|
dtpLastUpdateDate.Name = "dtpLastUpdateDate";
|
||||||
txtLastUpdateDate.Size = new Size(200, 27);
|
dtpLastUpdateDate.Size = new Size(200, 27);
|
||||||
txtLastUpdateDate.TabIndex = 5;
|
dtpLastUpdateDate.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// lblNextUpdateDate
|
// lblNextUpdateDate
|
||||||
//
|
//
|
||||||
lblNextUpdateDate.AutoSize = true;
|
lblNextUpdateDate.AutoSize = true;
|
||||||
lblNextUpdateDate.Location = new Point(20, 140);
|
lblNextUpdateDate.Location = new Point(20, 104);
|
||||||
lblNextUpdateDate.Name = "lblNextUpdateDate";
|
lblNextUpdateDate.Name = "lblNextUpdateDate";
|
||||||
lblNextUpdateDate.Size = new Size(223, 20);
|
lblNextUpdateDate.Size = new Size(223, 20);
|
||||||
lblNextUpdateDate.TabIndex = 6;
|
lblNextUpdateDate.TabIndex = 6;
|
||||||
lblNextUpdateDate.Text = "Дата следующего обновления:";
|
lblNextUpdateDate.Text = "Дата следующего обновления:";
|
||||||
//
|
//
|
||||||
// txtNextUpdateDate
|
// dtpNextUpdateDate
|
||||||
//
|
//
|
||||||
txtNextUpdateDate.Location = new Point(255, 140);
|
dtpNextUpdateDate.Location = new Point(276, 99);
|
||||||
txtNextUpdateDate.Name = "txtNextUpdateDate";
|
dtpNextUpdateDate.Name = "dtpNextUpdateDate";
|
||||||
txtNextUpdateDate.Size = new Size(200, 27);
|
dtpNextUpdateDate.Size = new Size(200, 27);
|
||||||
txtNextUpdateDate.TabIndex = 7;
|
dtpNextUpdateDate.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// btnSave
|
// btnSave
|
||||||
//
|
//
|
||||||
btnSave.Location = new Point(20, 178);
|
btnSave.Location = new Point(140, 164);
|
||||||
btnSave.Name = "btnSave";
|
btnSave.Name = "btnSave";
|
||||||
btnSave.Size = new Size(100, 30);
|
btnSave.Size = new Size(100, 30);
|
||||||
btnSave.TabIndex = 8;
|
btnSave.TabIndex = 8;
|
||||||
btnSave.Text = "Сохранить";
|
btnSave.Text = "Сохранить";
|
||||||
btnSave.Click += btnSave_Click;
|
btnSave.Click += SaveBtn_Click;
|
||||||
//
|
//
|
||||||
// buttonCancel_Click
|
// btnCancel
|
||||||
//
|
//
|
||||||
buttonCancel_Click.Location = new Point(355, 178);
|
btnCancel.Location = new Point(250, 164);
|
||||||
buttonCancel_Click.Name = "buttonCancel_Click";
|
btnCancel.Name = "btnCancel";
|
||||||
buttonCancel_Click.Size = new Size(100, 30);
|
btnCancel.Size = new Size(100, 30);
|
||||||
buttonCancel_Click.TabIndex = 9;
|
btnCancel.TabIndex = 9;
|
||||||
buttonCancel_Click.Text = "Отмена";
|
btnCancel.Text = "Отмена";
|
||||||
buttonCancel_Click.Click += buttonCancel_Click_Click;
|
btnCancel.Click += DiscardBtn_Click;
|
||||||
//
|
//
|
||||||
// FTicket_Extension
|
// FTicket_Extension
|
||||||
//
|
//
|
||||||
ClientSize = new Size(560, 250);
|
ClientSize = new Size(797, 250);
|
||||||
Controls.Add(buttonCancel_Click);
|
|
||||||
Controls.Add(lblReaderID);
|
Controls.Add(lblReaderID);
|
||||||
Controls.Add(txtReaderID);
|
Controls.Add(txtReaderID);
|
||||||
Controls.Add(lblExtensionID);
|
|
||||||
Controls.Add(txtExtensionID);
|
|
||||||
Controls.Add(lblLastUpdateDate);
|
Controls.Add(lblLastUpdateDate);
|
||||||
Controls.Add(txtLastUpdateDate);
|
Controls.Add(dtpLastUpdateDate);
|
||||||
Controls.Add(lblNextUpdateDate);
|
Controls.Add(lblNextUpdateDate);
|
||||||
Controls.Add(txtNextUpdateDate);
|
Controls.Add(dtpNextUpdateDate);
|
||||||
Controls.Add(btnSave);
|
Controls.Add(btnSave);
|
||||||
|
Controls.Add(btnCancel);
|
||||||
Name = "FTicket_Extension";
|
Name = "FTicket_Extension";
|
||||||
Text = "Продление билета";
|
Text = "Продление билета";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button buttonCancel_Click;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,48 +2,88 @@
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ProjectLibrary.Entites;
|
using ProjectLibrary.Entites;
|
||||||
using ProjectLibrary.Entities;
|
using ProjectLibrary.Entities;
|
||||||
|
using ProjectLibrary.Repositories;
|
||||||
|
|
||||||
namespace ProjectLibrary.Forms
|
namespace ProjectLibrary.Forms
|
||||||
{
|
{
|
||||||
public partial class FTicket_Extension : Form
|
public partial class FTicket_Extension : Form
|
||||||
{
|
{
|
||||||
private TicketExtensions _ticketExtensions;
|
private readonly ITicketExtensionsRepository _ticketExtensionsRepository;
|
||||||
|
private int? _extensionId;
|
||||||
|
|
||||||
public FTicket_Extension(TicketExtensions ticketExtensions)
|
public int ID
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ticketExtension = _ticketExtensionsRepository.GetTicketExtensionById(value);
|
||||||
|
|
||||||
|
if (ticketExtension == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Ticket extension with ID {value} not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
txtReaderID.Text = ticketExtension.ReaderID.ToString();
|
||||||
|
dtpLastUpdateDate.Value = ticketExtension.LastUpdateDate;
|
||||||
|
dtpNextUpdateDate.Value = ticketExtension.NextUpdateDate;
|
||||||
|
|
||||||
|
_extensionId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error : wrong data ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FTicket_Extension(ITicketExtensionsRepository ticketExtensionsRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_ticketExtensions = ticketExtensions;
|
_ticketExtensionsRepository = ticketExtensionsRepository ?? throw new ArgumentNullException(nameof(ticketExtensionsRepository));
|
||||||
LoadTicketExtensionData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadTicketExtensionData()
|
private void SaveBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
txtReaderID.Text = _ticketExtensions.ReaderID.ToString();
|
try
|
||||||
txtExtensionID.Text = _ticketExtensions.ExtensionID.ToString();
|
{
|
||||||
txtLastUpdateDate.Text = _ticketExtensions.LastUpdateDate.ToShortDateString();
|
if (string.IsNullOrWhiteSpace(txtReaderID.Text))
|
||||||
txtNextUpdateDate.Text = _ticketExtensions.NextUpdateDate.ToShortDateString();
|
{
|
||||||
|
throw new Exception("[ Error : blank spaces were left, not enough information ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnSave_Click(object sender, EventArgs e)
|
var ticketExtension = CreateTicketExtension();
|
||||||
|
|
||||||
|
if (_extensionId.HasValue)
|
||||||
{
|
{
|
||||||
// Создание новой сущности с обновленными данными
|
_ticketExtensionsRepository.UpdateTicketExtension(ticketExtension);
|
||||||
var updatedTicketExtensions = TicketExtensions.CreateEntity(
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ticketExtensionsRepository.AddTicketExtension(ticketExtension);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Данные успешно сохранены!", "[ Success ]", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error : while saving ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DiscardBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TicketExtensions CreateTicketExtension()
|
||||||
|
{
|
||||||
|
return TicketExtensions.CreateEntity(
|
||||||
int.Parse(txtReaderID.Text),
|
int.Parse(txtReaderID.Text),
|
||||||
int.Parse(txtExtensionID.Text),
|
dtpLastUpdateDate.Value,
|
||||||
DateTime.Parse(txtLastUpdateDate.Text),
|
dtpNextUpdateDate.Value
|
||||||
DateTime.Parse(txtNextUpdateDate.Text)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Обновление внутренней переменной
|
|
||||||
_ticketExtensions = updatedTicketExtensions;
|
|
||||||
|
|
||||||
MessageBox.Show("Данные успешно сохранены!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCancel_Click_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// Закрытие формы без сохранения
|
|
||||||
this.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,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<IBookOrdersRepository, BookOrdersRepository>();
|
container.RegisterType<IBookOrderRepository, BookOrderRepository>();
|
||||||
container.RegisterType<IBookLibraryRepository, BookLibraryRepository>();
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
namespace ProjectLibrary.Repositories
|
|
||||||
{
|
|
||||||
using ProjectLibrary.Entites;
|
|
||||||
using ProjectLibrary.Entities;
|
|
||||||
|
|
||||||
public interface IBookLibraryRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Book_Library> ReadBookLibraries(int? bookId = null, int? libraryId = null);
|
|
||||||
void CreateBookLibrary(Book_Library bookLibrary);
|
|
||||||
void DeleteBookLibrary(int bookId, int libraryId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,15 @@
|
|||||||
namespace ProjectLibrary.Repositories
|
using ProjectLibrary.Entites;
|
||||||
{
|
using ProjectLibrary.Entities;
|
||||||
using ProjectLibrary.Entites;
|
using System.Collections.Generic;
|
||||||
using ProjectLibrary.Entities;
|
|
||||||
|
|
||||||
public interface IBookOrdersRepository
|
namespace ProjectLibrary.Repositories
|
||||||
|
{
|
||||||
|
public interface IBookOrderRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Book_Orders> ReadBookOrders(int? bookId = null, int? orderId = null);
|
Book_Orders GetBookOrderByOrderId(int orderId); // Получить книгу по ID заказа
|
||||||
void CreateBookOrder(Book_Orders bookOrder);
|
void AddBookOrder(Book_Orders bookOrder); // Добавить книгу к заказу
|
||||||
void DeleteBookOrder(int bookId, int orderId);
|
void UpdateBookOrder(Book_Orders bookOrder); // Обновить данные о книге в заказе
|
||||||
|
void DeleteBookOrder(int bookId, int orderId); // Удалить книгу из заказа
|
||||||
|
List<Book_Orders> ReadBookOrders(); // Получить все записи о книгах в заказах
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
namespace ProjectLibrary.Repositories
|
namespace ProjectLibrary.Repositories
|
||||||
{
|
{
|
||||||
using ProjectLibrary.Entites;
|
|
||||||
using ProjectLibrary.Entities;
|
using ProjectLibrary.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public interface IReaderRepository
|
public interface IReaderRepository
|
||||||
{
|
{
|
||||||
IEnumerable<Reader> ReadReaders();
|
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(); // Метод для чтения всех читателей
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
public interface ITicketExtensionsRepository
|
public interface ITicketExtensionsRepository
|
||||||
{
|
{
|
||||||
IEnumerable<TicketExtensions> ReadTicketExtensions();
|
TicketExtensions GetTicketExtensionById(int id);
|
||||||
TicketExtensions ReadTicketExtensionById(int id);
|
void AddTicketExtension(TicketExtensions ticketExtension);
|
||||||
void CreateTicketExtension(TicketExtensions ticketExtension);
|
|
||||||
void UpdateTicketExtension(TicketExtensions ticketExtension);
|
void UpdateTicketExtension(TicketExtensions ticketExtension);
|
||||||
void DeleteTicketExtension(int id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
using ProjectLibrary.Entites;
|
|
||||||
using ProjectLibrary.Entities;
|
|
||||||
using ProjectLibrary.Repositories;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace ProjectLibrary.Repositories.Implementations
|
|
||||||
{
|
|
||||||
public class BookLibraryRepository : IBookLibraryRepository
|
|
||||||
{
|
|
||||||
// Эмулируем базу данных в виде списка
|
|
||||||
private readonly List<Book_Library> _bookLibraries = new List<Book_Library>();
|
|
||||||
|
|
||||||
public void CreateBookLibrary(Book_Library bookLibrary)
|
|
||||||
{
|
|
||||||
// Логика для добавления связи книги и библиотеки
|
|
||||||
_bookLibraries.Add(bookLibrary);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteBookLibrary(int bookId, int libraryId)
|
|
||||||
{
|
|
||||||
// Логика для удаления связи книги и библиотеки по идентификаторам
|
|
||||||
var bookLibrary = _bookLibraries.FirstOrDefault(bl => bl.BookID == bookId && bl.LibraryID == libraryId);
|
|
||||||
if (bookLibrary != null)
|
|
||||||
{
|
|
||||||
_bookLibraries.Remove(bookLibrary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Book_Library> ReadBookLibraries(int? bookId = null, int? libraryId = null)
|
|
||||||
{
|
|
||||||
// Логика для получения всех связей книг и библиотек с возможностью фильтрации по bookId и libraryId
|
|
||||||
return _bookLibraries.Where(bl =>
|
|
||||||
(!bookId.HasValue || bl.BookID == bookId) &&
|
|
||||||
(!libraryId.HasValue || bl.LibraryID == libraryId));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateBookLibrary(Book_Library bookLibrary)
|
|
||||||
{
|
|
||||||
// Логика для обновления информации о связи книги и библиотеки
|
|
||||||
var existingBookLibrary = _bookLibraries.FirstOrDefault(bl => bl.BookID == bookLibrary.BookID && bl.LibraryID == bookLibrary.LibraryID);
|
|
||||||
if (existingBookLibrary != null)
|
|
||||||
{
|
|
||||||
_bookLibraries.Remove(existingBookLibrary);
|
|
||||||
_bookLibraries.Add(bookLibrary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,37 @@
|
|||||||
|
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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,38 +0,0 @@
|
|||||||
using ProjectLibrary.Entites;
|
|
||||||
using ProjectLibrary.Entities;
|
|
||||||
using ProjectLibrary.Repositories;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace ProjectLibrary.Repositories.Implementations
|
|
||||||
{
|
|
||||||
public class BookOrdersRepository : IBookOrdersRepository
|
|
||||||
{
|
|
||||||
// Эмулируем базу данных в виде списка
|
|
||||||
private readonly List<Book_Orders> _bookOrders = new List<Book_Orders>();
|
|
||||||
|
|
||||||
public void CreateBookOrder(Book_Orders bookOrder)
|
|
||||||
{
|
|
||||||
// Логика для добавления связи книги и заказа
|
|
||||||
_bookOrders.Add(bookOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteBookOrder(int bookId, int orderId)
|
|
||||||
{
|
|
||||||
// Логика для удаления связи книги и заказа по идентификаторам
|
|
||||||
var bookOrder = _bookOrders.FirstOrDefault(bo => bo.BookID == bookId && bo.OrderID == orderId);
|
|
||||||
if (bookOrder != null)
|
|
||||||
{
|
|
||||||
_bookOrders.Remove(bookOrder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Book_Orders> ReadBookOrders(int? bookId = null, int? orderId = null)
|
|
||||||
{
|
|
||||||
// Логика для получения всех связей книг и заказов с возможностью фильтрации по bookId и orderId
|
|
||||||
return _bookOrders.Where(bo =>
|
|
||||||
(!bookId.HasValue || bo.BookID == bookId) &&
|
|
||||||
(!orderId.HasValue || bo.OrderID == orderId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,46 +8,31 @@ namespace ProjectLibrary.Repositories.Implementations
|
|||||||
{
|
{
|
||||||
public class BookRepository : IBookRepository
|
public class BookRepository : IBookRepository
|
||||||
{
|
{
|
||||||
// Эмулируем базу данных в виде списка
|
|
||||||
private readonly List<Book> _books = new List<Book>();
|
|
||||||
|
|
||||||
public void CreateBook(Book book)
|
public void CreateBook(Book book)
|
||||||
{
|
{
|
||||||
// Логика для добавления книги в базу данных
|
|
||||||
_books.Add(book);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteBook(int id)
|
public void DeleteBook(int id)
|
||||||
{
|
{
|
||||||
// Логика для удаления книги по id
|
|
||||||
var book = _books.FirstOrDefault(b => b.Id == id);
|
|
||||||
if (book != null)
|
|
||||||
{
|
|
||||||
_books.Remove(book);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Book ReadBookById(int id)
|
public Book ReadBookById(int id)
|
||||||
{
|
{
|
||||||
// Логика для получения книги по id
|
|
||||||
return _books.FirstOrDefault(b => b.Id == id) ?? Book.CreateEntity(id, "Unknown Author", "Unknown Title", BookType.None, 0);
|
return Book.CreateEntity(id, "", "", BookType.None, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Book> ReadBooks()
|
public IEnumerable<Book> ReadBooks()
|
||||||
{
|
{
|
||||||
// Логика для получения всех книг
|
return [];
|
||||||
return _books;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBook(Book book)
|
public void UpdateBook(Book book)
|
||||||
{
|
{
|
||||||
// Логика для обновления информации о книге
|
|
||||||
var existingBook = _books.FirstOrDefault(b => b.Id == book.Id);
|
|
||||||
if (existingBook != null)
|
|
||||||
{
|
|
||||||
_books.Remove(existingBook);
|
|
||||||
_books.Add(book);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,35 @@
|
|||||||
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 LibraryRepository : ILibraryRepository
|
public class LibraryRepository : ILibraryRepository
|
||||||
{
|
{
|
||||||
private readonly List<Library> _libraries = new List<Library>();
|
|
||||||
|
|
||||||
public void CreateLibrary(Library library)
|
public void CreateLibrary(Library library)
|
||||||
{
|
{
|
||||||
_libraries.Add(library);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteLibrary(int id)
|
public void DeleteLibrary(int id)
|
||||||
{
|
{
|
||||||
var library = _libraries.FirstOrDefault(l => l.Id == id);
|
|
||||||
if (library != null)
|
|
||||||
{
|
|
||||||
_libraries.Remove(library);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Library ReadLibraryById(int id)
|
public Library ReadLibraryById(int id)
|
||||||
{
|
{
|
||||||
return _libraries.FirstOrDefault(l => l.Id == id) ?? Library.CreateEntity(id, "Unknown Library", "Unknown Address");
|
return Library.CreateEntity(id, "", "", []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Library> ReadLibraries()
|
public IEnumerable<Library> ReadLibraries()
|
||||||
{
|
{
|
||||||
return _libraries;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateLibrary(Library library)
|
public void UpdateLibrary(Library library)
|
||||||
{
|
{
|
||||||
var existingLibrary = _libraries.FirstOrDefault(l => l.Id == library.Id);
|
|
||||||
if (existingLibrary != null)
|
|
||||||
{
|
|
||||||
_libraries.Remove(existingLibrary);
|
|
||||||
_libraries.Add(library);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,40 +8,31 @@ namespace ProjectLibrary.Repositories.Implementations
|
|||||||
{
|
{
|
||||||
public class OrderRepository : IOrderRepository
|
public class OrderRepository : IOrderRepository
|
||||||
{
|
{
|
||||||
private readonly List<Orders> _orders = new List<Orders>();
|
|
||||||
|
|
||||||
public void CreateOrder(Orders order)
|
public void CreateOrder(Orders order)
|
||||||
{
|
{
|
||||||
_orders.Add(order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteOrder(int id)
|
public void DeleteOrder(int id)
|
||||||
{
|
{
|
||||||
var order = _orders.FirstOrDefault(o => o.Id == id);
|
|
||||||
if (order != null)
|
|
||||||
{
|
|
||||||
_orders.Remove(order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Orders ReadOrderById(int id)
|
public Orders ReadOrderById(int id)
|
||||||
{
|
{
|
||||||
return _orders.FirstOrDefault(o => o.Id == id) ?? Orders.CreateEntity(id, 0, 0, 0);
|
return Orders.CreateEntity(0, DateTime.Now, DateTime.Now, 0, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Orders> ReadOrders()
|
public IEnumerable<Orders> ReadOrders()
|
||||||
{
|
{
|
||||||
return _orders;
|
return [] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOrder(Orders order)
|
public void UpdateOrder(Orders order)
|
||||||
{
|
{
|
||||||
var existingOrder = _orders.FirstOrDefault(o => o.Id == order.Id);
|
|
||||||
if (existingOrder != null)
|
|
||||||
{
|
|
||||||
_orders.Remove(existingOrder);
|
|
||||||
_orders.Add(order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,36 @@
|
|||||||
using ProjectLibrary.Entites;
|
using System.Collections.Generic;
|
||||||
using ProjectLibrary.Entities;
|
|
||||||
using ProjectLibrary.Repositories;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using ProjectLibrary.Entities;
|
||||||
|
|
||||||
namespace ProjectLibrary.Repositories.Implementations
|
namespace ProjectLibrary.Repositories
|
||||||
{
|
{
|
||||||
public class ReaderRepository : IReaderRepository
|
public class ReaderRepository : IReaderRepository
|
||||||
{
|
{
|
||||||
private readonly List<Reader> _readers = new List<Reader>();
|
|
||||||
|
|
||||||
public void CreateReader(Reader reader)
|
|
||||||
|
public Reader GetReaderById(int id)
|
||||||
{
|
{
|
||||||
_readers.Add(reader);
|
return Reader.CreateEntity(id, "", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteReader(int id)
|
public void AddReader(Reader reader)
|
||||||
{
|
{
|
||||||
var reader = _readers.FirstOrDefault(r => r.Id == id);
|
|
||||||
if (reader != null)
|
|
||||||
{
|
|
||||||
_readers.Remove(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Reader ReadReaderById(int id)
|
|
||||||
{
|
|
||||||
return _readers.FirstOrDefault(r => r.Id == id) ?? Reader.CreateEntity(id, "Unknown Reader", 0, DateTime.Now);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Reader> ReadReaders()
|
|
||||||
{
|
|
||||||
return _readers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateReader(Reader reader)
|
public void UpdateReader(Reader reader)
|
||||||
{
|
{
|
||||||
var existingReader = _readers.FirstOrDefault(r => r.Id == reader.Id);
|
|
||||||
if (existingReader != null)
|
|
||||||
{
|
|
||||||
_readers.Remove(existingReader);
|
|
||||||
_readers.Add(reader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteReader(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Reader> ReadReaders()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,22 @@
|
|||||||
using ProjectLibrary.Entites;
|
using ProjectLibrary.Entites;
|
||||||
using ProjectLibrary.Entities;
|
|
||||||
using ProjectLibrary.Repositories;
|
using ProjectLibrary.Repositories;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace ProjectLibrary.Repositories.Implementations
|
public class TicketExtensionsRepository : ITicketExtensionsRepository
|
||||||
{
|
{
|
||||||
public class TicketExtensionsRepository : ITicketExtensionsRepository
|
|
||||||
{
|
|
||||||
private readonly List<TicketExtensions> _ticketExtensions = new List<TicketExtensions>();
|
|
||||||
|
|
||||||
public void CreateTicketExtension(TicketExtensions ticketExtension)
|
|
||||||
|
public TicketExtensions GetTicketExtensionById(int id)
|
||||||
{
|
{
|
||||||
_ticketExtensions.Add(ticketExtension);
|
return TicketExtensions.CreateEntity(0, DateTime.Now, DateTime.Now);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteTicketExtension(int id)
|
public void AddTicketExtension(TicketExtensions ticketExtension)
|
||||||
{
|
{
|
||||||
var ticketExtension = _ticketExtensions.FirstOrDefault(t => t.ExtensionID == id);
|
|
||||||
if (ticketExtension != null)
|
|
||||||
{
|
|
||||||
_ticketExtensions.Remove(ticketExtension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TicketExtensions ReadTicketExtensionById(int id)
|
|
||||||
{
|
|
||||||
return _ticketExtensions.FirstOrDefault(t => t.ExtensionID == id) ?? TicketExtensions.CreateEntity(0, id, DateTime.Now, DateTime.Now);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<TicketExtensions> ReadTicketExtensions()
|
|
||||||
{
|
|
||||||
return _ticketExtensions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTicketExtension(TicketExtensions ticketExtension)
|
public void UpdateTicketExtension(TicketExtensions ticketExtension)
|
||||||
{
|
{
|
||||||
var existingTicketExtension = _ticketExtensions.FirstOrDefault(t => t.ExtensionID == ticketExtension.ExtensionID);
|
|
||||||
if (existingTicketExtension != null)
|
|
||||||
{
|
|
||||||
_ticketExtensions.Remove(existingTicketExtension);
|
|
||||||
_ticketExtensions.Add(ticketExtension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user