ISEbd-22 Alimova M.S. Lab Work 04 base #5

Closed
malimova wants to merge 20 commits from Lab4_base into Lab3_base
6 changed files with 88 additions and 40 deletions
Showing only changes of commit 80bf9899df - Show all commits

View File

@ -17,6 +17,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage
public void CreateReport(ExcelInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
@ -24,11 +25,13 @@ namespace ConfectioneryBusinessLogic.OfficePackage
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var pc in info.PastryComponents)
{
@ -36,30 +39,32 @@ namespace ConfectioneryBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.PastryName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var product in pc.Pastrys)
foreach (var (Component, Count) in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = product.Item1,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Component,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = product.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
@ -76,6 +81,7 @@ namespace ConfectioneryBusinessLogic.OfficePackage
});
rowIndex++;
}
SaveExcel(info);
}
/// <summary>

View File

@ -32,30 +32,12 @@ namespace ConfectioneryBusinessLogic
/// <returns></returns>
public List<ReportPastryComponentViewModel> GetPastryComponent()
{
var components = _componentStorage.GetFullList();
var products = _pastryStorage.GetFullList();
var list = new List<ReportPastryComponentViewModel>();
foreach (var component in components)
return _pastryStorage.GetFullList().Select(x => new ReportPastryComponentViewModel
{
var record = new ReportPastryComponentViewModel
{
ComponentName = component.ComponentName,
Pastrys = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var product in products)
{
if (product.PastryComponents.ContainsKey(component.Id))
{
record.Pastrys.Add(new Tuple<string,
int>(product.PastryName, product.PastryComponents[component.Id].Item2));
record.TotalCount +=
product.PastryComponents[component.Id].Item2;
}
}
list.Add(record);
}
return list;
PastryName = x.PastryName,
Components = x.PastryComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(),
TotalCount = x.PastryComponents.Select(x => x.Value.Item2).Sum()
}).ToList();
}
/// <summary>
/// Получение списка заказов за определенный период

View File

@ -8,8 +8,8 @@ namespace ConfectioneryContracts.ViewModels
{
public class ReportPastryComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string PastryName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Pastrys { get; set; } = new();
public List<(string Component, int Count)> Components { get; set; } = new();
}
}

View File

@ -44,7 +44,7 @@
dataGridView.BackgroundColor = Color.AliceBlue;
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.BackColor = SystemColors.Control;
dataGridViewCellStyle1.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
dataGridViewCellStyle1.Font = new Font("Segoe UI", 9F);
dataGridViewCellStyle1.ForeColor = SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = SystemColors.HighlightText;
@ -54,7 +54,7 @@
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnPastry, ColumnCount });
dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = SystemColors.Window;
dataGridViewCellStyle2.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
dataGridViewCellStyle2.Font = new Font("Segoe UI", 9F);
dataGridViewCellStyle2.ForeColor = SystemColors.ControlText;
dataGridViewCellStyle2.SelectionBackColor = SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = SystemColors.HighlightText;
@ -64,14 +64,13 @@
dataGridView.Name = "dataGridView";
dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = SystemColors.Control;
dataGridViewCellStyle3.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
dataGridViewCellStyle3.Font = new Font("Segoe UI", 9F);
dataGridViewCellStyle3.ForeColor = SystemColors.WindowText;
dataGridViewCellStyle3.SelectionBackColor = SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True;
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
dataGridView.RowHeadersWidth = 62;
dataGridView.RowTemplate.Height = 33;
dataGridView.Size = new Size(875, 498);
dataGridView.TabIndex = 0;
//
@ -115,6 +114,7 @@
Controls.Add(dataGridView);
Name = "FormReportPastryComponents";
Text = "Компоненты по изделиям";
Load += FormReportPastryComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}

View File

@ -35,8 +35,8 @@ namespace ConfectioneryView
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Pastrys)
dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

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