1
Fork 0

Removed database tools from setup

This commit is contained in:
Jake Howard 2014-11-07 00:39:59 +00:00
parent f37b56515a
commit 13f8ded5b9

View file

@ -6,7 +6,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Data.SqlServerCe;
using System.Windows.Forms;
@ -14,10 +13,11 @@ namespace Saviour_Backup_System
{
class setup
{
static string databaseName = databaseTools.databaseName;
static string databaseName = database.databaseName;
internal static string[] runtimeArguements = null;
internal static mainWindow MW;
internal static notificationIcon icon;
internal static void initProgram(string[] args)
{
runtimeArguements = args;
@ -29,41 +29,7 @@ namespace Saviour_Backup_System
//if (!File.Exists(databaseName)) { setupDatabase(); } // If the program has been run before, then the database will exist, so use that to test it.
}
private static void setupDatabase(){
SqlCeEngine SQLEngine = new SqlCeEngine("Data Source = " + databaseName);
SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already
SQLEngine.Dispose();
SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName);
conn.Open();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "CREATE TABLE Rules (%%);"; //Fill these in! (Before running)
cmd.ExecuteNonQuery();
cmd.CommandText = "CREATE TABLE Properties (Property NTEXT PRIMARY KEY, value NTEXT);"; //Fill this one in too
cmd.ExecuteNonQuery();
fillDatabase(cmd, conn);
}
private static void fillDatabase(SqlCeCommand cmd, SqlCeConnection conn)
{
cmd.CommandText = "INSERT INTO Properties VALUES (?,?);";
cmd.Parameters.Add(new SqlCeParameter("PROPERTY", SqlDbType.Int));
cmd.Parameters.Add(new SqlCeParameter("VALUE", SqlDbType.NText));
cmd.Parameters["PROPERTY"].Value = "Startup";
cmd.Parameters["VALUE"].Value = "FALSE";
cmd.ExecuteNonQuery();
cmd.Parameters["PROPERTY"].Value = "";
cmd.Parameters["VALUE"].Value = "";
cmd.ExecuteNonQuery();
}
internal static void closeProgram()
{