From 2cbce48654644542723b6ed07a020afdb5b5db87 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Fri, 28 Jan 2022 15:38:57 +0300 Subject: [PATCH] Refactoring --- src/PriceListTools/PriceListTool.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/PriceListTools/PriceListTool.cs b/src/PriceListTools/PriceListTool.cs index a80010b..1736835 100644 --- a/src/PriceListTools/PriceListTool.cs +++ b/src/PriceListTools/PriceListTool.cs @@ -9,6 +9,7 @@ namespace RehauSku.PriceListTools { protected private Application ExcelApp = (Application)ExcelDnaUtil.Application; protected private Target TargetFile; + protected private List> Missing; public void OpenNewPrice() { @@ -33,44 +34,44 @@ namespace RehauSku.PriceListTools protected private void FillColumn(IEnumerable> dictionary, params int[] columns) { - List> missing = new List>(); + Missing = new List>(); object[,] groupColumn = TargetFile.groupCell.EntireColumn.Value2; foreach (var kvp in dictionary) { - FillPosition(kvp, columns, ref missing, ref groupColumn); + FillPosition(kvp, columns); } - if (missing.Count > 0) + if (Missing.Count > 0) { System.Windows.Forms.MessageBox.Show - ($"{missing.Count} артикулов отсутствует в таблице заказов {RegistryUtil.PriceListPath} Попробовать найти новый вариант?", + ($"{Missing.Count} артикулов отсутствует в таблице заказов {RegistryUtil.PriceListPath} Попробовать найти новый вариант?", "Отсутствует позиция в конечной таблице заказов", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information); } } - protected private void FillPosition(KeyValuePair kvp, int[] columns, ref List> missing, ref object[,] groupColumn) + protected private void FillPosition(KeyValuePair kvp, int[] columns) { Range foundCell = TargetFile.skuCell.EntireColumn.Find(kvp.Key.Sku); if (foundCell == null) { - missing.Add(kvp); + Missing.Add(kvp); return; } - string foundCellGroup = groupColumn[foundCell.Row, 1].ToString(); + string foundCellGroup = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString(); while (foundCell != null && foundCellGroup != kvp.Key.Group) { foundCell = TargetFile.skuCell.EntireColumn.FindNext(foundCell); - foundCellGroup = groupColumn[foundCell.Row, 1].ToString(); + foundCellGroup = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString(); } if (foundCell == null) { - missing.Add(kvp); + Missing.Add(kvp); } else