Compare commits

..

No commits in common. "0fba5967709c252c4ed829f1cff456725074cbec" and "07ccf1e048078d1c845f36d785b47d826bfae7d1" have entirely different histories.

79 changed files with 49 additions and 3533 deletions

View File

@ -9,9 +9,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Excel-DNA.Interop" Version="15.0.1" /> <PackageReference Include="Excel-DNA.Interop" Version="15.0.1" />
<PackageReference Include="KOP_Labs" Version="1.0.0" />
<PackageReference Include="Microsoft.Office.Excel" Version="14.0.4760.1000" /> <PackageReference Include="Microsoft.Office.Excel" Version="14.0.4760.1000" />
<PackageReference Include="ViewComponents" Version="1.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,7 +1,6 @@
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CustomComponents.MyNonVisualComponents;
using Excel = Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel;
namespace CustomComponents namespace CustomComponents

View File

@ -0,0 +1,10 @@
namespace CustomComponents
{
public enum LegendPosition
{
Left,
Top,
Right,
Botton,
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.Office.Interop.Excel;
namespace CustomComponents
{
public class LineChartConfig
{
public string FilePath { get; set; }
public string Header { get; set; }
public string ChartTitle { get; set; }
public Dictionary<string, List<int>> Values { get; set; }
public LegendPosition LegendPosition { get; set; }
}
}

View File

@ -94,10 +94,5 @@ namespace CustomComponents
listBox.Items.Add(str); listBox.Items.Add(str);
} }
public void deleteAll()
{
listBox.Items.Clear();
}
} }
} }

View File

@ -0,0 +1,14 @@
namespace CustomComponents
{
public class MergeCells
{
public string Heading;
public int[] CellIndexes;
public MergeCells(string heading, int[] cellIndexes)
{
Heading = heading;
CellIndexes = cellIndexes;
}
}
}

View File

@ -1,10 +0,0 @@
namespace CustomComponents.MyNonVisualComponents
{
public enum LegendPosition
{
Left,
Top,
Right,
Botton,
}
}

View File

@ -1,17 +0,0 @@
using Microsoft.Office.Interop.Excel;
namespace CustomComponents.MyNonVisualComponents
{
public class LineChartConfig
{
public string FilePath { get; set; }
public string Header { get; set; }
public string ChartTitle { get; set; }
public Dictionary<string, List<int>> Values { get; set; }
public LegendPosition LegendPosition { get; set; }
}
}

View File

@ -1,14 +0,0 @@
namespace CustomComponents.MyNonVisualComponents
{
public class MergeCells
{
public string Heading;
public int[] CellIndexes;
public MergeCells(string heading, int[] cellIndexes)
{
Heading = heading;
CellIndexes = cellIndexes;
}
}
}

View File

@ -1,5 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using CustomComponents.MyNonVisualComponents;
using Excel = Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel;
namespace CustomComponents namespace CustomComponents

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public class ColumnParameters
{
public string _nameColumn { get; set; } = string.Empty;
public string _nameField { get; set; } = string.Empty;
public ColumnParameters(string nameColumn, string nameField)
{
_nameColumn = nameColumn;
_nameField = nameField;
}
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public class DataHistogramm
{
public string _nameData { get; set; } = string.Empty;
public double _data { get; set; }
public DataHistogramm(string nameData, int data)
{
_nameData = nameData;
_data = data;
}
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public enum EnumLegends
{
None = 0,
Left = 1,
Right = 2,
Top = 3,
Bottom = 4
}
}

View File

@ -1,30 +0,0 @@
using DocumentFormat.OpenXml.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public class MyHistogramm
{
public string _filePath = string.Empty;
public string _fileHeader = string.Empty;
public string _histogramName = string.Empty;
public EnumLegends _legends;
public List<DataHistogramm> _dataList = new();
public MyHistogramm(string filePath, string fileHeader, string histogramName, EnumLegends legends, List<DataHistogramm> dataList) {
_filePath = filePath;
_fileHeader = fileHeader;
_histogramName = histogramName;
_legends = legends;
_dataList = dataList;
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public class MyTable
{
public string _filePath = string.Empty;
public string _fileHeader = string.Empty;
public List<string[,]> _dataList = new();
public MyTable(string filePath, string fileHeader, List<string[,]> dataList) {
_filePath = filePath;
_fileHeader = fileHeader;
_dataList = dataList;
}
}
}

View File

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public class MyTableWithHead<T>
{
public string _filePath = string.Empty;
public string _fileHeader = string.Empty;
public List<double> _heightRow = new();
public List<double> _widthCol = new();
public List<T> _dataList;
public Dictionary<int, ColumnParameters> _columnsSettings;
public MyTableWithHead(string filePath, string fileHeader, List<double> heightRow,
List<double> widthCol, List<T> dataList, Dictionary<int, ColumnParameters> columnsSettings)
{
_filePath = filePath;
_fileHeader = fileHeader;
_heightRow = heightRow;
_widthCol = widthCol;
_dataList = dataList;
_columnsSettings = columnsSettings;
}
}
}

View File

@ -1,36 +0,0 @@
namespace CustomComponents.ZhelovanovNonVisualComponents
{
partial class WordHistogramm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -1,88 +0,0 @@
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Drawing.Charts;
using KOP_Labs.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.ZhelovanovNonVisualComponents
{
public partial class WordHistogramm : Component
{
public WordHistogramm()
{
InitializeComponent();
}
public WordHistogramm(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateHistogramm(MyHistogramm myHistogramm)
{
if(!CheckData(myHistogramm._dataList)) {
return;
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Aspose.Words.Font font = builder.Font;
font.Size = 14;
font.Bold = true;
font.Color = System.Drawing.Color.Black;
font.Name = "Times New Roman";
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
paragraphFormat.FirstLineIndent = 8;
paragraphFormat.SpaceAfter = 24;
paragraphFormat.Alignment = ParagraphAlignment.Center;
paragraphFormat.KeepTogether = true;
builder.Writeln(myHistogramm._fileHeader);
Shape shape = builder.InsertChart(ChartType.Column, 500, 270);
Chart chart = shape.Chart;
chart.Title.Text = myHistogramm._fileHeader;
ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();
string[] categories = new string[] { myHistogramm._dataList[0]._nameData };
foreach (var data in myHistogramm._dataList)
{
seriesColl.Add(data._nameData, categories, new double[] { data._data });
}
ChartLegend legend = chart.Legend;
legend.Position = (LegendPosition)myHistogramm._legends;
legend.Overlay = true;
doc.Save(myHistogramm._filePath);
}
private bool CheckData(List<DataHistogramm> data)
{
foreach (var _data in data)
{
if (string.IsNullOrEmpty(_data._data.ToString()))
{
return false;
}
}
return true;
}
}
}

View File

@ -1,36 +0,0 @@
namespace KOP_Labs.NonVisualComponents
{
partial class WordTableComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -1,166 +0,0 @@

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.ExtendedProperties;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using KOP_Labs.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Bold = DocumentFormat.OpenXml.Wordprocessing.Bold;
using BottomBorder = DocumentFormat.OpenXml.Wordprocessing.BottomBorder;
using LeftBorder = DocumentFormat.OpenXml.Wordprocessing.LeftBorder;
using RightBorder = DocumentFormat.OpenXml.Wordprocessing.RightBorder;
using Run = DocumentFormat.OpenXml.Wordprocessing.Run;
using RunProperties = DocumentFormat.OpenXml.Wordprocessing.RunProperties;
using Table = DocumentFormat.OpenXml.Wordprocessing.Table;
using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
using TopBorder = DocumentFormat.OpenXml.Wordprocessing.TopBorder;
namespace KOP_Labs.NonVisualComponents
{
public partial class WordTableComponent : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public WordTableComponent()
{
InitializeComponent();
}
public WordTableComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDoc(MyTable myTable)
{
if(!CheckData(myTable._dataList)) return;
_wordDocument = WordprocessingDocument.Create(myTable._filePath, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
using (WordprocessingDocument doc = WordprocessingDocument.Open(myTable._filePath, true))
{
var mainDoc = doc.MainDocumentPart.Document;
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph headerParagraph = new Paragraph();
Run headerRun = new Run(new Text(myTable._fileHeader));
RunProperties runProperties = new RunProperties();
Bold bold = new Bold();
runProperties.Append(bold);
headerRun.Append(runProperties);
headerParagraph.Append(headerRun);
Table table = new Table();
TableProperties props = 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
}
));
table.AppendChild<TableProperties>(props);
for (var i = 0; i < myTable._dataList.Count; i++)
{
var tr = new TableRow();
for (var j = 0; j < myTable._dataList[i].Length; j++)
{
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = "2000"
}
));
tc.Append(new Paragraph(new Run(new Text(myTable._dataList[i][0, j]))));
tr.Append(tc);
}
table.Append(tr);
}
mainDoc.Body.Append(headerParagraph);
mainDoc.Body.Append(table);
mainDoc.Save();
}
}
private bool CheckData(List<string[,]> data)
{
for (int i = 0; i < data.Count; i++)
{
for (int j = 0; j < data[i].Length; j++)
{
if (data[i][0, j] == null) {
return false;
}
}
}
return true;
}
}
}

