diff options
Diffstat (limited to 'src/PriceListTools')
-rw-r--r-- | src/PriceListTools/ExportTool.cs | 55 | ||||
-rw-r--r-- | src/PriceListTools/Position.cs | 3 | ||||
-rw-r--r-- | src/PriceListTools/PriceListTool.cs | 4 |
3 files changed, 16 insertions, 46 deletions
diff --git a/src/PriceListTools/ExportTool.cs b/src/PriceListTools/ExportTool.cs index 8bf274a..757d827 100644 --- a/src/PriceListTools/ExportTool.cs +++ b/src/PriceListTools/ExportTool.cs @@ -7,7 +7,7 @@ namespace RehauSku.PriceListTools { internal class ExportTool : PriceListTool { - private Dictionary<string, double> SkuAmount { get; set; } + private Dictionary<Position, double> PositionAmount; private Range Selection; public void TryGetSelection() @@ -19,62 +19,23 @@ namespace RehauSku.PriceListTools throw new Exception("Неверный диапазон"); } } - public void FillTarget() { ExcelApp.ScreenUpdating = false; GetSelected(); - FillColumn(SkuAmount, TargetFile.amountCell.Column); + FillColumnsWithDictionary(PositionAmount, TargetFile.amountCell.Column); FilterByAmount(); ExcelApp.ScreenUpdating = true; Forms.Dialog.SaveWorkbookAs(); } - private void FillColumn(IEnumerable<KeyValuePair<string, double>> dictionary, int column) - { - List<KeyValuePair<string, double>> missing = new List<KeyValuePair<string, double>>(); - - foreach (var kvp in dictionary) - { - Range cell = TargetFile.skuCell.EntireColumn.Find(kvp.Key); - - if (cell == null) - { - missing.Add(kvp); - } - - else - { - Range sumCell = TargetFile.Sheet.Cells[cell.Row, column]; - - if (sumCell.Value2 == null) - { - sumCell.Value2 = kvp.Value; - } - - else - { - sumCell.Value2 += kvp.Value; - } - } - } - - if (missing.Count > 0) - { - System.Windows.Forms.MessageBox.Show - ($"{missing.Count} артикулов отсутствует в таблице заказов {RegistryUtil.PriceListPath} Попробовать найти новый вариант?", - "Отсутствует позиция в конечной таблице заказов", - System.Windows.Forms.MessageBoxButtons.YesNo, - System.Windows.Forms.MessageBoxIcon.Information); - } - } - - private void GetSelected() { object[,] cells = Selection.Value2; - SkuAmount = new Dictionary<string, double>(); + Dictionary<string, double> SkuAmount = new Dictionary<string, double>(); + PositionAmount = new Dictionary<Position, double>(); + int rowsCount = Selection.Rows.Count; for (int row = 1; row <= rowsCount; row++) @@ -115,11 +76,17 @@ namespace RehauSku.PriceListTools { SkuAmount[sku] += amount.Value; } + else { SkuAmount.Add(sku, amount.Value); } } + + foreach (var kvp in SkuAmount) + { + PositionAmount.Add(new Position(null, kvp.Key, null), kvp.Value); + } } } } diff --git a/src/PriceListTools/Position.cs b/src/PriceListTools/Position.cs index 471aa59..0863642 100644 --- a/src/PriceListTools/Position.cs +++ b/src/PriceListTools/Position.cs @@ -13,5 +13,4 @@ Name = name; } } -} - +}
\ No newline at end of file diff --git a/src/PriceListTools/PriceListTool.cs b/src/PriceListTools/PriceListTool.cs index 09d4dac..f87aa16 100644 --- a/src/PriceListTools/PriceListTool.cs +++ b/src/PriceListTools/PriceListTool.cs @@ -89,6 +89,8 @@ namespace RehauSku.PriceListTools while (foundCell != null && foundCellGroup != positionAmount.Key.Group) { + if (positionAmount.Key.Group == null) break; + foundCell = TargetFile.skuCell.EntireColumn.FindNext(foundCell); foundCellGroup = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString(); } @@ -132,6 +134,8 @@ namespace RehauSku.PriceListTools while (foundCell != null && foundCellGroup != positionAmount.Key.Group) { + if (positionAmount.Key.Group == null) break; + foundCell = TargetFile.skuCell.EntireColumn.FindNext(foundCell); foundCellGroup = TargetFile.Sheet.Cells[foundCell.Row, TargetFile.groupCell.Column].Value2.ToString(); } |