PIbd-22. Aleikin A.M. LabWork04 #4
@ -42,19 +42,19 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
var components = _componentStorage.GetFullList();
|
||||
|
||||
var pastries = _pastryStorage.GetFullList();
|
||||
var list = new List<ReportPastryComponentViewModel>();
|
||||
foreach (var component in components)
|
||||
foreach (var pastry in pastries)
|
||||
{
|
||||
var record = new ReportPastryComponentViewModel
|
||||
{
|
||||
ComponentName = component.ComponentName,
|
||||
Pastries = new List<(string, int)>(),
|
||||
PastryName = pastry.PastryName,
|
||||
Components = new List<(string Component, int Count)>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var pastry in pastries)
|
||||
foreach (var component in components)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
})
|
||||
.Select(x => new ReportOrdersViewModel
|
||||
.Select(x =>
|
||||
new ReportOrdersViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
DateCreate = x.DateCreate,
|
||||
@ -95,8 +96,8 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
Components = _componentStorage.GetFullList()
|
||||
Title = "Список изделий",
|
||||
Pastries = _pastryStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
@ -108,7 +109,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
Title = "Список изделий",
|
||||
PastryComponents = GetPastryComponent()
|
||||
});
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ namespace ConfectioneryBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.ComponentName,
|
||||
Text = pc.PastryName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var (Pastry, Count) in pc.Pastries)
|
||||
foreach (var (Component, Count) in pc.Components)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = Pastry,
|
||||
Text = Component,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
@ -22,11 +22,12 @@ namespace ConfectioneryBusinessLogic.OfficePackage
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
foreach (var component in info.Components)
|
||||
foreach (var pastry in info.Pastries)
|
||||
{
|
||||
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
|
||||
{
|
||||
Size = "24",
|
||||
|
@ -13,6 +13,6 @@ namespace ConfectioneryBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
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 string ComponentName { get; set; } = string.Empty;
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
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)
|
||||
{
|
||||
using var context = new ConfectioneryDatabase();
|
||||
if (model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.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();
|
||||
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()
|
||||
|
@ -30,8 +30,8 @@
|
||||
{
|
||||
this.buttonSaveToExcel = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnComponent = 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();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -53,8 +53,8 @@
|
||||
this.dataGridView.AllowUserToOrderColumns = true;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnComponent,
|
||||
this.ColumnPastry,
|
||||
this.ColumnComponent,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 53);
|
||||
@ -64,18 +64,18 @@
|
||||
this.dataGridView.Size = new System.Drawing.Size(800, 397);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// ColumnComponent
|
||||
//
|
||||
this.ColumnComponent.HeaderText = "Компонент";
|
||||
this.ColumnComponent.Name = "ColumnComponent";
|
||||
this.ColumnComponent.ReadOnly = true;
|
||||
//
|
||||
// ColumnPastry
|
||||
//
|
||||
this.ColumnPastry.HeaderText = "Изделие";
|
||||
this.ColumnPastry.Name = "ColumnPastry";
|
||||
this.ColumnPastry.ReadOnly = true;
|
||||
//
|
||||
// ColumnComponent
|
||||
//
|
||||
this.ColumnComponent.HeaderText = "Компонент";
|
||||
this.ColumnComponent.Name = "ColumnComponent";
|
||||
this.ColumnComponent.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
@ -101,8 +101,8 @@
|
||||
|
||||
private Button buttonSaveToExcel;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnComponent;
|
||||
private DataGridViewTextBoxColumn ColumnPastry;
|
||||
private DataGridViewTextBoxColumn ColumnComponent;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
@ -34,8 +34,8 @@ namespace ConfectioneryView
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
|
||||
foreach (var listElem in elem.Pastries)
|
||||
dataGridView.Rows.Add(new object[] { elem.PastryName, "", "" });
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||
}
|
||||
|
@ -57,21 +57,12 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</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">
|
||||
<value>True</value>
|
||||
</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">
|
||||
<value>True</value>
|
||||
</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">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
Loading…
Reference in New Issue
Block a user
При получении изделий, у них уже есть список компонент, отдельно его получать не требуется