View File

@ -1,36 +0,0 @@
namespace KOP_Labs.NonVisualComponents
{
partial class WordTableHeaderComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -1,243 +0,0 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using KOP_Labs.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Wordprocessing;
namespace KOP_Labs.NonVisualComponents
{
public partial class WordTableHeaderComponent : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public WordTableHeaderComponent()
{
InitializeComponent();
}
public WordTableHeaderComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDoc<T>(MyTableWithHead<T> myTable)
{
if (!CheckData(myTable._dataList)) return;
_wordDocument = WordprocessingDocument.Create(myTable._filePath, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
using (WordprocessingDocument doc = WordprocessingDocument.Open(myTable._filePath, true))
{
var mainDoc = doc.MainDocumentPart.Document;
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph headerParagraph = new Paragraph();
Run headerRun = new Run(new Text(myTable._fileHeader));
RunProperties runProperties = new RunProperties();
Bold bold = new Bold();
runProperties.Append(bold);
headerRun.Append(runProperties);
headerParagraph.Append(headerRun);
Table table = new Table();
TableProperties props = 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
}
));
table.AppendChild<TableProperties>(props);
var _tr = new TableRow();
int indexHeaderHeigh = 0;
int indexHeaderWidth = 0;
foreach (var item in myTable._columnsSettings)
{
_tr.Append(new TableRowProperties(new TableRowHeight
{
Val = Convert.ToUInt32(myTable._heightRow[indexHeaderHeigh])
}));
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = myTable._widthCol[indexHeaderWidth].ToString(),
}
));
if (string.IsNullOrEmpty(myTable._columnsSettings[indexHeaderWidth]._nameField) ||
string.IsNullOrEmpty(myTable._columnsSettings[indexHeaderWidth]._nameColumn))
{
return;
}
Paragraph tableHeader = new();
var Run = new Run();
var headerProperties = new RunProperties();
headerProperties.Append(new Bold());
Run.AppendChild(headerProperties);
Run.AppendChild(new Text(item.Value._nameColumn));
tableHeader.AppendChild(Run);
tc.Append(tableHeader);
_tr.Append(tc);
indexHeaderWidth++;
}
table.Append(_tr);
indexHeaderHeigh++;
indexHeaderWidth = 0;
for (int i = 0; i < myTable._dataList.Count; i++)
{
var tr = new TableRow();
foreach (var item in myTable._columnsSettings)
{
tr.Append(new TableRowProperties(new TableRowHeight
{
Val = Convert.ToUInt32(myTable._heightRow[indexHeaderHeigh])
}));
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = myTable._widthCol[indexHeaderWidth].ToString(),
}
));
foreach (var val in myTable._dataList[i].GetType().GetProperties())
{
if (val.Name == item.Value._nameField)
{
var newParagraph = new Paragraph();
var newRun = new Run();
var runPropertiesInd = new RunProperties();
if (indexHeaderWidth == 0)
{
runPropertiesInd.Append(new Bold());
}
newRun.AppendChild(runPropertiesInd);
newRun.AppendChild(new Text(val.GetValue(myTable._dataList[i]).ToString()));
newParagraph.AppendChild(newRun);
tc.Append(newParagraph);
break;
}
}
tr.Append(tc);
indexHeaderWidth++;
}
indexHeaderWidth = 0;
table.Append(tr);
}
mainDoc.Body.Append(headerParagraph);
mainDoc.Body.Append(table);
mainDoc.Save();
}
}
private bool CheckData<T>(List<T> dataList)
{
foreach (var data in dataList)
{
foreach (var value in data.GetType().GetProperties())
{
if (string.IsNullOrEmpty(value.GetValue(data).ToString()))
{
return false;
}
}
}
return true;
}
}
}

View File

@ -1,72 +0,0 @@
namespace KOP_Labs
{
partial class BooksForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
groupBoxComponent = new GroupBox();
listBoxComponent = new ListBox();
groupBoxComponent.SuspendLayout();
SuspendLayout();
//
// groupBoxComponent
//
groupBoxComponent.Controls.Add(listBoxComponent);
groupBoxComponent.Location = new Point(19, 28);
groupBoxComponent.Name = "groupBoxComponent";
groupBoxComponent.Size = new Size(517, 183);
groupBoxComponent.TabIndex = 0;
groupBoxComponent.TabStop = false;
groupBoxComponent.Text = "Компонент";
//
// listBoxComponent
//
listBoxComponent.FormattingEnabled = true;
listBoxComponent.ItemHeight = 20;
listBoxComponent.Location = new Point(24, 35);
listBoxComponent.Name = "listBoxComponent";
listBoxComponent.Size = new Size(476, 124);
listBoxComponent.TabIndex = 0;
listBoxComponent.SelectedIndexChanged += listBoxComponent_SelectedIndexChanged;
//
// BooksForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(groupBoxComponent);
Name = "BooksForm";
Size = new Size(563, 258);
groupBoxComponent.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxComponent;
private ListBox listBoxComponent;
}
}

