Лаб3 готова

This commit is contained in:
Артем Харламов 2023-12-12 16:23:04 +04:00
parent 65e207cf3d
commit 32dfbe5764
23 changed files with 1488 additions and 52 deletions

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class AuthorSearchModel
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModels
{
public class BookSearchModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Author { get; set; } = string.Empty;
public string PicturePath { get; set; } = string.Empty;
public DateTime PublicationDate { get; set; }
}
}

View File

@ -14,6 +14,7 @@ namespace Contracts.ViewModels
public string Name { get; set; } = string.Empty;
[DisplayName("Автор")]
public string Author { get; set; } = string.Empty;
public string PicturePath { get; set; } = string.Empty;
[DisplayName("Дата публикации")]
public DateTime PublicationDate { get; set; }
}

View File

@ -44,7 +44,7 @@ namespace DatabaseImplement.Implements
{
var context = new LibraryDatabase();
return context.Books
.Where(book => book.Name.Contains(model.Name) && book.Author.Contains(model.Author))
.Where(book => book.Name.Contains(model.Name) && book.PublicationDate.Equals(model.PublicationDate))
.ToList()
.Select(CreateModel)
.ToList();
@ -117,6 +117,7 @@ namespace DatabaseImplement.Implements
Id = book.Id,
Name = book.Name,
Author = book.Author,
PicturePath = book.PicturePath,
PublicationDate = book.PublicationDate
};
}

View File

@ -0,0 +1,71 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(LibraryDatabase))]
[Migration("20231130223553_FirstUpdate")]
partial class FirstUpdate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Author", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Authors");
});
modelBuilder.Entity("DatabaseImplement.Models.Book", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PicturePath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("PublicationDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Books");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class FirstUpdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Author",
table: "Books");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Author",
table: "Books",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
}
}
}

View File

@ -0,0 +1,75 @@
// <auto-generated />
using System;
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(LibraryDatabase))]
[Migration("20231211142817_SecondUpdate")]
partial class SecondUpdate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Author", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Authors");
});
modelBuilder.Entity("DatabaseImplement.Models.Book", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Author")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PicturePath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("PublicationDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Books");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class SecondUpdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Author",
table: "Books",
type: "nvarchar(max)",
nullable: false,
defaultValue: "");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Author",
table: "Books");
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -12,12 +13,12 @@ namespace DatabaseImplement.Models
public int Id { get; set; }
[Required]
public string Name { get; set; }
public string Name { get; set; } = string.Empty;
[Required]
public string PicturePath { get; set; }
public string PicturePath { get; set; } = string.Empty;
[Required]
public string Author { get; set; }
public string Author { get; set; } = string.Empty;
[Required]
public DateTime PublicationDate { get; set; }

65
Library/FormAuthor.Designer.cs generated Normal file
View File

