ChrisCompleteCodeTrunk
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
namespace Action_Tire_Payment_Processor
{
public static class Settings
{
public static FileInfo ConfigFile;
//public static SQLiteConnection sql;
public static bool ConfigFileRelative = bool.Parse(ConfigurationManager.AppSettings["Config Relative"]);
public static string ConfigFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"BBDS Solutions\ATPP");//ConfigurationManager.AppSettings["Config File"];
public static void Init()
{
//if (!Directory.Exists(ConfigFilePath))
//{
// Directory.CreateDirectory(ConfigFilePath);
//}
////if (ConfigFileRelative)
////{
//string path = Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "settings");
//// ConfigFile = new FileInfo(path);
////}
////else
////{
//if (File.Exists(path) && !File.Exists(Path.Combine(ConfigFilePath, "settings")))
//{
// File.Copy(path, Path.Combine(ConfigFilePath, "settings"));
//}
//ConfigFile = new FileInfo(Path.Combine(ConfigFilePath, "settings"));
////}
//sql = new SQLiteConnection("Data Source=" + ConfigFile.FullName + ";Version=3;UseUTF16Encoding=True;");
//sql.ParseViaFramework = true;
//InitDB();
}
public static void InitDB()
{
//try
//{
// string query = "CREATE TABLE IF NOT EXISTS Option(Name TEXT PRIMARY KEY, Value TEXT);";
// sql.Open();
// SQLiteCommand cmd = new SQLiteCommand(query, sql);
// cmd.ExecuteNonQuery();
// sql.Close();
//}
//catch (Exception ex)
//{
// try { sql.Close(); }
// catch { }
// throw ex;
//}
//sql.Open();
}
public static void SetOption(string name, string value)
{
// Open App.Config of executable
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Add an Application Setting.
if (config.AppSettings.Settings[name] != null)
config.AppSettings.Settings[name].Value = value;
else
config.AppSettings.Settings.Add(name, value);
// Save the configuration file.
config.Save(ConfigurationSaveMode.Modified, true);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
}
public static string GetOption(string name)
{
if (ConfigurationManager.AppSettings[name] == null) SetOption(name, "");
string ret = ConfigurationManager.AppSettings[name].ToString();
return ret;
}
public static string GetPrinterNameToUse()
{
string ret = "";
bool local = false;
bool.TryParse(Settings.GetOption("USEDEFAULTPRINTER"), out local);
if (local)
{
//get default printer here
PrinterSettings settings = new PrinterSettings();
ret = settings.PrinterName;
}
else
{
ret = Settings.GetOption("DEFAULTLOCALPRINTER").ToString();
}
return ret;
}
}
}
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|