ПИбд-22 Боровков М В 5 лабораторная работа #6

Closed
bekodeg wants to merge 44 commits from labWork5 into labWork4
4 changed files with 41 additions and 20 deletions
Showing only changes of commit 4dc2d7a83f - Show all commits

View File

@ -35,6 +35,7 @@
dateTimePickerFrom = new DateTimePicker(); dateTimePickerFrom = new DateTimePicker();
buttonToPdf = new Button(); buttonToPdf = new Button();
buttonMake = new Button(); buttonMake = new Button();
panelBody = new Panel();
panel.SuspendLayout(); panel.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@ -104,11 +105,19 @@
buttonMake.UseVisualStyleBackColor = true; buttonMake.UseVisualStyleBackColor = true;
buttonMake.Click += buttonMake_Click; buttonMake.Click += buttonMake_Click;
// //
// panelBody
//
panelBody.Location = new Point(0, 57);
panelBody.Name = "panelBody";
panelBody.Size = new Size(800, 393);
panelBody.TabIndex = 1;
//
// FormReportOrders // FormReportOrders
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(panelBody);
Controls.Add(panel); Controls.Add(panel);
Name = "FormReportOrders"; Name = "FormReportOrders";
Text = "FormReportOrders"; Text = "FormReportOrders";
@ -126,5 +135,6 @@
private DateTimePicker dateTimePickerFrom; private DateTimePicker dateTimePickerFrom;
private Label label1; private Label label1;
private Label label2; private Label label2;
private Panel panelBody;
} }
} }

View File

@ -20,10 +20,9 @@ namespace SushiBar.Forms
{ {
Dock = DockStyle.Fill Dock = DockStyle.Fill
}; };
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); reportViewer.LocalReport.LoadReportDefinition(
Controls.Clear(); new FileStream("Report/ReportOrders.rdlc", FileMode.Open));
Controls.Add(reportViewer); panelBody.Controls.Add(reportViewer);
Controls.Add(panel);
} }
private void ButtonMake_Click(object sender, EventArgs e) private void ButtonMake_Click(object sender, EventArgs e)
{ {
@ -43,10 +42,15 @@ namespace SushiBar.Forms
var source = new ReportDataSource("DataSetOrders", dataSource); var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source); reportViewer.LocalReport.DataSources.Add(source);
var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c{dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; var parameters = new[] {
new ReportParameter("ReportParameterPeriod",
$"c{dateTimePickerFrom.Value.ToShortDateString()} по" +
$" {dateTimePickerTo.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters); reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport(); reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}",
dateTimePickerFrom.Value.ToShortDateString(),
dateTimePickerTo.Value.ToShortDateString());
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -69,6 +73,7 @@ namespace SushiBar.Forms
{ {
try try
{ {
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
_logic.SaveOrdersToPdfFile(new ReportBindingModel _logic.SaveOrdersToPdfFile(new ReportBindingModel
{ {
FileName = dialog.FileName, FileName = dialog.FileName,

View File

@ -26,16 +26,22 @@ namespace SushiBar.Forms
dataGridView.Rows.Clear(); dataGridView.Rows.Clear();
foreach (var elem in dict) foreach (var elem in dict)
{ {
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); dataGridView.Rows.Add(new object[] {
foreach (var listElem in elem.Sushis) elem.SushiName, "", ""
});
foreach (var listElem in elem.Components)
{ {
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); dataGridView.Rows.Add(new object[] {
"", listElem.Item1, listElem.Item2
});
} }
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); dataGridView.Rows.Add(new object[] {
"Итого", "", elem.TotalCount
});
dataGridView.Rows.Add(Array.Empty<object>()); dataGridView.Rows.Add(Array.Empty<object>());
} }
} }
_logger.LogInformation("Загрузка списка изделий по компонентам"); _logger.LogInformation("Загрузка списка суши по компонентам");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -2,7 +2,7 @@
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"> <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh> <AutoRefresh>0</AutoRefresh>
<DataSources> <DataSources>
<DataSource Name="FishFactoryContractsViewModels"> <DataSource Name="SushiBarContractsViewModels">
<ConnectionProperties> <ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider> <DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString> <ConnectString>/* Local Connection */</ConnectString>
@ -13,7 +13,7 @@
<DataSets> <DataSets>
<DataSet Name="DataSetOrders"> <DataSet Name="DataSetOrders">
<Query> <Query>
<DataSourceName>FishFactoryContractsViewModels</DataSourceName> <DataSourceName>SushiBarContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText> <CommandText>/* Local Query */</CommandText>
</Query> </Query>
<Fields> <Fields>
@ -25,8 +25,8 @@
<DataField>DateCreate</DataField> <DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName> <rd:TypeName>System.DateTime</rd:TypeName>
</Field> </Field>
<Field Name="CannedName"> <Field Name="SushiName">
<DataField>CannedName</DataField> <DataField>SushiName</DataField>
<rd:TypeName>System.String</rd:TypeName> <rd:TypeName>System.String</rd:TypeName>
</Field> </Field>
<Field Name="Sum"> <Field Name="Sum">
@ -35,13 +35,13 @@
</Field> </Field>
<Field Name="OrderStatus"> <Field Name="OrderStatus">
<DataField>OrderStatus</DataField> <DataField>OrderStatus</DataField>
<rd:TypeName>FishFactoryDataModels.OrderStatus</rd:TypeName> <rd:TypeName>SushiBarDataModels.OrderStatus</rd:TypeName>
</Field> </Field>
</Fields> </Fields>
<rd:DataSetInfo> <rd:DataSetInfo>
<rd:DataSetName>FishFactoryContracts.ViewModels</rd:DataSetName> <rd:DataSetName>SushiBarContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportOrderViewModel</rd:TableName> <rd:TableName>ReportOrderViewModel</rd:TableName>
<rd:ObjectDataSourceType>FishFactoryContracts.ViewModels.ReportOrderViewModel, FishFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType> <rd:ObjectDataSourceType>SushiBarContracts.ViewModels.ReportOrderViewModel, SushiBarContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo> </rd:DataSetInfo>
</DataSet> </DataSet>
</DataSets> </DataSets>
@ -368,7 +368,7 @@
</TablixCell> </TablixCell>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="CannedName"> <Textbox Name="SushiName">
<CanGrow>true</CanGrow> <CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether> <KeepTogether>true</KeepTogether>
<Paragraphs> <Paragraphs>
@ -382,7 +382,7 @@
<Style /> <Style />
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<rd:DefaultName>CannedName</rd:DefaultName> <rd:DefaultName>SushiName</rd:DefaultName>
<Style> <Style>
<Border> <Border>
<Color>LightGrey</Color> <Color>LightGrey</Color>