From b9dbfe96fa9cf37fa575142ad9d0b94d1c130861 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 2 Aug 2014 10:48:14 +0100 Subject: [PATCH] split the initProgram function --- Saviour Backup System/setup.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Saviour Backup System/setup.cs b/Saviour Backup System/setup.cs index 6973b7c..f63e90d 100644 --- a/Saviour Backup System/setup.cs +++ b/Saviour Backup System/setup.cs @@ -1,21 +1,30 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Data.SqlServerCe; +using System.Windows.Forms; namespace Saviour_Backup_System { class setup { - internal static void initProgram(){ - string databaseName = databaseTools.databaseName; - if (File.Exists(databaseName)) { return; } // If the program has been run before, then the database will exist, so use that to test it. + internal static NotifyIcon notifyIcon; + internal static ContextMenu contextMenu; + static string databaseName = databaseTools.databaseName; + internal static void initProgram() + { + //if (!File.Exists(databaseName)) { setupDatabase(); } // If the program has been run before, then the database will exist, so use that to test it. + notificationIcon.init(); + } + + private static void setupDatabase(){ SqlCeEngine SQLEngine = new SqlCeEngine("Data Source = " + databaseName); SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already @@ -31,6 +40,8 @@ namespace Saviour_Backup_System fillDatabase(cmd, conn); } + + private static void fillDatabase(SqlCeCommand cmd, SqlCeConnection conn) { cmd.CommandText = "INSERT INTO Properties VALUES (?,?);"; @@ -46,5 +57,12 @@ namespace Saviour_Backup_System cmd.ExecuteNonQuery(); } + + + internal static void closeProgram(object sender, FormClosingEventArgs e) + { + + notificationIcon.notifyIcon.Dispose(); // + } } }