- Timestamp:
- Aug 12, 2019, 12:33:47 PM (5 years ago)
- Location:
- Common
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Database.cs
r7 r8 28 28 public delegate void LogMessageHandler(string text); 29 29 public static event LogMessageHandler LogMessage; 30 public static string connectionString = "";31 30 public static string databaseName = ""; 32 31 public static string serverName = ""; … … 40 39 41 40 // Connect to server 42 if (type == DatabaseType.MsSql)43 {44 connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";45 } else46 41 if (type == DatabaseType.SQLite) 47 42 { 48 43 Directory.CreateDirectory(Path.GetDirectoryName(sqliteFileName)); 49 connectionString = "Data Source=" + sqliteFileName + "; Version=3";50 44 databaseName = null; 51 45 } … … 62 56 { 63 57 // database does not exist, try to create it 64 connectionString = "server=" + serverName + "; Trusted_Connection=yes; connection timeout=5";65 58 ExecuteNonQuery("CREATE DATABASE " + databaseName); 66 59 67 60 // Need to wait for the new DB startup in order to continue and be sure it can be accessed 68 61 if (connection is SqlConnection) SqlConnection.ClearAllPools(); 69 70 connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";71 62 } 72 63 else … … 87 78 88 79 return result; 80 } 81 82 public static string GetConnectionString() 83 { 84 string connectionString = ""; 85 if (type == DatabaseType.MsSql) 86 { 87 connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5"; 88 } 89 else 90 if (type == DatabaseType.SQLite) 91 { 92 connectionString = "Data Source=" + sqliteFileName + "; Version=3"; 93 } 94 return connectionString; 89 95 } 90 96 … … 105 111 { 106 112 DbConnection connection = GetFactory().CreateConnection(); 107 connection.ConnectionString = connectionString;113 connection.ConnectionString = GetConnectionString(); 108 114 return connection; 109 115 } -
Common/Prompt.cs
r6 r8 21 21 StartPosition = FormStartPosition.CenterScreen, 22 22 }; 23 Label textLabel = new Label() { Left = 50, Top = 20, Text = text };23 Label textLabel = new Label() { Left = 50, Top = 20, AutoSize = true, Text = text }; 24 24 TextBox textBox = new TextBox() { Left = 50, Top = 44, Width = 400, Text = initialValue }; 25 25 textBox.SelectAll(); … … 216 216 StartPosition = FormStartPosition.CenterScreen, 217 217 }; 218 Label textLabel = new Label() { Left = 50, Top = 20, Text = text };218 Label textLabel = new Label() { Left = 50, Top = 20, AutoSize = true, Text = text }; 219 219 RichTextBox textBox = new RichTextBox() { Left = 50, Top = 44, Width = 400, Height = dataSize, Text = initialValue }; 220 220 textBox.SelectAll(); -
Common/Registry.cs
r2 r8 35 35 } 36 36 37 public static float GetValueFloat(this RegistryKey regKey, string name, float defaultValue) 38 { 39 object value = regKey.GetValue(name, defaultValue); 40 float num; 41 if (float.TryParse((string)value, out num)) 42 return num; 43 else return defaultValue; 44 } 45 37 46 public static void SetValueBool(this RegistryKey regKey, string name, bool value) 38 47 { … … 50 59 regKey.SetValue(name, value); 51 60 } 61 62 public static void SetValueFloat(this RegistryKey regKey, string name, float value) 63 { 64 regKey.SetValue(name, value); 65 } 52 66 } 53 67 }
Note:
See TracChangeset
for help on using the changeset viewer.