This commit is contained in:
VictoriaPresnyakova 2023-03-20 22:56:32 +04:00
parent 8bf9fbd296
commit 23be5195d1
12 changed files with 148 additions and 120 deletions

View File

@ -198,7 +198,7 @@ namespace JewelryStore
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel
_reportLogic.SaveJewelsToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});

View File

@ -70,14 +70,14 @@
//
// ColumnComponent
//
this.ColumnComponent.HeaderText = "Компонент";
this.ColumnComponent.HeaderText = "Изделие";
this.ColumnComponent.Name = "ColumnComponent";
this.ColumnComponent.ReadOnly = true;
this.ColumnComponent.Width = 200;
//
// ColumnJewel
//
this.ColumnJewel.HeaderText = "Изделие";
this.ColumnJewel.HeaderText = "Компонент";
this.ColumnJewel.Name = "ColumnJewel";
this.ColumnJewel.ReadOnly = true;
this.ColumnJewel.Width = 200;

View File

@ -36,8 +36,8 @@ namespace JewelryStore
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Jewels)
dataGridView.Rows.Add(new object[] { elem.JewelName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

@ -33,6 +33,10 @@
<DataField>Sum</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="Status">
<DataField>Status</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>JewelryStoreContracts.ViewModels</rd:DataSetName>
@ -40,23 +44,20 @@
<rd:ObjectDataSourceType>JewelryStoreContracts.ViewModels.ReportOrdersViewModel, JewelryStoreContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="ReportParameterPeriod">
<Textbox Name="TextboxTitle">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
<Value>Заказы</Value>
<Style />
</TextRun>
</TextRuns>
<Style>
@ -64,10 +65,8 @@
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top>
<Height>1cm</Height>
<Width>21cm</Width>
<Height>0.6cm</Height>
<Width>16.51cm</Width>
<Style>
<Border>
<Style>None</Style>
@ -79,18 +78,15 @@
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="TextboxTitle">
<Textbox Name="ReportParameterPeriod">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Заказы</Value>
<Style>
<FontSize>16pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style>
@ -98,8 +94,10 @@
</Style>
</Paragraph>
</Paragraphs>
<Height>1cm</Height>
<Width>21cm</Width>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>0.6cm</Top>
<Height>0.6cm</Height>
<Width>16.51cm</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
@ -112,18 +110,21 @@
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<Tablix Name="Tablix">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>2.60583cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3.262cm</Width>
</TablixColumn>
<TablixColumn>
<Width>4.8495cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
<TablixColumn>
<Width>3.21438cm</Width>
</TablixColumn>
<TablixColumn>
<Width>8.23317cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
@ -134,7 +135,7 @@
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox5">
<Textbox Name="TextboxId">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
@ -142,15 +143,12 @@
<TextRuns>
<TextRun>
<Value>Номер</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox5</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
@ -166,7 +164,7 @@
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<Textbox Name="TextboxDateCreate">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
@ -174,15 +172,12 @@
<TextRuns>
<TextRun>
<Value>Дата создания</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
@ -198,7 +193,7 @@
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox3">
<Textbox Name="TextboxJewelName">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
@ -206,15 +201,12 @@
<TextRuns>
<TextRun>
<Value>Изделие</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox3</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
@ -230,7 +222,37 @@
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox7">
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Статус</Value>
<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="TextboxSum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
@ -238,15 +260,12 @@
<TextRuns>
<TextRun>
<Value>Сумма</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
@ -305,9 +324,7 @@
<TextRuns>
<TextRun>
<Value>=Fields!DateCreate.Value</Value>
<Style>
<Format>d</Format>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style />
@ -357,6 +374,36 @@
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Status1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Status.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Status1</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">
@ -385,7 +432,6 @@
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<rd:Selected>true</rd:Selected>
</CellContents>
</TablixCell>
</TablixCells>
@ -398,6 +444,7 @@
<TablixMember />
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
@ -411,18 +458,18 @@
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Top>1.9177cm</Top>
<Left>0.79267cm</Left>
<Height>1.2cm</Height>
<Width>16.44755cm</Width>
<Width>15.71733cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Style>Double</Style>
<Style>None</Style>
</Border>
</Style>
</Tablix>
<Textbox Name="TextboxTotalSum">
<Textbox Name="TextboxResout">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
@ -430,9 +477,7 @@
<TextRuns>
<TextRun>
<Value>Итого:</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style>
@ -440,8 +485,8 @@
</Style>
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>12cm</Left>
<Top>3.46287cm</Top>
<Left>11.51cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>3</ZIndex>
@ -455,7 +500,7 @@
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="SumTotal">
<Textbox Name="Textbox10">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
@ -463,18 +508,15 @@
<TextRuns>
<TextRun>
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
<Style />
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
<Style />
</Paragraph>
</Paragraphs>
<Top>4cm</Top>
<Left>14.5cm</Left>
<rd:DefaultName>Textbox10</rd:DefaultName>
<Top>3.46287cm</Top>
<Left>14.01cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>4</ZIndex>
@ -489,10 +531,10 @@
</Style>
</Textbox>
</ReportItems>
<Height>5.72875cm</Height>
<Height>2in</Height>
<Style />
</Body>
<Width>21cm</Width>
<Width>7.48425in</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
@ -526,5 +568,5 @@
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
<rd:ReportID>0c9e94bc-df40-42bd-a526-01713dd3057f</rd:ReportID>
</Report>

View File

@ -29,6 +29,7 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
_jewelStorage = jewelStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
@ -39,30 +40,12 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
/// <returns></returns>
public List<ReportJewelComponentViewModel> GetJewelComponent()
{
var components = _componentStorage.GetFullList();
var jewels = _jewelStorage.GetFullList();
var list = new List<ReportJewelComponentViewModel>();
foreach (var component in components)
return _jewelStorage.GetFullList().Select(x => new ReportJewelComponentViewModel
{
var record = new ReportJewelComponentViewModel
{
ComponentName = component.ComponentName,
Jewels = new List<Tuple<string, int>>(),
TotalCount = 0
};
foreach (var jewel in jewels)
{
if (jewel.JewelComponents.ContainsKey(component.Id))
{
record.Jewels.Add(new Tuple<string,
int>(jewel.JewelName, jewel.JewelComponents[component.Id].Item2));
record.TotalCount +=
jewel.JewelComponents[component.Id].Item2;
}
}
list.Add(record);
}
return list;
JewelName = x.JewelName,
Components = x.JewelComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(),
TotalCount = x.JewelComponents.Select(x => x.Value.Item2).Sum()
}).ToList();
}
/// <summary>
/// Получение списка заказов за определенный период
@ -82,7 +65,8 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
Id = x.Id,
DateCreate = x.DateCreate,
JewelName = x.JewelName,
Sum = x.Sum
Sum = x.Sum,
Status = x.Status.ToString()
})
.ToList();
}
@ -90,13 +74,13 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model)
public void SaveJewelsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список компонент",
Components = _componentStorage.GetFullList()
Title = "Список изделий",
Jewels = _jewelStorage.GetFullList()
});
}
/// <summary>
@ -108,7 +92,7 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список компонент",
Title = "Список изделий",
JewelComponents = GetJewelComponent()
});
}

