Complete lab

This commit is contained in:
Viltskaa 2023-04-11 11:12:55 +04:00
parent 6dca3efbb7
commit e3c8540c6f
14 changed files with 311 additions and 624 deletions

View File

@ -45,6 +45,9 @@
this.buttonReload = new System.Windows.Forms.Button();
this.buttonSell = new System.Windows.Forms.Button();
this.buttonSupply = new System.Windows.Forms.Button();
this.storeListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.storeWorkloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.orderListWithGroupByToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
@ -82,21 +85,21 @@
// componentsToolStripMenuItem
//
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this.componentsToolStripMenuItem.Text = "Components";
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
//
// sushiToolStripMenuItem
//
this.sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
this.sushiToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.sushiToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this.sushiToolStripMenuItem.Text = "Sushi";
this.sushiToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click);
//
// storesToolStripMenuItem
//
this.storesToolStripMenuItem.Name = "storesToolStripMenuItem";
this.storesToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.storesToolStripMenuItem.Size = new System.Drawing.Size(143, 22);
this.storesToolStripMenuItem.Text = "Stores";
this.storesToolStripMenuItem.Click += new System.EventHandler(this.StoreToolStripMenuItem_Click);
//
@ -105,7 +108,10 @@
this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.listComponentsToolStripMenuItem,
this.componentsOnSushiToolStripMenuItem,
this.orderListToolStripMenuItem});
this.orderListToolStripMenuItem,
this.storeListToolStripMenuItem,
this.storeWorkloadToolStripMenuItem,
this.orderListWithGroupByToolStripMenuItem});
this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
this.reportsToolStripMenuItem.Size = new System.Drawing.Size(59, 20);
this.reportsToolStripMenuItem.Text = "Reports";
@ -113,21 +119,21 @@
// listComponentsToolStripMenuItem
//
this.listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem";
this.listComponentsToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.listComponentsToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.listComponentsToolStripMenuItem.Text = "List components";
this.listComponentsToolStripMenuItem.Click += new System.EventHandler(this.ListComponentsToolStripMenuItem_Click);
//
// componentsOnSushiToolStripMenuItem
//
this.componentsOnSushiToolStripMenuItem.Name = "componentsOnSushiToolStripMenuItem";
this.componentsOnSushiToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.componentsOnSushiToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.componentsOnSushiToolStripMenuItem.Text = "Components on sushi";
this.componentsOnSushiToolStripMenuItem.Click += new System.EventHandler(this.ComponentsOnSushiToolStripMenuItem_Click);
//
// orderListToolStripMenuItem
//
this.orderListToolStripMenuItem.Name = "orderListToolStripMenuItem";
this.orderListToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
this.orderListToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.orderListToolStripMenuItem.Text = "Order list";
this.orderListToolStripMenuItem.Click += new System.EventHandler(this.ListOrdersToolStripMenuItem_Click);
//
@ -201,6 +207,27 @@
this.buttonSupply.UseVisualStyleBackColor = true;
this.buttonSupply.Click += new System.EventHandler(this.ButtonReplenishment_Click);
//
// storeListToolStripMenuItem
//
this.storeListToolStripMenuItem.Name = "storeListToolStripMenuItem";
this.storeListToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.storeListToolStripMenuItem.Text = "Store list";
this.storeListToolStripMenuItem.Click += new System.EventHandler(this.StoreListToolStripMenuItem_Click);
//
// storeWorkloadToolStripMenuItem
//
this.storeWorkloadToolStripMenuItem.Name = "storeWorkloadToolStripMenuItem";
this.storeWorkloadToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.storeWorkloadToolStripMenuItem.Text = "Store workload";
this.storeWorkloadToolStripMenuItem.Click += new System.EventHandler(this.StoreWorkloadToolStripMenuItem_Click);
//
// orderListWithGroupByToolStripMenuItem
//
this.orderListWithGroupByToolStripMenuItem.Name = "orderListWithGroupByToolStripMenuItem";
this.orderListWithGroupByToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.orderListWithGroupByToolStripMenuItem.Text = "Order list with group by";
this.orderListWithGroupByToolStripMenuItem.Click += new System.EventHandler(this.OrderListWithGroupByToolStripMenuItem_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -246,5 +273,8 @@
private ToolStripMenuItem orderListToolStripMenuItem;
private Button buttonSell;
private Button buttonSupply;
private ToolStripMenuItem storeListToolStripMenuItem;
private ToolStripMenuItem storeWorkloadToolStripMenuItem;
private ToolStripMenuItem orderListWithGroupByToolStripMenuItem;
}
}

