Сдана хард4

This commit is contained in:
Данила Мочалов 2023-03-27 10:09:32 +04:00
parent 4b8f3eae04
commit d2653e9015
6 changed files with 20 additions and 127 deletions

View File

@ -31,10 +31,6 @@
this.panel = new System.Windows.Forms.Panel(); this.panel = new System.Windows.Forms.Panel();
this.buttonCreateToPdf = new System.Windows.Forms.Button(); this.buttonCreateToPdf = new System.Windows.Forms.Button();
this.buttonCreateReport = new System.Windows.Forms.Button(); this.buttonCreateReport = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker();
this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker();
this.panel.SuspendLayout(); this.panel.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -42,10 +38,6 @@
// //
this.panel.Controls.Add(this.buttonCreateToPdf); this.panel.Controls.Add(this.buttonCreateToPdf);
this.panel.Controls.Add(this.buttonCreateReport); this.panel.Controls.Add(this.buttonCreateReport);
this.panel.Controls.Add(this.label2);
this.panel.Controls.Add(this.label1);
this.panel.Controls.Add(this.dateTimePickerEnd);
this.panel.Controls.Add(this.dateTimePickerStart);
this.panel.Dock = System.Windows.Forms.DockStyle.Top; this.panel.Dock = System.Windows.Forms.DockStyle.Top;
this.panel.Location = new System.Drawing.Point(0, 0); this.panel.Location = new System.Drawing.Point(0, 0);
this.panel.Name = "panel"; this.panel.Name = "panel";
@ -72,38 +64,6 @@
this.buttonCreateReport.UseVisualStyleBackColor = true; this.buttonCreateReport.UseVisualStyleBackColor = true;
this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click); this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click);
// //
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(369, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 20);
this.label2.TabIndex = 3;
this.label2.Text = "Конец:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(87, 6);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 20);
this.label1.TabIndex = 2;
this.label1.Text = "Начало:";
//
// dateTimePickerEnd
//
this.dateTimePickerEnd.Location = new System.Drawing.Point(307, 39);
this.dateTimePickerEnd.Name = "dateTimePickerEnd";
this.dateTimePickerEnd.Size = new System.Drawing.Size(187, 27);
this.dateTimePickerEnd.TabIndex = 1;
//
// dateTimePickerStart
//
this.dateTimePickerStart.Location = new System.Drawing.Point(35, 39);
this.dateTimePickerStart.Name = "dateTimePickerStart";
this.dateTimePickerStart.Size = new System.Drawing.Size(187, 27);
this.dateTimePickerStart.TabIndex = 0;
//
// FormReportDateOrders // FormReportDateOrders
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
@ -113,7 +73,6 @@
this.Name = "FormReportDateOrders"; this.Name = "FormReportDateOrders";
this.Text = "Заказы по датам"; this.Text = "Заказы по датам";
this.panel.ResumeLayout(false); this.panel.ResumeLayout(false);
this.panel.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -123,9 +82,5 @@
private Panel panel; private Panel panel;
private Button buttonCreateToPdf; private Button buttonCreateToPdf;
private Button buttonCreateReport; private Button buttonCreateReport;
private Label label2;
private Label label1;
private DateTimePicker dateTimePickerEnd;
private DateTimePicker dateTimePickerStart;
} }
} }

View File

@ -38,25 +38,14 @@ namespace LawFirmView
private void buttonCreateReport_Click(object sender, EventArgs e) private void buttonCreateReport_Click(object sender, EventArgs e)
{ {
if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date)
{
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try try
{ {
var dataSource = _logic.GetDateOrders(new ReportBindingModel var dataSource = _logic.GetDateOrders();
{
DateFrom = dateTimePickerStart.Value,
DateTo = dateTimePickerEnd.Value
});
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 {dateTimePickerStart.Value.ToShortDateString()} по {dateTimePickerEnd.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport(); reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); _logger.LogInformation("Загрузка списка заказов на весь период по датам");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -67,11 +56,6 @@ namespace LawFirmView
private void buttonCreateToPdf_Click(object sender, EventArgs e) private void buttonCreateToPdf_Click(object sender, EventArgs e)
{ {
if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date)
{
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
@ -79,11 +63,9 @@ namespace LawFirmView
{ {
_logic.SaveDateOrdersToPdfFile(new ReportBindingModel _logic.SaveDateOrdersToPdfFile(new ReportBindingModel
{ {
FileName = dialog.FileName, FileName = dialog.FileName
DateFrom = dateTimePickerStart.Value,
DateTo = dateTimePickerEnd.Value
}); });
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); _logger.LogInformation("Сохранение списка заказов на весь период по датам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -26,7 +26,7 @@
<rd:TypeName>System.Decimal</rd:TypeName> <rd:TypeName>System.Decimal</rd:TypeName>
</Field> </Field>
<Field Name="SumOrders"> <Field Name="SumOrders">
<DataField>TotalSumOrders</DataField> <DataField>SumOrders</DataField>
<rd:TypeName>System.Double</rd:TypeName> <rd:TypeName>System.Double</rd:TypeName>
</Field> </Field>
</Fields> </Fields>
@ -41,40 +41,6 @@
<ReportSection> <ReportSection>
<Body> <Body>
<ReportItems> <ReportItems>
<Textbox Name="ReportParameterPeriod">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top>
<Height>1cm</Height>
<Width>21cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="TextboxTitle"> <Textbox Name="TextboxTitle">
<CanGrow>true</CanGrow> <CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether> <KeepTogether>true</KeepTogether>
@ -96,7 +62,6 @@
</Paragraphs> </Paragraphs>
<Height>1cm</Height> <Height>1cm</Height>
<Width>21cm</Width> <Width>21cm</Width>
<ZIndex>1</ZIndex>
<Style> <Style>
<Border> <Border>
<Style>None</Style> <Style>None</Style>
@ -134,7 +99,7 @@
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>Дата создания</Value> <Value>Дата</Value>
<Style> <Style>
<FontWeight>Bold</FontWeight> <FontWeight>Bold</FontWeight>
</Style> </Style>
@ -166,7 +131,7 @@
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>Количество заказов</Value> <Value>Количество</Value>
<Style> <Style>
<FontWeight>Bold</FontWeight> <FontWeight>Bold</FontWeight>
</Style> </Style>
@ -316,7 +281,6 @@
<PaddingBottom>2pt</PaddingBottom> <PaddingBottom>2pt</PaddingBottom>
</Style> </Style>
</Textbox> </Textbox>
<rd:Selected>true</rd:Selected>
</CellContents> </CellContents>
</TablixCell> </TablixCell>
</TablixCells> </TablixCells>
@ -345,7 +309,7 @@
<Left>0.55245cm</Left> <Left>0.55245cm</Left>
<Height>1.2cm</Height> <Height>1.2cm</Height>
<Width>13cm</Width> <Width>13cm</Width>
<ZIndex>2</ZIndex> <ZIndex>1</ZIndex>
<Style> <Style>
<Border> <Border>
<Style>Double</Style> <Style>Double</Style>
@ -374,7 +338,7 @@
<Left>8.55245cm</Left> <Left>8.55245cm</Left>
<Height>0.6cm</Height> <Height>0.6cm</Height>
<Width>2.5cm</Width> <Width>2.5cm</Width>
<ZIndex>3</ZIndex> <ZIndex>2</ZIndex>
<Style> <Style>
<Border> <Border>
<Style>None</Style> <Style>None</Style>
@ -407,7 +371,7 @@
<Left>11.05245cm</Left> <Left>11.05245cm</Left>
<Height>0.6cm</Height> <Height>0.6cm</Height>
<Width>2.5cm</Width> <Width>2.5cm</Width>
<ZIndex>4</ZIndex> <ZIndex>3</ZIndex>
<Style> <Style>
<Border> <Border>
<Style>None</Style> <Style>None</Style>

View File

@ -123,7 +123,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
_saveToExcel.CreateShopReport(new ExcelInfo _saveToExcel.CreateShopReport(new ExcelInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список магазинов с изделиями", Title = "Загруженность магазинов",
ShopDocuments = GetShopDocuments() ShopDocuments = GetShopDocuments()
}); });
} }
@ -140,17 +140,17 @@ namespace LawFirmBusinessLogic.BusinessLogics
Documents = new List<Tuple<string, int>>(), Documents = new List<Tuple<string, int>>(),
Count = 0 Count = 0
}; };
foreach (var furnitureCount in shop.ShopDocuments.Values) foreach (var docCount in shop.ShopDocuments.Values)
{ {
record.Documents.Add(new Tuple<string, int>(furnitureCount.Item1.DocumentName, furnitureCount.Item2)); record.Documents.Add(new Tuple<string, int>(docCount.Item1.DocumentName, docCount.Item2));
record.Count += furnitureCount.Item2; record.Count += docCount.Item2;
} }
list.Add(record); list.Add(record);
} }
return list; return list;
} }
public List<ReportDateOrdersViewModel> GetDateOrders(ReportBindingModel model) public List<ReportDateOrdersViewModel> GetDateOrders()
{ {
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportDateOrdersViewModel return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportDateOrdersViewModel
{ {
@ -164,10 +164,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
_saveToPdf.CreateReportDateDoc(new PdfInfo _saveToPdf.CreateReportDateDoc(new PdfInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список объединенных по дате заказов", Title = "Заказы по датам",
DateFrom = model.DateFrom!.Value, DateOrders = GetDateOrders()
DateTo = model.DateTo!.Value,
DateOrders = GetDateOrders(model)
}); });
} }
} }

View File

@ -56,16 +56,10 @@ namespace LawFirmBusinessLogic.OfficePackage
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
CreateParagraph(new PdfParagraph
{
Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "3cm", "3cm", "7cm" }); CreateTable(new List<string> { "3cm", "3cm", "7cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "Дата заказа", "Количество заказов", "Сумма" }, Texts = new List<string> { "Дата", "Количество", "Сумма" },
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
@ -82,7 +76,7 @@ namespace LawFirmBusinessLogic.OfficePackage
{ {
Text = $"Итого: {info.DateOrders.Sum(x => x.SumOrders)}\t", Text = $"Итого: {info.DateOrders.Sum(x => x.SumOrders)}\t",
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Right ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
SavePdf(info); SavePdf(info);
} }

View File

@ -24,7 +24,7 @@ namespace LawFirmContracts.BusinessLogicContracts
void SaveShopsToWordFile(ReportBindingModel model); void SaveShopsToWordFile(ReportBindingModel model);
void SaveShopDocumentsToExcelFile(ReportBindingModel model); void SaveShopDocumentsToExcelFile(ReportBindingModel model);
List<ReportShopDocumentsViewModel> GetShopDocuments(); List<ReportShopDocumentsViewModel> GetShopDocuments();
List<ReportDateOrdersViewModel> GetDateOrders(ReportBindingModel model); List<ReportDateOrdersViewModel> GetDateOrders();
void SaveDateOrdersToPdfFile(ReportBindingModel model); void SaveDateOrdersToPdfFile(ReportBindingModel model);
} }
} }