2021-12-17 09:07:03 +03:00
|
|
|
|
using Microsoft.Win32;
|
2022-12-20 12:27:47 +03:00
|
|
|
|
using RhSolutions.Controllers;
|
|
|
|
|
using RhSolutions.Models;
|
2022-02-01 20:32:29 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2021-12-24 16:22:03 +03:00
|
|
|
|
using System.Windows.Forms;
|
2021-12-17 09:07:03 +03:00
|
|
|
|
|
2022-12-20 12:27:47 +03:00
|
|
|
|
namespace RhSolutions.Services
|
2021-12-17 09:07:03 +03:00
|
|
|
|
{
|
|
|
|
|
static class RegistryUtil
|
|
|
|
|
{
|
2022-01-09 15:47:54 +03:00
|
|
|
|
private static string priceListPath;
|
|
|
|
|
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-12-20 12:27:47 +03:00
|
|
|
|
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
|
2022-01-09 15:47:54 +03:00
|
|
|
|
priceListPath = RootKey.GetValue("PriceListPath") as string;
|
2021-12-17 09:07:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-23 15:31:23 +03:00
|
|
|
|
public static void Uninitialize()
|
|
|
|
|
{
|
2022-12-20 12:27:47 +03:00
|
|
|
|
RootKey.Close();
|
2021-12-23 15:31:23 +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-02-01 20:32:29 +03:00
|
|
|
|
if (string.IsNullOrEmpty(priceListPath) || !File.Exists(priceListPath))
|
2021-12-22 17:07:37 +03:00
|
|
|
|
{
|
2022-02-01 20:32:29 +03:00
|
|
|
|
DialogResult result = MessageBox.Show("Прайс-лист отсутствует или неверный файл шаблона прайс-листа. " +
|
|
|
|
|
"Укажите файл шаблона прайс-листа.",
|
|
|
|
|
"Нет файла шаблона",
|
|
|
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
string fileName = Dialog.GetFilePath();
|
2022-02-02 18:34:32 +03:00
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(fileName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Нет файла шаблона");
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-01 20:32:29 +03:00
|
|
|
|
priceListPath = fileName;
|
|
|
|
|
RootKey.SetValue("PriceListPath", fileName);
|
|
|
|
|
return priceListPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
throw new Exception("Нет файла шаблона");
|
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);
|
2022-02-14 11:06:40 +03:00
|
|
|
|
RibbonController.RefreshControl("setPriceList");
|
2021-12-24 17:42:20 +03:00
|
|
|
|
}
|
2021-12-22 08:26:54 +03:00
|
|
|
|
}
|
2021-12-17 09:07:03 +03:00
|
|
|
|
|
2022-02-14 11:06:40 +03:00
|
|
|
|
public static string GetPriceListName()
|
|
|
|
|
{
|
|
|
|
|
return Path.GetFileName(priceListPath);
|
|
|
|
|
}
|
2021-12-17 09:07:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|