Compare commits

...

7 Commits
start ... Lab4

85 changed files with 9835 additions and 51 deletions

View File

@ -0,0 +1,190 @@
namespace LDBproject.AdditionalForms
{
partial class BookF
{
/// <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()
{
Titlelabel = new Label();
Authorlabel = new Label();
PrintYlabel = new Label();
Genrelabel = new Label();
Statlabel = new Label();
TitleTb = new TextBox();
AuthorTb = new TextBox();
YearNud = new NumericUpDown();
SaveBtn = new Button();
DiscardBtn = new Button();
StatusCbox = new ComboBox();
GenresChBoxList = new CheckedListBox();
((System.ComponentModel.ISupportInitialize)YearNud).BeginInit();
SuspendLayout();
//
// Titlelabel
//
Titlelabel.AutoSize = true;
Titlelabel.Location = new Point(27, 32);
Titlelabel.Name = "Titlelabel";
Titlelabel.Size = new Size(48, 25);
Titlelabel.TabIndex = 1;
Titlelabel.Text = "Title:";
//
// Authorlabel
//
Authorlabel.AutoSize = true;
Authorlabel.Location = new Point(27, 68);
Authorlabel.Name = "Authorlabel";
Authorlabel.Size = new Size(71, 25);
Authorlabel.TabIndex = 2;
Authorlabel.Text = "Author:";
//
// PrintYlabel
//
PrintYlabel.AutoSize = true;
PrintYlabel.Location = new Point(25, 104);
PrintYlabel.Name = "PrintYlabel";
PrintYlabel.Size = new Size(112, 25);
PrintYlabel.TabIndex = 3;
PrintYlabel.Text = "Year of print:";
//
// Genrelabel
//
Genrelabel.AutoSize = true;
Genrelabel.Location = new Point(27, 185);
Genrelabel.Name = "Genrelabel";
Genrelabel.Size = new Size(70, 25);
Genrelabel.TabIndex = 4;
Genrelabel.Text = "Genres:";
//
// Statlabel
//
Statlabel.AutoSize = true;
Statlabel.Location = new Point(27, 147);
Statlabel.Name = "Statlabel";
Statlabel.Size = new Size(126, 25);
Statlabel.TabIndex = 5;
Statlabel.Text = "Current status:";
//
// TitleTb
//
TitleTb.Location = new Point(163, 29);
TitleTb.Name = "TitleTb";
TitleTb.Size = new Size(452, 31);
TitleTb.TabIndex = 7;
//
// AuthorTb
//
AuthorTb.Location = new Point(163, 65);
AuthorTb.Name = "AuthorTb";
AuthorTb.Size = new Size(452, 31);
AuthorTb.TabIndex = 8;
//
// YearNud
//
YearNud.Location = new Point(163, 102);
YearNud.Maximum = new decimal(new int[] { 2025, 0, 0, 0 });
YearNud.Minimum = new decimal(new int[] { 1980, 0, 0, 0 });
YearNud.Name = "YearNud";
YearNud.Size = new Size(127, 31);
YearNud.TabIndex = 9;
YearNud.Value = new decimal(new int[] { 1980, 0, 0, 0 });
//
// SaveBtn
//
SaveBtn.Location = new Point(27, 241);
SaveBtn.Name = "SaveBtn";
SaveBtn.Size = new Size(110, 68);
SaveBtn.TabIndex = 13;
SaveBtn.Text = "Save";
SaveBtn.UseVisualStyleBackColor = true;
SaveBtn.Click += SaveBtn_Click;
//
// DiscardBtn
//
DiscardBtn.Location = new Point(27, 315);
DiscardBtn.Name = "DiscardBtn";
DiscardBtn.Size = new Size(110, 70);
DiscardBtn.TabIndex = 14;
DiscardBtn.Text = "Discard";
DiscardBtn.UseVisualStyleBackColor = true;
DiscardBtn.Click += DiscardBtn_Click;
//
// StatusCbox
//
StatusCbox.FormattingEnabled = true;
StatusCbox.Location = new Point(163, 139);
StatusCbox.Name = "StatusCbox";
StatusCbox.Size = new Size(211, 33);
StatusCbox.TabIndex = 15;
//
// GenresChBoxList
//
GenresChBoxList.FormattingEnabled = true;
GenresChBoxList.Location = new Point(163, 185);
GenresChBoxList.Name = "GenresChBoxList";
GenresChBoxList.Size = new Size(211, 200);
GenresChBoxList.TabIndex = 16;
//
// BookF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(647, 412);
Controls.Add(GenresChBoxList);
Controls.Add(StatusCbox);
Controls.Add(DiscardBtn);
Controls.Add(SaveBtn);
Controls.Add(YearNud);
Controls.Add(AuthorTb);
Controls.Add(TitleTb);
Controls.Add(Statlabel);
Controls.Add(Genrelabel);
Controls.Add(PrintYlabel);
Controls.Add(Authorlabel);
Controls.Add(Titlelabel);
Name = "BookF";
Text = "Book";
((System.ComponentModel.ISupportInitialize)YearNud).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label Titlelabel;
private Label Authorlabel;
private Label PrintYlabel;
private Label Genrelabel;
private Label Statlabel;
private TextBox IDtb;
private TextBox TitleTb;
private TextBox AuthorTb;
private NumericUpDown YearNud;
private Button SaveBtn;
private Button DiscardBtn;
private ComboBox StatusCbox;
private CheckedListBox GenresChBoxList;
}
}

View File

@ -0,0 +1,116 @@
using LDBproject.Entities.Enums;
using LDBproject.Entities;
using LDBproject.Repositories;
namespace LDBproject.AdditionalForms;
public partial class BookF : Form
{
private readonly IBookRep _bookRepository;
private int? _bookID;
public BookF(IBookRep bookR)
{
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
{
set
{
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;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "BookF [ Error : wrong data ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
private void SaveBtn_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(TitleTb.Text)
|| GenresChBoxList.CheckedItems.Count == 0
|| StatusCbox.SelectedIndex < 1)
{
throw new Exception("BookF [ Blank spaces were left, not enough information ]");
}
if (_bookID.HasValue)
{
_bookRepository.UpdateBook(CreateBook(_bookID.Value));
}
else
{
_bookRepository.AddBook(CreateBook(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "BookF [ Error : while saving ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DiscardBtn_Click(object sender, EventArgs e) => Close();
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!);
}
}

View File

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

View File

@ -0,0 +1,140 @@
namespace LDBproject.AdditionalForms
{
partial class BookListF
{
/// <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()
{
PanelWithOperations = new Panel();
DelBtn = new Button();
AddBtn = new Button();
UpdBtn = new Button();
DataGV = new DataGridView();
PanelWithOperations.SuspendLayout();
((System.ComponentModel.ISupportInitialize)DataGV).BeginInit();
SuspendLayout();
//
// PanelWithOperations
//
PanelWithOperations.BackColor = Color.Transparent;
PanelWithOperations.Controls.Add(DelBtn);
PanelWithOperations.Controls.Add(AddBtn);
PanelWithOperations.Controls.Add(UpdBtn);
PanelWithOperations.Dock = DockStyle.Right;
PanelWithOperations.Location = new Point(1155, 0);
PanelWithOperations.Margin = new Padding(4, 4, 4, 4);
PanelWithOperations.Name = "PanelWithOperations";
PanelWithOperations.Size = new Size(200, 718);
PanelWithOperations.TabIndex = 0;
//
// DelBtn
//
DelBtn.BackColor = Color.DarkSlateBlue;
DelBtn.BackgroundImage = Properties.Resources.DelImg;
DelBtn.BackgroundImageLayout = ImageLayout.Stretch;
DelBtn.ForeColor = Color.Transparent;
DelBtn.Location = new Point(40, 364);
DelBtn.Margin = new Padding(4, 4, 4, 4);
DelBtn.Name = "DelBtn";
DelBtn.Size = new Size(101, 91);
DelBtn.TabIndex = 4;
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(40, 167);
AddBtn.Margin = new Padding(4, 4, 4, 4);
AddBtn.Name = "AddBtn";
AddBtn.Size = new Size(101, 91);
AddBtn.TabIndex = 3;
AddBtn.UseVisualStyleBackColor = false;
AddBtn.Click += AddBtn_Click;
//
// UpdBtn
//
UpdBtn.BackColor = Color.DarkSlateBlue;
UpdBtn.BackgroundImage = Properties.Resources.OperationImg;
UpdBtn.BackgroundImageLayout = ImageLayout.Stretch;
UpdBtn.ForeColor = Color.Transparent;
UpdBtn.Location = new Point(40, 265);
UpdBtn.Margin = new Padding(4, 4, 4, 4);
UpdBtn.Name = "UpdBtn";
UpdBtn.Size = new Size(101, 91);
UpdBtn.TabIndex = 1;
UpdBtn.UseVisualStyleBackColor = false;
UpdBtn.Click += UpdBtn_Click;
//
// DataGV
//
DataGV.AllowUserToResizeColumns = false;
DataGV.AllowUserToResizeRows = false;
DataGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
DataGV.BackgroundColor = Color.DarkSlateBlue;
DataGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
DataGV.GridColor = Color.GreenYellow;
DataGV.Location = new Point(39, 166);
DataGV.Margin = new Padding(4, 4, 4, 4);
DataGV.Name = "DataGV";
DataGV.RowHeadersVisible = false;
DataGV.RowHeadersWidth = 62;
DataGV.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
DataGV.Size = new Size(1090, 488);
DataGV.TabIndex = 1;
//
// BookListF
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.BookListFrameCover;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(1355, 718);
Controls.Add(DataGV);
Controls.Add(PanelWithOperations);
DoubleBuffered = true;
Margin = new Padding(4, 4, 4, 4);
Name = "BookListF";
StartPosition = FormStartPosition.CenterParent;
Text = "BookListF";
Load += BookListF_Load;
PanelWithOperations.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)DataGV).EndInit();
ResumeLayout(false);
}
#endregion
private Panel PanelWithOperations;
private Button AddBtn;
private Button UpdBtn;
private Button DelBtn;
private DataGridView DataGV;
}
}

View File

@ -0,0 +1,105 @@
using LDBproject.Repositories;
using Unity;
namespace LDBproject.AdditionalForms;
public partial class BookListF : Form
{
private readonly IUnityContainer _container;
private readonly IBookRep _bookR;
public BookListF(IUnityContainer container, IBookRep bookR)
{
InitializeComponent();
_bookR = bookR ?? throw new ArgumentNullException(nameof(bookR));
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void BookListF_Load(object sender, EventArgs e)
{
try
{
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Book List Form [ Error while saving ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddBtn_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<BookF>().ShowDialog();
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Book List Form [ Error while adding element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void UpdBtn_Click(object sender, EventArgs e)
{
if (!GetIDFromRow(out var findID))
{
return;
}
try
{
var form = _container.Resolve<BookF>();
form.ID = findID;
form.ShowDialog();
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Book List Form [ Error while updating element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReloadList()
{
DataGV.DataSource = _bookR.GetBookList();
// [Browsable(false)] * [ - ]
DataGV.Columns["MainBookInfo"].Visible = false; // [ + ]
}
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;
}
}

View File

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

View File

@ -0,0 +1,131 @@
namespace LDBproject.AdditionalForms
{
partial class CustomerF
{
/// <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()
{
CancelBtn = new Button();
SaveBtn = new Button();
FIOEnterTb = new TextBox();
FullNameLabel = new Label();
BDlabel = new Label();
BirthdayDTPicker = new DateTimePicker();
SuspendLayout();
//
// CancelBtn
//
CancelBtn.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
CancelBtn.ForeColor = Color.DarkSlateBlue;
CancelBtn.Location = new Point(495, 70);
CancelBtn.Name = "CancelBtn";
CancelBtn.Size = new Size(102, 34);
CancelBtn.TabIndex = 8;
CancelBtn.Text = "Cancel";
CancelBtn.UseVisualStyleBackColor = true;
CancelBtn.Click += CancelBtn_Click;
//
// SaveBtn
//
SaveBtn.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
SaveBtn.ForeColor = Color.DarkSlateBlue;
SaveBtn.Location = new Point(404, 70);
SaveBtn.Name = "SaveBtn";
SaveBtn.Size = new Size(81, 34);
SaveBtn.TabIndex = 7;
SaveBtn.Text = "Save";
SaveBtn.UseVisualStyleBackColor = true;
SaveBtn.Click += SaveBtn_Click;
//
// FIOEnterTb
//
FIOEnterTb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
FIOEnterTb.ForeColor = Color.MidnightBlue;
FIOEnterTb.Location = new Point(173, 27);
FIOEnterTb.Name = "FIOEnterTb";
FIOEnterTb.Size = new Size(424, 31);
FIOEnterTb.TabIndex = 6;
//
// FullNameLabel
//
FullNameLabel.AutoSize = true;
FullNameLabel.Location = new Point(29, 30);
FullNameLabel.Name = "FullNameLabel";
FullNameLabel.Size = new Size(138, 25);
FullNameLabel.TabIndex = 9;
FullNameLabel.Text = "Full Name (FIO):";
//
// BDlabel
//
BDlabel.AutoSize = true;
BDlabel.Location = new Point(29, 75);
BDlabel.Name = "BDlabel";
BDlabel.Size = new Size(159, 25);
BDlabel.TabIndex = 10;
BDlabel.Text = "Birth day and year:";
//
// BirthdayDTPicker
//
BirthdayDTPicker.CalendarForeColor = Color.GreenYellow;
BirthdayDTPicker.CalendarMonthBackground = Color.DarkSlateBlue;
BirthdayDTPicker.CalendarTitleBackColor = Color.MidnightBlue;
BirthdayDTPicker.CalendarTitleForeColor = Color.DarkSlateBlue;
BirthdayDTPicker.CalendarTrailingForeColor = Color.GreenYellow;
BirthdayDTPicker.Location = new Point(194, 73);
BirthdayDTPicker.Name = "BirthdayDTPicker";
BirthdayDTPicker.Size = new Size(193, 31);
BirthdayDTPicker.TabIndex = 12;
BirthdayDTPicker.Value = new DateTime(2024, 11, 15, 12, 40, 0, 0);
//
// CustomerF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.DarkSlateBlue;
ClientSize = new Size(631, 130);
Controls.Add(BirthdayDTPicker);
Controls.Add(BDlabel);
Controls.Add(FullNameLabel);
Controls.Add(CancelBtn);
Controls.Add(SaveBtn);
Controls.Add(FIOEnterTb);
ForeColor = Color.GreenYellow;
Name = "CustomerF";
Text = "CustomerF";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button CancelBtn;
private Button SaveBtn;
private TextBox FIOEnterTb;
private Label FullNameLabel;
private Label BDlabel;
private DateTimePicker BirthdayDTPicker;
}
}

View File

@ -0,0 +1,77 @@
using LDBproject.Entities;
using LDBproject.Repositories;
namespace LDBproject.AdditionalForms;
public partial class CustomerF : Form
{
private readonly ICustomerCardsRep _customeRepository;
private int? _custID;
public CustomerF(ICustomerCardsRep customeR)
{
InitializeComponent();
_customeRepository = customeR ?? throw new ArgumentNullException(nameof(customeR));
}
public int ID
{
set
{
try
{
var reader = _customeRepository.GetCardByID(value);
if (reader == null)
{
throw new InvalidDataException(nameof(reader));
}
FIOEnterTb.Text = reader.FIO;
BirthdayDTPicker.Value = reader.AgeBirthday;
_custID = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "CustomerF [ Error : wrong data ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
private void SaveBtn_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(FIOEnterTb.Text)
|| BirthdayDTPicker.Value.Year < 1940)
{
throw new Exception("CustomerF [ Blank spaces were left, not enough information ]");
}
if (_custID.HasValue)
{
_customeRepository.UpdateCard(CreateCustomer(_custID.Value));
}
else
{
_customeRepository.AddCard(CreateCustomer(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "CustomerF [ Error : while saving ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelBtn_Click(object sender, EventArgs e) => Close();
private CustomerCard CreateCustomer(int id)
{
return CustomerCard.AddCustomer(id, FIOEnterTb.Text, BirthdayDTPicker.Value);
}
}

View File

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

View File

@ -0,0 +1,132 @@
namespace LDBproject.AdditionalForms
{
partial class CustomerListF
{
/// <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();
UpdBtn = 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(UpdBtn);
panel1.Controls.Add(AddBtn);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(603, 0);
panel1.Name = "panel1";
panel1.Size = new Size(163, 404);
panel1.TabIndex = 3;
//
// -
//
//
// DelBtn
//
DelBtn.BackColor = Color.DarkSlateBlue;
DelBtn.BackgroundImage = Properties.Resources.DelImg;
DelBtn.BackgroundImageLayout = ImageLayout.Stretch;
DelBtn.ForeColor = Color.Transparent;
DelBtn.Location = new Point(27, 218);
DelBtn.Name = "DelBtn";
DelBtn.Size = new Size(78, 71);
DelBtn.TabIndex = 6;
DelBtn.UseVisualStyleBackColor = false;
DelBtn.Click += DelBtn_Click;
//
// UpdBtn
//
UpdBtn.BackColor = Color.DarkSlateBlue;
UpdBtn.BackgroundImage = Properties.Resources.OperationImg;
UpdBtn.BackgroundImageLayout = ImageLayout.Stretch;
UpdBtn.ForeColor = Color.Transparent;
UpdBtn.Location = new Point(27, 141);
UpdBtn.Name = "UpdBtn";
UpdBtn.Size = new Size(78, 71);
UpdBtn.TabIndex = 5;
UpdBtn.UseVisualStyleBackColor = false;
UpdBtn.Click += UpdBtn_Click;
//
// AddBtn
//
AddBtn.BackColor = Color.DarkSlateBlue;
AddBtn.BackgroundImage = Properties.Resources.AddImg;
AddBtn.BackgroundImageLayout = ImageLayout.Stretch;
AddBtn.ForeColor = Color.Transparent;
AddBtn.Location = new Point(27, 64);
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(15, 100);
DataGV.Name = "DataGV";
DataGV.RowHeadersWidth = 62;
DataGV.Size = new Size(550, 273);
DataGV.TabIndex = 2;
//
// CustomerListF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.ReadersFrameCover;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(766, 404);
Controls.Add(panel1);
Controls.Add(DataGV);
DoubleBuffered = true;
Name = "CustomerListF";
Text = "CustomerListF";
Load += CustomerListF_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)DataGV).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button DelBtn;
private Button UpdBtn;
private Button AddBtn;
private DataGridView DataGV;
}
}

View File

@ -0,0 +1,106 @@
using LDBproject.Repositories;
using Unity;
namespace LDBproject.AdditionalForms;
public partial class CustomerListF : Form
{
private readonly IUnityContainer _container;
private readonly ICustomerCardsRep _custR;
public CustomerListF(IUnityContainer container, ICustomerCardsRep customeR)
{
InitializeComponent();
_custR = customeR ?? throw new ArgumentNullException(nameof(customeR));
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void CustomerListF_Load(object sender, EventArgs e)
{
try
{
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Customer List Form [ Error while saving ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddBtn_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<CustomerF>().ShowDialog();
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Customer List Form [ 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
{
_custR.DeleteCard(foundID);
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Customer List Form [ Error while removing element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReloadList()
{
DataGV.DataSource = _custR.GetCards();
DataGV.Columns["FIO"].Visible = false;
DataGV.Columns["CardID"].Visible = false;
}
private bool GetIDFromRow(out int id)
{
id = 0;
if (DataGV.SelectedRows.Count < 1)
{
MessageBox.Show("[ Error : Customer doesn't exist ]", "<ERROR>",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
id = Convert.ToInt32(DataGV.SelectedRows[0].Cells["CardID"].Value);
return true;
}
private void UpdBtn_Click(object sender, EventArgs e)
{
if (!GetIDFromRow(out var findID))
{
return;
}
try
{
var form = _container.Resolve<CustomerF>();
form.ID = findID;
form.ShowDialog();
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Customer List Form [ Error while updating element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

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

View File

@ -0,0 +1,129 @@
namespace LDBproject.AdditionalForms
{
partial class EmployeeF
{
/// <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()
{
FullNameLabel = new Label();
FIOEnterTb = new TextBox();
GenreLabel = new Label();
SaveBtn = new Button();
CancelBtn = new Button();
GenresCheckedBL = new CheckedListBox();
SuspendLayout();
//
// FullNameLabel
//
FullNameLabel.AutoSize = true;
FullNameLabel.Location = new Point(23, 25);
FullNameLabel.Name = "FullNameLabel";
FullNameLabel.Size = new Size(138, 25);
FullNameLabel.TabIndex = 0;
FullNameLabel.Text = "Full Name (FIO):";
//
// FIOEnterTb
//
FIOEnterTb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
FIOEnterTb.ForeColor = Color.MidnightBlue;
FIOEnterTb.Location = new Point(167, 22);
FIOEnterTb.Name = "FIOEnterTb";
FIOEnterTb.Size = new Size(456, 31);
FIOEnterTb.TabIndex = 1;
//
// GenreLabel
//
GenreLabel.AutoSize = true;
GenreLabel.Location = new Point(23, 77);
GenreLabel.Name = "GenreLabel";
GenreLabel.Size = new Size(70, 25);
GenreLabel.TabIndex = 2;
GenreLabel.Text = "Genres:";
//
// SaveBtn
//
SaveBtn.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
SaveBtn.ForeColor = Color.DarkSlateBlue;
SaveBtn.Location = new Point(379, 131);
SaveBtn.Name = "SaveBtn";
SaveBtn.Size = new Size(112, 34);
SaveBtn.TabIndex = 4;
SaveBtn.Text = "Save";
SaveBtn.UseVisualStyleBackColor = true;
SaveBtn.Click += SaveBtn_Click;
//
// CancelBtn
//
CancelBtn.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
CancelBtn.ForeColor = Color.DarkSlateBlue;
CancelBtn.Location = new Point(497, 131);
CancelBtn.Name = "CancelBtn";
CancelBtn.Size = new Size(126, 34);
CancelBtn.TabIndex = 5;
CancelBtn.Text = "Cancel";
CancelBtn.UseVisualStyleBackColor = true;
CancelBtn.Click += CancelBtn_Click;
//
// GenresCheckedBL
//
GenresCheckedBL.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
GenresCheckedBL.ForeColor = Color.MidnightBlue;
GenresCheckedBL.FormattingEnabled = true;
GenresCheckedBL.Location = new Point(99, 77);
GenresCheckedBL.Name = "GenresCheckedBL";
GenresCheckedBL.Size = new Size(251, 88);
GenresCheckedBL.TabIndex = 7;
//
// EmployeeF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.DarkSlateBlue;
ClientSize = new Size(653, 191);
Controls.Add(GenresCheckedBL);
Controls.Add(CancelBtn);
Controls.Add(SaveBtn);
Controls.Add(GenreLabel);
Controls.Add(FIOEnterTb);
Controls.Add(FullNameLabel);
ForeColor = Color.GreenYellow;
Name = "EmployeeF";
Text = "EmployeeF";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label FullNameLabel;
private TextBox FIOEnterTb;
private Label GenreLabel;
private Button SaveBtn;
private Button CancelBtn;
private ComboBox GenreCbox;
private CheckedListBox GenresCheckedBL;
}
}

View File

@ -0,0 +1,103 @@
using LDBproject.Entities.Enums;
using LDBproject.Entities;
using LDBproject.Repositories;
namespace LDBproject.AdditionalForms;
public partial class EmployeeF : Form
{
private readonly ILibrarianRep _libRepository;
private int? _librarianID;
public EmployeeF(ILibrarianRep librarianR)
{
InitializeComponent();
_libRepository = librarianR ?? throw new ArgumentNullException(nameof(librarianR));
foreach (var elem in Enum.GetValues(typeof(Genres)))
{
GenresCheckedBL.Items.Add(elem);
}
}
public int ID
{
set
{
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;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "EmployeeF [ Error : while setting ID ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
private void SaveBtn_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(FIOEnterTb.Text)
|| GenresCheckedBL.CheckedItems.Count == 0)
{
throw new Exception("EmployeeF [ Blank spaces were left, not enough information ]");
}
if (_librarianID.HasValue)
{
_libRepository.ChangeCardInfo(CreateWorker(_librarianID.Value));
}
else
{
_libRepository.AddCard(CreateWorker(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "EmployeeF [ Error : while saving data ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelBtn_Click(object sender, EventArgs e) => Close();
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);
}
}

View File

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

View File

@ -0,0 +1,128 @@
namespace LDBproject.AdditionalForms
{
partial class EmployeesF
{
/// <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()
{
DataGV = new DataGridView();
panel1 = new Panel();
DelBtn = new Button();
UpdBtn = new Button();
AddBtn = new Button();
((System.ComponentModel.ISupportInitialize)DataGV).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
//
// DataGV
//
DataGV.BackgroundColor = Color.DarkSlateBlue;
DataGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
DataGV.GridColor = Color.GreenYellow;
DataGV.Location = new Point(30, 100);
DataGV.Name = "DataGV";
DataGV.RowHeadersWidth = 62;
DataGV.Size = new Size(550, 273);
DataGV.TabIndex = 0;
//
// panel1
//
panel1.BackColor = Color.Transparent;
panel1.Controls.Add(DelBtn);
panel1.Controls.Add(UpdBtn);
panel1.Controls.Add(AddBtn);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(586, 0);
panel1.Name = "panel1";
panel1.Size = new Size(163, 407);
panel1.TabIndex = 1;
//
// DelBtn
//
DelBtn.BackColor = Color.DarkSlateBlue;
DelBtn.BackgroundImage = Properties.Resources.DelImg;
DelBtn.BackgroundImageLayout = ImageLayout.Stretch;
DelBtn.ForeColor = Color.Transparent;
DelBtn.Location = new Point(27, 218);
DelBtn.Name = "DelBtn";
DelBtn.Size = new Size(78, 71);
DelBtn.TabIndex = 6;
DelBtn.UseVisualStyleBackColor = false;
DelBtn.Click += DelBtn_Click;
//
// UpdBtn
//
UpdBtn.BackColor = Color.DarkSlateBlue;
UpdBtn.BackgroundImage = Properties.Resources.OperationImg;
UpdBtn.BackgroundImageLayout = ImageLayout.Stretch;
UpdBtn.ForeColor = Color.Transparent;
UpdBtn.Location = new Point(27, 141);
UpdBtn.Name = "UpdBtn";
UpdBtn.Size = new Size(78, 71);
UpdBtn.TabIndex = 5;
UpdBtn.UseVisualStyleBackColor = false;
UpdBtn.Click += UpdBtn_Click;
//
// AddBtn
//
AddBtn.BackColor = Color.DarkSlateBlue;
AddBtn.BackgroundImage = Properties.Resources.AddImg;
AddBtn.BackgroundImageLayout = ImageLayout.Stretch;
AddBtn.ForeColor = Color.Transparent;
AddBtn.Location = new Point(27, 64);
AddBtn.Name = "AddBtn";
AddBtn.Size = new Size(78, 71);
AddBtn.TabIndex = 4;
AddBtn.UseVisualStyleBackColor = false;
AddBtn.Click += AddBtn_Click;
//
// EmployeesF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.EmployeesFrameCover;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(749, 407);
Controls.Add(panel1);
Controls.Add(DataGV);
DoubleBuffered = true;
Name = "EmployeesF";
Text = "EmployeesF";
Load += EmployeesF_Load;
((System.ComponentModel.ISupportInitialize)DataGV).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView DataGV;
private Panel panel1;
private Button AddBtn;
private Button UpdBtn;
private Button DelBtn;
}
}

View File

@ -0,0 +1,105 @@
using LDBproject.Repositories;
using Unity;
namespace LDBproject.AdditionalForms;
public partial class EmployeesF : Form
{
private readonly IUnityContainer _container;
private readonly ILibrarianRep _libR;
public EmployeesF(IUnityContainer container, ILibrarianRep libR)
{
InitializeComponent();
_libR = libR ?? throw new ArgumentNullException(nameof(libR));
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void EmployeesF_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<EmployeeF>().ShowDialog();
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Error while adding element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void UpdBtn_Click(object sender, EventArgs e)
{
if (!GetiDFromRow(out var findID))
{
return;
}
try
{
var form = _container.Resolve<EmployeeF>();
form.ID = findID;
form.ShowDialog();
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Error while updating 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
{
_libR.DeleteCard(foundID);
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Error while removing element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReloadList()
{
DataGV.DataSource = _libR.GetCards();
DataGV.Columns["CardID"].Visible = false;
}
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["CardID"].Value);
return true;
}
}

View File

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

View File

@ -0,0 +1,104 @@
namespace LDBproject.AdditionalForms
{
partial class FullReportsF
{
/// <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()
{
BookChBox = new CheckBox();
EmployeeChBox = new CheckBox();
ReadersChBox = new CheckBox();
ConfBuildBtn = new Button();
SuspendLayout();
//
// BookChBox
//
BookChBox.AutoSize = true;
BookChBox.ForeColor = Color.GreenYellow;
BookChBox.Location = new Point(58, 36);
BookChBox.Name = "BookChBox";
BookChBox.Size = new Size(87, 29);
BookChBox.TabIndex = 0;
BookChBox.Text = "Books";
BookChBox.UseVisualStyleBackColor = true;
//
// EmployeeChBox
//
EmployeeChBox.AutoSize = true;
EmployeeChBox.ForeColor = Color.GreenYellow;
EmployeeChBox.Location = new Point(239, 36);
EmployeeChBox.Name = "EmployeeChBox";
EmployeeChBox.Size = new Size(113, 29);
EmployeeChBox.TabIndex = 1;
EmployeeChBox.Text = "Librarians";
EmployeeChBox.UseVisualStyleBackColor = true;
//
// ReadersChBox
//
ReadersChBox.AutoSize = true;
ReadersChBox.ForeColor = Color.GreenYellow;
ReadersChBox.Location = new Point(455, 36);
ReadersChBox.Name = "ReadersChBox";
ReadersChBox.Size = new Size(100, 29);
ReadersChBox.TabIndex = 2;
ReadersChBox.Text = "Readers";
ReadersChBox.UseVisualStyleBackColor = true;
//
// ConfBuildBtn
//
ConfBuildBtn.ForeColor = Color.DarkSlateBlue;
ConfBuildBtn.Location = new Point(58, 86);
ConfBuildBtn.Name = "ConfBuildBtn";
ConfBuildBtn.Size = new Size(497, 34);
ConfBuildBtn.TabIndex = 3;
ConfBuildBtn.Text = "Make report";
ConfBuildBtn.UseVisualStyleBackColor = true;
ConfBuildBtn.Click += ConfBuildBtn_Click;
//
// ReportF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.DarkSlateBlue;
ClientSize = new Size(610, 158);
Controls.Add(ConfBuildBtn);
Controls.Add(ReadersChBox);
Controls.Add(EmployeeChBox);
Controls.Add(BookChBox);
Name = "ReportF";
Text = "ReportF";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox BookChBox;
private CheckBox EmployeeChBox;
private CheckBox ReadersChBox;
private Button ConfBuildBtn;
}
}

View File

@ -0,0 +1,49 @@
using LDBproject.Reports;
using Unity;
namespace LDBproject.AdditionalForms;
public partial class FullReportsF : Form
{
private readonly IUnityContainer _container;
public FullReportsF(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void ConfBuildBtn_Click(object sender, EventArgs e)
{
try
{
if (!BookChBox.Checked && !EmployeeChBox.Checked && !ReadersChBox.Checked)
{
throw new Exception("There are no options chosen [!]");
}
var sfd = new SaveFileDialog()
{
Filter = "Docx Files | *.docx"
};
if (sfd.ShowDialog() != DialogResult.OK)
{
throw new Exception("No file chosen [!]");
}
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, BookChBox.Checked, EmployeeChBox.Checked, ReadersChBox.Checked))
{
MessageBox.Show("< The DOCument was made : Report done >", "Process result", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("< ERROR : see logs >", "Document creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "< ERROR : while creating report >", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

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

View File

@ -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;
}
}

View File

@ -0,0 +1,89 @@
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()
{
var res = _regR.GetOrdersInfo();
DataGV.DataSource = _regR.GetOrdersInfo();
// DataGV.Columns["ID"].Visible = false;
// DataGV.Columns["OrderID"].Visible = false;
DataGV.Columns["BorrowDate"].DefaultCellStyle.Format = "dd MMMM yyyy";
}
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;
}
}

View File

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

View File

@ -0,0 +1,114 @@
namespace LDBproject.AdditionalForms
{
partial class OrdersReportF
{
/// <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()
{
OkBtn = new Button();
FilePathTb = new TextBox();
ComboBoxB = new ComboBox();
BeginDTP = new DateTimePicker();
FinDTP = new DateTimePicker();
PathConfirmBtn = new Button();
SuspendLayout();
//
// OkBtn
//
OkBtn.Location = new Point(49, 362);
OkBtn.Name = "OkBtn";
OkBtn.Size = new Size(513, 46);
OkBtn.TabIndex = 0;
OkBtn.Text = "Confirm";
OkBtn.UseVisualStyleBackColor = true;
OkBtn.Click += MakeReportBtn_Click;
//
// FilePathTb
//
FilePathTb.Location = new Point(49, 56);
FilePathTb.Name = "FilePathTb";
FilePathTb.Size = new Size(413, 39);
FilePathTb.TabIndex = 1;
//
// ComboBoxB
//
ComboBoxB.FormattingEnabled = true;
ComboBoxB.Location = new Point(49, 142);
ComboBoxB.Name = "ComboBoxB";
ComboBoxB.Size = new Size(513, 40);
ComboBoxB.TabIndex = 2;
//
// BeginDTP
//
BeginDTP.Location = new Point(49, 215);
BeginDTP.Name = "BeginDTP";
BeginDTP.Size = new Size(513, 39);
BeginDTP.TabIndex = 3;
//
// FinDTP
//
FinDTP.Location = new Point(49, 279);
FinDTP.Name = "FinDTP";
FinDTP.Size = new Size(513, 39);
FinDTP.TabIndex = 4;
//
// PathConfirmBtn
//
PathConfirmBtn.Location = new Point(477, 53);
PathConfirmBtn.Name = "PathConfirmBtn";
PathConfirmBtn.Size = new Size(85, 47);
PathConfirmBtn.TabIndex = 5;
PathConfirmBtn.Text = "../";
PathConfirmBtn.UseVisualStyleBackColor = true;
PathConfirmBtn.Click += SelectFilePathBtn_Click;
//
// CardsReportF
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(614, 452);
Controls.Add(PathConfirmBtn);
Controls.Add(FinDTP);
Controls.Add(BeginDTP);
Controls.Add(ComboBoxB);
Controls.Add(FilePathTb);
Controls.Add(OkBtn);
Name = "CardsReportF";
Text = "CardsReportF";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button OkBtn;
private TextBox FilePathTb;
private ComboBox ComboBoxB;
private DateTimePicker BeginDTP;
private DateTimePicker FinDTP;
private Button PathConfirmBtn;
}
}

View File

@ -0,0 +1,87 @@
using Unity;
using LDBproject.Repositories;
using LDBproject.Reports;
using LDBproject.Entities;
namespace LDBproject.AdditionalForms
{
public partial class OrdersReportF : Form
{
private readonly IUnityContainer _container;
private readonly IOrderRep _orderRep;
public OrdersReportF(IUnityContainer container, IOrderRep orderRep)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_orderRep = orderRep ?? throw new ArgumentNullException(nameof(orderRep));
var ordersInfo = _orderRep.GetOrdersInfo().ToList();
if (ordersInfo.Any())
{
ComboBoxB.DataSource = ordersInfo;
ComboBoxB.DisplayMember = "DisplayInfo";
ComboBoxB.ValueMember = "OrderID"; // Assuming the data model has this property
}
else
{
MessageBox.Show("No Orders Found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
}
}
private void SelectFilePathBtn_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog() { Filter = "Excel Files | *.xlsx" };
if (sfd.ShowDialog() == DialogResult.OK)
{
FilePathTb.Text = sfd.FileName;
}
}
private void MakeReportBtn_Click(object sender, EventArgs e)
{
try
{
string filePath = FilePathTb.Text;
if (string.IsNullOrWhiteSpace(filePath))
{
MessageBox.Show("Please select a file path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (ComboBoxB.SelectedItem == null)
{
MessageBox.Show("Please select an order.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DateTime startDate = BeginDTP.Value;
DateTime endDate = FinDTP.Value;
if (startDate >= endDate)
{
MessageBox.Show("Start date must be before end date.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Correctly get the selected OrderInfo object
if (ComboBoxB.SelectedItem is not Order selectedOrderInfo)
{
MessageBox.Show("Invalid order selection.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Resolve TableReport and pass the dates
var tableReport = _container.Resolve<TableReport>();
if (tableReport.CreateTable(filePath, startDate, endDate))
{
MessageBox.Show("< Chart PDF report generated successfully >", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show($"An error occurred while generating the report: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

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

View File

@ -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;
}
}

View File

@ -0,0 +1,65 @@
using LDBproject.Entities;
using LDBproject.Repositories;
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 = "MainBookInfo"; // MainBookInfo \ BookInfo
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();
}

View 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>

View File

@ -0,0 +1,107 @@
namespace LDBproject.AdditionalForms
{
partial class UpdReportF
{
/// <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()
{
button1 = new Button();
button2 = new Button();
UpdDTP = new DateTimePicker();
label = new Label();
FileNamelabel = new Label();
SuspendLayout();
//
// button1
//
button1.Location = new Point(41, 28);
button1.Name = "button1";
button1.Size = new Size(453, 46);
button1.TabIndex = 0;
button1.Text = "Choose file path";
button1.UseVisualStyleBackColor = true;
button1.Click += SelectFileNameBtn_Click;
//
// button2
//
button2.Location = new Point(41, 247);
button2.Name = "button2";
button2.Size = new Size(453, 46);
button2.TabIndex = 1;
button2.Text = "Ok";
button2.UseVisualStyleBackColor = true;
button2.Click += CreateBtn_Click;
//
// UpdDTP
//
UpdDTP.Location = new Point(73, 190);
UpdDTP.Name = "UpdDTP";
UpdDTP.Size = new Size(400, 39);
UpdDTP.TabIndex = 2;
//
// label
//
label.AutoSize = true;
label.Location = new Point(81, 141);
label.Name = "label";
label.Size = new Size(383, 32);
label.TabIndex = 3;
label.Text = "Check how much updates was on :";
//
// FileNamelabel
//
FileNamelabel.AutoSize = true;
FileNamelabel.Location = new Point(44, 79);
FileNamelabel.Name = "FileNamelabel";
FileNamelabel.Size = new Size(120, 32);
FileNamelabel.TabIndex = 4;
FileNamelabel.Text = "/file path/";
//
// UpdReport
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(543, 330);
Controls.Add(FileNamelabel);
Controls.Add(label);
Controls.Add(UpdDTP);
Controls.Add(button2);
Controls.Add(button1);
Name = "UpdReport";
Text = "UpdReport";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button button1;
private Button button2;
private DateTimePicker UpdDTP;
private Label label;
private Label FileNamelabel;
}
}

View File

@ -0,0 +1,55 @@
using System.Windows.Forms;
using Unity;
namespace LDBproject.AdditionalForms
{
public partial class UpdReportF : Form
{
private string _fileName = string.Empty;
private readonly IUnityContainer _container;
public UpdReportF(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void SelectFileNameBtn_Click(object sender, EventArgs e)
{
var sfd = new SaveFileDialog()
{
Filter = "Pdf Files | *.pdf"
};
if (sfd.ShowDialog() == DialogResult.OK)
{
_fileName = sfd.FileName;
FileNamelabel.Text = Path.GetFileName(_fileName);
}
}
private void CreateBtn_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(_fileName))
{
throw new Exception("No file (path) chosen");
}
if
(_container.Resolve<ChartReport>().CreateChart(_fileName, UpdDTP.Value))
{
MessageBox.Show("< PDF Document was formated >", "Creating chart report (pdf)",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show("< ERROR : see logs >", "Pdf. formating",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "< ERROR : while creating pdf document >",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

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

View File

@ -0,0 +1,198 @@
namespace LDBproject.AdditionalForms
{
partial class UpdateF
{
/// <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()
{
LibLabel = new Label();
LibrarianCBox = new ComboBox();
LastUpdLabel = new Label();
NextUpdLabel = new Label();
UpdDTPicker = new DateTimePicker();
NextUpdDTPicker = new DateTimePicker();
ConfirmBtn = new Button();
CancelBtn = new Button();
CardCBox = new ComboBox();
CardLbl = new Label();
NoteTb = new TextBox();
NoteLbl = new Label();
SuspendLayout();
//
// LibLabel
//
LibLabel.AutoSize = true;
LibLabel.Location = new Point(27, 91);
LibLabel.Margin = new Padding(4, 0, 4, 0);
LibLabel.Name = "LibLabel";
LibLabel.Size = new Size(118, 32);
LibLabel.TabIndex = 0;
LibLabel.Text = "By whom:";
//
// LibrarianCBox
//
LibrarianCBox.FormattingEnabled = true;
LibrarianCBox.Location = new Point(152, 87);
LibrarianCBox.Margin = new Padding(4, 4, 4, 4);
LibrarianCBox.Name = "LibrarianCBox";
LibrarianCBox.Size = new Size(515, 40);
LibrarianCBox.TabIndex = 1;
//
// LastUpdLabel
//
LastUpdLabel.AutoSize = true;
LastUpdLabel.Location = new Point(27, 213);
LastUpdLabel.Margin = new Padding(4, 0, 4, 0);
LastUpdLabel.Name = "LastUpdLabel";
LastUpdLabel.Size = new Size(74, 32);
LastUpdLabel.TabIndex = 2;
LastUpdLabel.Text = "From:";
//
// NextUpdLabel
//
NextUpdLabel.AutoSize = true;
NextUpdLabel.Location = new Point(27, 266);
NextUpdLabel.Margin = new Padding(4, 0, 4, 0);
NextUpdLabel.Name = "NextUpdLabel";
NextUpdLabel.Size = new Size(50, 32);
NextUpdLabel.TabIndex = 3;
NextUpdLabel.Text = "Till:";
//
// UpdDTPicker
//
UpdDTPicker.Location = new Point(110, 213);
UpdDTPicker.Margin = new Padding(4, 4, 4, 4);
UpdDTPicker.Name = "UpdDTPicker";
UpdDTPicker.Size = new Size(389, 39);
UpdDTPicker.TabIndex = 4;
//
// NextUpdDTPicker
//
NextUpdDTPicker.Location = new Point(110, 266);
NextUpdDTPicker.Margin = new Padding(4, 4, 4, 4);
NextUpdDTPicker.Name = "NextUpdDTPicker";
NextUpdDTPicker.Size = new Size(389, 39);
NextUpdDTPicker.TabIndex = 5;
//
// ConfirmBtn
//
ConfirmBtn.Location = new Point(523, 213);
ConfirmBtn.Margin = new Padding(4, 4, 4, 4);
ConfirmBtn.Name = "ConfirmBtn";
ConfirmBtn.Size = new Size(146, 44);
ConfirmBtn.TabIndex = 6;
ConfirmBtn.Text = "Confirm";
ConfirmBtn.UseVisualStyleBackColor = true;
ConfirmBtn.Click += ConfirmBtn_Click;
//
// CancelBtn
//
CancelBtn.Location = new Point(523, 266);
CancelBtn.Margin = new Padding(4, 4, 4, 4);
CancelBtn.Name = "CancelBtn";
CancelBtn.Size = new Size(146, 44);
CancelBtn.TabIndex = 7;
CancelBtn.Text = "Cancel";
CancelBtn.UseVisualStyleBackColor = true;
CancelBtn.Click += CancelBtn_Click;
//
// CardCBox
//
CardCBox.FormattingEnabled = true;
CardCBox.Location = new Point(222, 26);
CardCBox.Margin = new Padding(4, 4, 4, 4);
CardCBox.Name = "CardCBox";
CardCBox.Size = new Size(445, 40);
CardCBox.TabIndex = 9;
//
// CardLbl
//
CardLbl.AutoSize = true;
CardLbl.Location = new Point(27, 29);
CardLbl.Margin = new Padding(4, 0, 4, 0);
CardLbl.Name = "CardLbl";
CardLbl.Size = new Size(188, 32);
CardLbl.TabIndex = 8;
CardLbl.Text = "Card to prolong:";
//
// NoteTb
//
NoteTb.Location = new Point(110, 150);
NoteTb.Margin = new Padding(4);
NoteTb.Name = "NoteTb";
NoteTb.Size = new Size(557, 39);
NoteTb.TabIndex = 10;
//
// NoteLbl
//
NoteLbl.AutoSize = true;
NoteLbl.Location = new Point(27, 152);
NoteLbl.Margin = new Padding(4, 0, 4, 0);
NoteLbl.Name = "NoteLbl";
NoteLbl.Size = new Size(72, 32);
NoteLbl.TabIndex = 11;
NoteLbl.Text = "Note:";
//
// UpdateF
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(706, 345);
Controls.Add(NoteLbl);
Controls.Add(NoteTb);
Controls.Add(CardCBox);
Controls.Add(CardLbl);
Controls.Add(CancelBtn);
Controls.Add(ConfirmBtn);
Controls.Add(NextUpdDTPicker);
Controls.Add(UpdDTPicker);
Controls.Add(NextUpdLabel);
Controls.Add(LastUpdLabel);
Controls.Add(LibrarianCBox);
Controls.Add(LibLabel);
Margin = new Padding(4, 4, 4, 4);
Name = "UpdateF";
Text = "UpdateF";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label LibLabel;
private ComboBox LibrarianCBox;
private Label LastUpdLabel;
private Label NextUpdLabel;
private DateTimePicker UpdDTPicker;
private DateTimePicker NextUpdDTPicker;
private Button ConfirmBtn;
private Button CancelBtn;
private ComboBox CardCBox;
private Label CardLbl;
private TextBox NoteTb;
private Label NoteLbl;
}
}

View File

@ -0,0 +1,42 @@
using LDBproject.Entities;
using LDBproject.Repositories;
namespace LDBproject.AdditionalForms;
public partial class UpdateF : Form
{
private readonly IUpdateRep _updRep;
public UpdateF(IUpdateRep updRep, ILibrarianRep libRep, ICustomerCardsRep customersRep)
{
InitializeComponent();
_updRep = updRep ?? throw new ArgumentNullException(nameof(updRep));
LibrarianCBox.DataSource = libRep.GetCards();
LibrarianCBox.DisplayMember = "FIO";
LibrarianCBox.ValueMember = "CardID";
CardCBox.DataSource = customersRep.GetCards();
CardCBox.DisplayMember = "FullReaderInfo"; // FullReaderInfo \ ReaderName
CardCBox.ValueMember = "CardID";
}
private void ConfirmBtn_Click(object sender, EventArgs e)
{
try
{
if (LibrarianCBox.SelectedIndex < 0 || CardCBox.SelectedIndex < 0)
{
throw new Exception("[ Blanck space left ]");
}
_updRep.AddUpdate(UpdateC.CustomerUpd(CardCBox.SelectedIndex, LibrarianCBox.SelectedIndex,
UpdDTPicker.Value, NextUpdDTPicker.Value, NoteTb.Text));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Saving error ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CancelBtn_Click(object sender, EventArgs e) => Close();
}

View File

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

View File

@ -0,0 +1,112 @@
namespace LDBproject.AdditionalForms
{
partial class UpdatesListF
{
/// <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(546, 0);
panel1.Name = "panel1";
panel1.Size = new Size(163, 360);
panel1.TabIndex = 3;
//
// DelBtn
//
DelBtn.BackColor = Color.DarkSlateBlue;
DelBtn.BackgroundImage = Properties.Resources.DelImg;
DelBtn.BackgroundImageLayout = ImageLayout.Stretch;
DelBtn.ForeColor = Color.Transparent;
DelBtn.Location = new Point(27, 218);
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(27, 126);
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(30, 90);
DataGV.Name = "DataGV";
DataGV.RowHeadersWidth = 62;
DataGV.Size = new Size(489, 245);
DataGV.TabIndex = 2;
//
// CardUpdatesF
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.UpdListFrameCover;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(709, 360);
Controls.Add(panel1);
Controls.Add(DataGV);
DoubleBuffered = true;
Name = "CardUpdatesF";
Text = "CardUpdatesF";
Load += CardUpdatesF_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)DataGV).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button DelBtn;
private Button AddBtn;
private DataGridView DataGV;
}
}

View File

@ -0,0 +1,86 @@
using LDBproject.Repositories;
using Unity;
namespace LDBproject.AdditionalForms;
public partial class UpdatesListF : Form
{
private readonly IUnityContainer _container;
private readonly IUpdateRep _updR;
public UpdatesListF(IUnityContainer container, IUpdateRep updR)
{
InitializeComponent();
_updR = updR ?? throw new ArgumentNullException(nameof(updR));
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void CardUpdatesF_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<UpdateF>().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
{
_updR.RemoveUpd(foundID);
ReloadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Error while removing element ]", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReloadList()
{
DataGV.DataSource = _updR.GetUpdateList();
DataGV.Columns["ID"].Visible = false;
DataGV.Columns["LastUpdate"].DefaultCellStyle.Format = "dd.MM.yyyy";
DataGV.Columns["UpdBoundary"].DefaultCellStyle.Format = "dd.MM.yyyy";
}
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["ID"].Value);
return true;
}
}

View File

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

View File

@ -0,0 +1,37 @@
using System.ComponentModel;
using LDBproject.Entities.Enums;
namespace LDBproject.Entities;
public class Book
{
public int BookID { get; private set; }
public string MainBookInfo => $"<<{Title}>>; {Author}";
[DisplayName("< title >")]
public string Title { get; private set; }
[DisplayName("< author >")]
public string Author { get; private set; }
[DisplayName("< year of print >")]
public int PublishYear { get; private set; }
[DisplayName("< current position >")]
public BookStat Status { get; private set; }
[DisplayName("< genres >")]
public Genres GenreMask { get; private set; } = Genres.None;
public static Book AddBook(
int bookIndex, string title, string author, int year, Genres genres, BookStat status)
{
return new Book
{
BookID = bookIndex,
Title = title,
Author = author,
PublishYear = year,
GenreMask = genres,
Status = status
};
}
}

View File

@ -0,0 +1,27 @@
using System.ComponentModel;
namespace LDBproject.Entities;
public class CustomerCard
{
public int CardID { get; private set; }
[DisplayName("Reader's full name")]
public string FIO { get; private set; }
public string FullReaderInfo => $"{CardID} : {FIO}";
[DisplayName("Birthday date")]
public DateTime AgeBirthday { get; private set; }
public static CustomerCard AddCustomer(
int cardIndex, string fullName, DateTime year)
{
return new CustomerCard
{
CardID = cardIndex,
FIO = fullName,
AgeBirthday = year
};
}
}

View File

@ -0,0 +1,11 @@
namespace LDBproject.Entities.Enums;
public enum BookStat
{
Unable = 0,
Ordered = 1,
IDassignment = 2,
OnStock = 3,
Borrowed = 4,
Debited = 5
}

View File

@ -0,0 +1,19 @@
namespace LDBproject.Entities.Enums
{
[Flags]
public enum Genres
{
None = 0, // 00000000
Adventure = 1, // 00000001
Fantasy = 2, // 00000010
Mystery = 4, // 00000100
Fiction = 8, // 00001000
Suspense = 16, // 00010000
Romance = 32, // 00100000
Crime = 64, // 01000000
Talent = 128, // 10000000
Realism = 256, // 10000001
Horror = 512, // 10000010
Historical = 1024, // 10000011
}
}

View File

@ -0,0 +1,26 @@
using System.ComponentModel;
using LDBproject.Entities.Enums;
namespace LDBproject.Entities;
public class LibrarianCard
{
public int CardID { get; private set; }
[DisplayName("Employee full name")]
public string FIO { get; private set; }
[DisplayName("Connected genres")]
public Genres GenreMask { get; private set; }
public static LibrarianCard AddWorker(
int cardIndex, string fullName, Genres genre)
{
return new LibrarianCard
{
CardID = cardIndex,
FIO = fullName,
GenreMask = genre
};
}
}

View File

@ -0,0 +1,47 @@
using System.ComponentModel;
namespace LDBproject.Entities;
public class Order
{
public int OrderID { get; private set; }
[Browsable(false)]
public int CardID { get; private set; }
[Browsable(false)]
public int LibrarianID { get; private set; }
[DisplayName("Reader")]
public string ReaderName { get; private set; } = string.Empty;
[DisplayName("Librarian")]
public string EmployeeName { get; private set; } = string.Empty;
[DisplayName("Book")]
public string BookInfo { get; private set; } = string.Empty;
[DisplayName("Date of borrow")]
public DateTime BorrowDate { get; private set; }
[DisplayName("List of borrowed books")]
public string BookList => Registrations != null ? string.Join(", ", Registrations.Select(x => $"{x.BookID} {x.Note}")) : string.Empty;
[Browsable(false)]
public IEnumerable<Registration> Registrations { get; set; } = [];
public static Order NewOrder(
int orderIndex, int ticketIndex, int librarian, IEnumerable<Registration> list, DateTime borrow)
{
return new Order
{
OrderID = orderIndex,
CardID = ticketIndex,
LibrarianID = librarian,
Registrations = list,
BorrowDate = borrow
};
}
public void SetRegs(IEnumerable<Registration> regs)
{
if (regs != null && regs.Any())
{
Registrations = regs;
}
}
}

View File

@ -0,0 +1,22 @@
namespace LDBproject.Entities;
public class Registration
{
public int ID { get; private set; }
public int OrderID { get; private set; }
public int BookID { get; private set; }
public string BookInfo { get; private set; } = string.Empty;
public string Note { get; private set; }
public static Registration OrderReg(
int orderIndex, int bookIndex, string notes)
{
return new Registration
{
OrderID = orderIndex,
BookID = bookIndex,
Note = notes
};
}
}

View File

@ -0,0 +1,36 @@
using System.ComponentModel;
namespace LDBproject.Entities;
public class UpdateC
{
public int ID { get; private set; }
[Browsable(false)]
public int CardID { get; private set; }
[Browsable(false)]
public int LibrarianID { get; private set; }
[DisplayName("Reader")]
public string ReaderName { get; private set; } = string.Empty;
[DisplayName("Librarian")]
public string EmployeeName { get; private set; } = string.Empty;
[DisplayName("Date of last upd")]
public DateTime LastUpdate { get; private set; }
[DisplayName("upd active till")]
public DateTime UpdBoundary { get; private set; }
[DisplayName("Notes")]
public string Note { get; private set; }
public static UpdateC CustomerUpd(
int cardIndex, int librIndex, DateTime updDate, DateTime updToDate, string note)
{
return new UpdateC
{
CardID = cardIndex,
LastUpdate = updDate,
LibrarianID = librIndex,
UpdBoundary = updToDate,
Note = note
};
}
}

View File

@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<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.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
<PackageReference Include="iTextSharp" Version="5.5.13.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.2" />
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
<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.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,6 @@
namespace LDBproj
using LDBproject.AdditionalForms;
namespace LDBproject
{
partial class MainForm
{
@ -28,12 +30,181 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
menuStrip1 = new MenuStrip();
toolStripMenuItem1 = new ToolStripMenuItem();
menuStrip2 = new MenuStrip();
StaffTSMI = new ToolStripMenuItem();
EmployeeCard = new ToolStripMenuItem();
ReaderCard = new ToolStripMenuItem();
BookReg = new ToolStripMenuItem();
OperationsTSMI = new ToolStripMenuItem();
GiveOut = new ToolStripMenuItem();
Updating = new ToolStripMenuItem();
LogsTSMI = new ToolStripMenuItem();
ReportW = new ToolStripMenuItem();
ReportP = new ToolStripMenuItem();
ReportC = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
menuStrip2.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(24, 24);
menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1 });
menuStrip1.Location = new Point(0, 33);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 24);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
//
// toolStripMenuItem1
//
toolStripMenuItem1.Name = "toolStripMenuItem1";
toolStripMenuItem1.Size = new Size(16, 20);
//
// menuStrip2
//
menuStrip2.BackColor = Color.GreenYellow;
menuStrip2.ImageScalingSize = new Size(24, 24);
menuStrip2.Items.AddRange(new ToolStripItem[] { StaffTSMI, OperationsTSMI, LogsTSMI });
menuStrip2.Location = new Point(0, 0);
menuStrip2.Name = "menuStrip2";
menuStrip2.Size = new Size(800, 33);
menuStrip2.TabIndex = 1;
menuStrip2.Text = "menuStrip2";
//
// StaffTSMI
//
StaffTSMI.DropDownItems.AddRange(new ToolStripItem[] { EmployeeCard, ReaderCard, BookReg });
StaffTSMI.ForeColor = Color.DarkSlateBlue;
StaffTSMI.Name = "StaffTSMI";
StaffTSMI.Size = new Size(256, 29);
StaffTSMI.Text = "Персональная информация";
//
// EmployeeCard
//
EmployeeCard.BackColor = Color.DarkSlateBlue;
EmployeeCard.ForeColor = Color.GreenYellow;
EmployeeCard.Name = "EmployeeCard";
EmployeeCard.Size = new Size(273, 34);
EmployeeCard.Text = "Карта сотрудника";
EmployeeCard.Click += EmployeeCard_Click;
//
// ReaderCard
//
ReaderCard.BackColor = Color.DarkSlateBlue;
ReaderCard.ForeColor = Color.GreenYellow;
ReaderCard.Name = "ReaderCard";
ReaderCard.Size = new Size(273, 34);
ReaderCard.Text = "Читательский билет";
ReaderCard.Click += ReaderCard_Click;
//
// BookReg
//
BookReg.BackColor = Color.DarkSlateBlue;
BookReg.ForeColor = Color.GreenYellow;
BookReg.Name = "BookReg";
BookReg.Size = new Size(273, 34);
BookReg.Text = "Книга";
BookReg.Click += BookReg_Click;
//
// OperationsTSMI
//
OperationsTSMI.DropDownItems.AddRange(new ToolStripItem[] { GiveOut, Updating });
OperationsTSMI.ForeColor = Color.DarkSlateBlue;
OperationsTSMI.Name = "OperationsTSMI";
OperationsTSMI.Size = new Size(112, 29);
OperationsTSMI.Text = "Операции";
//
// GiveOut
//
GiveOut.BackColor = Color.DarkSlateBlue;
GiveOut.ForeColor = Color.GreenYellow;
GiveOut.Name = "GiveOut";
GiveOut.Size = new Size(289, 34);
GiveOut.Text = "Оформление выдачи";
GiveOut.Click += GiveOut_Click;
//
// Updating
//
Updating.BackColor = Color.DarkSlateBlue;
Updating.ForeColor = Color.GreenYellow;
Updating.Name = "Updating";
Updating.Size = new Size(289, 34);
Updating.Text = "Обновление билета";
Updating.Click += Updating_Click;
//
// LogsTSMI
//
LogsTSMI.DropDownItems.AddRange(new ToolStripItem[] { ReportW, ReportP, ReportC });
LogsTSMI.ForeColor = Color.DarkSlateBlue;
LogsTSMI.Name = "LogsTSMI";
LogsTSMI.Size = new Size(88, 29);
LogsTSMI.Text = "Отчёты";
// Reports --- [ ! ]
ReportW.BackColor = Color.DarkSlateBlue;
ReportW.ForeColor = Color.GreenYellow;
ReportW.Name = "ReportW";
ReportW.Size = new Size(273, 34);
ReportW.Text = "Сформировать документ";
ReportW.Click += Report_Click;
ReportP.BackColor = Color.DarkSlateBlue;
ReportP.ForeColor = Color.GreenYellow;
ReportP.Name = "ReportP";
ReportP.Size = new Size(273, 34);
ReportP.Text = "Отчёт о заказах";
ReportP.Click += OrderReport_Click;
ReportC.BackColor = Color.DarkSlateBlue;
ReportC.ForeColor = Color.GreenYellow;
ReportC.Name = "ReportC";
ReportC.Size = new Size(273, 34);
ReportC.Text = "Отчёт о билетах";
ReportC.Click += UpdReport_Click;
//
// MainForm
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(800, 450);
Controls.Add(menuStrip1);
Controls.Add(menuStrip2);
DoubleBuffered = true;
MainMenuStrip = menuStrip1;
Name = "MainForm";
Text = "WorkForm";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
menuStrip2.ResumeLayout(false);
menuStrip2.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem toolStripMenuItem1;
private MenuStrip menuStrip2;
private ToolStripMenuItem StaffTSMI;
private ToolStripMenuItem EmployeeCard;
private ToolStripMenuItem OperationsTSMI;
private ToolStripMenuItem GiveOut;
private ToolStripMenuItem LogsTSMI;
private ToolStripMenuItem ReaderCard;
private ToolStripMenuItem BookReg;
private ToolStripMenuItem Updating;
private ToolStripMenuItem ReportW;
private ToolStripMenuItem ReportP;
private ToolStripMenuItem ReportC;
}
}

View File

@ -1,10 +1,120 @@
namespace LDBproj
{
using LDBproject.AdditionalForms;
using Unity;
namespace LDBproject;
public partial class MainForm : Form
{
public MainForm()
private readonly IUnityContainer _container;
public MainForm(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void EmployeeCard_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<EmployeesF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : mistake ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReaderCard_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<CustomerListF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : mistake ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void BookReg_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<BookListF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : mistake ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void GiveOut_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<OrdersF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : mistake ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Updating_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<UpdatesListF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : mistake ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Report_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FullReportsF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : ERROR ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrderReport_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<OrdersReportF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : ERROR ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void UpdReport_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<UpdReportF>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "[ Download : ERROR ]",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,52 @@
namespace LDBproj
using LDBproject.Repositories.Implementations;
using LDBproject.Repositories;
using Unity;
using Unity.Microsoft.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
namespace LDBproject
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
Application.Run(CreateContainer().Resolve<MainForm>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IBookRep, BookR>();
container.RegisterType<ICustomerCardsRep, CustomerCardR>();
container.RegisterType<ILibrarianRep, LibrarianR>();
container.RegisterType<IOrderRep, OrderR>();
container.RegisterType<IUpdateRep, UpdateR>();
container.RegisterType<IConnectionString, ConnectionStrR>();
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;
}
}
}

View File

@ -0,0 +1,140 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LDBproject.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LDBproject.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap AddImg {
get {
object obj = ResourceManager.GetObject("AddImg", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap BookListFrameCover {
get {
object obj = ResourceManager.GetObject("BookListFrameCover", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap DelImg {
get {
object obj = ResourceManager.GetObject("DelImg", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap EmployeesFrameCover {
get {
object obj = ResourceManager.GetObject("EmployeesFrameCover", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap OperationImg {
get {
object obj = ResourceManager.GetObject("OperationImg", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ReadersFrameCover {
get {
object obj = ResourceManager.GetObject("ReadersFrameCover", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap RegistrationsFrameCover {
get {
object obj = ResourceManager.GetObject("RegistrationsFrameCover", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap UpdListFrameCover {
get {
object obj = ResourceManager.GetObject("UpdListFrameCover", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,145 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ReadersFrameCover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\ReadersFrameCover.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="OperationImg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\OperationImg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="UpdListFrameCover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\UpdListFrameCover.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="AddImg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\AddImg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="DelImg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\DelImg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="BookListFrameCover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\BookListFrameCover.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="EmployeesFrameCover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\EmployeesFrameCover.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="RegistrationsFrameCover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\RscImages\RegistrationsFrameCover.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,43 @@
using Microsoft.Extensions.Logging;
using LDBproject.Entities;
using LDBproject.Repositories;
using LDBproject.Reports;
internal class ChartReport
{
private readonly IUpdateRep _updR;
private readonly ILogger<ChartReport> _logger;
public ChartReport(IUpdateRep updR, ILogger<ChartReport> logger)
{
_updR = updR ?? throw new ArgumentNullException(nameof(updR));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateChart(string filePath, DateTime dateTime)
{
try
{
var updates = _updR.GetUpdateList(dateFrom: dateTime.Date, dateTo: dateTime.Date.AddDays(1)).ToList(); // Materialize the query
var data = GetData(updates, dateTime);
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
new PdfBuilder(filePath).AddHeader("Card Updates")
.AddPieChart("Number of Times Card Updated", data)
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error creating chart.");
return false;
}
}
private List<(string Caption, double Value)> GetData(List<UpdateC> updates, DateTime date)
{
return updates.GroupBy(x => x.CardID)
.Select(group => (
Caption: $"Card n_{group.Key}",
Value: (double)group.Count()
)).ToList();
}
}

View File

@ -0,0 +1,75 @@
using Microsoft.Extensions.Logging;
using LDBproject.Repositories;
namespace LDBproject.Reports;
internal class DocReport
{
private readonly IBookRep _bookRep;
private readonly ILibrarianRep _librarianRep;
private readonly ICustomerCardsRep _customerRep;
private readonly ILogger<DocReport> _logger;
public DocReport(IBookRep bookRep, ILibrarianRep librarianRep,
ICustomerCardsRep customerRep, ILogger<DocReport> logger)
{
_bookRep = bookRep ?? throw new ArgumentNullException(nameof(bookRep));
_librarianRep = librarianRep ?? throw new ArgumentNullException(nameof(librarianRep));
_customerRep = customerRep ?? throw new ArgumentNullException(nameof(customerRep));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateDoc(string filePath, bool includeOrders, bool includeLibrarians, bool includeCustomers)
{
try
{
var builder = new WordBuilder(filePath).AddHeader("Reports Document");
if (includeOrders)
{
builder.AddParagraph("Книги").AddTable([2400, 2400, 1200], GetBooks());
}
if (includeLibrarians)
{
builder.AddParagraph("Работники").AddTable([2400, 1200], GetLibrarians());
}
if (includeCustomers)
{
builder.AddParagraph("Читатели").AddTable([2400, 2400], GetCustomers());
}
builder.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "< Error while forming document >");
return false;
}
}
private List<string[]> GetBooks()
{
return [
["Title", "Author", "Year of publishing"],
.. _bookRep.GetBookList().Select(x => new string[]
{ x.Title, x.Author, x.PublishYear.ToString() }),];
}
private List<string[]> GetLibrarians()
{
return [["FIO", "Genres"],
.. _librarianRep.GetCards().Select(x => new string[]
{ x.FIO, x.GenreMask.ToString() ?? "Unknown" }),];
}
private List<string[]> GetCustomers()
{
return [["FIO", "Birthday"],
.. _customerRep.GetCards().Select(x => new string[]
{ x.FIO, x.AgeBirthday.ToString() }),];
}
}

View File

@ -0,0 +1,285 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
namespace LDBproject.Reports;
internal class ExcelBuilder
{
private readonly string _filePath;
private readonly SheetData _sheetData;
private readonly MergeCells _mergeCells;
private readonly Columns _columns;
private uint _rowIndex = 0;
public ExcelBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_sheetData = new SheetData();
_mergeCells = new MergeCells();
_columns = new Columns();
_rowIndex = 1;
}
public ExcelBuilder AddHeader(string header, int startIndex, int count)
{
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldCentered); // Changed style
for (int i = startIndex + 1; i < startIndex + count; ++i)
{
CreateCell(i, _rowIndex, "", StyleIndex.BoldCentered); // Changed style
}
_mergeCells.Append(new MergeCell
{
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
});
_rowIndex++;
return this;
}
public ExcelBuilder AddParagraph(string text, int columnIndex)
{
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
return this;
}
public ExcelBuilder AddTable(int[] columnWidths, List<string[]> data)
{
// Error handling (keep this)
if (columnWidths == null || columnWidths.Length == 0)
{
throw new ArgumentNullException(nameof(columnWidths));
}
if (data == null || data.Count == 0)
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != columnWidths.Length))
{
throw new InvalidOperationException("Column widths and data row lengths must match.");
}
if (data.Count > 0)
{
var firstRow = data.First();
if (firstRow.Length != columnWidths.Length)
{
throw new InvalidOperationException("Column widths and data row lengths must match.");
}
}
//Column setup - now it's dynamically calculated
uint counter = 1;
int coef = 2; // Consider making this a configurable parameter
_columns.Append(columnWidths.Select(x => new Column
{
Min = counter,
Max = counter++,
Width = x * coef,
CustomWidth = true
}));
for (int i = 0; i < data.Count; i++)
{
for (int j = 0; j < data[i].Length; j++)
{
StyleIndex styleIndex = (i == 0) ? StyleIndex.BoldCentered : StyleIndex.WithThinBorder; // Header row style
CreateCell(j, _rowIndex, data[i][j], styleIndex);
}
_rowIndex++;
}
return this;
}
public void Build()
{
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
var workbookpart = spreadsheetDocument.AddWorkbookPart();
GenerateStyle(workbookpart);
workbookpart.Workbook = new Workbook();
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet();
if (_columns.HasChildren)
{
worksheetPart.Worksheet.Append(_columns);
}
worksheetPart.Worksheet.Append(_sheetData);
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
var sheet = new Sheet()
{
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Page 1"
};
sheets.Append(sheet);
if (_mergeCells.HasChildren)
{
worksheetPart.Worksheet.InsertAfter(_mergeCells,
worksheetPart.Worksheet.Elements<SheetData>().First());
}
}
private static void GenerateStyle(WorkbookPart workbookPart)
{
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
workbookStylesPart.Stylesheet = new Stylesheet();
var fonts = new Fonts()
{
Count = 3, // Increased count to accommodate bold font
KnownFonts = BooleanValue.FromBoolean(true)
};
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
{
FontSize = new FontSize() { Val = 11 },
FontName = new FontName() { Val = "Calibri" },
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
FontScheme = new FontScheme() { Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor) }
});
// Added bold font
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
{
FontSize = new FontSize() { Val = 11 },
FontName = new FontName() { Val = "Calibri" },
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
Bold = new Bold(), // Added Bold element
FontScheme = new FontScheme() { Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor) }
});
workbookStylesPart.Stylesheet.Append(fonts);
// Default Fill
var fills = new Fills() { Count = 1 };
fills.Append(new Fill
{
PatternFill = new PatternFill()
{
PatternType = new EnumValue<PatternValues>(PatternValues.None)
}
});
workbookStylesPart.Stylesheet.Append(fills);
// Default Border & Added a border with lines
var borders = new Borders() { Count = 3 }; // Increased count for the new border
borders.Append(new Border
{
LeftBorder = new LeftBorder(),
RightBorder = new RightBorder(),
TopBorder = new TopBorder(),
BottomBorder = new BottomBorder(),
DiagonalBorder = new DiagonalBorder()
});
// Added a border with lines
borders.Append(new Border
{
LeftBorder = new LeftBorder { Style = BorderStyleValues.Thin },
RightBorder = new RightBorder { Style = BorderStyleValues.Thin },
TopBorder = new TopBorder { Style = BorderStyleValues.Thin },
BottomBorder = new BottomBorder { Style = BorderStyleValues.Thin },
DiagonalBorder = new DiagonalBorder()
});
workbookStylesPart.Stylesheet.Append(borders);
// Default cell format and a few more formats
var cellFormats = new CellFormats() { Count = 4 };
cellFormats.Append(new CellFormat
{
NumberFormatId = 0,
FormatId = 0,
FontId = 0,
BorderId = 0,
FillId = 0,
Alignment = new Alignment()
{
Horizontal = HorizontalAlignmentValues.Left,
Vertical = VerticalAlignmentValues.Center,
WrapText = true
}
});
// Added formats (customize these as needed)
cellFormats.Append(new CellFormat { NumberFormatId = 0, FontId = 1, BorderId = 1, Alignment = new Alignment { Horizontal = HorizontalAlignmentValues.Center } }); //Bold and centered
cellFormats.Append(new CellFormat { NumberFormatId = 0, FontId = 0, BorderId = 1 }); // With thin border
workbookStylesPart.Stylesheet.Append(cellFormats);
}
private enum StyleIndex
{
SimpleTextWithoutBorder = 0,
BoldCentered = 1,
WithThinBorder = 2
}
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
{
var columnName = GetExcelColumnName(columnIndex);
var cellReference = columnName + rowIndex;
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
if (row == null)
{
row = new Row() { RowIndex = rowIndex };
_sheetData.Append(row);
}
var newCell = row.Elements<Cell>().FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
if (newCell == null)
{
Cell? refCell = null;
foreach (Cell cell in row.Elements<Cell>())
{
if (cell.CellReference?.Value != null && cell.CellReference.Value.Length == cellReference.Length)
{
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
{
refCell = cell;
break;
}
}
}
newCell = new Cell() { CellReference = cellReference };
row.InsertBefore(newCell, refCell);
}
newCell.CellValue = new CellValue(text);
newCell.DataType = CellValues.String;
newCell.StyleIndex = (uint)styleIndex;
}
private static string GetExcelColumnName(int columnNumber)
{
columnNumber += 1;
int dividend = columnNumber;
string columnName = string.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
dividend = (dividend - modulo) / 26;
}
return columnName;
}
}

View File

@ -0,0 +1,87 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.Rendering;
namespace LDBproject.Reports;
internal class PdfBuilder
{
private readonly string _filePath;
private readonly Document _document;
public PdfBuilder(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentNullException(nameof(filePath));
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
_filePath = filePath;
_document = new Document();
DefineStyles();
}
public PdfBuilder AddHeader(string header)
{
_document.AddSection().AddParagraph(header, "HeaderStyle"); // used the defined style
return this;
// _document.AddSection().AddParagraph(header, "NormalBold");
// return this;
}
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
{
if (data == null || data.Count == 0)
{
return this;
}
var chart = new Chart(ChartType.Pie2D);
var series = chart.SeriesCollection.AddSeries();
series.Add(data.Select(x => x.Value).ToArray());
var xseries = chart.XValues.AddXSeries();
xseries.Add(data.Select(x => x.Caption).ToArray());
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
chart.TopArea.AddParagraph(title);
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.TopArea.AddLegend();
_document.LastSection.Add(chart);
return this;
}
public void Build()
{
var renderer = new PdfDocumentRenderer(true)
{
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(_filePath);
}
private void DefineStyles()
{
// defined the HeaderStyle
string[] fallbackFonts = { "Arial", "Times New Roman", "Calibri" }; //List of fonts to try
string fontName = "Times New Roman";
foreach (var font in fallbackFonts)
{
if (System.Drawing.FontFamily.Families.Any(f => f.Name == font))
{
fontName = font;
break;
}
}
var headerStyle = _document.Styles.AddStyle("HeaderStyle", "Normal");
headerStyle.Font.Name = fontName;
headerStyle.Font.Size = 14;
headerStyle.Font.Bold = true;
}
}

View File

@ -0,0 +1,67 @@
using Microsoft.Extensions.Logging;
using LDBproject.Repositories;
namespace LDBproject.Reports
{
internal class TableReport
{
private readonly IOrderRep _orderRep;
private readonly ILogger<TableReport> _logger;
internal static readonly string[] item = { "Librarian ID", "Card ID", "Borrow Date", "Book ID", "Note" };
public TableReport(IOrderRep orderRep, ILogger<TableReport> logger)
{
_orderRep = orderRep ?? throw new ArgumentNullException(nameof(orderRep));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
public bool CreateTable(string filePath, DateTime startDate, DateTime endDate)
{
try
{
new ExcelBuilder(filePath)
.AddHeader("Report about borrowed books", 0, 5) // Updated header
.AddParagraph($"Period: {startDate:yyyy-MM-dd} - {endDate:yyyy-MM-dd}", 0)
.AddTable([4, 4, 7, 4, 7], GetData(startDate, endDate)) // Updated column widths
.Build();
return true;
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while forming document");
return false;
}
}
private List<string[]> GetData(DateTime startDate, DateTime endDate)
{
var data = _orderRep.GetOrdersInfo(brDate: startDate, tillDate: endDate)
.SelectMany(order => order.Registrations
.Select(reg => new
{
order.EmployeeName,
order.ReaderName,
order.BorrowDate,
order.BookInfo,
reg.Note
}))
.OrderBy(x => x.BorrowDate);
var result = new List<string[]> { item };
result.AddRange(data.Select(x => new string[]
{
x.EmployeeName,
x.ReaderName,
x.BorrowDate.ToString("dd.MM.yyyy"),
x.BookInfo,
x.Note
}));
int totalBookCount = data.Count();
result.Add(new[] { "Total Books:", "", "", totalBookCount.ToString(), "" });
return result;
}
}
}

View File

@ -0,0 +1,99 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
internal class WordBuilder
{
private readonly string _filePath;
private readonly Document _doc;
private readonly Body _body;
public WordBuilder(string filepath)
{
if (string.IsNullOrWhiteSpace(filepath))
{
throw new ArgumentNullException(nameof(filepath));
}
if (File.Exists(filepath))
{
File.Delete(filepath);
}
_filePath = filepath;
_doc = new Document();
_body = _doc.AppendChild(new Body());
}
public WordBuilder AddHeader(string header)
{
var paragraph = _body.AppendChild(new Paragraph());
var run = paragraph.AppendChild(new Run());
// Set bold text using RunProperties
run.AppendChild(new RunProperties(new Bold()));
run.AppendChild(new Text(header)); // Use Wordprocessing.Text
return this;
}
public WordBuilder AddTable(int[] widths, List<string[]> data)
{
if (widths == null || widths.Length == 0)
{
throw new ArgumentNullException(nameof(widths));
}
if (data == null || data.Count == 0)
{
throw new ArgumentNullException(nameof(data));
}
if (data.Any(x => x.Length != widths.Length))
{
throw new InvalidOperationException("widths.Length != data.Length");
}
var table = new Table();
table.AppendChild(new TableProperties(new TableBorders(new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 })));
// Заголовок
var tr = new TableRow();
for (var j = 0; j < widths.Length; ++j)
{
tr.Append(new TableCell(
new TableCellProperties(new TableCellWidth()
{
Width = widths[j].ToString()
}),
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j]))))); // Use Wordprocessing.Text
}
table.Append(tr);
// Данные
table.Append(data.Skip(1).Select(x => new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y)))))))); // Use Wordprocessing.Text
_body.Append(table);
return this;
}
public WordBuilder AddParagraph(string text)
{
var paragraph = _body.AppendChild(new Paragraph());
var run = paragraph.AppendChild(new Run());
run.AppendChild(new Text(text)); // Use Wordprocessing.Text
return this;
}
public void Build()
{
using var wordDocument = WordprocessingDocument.Create(_filePath, WordprocessingDocumentType.Document);
var mainPart = wordDocument.AddMainDocumentPart();
mainPart.Document = _doc;
}
}

View File

@ -0,0 +1,16 @@
using LDBproject.Entities;
namespace LDBproject.Repositories;
public interface IBookRep
{
IEnumerable<Book> GetBookList();
Book GetBookByID(int id);
void AddBook(Book card);
void UpdateBook(Book card);
void DeleteBook(int id);
}

View File

@ -0,0 +1,6 @@
namespace LDBproject.Repositories;
public interface IConnectionString
{
public string ConnectionString { get; }
}

View File

@ -0,0 +1,16 @@
using LDBproject.Entities;
namespace LDBproject.Repositories;
public interface ICustomerCardsRep
{
IEnumerable<CustomerCard> GetCards();
CustomerCard GetCardByID(int id);
void AddCard(CustomerCard card);
void UpdateCard(CustomerCard card);
void DeleteCard(int id);
}

View File

@ -0,0 +1,16 @@
using LDBproject.Entities;
namespace LDBproject.Repositories;
public interface ILibrarianRep
{
IEnumerable<LibrarianCard> GetCards();
LibrarianCard GetCardByID(int id);
void AddCard(LibrarianCard card);
void ChangeCardInfo(LibrarianCard card);
void DeleteCard(int id);
}

View File

@ -0,0 +1,15 @@
using LDBproject.Entities;
namespace LDBproject.Repositories;
public interface IOrderRep
{
IEnumerable<Order> GetOrdersInfo(DateTime? brDate = null, DateTime? tillDate = null,
int? cardID = null, int? librnID = null);
void CreateOrder(Order order);
void UpdateOrderInfo(Order order);
void DeleteOrderinfo(int orderID);
}

View File

@ -0,0 +1,15 @@
using LDBproject.Entities;
namespace LDBproject.Repositories;
public interface IUpdateRep
{
IEnumerable<UpdateC> GetUpdateList(DateTime? dateFrom = null, DateTime? dateTo = null);
UpdateC GetUpdateByID(int id);
void AddUpdate(UpdateC card);
void RemoveUpd(int cardID);
}

View File

@ -0,0 +1,115 @@
using Microsoft.Extensions.Logging;
using LDBproject.Entities;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace LDBproject.Repositories.Implementations;
public class BookR : IBookRep
{
private readonly IConnectionString _connectionString;
private readonly ILogger<BookR> _logger;
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)
{
_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)
{
_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)
{
_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)
{
_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()
{
_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;
}
}
}

View File

@ -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;";
}
}

View File

@ -0,0 +1,109 @@
using Microsoft.Extensions.Logging;
using LDBproject.Entities;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace LDBproject.Repositories.Implementations;
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)
{
_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)
{
_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)
{
_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)
{
_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()
{
_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;
}
}
}

View File

@ -0,0 +1,108 @@
using Microsoft.Extensions.Logging;
using LDBproject.Entities;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace LDBproject.Repositories.Implementations;
internal class LibrarianR : ILibrarianRep
{
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)
{
_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)
{
_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)
{
_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)
{
_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()
{
_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;
}
}
}

View File

@ -0,0 +1,200 @@
using Microsoft.Extensions.Logging;
using LDBproject.Entities;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace LDBproject.Repositories.Implementations;
public class OrderR : IOrderRep
{
private readonly IConnectionString _connectionString;
private readonly ILogger<OrderR> _logger;
public OrderR(IConnectionString connectionString, ILogger<OrderR> logger)
{
_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;
}
}
public IEnumerable<Order> GetOrdersInfo(DateTime? brDate = null, DateTime? tilldate = null,
int? cardID = null, int? librnID = null)
{
_logger.LogInformation("< Getting ORDERS >");
try
{
var builder = new QueryBuilder();
if (brDate.HasValue)
{
builder.AddCondition("orders.BorrowDate >= @brDate");
}
if (brDate.HasValue)
{
builder.AddCondition("orders.BorrowDate <= @tilldate");
}
if (cardID.HasValue)
{
builder.AddCondition("orders.CardID = @cardID");
}
if (librnID.HasValue)
{
builder.AddCondition("orders.LibrarianID = @librnID");
}
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelectAll = @$"SELECT
orders.*,
lc.FIO as EmployeeName,
CONCAT(books.Title, ' ', books.Author) as BookInfo,
CONCAT(cc.CardID, ' ', cc.FIO) as ReaderName,
regs.BookID, regs.Note
FROM Orders orders
INNER JOIN LibrarianCards lc ON lc.CardID = orders.LibrarianID
INNER JOIN CustomerCards cc ON cc.CardID = orders.CardID
INNER JOIN Registrations regs ON regs.OrderID = orders.OrderID
LEFT JOIN Books books ON books.BookID = regs.BookID
{builder.Build()}";
var regsDict = new Dictionary<int, List<Registration>>();
var orders = connection.Query<Order, Registration, Order>(querySelectAll, (order, orders) =>
{
if (!regsDict.TryGetValue(order.OrderID, out var reg))
{
reg = [];
regsDict.Add(order.OrderID, reg);
}
reg.Add(orders);
return order;
}, splitOn: "BookID"); // params: ... - variables parameters from GetOrdersInfo(...) [ ! ]
// unnessessary - [ + ]
_logger.LogDebug("Aimed objects: {json}", JsonConvert.SerializeObject(orders));
return regsDict.Select(x =>
{
var odr = orders.First(y => y.OrderID == x.Key);
odr.SetRegs(x.Value);
return odr;
}).ToList();
}
catch (Exception ex)
{
_logger.LogError(ex, "< Error while reading ORDERS >");
throw;
}
}
}

View File

@ -0,0 +1,34 @@
using System.Text;
namespace LDBproject.Repositories.Implementations;
internal class QueryBuilder
{
private readonly StringBuilder _builder;
public QueryBuilder()
{
_builder = new();
}
public QueryBuilder AddCondition(string condition)
{
if (_builder.Length > 0)
{
_builder.Append(" AND ");
}
_builder.Append(condition);
return this;
}
public string Build()
{
if (_builder.Length == 0)
{
return string.Empty;
}
return $"WHERE {_builder}";
}
}

View File

@ -0,0 +1,98 @@
using Microsoft.Extensions.Logging;
using LDBproject.Entities;
using Newtonsoft.Json;
using Npgsql;
using Dapper;
namespace LDBproject.Repositories.Implementations;
public class UpdateR : IUpdateRep
{
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)
{
_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)
{
_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)
{
_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(DateTime? dateFrom = null, DateTime? dateTo = null)
{
_logger.LogInformation("< Getting all UPDATES >");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelectAll = @"SELECT
upd.*,
lc.FIO as EmployeeName,
CONCAT(cc.CardID, ' ', cc.FIO) as ReaderName
FROM Updates upd
LEFT JOIN LibrarianCards lc ON lc.CardID = upd.LibrarianID
LEFT JOIN CustomerCards cc ON cc.CardID = upd.CardID";
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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LDBproj", "LDBproj\LDBproj.csproj", "{BA5F8F6F-85FF-43E6-A4B0-D8DC7F897FD6}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LDBproject", "LDBproj\LDBproject.csproj", "{BA5F8F6F-85FF-43E6-A4B0-D8DC7F897FD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution