1
Fork 0

split the initProgram function

This commit is contained in:
Jake Howard 2014-08-02 10:48:14 +01:00
parent 213b4eb226
commit b9dbfe96fa

View file

@ -1,21 +1,30 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.IO; using System.IO;
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using System.Windows.Forms;
namespace Saviour_Backup_System namespace Saviour_Backup_System
{ {
class setup class setup
{ {
internal static void initProgram(){ internal static NotifyIcon notifyIcon;
string databaseName = databaseTools.databaseName; internal static ContextMenu contextMenu;
if (File.Exists(databaseName)) { return; } // If the program has been run before, then the database will exist, so use that to test it. 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); SqlCeEngine SQLEngine = new SqlCeEngine("Data Source = " + databaseName);
SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already
@ -31,6 +40,8 @@ namespace Saviour_Backup_System
fillDatabase(cmd, conn); fillDatabase(cmd, conn);
} }
private static void fillDatabase(SqlCeCommand cmd, SqlCeConnection conn) private static void fillDatabase(SqlCeCommand cmd, SqlCeConnection conn)
{ {
cmd.CommandText = "INSERT INTO Properties VALUES (?,?);"; cmd.CommandText = "INSERT INTO Properties VALUES (?,?);";
@ -46,5 +57,12 @@ namespace Saviour_Backup_System
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
internal static void closeProgram(object sender, FormClosingEventArgs e)
{
notificationIcon.notifyIcon.Dispose(); //
}
} }
} }