Excel done, lab done
This commit is contained in:
parent
2b5739b429
commit
d89c3851ac
@ -40,24 +40,22 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
public List<ReportComputerComponentViewModel> GetComputerComponent()
|
public List<ReportComputerComponentViewModel> GetComputerComponent()
|
||||||
{
|
{
|
||||||
var components = _componentStorage.GetFullList();
|
var components = _componentStorage.GetFullList();
|
||||||
var products = _productStorage.GetFullList();
|
var computers = _productStorage.GetFullList();
|
||||||
var list = new List<ReportComputerComponentViewModel>();
|
var list = new List<ReportComputerComponentViewModel>();
|
||||||
foreach (var component in components)
|
foreach (var computer in computers)
|
||||||
{
|
{
|
||||||
var record = new ReportComputerComponentViewModel
|
var record = new ReportComputerComponentViewModel
|
||||||
{
|
{
|
||||||
ComponentName = component.ComponentName,
|
ComputerName = computer.ComputerName,
|
||||||
Computers = new List<Tuple<string, int>>(),
|
Components = new List<Tuple<string, int>>(),
|
||||||
TotalCount = 0
|
TotalCount = 0
|
||||||
};
|
};
|
||||||
foreach (var product in products)
|
foreach (var component in components)
|
||||||
{
|
{
|
||||||
if (product.ComputerComponents.ContainsKey(component.Id))
|
if (computer.ComputerComponents.ContainsKey(component.Id))
|
||||||
{
|
{
|
||||||
record.Computers.Add(new Tuple<string,
|
record.Components.Add(new Tuple<string, int>(component.ComponentName, computer.ComputerComponents[component.Id].Item2));
|
||||||
int>(product.ComputerName, product.ComputerComponents[component.Id].Item2));
|
record.TotalCount += computer.ComputerComponents[component.Id].Item2;
|
||||||
record.TotalCount +=
|
|
||||||
product.ComputerComponents[component.Id].Item2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.Add(record);
|
list.Add(record);
|
||||||
|
@ -36,11 +36,11 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = pc.ComponentName,
|
Text = pc.ComputerName,
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
foreach (var product in pc.Computers)
|
foreach (var product in pc.Components)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,8 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportComputerComponentViewModel
|
public class ReportComputerComponentViewModel
|
||||||
{
|
{
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComputerName { get; set; } = string.Empty;
|
||||||
public int TotalCount { get; set; }
|
public int TotalCount { get; set; }
|
||||||
public List<Tuple<string, int>> Computers { get; set; } = new();
|
public List<Tuple<string, int>> Components { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ namespace ComputersShop
|
|||||||
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.ComputerName, "", "" });
|
||||||
foreach (var listElem in elem.Computers)
|
foreach (var listElem in elem.Components)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
}
|
}
|
||||||
@ -43,11 +43,11 @@ namespace ComputersShop
|
|||||||
dataGridView.Rows.Add(Array.Empty<object>());
|
dataGridView.Rows.Add(Array.Empty<object>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
_logger.LogInformation("Загрузка списка компонентов по изделиям");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
_logger.LogError(ex, "Ошибка загрузки списка компонентов по изделиям");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user