@ -0,0 +1,65 @@
namespace Library
{
partial class FormAuthor
{
/// <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()
{
dataGridView1 = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.Size = new Size(704, 411);
dataGridView1.TabIndex = 0;
dataGridView1.CellEndEdit += dataGridView_CellEndEdit;
dataGridView1.KeyDown += dataGridView_KeyDown;
//
// FormAuthor
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(704, 411);
Controls.Add(dataGridView1);
Name = "FormAuthor";
Text = "Справочник авторов";
Load += FormAuthor_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
}
}

119
Library/FormAuthor.cs Normal file
View File

@ -0,0 +1,119 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Library
{
public partial class FormAuthor : Form
{
private readonly IAuthorLogic authorLogic;
BindingList<AuthorBindingModel> authorBindingList;
public FormAuthor(IAuthorLogic _authorLogic)
{
InitializeComponent();
authorLogic = _authorLogic;
authorBindingList = new BindingList<AuthorBindingModel>();
dataGridView1.AllowUserToAddRows = false;
}
private void LoadData()
{
try
{
var list1 = authorLogic.Read(null);
authorBindingList.Clear();
foreach (var item in list1)
{
authorBindingList.Add(new AuthorBindingModel
{
Id = item.Id,
FIO = item.FIO,
});
}
if (authorLogic != null)
{
dataGridView1.DataSource = authorBindingList;
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var typeName = (string)dataGridView1.CurrentRow.Cells[1].Value;
if (!string.IsNullOrEmpty(typeName))
{
if (dataGridView1.CurrentRow.Cells[0].Value != null)
{
authorLogic.CreateOrUpdate(new AuthorBindingModel()
{
Id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value),
FIO = (string)dataGridView1.CurrentRow.Cells[1].EditedFormattedValue
});
}
else
{
authorLogic.CreateOrUpdate(new AuthorBindingModel()
{
FIO = (string)dataGridView1.CurrentRow.Cells[1].EditedFormattedValue
});
}
}
else
{
MessageBox.Show("Введена пустая строка", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
private void FormAuthor_Load(object sender, EventArgs e)
{
LoadData();
}
private void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Insert)
{
if (dataGridView1.Rows.Count == 0)
{
authorBindingList.Add(new AuthorBindingModel());
dataGridView1.DataSource = new BindingList<AuthorBindingModel>(authorBindingList);
dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[1];
return;
}
if (dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value != null)
{
authorBindingList.Add(new AuthorBindingModel());
dataGridView1.DataSource = new BindingList<AuthorBindingModel>(authorBindingList);
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1];
return;
}
}
if (e.KeyData == Keys.Delete)
{
if (MessageBox.Show("Удалить выбранный элемент", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
authorLogic.Delete(new AuthorBindingModel() { Id = (int)dataGridView1.CurrentRow.Cells[0].Value });
LoadData();
}
}
}
}
}

120
Library/FormAuthor.resx Normal file
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>

167
Library/FormBook.Designer.cs generated Normal file
View File

@ -0,0 +1,167 @@
namespace Library
{
partial class FormBook
{
/// <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()
{
labelName = new Label();
textBoxName = new TextBox();
labelCover = new Label();
textBoxCover = new TextBox();
labelAuthor = new Label();
labelDate = new Label();
dateTextBox = new CustomComponents.DateTextBox();
button1 = new Button();
buttonSave = new Button();
booksForm = new KOP_Labs.BooksForm();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(34, 218);
labelName.Name = "labelName";
labelName.Size = new Size(124, 20);
labelName.TabIndex = 0;
labelName.Text = "Название книги:";
//
// textBoxName
//
textBoxName.Location = new Point(175, 218);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(205, 27);
textBoxName.TabIndex = 1;
//
// labelCover
//
labelCover.AutoSize = true;
labelCover.Location = new Point(34, 263);
labelCover.Name = "labelCover";
labelCover.Size = new Size(75, 20);
labelCover.TabIndex = 2;
labelCover.Text = "Обложка:";
//
// textBoxCover
//
textBoxCover.Location = new Point(175, 256);
textBoxCover.Name = "textBoxCover";
textBoxCover.Size = new Size(205, 27);
textBoxCover.TabIndex = 3;
textBoxCover.DoubleClick += textBoxCover_Click;
//
// labelAuthor
//
labelAuthor.AutoSize = true;
labelAuthor.Location = new Point(34, 14);
labelAuthor.Name = "labelAuthor";
labelAuthor.Size = new Size(54, 20);
labelAuthor.TabIndex = 4;
labelAuthor.Text = "Автор:";
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(34, 327);
labelDate.Name = "labelDate";
labelDate.Size = new Size(106, 20);
labelDate.TabIndex = 6;
labelDate.Text = "Дата издания:";
//
// dateTextBox
//
dateTextBox.Location = new Point(165, 289);
dateTextBox.Name = "dateTextBox";
dateTextBox.Pattern = "";
dateTextBox.Size = new Size(157, 77);
dateTextBox.TabIndex = 8;
dateTextBox.TextBoxValue = "";
//
// button1
//
button1.Location = new Point(34, 399);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 9;
button1.Text = "Закрыть";
button1.UseVisualStyleBackColor = true;
button1.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(257, 399);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// booksForm
//
booksForm.AutoSize = true;
booksForm.Location = new Point(129, 14);
booksForm.Name = "booksForm";
booksForm.SelectedValue = null;
booksForm.Size = new Size(251, 201);
booksForm.TabIndex = 11;
//
// FormBook
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(392, 484);
Controls.Add(booksForm);
Controls.Add(buttonSave);
Controls.Add(button1);
Controls.Add(dateTextBox);
Controls.Add(labelDate);
Controls.Add(labelAuthor);
Controls.Add(textBoxCover);
Controls.Add(labelCover);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormBook";
Text = "Создание/Редактирование книги";
Load += FormBook_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private TextBox textBoxName;
private Label labelCover;
private TextBox textBoxCover;
private Label labelAuthor;
private Label labelDate;
private CustomComponents.DateTextBox dateTextBox;
private Button button1;
private Button buttonSave;
private KOP_Labs.BooksForm booksForm;
}
}

126
Library/FormBook.cs Normal file
View File

@ -0,0 +1,126 @@
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using KOP_Labs;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Library
{
public partial class FormBook : Form
{
public int Id { set { id = value; } }
private readonly IBookLogic _logicB;
private readonly IAuthorLogic _logicA;
private int? id;
public FormBook(IBookLogic bookLogic, IAuthorLogic authorLogic)
{
InitializeComponent();
_logicB = bookLogic;
_logicA = authorLogic;
}
private void buttonSave_Click(object sender, EventArgs e)
{
dateTextBox.Pattern = @"^(([0-2][0-9])|([3][0-1]))\s(января|февраля|марта|апреля|мая|июня|июля|августа|сентября|октября|ноября|декабря)\s\d{4}$";
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название книги", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxCover.Text))
{
MessageBox.Show("Выберите обложку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(dateTextBox.TextBoxValue))
{
MessageBox.Show("Заполните дату публикации согласно шаблону", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(booksForm.SelectedValue))
{
MessageBox.Show("Выберите хотя бы одного автора", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
_logicB.CreateOrUpdate(new BookBindingModel
{
Id = id,
Name = textBoxName.Text,
PicturePath = textBoxCover.Text,
Author = booksForm.SelectedValue,
PublicationDate = DateTime.Parse(dateTextBox.TextBoxValue)
}) ;
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormBook_Load(object sender, EventArgs e)
{
List<AuthorViewModel> viewS = _logicA.Read(null);
if (viewS != null)
{
booksForm.ClearList();
foreach (AuthorViewModel s in viewS)
{
booksForm.FillValues(s.FIO);
}
}
if (id.HasValue)
{
try
{
BookViewModel view = _logicB.Read(new BookBindingModel { Id = id.Value })?[0];
if (view != null)
{
textBoxName.Text = view.Name;
textBoxCover.Text = view.PicturePath;
booksForm.SelectedValue = view.Author;
dateTextBox.TextBoxValue = view.PublicationDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("ru-RU"));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void textBoxCover_Click(object sender, EventArgs e)
{
using (var dialog = new OpenFileDialog { Filter = "jpg|*.jpg" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
textBoxCover.Text = dialog.FileName.ToString();
}
}
}
}
}

120
Library/FormBook.resx Normal file
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

@ -28,12 +28,161 @@
/// </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";
components = new System.ComponentModel.Container();
удалитьToolStripMenuItem = new ToolStripMenuItem();
редактироватьToolStripMenuItem = new ToolStripMenuItem();
сохранитьВPDFToolStripMenuItem = new ToolStripMenuItem();
сохранитьВEToolStripMenuItem = new ToolStripMenuItem();
сохранитьВWordToolStripMenuItem = new ToolStripMenuItem();
авторыToolStripMenuItem = new ToolStripMenuItem();
tableComponent = new KOP_Labs.TableComponent();
pdfImages = new ViewComponents.NotVisualComponents.PdfImages(components);
wordHistogramm = new KOP_Labs.NonVisualComponents.WordHistogramm(components);
contextMenuStrip = new ContextMenuStrip(components);
добавитьToolStripMenuItem = new ToolStripMenuItem();
удалитьToolStripMenuItem1 = new ToolStripMenuItem();
редактироватьToolStripMenuItem1 = new ToolStripMenuItem();
сохранитьВPdfToolStripMenuItem1 = new ToolStripMenuItem();
сохранитьВToolStripMenuItem = new ToolStripMenuItem();
сохранитьВWordToolStripMenuItem1 = new ToolStripMenuItem();
авторыToolStripMenuItem1 = new ToolStripMenuItem();
excelTable1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowExcel(components);
contextMenuStrip.SuspendLayout();
SuspendLayout();
//
// удалитьToolStripMenuItem
//
удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
удалитьToolStripMenuItem.Size = new Size(32, 19);
//
// редактироватьToolStripMenuItem
//
редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
редактироватьToolStripMenuItem.Size = new Size(32, 19);
//
// сохранитьВPDFToolStripMenuItem
//
сохранитьВPDFToolStripMenuItem.Name = "сохранитьВPDFToolStripMenuItem";
сохранитьВPDFToolStripMenuItem.Size = new Size(32, 19);
//
// сохранитьВEToolStripMenuItem
//
сохранитьВEToolStripMenuItem.Name = "сохранитьВEToolStripMenuItem";
сохранитьВEToolStripMenuItem.Size = new Size(32, 19);
//
// сохранитьВWordToolStripMenuItem
//
сохранитьВWordToolStripMenuItem.Name = "сохранитьВWordToolStripMenuItem";
сохранитьВWordToolStripMenuItem.Size = new Size(32, 19);
//
// авторыToolStripMenuItem
//
авторыToolStripMenuItem.Name = "авторыToolStripMenuItem";
авторыToolStripMenuItem.Size = new Size(32, 19);
//
// tableComponent
//
tableComponent.Dock = DockStyle.Fill;
tableComponent.IndexRow = 0;
tableComponent.Location = new Point(0, 0);
tableComponent.Name = "tableComponent";
tableComponent.Size = new Size(800, 450);
tableComponent.TabIndex = 1;
//
// contextMenuStrip
//
contextMenuStrip.ImageScalingSize = new Size(20, 20);
contextMenuStrip.Items.AddRange(new ToolStripItem[] { добавитьToolStripMenuItem, удалитьToolStripMenuItem1, редактироватьToolStripMenuItem1, сохранитьВPdfToolStripMenuItem1, сохранитьВToolStripMenuItem, сохранитьВWordToolStripMenuItem1, авторыToolStripMenuItem1 });
contextMenuStrip.Name = "contextMenuStrip";
contextMenuStrip.Size = new Size(256, 172);
//
// добавитьToolStripMenuItem
//
добавитьToolStripMenuItem.Name = обавитьToolStripMenuItem";
добавитьToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.A;
добавитьToolStripMenuItem.Size = new Size(255, 24);
добавитьToolStripMenuItem.Text = "Добавить";
добавитьToolStripMenuItem.Click += добавитьToolStripMenuItem_Click;
//
// удалитьToolStripMenuItem1
//
удалитьToolStripMenuItem1.Name = "удалитьToolStripMenuItem1";
удалитьToolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.D;
удалитьToolStripMenuItem1.Size = new Size(255, 24);
удалитьToolStripMenuItem1.Text = "Удалить";
удалитьToolStripMenuItem1.Click += удалитьToolStripMenuItem_Click;
//
// редактироватьToolStripMenuItem1
//
редактироватьToolStripMenuItem1.Name = "редактироватьToolStripMenuItem1";
редактироватьToolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.U;
редактироватьToolStripMenuItem1.Size = new Size(255, 24);
редактироватьToolStripMenuItem1.Text = "Редактировать";
редактироватьToolStripMenuItem1.Click += редактироватьToolStripMenuItem_Click;
//
// сохранитьВPdfToolStripMenuItem1
//
сохранитьВPdfToolStripMenuItem1.Name = "сохранитьВPdfToolStripMenuItem1";
сохранитьВPdfToolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.S;
сохранитьВPdfToolStripMenuItem1.Size = new Size(255, 24);
сохранитьВPdfToolStripMenuItem1.Text = "Сохранить в Pdf";
сохранитьВPdfToolStripMenuItem1.Click += сохранитьВPDFToolStripMenuItem_Click;
//
// сохранитьВToolStripMenuItem
//
сохранитьВToolStripMenuItem.Name = "сохранитьВToolStripMenuItem";
сохранитьВToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
сохранитьВToolStripMenuItem.Size = new Size(255, 24);
сохранитьВToolStripMenuItem.Text = "Сохранить в Excel";
сохранитьВToolStripMenuItem.Click += сохранитьВExcelToolStripMenuItem_Click;
//
// сохранитьВWordToolStripMenuItem1
//
сохранитьВWordToolStripMenuItem1.Name = "сохранитьВWordToolStripMenuItem1";
сохранитьВWordToolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.C;
сохранитьВWordToolStripMenuItem1.Size = new Size(255, 24);
сохранитьВWordToolStripMenuItem1.Text = "Сохранить в Word";
сохранитьВWordToolStripMenuItem1.Click += сохранитьВWordToolStripMenuItem_Click;
//
// авторыToolStripMenuItem1
//
авторыToolStripMenuItem1.Name = "авторыToolStripMenuItem1";
авторыToolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.F;
авторыToolStripMenuItem1.Size = new Size(255, 24);
авторыToolStripMenuItem1.Text = "Авторы";
авторыToolStripMenuItem1.Click += авторыToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(tableComponent);
Name = "FormMain";
Text = "Form1";
Load += FormMain_Load;
contextMenuStrip.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem сохранитьВPDFToolStripMenuItem;
private ToolStripMenuItem сохранитьВEToolStripMenuItem;
private ToolStripMenuItem сохранитьВWordToolStripMenuItem;
private KOP_Labs.TableComponent tableComponent;
private ViewComponents.NotVisualComponents.PdfImages pdfImages;
private KOP_Labs.NonVisualComponents.WordHistogramm wordHistogramm;
private ToolStripMenuItem авторыToolStripMenuItem;
private ContextMenuStrip contextMenuStrip;
private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem1;
private ToolStripMenuItem редактироватьToolStripMenuItem1;
private ToolStripMenuItem сохранитьВPdfToolStripMenuItem1;
private ToolStripMenuItem сохранитьВToolStripMenuItem;
private ToolStripMenuItem сохранитьВWordToolStripMenuItem1;
private ToolStripMenuItem авторыToolStripMenuItem1;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderRowExcel excelTable1;
}
}

View File

@ -1,10 +1,256 @@
using ComponentsLibraryNet60.Models;
using Contracts.BindingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using Contracts.ViewModels;
using CustomComponents;
using KOP_Labs.Classes;
using System.Collections.Generic;
using Unity;
using ViewComponents.NotVisualComponents;
namespace Library
{
public partial class FormMain : Form
{
public FormMain()
private readonly IBookLogic _bookLogic;
private readonly IAuthorLogic _authorLogic;
public FormMain(IBookLogic bookLogic, IAuthorLogic authorLogic)
{
_bookLogic = bookLogic;
_authorLogic = authorLogic;
InitializeComponent();
tableComponent.TableConfiguration(5, new List<TableParameters>
{
new TableParameters("Id", 80, false, "Id"),
new TableParameters("Íàçâàíèå", 100, true, "Name"),
new TableParameters("Àâòîð", 180, true, "Author"),
new TableParameters("Îáëîæêà", 80, false, "PicturePath"),
new TableParameters("Äàòà èçäàíèÿ", 150, true, "PublicationDate")
});
tableComponent.ContextMenuStrip = contextMenuStrip;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
tableComponent.ClearRows();
try
{
var list = _bookLogic.Read(null);
foreach (var row in list)
{
tableComponent.AddRow(row);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AddNewElement()
{
var form = Program.Container.Resolve<FormBook>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void UpdateElement()
{
var form = Program.Container.Resolve<FormBook>();
var selectedBook = tableComponent.GetSelectedObject<BookSearchModel>();
if (selectedBook != null)
{
form.Id = Convert.ToInt32(selectedBook.Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
else
{
MessageBox.Show("Âûáåðèòå êíèãó äëÿ ðåäàêòèðîâàíèÿ");
}
}
private void DeleteElement()
{
if (MessageBox.Show("Óäàëèòü êíèãó", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var selectedBook = tableComponent.GetSelectedObject<BookSearchModel>();
int id = Convert.ToInt32(selectedBook.Id);
try
{
_bookLogic.Delete(new BookBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
private void CreatePdf()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Ôàéë âûáðàí", "Óñïåõ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else return;
}
List<string> images = new List<string>();
var list = _bookLogic.Read(null);
try
{
if (list != null)
{
foreach (var item in list)
{
images.Add(item.PicturePath);
}
string[] imagesArray = images.ToArray();
pdfImages.CreatePdfDoc(new ImagesForPDF(fileName, "Èëëþñòðàöèè êíèã", imagesArray));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà");
}
}
private void CreateExcel()
{
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Ôàéë âûáðàí", "Óñïåõ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else return;
}
List<(int Column, int Row)> width = new List<(int, int)>() { (30, 0), (30, 0), (30, 0), (30, 0) };
List<(int StartIndex, int Count)> column_union = new List<(int, int)>() { (1, 2) };
List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> headers =
new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> {
(0,0, "Èäåíòèôèêàòîð", "Id"),
(1,0,"Êíèãà", ""),
(1,1,"Íàçâàíèå", "Name"),
(2,1,"Àâòîð","Author"),
(3,0,"Äàòà ïóáëèêàöèè", "PublicationDate")
};
var list = _bookLogic.Read(null);
ComponentDocumentWithTableHeaderDataConfig<BookViewModel> config = new();
try
{
excelTable1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<BookViewModel>()
{
Data = list,
UseUnion = true,
ColumnsRowsWidth = width,
ColumnUnion = column_union,
Headers = headers,
FilePath = fileName,
Header = "Îò÷¸ò ïî êíèãàì"
});
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà");
}
}
private void CreateWord()
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
string fileName = "";
using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
fileName = dialog.FileName.ToString();
MessageBox.Show("Ôàéë âûáðàí", "Óñïåõ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else return;
}
List<DataHistogramm> dataHistogramms = new List<DataHistogramm>();
var list_author = _authorLogic.Read(null);
var list_book = _bookLogic.Read(null);
foreach (var nm in list_author)
{
int bk_count = 0;
foreach (var bk in list_book)
if (bk.Author.Contains(nm.FIO)) bk_count++;
dataHistogramms.Add(new DataHistogramm(nm.FIO, bk_count));
}
try
{
wordHistogramm.CreateHistogramm(new MyHistogramm(fileName, "Ãèñòîãðàììà", "Àâòîðû è èõ êíèãè", EnumLegends.Top, dataHistogramms));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà");
}
}
private void äîáàâèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
AddNewElement();
}
private void óäàëèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
DeleteElement();
}
private void ðåäàêòèðîâàòüToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateElement();
}
private void ñîõðàíèòüÂPDFToolStripMenuItem_Click(object sender, EventArgs e)
{
CreatePdf();
}
private void ñîõðàíèòüÂExcelToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateExcel();
}
private void ñîõðàíèòüÂWordToolStripMenuItem_Click(object sender, EventArgs e)
{
CreateWord();
}
private void àâòîðûToolStripMenuItem_Click(object sender, EventArgs e)
{
var form = Program.Container.Resolve<FormAuthor>();
form.ShowDialog();
}
}
}

View File

@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="pdfImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>194, 17</value>
</metadata>
<metadata name="wordHistogramm.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>454, 17</value>
</metadata>
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>627, 17</value>
</metadata>
<metadata name="excelTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>804, 17</value>
</metadata>
</root>

View File

@ -9,14 +9,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="CustomComponents" Version="1.0.0" />
<PackageReference Include="KOP_Labs" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PDFsharp-MigraDoc" Version="1.50.5147" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="ViewComponents" Version="1.0.0" />
</ItemGroup>

View File

@ -1,17 +1,38 @@
using BusinessLogic;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Unity;
using Unity.Lifetime;
namespace Library
{
internal static class Program
{
private static IUnityContainer container = null;
public static IUnityContainer Container { get { if (container == null) { container = BuildUnityContainer(); } return container; } }
/// <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 FormMain());
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(Container.Resolve<FormMain>());
}
private static IUnityContainer BuildUnityContainer()
{
var currentContainer = new UnityContainer();
currentContainer.RegisterType<IBookStorage, BookStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IAuthorStorage, AuthorStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IBookLogic, BookLogic>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IAuthorLogic, AuthorLogic>(new HierarchicalLifetimeManager());
return currentContainer;
}
}
}

View File

@ -187,7 +187,7 @@
myTreeView.Location = new Point(629, 218);
myTreeView.Name = "myTreeView";
myTreeView.SelectedNodeIndex = -1;
myTreeView.Size = new Size(226, 204);
myTreeView.Size = new Size(201, 192);
myTreeView.TabIndex = 8;
//
// buttonPdfImages

View File

@ -1,4 +1,64 @@
<root>
<?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">

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="ComponentsForKOP" value="C:\ComponentsForKOP" />
</packageSources>
<activePackageSource>
<!-- this tells that all of them are active -->
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>