3(2/1). Queries done, tables filled + operations (+ | upd | -) arranged
This commit is contained in:
parent
0bd35aa6c1
commit
a40674bff0
@ -1,12 +1,26 @@
|
|||||||
namespace LDBproject.AdditionalForms;
|
using LDBproject.Entities.Enums;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using LDBproject.Repositories;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class BookF : Form
|
public partial class BookF : Form
|
||||||
{
|
{
|
||||||
|
private readonly IBookRep _bookRepository;
|
||||||
private int? _bookID;
|
private int? _bookID;
|
||||||
|
|
||||||
public BookF()
|
public BookF(IBookRep bookR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_bookRepository = bookR ?? throw new ArgumentNullException(nameof(bookR));
|
||||||
|
|
||||||
|
StatusCbox.DataSource = Enum.GetValues(typeof(BookStat));
|
||||||
|
|
||||||
|
// Populate the checkbox list with enum values as before
|
||||||
|
foreach (var elem in Enum.GetValues(typeof(Genres)))
|
||||||
|
{
|
||||||
|
GenresChBoxList.Items.Add(elem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ID
|
public int ID
|
||||||
@ -15,6 +29,37 @@ public partial class BookF : Form
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var book = _bookRepository.GetBookByID(value);
|
||||||
|
|
||||||
|
if (book == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException(nameof(book));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear all checkboxes
|
||||||
|
for (int i = 0; i < GenresChBoxList.Items.Count; i++)
|
||||||
|
{
|
||||||
|
GenresChBoxList.SetItemChecked(i, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the checkboxes based on the book's GenreIDs
|
||||||
|
foreach (Genres genre in Enum.GetValues(typeof(Genres)))
|
||||||
|
{
|
||||||
|
if ((genre & book.GenreMask) != 0)
|
||||||
|
{
|
||||||
|
int index = GenresChBoxList.Items.IndexOf(genre);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
GenresChBoxList.SetItemChecked(index, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TitleTb.Text = book.Title;
|
||||||
|
AuthorTb.Text = book.Author;
|
||||||
|
YearNud.Value = book.PublishYear;
|
||||||
|
StatusCbox.SelectedItem = book.Status;
|
||||||
|
|
||||||
_bookID = value;
|
_bookID = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -38,11 +83,11 @@ public partial class BookF : Form
|
|||||||
|
|
||||||
if (_bookID.HasValue)
|
if (_bookID.HasValue)
|
||||||
{
|
{
|
||||||
|
_bookRepository.UpdateBook(CreateBook(_bookID.Value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_bookRepository.AddBook(CreateBook(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
@ -56,5 +101,16 @@ public partial class BookF : Form
|
|||||||
|
|
||||||
private void DiscardBtn_Click(object sender, EventArgs e) => Close();
|
private void DiscardBtn_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private object CreateBook(int id) { return null; }
|
private Book CreateBook(int id)
|
||||||
|
{
|
||||||
|
Genres selectedGenres = Genres.None;
|
||||||
|
foreach (var item in GenresChBoxList.CheckedItems)
|
||||||
|
{
|
||||||
|
if (item is Genres genre)
|
||||||
|
selectedGenres |= genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Book.AddBook(id, TitleTb.Text, AuthorTb.Text,
|
||||||
|
(int)YearNud.Value, selectedGenres, (BookStat)StatusCbox.SelectedItem!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using Unity;
|
using LDBproject.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace LDBproject.AdditionalForms;
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class BookListF : Form
|
public partial class BookListF : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IBookRep _bookR;
|
||||||
|
|
||||||
public BookListF(IUnityContainer container)
|
public BookListF(IUnityContainer container, IBookRep bookR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_bookR = bookR ?? throw new ArgumentNullException(nameof(bookR));
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,43 +40,6 @@ public partial class BookListF : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DelBtn_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!GetIDFromRow(out var foundID))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MessageBox.Show("Remove element?", "Deleting", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ReloadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Book List Form [ Error while removing element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadList() { }
|
|
||||||
|
|
||||||
private bool GetIDFromRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (DataGV.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("[ Error : Book doesn't exist ]", "<ERROR>",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
id = Convert.ToInt32(DataGV.SelectedRows[0].Cells["BookID"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdBtn_Click(object sender, EventArgs e)
|
private void UpdBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!GetIDFromRow(out var findID))
|
if (!GetIDFromRow(out var findID))
|
||||||
@ -93,4 +59,42 @@ public partial class BookListF : Form
|
|||||||
MessageBox.Show(ex.Message, "Book List Form [ Error while updating element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Book List Form [ Error while updating element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ReloadList() => DataGV.DataSource = _bookR.GetBookList();
|
||||||
|
|
||||||
|
private void DelBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!GetIDFromRow(out var foundID))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Remove element?", "Deleting", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_bookR.DeleteBook(foundID);
|
||||||
|
ReloadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Book List Form [ Error while removing element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool GetIDFromRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (DataGV.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("[ Error : Book doesn't exist ]", "<ERROR>",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
id = Convert.ToInt32(DataGV.SelectedRows[0].Cells["BookID"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
namespace LDBproject.AdditionalForms;
|
using LDBproject.Entities;
|
||||||
|
using LDBproject.Repositories;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class CustomerF : Form
|
public partial class CustomerF : Form
|
||||||
{
|
{
|
||||||
|
private readonly ICustomerCardsRep _customeRepository;
|
||||||
private int? _custID;
|
private int? _custID;
|
||||||
|
|
||||||
public CustomerF()
|
public CustomerF(ICustomerCardsRep customeR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_customeRepository = customeR ?? throw new ArgumentNullException(nameof(customeR));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ID
|
public int ID
|
||||||
@ -15,6 +20,16 @@ public partial class CustomerF : Form
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var reader = _customeRepository.GetCardByID(value);
|
||||||
|
|
||||||
|
if (reader == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException(nameof(reader));
|
||||||
|
}
|
||||||
|
|
||||||
|
FIOEnterTb.Text = reader.FIO;
|
||||||
|
BirthdayDTPicker.Value = reader.AgeBirthday;
|
||||||
|
|
||||||
_custID = value;
|
_custID = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -37,11 +52,11 @@ public partial class CustomerF : Form
|
|||||||
|
|
||||||
if (_custID.HasValue)
|
if (_custID.HasValue)
|
||||||
{
|
{
|
||||||
|
_customeRepository.UpdateCard(CreateCustomer(_custID.Value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_customeRepository.AddCard(CreateCustomer(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
@ -55,5 +70,8 @@ public partial class CustomerF : Form
|
|||||||
|
|
||||||
private void CancelBtn_Click(object sender, EventArgs e) => Close();
|
private void CancelBtn_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private object CreateCustomer(int id) { return null; }
|
private CustomerCard CreateCustomer(int id)
|
||||||
|
{
|
||||||
|
return CustomerCard.AddCustomer(id, FIOEnterTb.Text, BirthdayDTPicker.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using Unity;
|
using LDBproject.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace LDBproject.AdditionalForms;
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class CustomerListF : Form
|
public partial class CustomerListF : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly ICustomerCardsRep _custR;
|
||||||
|
|
||||||
public CustomerListF(IUnityContainer container)
|
public CustomerListF(IUnityContainer container, ICustomerCardsRep customeR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_custR = customeR ?? throw new ArgumentNullException(nameof(customeR));
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ public partial class CustomerListF : Form
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_custR.DeleteCard(foundID);
|
||||||
ReloadList();
|
ReloadList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -59,7 +63,8 @@ public partial class CustomerListF : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadList() { }
|
private void ReloadList() =>
|
||||||
|
DataGV.DataSource = _custR.GetCards();
|
||||||
|
|
||||||
private bool GetIDFromRow(out int id)
|
private bool GetIDFromRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
namespace LDBproject.AdditionalForms;
|
using LDBproject.Entities.Enums;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using LDBproject.Repositories;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class EmployeeF : Form
|
public partial class EmployeeF : Form
|
||||||
{
|
{
|
||||||
|
private readonly ILibrarianRep _libRepository;
|
||||||
private int? _librarianID;
|
private int? _librarianID;
|
||||||
|
|
||||||
public EmployeeF()
|
public EmployeeF(ILibrarianRep librarianR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_libRepository = librarianR ?? throw new ArgumentNullException(nameof(librarianR));
|
||||||
|
foreach (var elem in Enum.GetValues(typeof(Genres)))
|
||||||
|
{
|
||||||
|
GenresCheckedBL.Items.Add(elem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ID
|
public int ID
|
||||||
@ -15,6 +25,30 @@ public partial class EmployeeF : Form
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var librarian = _libRepository.GetCardByID(value);
|
||||||
|
if (librarian == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException(nameof(librarian));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uncheck all genres in the checklist box
|
||||||
|
for (int i = 0; i < GenresCheckedBL.Items.Count; i++)
|
||||||
|
{
|
||||||
|
GenresCheckedBL.SetItemChecked(i, false);
|
||||||
|
}
|
||||||
|
// Check the genres that are in the bitmask
|
||||||
|
foreach (Genres genre in Enum.GetValues(typeof(Genres)))
|
||||||
|
{
|
||||||
|
if ((genre & librarian.GenreMask) != 0 && genre != Genres.None)
|
||||||
|
{
|
||||||
|
int index = GenresCheckedBL.Items.IndexOf(genre);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
GenresCheckedBL.SetItemChecked(index, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FIOEnterTb.Text = librarian.FIO;
|
||||||
_librarianID = value;
|
_librarianID = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -37,11 +71,11 @@ public partial class EmployeeF : Form
|
|||||||
|
|
||||||
if (_librarianID.HasValue)
|
if (_librarianID.HasValue)
|
||||||
{
|
{
|
||||||
|
_libRepository.ChangeCardInfo(CreateWorker(_librarianID.Value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_libRepository.AddCard(CreateWorker(0));
|
||||||
}
|
}
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
@ -54,6 +88,16 @@ public partial class EmployeeF : Form
|
|||||||
|
|
||||||
private void CancelBtn_Click(object sender, EventArgs e) => Close();
|
private void CancelBtn_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private object CreateWorker(int id) { return null; }
|
private LibrarianCard CreateWorker(int id)
|
||||||
|
{
|
||||||
|
Genres selectedGenres = Genres.None;
|
||||||
|
foreach (var item in GenresCheckedBL.CheckedItems)
|
||||||
|
{
|
||||||
|
if (item is Genres genre)
|
||||||
|
selectedGenres |= genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LibrarianCard.AddWorker(id, FIOEnterTb.Text, selectedGenres);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using Unity;
|
using LDBproject.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace LDBproject.AdditionalForms;
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class EmployeesF : Form
|
public partial class EmployeesF : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly ILibrarianRep _libR;
|
||||||
|
|
||||||
public EmployeesF(IUnityContainer container)
|
public EmployeesF(IUnityContainer container, ILibrarianRep libR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_libR = libR ?? throw new ArgumentNullException(nameof(libR));
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +74,7 @@ public partial class EmployeesF : Form
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_libR.DeleteCard(foundID);
|
||||||
ReloadList();
|
ReloadList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -79,7 +83,7 @@ public partial class EmployeesF : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadList() { }
|
private void ReloadList() => DataGV.DataSource = _libR.GetCards();
|
||||||
|
|
||||||
private bool GetiDFromRow(out int id)
|
private bool GetiDFromRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using Unity;
|
using LDBproject.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace LDBproject.AdditionalForms;
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class OrderRegistrations : Form
|
public partial class OrderRegistrations : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IOrderRep _regR;
|
||||||
|
|
||||||
public OrderRegistrations(IUnityContainer container)
|
public OrderRegistrations(IUnityContainer container, IOrderRep regR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_regR = regR ?? throw new ArgumentNullException(nameof(regR));
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ public partial class OrderRegistrations : Form
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_regR.DeleteOrderinfo(foundID);
|
||||||
ReloadList();
|
ReloadList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -59,7 +63,8 @@ public partial class OrderRegistrations : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadList() { }
|
private void ReloadList() =>
|
||||||
|
DataGV.DataSource = _regR.GetOrdersInfo();
|
||||||
|
|
||||||
private bool GetIDFromRow(out int id)
|
private bool GetIDFromRow(out int id)
|
||||||
{
|
{
|
||||||
|
112
LibraryDBproject/LDBproj/AdditionalForms/OrdersF.Designer.cs
generated
Normal file
112
LibraryDBproject/LDBproj/AdditionalForms/OrdersF.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
namespace LDBproject.AdditionalForms
|
||||||
|
{
|
||||||
|
partial class OrdersF
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
panel1 = new Panel();
|
||||||
|
DelBtn = new Button();
|
||||||
|
AddBtn = new Button();
|
||||||
|
DataGV = new DataGridView();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)DataGV).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.BackColor = Color.Transparent;
|
||||||
|
panel1.Controls.Add(DelBtn);
|
||||||
|
panel1.Controls.Add(AddBtn);
|
||||||
|
panel1.Dock = DockStyle.Right;
|
||||||
|
panel1.Location = new Point(430, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(246, 364);
|
||||||
|
panel1.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// DelBtn
|
||||||
|
//
|
||||||
|
DelBtn.BackColor = Color.DarkSlateBlue;
|
||||||
|
DelBtn.BackgroundImage = Properties.Resources.DelImg;
|
||||||
|
DelBtn.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
DelBtn.ForeColor = Color.Transparent;
|
||||||
|
DelBtn.Location = new Point(129, 34);
|
||||||
|
DelBtn.Name = "DelBtn";
|
||||||
|
DelBtn.Size = new Size(78, 71);
|
||||||
|
DelBtn.TabIndex = 6;
|
||||||
|
DelBtn.UseVisualStyleBackColor = false;
|
||||||
|
DelBtn.Click += DelBtn_Click;
|
||||||
|
//
|
||||||
|
// AddBtn
|
||||||
|
//
|
||||||
|
AddBtn.BackColor = Color.DarkSlateBlue;
|
||||||
|
AddBtn.BackgroundImage = Properties.Resources.AddImg;
|
||||||
|
AddBtn.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
AddBtn.ForeColor = Color.Transparent;
|
||||||
|
AddBtn.Location = new Point(24, 34);
|
||||||
|
AddBtn.Name = "AddBtn";
|
||||||
|
AddBtn.Size = new Size(78, 71);
|
||||||
|
AddBtn.TabIndex = 4;
|
||||||
|
AddBtn.UseVisualStyleBackColor = false;
|
||||||
|
AddBtn.Click += AddBtn_Click;
|
||||||
|
//
|
||||||
|
// DataGV
|
||||||
|
//
|
||||||
|
DataGV.BackgroundColor = Color.DarkSlateBlue;
|
||||||
|
DataGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
DataGV.GridColor = Color.GreenYellow;
|
||||||
|
DataGV.Location = new Point(28, 86);
|
||||||
|
DataGV.Name = "DataGV";
|
||||||
|
DataGV.RowHeadersWidth = 62;
|
||||||
|
DataGV.Size = new Size(357, 245);
|
||||||
|
DataGV.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// OrderRegistrations
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BackgroundImage = Properties.Resources.RegistrationsFrameCover;
|
||||||
|
BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
ClientSize = new Size(676, 364);
|
||||||
|
Controls.Add(DataGV);
|
||||||
|
Controls.Add(panel1);
|
||||||
|
DoubleBuffered = true;
|
||||||
|
Name = "OrderRegistrations";
|
||||||
|
Text = "OrderRegistrations";
|
||||||
|
Load += RegistrationsF_Load;
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)DataGV).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
|
private Button DelBtn;
|
||||||
|
private Button AddBtn;
|
||||||
|
private DataGridView DataGV;
|
||||||
|
}
|
||||||
|
}
|
83
LibraryDBproject/LDBproj/AdditionalForms/OrdersF.cs
Normal file
83
LibraryDBproject/LDBproj/AdditionalForms/OrdersF.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
using LDBproject.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
|
public partial class OrdersF : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IOrderRep _regR;
|
||||||
|
|
||||||
|
public OrdersF(IUnityContainer container, IOrderRep regR)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_regR = regR ?? throw new ArgumentNullException(nameof(regR));
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RegistrationsF_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReloadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error while saving ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<RegOrderF>().ShowDialog();
|
||||||
|
ReloadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error while adding element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DelBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!GetIDFromRow(out var foundID))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Remove element?", "Deleting", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_regR.DeleteOrderinfo(foundID);
|
||||||
|
ReloadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "[ Error while removing element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadList() =>
|
||||||
|
DataGV.DataSource = _regR.GetOrdersInfo();
|
||||||
|
|
||||||
|
private bool GetIDFromRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (DataGV.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("[ Error : element doesn't exist ]", "<ERROR>",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
id = Convert.ToInt32(DataGV.SelectedRows[0].Cells["OrderID"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
120
LibraryDBproject/LDBproj/AdditionalForms/OrdersF.resx
Normal file
120
LibraryDBproject/LDBproj/AdditionalForms/OrdersF.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>
|
@ -31,15 +31,15 @@
|
|||||||
LibrarianCBox = new ComboBox();
|
LibrarianCBox = new ComboBox();
|
||||||
LibLabel = new Label();
|
LibLabel = new Label();
|
||||||
DateLabel = new Label();
|
DateLabel = new Label();
|
||||||
ReturnDTPicker = new DateTimePicker();
|
BorrowDTPicker = new DateTimePicker();
|
||||||
groupBox1 = new GroupBox();
|
groupBox1 = new GroupBox();
|
||||||
DataGV = new DataGridView();
|
DataGV = new DataGridView();
|
||||||
BookColumnCBox = new DataGridViewComboBoxColumn();
|
|
||||||
AuthorColumn = new DataGridViewTextBoxColumn();
|
|
||||||
SaveBtn = new Button();
|
SaveBtn = new Button();
|
||||||
BackBtn = new Button();
|
BackBtn = new Button();
|
||||||
ReaderLabel = new Label();
|
ReaderLabel = new Label();
|
||||||
CardCBox = new ComboBox();
|
CardCBox = new ComboBox();
|
||||||
|
BookColumnCBox = new DataGridViewComboBoxColumn();
|
||||||
|
NoteColumn = new DataGridViewTextBoxColumn();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)DataGV).BeginInit();
|
((System.ComponentModel.ISupportInitialize)DataGV).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -47,42 +47,48 @@
|
|||||||
// LibrarianCBox
|
// LibrarianCBox
|
||||||
//
|
//
|
||||||
LibrarianCBox.FormattingEnabled = true;
|
LibrarianCBox.FormattingEnabled = true;
|
||||||
LibrarianCBox.Location = new Point(119, 21);
|
LibrarianCBox.Location = new Point(155, 44);
|
||||||
|
LibrarianCBox.Margin = new Padding(4);
|
||||||
LibrarianCBox.Name = "LibrarianCBox";
|
LibrarianCBox.Name = "LibrarianCBox";
|
||||||
LibrarianCBox.Size = new Size(182, 33);
|
LibrarianCBox.Size = new Size(235, 40);
|
||||||
LibrarianCBox.TabIndex = 0;
|
LibrarianCBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// LibLabel
|
// LibLabel
|
||||||
//
|
//
|
||||||
LibLabel.AutoSize = true;
|
LibLabel.AutoSize = true;
|
||||||
LibLabel.Location = new Point(30, 24);
|
LibLabel.Location = new Point(39, 47);
|
||||||
|
LibLabel.Margin = new Padding(4, 0, 4, 0);
|
||||||
LibLabel.Name = "LibLabel";
|
LibLabel.Name = "LibLabel";
|
||||||
LibLabel.Size = new Size(83, 25);
|
LibLabel.Size = new Size(110, 32);
|
||||||
LibLabel.TabIndex = 1;
|
LibLabel.TabIndex = 1;
|
||||||
LibLabel.Text = "Librarian:";
|
LibLabel.Text = "Librarian:";
|
||||||
//
|
//
|
||||||
// DateLabel
|
// DateLabel
|
||||||
//
|
//
|
||||||
DateLabel.AutoSize = true;
|
DateLabel.AutoSize = true;
|
||||||
DateLabel.Location = new Point(30, 128);
|
DateLabel.Location = new Point(39, 164);
|
||||||
|
DateLabel.Margin = new Padding(4, 0, 4, 0);
|
||||||
DateLabel.Name = "DateLabel";
|
DateLabel.Name = "DateLabel";
|
||||||
DateLabel.Size = new Size(107, 25);
|
DateLabel.Size = new Size(148, 32);
|
||||||
DateLabel.TabIndex = 2;
|
DateLabel.TabIndex = 2;
|
||||||
DateLabel.Text = "Return date:";
|
DateLabel.Text = "Borrow date:";
|
||||||
//
|
//
|
||||||
// ReturnDTPicker
|
// BorrowDTPicker
|
||||||
//
|
//
|
||||||
ReturnDTPicker.Location = new Point(37, 163);
|
BorrowDTPicker.Location = new Point(48, 209);
|
||||||
ReturnDTPicker.Name = "ReturnDTPicker";
|
BorrowDTPicker.Margin = new Padding(4);
|
||||||
ReturnDTPicker.Size = new Size(264, 31);
|
BorrowDTPicker.Name = "BorrowDTPicker";
|
||||||
ReturnDTPicker.TabIndex = 3;
|
BorrowDTPicker.Size = new Size(342, 39);
|
||||||
|
BorrowDTPicker.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
groupBox1.Controls.Add(DataGV);
|
groupBox1.Controls.Add(DataGV);
|
||||||
groupBox1.Location = new Point(334, 24);
|
groupBox1.Location = new Point(434, 31);
|
||||||
|
groupBox1.Margin = new Padding(4);
|
||||||
groupBox1.Name = "groupBox1";
|
groupBox1.Name = "groupBox1";
|
||||||
groupBox1.Size = new Size(423, 266);
|
groupBox1.Padding = new Padding(4);
|
||||||
|
groupBox1.Size = new Size(550, 340);
|
||||||
groupBox1.TabIndex = 4;
|
groupBox1.TabIndex = 4;
|
||||||
groupBox1.TabStop = false;
|
groupBox1.TabStop = false;
|
||||||
groupBox1.Text = "BookListGBox";
|
groupBox1.Text = "BookListGBox";
|
||||||
@ -90,32 +96,20 @@
|
|||||||
// DataGV
|
// DataGV
|
||||||
//
|
//
|
||||||
DataGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
DataGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
DataGV.Columns.AddRange(new DataGridViewColumn[] { BookColumnCBox, AuthorColumn });
|
DataGV.Columns.AddRange(new DataGridViewColumn[] { BookColumnCBox, NoteColumn });
|
||||||
DataGV.Location = new Point(6, 41);
|
DataGV.Location = new Point(8, 52);
|
||||||
|
DataGV.Margin = new Padding(4);
|
||||||
DataGV.Name = "DataGV";
|
DataGV.Name = "DataGV";
|
||||||
DataGV.RowHeadersWidth = 62;
|
DataGV.RowHeadersWidth = 62;
|
||||||
DataGV.Size = new Size(411, 206);
|
DataGV.Size = new Size(534, 264);
|
||||||
DataGV.TabIndex = 0;
|
DataGV.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// BookColumnCBox
|
|
||||||
//
|
|
||||||
BookColumnCBox.HeaderText = "Book's title";
|
|
||||||
BookColumnCBox.MinimumWidth = 8;
|
|
||||||
BookColumnCBox.Name = "BookColumnCBox";
|
|
||||||
BookColumnCBox.Width = 150;
|
|
||||||
//
|
|
||||||
// AuthorColumn
|
|
||||||
//
|
|
||||||
AuthorColumn.HeaderText = "Author";
|
|
||||||
AuthorColumn.MinimumWidth = 8;
|
|
||||||
AuthorColumn.Name = "AuthorColumn";
|
|
||||||
AuthorColumn.Width = 150;
|
|
||||||
//
|
|
||||||
// SaveBtn
|
// SaveBtn
|
||||||
//
|
//
|
||||||
SaveBtn.Location = new Point(37, 216);
|
SaveBtn.Location = new Point(48, 276);
|
||||||
|
SaveBtn.Margin = new Padding(4);
|
||||||
SaveBtn.Name = "SaveBtn";
|
SaveBtn.Name = "SaveBtn";
|
||||||
SaveBtn.Size = new Size(264, 34);
|
SaveBtn.Size = new Size(343, 44);
|
||||||
SaveBtn.TabIndex = 5;
|
SaveBtn.TabIndex = 5;
|
||||||
SaveBtn.Text = "Save and give out";
|
SaveBtn.Text = "Save and give out";
|
||||||
SaveBtn.UseVisualStyleBackColor = true;
|
SaveBtn.UseVisualStyleBackColor = true;
|
||||||
@ -123,9 +117,10 @@
|
|||||||
//
|
//
|
||||||
// BackBtn
|
// BackBtn
|
||||||
//
|
//
|
||||||
BackBtn.Location = new Point(37, 256);
|
BackBtn.Location = new Point(48, 328);
|
||||||
|
BackBtn.Margin = new Padding(4);
|
||||||
BackBtn.Name = "BackBtn";
|
BackBtn.Name = "BackBtn";
|
||||||
BackBtn.Size = new Size(264, 34);
|
BackBtn.Size = new Size(343, 44);
|
||||||
BackBtn.TabIndex = 6;
|
BackBtn.TabIndex = 6;
|
||||||
BackBtn.Text = "Go back";
|
BackBtn.Text = "Go back";
|
||||||
BackBtn.UseVisualStyleBackColor = true;
|
BackBtn.UseVisualStyleBackColor = true;
|
||||||
@ -134,34 +129,51 @@
|
|||||||
// ReaderLabel
|
// ReaderLabel
|
||||||
//
|
//
|
||||||
ReaderLabel.AutoSize = true;
|
ReaderLabel.AutoSize = true;
|
||||||
ReaderLabel.Location = new Point(30, 65);
|
ReaderLabel.Location = new Point(39, 90);
|
||||||
|
ReaderLabel.Margin = new Padding(4, 0, 4, 0);
|
||||||
ReaderLabel.Name = "ReaderLabel";
|
ReaderLabel.Name = "ReaderLabel";
|
||||||
ReaderLabel.Size = new Size(66, 50);
|
ReaderLabel.Size = new Size(87, 64);
|
||||||
ReaderLabel.TabIndex = 7;
|
ReaderLabel.TabIndex = 7;
|
||||||
ReaderLabel.Text = "Reader\r\ncard:";
|
ReaderLabel.Text = "Reader\r\ncard:";
|
||||||
//
|
//
|
||||||
// CardCBox
|
// CardCBox
|
||||||
//
|
//
|
||||||
CardCBox.FormattingEnabled = true;
|
CardCBox.FormattingEnabled = true;
|
||||||
CardCBox.Location = new Point(119, 82);
|
CardCBox.Location = new Point(155, 105);
|
||||||
|
CardCBox.Margin = new Padding(4);
|
||||||
CardCBox.Name = "CardCBox";
|
CardCBox.Name = "CardCBox";
|
||||||
CardCBox.Size = new Size(182, 33);
|
CardCBox.Size = new Size(235, 40);
|
||||||
CardCBox.TabIndex = 8;
|
CardCBox.TabIndex = 8;
|
||||||
//
|
//
|
||||||
|
// BookColumnCBox
|
||||||
|
//
|
||||||
|
BookColumnCBox.HeaderText = "Book's title";
|
||||||
|
BookColumnCBox.MinimumWidth = 8;
|
||||||
|
BookColumnCBox.Name = "BookColumnCBox";
|
||||||
|
BookColumnCBox.Width = 150;
|
||||||
|
//
|
||||||
|
// NoteColumn
|
||||||
|
//
|
||||||
|
NoteColumn.HeaderText = "Note";
|
||||||
|
NoteColumn.MinimumWidth = 8;
|
||||||
|
NoteColumn.Name = "NoteColumn";
|
||||||
|
NoteColumn.Width = 150;
|
||||||
|
//
|
||||||
// RegOrder
|
// RegOrder
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(785, 314);
|
ClientSize = new Size(1020, 402);
|
||||||
Controls.Add(CardCBox);
|
Controls.Add(CardCBox);
|
||||||
Controls.Add(ReaderLabel);
|
Controls.Add(ReaderLabel);
|
||||||
Controls.Add(BackBtn);
|
Controls.Add(BackBtn);
|
||||||
Controls.Add(SaveBtn);
|
Controls.Add(SaveBtn);
|
||||||
Controls.Add(groupBox1);
|
Controls.Add(groupBox1);
|
||||||
Controls.Add(ReturnDTPicker);
|
Controls.Add(BorrowDTPicker);
|
||||||
Controls.Add(DateLabel);
|
Controls.Add(DateLabel);
|
||||||
Controls.Add(LibLabel);
|
Controls.Add(LibLabel);
|
||||||
Controls.Add(LibrarianCBox);
|
Controls.Add(LibrarianCBox);
|
||||||
|
Margin = new Padding(4);
|
||||||
Name = "RegOrder";
|
Name = "RegOrder";
|
||||||
Text = "RegOrder";
|
Text = "RegOrder";
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
@ -175,7 +187,7 @@
|
|||||||
private ComboBox LibrarianCBox;
|
private ComboBox LibrarianCBox;
|
||||||
private Label LibLabel;
|
private Label LibLabel;
|
||||||
private Label DateLabel;
|
private Label DateLabel;
|
||||||
private DateTimePicker ReturnDTPicker;
|
private DateTimePicker BorrowDTPicker;
|
||||||
private GroupBox groupBox1;
|
private GroupBox groupBox1;
|
||||||
private DataGridView DataGV;
|
private DataGridView DataGV;
|
||||||
private Button SaveBtn;
|
private Button SaveBtn;
|
||||||
@ -183,6 +195,6 @@
|
|||||||
private Label ReaderLabel;
|
private Label ReaderLabel;
|
||||||
private ComboBox CardCBox;
|
private ComboBox CardCBox;
|
||||||
private DataGridViewComboBoxColumn BookColumnCBox;
|
private DataGridViewComboBoxColumn BookColumnCBox;
|
||||||
private DataGridViewTextBoxColumn AuthorColumn;
|
private DataGridViewTextBoxColumn NoteColumn;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,28 @@
|
|||||||
namespace LDBproject.AdditionalForms;
|
using LDBproject.Entities;
|
||||||
|
using LDBproject.Repositories;
|
||||||
|
using LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class RegOrder : Form
|
public partial class RegOrder : Form
|
||||||
{
|
{
|
||||||
public RegOrder()
|
private readonly IOrderRep _orderRepository;
|
||||||
|
|
||||||
|
public RegOrder(IOrderRep orderRep, ICustomerCardsRep readerRep,
|
||||||
|
ILibrarianRep employeeRep, IBookRep bookRep)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_orderRepository = orderRep ?? throw new ArgumentNullException(nameof(orderRep));
|
||||||
|
|
||||||
|
LibrarianCBox.DataSource = employeeRep.GetCards();
|
||||||
LibrarianCBox.DisplayMember = "FIO";
|
LibrarianCBox.DisplayMember = "FIO";
|
||||||
LibrarianCBox.ValueMember = "CardID";
|
LibrarianCBox.ValueMember = "CardID";
|
||||||
|
|
||||||
|
CardCBox.DataSource = readerRep.GetCards();
|
||||||
CardCBox.DisplayMember = "FIO";
|
CardCBox.DisplayMember = "FIO";
|
||||||
CardCBox.ValueMember = "CardID";
|
CardCBox.ValueMember = "CardID";
|
||||||
|
|
||||||
|
BookColumnCBox.DataSource = bookRep.GetBookList();
|
||||||
BookColumnCBox.DisplayMember = "Title";
|
BookColumnCBox.DisplayMember = "Title";
|
||||||
BookColumnCBox.ValueMember = "BookID";
|
BookColumnCBox.ValueMember = "BookID";
|
||||||
}
|
}
|
||||||
@ -24,27 +35,32 @@ public partial class RegOrder : Form
|
|||||||
{
|
{
|
||||||
throw new Exception("[ Blanck space left ]");
|
throw new Exception("[ Blanck space left ]");
|
||||||
}
|
}
|
||||||
|
_orderRepository.CreateOrder(Order.NewOrder(0, (int)CardCBox.SelectedValue, (int)LibrarianCBox.SelectedValue,
|
||||||
|
CreateBookListFromDG(), BorrowDTPicker.Value));
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "[ Saving error ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Order Form [ Error while saving order ]",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Registration> CreateBookListFromDG()
|
||||||
|
{
|
||||||
|
List<Registration> registrations = new List<Registration>();
|
||||||
|
foreach (DataGridViewRow row in DataGV.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["BookColumnCBox"].Value != null)
|
||||||
|
{
|
||||||
|
var bookId = (int)row.Cells["BookColumnCBox"].Value;
|
||||||
|
var notes = row.Cells["NoteColumn"].Value?.ToString();
|
||||||
|
registrations.Add(Registration.OrderReg(0, bookId, notes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return registrations;
|
||||||
|
}
|
||||||
|
|
||||||
private void BackBtn_Click(object sender, EventArgs e) => Close();
|
private void BackBtn_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private List<object> CreateBookListFromDG()
|
|
||||||
{
|
|
||||||
var list = new List<object>();
|
|
||||||
foreach (DataGridViewRow row in DataGV.Rows)
|
|
||||||
{
|
|
||||||
if (row.Cells["BookColumn"].Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@
|
|||||||
<metadata name="BookColumnCBox.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="BookColumnCBox.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="AuthorColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="NoteColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
200
LibraryDBproject/LDBproj/AdditionalForms/RegOrderF.Designer.cs
generated
Normal file
200
LibraryDBproject/LDBproj/AdditionalForms/RegOrderF.Designer.cs
generated
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
namespace LDBproject.AdditionalForms
|
||||||
|
{
|
||||||
|
partial class RegOrderF
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
LibrarianCBox = new ComboBox();
|
||||||
|
LibLabel = new Label();
|
||||||
|
DateLabel = new Label();
|
||||||
|
BorrowDTPicker = new DateTimePicker();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
DataGV = new DataGridView();
|
||||||
|
SaveBtn = new Button();
|
||||||
|
BackBtn = new Button();
|
||||||
|
ReaderLabel = new Label();
|
||||||
|
CardCBox = new ComboBox();
|
||||||
|
BookColumnCBox = new DataGridViewComboBoxColumn();
|
||||||
|
NoteColumn = new DataGridViewTextBoxColumn();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)DataGV).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// LibrarianCBox
|
||||||
|
//
|
||||||
|
LibrarianCBox.FormattingEnabled = true;
|
||||||
|
LibrarianCBox.Location = new Point(155, 44);
|
||||||
|
LibrarianCBox.Margin = new Padding(4);
|
||||||
|
LibrarianCBox.Name = "LibrarianCBox";
|
||||||
|
LibrarianCBox.Size = new Size(235, 40);
|
||||||
|
LibrarianCBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// LibLabel
|
||||||
|
//
|
||||||
|
LibLabel.AutoSize = true;
|
||||||
|
LibLabel.Location = new Point(39, 47);
|
||||||
|
LibLabel.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
LibLabel.Name = "LibLabel";
|
||||||
|
LibLabel.Size = new Size(110, 32);
|
||||||
|
LibLabel.TabIndex = 1;
|
||||||
|
LibLabel.Text = "Librarian:";
|
||||||
|
//
|
||||||
|
// DateLabel
|
||||||
|
//
|
||||||
|
DateLabel.AutoSize = true;
|
||||||
|
DateLabel.Location = new Point(39, 164);
|
||||||
|
DateLabel.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
DateLabel.Name = "DateLabel";
|
||||||
|
DateLabel.Size = new Size(148, 32);
|
||||||
|
DateLabel.TabIndex = 2;
|
||||||
|
DateLabel.Text = "Borrow date:";
|
||||||
|
//
|
||||||
|
// BorrowDTPicker
|
||||||
|
//
|
||||||
|
BorrowDTPicker.Location = new Point(48, 209);
|
||||||
|
BorrowDTPicker.Margin = new Padding(4);
|
||||||
|
BorrowDTPicker.Name = "BorrowDTPicker";
|
||||||
|
BorrowDTPicker.Size = new Size(342, 39);
|
||||||
|
BorrowDTPicker.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(DataGV);
|
||||||
|
groupBox1.Location = new Point(434, 31);
|
||||||
|
groupBox1.Margin = new Padding(4);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(4);
|
||||||
|
groupBox1.Size = new Size(550, 340);
|
||||||
|
groupBox1.TabIndex = 4;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "BookListGBox";
|
||||||
|
//
|
||||||
|
// DataGV
|
||||||
|
//
|
||||||
|
DataGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
DataGV.Columns.AddRange(new DataGridViewColumn[] { BookColumnCBox, NoteColumn });
|
||||||
|
DataGV.Location = new Point(8, 52);
|
||||||
|
DataGV.Margin = new Padding(4);
|
||||||
|
DataGV.Name = "DataGV";
|
||||||
|
DataGV.RowHeadersWidth = 62;
|
||||||
|
DataGV.Size = new Size(534, 264);
|
||||||
|
DataGV.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// SaveBtn
|
||||||
|
//
|
||||||
|
SaveBtn.Location = new Point(48, 276);
|
||||||
|
SaveBtn.Margin = new Padding(4);
|
||||||
|
SaveBtn.Name = "SaveBtn";
|
||||||
|
SaveBtn.Size = new Size(343, 44);
|
||||||
|
SaveBtn.TabIndex = 5;
|
||||||
|
SaveBtn.Text = "Save and give out";
|
||||||
|
SaveBtn.UseVisualStyleBackColor = true;
|
||||||
|
SaveBtn.Click += SaveBtn_Click;
|
||||||
|
//
|
||||||
|
// BackBtn
|
||||||
|
//
|
||||||
|
BackBtn.Location = new Point(48, 328);
|
||||||
|
BackBtn.Margin = new Padding(4);
|
||||||
|
BackBtn.Name = "BackBtn";
|
||||||
|
BackBtn.Size = new Size(343, 44);
|
||||||
|
BackBtn.TabIndex = 6;
|
||||||
|
BackBtn.Text = "Go back";
|
||||||
|
BackBtn.UseVisualStyleBackColor = true;
|
||||||
|
BackBtn.Click += BackBtn_Click;
|
||||||
|
//
|
||||||
|
// ReaderLabel
|
||||||
|
//
|
||||||
|
ReaderLabel.AutoSize = true;
|
||||||
|
ReaderLabel.Location = new Point(39, 90);
|
||||||
|
ReaderLabel.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
ReaderLabel.Name = "ReaderLabel";
|
||||||
|
ReaderLabel.Size = new Size(87, 64);
|
||||||
|
ReaderLabel.TabIndex = 7;
|
||||||
|
ReaderLabel.Text = "Reader\r\ncard:";
|
||||||
|
//
|
||||||
|
// CardCBox
|
||||||
|
//
|
||||||
|
CardCBox.FormattingEnabled = true;
|
||||||
|
CardCBox.Location = new Point(155, 105);
|
||||||
|
CardCBox.Margin = new Padding(4);
|
||||||
|
CardCBox.Name = "CardCBox";
|
||||||
|
CardCBox.Size = new Size(235, 40);
|
||||||
|
CardCBox.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// BookColumnCBox
|
||||||
|
//
|
||||||
|
BookColumnCBox.HeaderText = "Book's title";
|
||||||
|
BookColumnCBox.MinimumWidth = 8;
|
||||||
|
BookColumnCBox.Name = "BookColumnCBox";
|
||||||
|
BookColumnCBox.Width = 150;
|
||||||
|
//
|
||||||
|
// NoteColumn
|
||||||
|
//
|
||||||
|
NoteColumn.HeaderText = "Note";
|
||||||
|
NoteColumn.MinimumWidth = 8;
|
||||||
|
NoteColumn.Name = "NoteColumn";
|
||||||
|
NoteColumn.Width = 150;
|
||||||
|
//
|
||||||
|
// RegOrder
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1020, 402);
|
||||||
|
Controls.Add(CardCBox);
|
||||||
|
Controls.Add(ReaderLabel);
|
||||||
|
Controls.Add(BackBtn);
|
||||||
|
Controls.Add(SaveBtn);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(BorrowDTPicker);
|
||||||
|
Controls.Add(DateLabel);
|
||||||
|
Controls.Add(LibLabel);
|
||||||
|
Controls.Add(LibrarianCBox);
|
||||||
|
Margin = new Padding(4);
|
||||||
|
Name = "RegOrder";
|
||||||
|
Text = "RegOrder";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)DataGV).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox LibrarianCBox;
|
||||||
|
private Label LibLabel;
|
||||||
|
private Label DateLabel;
|
||||||
|
private DateTimePicker BorrowDTPicker;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private DataGridView DataGV;
|
||||||
|
private Button SaveBtn;
|
||||||
|
private Button BackBtn;
|
||||||
|
private Label ReaderLabel;
|
||||||
|
private ComboBox CardCBox;
|
||||||
|
private DataGridViewComboBoxColumn BookColumnCBox;
|
||||||
|
private DataGridViewTextBoxColumn NoteColumn;
|
||||||
|
}
|
||||||
|
}
|
66
LibraryDBproject/LDBproj/AdditionalForms/RegOrderF.cs
Normal file
66
LibraryDBproject/LDBproj/AdditionalForms/RegOrderF.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using LDBproject.Entities;
|
||||||
|
using LDBproject.Repositories;
|
||||||
|
using LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
|
public partial class RegOrderF : Form
|
||||||
|
{
|
||||||
|
private readonly IOrderRep _orderRepository;
|
||||||
|
|
||||||
|
public RegOrderF(IOrderRep orderRep, ICustomerCardsRep readerRep,
|
||||||
|
ILibrarianRep employeeRep, IBookRep bookRep)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_orderRepository = orderRep ?? throw new ArgumentNullException(nameof(orderRep));
|
||||||
|
|
||||||
|
LibrarianCBox.DataSource = employeeRep.GetCards();
|
||||||
|
LibrarianCBox.DisplayMember = "FIO";
|
||||||
|
LibrarianCBox.ValueMember = "CardID";
|
||||||
|
|
||||||
|
CardCBox.DataSource = readerRep.GetCards();
|
||||||
|
CardCBox.DisplayMember = "FIO";
|
||||||
|
CardCBox.ValueMember = "CardID";
|
||||||
|
|
||||||
|
BookColumnCBox.DataSource = bookRep.GetBookList();
|
||||||
|
BookColumnCBox.DisplayMember = "Title";
|
||||||
|
BookColumnCBox.ValueMember = "BookID";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (DataGV.RowCount < 1 || LibrarianCBox.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("[ Blanck space left ]");
|
||||||
|
}
|
||||||
|
_orderRepository.CreateOrder(Order.NewOrder(0, (int)CardCBox.SelectedValue, (int)LibrarianCBox.SelectedValue,
|
||||||
|
CreateBookListFromDG(), BorrowDTPicker.Value));
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Order Form [ Error while saving order ]",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Registration> CreateBookListFromDG()
|
||||||
|
{
|
||||||
|
List<Registration> registrations = new List<Registration>();
|
||||||
|
foreach (DataGridViewRow row in DataGV.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["BookColumnCBox"].Value != null)
|
||||||
|
{
|
||||||
|
var bookId = (int)row.Cells["BookColumnCBox"].Value;
|
||||||
|
var notes = row.Cells["NoteColumn"].Value?.ToString();
|
||||||
|
registrations.Add(Registration.OrderReg(0, bookId, notes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return registrations;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BackBtn_Click(object sender, EventArgs e) => Close();
|
||||||
|
}
|
126
LibraryDBproject/LDBproj/AdditionalForms/RegOrderF.resx
Normal file
126
LibraryDBproject/LDBproj/AdditionalForms/RegOrderF.resx
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?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>
|
||||||
|
<metadata name="BookColumnCBox.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="NoteColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -1,14 +1,21 @@
|
|||||||
namespace LDBproject.AdditionalForms;
|
using LDBproject.Entities;
|
||||||
|
using LDBproject.Repositories;
|
||||||
|
|
||||||
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class UpdateF : Form
|
public partial class UpdateF : Form
|
||||||
{
|
{
|
||||||
public UpdateF()
|
private readonly IUpdateRep _updRep;
|
||||||
|
|
||||||
|
public UpdateF(IUpdateRep updRep, ILibrarianRep libRep, ICustomerCardsRep customersRep)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_updRep = updRep ?? throw new ArgumentNullException(nameof(updRep));
|
||||||
|
|
||||||
|
LibrarianCBox.DataSource = libRep.GetCards();
|
||||||
LibrarianCBox.DisplayMember = "FIO";
|
LibrarianCBox.DisplayMember = "FIO";
|
||||||
LibrarianCBox.ValueMember = "CardID";
|
LibrarianCBox.ValueMember = "CardID";
|
||||||
|
CardCBox.DataSource = customersRep.GetCards();
|
||||||
CardCBox.DisplayMember = "FIO";
|
CardCBox.DisplayMember = "FIO";
|
||||||
CardCBox.DisplayMember = "CardID";
|
CardCBox.DisplayMember = "CardID";
|
||||||
CardCBox.ValueMember = "CardID";
|
CardCBox.ValueMember = "CardID";
|
||||||
@ -22,7 +29,8 @@ public partial class UpdateF : Form
|
|||||||
{
|
{
|
||||||
throw new Exception("[ Blanck space left ]");
|
throw new Exception("[ Blanck space left ]");
|
||||||
}
|
}
|
||||||
|
_updRep.AddUpdate(UpdateC.CustomerUpd(CardCBox.SelectedIndex, LibrarianCBox.SelectedIndex,
|
||||||
|
UpdDTPicker.Value, NextUpdDTPicker.Value, NoteTb.Text));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
using Unity;
|
using LDBproject.Repositories;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace LDBproject.AdditionalForms;
|
namespace LDBproject.AdditionalForms;
|
||||||
|
|
||||||
public partial class UpdatesListF : Form
|
public partial class UpdatesListF : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IUpdateRep _updR;
|
||||||
|
|
||||||
public UpdatesListF(IUnityContainer container)
|
public UpdatesListF(IUnityContainer container, IUpdateRep updR)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_updR = updR ?? throw new ArgumentNullException(nameof(updR));
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ public partial class UpdatesListF : Form
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_updR.RemoveUpd(foundID);
|
||||||
ReloadList();
|
ReloadList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -59,7 +63,8 @@ public partial class UpdatesListF : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadList() { }
|
private void ReloadList() =>
|
||||||
|
DataGV.DataSource = _updR.GetUpdateList();
|
||||||
|
|
||||||
private bool GetIDFromRow(out int id)
|
private bool GetIDFromRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -6,11 +6,11 @@ public class Order
|
|||||||
|
|
||||||
public int CardID { get; private set; }
|
public int CardID { get; private set; }
|
||||||
|
|
||||||
public DateTime BorrowDate { get; private set; }
|
|
||||||
|
|
||||||
public int LibrarianID { get; private set; }
|
public int LibrarianID { get; private set; }
|
||||||
|
|
||||||
public IEnumerable<Registration> BookList { get; set; } = [];
|
public DateTime BorrowDate { get; private set; }
|
||||||
|
|
||||||
|
public IEnumerable<Registration> Registrations { get; set; } = [];
|
||||||
|
|
||||||
public static Order NewOrder(
|
public static Order NewOrder(
|
||||||
int orderIndex, int ticketIndex, int librarian, IEnumerable<Registration> list, DateTime borrow)
|
int orderIndex, int ticketIndex, int librarian, IEnumerable<Registration> list, DateTime borrow)
|
||||||
@ -20,7 +20,7 @@ public class Order
|
|||||||
OrderID = orderIndex,
|
OrderID = orderIndex,
|
||||||
CardID = ticketIndex,
|
CardID = ticketIndex,
|
||||||
LibrarianID = librarian,
|
LibrarianID = librarian,
|
||||||
BookList = list,
|
Registrations = list,
|
||||||
BorrowDate = borrow
|
BorrowDate = borrow
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class Registration
|
|||||||
public string Note { get; private set; }
|
public string Note { get; private set; }
|
||||||
|
|
||||||
public static Registration OrderReg(
|
public static Registration OrderReg(
|
||||||
int orderIndex, string notes, int bookIndex)
|
int orderIndex, int bookIndex, string notes)
|
||||||
{
|
{
|
||||||
return new Registration
|
return new Registration
|
||||||
{
|
{
|
||||||
|
@ -9,12 +9,20 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="LDBproject.csproj" />
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
<None Include="LDBproject.csproj.user" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||||
</ItemGroup>
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||||
<ItemGroup>
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Npgsql" Version="9.0.2" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
|
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
<PackageReference Include="Unity.Container" Version="5.11.11" />
|
<PackageReference Include="Unity.Container" Version="5.11.11" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,6 +1,10 @@
|
|||||||
using LDBproject.Repositories.Implementations;
|
using LDBproject.Repositories.Implementations;
|
||||||
using LDBproject.Repositories;
|
using LDBproject.Repositories;
|
||||||
using Unity;
|
using Unity;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
|
||||||
namespace LDBproject
|
namespace LDBproject
|
||||||
@ -20,13 +24,29 @@ namespace LDBproject
|
|||||||
{
|
{
|
||||||
var container = new UnityContainer();
|
var container = new UnityContainer();
|
||||||
|
|
||||||
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||||
|
|
||||||
container.RegisterType<IBookRep, BookR>();
|
container.RegisterType<IBookRep, BookR>();
|
||||||
container.RegisterType<ICustomerCardsRep, CustomerCardR>();
|
container.RegisterType<ICustomerCardsRep, CustomerCardR>();
|
||||||
container.RegisterType<ILibrarianRep, LibrarianR>();
|
container.RegisterType<ILibrarianRep, LibrarianR>();
|
||||||
container.RegisterType<IOrderRep, OrderR>();
|
container.RegisterType<IOrderRep, OrderR>();
|
||||||
container.RegisterType<IUpdateRep, UpdateR>();
|
container.RegisterType<IUpdateRep, UpdateR>();
|
||||||
|
|
||||||
|
container.RegisterType<IConnectionString, ConnectionStrR>();
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static LoggerFactory CreateLoggerFactory()
|
||||||
|
{
|
||||||
|
var loggerFactory = new LoggerFactory();
|
||||||
|
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
.Build())
|
||||||
|
.CreateLogger());
|
||||||
|
return loggerFactory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace LDBproject.Repositories;
|
||||||
|
|
||||||
|
public interface IConnectionString
|
||||||
|
{
|
||||||
|
public string ConnectionString { get; }
|
||||||
|
}
|
@ -9,5 +9,7 @@ public interface IOrderRep
|
|||||||
|
|
||||||
void CreateOrder(Order order);
|
void CreateOrder(Order order);
|
||||||
|
|
||||||
|
void UpdateOrderInfo(Order order);
|
||||||
|
|
||||||
void DeleteOrderinfo(int orderID);
|
void DeleteOrderinfo(int orderID);
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,115 @@
|
|||||||
using LDBproject.Entities;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
namespace LDBproject.Repositories.Implementations;
|
namespace LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
public class BookR : IBookRep
|
public class BookR : IBookRep
|
||||||
{
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
private readonly ILogger<BookR> _logger;
|
||||||
|
|
||||||
public BookR()
|
public BookR(IConnectionString connectionString, ILogger<BookR> logger)
|
||||||
{
|
{
|
||||||
|
_connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Book GetBookByID(int id)
|
public Book GetBookByID(int id)
|
||||||
{
|
{
|
||||||
return null;
|
_logger.LogInformation("< Getting BOOK by id >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT b.*, GenreMask FROM Books b WHERE b.BookID = @BookID";
|
||||||
|
return connection.QueryFirstOrDefault<Book>(querySelect, new { BookID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while reading :') BOOK by ID >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddBook(Book book)
|
public void AddBook(Book book)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< New BOOK Added >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(book));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var queryInsert = @"INSERT INTO Books (Title, Author, PublishYear, Status, GenreMask)
|
||||||
|
VALUES (@Title, @Author, @PublishYear, @Status, @GenreMask)";
|
||||||
|
connection.Execute(queryInsert, book);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while adding BOOK >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBook(Book book)
|
public void UpdateBook(Book book)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< BOOK Info Updated >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(book));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var queryUpdate = @"UPDATE Books SET Title = @Title, Author = @Author,
|
||||||
|
PublishYear = @PublishYear, Status = @Status, GenreMask = @GenreMask
|
||||||
|
WHERE BookID = @BookID";
|
||||||
|
connection.Execute(queryUpdate, book);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while updating BOOK >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteBook(int id)
|
public void DeleteBook(int id)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< Removing BOOK >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM Books WHERE BookID = @BookID";
|
||||||
|
connection.Execute(queryDelete, new { BookID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while deleting BOOK >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Book> GetBookList()
|
public IEnumerable<Book> GetBookList()
|
||||||
{
|
{
|
||||||
return [];
|
_logger.LogInformation("< Getting all BOOKS >");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var querySelectAll = @"SELECT b.*, GenreMask FROM Books b";
|
||||||
|
var books = connection.Query<Book>(querySelectAll);
|
||||||
|
|
||||||
|
_logger.LogDebug("Aimed objects: {json}", JsonConvert.SerializeObject(books));
|
||||||
|
return books;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while getting BOOKS >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace LDBproject.Repositories.Implementations
|
||||||
|
{
|
||||||
|
internal class ConnectionStrR : IConnectionString
|
||||||
|
{
|
||||||
|
public string ConnectionString => "Server=127.0.0.7;Port=5472;Database=libraryDB;Uid=Del8a;Pwd=del8almond;";
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +1,109 @@
|
|||||||
using LDBproject.Entities;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
|
|
||||||
namespace LDBproject.Repositories.Implementations;
|
namespace LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
public class CustomerCardR : ICustomerCardsRep
|
public class CustomerCardR : ICustomerCardsRep
|
||||||
{
|
{
|
||||||
|
private readonly IConnectionString _connectionString;
|
||||||
|
private readonly ILogger<CustomerCardR> _logger;
|
||||||
|
|
||||||
|
public CustomerCardR(IConnectionString connectionString, ILogger<CustomerCardR> logger)
|
||||||
|
{
|
||||||
|
_connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
public CustomerCard GetCardByID(int id)
|
public CustomerCard GetCardByID(int id)
|
||||||
{
|
{
|
||||||
return null;
|
_logger.LogInformation("< Getting CARD by id >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT * FROM CustomerCards WHERE CardID = @CardID"; // Assumes you have a CardID column
|
||||||
|
return connection.QueryFirstOrDefault<CustomerCard>(querySelect, new { CardID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while reading CARD by ID >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddCard(CustomerCard card)
|
public void AddCard(CustomerCard card)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< New (reader)CARD Added >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(card));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var queryInsert = @"INSERT INTO CustomerCards (FIO, AgeBirthday) VALUES (@FIO, @AgeBirthday)";
|
||||||
|
connection.Execute(queryInsert, card);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while adding CARD >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateCard(CustomerCard card)
|
public void UpdateCard(CustomerCard card)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< CARD Info Updated >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(card));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var queryUpdate = @"UPDATE CustomerCards SET FIO = @FIO, AgeBirthday = @AgeBirthday WHERE CardID = @CardID"; // Assumes you have a CardID column
|
||||||
|
connection.Execute(queryUpdate, card);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while updating CARD >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteCard(int id)
|
public void DeleteCard(int id)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< Removing CARD >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM CustomerCards WHERE CardID = @CardID"; // Assumes you have a CardID column
|
||||||
|
connection.Execute(queryDelete, new { CardID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while deleting CARD >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<CustomerCard> GetCards()
|
public IEnumerable<CustomerCard> GetCards()
|
||||||
{
|
{
|
||||||
return [];
|
_logger.LogInformation("< Getting all CARDS >");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var querySelectAll = "SELECT * FROM CustomerCards";
|
||||||
|
var cards = connection.Query<CustomerCard>(querySelectAll);
|
||||||
|
_logger.LogDebug("Aimed objects: {json}", JsonConvert.SerializeObject(cards));
|
||||||
|
return cards;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while getting CARDS >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,32 +1,108 @@
|
|||||||
using LDBproject.Entities;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
namespace LDBproject.Repositories.Implementations;
|
namespace LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
internal class LibrarianR : ILibrarianRep
|
internal class LibrarianR : ILibrarianRep
|
||||||
{
|
{
|
||||||
public LibrarianR()
|
private readonly IConnectionString _connectionString;
|
||||||
|
private readonly ILogger<LibrarianR> _logger;
|
||||||
|
|
||||||
|
public LibrarianR(IConnectionString connectionString, ILogger<LibrarianR> logger)
|
||||||
{
|
{
|
||||||
|
_connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibrarianCard GetCardByID(int id)
|
public LibrarianCard GetCardByID(int id)
|
||||||
{
|
{
|
||||||
return null;
|
_logger.LogInformation("< Getting EMPLOYEE by id >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT * FROM LibrarianCards WHERE CardID = @CardID"; // Assumes you have a CardID column
|
||||||
|
return connection.QueryFirstOrDefault<LibrarianCard>(querySelect, new { CardID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while getting EMPLOYEE by ID >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddCard(LibrarianCard card)
|
public void AddCard(LibrarianCard card)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< New EMPLOYEE Added >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(card));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var queryInsert = @"INSERT INTO LibrarianCards (FIO, GenreMask) VALUES (@FIO, @GenreMask)";
|
||||||
|
connection.Execute(queryInsert, card);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while adding EMPLOYEE >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeCardInfo(LibrarianCard card)
|
public void ChangeCardInfo(LibrarianCard card)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< EMPLOYEE Info Updated >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(card));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var queryUpdate = @"UPDATE LibrarianCards SET FIO = @FIO, GenreMask = @GenreMask WHERE CardID = @CardID"; // Assumes you have a CardID column
|
||||||
|
connection.Execute(queryUpdate, card);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while updating EMPLOYEE info >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteCard(int id)
|
public void DeleteCard(int id)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< Removing CARD >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM LibrarianCards WHERE CardID = @CardID"; // Assumes you have a CardID column
|
||||||
|
connection.Execute(queryDelete, new { CardID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while deleting EMPLOYEE >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<LibrarianCard> GetCards()
|
public IEnumerable<LibrarianCard> GetCards()
|
||||||
{
|
{
|
||||||
return [];
|
_logger.LogInformation("< Getting all EMPLOYEE >");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var querySelectAll = "SELECT * FROM LibrarianCards";
|
||||||
|
var cards = connection.Query<LibrarianCard>(querySelectAll);
|
||||||
|
_logger.LogDebug("Aimed objects: {json}", JsonConvert.SerializeObject(cards));
|
||||||
|
return cards;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while getting EMPLOYEE >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,156 @@
|
|||||||
using LDBproject.Entities;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace LDBproject.Repositories.Implementations;
|
namespace LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
public class OrderR : IOrderRep
|
public class OrderR : IOrderRep
|
||||||
{
|
{
|
||||||
public void CreateOrder(Order order) {}
|
private readonly IConnectionString _connectionString;
|
||||||
|
private readonly ILogger<OrderR> _logger;
|
||||||
|
|
||||||
public void DeleteOrderinfo(int orderID) {}
|
public OrderR(IConnectionString connectionString, ILogger<OrderR> logger)
|
||||||
|
|
||||||
public IEnumerable<Order> GetOrdersInfo(int? librarianID = null, int? orderID = null, int? customerID = null)
|
|
||||||
{
|
{
|
||||||
return [];
|
_connectionString = connectionString;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateOrder(Order order)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("< Adding new ORDER > [!]");
|
||||||
|
_logger.LogDebug("Object - {json}", JsonConvert.SerializeObject(order));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
|
||||||
|
// 1. Insert the Order without RETURNING
|
||||||
|
var queryInsert = @"INSERT INTO Orders (CardID, LibrarianID, BorrowDate) VALUES (@CardID, @LibrarianID, @BorrowDate)";
|
||||||
|
|
||||||
|
connection.Execute(queryInsert, new
|
||||||
|
{
|
||||||
|
order.CardID,
|
||||||
|
order.LibrarianID,
|
||||||
|
order.BorrowDate
|
||||||
|
}, transaction);
|
||||||
|
|
||||||
|
// 2. Get the last inserted OrderID
|
||||||
|
var queryGetLastInsertedId = "SELECT MAX(OrderID) FROM Orders";
|
||||||
|
|
||||||
|
int orderID = connection.QuerySingle<int>(queryGetLastInsertedId, transaction: transaction);
|
||||||
|
|
||||||
|
|
||||||
|
// 3. Insert the Registrations associated with the order
|
||||||
|
var querySubInsert = @"INSERT INTO Registrations (OrderID, BookID, Note) VALUES (@OrderID, @BookID, @Note)";
|
||||||
|
foreach (var elem in order.Registrations)
|
||||||
|
{
|
||||||
|
connection.Execute(querySubInsert, new { OrderID = orderID, elem.BookID, elem.Note }, transaction);
|
||||||
|
}
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while adding ORDER >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateOrderInfo(Order order)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("< Updating order info >");
|
||||||
|
_logger.LogDebug("Object - {json}", JsonConvert.SerializeObject(order));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
// 1. Update order
|
||||||
|
var queryUpdate = @"
|
||||||
|
UPDATE Orders SET
|
||||||
|
CardID = @CardID,
|
||||||
|
LibrarianID = @LibrarianID,
|
||||||
|
BorrowDate = @BorrowDate
|
||||||
|
WHERE OrderID = @OrderID";
|
||||||
|
|
||||||
|
connection.Execute(queryUpdate, new
|
||||||
|
{
|
||||||
|
order.CardID,
|
||||||
|
order.LibrarianID,
|
||||||
|
order.BorrowDate,
|
||||||
|
order.OrderID
|
||||||
|
}, transaction);
|
||||||
|
|
||||||
|
//2. Update registrations:
|
||||||
|
var queryDeleteRegistrations = "DELETE FROM Registrations WHERE OrderID = @OrderID";
|
||||||
|
connection.Execute(queryDeleteRegistrations, new { OrderID = order.OrderID }, transaction);
|
||||||
|
|
||||||
|
var querySubInsert = @"INSERT INTO Registrations (OrderID, BookID, Note) VALUES (@OrderID, @BookID, @Note)";
|
||||||
|
foreach (var elem in order.Registrations)
|
||||||
|
{
|
||||||
|
connection.Execute(querySubInsert, new { OrderID = order.OrderID, elem.BookID, elem.Note }, transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while updating order info >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteOrderinfo(int orderID)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("< Deleting exact order >");
|
||||||
|
_logger.LogDebug("Obj: {id}", orderID);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
using var transaction = connection.BeginTransaction();
|
||||||
|
|
||||||
|
// 1. Delete registrations for the order
|
||||||
|
var queryDeleteRegistrations = @"DELETE FROM Registrations WHERE OrderID=@OrderID";
|
||||||
|
connection.Execute(queryDeleteRegistrations, new { OrderID = orderID }, transaction);
|
||||||
|
// 2. Delete the order itself
|
||||||
|
var queryDel = @"DELETE FROM Orders WHERE OrderID=@OrderID";
|
||||||
|
connection.Execute(queryDel, new { orderID }, transaction);
|
||||||
|
|
||||||
|
transaction.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while deleting ORDER >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------- [ REVIEWED (waits for further editing) ] -------------------------------
|
||||||
|
|
||||||
|
public IEnumerable<Order> GetOrdersInfo(int? orderID = null, int ? librarianID = null, int? customerID = null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("< Getting all ORDERS >");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
connection.Open();
|
||||||
|
var querySelectAll = @"SELECT * FROM Orders";
|
||||||
|
var orders = connection.Query<Order>(querySelectAll);
|
||||||
|
|
||||||
|
_logger.LogDebug("Aimed objects: {json}", JsonConvert.SerializeObject(orders));
|
||||||
|
|
||||||
|
return orders;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while reading ORDERS >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,90 @@
|
|||||||
using LDBproject.Entities;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using LDBproject.Entities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Npgsql;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
namespace LDBproject.Repositories.Implementations;
|
namespace LDBproject.Repositories.Implementations;
|
||||||
|
|
||||||
public class UpdateR : IUpdateRep
|
public class UpdateR : IUpdateRep
|
||||||
{
|
{
|
||||||
public UpdateR()
|
private readonly IConnectionString _connectionString;
|
||||||
|
private readonly ILogger<UpdateR> _logger;
|
||||||
|
|
||||||
|
public UpdateR(IConnectionString connectionString, ILogger<UpdateR> logger)
|
||||||
{
|
{
|
||||||
|
_connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateC GetUpdateByID(int id)
|
public UpdateC GetUpdateByID(int id)
|
||||||
{
|
{
|
||||||
return null;
|
_logger.LogInformation("< Getting UPDATE by id >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", id);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelect = @"SELECT * FROM Updates WHERE ID = @ID";
|
||||||
|
return connection.QueryFirstOrDefault<UpdateC>(querySelect, new { ID = id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while getting UPDATE by id >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddUpdate(UpdateC update)
|
public void AddUpdate(UpdateC update)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< New card UPDATE added >");
|
||||||
|
_logger.LogDebug("Object: {json}", JsonConvert.SerializeObject(update));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryInsert = @"INSERT INTO Updates (CardID, LibrarianID, LastUpdate, UpdBoundary, Note)
|
||||||
|
VALUES (@CardID, @LibrarianID, @LastUpdate, @UpdBoundary, @Note)";
|
||||||
|
connection.Execute(queryInsert, update);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while adding card UPDATE >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveUpd(int Id)
|
public void RemoveUpd(int Id)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("< Deleting card UPDATE by id >");
|
||||||
|
_logger.LogDebug("Object ID: {id}", Id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var queryDelete = @"DELETE FROM Updates WHERE ID = @ID";
|
||||||
|
connection.Execute(queryDelete, new { ID = Id });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while deleting card UPDATE >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<UpdateC> GetUpdateList()
|
public IEnumerable<UpdateC> GetUpdateList()
|
||||||
{
|
{
|
||||||
return [];
|
_logger.LogInformation("< Getting all UPDATES >");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var querySelectAll = @"SELECT * FROM Updates";
|
||||||
|
var upds = connection.Query<UpdateC>(querySelectAll);
|
||||||
|
_logger.LogDebug("Aimed objects: {json}", JsonConvert.SerializeObject(upds));
|
||||||
|
return upds;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "< Error while getting all UPDATES >");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user