ISEbd-21 Melnikov I.O. Lab Work 04 Base #10

Closed
Igor-Melnikov wants to merge 10 commits from lab4 into lab3
6 changed files with 91 additions and 50 deletions
Showing only changes of commit 6f865eac97 - Show all commits

View File

@ -29,13 +29,13 @@
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnManufacture = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.buttonSaveToExcel = new System.Windows.Forms.Button();
this.ColumnManufacture = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnSum = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
this.Load += new System.EventHandler(this.FormReportManufactureComponents_Load);
//
// dataGridView
//
@ -43,9 +43,10 @@
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnComponent,
this.ColumnManufacture,
this.ColumnCount});
this.ColumnComponent,
this.ColumnCount,
this.ColumnSum});
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dataGridView.Location = new System.Drawing.Point(0, 45);
this.dataGridView.Name = "dataGridView";
@ -53,21 +54,6 @@
this.dataGridView.Size = new System.Drawing.Size(610, 405);
this.dataGridView.TabIndex = 0;
//
// ColumnComponent
//
this.ColumnComponent.HeaderText = "Компонент";
this.ColumnComponent.Name = "ColumnComponent";
//
// ColumnManufacture
//
this.ColumnManufacture.HeaderText = "Изделие";
this.ColumnManufacture.Name = "ColumnManufacture";
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount";
//
// buttonSaveToExcel
//
this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 12);
@ -78,6 +64,26 @@
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
//
// ColumnManufacture
//
this.ColumnManufacture.HeaderText = "Изделие";
this.ColumnManufacture.Name = "ColumnManufacture";
//
// ColumnComponent
//
this.ColumnComponent.HeaderText = "Компонент";
this.ColumnComponent.Name = "ColumnComponent";
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount";
//
// ColumnSum
//
this.ColumnSum.HeaderText = "Сумма";
this.ColumnSum.Name = "ColumnSum";
//
// FormReportManufactureComponents
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -87,6 +93,7 @@
this.Controls.Add(this.dataGridView);
this.Name = "FormReportManufactureComponents";
this.Text = "FormReportManufactureComponents";
Review

Заголовок формы оформлен неверно

Заголовок формы оформлен неверно
this.Load += new System.EventHandler(this.FormReportManufactureComponents_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
@ -95,9 +102,10 @@
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnComponent;
private DataGridViewTextBoxColumn ColumnManufacture;
private DataGridViewTextBoxColumn ColumnCount;
private Button buttonSaveToExcel;
private DataGridViewTextBoxColumn ColumnManufacture;
private DataGridViewTextBoxColumn ColumnComponent;
private DataGridViewTextBoxColumn ColumnCount;
private DataGridViewTextBoxColumn ColumnSum;
}
}

View File

@ -24,12 +24,12 @@ namespace BlacksmithWorkshopView
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Manufactures)
dataGridView.Rows.Add(new object[] { elem.ManufactureName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2, listElem.Item3 });
}
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount, elem.TotalSum });
dataGridView.Rows.Add(Array.Empty<object>());
}
}

View File

@ -57,22 +57,16 @@
<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="ColumnManufacture.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="ColumnManufacture.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>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="ColumnSum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -38,20 +38,22 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
var components = _componentStorage.GetFullList();
var manufactures = _manufactureStorage.GetFullList();
var list = new List<ReportManufactureComponentViewModel>();
foreach (var component in components)
foreach (var manufacture in manufactures)
{
var record = new ReportManufactureComponentViewModel
{
ComponentName = component.ComponentName,
Manufactures = new List<(string, int)>(),
TotalCount = 0
ManufactureName = manufacture.ManufactureName,
Components = new List<(string, int, double)>(),
TotalCount = 0,
TotalSum = 0
};
foreach (var manufacture in manufactures)
foreach (var component in components)
{
if (manufacture.ManufactureComponents.ContainsKey(component.Id))
{
record.Manufactures.Add((manufacture.ManufactureName, manufacture.ManufactureComponents[component.Id].Item2));
record.Components.Add((component.ComponentName, manufacture.ManufactureComponents[component.Id].Item2, component.Cost * manufacture.ManufactureComponents[component.Id].Item2));
record.TotalCount += manufacture.ManufactureComponents[component.Id].Item2;
record.TotalSum += component.Cost * manufacture.ManufactureComponents[component.Id].Item2;
}
}
list.Add(record);
@ -80,7 +82,7 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
.ToList();
}
/// <summary>
/// Сохранение компонент в файл-Word
/// Сохранение изделий в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveComponentsToWordFile(ReportBindingModel model)
@ -93,7 +95,7 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
});
}
/// <summary>
/// Сохранение компонент с указаеним продуктов в файл-Excel
/// Сохранение изделий с указаеним продуктов в файл-Excel
/// </summary>
/// <param name="model"></param>
public void SaveManufactureComponentToExcelFile(ReportBindingModel model)
@ -101,7 +103,7 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список компонент",
Title = "Список изделий",
ManufactureComponents = GetManufactureComponent()
});
}

View File

@ -22,7 +22,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
CellToName = "D1"
});
uint rowIndex = 2;
foreach (var pc in info.ManufactureComponents)
@ -31,11 +31,32 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.ManufactureName,
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = "Компонент",
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = "Количество",
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "D",
RowIndex = rowIndex,
Text = "Сумма",
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
foreach (var (Manufacture, Count) in pc.Manufactures)
foreach (var (Manufacture, Count, Sum) in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
@ -53,6 +74,14 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
StyleInfo =
ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "D",
RowIndex = rowIndex,
Text = Sum.ToString(),
StyleInfo =
ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
@ -69,6 +98,13 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
Text = pc.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "D",
RowIndex = rowIndex,
Text = pc.TotalSum.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);

View File

@ -2,8 +2,9 @@
{
public class ReportManufactureComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string ManufactureName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Manufacture, int Count)> Manufactures { get; set; } = new();
public double TotalSum { get; set; }
public List<(string Component, int Count, double Sum)> Components { get; set; } = new();
}
}