View File

@ -1,69 +0,0 @@
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 KOP_Labs
{
public partial class BooksForm : UserControl
{
public BooksForm()
{
InitializeComponent();
}
public string? SelectedValue
{
get
{
if (listBoxComponent.SelectedItem == null)
{
return null;
}
return listBoxComponent.SelectedItem.ToString()!;
}
set
{
if (value != null && !listBoxComponent.Items.Contains(value))
{
return;
}
listBoxComponent.SelectedItem = value;
}
}
private event EventHandler? _selectChanged;
public event EventHandler SelectChanged
{
add { _selectChanged += value; }
remove { _selectChanged -= value; }
}
public void FillValues(string values)
{
if (values == null || values.Length == 0)
{
return;
}
listBoxComponent.Items.Add(values);
}
public void ClearList()
{
listBoxComponent.Items.Clear();
}
private void listBoxComponent_SelectedIndexChanged(object sender, EventArgs e)
{
_selectChanged?.Invoke(this, e);
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<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

@ -1,63 +0,0 @@
namespace KOP_Labs
{
partial class TableComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(36, 29);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(300, 188);
dataGridView.TabIndex = 0;
dataGridView.SelectionChanged += SelectionChanged;
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
//
// TableComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(dataGridView);
Name = "TableComponent";
Size = new Size(542, 301);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

View File

@ -1,109 +0,0 @@
using KOP_Labs.Classes;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KOP_Labs
{
public partial class TableComponent : UserControl
{
public event EventHandler TaskHandler;
public int indexRow;
public int IndexRow
{
get
{
return indexRow;
}
set
{
indexRow = value;
}
}
public TableComponent()
{
InitializeComponent();
}
public void TableConfiguration(int countCol, List<TableParameters> parameters)
{
if (parameters.Count != parameters.Count) { return; }
for (int i = 0; i < countCol; i++)
{
DataGridViewColumn column = new DataGridViewColumn();
column.Name = parameters[i]._name;
column.HeaderText = parameters[i]._header;
column.Width = parameters[i]._width;
column.Visible = parameters[i]._isVisual;
column.CellTemplate = new DataGridViewTextBoxCell();
dataGridView.Columns.Add(column);
}
}
public void ClearRows()
{
dataGridView.Rows.Clear();
}
public void AddRow<T>(T newObject)
{
DataGridViewRow row = (DataGridViewRow)dataGridView.Rows[0].Clone();
foreach (var prop in newObject.GetType().GetProperties())
{
object value = prop.GetValue(newObject);
row.Cells[dataGridView.Columns[prop.Name].Index].Value = value;
}
dataGridView.Rows.Add(row);
}
public T GetSelectedObject<T>() where T : new()
{
if (dataGridView.SelectedCells.Count == 0)
{
return new T();
}
int rowIndex = dataGridView.SelectedCells[0].RowIndex;
var targetObject = new T();
Type objectType = typeof(T);
PropertyInfo[] properties = objectType.GetProperties();
foreach (PropertyInfo property in properties)
{
DataGridViewCell selectedCell = dataGridView.Rows[rowIndex].Cells[property.Name];
object cellValue = selectedCell.Value;
if (cellValue != null && property.CanWrite)
{
object convertedValue = Convert.ChangeType(cellValue, property.PropertyType);
property.SetValue(targetObject, convertedValue);
}
}
return targetObject;
}
private void SelectionChanged(object sender, EventArgs e)
{
var element = sender as DataGridView;
if (dataGridView.SelectedRows.Count == 0)
{
return;
}
IndexRow = element.SelectedRows[0].Index;
TaskHandler?.Invoke(this, e);
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<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

@ -1,71 +0,0 @@
namespace CustomComponents.ZhelovanovVisualComponents
{
partial class TextBoxComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
textBox = new TextBox();
checkBox1 = new CheckBox();
SuspendLayout();
//
// textBox
//
textBox.Location = new Point(141, 73);
textBox.Name = "textBox";
textBox.Size = new Size(125, 27);
textBox.TabIndex = 0;
textBox.TextChanged += TextBox_TextChanged;
//
// checkBox1
//
checkBox1.AutoSize = true;
checkBox1.Location = new Point(34, 73);
checkBox1.Name = "checkBox1";
checkBox1.Size = new Size(101, 24);
checkBox1.TabIndex = 1;
checkBox1.Text = "checkBox1";
checkBox1.UseVisualStyleBackColor = true;
checkBox1.CheckedChanged += CheckBox_CheckedChanged;
//
// TextBoxComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(checkBox1);
Controls.Add(textBox);
Name = "TextBoxComponent";
Size = new Size(439, 252);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
private CheckBox checkBox1;
}
}

View File

@ -1,129 +0,0 @@
using DocumentFormat.OpenXml.Drawing.Diagrams;
using KOP_Labs.Exceptions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
namespace CustomComponents.ZhelovanovVisualComponents
{
public partial class TextBoxComponent : UserControl
{
public TextBoxComponent()
{
InitializeComponent();
Error = string.Empty;
}
public string Error { get; private set; }
public float? Value
{
get
{
if (checkBox1.Checked)
{
return null;
}
if (CheckValue())
{
return float.Parse(textBox.Text);
}
return null;
}
set
{
if (value == null)
{
checkBox1.Checked = true;
}
textBox.Text = value.ToString();
}
}
private EventHandler checkChanged;
public event EventHandler CheckChanged
{
add
{
checkChanged += value;
}
remove
{
checkChanged -= value;
}
}
private void CheckBox_CheckedChanged(object sender, EventArgs e)
{
Error = string.Empty;
if (checkBox1.Checked)
{
textBox.Enabled = false;
textBox.Text = string.Empty;
}
else
{
textBox.Enabled = true;
}
checkChanged?.Invoke(sender, e);
}
private EventHandler valueChanged;
public event EventHandler ValueChanged
{
add
{
valueChanged += value;
}
remove
{
valueChanged -= value;
}
}
public bool CheckValue()
{
Error = string.Empty;
if (!checkBox1.Checked && (string.IsNullOrEmpty(textBox.Text)))
{
Error = "Пусто!";
return false;
}
if (!checkBox1.Checked && !float.TryParse(textBox.Text, out float floatValue))
{
Error = "Не тот тип!";
return false;
}
return true;
}
private void TextBox_TextChanged(object sender, EventArgs e)
{
valueChanged?.Invoke(sender, e);
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<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

@ -3,15 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.5.33530.505 VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryView", "LibraryView\LibraryView.csproj", "{50CEADA7-BB8C-41AB-BAB5-F29DF48E581F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryView", "LibraryView\LibraryView.csproj", "{50CEADA7-BB8C-41AB-BAB5-F29DF48E581F}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomComponents", "CustomComponents\CustomComponents.csproj", "{F6B42349-8FB3-4D68-8757-D26DAD2F0992}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomComponents", "CustomComponents\CustomComponents.csproj", "{F6B42349-8FB3-4D68-8757-D26DAD2F0992}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryBusinessLogic", "LibraryBusinessLogic\LibraryBusinessLogic.csproj", "{215533AD-E311-4527-B8F6-C9F3708FDA0B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryContracts", "LibraryContracts\LibraryContracts.csproj", "{26F921C2-4336-4123-ABC6-3916BF341224}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryDatabaseImplement", "LibraryDatabaseImplement\LibraryDatabaseImplement.csproj", "{B0677916-A9E7-48E6-961A-75C6ACFF2546}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -27,18 +21,6 @@ Global
{F6B42349-8FB3-4D68-8757-D26DAD2F0992}.Debug|Any CPU.Build.0 = Debug|Any CPU {F6B42349-8FB3-4D68-8757-D26DAD2F0992}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6B42349-8FB3-4D68-8757-D26DAD2F0992}.Release|Any CPU.ActiveCfg = Release|Any CPU {F6B42349-8FB3-4D68-8757-D26DAD2F0992}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6B42349-8FB3-4D68-8757-D26DAD2F0992}.Release|Any CPU.Build.0 = Release|Any CPU {F6B42349-8FB3-4D68-8757-D26DAD2F0992}.Release|Any CPU.Build.0 = Release|Any CPU
{215533AD-E311-4527-B8F6-C9F3708FDA0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{215533AD-E311-4527-B8F6-C9F3708FDA0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{215533AD-E311-4527-B8F6-C9F3708FDA0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{215533AD-E311-4527-B8F6-C9F3708FDA0B}.Release|Any CPU.Build.0 = Release|Any CPU
{26F921C2-4336-4123-ABC6-3916BF341224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26F921C2-4336-4123-ABC6-3916BF341224}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26F921C2-4336-4123-ABC6-3916BF341224}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26F921C2-4336-4123-ABC6-3916BF341224}.Release|Any CPU.Build.0 = Release|Any CPU
{B0677916-A9E7-48E6-961A-75C6ACFF2546}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0677916-A9E7-48E6-961A-75C6ACFF2546}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0677916-A9E7-48E6-961A-75C6ACFF2546}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0677916-A9E7-48E6-961A-75C6ACFF2546}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,60 +0,0 @@
using LibraryContracts.BusinessLogicsContracts;
using LibraryContracts.StorageContracts;
using LibraryContracts.BindingModels;
using LibraryContracts.ViewModels;
namespace LibraryBusinessLogic.BusinessLogics
{
public class BookLogic : IBookLogic
{
private readonly IBookStorage _bookStorage;
public BookLogic(IBookStorage bookStorage)
{
_bookStorage = bookStorage;
}
public List<BookViewModel> Read(BookBindingModel model)
{
if (model == null)
{
return _bookStorage.GetFullList();
}
if (model.Id.HasValue)
{
return new List<BookViewModel> { _bookStorage.GetElement(model) };
}
return _bookStorage.GetFilteredList(model);
}
public void CreateOrUpdate(BookBindingModel model)
{
var element = _bookStorage.GetElement(
new BookBindingModel
{
Title = model.Title
});
if (element != null && element.Id != model.Id)
{
throw new Exception("Книга с таким названием уже существует");
}
if (model.Id.HasValue)
{
_bookStorage.Update(model);
}
else
{
_bookStorage.Insert(model);
}
}
public void Delete(BookBindingModel model)
{
var element = _bookStorage.GetElement(new BookBindingModel { Id = model.Id });
if (element == null)
{
throw new Exception("Книга не найдена");
}
_bookStorage.Delete(model);
}
}
}

View File

@ -1,61 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.BusinessLogicsContracts;
using LibraryContracts.StorageContracts;
using LibraryContracts.ViewModels;
namespace LibraryBusinessLogic.BusinessLogics
{
public class GenreLogic : IGenreLogic
{
private readonly IGenreStorage _genreStorage;
public GenreLogic(IGenreStorage genreStorage)
{
_genreStorage = genreStorage;
}
public List<GenreViewModel> Read(GenreBindingModel model)
{
if (model == null)
{
return _genreStorage.GetFullList();
}
if (model.Id.HasValue)
{
return new List<GenreViewModel> { _genreStorage.GetElement(model) };
}
return _genreStorage.GetFilteredList(model);
}
public void CreateOrUpdate(GenreBindingModel model)
{
var element = _genreStorage.GetElement(
new GenreBindingModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new Exception("Такой жанр уже существует");
}
if (model.Id.HasValue)
{
_genreStorage.Update(model);
}
else
{
_genreStorage.Insert(model);
}
}
public void Delete(GenreBindingModel model)
{
var element = _genreStorage.GetElement(new GenreBindingModel { Id = model.Id });
if (element == null)
{
throw new Exception("Жанр не найден");
}
_genreStorage.Delete(model);
}
}
}

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LibraryContracts\LibraryContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -1,15 +0,0 @@
namespace LibraryContracts.BindingModels
{
public class BookBindingModel
{
public int? Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Genre { get; set; }
public int? Cost { get; set; }
}
}

View File

@ -1,8 +0,0 @@
namespace LibraryContracts.BindingModels
{
public class GenreBindingModel
{
public int? Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -1,12 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.ViewModels;
namespace LibraryContracts.BusinessLogicsContracts
{
public interface IBookLogic
{
List<BookViewModel> Read(BookBindingModel model);
void CreateOrUpdate(BookBindingModel model);
void Delete(BookBindingModel model);
}
}

View File

@ -1,12 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.ViewModels;
namespace LibraryContracts.BusinessLogicsContracts
{
public interface IGenreLogic
{
List<GenreViewModel> Read(GenreBindingModel model);
void CreateOrUpdate(GenreBindingModel model);
void Delete(GenreBindingModel model);
}
}

View File

@ -1,9 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -1,16 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.ViewModels;
namespace LibraryContracts.StorageContracts
{
public interface IBookStorage
{
List<BookViewModel> GetFullList();
List<BookViewModel> GetFilteredList(BookBindingModel model);
BookViewModel GetElement(BookBindingModel model);
void Insert(BookBindingModel model);
void Update(BookBindingModel model);
void Delete(BookBindingModel model);
}
}

View File

@ -1,16 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.ViewModels;
namespace LibraryContracts.StorageContracts
{
public interface IGenreStorage
{
List<GenreViewModel> GetFullList();
List<GenreViewModel> GetFilteredList(GenreBindingModel model);
GenreViewModel GetElement(GenreBindingModel model);
void Insert(GenreBindingModel model);
void Update(GenreBindingModel model);
void Delete(GenreBindingModel model);
}
}

View File

@ -1,37 +0,0 @@
using System.ComponentModel;
namespace LibraryContracts.ViewModels
{
public class BookViewModel
{
public int? Id { get; set; }
[DisplayName("Название")]
public string Title { get; set; }
[DisplayName("Описание")]
public string Description { get; set; }
[DisplayName("Жанр")]
public string Genre { get; set; }
[DisplayName("Стоимость")]
public int? Cost { get; set; }
public string CostStr
{
set
{
if (Cost == 0) CostStr = "Бесплатная";
else if (Cost == null) CostStr = "Не указано";
else CostStr = value;
}
get
{
if (Cost == 0) return "Бесплатная";
else if (Cost == null) return "Не указано";
else return Cost.ToString();
}
}
}
}

View File

@ -1,9 +0,0 @@
namespace LibraryContracts.ViewModels
{
public class GenreViewModel
{
public int? Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -1,120 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.StorageContracts;
using LibraryContracts.ViewModels;
using LibraryDatabaseImplement.Models;
namespace LibraryDatabaseImplement.Implements
{
public class BookStorage : IBookStorage
{
public List<BookViewModel> GetFullList()
{
using (var context = new LibraryDatabase())
{
return context.Books
.ToList()
.Select(CreateModel)
.ToList();
}
}
public List<BookViewModel> GetFilteredList(BookBindingModel model)
{
var context = new LibraryDatabase();
return context.Books
.Where(book => book.Title.Contains(model.Title) && book.Genre.Contains(model.Genre))
.ToList()
.Select(CreateModel)
.ToList();
}
public BookViewModel GetElement(BookBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new LibraryDatabase();
var book = context.Books
.ToList()
.FirstOrDefault(rec => rec.Title == model.Title || rec.Id == model.Id);
return book != null ? CreateModel(book) : null;
}
public void Insert(BookBindingModel model)
{
var context = new LibraryDatabase();
var transaction = context.Database.BeginTransaction();
try
{
context.Books.Add(CreateModel(model, new Book()));
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Update(BookBindingModel model)
{
var context = new LibraryDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var book = context.Books.FirstOrDefault(rec => rec.Id == model.Id);
if (book == null)
{
throw new Exception("Книга не найдена");
}
CreateModel(model, book);
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Delete(BookBindingModel model)
{
var context = new LibraryDatabase();
var book = context.Books.FirstOrDefault(rec => rec.Id == model.Id);
if (book != null)
{
context.Books.Remove(book);
context.SaveChanges();
}
else
{
throw new Exception("Книга не найдена");
}
}
private static Book CreateModel(BookBindingModel model, Book book)
{
book.Title = model.Title;
book.Description = model.Description;
book.Genre = model.Genre;
book.Cost = model.Cost;
return book;
}
private BookViewModel CreateModel(Book book)
{
return new BookViewModel
{
Id = book.Id,
Title = book.Title,
Description = book.Description,
Genre = book.Genre,
Cost = book.Cost
};
}
}
}

View File

@ -1,121 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.StorageContracts;
using LibraryContracts.ViewModels;
using LibraryDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibraryDatabaseImplement.Implements
{
public class GenreStorage : IGenreStorage
{
public List<GenreViewModel> GetFullList()
{
using var context = new LibraryDatabase();
return context.Genres
.Select(CreateModel)
.ToList();
}
public List<GenreViewModel> GetFilteredList(GenreBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new LibraryDatabase();
return context.Genres
.Where(rec => rec.Name.Contains(model.Name))
.Select(CreateModel)
.ToList();
}
public GenreViewModel GetElement(GenreBindingModel model)
{
if (model == null)
{
return null;
}
using var context = new LibraryDatabase();
var genre = context.Genres
.ToList()
.FirstOrDefault(rec => rec.Id == model.Id || rec.Name == model.Name);
return genre != null ? CreateModel(genre) : null;
}
public void Insert(GenreBindingModel model)
{
var context = new LibraryDatabase();
var transaction = context.Database.BeginTransaction();
try
{
context.Genres.Add(CreateModel(model, new Genre()));
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Update(GenreBindingModel model)
{
var context = new LibraryDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var genre = context.Genres.FirstOrDefault(rec => rec.Id == model.Id);
if (genre == null)
{
throw new Exception("Жанр не найден");
}
CreateModel(model, genre);
context.SaveChanges();
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
public void Delete(GenreBindingModel model)
{
var context = new LibraryDatabase();
var shape = context.Genres.FirstOrDefault(rec => rec.Id == model.Id);
if (shape != null)
{
context.Genres.Remove(shape);
context.SaveChanges();
}
else
{
throw new Exception("Жанр не найден");
}
}
private static Genre CreateModel(GenreBindingModel model, Genre genre)
{
genre.Name = model.Name;
return genre;
}
private static GenreViewModel CreateModel(Genre genre)
{
return new GenreViewModel
{
Id = genre.Id,
Name = genre.Name
};
}
}
}

View File

@ -1,27 +0,0 @@
using LibraryDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace LibraryDatabaseImplement
{
public class LibraryDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=LibraryDatabase;Integrated Security=True;MultipleActiveResultSets=True; TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Book>().Property(m => m.Cost).IsRequired(false);
base.OnModelCreating(modelBuilder);
}
public virtual DbSet<Book> Books { set; get; }
public virtual DbSet<Genre> Genres { set; get; }
}
}

View File

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibraryContracts\LibraryContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -1,79 +0,0 @@
// <auto-generated />
using System;
using LibraryDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace LibraryDatabaseImplement.Migrations
{
[DbContext(typeof(LibraryDatabase))]
[Migration("20231116200005_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("LibraryDatabaseImplement.Models.Book", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("Cost")
.HasColumnType("int");
b.Property<string>("CostStr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Genre")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Books");
});
modelBuilder.Entity("LibraryDatabaseImplement.Models.Genre", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Genres");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,54 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LibraryDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Books",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
Genre = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<int>(type: "int", nullable: true),
CostStr = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Books", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Genres",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Genres", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Books");
migrationBuilder.DropTable(
name: "Genres");
}
}
}

View File

@ -1,76 +0,0 @@
// <auto-generated />
using System;
using LibraryDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace LibraryDatabaseImplement.Migrations
{
[DbContext(typeof(LibraryDatabase))]
partial class LibraryDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("LibraryDatabaseImplement.Models.Book", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("Cost")
.HasColumnType("int");
b.Property<string>("CostStr")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Genre")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Books");
});
modelBuilder.Entity("LibraryDatabaseImplement.Models.Genre", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Genres");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibraryDatabaseImplement.Models
{
public class Book
{
public int Id { get; set; }
[Required]
public string Title { get; set; }
[Required]
public string Description { get; set; }
[Required]
public string Genre { get; set; }
[Required]
public int? Cost { get; set; }
public string CostStr
{
set { }
get
{
if (Cost == 0) return "Бесплатная";
else if (Cost == null) return "Не указано";
else return Cost.ToString();
}
}
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibraryDatabaseImplement.Models
{
public class Genre
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
}
}

View File

@ -1,169 +0,0 @@
using KOP_Labs;
namespace LibraryView
{
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()
{
this.label1 = new System.Windows.Forms.Label();
this.MeComboBoxGenre = new CustomComponents.DropDownList();
this.textBoxTitle = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBoxDescription = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBoxCost = new CustomComponents.ZhelovanovVisualComponents.TextBoxComponent();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonClose = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 21);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(121, 20);
this.label1.TabIndex = 0;
this.label1.Text = "Название книги";
//
// romanovaComboBoxGenre
//
this.MeComboBoxGenre.Location = new System.Drawing.Point(-3, 240);
this.MeComboBoxGenre.Name = "romanovaComboBoxGenre";
this.MeComboBoxGenre.Selected = "";
this.MeComboBoxGenre.Size = new System.Drawing.Size(259, 116);
this.MeComboBoxGenre.TabIndex = 1;
//
// textBoxTitle
//
this.textBoxTitle.Location = new System.Drawing.Point(22, 44);
this.textBoxTitle.Name = "textBoxTitle";
this.textBoxTitle.Size = new System.Drawing.Size(196, 27);
this.textBoxTitle.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.SystemColors.Control;
this.label2.Location = new System.Drawing.Point(20, 91);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(123, 20);
this.label2.TabIndex = 3;
this.label2.Text = "Описание книги";
//
// textBoxDescription
//
this.textBoxDescription.Location = new System.Drawing.Point(22, 114);
this.textBoxDescription.Multiline = true;
this.textBoxDescription.Name = "textBoxDescription";
this.textBoxDescription.Size = new System.Drawing.Size(290, 110);
this.textBoxDescription.TabIndex = 4;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(22, 240);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 20);
this.label3.TabIndex = 5;
this.label3.Text = "Жанр";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(22, 310);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(83, 20);
this.label4.TabIndex = 6;
this.label4.Text = "Стоимость";
//
// textBoxCost
//
this.textBoxCost.Location = new System.Drawing.Point(20, 333);
this.textBoxCost.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
this.textBoxCost.Name = "textBoxCost";
this.textBoxCost.Size = new System.Drawing.Size(168, 84);
this.textBoxCost.TabIndex = 7;
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(49, 435);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(94, 29);
this.buttonSave.TabIndex = 8;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonClose
//
this.buttonClose.Location = new System.Drawing.Point(162, 435);
this.buttonClose.Name = "buttonClose";
this.buttonClose.Size = new System.Drawing.Size(94, 29);
this.buttonClose.TabIndex = 9;
this.buttonClose.Text = "Отменить";
this.buttonClose.UseVisualStyleBackColor = true;
this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
//
// FormBook
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(342, 477);
this.Controls.Add(this.buttonClose);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBoxDescription);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBoxTitle);
this.Controls.Add(this.MeComboBoxGenre);
this.Controls.Add(this.label1);
this.Name = "FormBook";
this.Text = "Книги";
this.Load += new System.EventHandler(this.FormBook_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label label1;
private CustomComponents.DropDownList MeComboBoxGenre;
private TextBox textBoxTitle;
private Label label2;
private TextBox textBoxDescription;
private Label label3;
private Label label4;
private CustomComponents.ZhelovanovVisualComponents.TextBoxComponent textBoxCost;
private Button buttonSave;
private Button buttonClose;
}
}

View File

@ -1,128 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.BusinessLogicsContracts;
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 LibraryView
{
public partial class FormBook : Form
{
private readonly IBookLogic _bookLogic;
private readonly IGenreLogic _genreLogic;
public int Id { set { id = value; } }
private int? id;
public FormBook(IBookLogic bookLogic, IGenreLogic genreLogic)
{
_bookLogic = bookLogic;
_genreLogic = genreLogic;
InitializeComponent();
LoadGenries();
}
private void LoadGenries()
{
var genries = _genreLogic.Read(null);
foreach (var genre in genries)
{
MeComboBoxGenre.AddingToList(genre.Name);
}
}
private void FormBook_Load(object sender, EventArgs e)
{
if (id.HasValue)
{
try
{
var view = _bookLogic.Read(new BookBindingModel { Id = id })?[0];
if (view != null)
{
if (view.CostStr == "Не указано")
{
textBoxTitle.Text = view.Title;
textBoxDescription.Text = view.Description;
MeComboBoxGenre.Selected = view.Genre;
textBoxCost.Value = null;
}
else
{
textBoxTitle.Text = view.Title;
textBoxDescription.Text = view.Description;
MeComboBoxGenre.Selected = view.Genre;
textBoxCost.Value = view.Cost;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxTitle.Text))
{
MessageBox.Show("Заполните название книга", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxDescription.Text))
{
MessageBox.Show("Заполните описание книги", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(MeComboBoxGenre.Selected.ToString()))
{
MessageBox.Show("Выберите жанр книги", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
int? cost = null;
if (textBoxCost.Value != null)
{
try
{
cost = Convert.ToInt32(textBoxCost.Value);
}
catch
{
MessageBox.Show("Стоимость должна быть целым числом", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
try
{
_bookLogic.CreateOrUpdate(new BookBindingModel
{
Id = id,
Title = textBoxTitle.Text,
Description = textBoxDescription.Text,
Genre = MeComboBoxGenre.Selected.ToString(),
Cost = cost
});
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonClose_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,60 +0,0 @@
<root>
<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

@ -1,95 +0,0 @@
namespace LibraryView
{
partial class FormMain
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.sevaTreeView = new ComponentsLibrary.BasharinVisualComponents.SevaTreeView();
this.romanovaExcelDocument = new ComponentsLibrary.MyNotVisualComponents.RomanovaExcelDocument(this.components);
this.diagramTopdf1 = new ComponentsLibrary.BasharinNotVisualComponents.DiagramToPDF(this.components);
this.componentDocumentWithTableMultiHeaderWord = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderWord(this.components);
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(694, 28);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.справочникиToolStripMenuItem.Text = "Справочники";
//
// sevaTreeView
//
this.sevaTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
this.sevaTreeView.Location = new System.Drawing.Point(0, 28);
this.sevaTreeView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.sevaTreeView.Name = "sevaTreeView";
this.sevaTreeView.SelectedNodeIndex = 0;
this.sevaTreeView.Size = new System.Drawing.Size(694, 354);
this.sevaTreeView.TabIndex = 1;
this.sevaTreeView.Load += new System.EventHandler(this.treeViewControl_Load);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(694, 382);
this.Controls.Add(this.sevaTreeView);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMain";
this.Text = "Главная форма";
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private CustomComponents.BasharinVisualComponents.SevaTreeView sevaTreeView;
private ComponentsLibrary.MyNotVisualComponents.RomanovaExcelDocument romanovaExcelDocument;
private ComponentsLibrary.BasharinNotVisualComponents.DiagramToPDF diagramTopdf1;
private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderWord componentDocumentWithTableMultiHeaderWord;
}
}

View File

@ -1,344 +0,0 @@
//using KOP_Labs.Classes;
using KOP_Labs.NonVisualComponents;
using LibraryContracts.BindingModels;
using LibraryContracts.BusinessLogicsContracts;
using LibraryDatabaseImplement.Models;
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Windows.Forms;
using Unity;
using CustomComponents.ZhelovanovNonVisualComponents;
using CustomComponents;
namespace LibraryView
{
public partial class FormMain : Form
{
private ContextMenuStrip contextMenu = new ContextMenuStrip();
private readonly IBookLogic _bookLogic;
private readonly IGenreLogic _genreLogic;
public FormMain(IBookLogic bookLogic, IGenreLogic genreLogic)
{
InitializeComponent();
_bookLogic = bookLogic;
_genreLogic = genreLogic;
List<string> hierarhy = new List<string>();
hierarhy.Add("Genre");
hierarhy.Add("CostStr");
hierarhy.Add("Id");
hierarhy.Add("Title");
sevaTreeView.SetHierarhy(hierarhy);
// создаем элементы меню
ToolStripMenuItem addMenuGenre = new ToolStripMenuItem("Справочник");
ToolStripMenuItem addMenuItem = new ToolStripMenuItem("Добавить книгу");
ToolStripMenuItem updateMenuItem = new ToolStripMenuItem("Изменить книгу");
ToolStripMenuItem deleteMenuItem = new ToolStripMenuItem("Удалить книгу");
ToolStripMenuItem simpleDocMenuItem = new ToolStripMenuItem("Простой документ");
ToolStripMenuItem tableMenuItem = new ToolStripMenuItem("Таблица");
ToolStripMenuItem diagramMenuItem = new ToolStripMenuItem("Диаграмма");
// добавляем элементы в меню
contextMenu.Items.AddRange(new[] { addMenuGenre, addMenuItem, updateMenuItem, deleteMenuItem, simpleDocMenuItem, tableMenuItem, diagramMenuItem });
// ассоциируем контекстное меню с узлом дерева
sevaTreeView.ContextMenuStrip = contextMenu;
// устанавливаем обработчики событий для меню
addMenuGenre.Click += addGenreItem_Click;
addMenuItem.Click += addMenuItem_Click;
updateMenuItem.Click += updateMenuItem_Click;
deleteMenuItem.Click += deleteMenuItem_Click;
simpleDocMenuItem.Click += simpleDocMenuItem_Click;
tableMenuItem.Click += tableMenuItem_Click;
diagramMenuItem.Click += diagramDocMenuItem_Click;
}
private void treeViewControl_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
sevaTreeView.Clear();
var books = _bookLogic.Read(null);
if (books != null)
{
foreach (var book in books)
{
if (book != null)
{
sevaTreeView.Add(book);
}
}
}
}
void addMenuItem_Click(object sender, EventArgs e)
{
var form = Program.Container.Resolve<FormBook>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
void addGenreItem_Click(object sender, EventArgs e)
{
var form = Program.Container.Resolve<FormManual>();
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void updateMenuItem_Click(object sender, EventArgs e)
{
var form = Program.Container.Resolve<FormBook>();
form.Id = Convert.ToInt32(sevaTreeView.GetSelectedValue<Book>().Id);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
private void deleteMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(sevaTreeView.GetSelectedValue<Book>().Id);
try
{
_bookLogic.Delete(new BookBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
private void simpleDocMenuItem_Click(object sender, EventArgs e)
{
CreateExcelSimpleDoc();
}
private void tableMenuItem_Click(object sender, EventArgs e)
{
CreateWordTable();
}
private void diagramDocMenuItem_Click(object sender, EventArgs e)
{
CreateWordDiagram();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.A))
{
addMenuItem_Click(null, null);
return true;
}
if (keyData == (Keys.Control | Keys.U))
{
updateMenuItem_Click(null, null);
return true;
}
if (keyData == (Keys.Control | Keys.D))
{
deleteMenuItem_Click(null, null);
return true;
}
if (keyData == (Keys.Control | Keys.S))
{
CreateExcelSimpleDoc();
return true;
}
if (keyData == (Keys.Control | Keys.T))
{
CreateWordTable();
return true;
}
if (keyData == (Keys.Control | Keys.C))
{
CreateWordDiagram();
return true;
}
if (keyData == (Keys.Control | Keys.G))
{
addGenreItem_Click(null, null);
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
private void CreateExcelSimpleDoc()
{
string dataSet = "";
var products = _bookLogic.Read(null);
if (products != null)
{
foreach (var product in products)
{
if (product.Cost == 0)
{
dataSet += product.Title + " " + product.Description + ";";
}
}
string[] data = dataSet.Split(';');
var sfd = new SaveFileDialog();
sfd.FileName = "D:\\Papka\\KOP\\simpleDocProducts.xls";
sfd.Filter = "Excel files (*.xlsx)|*.xlsx";
if (sfd.ShowDialog() == DialogResult.OK)
{
if (data != null)
{
bigTextComponent.CreateExcel(sfd.FileName, "Книги", data);
MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Файл не был создан", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void CreateWordDiagram()
{
MyHistogramm histogram;
List<DataHistogramm> data = new List<DataHistogramm>();
var books = _bookLogic.Read(null);
var genries = _genreLogic.Read(null);
if (books != null && genries != null)
{
foreach (var genre in genries)
{
int count = 0;
foreach (var book in books)
{
if (book.Cost == 0 && book.Genre.Equals(genre.Name))
{
count++;
}
}
new DataHistogramm(genre.Name, count);
}
var sfd = new SaveFileDialog();
sfd.FileName = "DiagramBook.pdf";
sfd.Filter = "Pdf files (*.pdf)|*.pdf";
if (sfd.ShowDialog() == DialogResult.OK)
{
histogram = new(sfd.FileName, "Бесплатные книги", "Сколько бесплатных книг какого жанра", EnumLegends.Right, data);
wordHistogramm1.CreateHistogramm(histogram);
MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void CreateWordTable()
{
var sfd = new SaveFileDialog();
sfd.FileName = "WordBooks.docx";
sfd.Filter = "Word files (*.docx)|*.docx";
var booksDB = _bookLogic.Read(null);
List<Book> books = new List<Book>();
foreach (var book in booksDB)
{
Book prod = new Book
{
Id = (int)book.Id,
Title = book.Title,
Description = book.Description,
Genre = book.Genre,
Cost = book.Cost
};
books.Add(prod);
}
/*if (sfd.ShowDialog() == DialogResult.OK)
{
componentDocumentWithTableMultiHeaderWord.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig<Book>
{
FilePath = sfd.FileName,
Header = "Информация по всем книгам",
ColumnsRowsWidth = new List<(int, int)> { (5, 5), (10, 5), (10, 0), (5, 0), (7, 0) },
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
{
(0, 0, "Id", "Id"),
(1, 0, "Название", "Title"),
(2, 0, "Описание", "Description"),
(3, 0, "Категория", "Genre"),
(4, 0, "Стоимость книг", "CostStr")
},
Data = books
});
MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}*/
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
string title = "Информация по всем книгам";
string[,] row1 = {
{ "Id", "Id" }
};
string[,] row2 = {
{ "Название", "Title" }
};
string[,] row3 = {
{ "Описание", "Description" }
};
string[,] row4 = {
{ "Категория", "Genre" }
};
string[,] row5 = {
{ "Стоимость книг", "CostStr" }
};
MyTable table = new MyTable(sfd.FileName, title, new List<string[,]> { row1, row2, row3, row4, row5 });
wordTableComponent1.CreateDoc(table);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
public List<int> getColumnsWidth(int count, int width)
{
List<int> list = new List<int>();
for (int i = 0; i < count; i++)
{
list.Add(width);
}
return list;
}
}
}

View File

@ -1,72 +0,0 @@
<root>
<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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="romanovaExcelDocument.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>144, 17</value>
</metadata>
<metadata name="diagramTopdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>370, 17</value>
</metadata>
<metadata name="componentDocumentWithTableMultiHeaderWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>527, 17</value>
</metadata>
</root>

View File

@ -1,85 +0,0 @@
namespace LibraryView
{
partial class FormManual
{
/// <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()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.NameGenre = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Id,
this.NameGenre});
this.dataGridView.Location = new System.Drawing.Point(1, 1);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(485, 330);
this.dataGridView.TabIndex = 0;
//
// Id
//
this.Id.HeaderText = "Id";
this.Id.MinimumWidth = 6;
this.Id.Name = "Id";
this.Id.Visible = false;
this.Id.Width = 125;
//
// NameGenre
//
this.NameGenre.HeaderText = "Жанр";
this.NameGenre.MinimumWidth = 6;
this.NameGenre.Name = "NameGenre";
this.NameGenre.Width = 200;
//
// FormManual
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(485, 343);
this.Controls.Add(this.dataGridView);
this.Name = "FormManual";
this.Text = "Справочник жанров";
this.Load += new System.EventHandler(this.FormManual_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn Id;
private DataGridViewTextBoxColumn NameGenre;
}
}

View File

@ -1,113 +0,0 @@
using LibraryContracts.BindingModels;
using LibraryContracts.BusinessLogicsContracts;
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 LibraryView
{
public partial class FormManual : Form
{
private readonly IGenreLogic _genreLogic;
public FormManual(IGenreLogic genreLogic)
{
_genreLogic = genreLogic;
InitializeComponent();
}
private void FormManual_Load(object sender, EventArgs e)
{
LoadData();
dataGridView.CellEndEdit += CellEndEdit;
}
private void LoadData()
{
var genries = _genreLogic.Read(null);
if (genries != null)
{
dataGridView.Rows.Clear();
foreach (var genre in genries)
{
dataGridView.Rows.Add(genre.Id, genre.Name);
}
}
}
private void CellEndEdit(object sender, EventArgs e)
{
if (dataGridView.CurrentCell.Value != null)
{
if (dataGridView.CurrentRow.Cells[0].Value == null)
{
_genreLogic.CreateOrUpdate(new GenreBindingModel
{
Name = dataGridView.CurrentCell.Value.ToString()
});
}
else
{
_genreLogic.CreateOrUpdate(new GenreBindingModel
{
Id = (int)dataGridView.CurrentRow.Cells[0].Value,
Name = dataGridView.CurrentCell.Value.ToString()
});
}
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
DataGridViewRow row = new DataGridViewRow();
if (keyData == (Keys.Insert))
{
DataGridViewCell cell = dataGridView.Rows[dataGridView.NewRowIndex].Cells[1];
dataGridView.CurrentCell = cell;
dataGridView.BeginEdit(true);
return true;
}
if (keyData == (Keys.Enter))
{
dataGridView.EndEdit();
LoadData();
}
if (keyData == (Keys.Delete))
{
if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int? id = null;
try
{
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
}
catch
{
MessageBox.Show("Чтобы удалить запись, нажмите на пустую ячейку слева от удаляемой записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (id != null)
{
try
{
_genreLogic.Delete(new GenreBindingModel { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
LoadData();
}
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}

View File

@ -1,66 +0,0 @@
<root>
<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="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NameGenre.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -33,9 +33,6 @@
buttonCreateExDoc = new Button(); buttonCreateExDoc = new Button();
buttonCreateTable = new Button(); buttonCreateTable = new Button();
buttonCreateDiagram = new Button(); buttonCreateDiagram = new Button();
pdfImages1 = new ViewComponents.NotVisualComponents.PdfImages(components);
pdfTable1 = new ViewComponents.NotVisualComponents.PdfTable(components);
pieChartpdf1 = new ViewComponents.NotVisualComponents.PieChartPDF(components);
SuspendLayout(); SuspendLayout();
// //
// buttonCreateExDoc // buttonCreateExDoc
@ -88,8 +85,5 @@
private Button buttonCreateExDoc; private Button buttonCreateExDoc;
private Button buttonCreateTable; private Button buttonCreateTable;
private Button buttonCreateDiagram; private Button buttonCreateDiagram;
private ViewComponents.NotVisualComponents.PdfImages pdfImages1;
private ViewComponents.NotVisualComponents.PdfTable pdfTable1;
private ViewComponents.NotVisualComponents.PieChartPDF pieChartpdf1;
} }
} }

View File

@ -1,5 +1,4 @@
using CustomComponents; using CustomComponents;
using CustomComponents.MyNonVisualComponents;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
namespace LibraryView namespace LibraryView

View File

@ -60,13 +60,4 @@
<metadata name="bigTextComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="bigTextComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="pdfImages1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>209, 17</value>
</metadata>
<metadata name="pdfTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>342, 17</value>
</metadata>
<metadata name="pieChartpdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>463, 17</value>
</metadata>
</root> </root>

View File

@ -10,19 +10,10 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Aspose.Cells" Version="23.9.0" /> <PackageReference Include="Aspose.Cells" Version="23.9.0" />
<PackageReference Include="KOP_Labs" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CustomComponents\CustomComponents.csproj" /> <ProjectReference Include="..\CustomComponents\CustomComponents.csproj" />
<ProjectReference Include="..\LibraryBusinessLogic\LibraryBusinessLogic.csproj" />
<ProjectReference Include="..\LibraryContracts\LibraryContracts.csproj" />
<ProjectReference Include="..\LibraryDatabaseImplement\LibraryDatabaseImplement.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,26 +1,7 @@
using LibraryBusinessLogic.BusinessLogics;
using LibraryContracts.BusinessLogicsContracts;
using LibraryContracts.StorageContracts;
using LibraryDatabaseImplement.Implements;
using Unity;
using Unity.Lifetime;
namespace LibraryView namespace LibraryView
{ {
public static class Program internal static class Program
{ {
private static IUnityContainer container = null;
public static IUnityContainer Container
{
get
{
if (container == null)
{
container = BuildUnityContainer();
}
return container;
}
}
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
@ -29,19 +10,8 @@ namespace LibraryView
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
Application.EnableVisualStyles(); ApplicationConfiguration.Initialize();
Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormSecond());
Application.Run(Container.Resolve<FormMain>());
}
private static IUnityContainer BuildUnityContainer()
{
var currentContainer = new UnityContainer();
currentContainer.RegisterType<IBookStorage, BookStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IBookLogic, BookLogic>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IGenreStorage, GenreStorage>(new HierarchicalLifetimeManager());
currentContainer.RegisterType<IGenreLogic, GenreLogic>(new HierarchicalLifetimeManager());
return currentContainer;
} }
} }
} }