diff --git a/ProjectLibrary/Entites/Book.cs b/ProjectLibrary/Entites/Book.cs index 7204483..607faa0 100644 --- a/ProjectLibrary/Entites/Book.cs +++ b/ProjectLibrary/Entites/Book.cs @@ -1,14 +1,24 @@ namespace ProjectLibrary.Entities { using ProjectLibrary.Entities.Enums; + using System.ComponentModel; public class Book { public int Id { get; private set; } + + [DisplayName("Автор")] public string Author { get; private set; } = string.Empty; + + [Browsable(false)] public string Name { get; private set; } = string.Empty; + + [Browsable(false)] public BookType TypeBookID { get; set; } = BookType.None; + [DisplayName("Название книги (жанр)")] + public string NameTypeBookID => $"{Name}({TypeBookID})"; + public static Book CreateEntity(int id, string author, string name, BookType typeBookID = BookType.None) { return new Book diff --git a/ProjectLibrary/Entites/Book_Orders.cs b/ProjectLibrary/Entites/Book_Orders.cs index 9b6f030..5e14df2 100644 --- a/ProjectLibrary/Entites/Book_Orders.cs +++ b/ProjectLibrary/Entites/Book_Orders.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,9 +10,15 @@ namespace ProjectLibrary.Entites public class Book_Orders { public int BookID { get; private set; } + + public int OrderID { get; private set; } + + [DisplayName("Количество")] public int Count { get; private set; } + public string BookName { get; set; } + public static Book_Orders CreateEntity(int orderID,int bookID, int count ) { return new Book_Orders diff --git a/ProjectLibrary/Entites/Book_library.cs b/ProjectLibrary/Entites/Book_library.cs index 5c08041..7806809 100644 --- a/ProjectLibrary/Entites/Book_library.cs +++ b/ProjectLibrary/Entites/Book_library.cs @@ -1,9 +1,13 @@ -namespace ProjectLibrary.Entites +using System.ComponentModel; + +namespace ProjectLibrary.Entites { public class Book_Library { public int BookID { get; private set; } + public int LibraryID { get; private set; } + [DisplayName("Количество")] public int Count { get; private set; } public static Book_Library CreateEntity(int libraryID, int bookID, int count) diff --git a/ProjectLibrary/Entites/Library.cs b/ProjectLibrary/Entites/Library.cs index 07c629c..5bedc2a 100644 --- a/ProjectLibrary/Entites/Library.cs +++ b/ProjectLibrary/Entites/Library.cs @@ -1,6 +1,7 @@ using ProjectLibrary.Forms; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,14 +11,24 @@ namespace ProjectLibrary.Entites public class Library { public int Id { get; private set; } + + [DisplayName("Название")] public string Name { get; private set; } = string.Empty; + + [DisplayName("Адрес")] public string Address { get; private set; } = string.Empty; + + [Browsable(false)] public IEnumerable BookLibrary { get; private set; } + [DisplayName("Перечень книг в библиотеке")] + public string ListBookInLibrary => BookLibrary != null ? + string.Join("; ", BookLibrary.Select(x => $"{x.BookID},{x.Count}")): string.Empty; + public static Library CreateEntity(int id, string name, string address, IEnumerable bookLibrary) { return new Library @@ -28,5 +39,13 @@ namespace ProjectLibrary.Entites BookLibrary = bookLibrary }; } + + public void SetLibraryForBook(IEnumerable book_Library) + { + if (book_Library != null && book_Library.Any()) + { + BookLibrary = book_Library; + } + } } } diff --git a/ProjectLibrary/Entites/Orders.cs b/ProjectLibrary/Entites/Orders.cs index 03f05db..180998a 100644 --- a/ProjectLibrary/Entites/Orders.cs +++ b/ProjectLibrary/Entites/Orders.cs @@ -3,6 +3,7 @@ using Microsoft.VisualBasic; using ProjectLibrary.Entities; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,15 +13,32 @@ namespace ProjectLibrary.Entites public class Orders { public int Id { get; private set; } + + [DisplayName("Дата взятия книги")] public DateTime OrderDate { get; private set; } + + [DisplayName("Дата зврата книги")] public DateTime ReturnDate { get; private set; } + + [Browsable(false)] public int ReaderID { get; private set; } + + [DisplayName("ФИО читателя")] + public string ReaderName { get; private set; } + + public string BookName { get; set; } + + [Browsable(false)] public IEnumerable BookOrders { get; private set; } = []; + [DisplayName("Отданные книги")] + public string BookOrdersing => BookOrders != null ? + string.Join(", ", BookOrders.Select(x => $"{x.BookID}({x.Count})")) : + string.Empty; public static Orders CreateEntity(int id, DateTime returnDate, int readerID, IEnumerable bookOrders) { @@ -33,17 +51,12 @@ namespace ProjectLibrary.Entites BookOrders = bookOrders }; } - - public static Orders CreateEntity(TempBookOrders tempBookOrders, IEnumerable bookOrders) + public void SetOrdersOfBooks(IEnumerable book_Orders) { - return new Orders + if (book_Orders != null && book_Orders.Any()) { - Id = tempBookOrders.Id, - OrderDate = tempBookOrders.OrderDate, - ReturnDate = tempBookOrders.ReturnDate, - ReaderID = tempBookOrders.ReaderID, - BookOrders = bookOrders - }; + BookOrders = book_Orders; + } } } } diff --git a/ProjectLibrary/Entites/QueryBuilder.cs b/ProjectLibrary/Entites/QueryBuilder.cs new file mode 100644 index 0000000..e6c898b --- /dev/null +++ b/ProjectLibrary/Entites/QueryBuilder.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entites; + +internal class QueryBuilder +{ + private readonly StringBuilder _builder; + public QueryBuilder() + { + _builder = new(); + } + + public QueryBuilder AddCollerction(string condition) + { + if (_builder.Length > 0) + { + _builder.Append("AND"); + } + _builder.Append(condition); + return this; + } + + public string Build() + { + if (_builder.Length == 0) + { + return string.Empty; + } + return $"WHERE {_builder}"; + } +} diff --git a/ProjectLibrary/Entites/Reader.cs b/ProjectLibrary/Entites/Reader.cs index c46b5af..23015da 100644 --- a/ProjectLibrary/Entites/Reader.cs +++ b/ProjectLibrary/Entites/Reader.cs @@ -1,10 +1,18 @@ -namespace ProjectLibrary.Entities +using System.ComponentModel; + +namespace ProjectLibrary.Entities { public class Reader { public int Id { get; private set; } + + [DisplayName("ФИО")] public string Name { get; private set; } = string.Empty; + + [DisplayName("Читательский билет")] public int ReaderTicket { get; private set; } + + [DisplayName("Дата регистрации")] public DateTime RegistrationDateRT { get; private set; } // Изменение на DateTime public static Reader CreateEntity(int id, string name, int readerTicket) diff --git a/ProjectLibrary/Entites/TempBookOrders.cs b/ProjectLibrary/Entites/TempBookOrders.cs deleted file mode 100644 index 3597cd2..0000000 --- a/ProjectLibrary/Entites/TempBookOrders.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectLibrary.Entites; - -public class TempBookOrders -{ - public int Id { get; set; } - public DateTime OrderDate { get; set; } - public DateTime ReturnDate { get; set; } - public int ReaderID { get; set; } - public int BookID { get; set; } - public int Count { get; set; } - - -} diff --git a/ProjectLibrary/Entites/Ticket_Extension.cs b/ProjectLibrary/Entites/Ticket_Extension.cs index 331ace5..5808f47 100644 --- a/ProjectLibrary/Entites/Ticket_Extension.cs +++ b/ProjectLibrary/Entites/Ticket_Extension.cs @@ -1,12 +1,25 @@ -namespace ProjectLibrary.Entites +using System.ComponentModel; + +namespace ProjectLibrary.Entites { public class TicketExtensions { public int Id { get; private set; } + + [Browsable(false)] public int ReaderID { get; private set; } + + [DisplayName("ФИО читателя")] + public string ReaderName { get; private set; } + + [DisplayName("Последняя дата обновления")] public DateTime LastUpdateDate { get; private set; } + + [DisplayName("Следущая дата обновления")] public DateTime NextUpdateDate { get; private set; } + + public static TicketExtensions CreateEntity(int id, int readerID, DateTime lastUpdateDate, DateTime nextUpdateDate) { return new TicketExtensions diff --git a/ProjectLibrary/Forms/FBooks.Designer.cs b/ProjectLibrary/Forms/FBooks.Designer.cs index b11ed39..4359dd1 100644 --- a/ProjectLibrary/Forms/FBooks.Designer.cs +++ b/ProjectLibrary/Forms/FBooks.Designer.cs @@ -40,57 +40,52 @@ dataGridViewBooks.AllowUserToAddRows = false; dataGridViewBooks.AllowUserToDeleteRows = false; dataGridViewBooks.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewBooks.Location = new Point(10, 9); - dataGridViewBooks.Margin = new Padding(3, 2, 3, 2); + dataGridViewBooks.Location = new Point(11, 12); dataGridViewBooks.Name = "dataGridViewBooks"; dataGridViewBooks.ReadOnly = true; dataGridViewBooks.RowHeadersWidth = 51; dataGridViewBooks.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridViewBooks.Size = new Size(602, 254); + dataGridViewBooks.Size = new Size(688, 339); dataGridViewBooks.TabIndex = 8; // // buttonAdd // - buttonAdd.Location = new Point(27, 267); - buttonAdd.Margin = new Padding(3, 2, 3, 2); + buttonAdd.Location = new Point(31, 356); buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(161, 37); + buttonAdd.Size = new Size(184, 49); buttonAdd.TabIndex = 9; buttonAdd.Text = "Добавить"; buttonAdd.Click += buttonAdd_Click; // // buttonUpdate // - buttonUpdate.Location = new Point(247, 267); - buttonUpdate.Margin = new Padding(3, 2, 3, 2); + buttonUpdate.Location = new Point(282, 356); buttonUpdate.Name = "buttonUpdate"; - buttonUpdate.Size = new Size(161, 37); + buttonUpdate.Size = new Size(184, 49); buttonUpdate.TabIndex = 10; buttonUpdate.Text = "Изменить"; buttonUpdate.Click += buttonUpdate_Click; // // buttonRemove // - buttonRemove.Location = new Point(452, 267); - buttonRemove.Margin = new Padding(3, 2, 3, 2); + buttonRemove.Location = new Point(517, 356); buttonRemove.Name = "buttonRemove"; - buttonRemove.Size = new Size(161, 37); + buttonRemove.Size = new Size(184, 49); buttonRemove.TabIndex = 11; buttonRemove.Text = "Удалить"; buttonRemove.Click += buttonRemove_Click; // // FBooks // - AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(700, 338); + ClientSize = new Size(800, 451); Controls.Add(dataGridViewBooks); Controls.Add(buttonAdd); Controls.Add(buttonUpdate); Controls.Add(buttonRemove); - Margin = new Padding(3, 2, 3, 2); Name = "FBooks"; - Text = "FBooks"; + Text = "Книги"; Load += FBooks_Load; ((System.ComponentModel.ISupportInitialize)dataGridViewBooks).EndInit(); ResumeLayout(false); diff --git a/ProjectLibrary/Forms/FBooks.cs b/ProjectLibrary/Forms/FBooks.cs index 91e6c78..a4b82b6 100644 --- a/ProjectLibrary/Forms/FBooks.cs +++ b/ProjectLibrary/Forms/FBooks.cs @@ -20,6 +20,7 @@ namespace ProjectLibrary.Forms // Привязывает к DataGridView коллекцию книг, полученную из репозитория. // Устанавливает источник данных DataGridView (dataGridViewBooks) как список объектов из ReadBooks(). dataGridViewBooks.DataSource = _bookRepository.ReadBooks(); + dataGridViewBooks.Columns["Id"].Visible = false; } private bool TryGetIdentifierFromSelectedRow(out int id) diff --git a/ProjectLibrary/Forms/FBooks.resx b/ProjectLibrary/Forms/FBooks.resx index af32865..8b2ff64 100644 --- a/ProjectLibrary/Forms/FBooks.resx +++ b/ProjectLibrary/Forms/FBooks.resx @@ -1,7 +1,7 @@