Доделал до конца
This commit is contained in:
parent
26a7415f08
commit
7dc96fe39f
@ -42,19 +42,19 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
var components = _componentStorage.GetFullList();
|
var components = _componentStorage.GetFullList();
|
||||||
var pastries = _pastryStorage.GetFullList();
|
var pastries = _pastryStorage.GetFullList();
|
||||||
var list = new List<ReportPastryComponentViewModel>();
|
var list = new List<ReportPastryComponentViewModel>();
|
||||||
foreach (var component in components)
|
foreach (var pastry in pastries)
|
||||||
{
|
{
|
||||||
var record = new ReportPastryComponentViewModel
|
var record = new ReportPastryComponentViewModel
|
||||||
{
|
{
|
||||||
ComponentName = component.ComponentName,
|
PastryName = pastry.PastryName,
|
||||||
Pastries = new List<(string, int)>(),
|
Components = new List<(string Component, int Count)>(),
|
||||||
TotalCount = 0
|
TotalCount = 0
|
||||||
};
|
};
|
||||||
foreach (var pastry in pastries)
|
foreach (var component in components)
|
||||||
{
|
{
|
||||||
if (pastry.PastryComponents.ContainsKey(component.Id))
|
if (pastry.PastryComponents.ContainsKey(component.Id))
|
||||||
{
|
{
|
||||||
record.Pastries.Add(new (pastry.PastryName, pastry.PastryComponents[component.Id].Item2));
|
record.Components.Add(new (component.ComponentName, pastry.PastryComponents[component.Id].Item2));
|
||||||
record.TotalCount += pastry.PastryComponents[component.Id].Item2;
|
record.TotalCount += pastry.PastryComponents[component.Id].Item2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,7 +74,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
DateFrom = model.DateFrom,
|
DateFrom = model.DateFrom,
|
||||||
DateTo = model.DateTo
|
DateTo = model.DateTo
|
||||||
})
|
})
|
||||||
.Select(x => new ReportOrdersViewModel
|
.Select(x =>
|
||||||
|
new ReportOrdersViewModel
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
DateCreate = x.DateCreate,
|
DateCreate = x.DateCreate,
|
||||||
@ -95,8 +96,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
_saveToWord.CreateDoc(new WordInfo
|
_saveToWord.CreateDoc(new WordInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список компонент",
|
Title = "Список изделий",
|
||||||
Components = _componentStorage.GetFullList()
|
Pastries = _pastryStorage.GetFullList()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -108,7 +109,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
_saveToExcel.CreateReport(new ExcelInfo
|
_saveToExcel.CreateReport(new ExcelInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список компонент",
|
Title = "Список изделий",
|
||||||
PastryComponents = GetPastryComponent()
|
PastryComponents = GetPastryComponent()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -33,17 +33,17 @@ namespace ConfectioneryBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = pc.ComponentName,
|
Text = pc.PastryName,
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
foreach (var (Pastry, Count) in pc.Pastries)
|
foreach (var (Component, Count) in pc.Components)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = Pastry,
|
Text = Component,
|
||||||
StyleInfo =
|
StyleInfo =
|
||||||
ExcelStyleInfoType.TextWithBroder
|
ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
|
@ -22,11 +22,12 @@ namespace ConfectioneryBusinessLogic.OfficePackage
|
|||||||
JustificationType = WordJustificationType.Center
|
JustificationType = WordJustificationType.Center
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
foreach (var component in info.Components)
|
foreach (var pastry in info.Pastries)
|
||||||
{
|
{
|
||||||
CreateParagraph(new WordParagraph
|
CreateParagraph(new WordParagraph
|
||||||
{
|
{
|
||||||
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) },
|
Texts = new List<(string, WordTextProperties)> { (pastry.PastryName + " - ", new WordTextProperties { Size = "24", Bold = true}),
|
||||||
|
(pastry.Price.ToString(), new WordTextProperties { Size = "24"})},
|
||||||
TextProperties = new WordTextProperties
|
TextProperties = new WordTextProperties
|
||||||
{
|
{
|
||||||
Size = "24",
|
Size = "24",
|
||||||
|
@ -13,6 +13,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
public List<ComponentViewModel> Components { get; set; } = new();
|
public List<PastryViewModel> Pastries { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ namespace ConfectioneryContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportPastryComponentViewModel
|
public class ReportPastryComponentViewModel
|
||||||
{
|
{
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string PastryName { get; set; } = string.Empty;
|
||||||
public int TotalCount { get; set; }
|
public int TotalCount { get; set; }
|
||||||
public List<(string Pastry, int Count)> Pastries { get; set; } = new();
|
public List<(string Component, int Count)> Components { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,27 +45,14 @@ namespace ConfectioneryDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new ConfectioneryDatabase();
|
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||||
if (model.Id.HasValue)
|
|
||||||
{
|
{
|
||||||
return context.Orders
|
return new();
|
||||||
.Include(x => x.Pastry)
|
|
||||||
.Where(x => x.Id == model.Id)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
else if (model.DateFrom != null && model.DateTo != null)
|
|
||||||
{
|
|
||||||
return context.Orders
|
|
||||||
.Include(x => x.Pastry)
|
|
||||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
}
|
||||||
|
using var context = new ConfectioneryDatabase();
|
||||||
|
|
||||||
|
return context.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo)
|
||||||
|
.Select(x => GetViewModel(x)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
{
|
{
|
||||||
this.buttonSaveToExcel = new System.Windows.Forms.Button();
|
this.buttonSaveToExcel = new System.Windows.Forms.Button();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.ColumnPastry = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.ColumnPastry = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -53,8 +53,8 @@
|
|||||||
this.dataGridView.AllowUserToOrderColumns = true;
|
this.dataGridView.AllowUserToOrderColumns = true;
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
this.ColumnComponent,
|
|
||||||
this.ColumnPastry,
|
this.ColumnPastry,
|
||||||
|
this.ColumnComponent,
|
||||||
this.ColumnCount});
|
this.ColumnCount});
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 53);
|
this.dataGridView.Location = new System.Drawing.Point(0, 53);
|
||||||
@ -64,18 +64,18 @@
|
|||||||
this.dataGridView.Size = new System.Drawing.Size(800, 397);
|
this.dataGridView.Size = new System.Drawing.Size(800, 397);
|
||||||
this.dataGridView.TabIndex = 1;
|
this.dataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// ColumnComponent
|
|
||||||
//
|
|
||||||
this.ColumnComponent.HeaderText = "Компонент";
|
|
||||||
this.ColumnComponent.Name = "ColumnComponent";
|
|
||||||
this.ColumnComponent.ReadOnly = true;
|
|
||||||
//
|
|
||||||
// ColumnPastry
|
// ColumnPastry
|
||||||
//
|
//
|
||||||
this.ColumnPastry.HeaderText = "Изделие";
|
this.ColumnPastry.HeaderText = "Изделие";
|
||||||
this.ColumnPastry.Name = "ColumnPastry";
|
this.ColumnPastry.Name = "ColumnPastry";
|
||||||
this.ColumnPastry.ReadOnly = true;
|
this.ColumnPastry.ReadOnly = true;
|
||||||
//
|
//
|
||||||
|
// ColumnComponent
|
||||||
|
//
|
||||||
|
this.ColumnComponent.HeaderText = "Компонент";
|
||||||
|
this.ColumnComponent.Name = "ColumnComponent";
|
||||||
|
this.ColumnComponent.ReadOnly = true;
|
||||||
|
//
|
||||||
// ColumnCount
|
// ColumnCount
|
||||||
//
|
//
|
||||||
this.ColumnCount.HeaderText = "Количество";
|
this.ColumnCount.HeaderText = "Количество";
|
||||||
@ -101,8 +101,8 @@
|
|||||||
|
|
||||||
private Button buttonSaveToExcel;
|
private Button buttonSaveToExcel;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewTextBoxColumn ColumnComponent;
|
|
||||||
private DataGridViewTextBoxColumn ColumnPastry;
|
private DataGridViewTextBoxColumn ColumnPastry;
|
||||||
|
private DataGridViewTextBoxColumn ColumnComponent;
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,8 +34,8 @@ namespace ConfectioneryView
|
|||||||
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[] { elem.PastryName, "", "" });
|
||||||
foreach (var listElem in elem.Pastries)
|
foreach (var listElem in elem.Components)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
}
|
}
|
||||||
|
@ -57,21 +57,12 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="ColumnComponent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnPastry.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnPastry.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnComponent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnComponent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="ColumnPastry.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
Loading…
Reference in New Issue
Block a user