From e6db5f5201d3596af3728616ce4be7e6eb8c20ba Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 9 Nov 2014 16:11:10 +0000 Subject: [PATCH] renamed some classes, and moved code to be more global --- Saviour Backup System/databaseTools.cs | 15 +++++++-------- Saviour Backup System/setup.cs | 6 ++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Saviour Backup System/databaseTools.cs b/Saviour Backup System/databaseTools.cs index d44b8c3..e137d40 100644 --- a/Saviour Backup System/databaseTools.cs +++ b/Saviour Backup System/databaseTools.cs @@ -7,15 +7,16 @@ using System.Data.SqlServerCe; using System.Data; using System.IO; + namespace Saviour_Backup_System { - class database + class databaseTools { internal static string databaseName = "db.sdf"; private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName); private static SqlCeCommand cmd = conn.CreateCommand(); - internal static void setup(){ + internal static void init(){ SqlCeEngine SQLEngine = new SqlCeEngine("Data Source = " + databaseName); SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already SQLEngine.Dispose(); @@ -27,29 +28,27 @@ namespace Saviour_Backup_System conn.Open(); cmd.CommandText = "INSERT INTO Properties VALUES (?,?);"; - cmd.Parameters.Add(new SqlCeParameter("PROPERTY", SqlDbType.Int)); + cmd.Parameters.Add(new SqlCeParameter("PROPERTY", SqlDbType.NText)); cmd.Parameters.Add(new SqlCeParameter("VALUE", SqlDbType.NText)); cmd.Parameters["PROPERTY"].Value = "Startup"; cmd.Parameters["VALUE"].Value = "FALSE"; cmd.ExecuteNonQuery(); - cmd.Parameters["PROPERTY"].Value = "Save_Location"; string saveLocation; - string username = Environment.UserName; switch (OSInfo.Name) { case("Windows XP"): - saveLocation = @"C:\Documents and Settings\" + username + @"\Saviour Backup System\My Backups\"; + saveLocation = @"C:\Documents and Settings\" + setup.username + @"\Saviour Backup System\My Backups\"; break; case("Windows Vista"): - saveLocation = @"C:\Users\" + username + @"\Saviour Backup System\My Backups\"; + saveLocation = @"C:\Users\" + setup.username + @"\Saviour Backup System\My Backups\"; break; default: saveLocation = @"C:\"; break; } - cmd.Parameters["VALUE"].Value = ""; + cmd.Parameters["VALUE"].Value = saveLocation; cmd.ExecuteNonQuery(); cmd.Parameters["PROPERTY"].Value = "Window_Style"; diff --git a/Saviour Backup System/setup.cs b/Saviour Backup System/setup.cs index c5ae69b..ee0ca83 100644 --- a/Saviour Backup System/setup.cs +++ b/Saviour Backup System/setup.cs @@ -13,20 +13,18 @@ namespace Saviour_Backup_System { class setup { - static string databaseName = database.databaseName; + static string databaseName = databaseTools.databaseName; internal static string[] runtimeArguements = null; internal static mainWindow MW; internal static notificationIcon icon; + internal static string username = Environment.UserName; internal static void initProgram(string[] args) { runtimeArguements = args; - icon = new notificationIcon(); MW = new mainWindow(); Application.Run(MW); - - //if (!File.Exists(databaseName)) { setupDatabase(); } // If the program has been run before, then the database will exist, so use that to test it. }