View File

@ -36,25 +36,24 @@ namespace JewelryStoreBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.JewelName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var product in pc.Jewels)
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(),
Text = Count.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});

View File

@ -25,10 +25,10 @@ namespace JewelryStoreBusinessLogic.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", "6cm", "3cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма" },
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -37,7 +37,7 @@ namespace JewelryStoreBusinessLogic.OfficePackage
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(),
order.DateCreate.ToShortDateString(), order.JewelName, order.Sum.ToString() },
order.DateCreate.ToShortDateString(), order.JewelName, order.Status.ToString(), order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -26,12 +26,14 @@ WordTextProperties { Bold = true, Size = "24", }) },
JustificationType = WordJustificationType.Center
}
});
foreach (var component in info.Components)
foreach (var jewel in info.Jewels)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {
(component.ComponentName, new WordTextProperties { Size = "24", }) },
(jewel.JewelName, new WordTextProperties { Size = "24", Bold = true}),
("\t"+jewel.Price.ToString(), new WordTextProperties{Size = "24"})
},
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -11,7 +11,7 @@ namespace JewelryStoreBusinessLogic.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<JewelViewModel> Jewels { get; set; } = new();
}
}

View File

@ -25,7 +25,7 @@ namespace JewelryStoreContracts.BusinessLogicsContracts
/// Сохранение компонент в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveComponentsToWordFile(ReportBindingModel model);
void SaveJewelsToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// </summary>

View File

@ -8,8 +8,8 @@ namespace JewelryStoreContracts.ViewModels
{
public class ReportJewelComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string JewelName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Jewels { get; set; } = new();
public List<(string, int)> Components { get; set; } = new();
}
}

View File

@ -12,6 +12,7 @@ namespace JewelryStoreContracts.ViewModels
public DateTime DateCreate { get; set; }
public string JewelName { get; set; } = string.Empty;
public double Sum { get; set; }
public string Status { get; set; } = string.Empty;
}
}