blob: 54e071e5f98c4a89eb09f4fc918d522e8522c2fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
using Microsoft.Win32;
using RehauSku.Interface;
using System;
using System.IO;
using System.Windows.Forms;
namespace RehauSku
{
static class RegistryUtil
{
private static string priceListPath;
private static RegistryKey RootKey { get; set; }
public static void Initialize()
{
RootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\REHAU\SkuAssist");
priceListPath = RootKey.GetValue("PriceListPath") as string;
}
public static void Uninitialize()
{
RootKey.Close();
}
public static string PriceListPath
{
get
{
if (string.IsNullOrEmpty(priceListPath) || !File.Exists(priceListPath))
{
DialogResult result = MessageBox.Show("Прайс-лист отсутствует или неверный файл шаблона прайс-листа. " +
"Укажите файл шаблона прайс-листа.",
"Нет файла шаблона",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (result == DialogResult.OK)
{
string fileName = Dialog.GetFilePath();
if (string.IsNullOrEmpty(fileName))
{
throw new Exception("Нет файла шаблона");
}
priceListPath = fileName;
RootKey.SetValue("PriceListPath", fileName);
return priceListPath;
}
else
throw new Exception("Нет файла шаблона");
}
else
{
return priceListPath;
}
}
set
{
priceListPath = value;
RootKey.SetValue("PriceListPath", value);
RibbonController.RefreshControl("setPriceList");
}
}
public static string GetPriceListName()
{
return Path.GetFileName(priceListPath);
}
}
}
|