diff --git a/ProjectLibrary/ProjectLibrary/Entities/Book.cs b/ProjectLibrary/ProjectLibrary/Entities/Book.cs new file mode 100644 index 0000000..588b64c --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/Book.cs @@ -0,0 +1,30 @@ +using ProjectLibrary.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities; + +public class Book +{ + public int Id { get; private set; } + + public string Title { get; private set; } = string.Empty; + + public BookTopic Topic { get; private set; } + + public Boolean IsIssued { get; private set; } + + public static Book CreateEntity(int id, string title, BookTopic topic, Boolean isIssued) + { + return new Book + { + Id = id, + Title = title ?? string.Empty, + Topic = topic, + IsIssued = isIssued + }; + } +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/DoIssue.cs b/ProjectLibrary/ProjectLibrary/Entities/DoIssue.cs new file mode 100644 index 0000000..fbaa84e --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/DoIssue.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities; + +public class DoIssue +{ + public int Id { get;private set; } + + public DateTime IssueDate { get;private set; } + + public DateTime DueDate { get; private set; } + + public DateTime ReturnDate { get; private set; } + + public IEnumerable Issue { get; private set; } = []; + public static DoIssue CreateOperation(int id, IEnumerable issue) + { + return new DoIssue + { + Id = id, + IssueDate = DateTime.Now, + DueDate = DateTime.Now, + ReturnDate = DateTime.Now, + Issue = issue + }; + } + +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/Enums/AllowedTopic.cs b/ProjectLibrary/ProjectLibrary/Entities/Enums/AllowedTopic.cs new file mode 100644 index 0000000..5ce2ce8 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/Enums/AllowedTopic.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities.Enums; + +[Flags] +public enum AllowedTopic +{ + None = 0, + + Science = 1, + + Tale = 2, + + Fantasy = 3 +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/Enums/BookTopic.cs b/ProjectLibrary/ProjectLibrary/Entities/Enums/BookTopic.cs new file mode 100644 index 0000000..240f6de --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/Enums/BookTopic.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities.Enums; + +[Flags] +public enum BookTopic +{ + None = 0, + + Science = 1, + + Tale = 2, + + Fantasy = 3 +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/Issue.cs b/ProjectLibrary/ProjectLibrary/Entities/Issue.cs new file mode 100644 index 0000000..1f07632 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/Issue.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities; + +public class Issue +{ + public int Id { get; private set; } + + public int LibrarianId { get; private set;} + + public int ReaderId { get; private set; } + + public static Issue CreateElement(int id, int librarianId, int readerId) + { + return new Issue + { + Id = id, + LibrarianId = librarianId, + ReaderId = readerId + }; + } +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/Librarian.cs b/ProjectLibrary/ProjectLibrary/Entities/Librarian.cs new file mode 100644 index 0000000..1d78a44 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/Librarian.cs @@ -0,0 +1,28 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectLibrary.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities; + +public class Librarian +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public AllowedTopic AllowedTopic { get; private set; } + + public static Librarian CreateEntity(int id, string name, AllowedTopic allowedTopic) + { + return new Librarian + { + Id = id, + Name = name ?? string.Empty, + AllowedTopic = allowedTopic + }; + } +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/LibrarianTopic.cs b/ProjectLibrary/ProjectLibrary/Entities/LibrarianTopic.cs new file mode 100644 index 0000000..30a0f1e --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/LibrarianTopic.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities; + +public class LibrarianTopic +{ + public int LibrarianId { get; private set; } + + public int TopicId { get; private set; } + + public static LibrarianTopic CreateOperation(int librarianId, int topicId) + { + return new LibrarianTopic + { + LibrarianId = librarianId, + TopicId = topicId + }; + } +} diff --git a/ProjectLibrary/ProjectLibrary/Entities/Reader.cs b/ProjectLibrary/ProjectLibrary/Entities/Reader.cs new file mode 100644 index 0000000..8f84a3d --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Entities/Reader.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Entities; + +public class Reader +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public int LibraryCard { get; private set; } + + public DateTime CardValidity { get; private set; } + + public static Reader CreateEntity(int id, string name, int libraryCard) + { + return new Reader + { + Id = id, + Name = name ?? string.Empty, + LibraryCard = libraryCard, + CardValidity = DateTime.Now + }; + } +} diff --git a/ProjectLibrary/ProjectLibrary/FormLibrary.Designer.cs b/ProjectLibrary/ProjectLibrary/FormLibrary.Designer.cs new file mode 100644 index 0000000..7d13464 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/FormLibrary.Designer.cs @@ -0,0 +1,132 @@ +namespace ProjectLibrary +{ + partial class FormLibrary + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + 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(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(784, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { библиотекариToolStripMenuItem, книгиToolStripMenuItem, читателиToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // библиотекариToolStripMenuItem + // + библиотекариToolStripMenuItem.Name = "библиотекариToolStripMenuItem"; + библиотекариToolStripMenuItem.Size = new Size(180, 22); + библиотекариToolStripMenuItem.Text = "Библиотекари"; + // + // книгиToolStripMenuItem + // + книгиToolStripMenuItem.Name = "книгиToolStripMenuItem"; + книгиToolStripMenuItem.Size = new Size(180, 22); + книгиToolStripMenuItem.Text = "Книги"; + // + // читателиToolStripMenuItem + // + читателиToolStripMenuItem.Name = "читателиToolStripMenuItem"; + читателиToolStripMenuItem.Size = new Size(180, 22); + читателиToolStripMenuItem.Text = "Читатели"; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { выдачаКнигиToolStripMenuItem, закрепитьТемуЗаБиблиотекаремToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // выдачаКнигиToolStripMenuItem + // + выдачаКнигиToolStripMenuItem.Name = "выдачаКнигиToolStripMenuItem"; + выдачаКнигиToolStripMenuItem.Size = new Size(264, 22); + выдачаКнигиToolStripMenuItem.Text = "Выдача книги"; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // закрепитьТемуЗаБиблиотекаремToolStripMenuItem + // + закрепитьТемуЗаБиблиотекаремToolStripMenuItem.Name = "закрепитьТемуЗаБиблиотекаремToolStripMenuItem"; + закрепитьТемуЗаБиблиотекаремToolStripMenuItem.Size = new Size(264, 22); + закрепитьТемуЗаБиблиотекаремToolStripMenuItem.Text = "Закрепить тему за библиотекарем"; + // + // FormLibrary + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources._312af421aa2411eebcbabe4f0f61c502_upscaled; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(784, 411); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormLibrary"; + StartPosition = FormStartPosition.CenterScreen; + Text = "Библиотека"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + 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; + } +} diff --git a/ProjectLibrary/ProjectLibrary/FormLibrary.cs b/ProjectLibrary/ProjectLibrary/FormLibrary.cs new file mode 100644 index 0000000..0c8abff --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/FormLibrary.cs @@ -0,0 +1,10 @@ +namespace ProjectLibrary +{ + public partial class FormLibrary : Form + { + public FormLibrary() + { + InitializeComponent(); + } + } +} diff --git a/ProjectLibrary/ProjectLibrary/FormLibrary.resx b/ProjectLibrary/ProjectLibrary/FormLibrary.resx new file mode 100644 index 0000000..a0623c8 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/FormLibrary.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormBook.Designer.cs b/ProjectLibrary/ProjectLibrary/Forms/FormBook.Designer.cs new file mode 100644 index 0000000..07322b6 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormBook.Designer.cs @@ -0,0 +1,144 @@ +namespace ProjectLibrary.Forms +{ + partial class FormBook + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelTitle = new Label(); + textBoxBookTitle = new TextBox(); + labelTopic = new Label(); + labelisIssued = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + checkBoxisIssued = new CheckBox(); + checkedListBoxBookTopic = new CheckedListBox(); + SuspendLayout(); + // + // labelTitle + // + labelTitle.AutoSize = true; + labelTitle.Location = new Point(34, 26); + labelTitle.Name = "labelTitle"; + labelTitle.Size = new Size(94, 15); + labelTitle.TabIndex = 0; + labelTitle.Text = "Название книги"; + // + // textBoxBookTitle + // + textBoxBookTitle.Location = new Point(158, 18); + textBoxBookTitle.Name = "textBoxBookTitle"; + textBoxBookTitle.Size = new Size(188, 23); + textBoxBookTitle.TabIndex = 1; + // + // labelTopic + // + labelTopic.AutoSize = true; + labelTopic.Location = new Point(34, 79); + labelTopic.Name = "labelTopic"; + labelTopic.Size = new Size(69, 15); + labelTopic.TabIndex = 2; + labelTopic.Text = "Тема книги"; + // + // labelisIssued + // + labelisIssued.AutoSize = true; + labelisIssued.Location = new Point(34, 202); + labelisIssued.Name = "labelisIssued"; + labelisIssued.Size = new Size(49, 15); + labelisIssued.TabIndex = 4; + labelisIssued.Text = "Занята?"; + // + // buttonSave + // + buttonSave.Location = new Point(53, 250); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(182, 250); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // checkBoxisIssued + // + checkBoxisIssued.AutoSize = true; + checkBoxisIssued.Location = new Point(158, 198); + checkBoxisIssued.Name = "checkBoxisIssued"; + checkBoxisIssued.Size = new Size(68, 19); + checkBoxisIssued.TabIndex = 8; + checkBoxisIssued.Text = "Занята?"; + checkBoxisIssued.UseVisualStyleBackColor = true; + // + // checkedListBoxBookTopic + // + checkedListBoxBookTopic.FormattingEnabled = true; + checkedListBoxBookTopic.Location = new Point(158, 61); + checkedListBoxBookTopic.Name = "checkedListBoxBookTopic"; + checkedListBoxBookTopic.Size = new Size(188, 112); + checkedListBoxBookTopic.TabIndex = 9; + // + // FormBook + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(359, 282); + Controls.Add(checkedListBoxBookTopic); + Controls.Add(checkBoxisIssued); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelisIssued); + Controls.Add(labelTopic); + Controls.Add(textBoxBookTitle); + Controls.Add(labelTitle); + Name = "FormBook"; + StartPosition = FormStartPosition.CenterParent; + Text = "Книга"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelTitle; + private TextBox textBoxBookTitle; + private Label labelTopic; + private Label labelisIssued; + private Button buttonSave; + private Button buttonCancel; + private CheckBox checkBoxisIssued; + private CheckedListBox checkedListBoxBookTopic; + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormBook.cs b/ProjectLibrary/ProjectLibrary/Forms/FormBook.cs new file mode 100644 index 0000000..907e9b7 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormBook.cs @@ -0,0 +1,97 @@ +using Microsoft.VisualBasic.FileIO; +using ProjectLibrary.Entities; +using ProjectLibrary.Entities.Enums; +using ProjectLibrary.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectLibrary.Forms; + +public partial class FormBook : Form +{ + private readonly IBookRepository _bookRepository; + private int? _bookId; + public int Id + { + set + { + try + { + var book = _bookRepository.ReadBookById(value); + if (book == null) + { + throw new InvalidDataException(nameof(book)); + } + textBoxBookTitle.Text = book.Title; + foreach (BookTopic elem in Enum.GetValues(typeof(BookTopic))) + { + if ((elem & book.Topic) != 0) + { + checkedListBoxBookTopic.SetItemChecked(checkedListBoxBookTopic.Items.IndexOf(elem), true); + checkBoxisIssued.Checked = book.IsIssued; + _bookId = value; + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormBook(IBookRepository bookRepository) + { + InitializeComponent(); + _bookRepository = bookRepository ?? + throw new ArgumentNullException(nameof(bookRepository)); + foreach (var elem in Enum.GetValues(typeof(BookTopic))) + { + checkedListBoxBookTopic.Items.Add(elem); + + } + } + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxBookTitle.Text) + || + checkedListBoxBookTopic.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_bookId.HasValue) + { + _bookRepository.UpdateBook(CreateBook(_bookId.Value)); + } + else + { + _bookRepository.CreateBook(CreateBook(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + private Book CreateBook(int id) { + BookTopic bookTopic = BookTopic.None; + foreach (var elem in checkedListBoxBookTopic.CheckedItems) + { + bookTopic |= (BookTopic)elem; + } + return Book.CreateEntity(id, textBoxBookTitle.Text,bookTopic, checkBoxisIssued.Checked); + } +} + diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormBook.resx b/ProjectLibrary/ProjectLibrary/Forms/FormBook.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormBook.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormBooks.Designer.cs b/ProjectLibrary/ProjectLibrary/Forms/FormBooks.Designer.cs new file mode 100644 index 0000000..42b6b2c --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormBooks.Designer.cs @@ -0,0 +1,126 @@ +namespace ProjectLibrary.Forms +{ + partial class FormBooks + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonAdd = new Button(); + dataGridView = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(590, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(144, 451); + panel1.TabIndex = 0; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.update; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(33, 201); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(75, 61); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(33, 119); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(75, 60); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 36); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 63); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(590, 451); + dataGridView.TabIndex = 1; + // + // FormBooks + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(734, 451); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormBooks"; + StartPosition = FormStartPosition.CenterParent; + Text = "Книги"; + Load += FormBooks_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private Button buttonUpd; + private Button buttonDel; + private Button buttonAdd; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormBooks.cs b/ProjectLibrary/ProjectLibrary/Forms/FormBooks.cs new file mode 100644 index 0000000..6e8b2f7 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormBooks.cs @@ -0,0 +1,114 @@ +using ProjectLibrary.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ProjectLibrary.Forms +{ + public partial class FormBooks : Form + { + + private readonly IUnityContainer _container; + + private readonly IBookRepository _bookRepository; + + public FormBooks(IUnityContainer container, IBookRepository bookRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _bookRepository = bookRepository ?? throw new ArgumentNullException(nameof(bookRepository)); + } + + private void FormBooks_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().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _bookRepository.DeleteBook(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _bookRepository.ReadBooks(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormBooks.resx b/ProjectLibrary/ProjectLibrary/Forms/FormBooks.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormBooks.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.Designer.cs b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.Designer.cs new file mode 100644 index 0000000..c740885 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.Designer.cs @@ -0,0 +1,120 @@ +namespace ProjectLibrary.Forms +{ + partial class FormLibrarian + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelLibrarianName = new Label(); + textBoxLibrarianName = new TextBox(); + labelLibrarianTopic = new Label(); + comboBoxAllowedTopic = new ComboBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // labelLibrarianName + // + labelLibrarianName.AutoSize = true; + labelLibrarianName.Location = new Point(27, 36); + labelLibrarianName.Name = "labelLibrarianName"; + labelLibrarianName.Size = new Size(112, 15); + labelLibrarianName.TabIndex = 0; + labelLibrarianName.Text = "Имя библиотекаря"; + // + // textBoxLibrarianName + // + textBoxLibrarianName.Location = new Point(154, 33); + textBoxLibrarianName.Name = "textBoxLibrarianName"; + textBoxLibrarianName.Size = new Size(132, 23); + textBoxLibrarianName.TabIndex = 1; + // + // labelLibrarianTopic + // + labelLibrarianTopic.AutoSize = true; + labelLibrarianTopic.Location = new Point(27, 91); + labelLibrarianTopic.Name = "labelLibrarianTopic"; + labelLibrarianTopic.Size = new Size(110, 15); + labelLibrarianTopic.TabIndex = 2; + labelLibrarianTopic.Text = "Разрешенная тема"; + // + // comboBoxAllowedTopic + // + comboBoxAllowedTopic.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxAllowedTopic.FormattingEnabled = true; + comboBoxAllowedTopic.Location = new Point(154, 88); + comboBoxAllowedTopic.Name = "comboBoxAllowedTopic"; + comboBoxAllowedTopic.Size = new Size(132, 23); + comboBoxAllowedTopic.TabIndex = 3; + // + // buttonSave + // + buttonSave.Location = new Point(27, 146); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(154, 146); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormLibrarian + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(300, 189); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxAllowedTopic); + Controls.Add(labelLibrarianTopic); + Controls.Add(textBoxLibrarianName); + Controls.Add(labelLibrarianName); + Name = "FormLibrarian"; + StartPosition = FormStartPosition.CenterParent; + Text = "Библиотекарь"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelLibrarianName; + private TextBox textBoxLibrarianName; + private Label labelLibrarianTopic; + private ComboBox comboBoxAllowedTopic; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.cs b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.cs new file mode 100644 index 0000000..bc55165 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.cs @@ -0,0 +1,82 @@ +using ProjectLibrary.Entities; +using ProjectLibrary.Entities.Enums; +using ProjectLibrary.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectLibrary.Forms; + +public partial class FormLibrarian : Form +{ + private readonly ILibrarianRepository _librarianRepository; + + private int? _librarianId; + + public int Id + { + set + { + try + { + var librarian = _librarianRepository.ReadLibrarianById(value); + if (librarian == null) + { + throw new + InvalidDataException(nameof(librarian)); + } + textBoxLibrarianName.Text = librarian.Name; + comboBoxAllowedTopic.SelectedItem = librarian.AllowedTopic; + _librarianId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormLibrarian(ILibrarianRepository librarianRepository) + { + InitializeComponent(); + _librarianRepository = librarianRepository ?? throw new ArgumentNullException(nameof(librarianRepository)); + comboBoxAllowedTopic.DataSource = Enum.GetValues(typeof(AllowedTopic)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxLibrarianName.Text) || + comboBoxAllowedTopic.SelectedIndex < 1) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_librarianId.HasValue) + { + _librarianRepository.UpdateLibrarian(CreateLibrarian(_librarianId.Value)); + } + else + { + _librarianRepository.CreateLibrarian(CreateLibrarian(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Librarian CreateLibrarian(int id) => Librarian.CreateEntity(id, textBoxLibrarianName.Text, (AllowedTopic)comboBoxAllowedTopic.SelectedItem!); +} + diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.resx b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarian.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.Designer.cs b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.Designer.cs new file mode 100644 index 0000000..f491a30 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectLibrary.Forms +{ + partial class FormLibrarians + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel1 = new Panel(); + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(589, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(145, 451); + panel1.TabIndex = 0; + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(589, 451); + dataGridView.TabIndex = 1; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(37, 35); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 70); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.update; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(37, 133); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(75, 70); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(37, 235); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(75, 70); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // FormLibrarians + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(734, 451); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormLibrarians"; + Text = "Библиотекари"; + Load += FormLibrarians_Load; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridView; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.cs b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.cs new file mode 100644 index 0000000..3bacb2b --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.cs @@ -0,0 +1,112 @@ +using ProjectLibrary.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectLibrary.Forms +{ + public partial class FormLibrarians : Form + { + private readonly IUnityContainer _container; + + private readonly ILibrarianRepository _librarianRepository; + public FormLibrarians(IUnityContainer container, ILibrarianRepository librarianRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _librarianRepository = librarianRepository ?? throw new ArgumentNullException(nameof(librarianRepository)); + } + + private void FormLibrarians_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().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _librarianRepository.DeleteLibrarian(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridView.DataSource = _librarianRepository.ReadLibrarians(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.resx b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormLibrarians.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormReader.Designer.cs b/ProjectLibrary/ProjectLibrary/Forms/FormReader.Designer.cs new file mode 100644 index 0000000..6b50688 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormReader.Designer.cs @@ -0,0 +1,122 @@ +namespace ProjectLibrary.Forms +{ + partial class FormReader + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new Label(); + label2 = new Label(); + textBoxReaderName = new TextBox(); + numericUpDownLibraryCard = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownLibraryCard).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(34, 36); + label1.Name = "label1"; + label1.Size = new Size(83, 15); + label1.TabIndex = 0; + label1.Text = "Имя читателя"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(34, 100); + label2.Name = "label2"; + label2.Size = new Size(106, 15); + label2.TabIndex = 1; + label2.Text = "ID карты читателя"; + // + // textBoxReaderName + // + textBoxReaderName.Location = new Point(167, 33); + textBoxReaderName.Name = "textBoxReaderName"; + textBoxReaderName.Size = new Size(200, 23); + textBoxReaderName.TabIndex = 3; + // + // numericUpDownLibraryCard + // + numericUpDownLibraryCard.Location = new Point(167, 98); + numericUpDownLibraryCard.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); + numericUpDownLibraryCard.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numericUpDownLibraryCard.Name = "numericUpDownLibraryCard"; + numericUpDownLibraryCard.Size = new Size(200, 23); + numericUpDownLibraryCard.TabIndex = 4; + numericUpDownLibraryCard.Value = new decimal(new int[] { 1, 0, 0, 0 }); + // + // buttonSave + // + buttonSave.Location = new Point(34, 147); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(75, 23); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(167, 147); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(75, 23); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отменить"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // FormReader + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(380, 191); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownLibraryCard); + Controls.Add(textBoxReaderName); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormReader"; + Text = "Читатель"; + ((System.ComponentModel.ISupportInitialize)numericUpDownLibraryCard).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private TextBox textBoxReaderName; + private NumericUpDown numericUpDownLibraryCard; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormReader.cs b/ProjectLibrary/ProjectLibrary/Forms/FormReader.cs new file mode 100644 index 0000000..493108d --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormReader.cs @@ -0,0 +1,76 @@ +using ProjectLibrary.Entities; +using ProjectLibrary.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectLibrary.Forms; + +public partial class FormReader : Form +{ + private readonly IReaderRepository _readerRepository; + + private int? _readerId; + public int Id + { + set + { + try + { + var reader = _readerRepository.ReadReaderById(value); + if (reader == null) + { + throw new InvalidDataException(nameof(reader)); + } + textBoxReaderName.Text = reader.Name; + numericUpDownLibraryCard.Value = reader.LibraryCard; + _readerId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormReader(IReaderRepository readerRepository) + { + InitializeComponent(); + _readerRepository = readerRepository ?? throw new ArgumentNullException(nameof(readerRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrWhiteSpace(textBoxReaderName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + if (_readerId.HasValue) + { + _readerRepository.UpdateReader(CreateReader(_readerId.Value)); + } + else + { + _readerRepository.CreateReader(CreateReader(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Reader CreateReader(int id) => Reader.CreateEntity(id, textBoxReaderName.Text, Convert.ToInt32(numericUpDownLibraryCard.Value)); +} diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormReader.resx b/ProjectLibrary/ProjectLibrary/Forms/FormReader.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormReader.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormReaders.Designer.cs b/ProjectLibrary/ProjectLibrary/Forms/FormReaders.Designer.cs new file mode 100644 index 0000000..183a216 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormReaders.Designer.cs @@ -0,0 +1,125 @@ +namespace ProjectLibrary.Forms +{ + partial class FormReaders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + panel1 = new Panel(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.AllowUserToResizeColumns = false; + dataGridView.AllowUserToResizeRows = false; + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(0, 0); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(656, 450); + dataGridView.TabIndex = 3; + // + // panel1 + // + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(656, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(144, 450); + panel1.TabIndex = 2; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.update; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(33, 128); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(75, 61); + buttonUpd.TabIndex = 2; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(33, 212); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(75, 60); + buttonDel.TabIndex = 1; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.plus; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(33, 36); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(75, 63); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormReaders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView); + Controls.Add(panel1); + Name = "FormReaders"; + Text = "FormReaders"; + Load += FormReaders_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Panel panel1; + private Button buttonUpd; + private Button buttonDel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormReaders.cs b/ProjectLibrary/ProjectLibrary/Forms/FormReaders.cs new file mode 100644 index 0000000..6e88bf7 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormReaders.cs @@ -0,0 +1,111 @@ +using ProjectLibrary.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ProjectLibrary.Forms +{ + public partial class FormReaders : Form + { + private readonly IUnityContainer _container; + + private readonly IReaderRepository _readerRepository; + public FormReaders(IUnityContainer container, IReaderRepository readerRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _readerRepository = readerRepository ?? throw new ArgumentNullException(nameof(readerRepository)); + } + + private void FormReaders_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().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_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 LoadList() => dataGridView.DataSource = _readerRepository.ReadReaders(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ProjectLibrary/ProjectLibrary/Forms/FormReaders.resx b/ProjectLibrary/ProjectLibrary/Forms/FormReaders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Forms/FormReaders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Program.cs b/ProjectLibrary/ProjectLibrary/Program.cs index 2baf02a..da391c5 100644 --- a/ProjectLibrary/ProjectLibrary/Program.cs +++ b/ProjectLibrary/ProjectLibrary/Program.cs @@ -1,3 +1,8 @@ +using Unity.Lifetime; +using Unity; +using ProjectLibrary.Repositories; +using ProjectLibrary.Repositories.Implementations; + namespace ProjectLibrary { internal static class Program @@ -11,7 +16,17 @@ namespace ProjectLibrary // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + return container; } } } \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/ProjectLibrary.csproj b/ProjectLibrary/ProjectLibrary/ProjectLibrary.csproj index 663fdb8..accbdf0 100644 --- a/ProjectLibrary/ProjectLibrary/ProjectLibrary.csproj +++ b/ProjectLibrary/ProjectLibrary/ProjectLibrary.csproj @@ -8,4 +8,23 @@ enable + + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Properties/Resources.Designer.cs b/ProjectLibrary/ProjectLibrary/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4a9518e --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectLibrary.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectLibrary.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap _312af421aa2411eebcbabe4f0f61c502_upscaled { + get { + object obj = ResourceManager.GetObject("312af421aa2411eebcbabe4f0f61c502_upscaled", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap update { + get { + object obj = ResourceManager.GetObject("update", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectLibrary/ProjectLibrary/Properties/Resources.resx b/ProjectLibrary/ProjectLibrary/Properties/Resources.resx new file mode 100644 index 0000000..973c2ba --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\312af421aa2411eebcbabe4f0f61c502_upscaled.jfif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\update.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectLibrary/ProjectLibrary/Repositories/IBookRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/IBookRepository.cs new file mode 100644 index 0000000..9e9e682 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/IBookRepository.cs @@ -0,0 +1,21 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories; + +public interface IBookRepository +{ + IEnumerable ReadBooks(); + + Book ReadBookById(int id); + + void CreateBook(Book book); + + void UpdateBook(Book book); + + void DeleteBook(int id); +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/IDoIssueRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/IDoIssueRepository.cs new file mode 100644 index 0000000..1699fca --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/IDoIssueRepository.cs @@ -0,0 +1,15 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories; + +public interface IDoIssueRepository +{ + IEnumerable ReadDoIssue(int? id, DateTime? dateFrom = null, DateTime? dateTo = null); + void CreateDoIssue(DoIssue doIssue); + void DeleteDoIssue(int id); +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/ILibrarianRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/ILibrarianRepository.cs new file mode 100644 index 0000000..f2abe85 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/ILibrarianRepository.cs @@ -0,0 +1,21 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories; + +public interface ILibrarianRepository +{ + IEnumerable ReadLibrarians(); + + Librarian ReadLibrarianById(int id); + + void CreateLibrarian(Librarian librarian); + + void UpdateLibrarian(Librarian librarian); + + void DeleteLibrarian(int id); +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/ILibrarianTopic.cs b/ProjectLibrary/ProjectLibrary/Repositories/ILibrarianTopic.cs new file mode 100644 index 0000000..cbf9657 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/ILibrarianTopic.cs @@ -0,0 +1,21 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories; + +public interface ILibrarianTopicRepository +{ + IEnumerable ReadLibrarianTopics(); + + LibrarianTopic ReadLibrarianTopicById(int id); + + void CreateLibrarianTopic(LibrarianTopic librarianTopic); + + void UpdateLibrarianTopic(LibrarianTopic librarianTopic); + + void DeleteLibrarianTopic(int id); +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/IReaderRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/IReaderRepository.cs new file mode 100644 index 0000000..fa24441 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/IReaderRepository.cs @@ -0,0 +1,21 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories; + +public interface IReaderRepository +{ + IEnumerable ReadReaders(); + + Reader ReadReaderById(int id); + + void CreateReader(Reader reader); + + void UpdateReader(Reader reader); + + void DeleteReader(int id); +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/Implementations/BookRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/BookRepository.cs new file mode 100644 index 0000000..ff34501 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/BookRepository.cs @@ -0,0 +1,33 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories.Implementations; + +public class BookRepository : IBookRepository +{ + public void CreateBook(Book book) + { + } + + public void DeleteBook(int id) + { + } + + public Book ReadBookById(int id) + { + return Book.CreateEntity(0, string.Empty, 0, false); + } + + public IEnumerable ReadBooks() + { + return []; + } + + public void UpdateBook(Book book) + { + } +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/Implementations/DoIssueRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/DoIssueRepository.cs new file mode 100644 index 0000000..bdb705a --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/DoIssueRepository.cs @@ -0,0 +1,24 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories.Implementations; + +public class DoIssueRepository : IDoIssueRepository +{ + public void CreateDoIssue(DoIssue doissue) + { + } + + public void DeleteDoIssue(int id) + { + } + + public IEnumerable ReadDoIssue(int? id, DateTime? dateFrom = null, DateTime? dateTo = null) + { + return []; + } +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/Implementations/LibrarianRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/LibrarianRepository.cs new file mode 100644 index 0000000..36439ab --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/LibrarianRepository.cs @@ -0,0 +1,34 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories.Implementations; + +public class LibrarianRepository : ILibrarianRepository +{ + public void CreateLibrarian(Librarian librarian) + { + } + + public void DeleteLibrarian(int id) + { + } + + public Librarian ReadLibrarianById(int id) + { + return Librarian.CreateEntity(0,string.Empty,0); + + } + + public IEnumerable ReadLibrarians() + { + return []; + } + + public void UpdateLibrarian(Librarian librarian) + { + } +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/Implementations/LibrarianTopicRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/LibrarianTopicRepository.cs new file mode 100644 index 0000000..4e783fd --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/LibrarianTopicRepository.cs @@ -0,0 +1,33 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories.Implementations; + +public class LibrarianTopicRepository : ILibrarianTopicRepository +{ + public void CreateLibrarianTopic(LibrarianTopic librarianTopic) + { + } + + public void DeleteLibrarianTopic(int id) + { + } + + public LibrarianTopic ReadLibrarianTopicById(int id) + { + return LibrarianTopic.CreateOperation(0,0); + } + + public IEnumerable ReadLibrarianTopics() + { + return []; + } + + public void UpdateLibrarianTopic(LibrarianTopic librarianTopic) + { + } +} diff --git a/ProjectLibrary/ProjectLibrary/Repositories/Implementations/ReaderRepository.cs b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/ReaderRepository.cs new file mode 100644 index 0000000..7a8e857 --- /dev/null +++ b/ProjectLibrary/ProjectLibrary/Repositories/Implementations/ReaderRepository.cs @@ -0,0 +1,33 @@ +using ProjectLibrary.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLibrary.Repositories.Implementations; + +public class ReaderRepository : IReaderRepository +{ + public void CreateReader(Reader reader) + { + } + + public void DeleteReader(int id) + { + } + + public Reader ReadReaderById(int id) + { + return Reader.CreateEntity(0,string.Empty,0); + } + + public IEnumerable ReadReaders() + { + return []; + } + + public void UpdateReader(Reader reader) + { + } +} diff --git a/ProjectLibrary/ProjectLibrary/Resources/312af421aa2411eebcbabe4f0f61c502_upscaled.jfif b/ProjectLibrary/ProjectLibrary/Resources/312af421aa2411eebcbabe4f0f61c502_upscaled.jfif new file mode 100644 index 0000000..03c6e32 Binary files /dev/null and b/ProjectLibrary/ProjectLibrary/Resources/312af421aa2411eebcbabe4f0f61c502_upscaled.jfif differ diff --git a/ProjectLibrary/ProjectLibrary/Resources/minus.png b/ProjectLibrary/ProjectLibrary/Resources/minus.png new file mode 100644 index 0000000..348ef53 Binary files /dev/null and b/ProjectLibrary/ProjectLibrary/Resources/minus.png differ diff --git a/ProjectLibrary/ProjectLibrary/Resources/plus.png b/ProjectLibrary/ProjectLibrary/Resources/plus.png new file mode 100644 index 0000000..a341f84 Binary files /dev/null and b/ProjectLibrary/ProjectLibrary/Resources/plus.png differ diff --git a/ProjectLibrary/ProjectLibrary/Resources/update.jpg b/ProjectLibrary/ProjectLibrary/Resources/update.jpg new file mode 100644 index 0000000..1cbbe55 Binary files /dev/null and b/ProjectLibrary/ProjectLibrary/Resources/update.jpg differ