2021-12-17 09:07:03 +03:00
|
|
|
|
using Microsoft.Win32;
|
2021-12-22 17:07:37 +03:00
|
|
|
|
using System.IO;
|
2021-12-24 16:22:03 +03:00
|
|
|
|
using RehauSku.Forms;
|
|
|
|
|
using System.Windows.Forms;
|
2022-01-09 15:47:54 +03:00
|
|
|
|
using ExcelDna.Integration;
|
2021-12-17 09:07:03 +03:00
|
|
|
|
|
|
|
|
|
namespace RehauSku
|
|
|
|
|
{
|
|
|
|
|
static class RegistryUtil
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
private static string priceListPath;
|
|
|
|
|
private static int? storeResponseOrder;
|
|
|
|
|
private static RegistryKey RootKey { get; set; }
|
2021-12-22 17:07:37 +03:00
|
|
|
|
|
|
|
|
|
public static void Initialize()
|
2021-12-17 09:07:03 +03:00
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
|
|
|
|
|
priceListPath = RootKey.GetValue("PriceListPath") as string;
|
|
|
|
|
storeResponseOrder = RootKey.GetValue("StoreResponseOrder") as int?;
|
2021-12-17 09:07:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-23 15:31:23 +03:00
|
|
|
|
public static void Uninitialize()
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
RootKey.Close();
|
2021-12-23 15:31:23 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 17:07:37 +03:00
|
|
|
|
public static bool IsPriceListPathEmpty()
|
2021-12-17 09:07:03 +03:00
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
return string.IsNullOrEmpty(priceListPath);
|
2021-12-22 08:26:54 +03:00
|
|
|
|
}
|
2021-12-17 09:07:03 +03:00
|
|
|
|
|
2021-12-22 17:07:37 +03:00
|
|
|
|
public static string PriceListPath
|
2021-12-22 08:26:54 +03:00
|
|
|
|
{
|
|
|
|
|
get
|
2021-12-17 09:07:03 +03:00
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
if (IsPriceListPathEmpty() || !File.Exists(priceListPath))
|
2021-12-22 17:07:37 +03:00
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
//MessageBox.Show("Прайс-лист отсутствует или неверный файл прайс-листа", "Укажите файл прайс-листа", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
2021-12-24 16:22:03 +03:00
|
|
|
|
string fileName = Dialog.GetFilePath();
|
2022-01-09 15:47:54 +03:00
|
|
|
|
priceListPath = fileName;
|
|
|
|
|
RootKey.SetValue("PriceListPath", fileName);
|
|
|
|
|
return priceListPath;
|
2021-12-22 17:07:37 +03:00
|
|
|
|
}
|
2021-12-17 09:07:03 +03:00
|
|
|
|
|
2021-12-22 17:07:37 +03:00
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
return priceListPath;
|
2021-12-22 17:07:37 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-24 17:42:20 +03:00
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
priceListPath = value;
|
|
|
|
|
RootKey.SetValue("PriceListPath", value);
|
2021-12-24 17:42:20 +03:00
|
|
|
|
}
|
2021-12-22 08:26:54 +03:00
|
|
|
|
}
|
2021-12-17 09:07:03 +03:00
|
|
|
|
|
2021-12-22 17:07:37 +03:00
|
|
|
|
public static ResponseOrder StoreResponseOrder
|
2021-12-17 09:07:03 +03:00
|
|
|
|
{
|
2021-12-22 17:07:37 +03:00
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
if (storeResponseOrder == null)
|
2021-12-22 17:07:37 +03:00
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
RootKey.SetValue("StoreResponseOrder", (int)ResponseOrder.Default);
|
|
|
|
|
storeResponseOrder = (int)ResponseOrder.Default;
|
|
|
|
|
return (ResponseOrder)storeResponseOrder.Value;
|
2021-12-22 17:07:37 +03:00
|
|
|
|
}
|
2021-12-22 08:26:54 +03:00
|
|
|
|
|
2021-12-22 17:07:37 +03:00
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
return (ResponseOrder)storeResponseOrder.Value;
|
2021-12-22 17:07:37 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-17 09:07:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|