This commit is contained in:
MaxKarme 2023-03-28 10:45:31 +04:00
parent f41a3493b1
commit f396af1eb9
17 changed files with 313 additions and 50 deletions

View File

@ -172,8 +172,8 @@
//
this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(269, 26);
this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
this.списокКомпонентовToolStripMenuItem.Text = "Список пицц";
this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.PizzasToolStripMenuItem_Click);
//
// компонентовПоПиццамToolStripMenuItem
//

View File

@ -153,9 +153,7 @@ namespace Pizzeria
LoadData();
}
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs
e)
private void PizzasToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
@ -164,8 +162,7 @@ e)
{
FileName = dialog.FileName
});
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK,
MessageBoxIcon.Information);
MessageBox.Show("Âûïîëíåíî", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void ComponentPizzasToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -94,14 +94,14 @@
this.panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel.Location = new System.Drawing.Point(0, 46);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(843, 409);
this.panel.Size = new System.Drawing.Size(937, 409);
this.panel.TabIndex = 7;
//
// FormReportOrders
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(842, 470);
this.ClientSize = new System.Drawing.Size(942, 470);
this.Controls.Add(this.panel);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);

View File

@ -23,8 +23,8 @@ namespace Pizzeria
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Pizzas)
dataGridView.Rows.Add(new object[] { elem.PizzaName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

@ -26,6 +26,21 @@
<ProjectReference Include="..\PizzeriaShopFileImplement\PizzeriaFileImplement.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

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

View File

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

View File

@ -29,6 +29,10 @@
<DataField>PizzaName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="OrderStatus">
<DataField>OrderStatus</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Sum">
<DataField>Sum</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
@ -116,16 +120,19 @@
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>2.5cm</Width>
<Width>2.0889cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3.21438cm</Width>
<Width>2.80328cm</Width>
</TablixColumn>
<TablixColumn>
<Width>8.23317cm</Width>
<Width>7.82207cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
<Width>2.0889cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.0889cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
@ -228,6 +235,38 @@
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Order Status</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox7">
@ -357,6 +396,36 @@
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="OrderStatus">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!OrderStatus.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>OrderStatus</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Sum">
@ -397,6 +466,7 @@
<TablixMember />
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
@ -413,7 +483,7 @@
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.2cm</Height>
<Width>16.44755cm</Width>
<Width>16.89205cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
@ -491,7 +561,7 @@
<Height>6.27908cm</Height>
<Style />
</Body>
<Width>17.4445cm</Width>
<Width>18.27233cm</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>

View File

@ -30,11 +30,11 @@ namespace PizzeriaBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.PizzaName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var pizza in pc.Pizzas)
foreach (var pizza in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{

View File

@ -18,10 +18,10 @@ namespace PizzeriaBusinessLogic.OfficePackage
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
CreateTable(new List<string> { "2cm", "3cm", "5cm", "4cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" },
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -29,7 +29,7 @@ namespace PizzeriaBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PizzaName, order.Sum.ToString() },
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PizzaName, order.OrderStatus, order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -16,11 +16,14 @@ namespace PizzeriaBusinessLogic.OfficePackage
JustificationType = WordJustificationType.Center
}
});
foreach (var component in info.Components)
foreach (var component in info.Pizzas)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) },
Texts = new List<(string, WordTextProperties)> {
(component.PizzaName, new WordTextProperties { Size = "24", Bold = true }),
(" " + component.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -5,6 +5,6 @@ namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new();
public List<PizzaViewModel> Pizzas { get; set; } = new();
}
}

View File

@ -53,8 +53,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
var properties = new ParagraphProperties();
properties.AppendChild(new Justification()
{
Val =
GetJustificationValues(paragraphProperties.JustificationType)
Val = GetJustificationValues(paragraphProperties.JustificationType)
});
properties.AppendChild(new SpacingBetweenLines
{
@ -66,8 +65,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
{
paragraphMarkRunProperties.AppendChild(new FontSize
{
Val =
paragraphProperties.Size
Val = paragraphProperties.Size
});
}
properties.AppendChild(paragraphMarkRunProperties);
@ -75,8 +73,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
}
protected override void CreateWord(WordInfo info)
{
_wordDocument = WordprocessingDocument.Create(info.FileName,
WordprocessingDocumentType.Document);
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
@ -103,8 +100,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
docRun.AppendChild(new Text
{
Text = run.Item1,
Space =
SpaceProcessingModeValues.Preserve
Space = SpaceProcessingModeValues.Preserve
});
docParagraph.AppendChild(docRun);
}

View File

@ -34,29 +34,25 @@ namespace PizzeriaBusinessLogic
/// <returns></returns>
public List<ReportPizzaComponentViewModel> GetPizzaComponent()
{
var components = _componentStorage.GetFullList();
var pizzas = _pizzaStorage.GetFullList();
var list = new List<ReportPizzaComponentViewModel>();
foreach (var component in components)
foreach(var pizza in pizzas)
{
var record = new ReportPizzaComponentViewModel
{
ComponentName = component.ComponentName,
Pizzas = new List<Tuple<string, int>>(),
TotalCount = 0
PizzaName = pizza.PizzaName,
TotalCount = 0,
Components = new List<(string componentName, int count)>()
};
foreach (var pizza in pizzas)
foreach(var component in pizza.PizzaComponents)
{
if (pizza.PizzaComponents.ContainsKey(component.Id))
{
record.Pizzas.Add(new Tuple<string,
int>(pizza.PizzaName, pizza.PizzaComponents[component.Id].Item2));
record.TotalCount +=
pizza.PizzaComponents[component.Id].Item2;
}
record.Components.Add((component.Value.Item1.ComponentName, component.Value.Item2 ));
record.TotalCount += component.Value.Item2;
}
list.Add(record);
}
return list;
}
/// <summary>
@ -76,6 +72,7 @@ namespace PizzeriaBusinessLogic
Id = x.Id,
DateCreate = x.DateCreate,
PizzaName = x.PizzaName,
OrderStatus = x.Status.ToString(),
Sum = x.Sum
})
.ToList();
@ -89,8 +86,8 @@ namespace PizzeriaBusinessLogic
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список компонент",
Components = _componentStorage.GetFullList()
Title = "Список пицц",
Pizzas = _pizzaStorage.GetFullList()
});
}
/// <summary>

View File

@ -5,6 +5,7 @@
public int Id { get; set; }
public DateTime DateCreate { get; set; }
public string PizzaName { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty;
public double Sum { get; set; }
}
}

View File

@ -2,8 +2,8 @@
{
public class ReportPizzaComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string PizzaName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Pizzas { get; set; } = new();
public List<(string componentName, int count)> Components { get; set; } = new();
}
}

View File

@ -22,6 +22,7 @@ namespace PizzeriaDatabaseImplement.Implements
{
using var context = new PizzeriaDatabase();
return context.Orders
.Include(x => x.Pizza)
.Where(x => (
(!model.Id.HasValue || x.Id == model.Id) &&
(!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) &&