From df1a2f9d91c78e7a87a8b1be643c0f7269cad761 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Tue, 28 Dec 2021 17:15:30 +0300 Subject: [PATCH 1/2] Show message box if sku is not found during export --- src/PriceListTools/PriceList.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PriceListTools/PriceList.cs b/src/PriceListTools/PriceList.cs index 1460c07..e67d573 100644 --- a/src/PriceListTools/PriceList.cs +++ b/src/PriceListTools/PriceList.cs @@ -44,7 +44,16 @@ namespace RehauSku.PriceListTools foreach (KeyValuePair kvp in values) { Range cell = ws.Columns[skuColumn].Find(kvp.Key); - ws.Cells[cell.Row, amountColumn].Value = kvp.Value; + if (cell == null) + { + System.Windows.Forms.MessageBox.Show + ($"Артикул {kvp.Key} отсутствует в таблице заказов {RegistryUtil.PriceListPath}", + "Отсутствует позиция в конечной таблице заказов", + System.Windows.Forms.MessageBoxButtons.OK, + System.Windows.Forms.MessageBoxIcon.Information); + } + else + ws.Cells[cell.Row, amountColumn].Value = kvp.Value; } AutoFilter filter = ws.AutoFilter; From fbe97d706cb87374a469f2e7df5c177877d6616b Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Mon, 3 Jan 2022 13:17:39 +0300 Subject: [PATCH 2/2] Add Excel statusbar message for exported lines count --- src/PriceListTools/PriceList.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PriceListTools/PriceList.cs b/src/PriceListTools/PriceList.cs index e67d573..35b3f7d 100644 --- a/src/PriceListTools/PriceList.cs +++ b/src/PriceListTools/PriceList.cs @@ -40,6 +40,7 @@ namespace RehauSku.PriceListTools int amountColumn = OfferSheet.amountColumn.Value; int skuColumn = OfferSheet.skuColumn.Value; + int exportedValues = 0; foreach (KeyValuePair kvp in values) { @@ -51,9 +52,12 @@ namespace RehauSku.PriceListTools "Отсутствует позиция в конечной таблице заказов", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); - } + } else + { ws.Cells[cell.Row, amountColumn].Value = kvp.Value; + exportedValues++; + } } AutoFilter filter = ws.AutoFilter; @@ -61,6 +65,7 @@ namespace RehauSku.PriceListTools filter.Range.AutoFilter(amountColumn - firstFilterColumn + 1, "<>"); ws.Range["A1"].Activate(); + ws.Application.StatusBar = $"Экспортировано {exportedValues} строк из {values.Count}"; } public class PriceListSheet