View File

@ -178,7 +178,7 @@ namespace SushiBar
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() != DialogResult.OK) return;
_reportLogic.SaveStoresToWordFile(new ReportBindingModel
_reportLogic.SaveSushiToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
@ -234,5 +234,36 @@ namespace SushiBar
form.ShowDialog();
}
}
private void StoreListToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() != DialogResult.OK) return;
_reportLogic.SaveStoresToWordFile(new ReportBindingModel
{
FileName = dialog.FileName
});
MessageBox.Show("Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void StoreWorkloadToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormStoreWorkload));
if (service is FormStoreWorkload form)
{
form.ShowDialog();
}
}
private void OrderListWithGroupByToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrdersGroupByDate));
if (service is FormReportOrdersGroupByDate form)
{
form.ShowDialog();
}
}
}
}

View File

@ -60,7 +60,6 @@ namespace SushiBar
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
@ -94,7 +93,6 @@ namespace SushiBar
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -42,7 +42,6 @@ namespace SushiBar
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void FormComponentsOnSushi_Load(object sender, EventArgs e)

View File

@ -56,6 +56,8 @@ namespace SushiBar
services.AddTransient<FormStore>();
services.AddTransient<FormStoreReplenishment>();
services.AddTransient<FormStoreSell>();
services.AddTransient<FormStoreWorkload>();
services.AddTransient<FormReportOrdersGroupByDate>();
}
}
}

View File

@ -1,588 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="SushiBarContractsViewModel">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>bf577a27-98a7-43b2-8beb-1a37d37ce5cd</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSetOrders">
<Query>
<DataSourceName>SushiBarContractsViewModel</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
<Field Name="Count">
<DataField>Count</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="DateCreate">
<DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="SushiName">
<DataField>IceCreamName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Status">
<DataField>Status</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Sum">
<DataField>Sum</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>SushiBarContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportOrderViewModel</rd:TableName>
<rd:ObjectDataSourceType>SushiBarContracts.ViewModels.ReportOrderViewModel, IceCreamShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Orders</Value>
<Style>
<FontSize>20pt</FontSize>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Height>0.99688cm</Height>
<Width>21.51cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>5.26521cm</Width>
</TablixColumn>
<TablixColumn>
<Width>5.26521cm</Width>
</TablixColumn>
<TablixColumn>
<Width>5.26521cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.26188cm</Width>
</TablixColumn>
<TablixColumn>
<Width>2.26188cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>2.22236cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Id</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="Textbox4">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Date Create</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox4</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="Textbox6">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Sushi Name</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox6</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="Textbox10">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Status</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox10</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="Textbox8">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Sum</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox8</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>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>2.22236cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Count">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Count.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Count</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>
<rd:Selected>true</rd:Selected>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="DateCreate">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!DateCreate.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>DateCreate</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="SushiName">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!SushiName.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>SushiName</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="Status">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Status.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Status</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">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Sum.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Sum</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>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember />
<TablixMember />
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Подробности" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>2.4609cm</Top>
<Left>0.60854cm</Left>
<Height>4.44472cm</Height>
<Width>20.31939cm</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>Solid</Style>
</Border>
</Style>
</Tablix>
<Textbox Name="Textbox12">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>12pt</FontSize>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox12</rd:DefaultName>
<Top>1.42557cm</Top>
<Height>0.65292cm</Height>
<Width>21.51cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="Textbox13">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Total</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
<Paragraph>
<TextRuns>
<TextRun>
<Value />
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox13</rd:DefaultName>
<Top>7.43162cm</Top>
<Left>16.16604cm</Left>
<Height>0.6cm</Height>
<Width>2.5cm</Width>
<ZIndex>3</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="Textbox14">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox14</rd:DefaultName>
<Top>7.43162cm</Top>
<Left>18.66604cm</Left>
<Height>0.6cm</Height>
<Width>2.26187cm</Width>
<ZIndex>4</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</ReportItems>
<Height>3.22917in</Height>
<Style />
</Body>
<Width>8.50383in</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParameters>
<ReportParameter Name="ReportParameterPeriod">
<DataType>String</DataType>
<Nullable>true</Nullable>
<Prompt>ReportParameter1</Prompt>
</ReportParameter>
</ReportParameters>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
<CellDefinitions>
<CellDefinition>
<ColumnIndex>0</ColumnIndex>
<RowIndex>0</RowIndex>
<ParameterName>ReportParameterPeriod</ParameterName>
</CellDefinition>
</CellDefinitions>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>10f2c1a3-5a29-4515-be40-6fe4bab54720</rd:ReportID>
</Report>

