diff options
author | Serghei Cebotari <51533848+schebotar@users.noreply.github.com> | 2021-12-26 19:37:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-26 19:37:46 +0300 |
commit | fc870d19555cc77b0e08912b4dab21d496b2321f (patch) | |
tree | ac8b9aa1e883a85339a594b2797ab319cca73c4e /src/PriceListTools/PriceListUtil.cs | |
parent | 0525ec1b42d5857b740dd0dae7f6d9baeb7088d1 (diff) | |
parent | 54fc3320e7d64d7903b4d091fe0d5c15df01fd78 (diff) |
Merge pull request #9 from schebotar/dev
Move to /src
Diffstat (limited to 'src/PriceListTools/PriceListUtil.cs')
-rw-r--r-- | src/PriceListTools/PriceListUtil.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/PriceListTools/PriceListUtil.cs b/src/PriceListTools/PriceListUtil.cs new file mode 100644 index 0000000..14797d9 --- /dev/null +++ b/src/PriceListTools/PriceListUtil.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.IO; + +namespace RehauSku.PriceListTools +{ + static class PriceListUtil + { + public static string CreateNewExportFile() + { + string fileExtension = Path.GetExtension(RegistryUtil.PriceListPath); + string path = Path.GetTempFileName() + fileExtension; + + File.Copy(RegistryUtil.PriceListPath, path); + return path; + } + + public static void AddValues(this Dictionary<string, double> SkuAmount, PriceList priceList) + { + object[,] amountCells = priceList.ActiveSheet.amountCells; + object[,] skuCells = priceList.ActiveSheet.skuCells; + + for (int row = priceList.ActiveSheet.headerRow.Value + 1; row < amountCells.GetLength(0); row++) + { + object amount = amountCells[row, 1]; + object sku = skuCells[row, 1]; + + if (amount != null && (double)amount != 0) + { + if (SkuAmount.ContainsKey(sku.ToString())) + { + SkuAmount[sku.ToString()] += (double)amount; + } + + else + SkuAmount.Add(sku.ToString(), (double)amount); + } + } + } + } +} + |