View File

@ -56,6 +56,12 @@ namespace SushiBarBusinessLogic.BusinessLogics
return list;
}
public List<StoreViewModel> GetStores()
{
return _storeStorage.GetFullList();
}
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
{
return _orderStorage.GetFilteredList(new OrderSearchModel
@ -74,15 +80,46 @@ namespace SushiBarBusinessLogic.BusinessLogics
.ToList();
}
public List<ReportOrderGroupViewModel> GetGroupOrders()
{
return _orderStorage.GetFullList()
.Select(x => new ReportOrdersViewModel
{
Id = x.Id,
DateCreate = x.DateCreate,
SushiName = x.SushiName,
Sum = x.Sum,
Status = x.Status.ToString()
})
.GroupBy(x => x.DateCreate.ToShortDateString())
.Select(x => new ReportOrderGroupViewModel
{
OrderDate = DateTime.Parse(x.Key),
Count = x.Count(),
Sum = x.Sum(y => y.Sum),
}).ToList();
}
public void SaveStoresToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
_saveToWord.CreateTableDoc(new WordInfo
{
FileName = model.FileName,
Title = "Stores list",
Stores = _storeStorage.GetFullList()
});
}
public void SaveWorkloadStoresToExcel(ReportBindingModel model)
{
_saveToExcel.CreateReportStores(new ExcelInfo
{
FileName = model.FileName,
Title = "Workload stores",
Stores = _storeStorage.GetFullList()
});
}
public void SaveSushiToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
@ -112,5 +149,15 @@ namespace SushiBarBusinessLogic.BusinessLogics
Orders = GetOrders(model)
});
}
public void SaveOrdersGroupedToPdf(ReportBindingModel model)
{
_saveToPdf.CreateDocGroupedByDate(new PdfInfo
{
FileName = model.FileName,
Title = "Order list grouped by date",
GroupOrders = GetGroupOrders()
});
}
}
}

View File

@ -70,6 +70,90 @@ namespace SushiBarBusinessLogic.OfficePackage
}
SaveExcel(info);
}
public void CreateReportStores(ExcelInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var storeViewModel in info.Stores)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = storeViewModel.StoreName,
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = "Sushi",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = "Count",
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var com in storeViewModel.Sushis)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = com.Value.Item2.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = com.Value.Item1.SushiName,
StyleInfo =
ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Total",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = storeViewModel.Sushis
.Values
.Select(x => x.Item2)
.Sum()
.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfo info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);

View File

@ -49,6 +49,44 @@ namespace SushiBarBusinessLogic.OfficePackage
});
SavePdf(info);
}
public void CreateDocGroupedByDate(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "4cm", "4cm", "4cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Date", "Count", "Sum" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var order in info.GroupOrders)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> {
order.OrderDate.ToShortDateString(),
order.Count.ToString(),
order.Sum.ToString()
},
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph
{
Text = $"Total: {info.GroupOrders.Sum(x=> x.Sum)}\t",
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
});
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);

View File

@ -1,4 +1,4 @@
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Wordprocessing;
using SushiBarBusinessLogic.OfficePackage.HelpersEnum;
using SushiBarBusinessLogic.OfficePackage.HelpersModels;
@ -6,27 +6,75 @@ namespace SushiBarBusinessLogic.OfficePackage;
public abstract class AbstractSaveToWord
{
public void CreateDoc(WordInfo info)
public void CreateTableDoc(WordInfo info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
var rows = info.Stores
.Select(store => CreateRow(
new List<TableCell?>()
new()
{
CreateCell(new WordCell { Text = store.StoreName }),
CreateCell(new WordCell { Text = store.StoreAddress }),
CreateCell(new WordCell { Text = store.OpeningDate.ToShortDateString() })
CreateCell(new WordCell { Text = store.OpeningDate.ToShortDateString()})
})).ToList();
rows.Insert(0, CreateRow(new ()
{
CreateCell(new WordCell{ Text = "Store name", Width = 3000 }),
CreateCell(new WordCell{ Text = "Store Address", Width = 2000 }),
CreateCell(new WordCell{ Text = "Opening Date", Width = 3000 }),
}));
CreateTable(rows);
SaveWord(info);
}
public void CreateDoc(WordInfo info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {
(info.Title, new WordTextProperties { Bold = true, Size = "24", })
},
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var sushi in info.Sushi)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {
(sushi.SushiName, new WordTextProperties { Bold = true, Size = "24" }),
($" {sushi.Price}", new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Right }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(info);
}
protected abstract void CreateWord(WordInfo info);
protected abstract void CreateParagraph(WordParagraph? paragraph);
protected abstract void SaveWord(WordInfo info);
protected abstract void CreateTable(List<TableRow?>? rows);
protected abstract TableRow? CreateRow(List<TableCell?>? cells);
protected abstract TableCell? CreateCell(WordCell? cell);
protected abstract void CreateTable(List<TableRow> rows);
protected abstract TableRow CreateRow(List<TableCell> cells);
protected abstract TableCell CreateCell(WordCell cell);
}

View File

@ -7,5 +7,6 @@ namespace SushiBarBusinessLogic.OfficePackage.HelpersModels
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportSushiComponentViewModel> Sushi{ get; set; } = new();
public List<StoreViewModel> Stores { get; set; } = new();
}
}

View File

@ -9,5 +9,6 @@ namespace SushiBarBusinessLogic.OfficePackage.HelpersModels
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportOrdersViewModel> Orders { get; set; } = new();
public List<ReportOrderGroupViewModel> GroupOrders { get; set; } = new();
}
}

View File

@ -1,12 +1,8 @@
using SushiBarBusinessLogic.OfficePackage.HelpersEnum;
using SushiBarBusinessLogic.OfficePackage.HelpersModels;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using Document = DocumentFormat.OpenXml.Wordprocessing.Document;
using TableCell = DocumentFormat.OpenXml.Drawing.TableCell;
using TableRow = DocumentFormat.OpenXml.Drawing.TableRow;
using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
using SushiBarBusinessLogic.OfficePackage.HelpersEnum;
using SushiBarBusinessLogic.OfficePackage.HelpersModels;
namespace SushiBarBusinessLogic.OfficePackage.Implements
{
@ -111,9 +107,9 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
_wordDocument.Close();
}
protected override void CreateTable(List<TableRow?>? rows)
protected override void CreateTable(List<TableRow> rows)
{
if (_docBody == null || rows == null)
if (_docBody == null)
{
return;
}
@ -130,20 +126,16 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
);
table.AppendChild(tblProp);
table.Append(rows);
_docBody.AppendChild(table);
_docBody.Append(table);
}
protected override TableRow? CreateRow(List<TableCell?>? cells)
protected override TableRow CreateRow(List<TableCell> cells)
{
if (cells == null) return null;
var row = new TableRow();
row.Append(cells);
return row;
return new TableRow(cells);
}
protected override TableCell? CreateCell(WordCell? cell)
protected override TableCell CreateCell(WordCell cell)
{
if (cell == null) return null;
var createCell = new TableCell(new Paragraph(
new Run(
new Text(cell.Text))));

View File

@ -7,9 +7,13 @@ namespace SushiBarContracts.BusinessLogicsContracts
{
List<ReportSushiComponentViewModel> GetSushi();
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
public List<StoreViewModel> GetStores();
void SaveSushiToWordFile(ReportBindingModel model);
void SaveProductComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model);
public void SaveStoresToWordFile(ReportBindingModel model);
public void SaveWorkloadStoresToExcel(ReportBindingModel model);
public void SaveOrdersGroupedToPdf(ReportBindingModel model);
public List<ReportOrderGroupViewModel> GetGroupOrders();
}
}