renamed some classes, and moved code to be more global
This commit is contained in:
parent
d0ad8170e8
commit
e6db5f5201
2 changed files with 9 additions and 12 deletions
|
@ -7,15 +7,16 @@ using System.Data.SqlServerCe;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
|
||||||
namespace Saviour_Backup_System
|
namespace Saviour_Backup_System
|
||||||
{
|
{
|
||||||
class database
|
class databaseTools
|
||||||
{
|
{
|
||||||
internal static string databaseName = "db.sdf";
|
internal static string databaseName = "db.sdf";
|
||||||
private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName);
|
private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName);
|
||||||
private static SqlCeCommand cmd = conn.CreateCommand();
|
private static SqlCeCommand cmd = conn.CreateCommand();
|
||||||
|
|
||||||
internal static void setup(){
|
internal static void init(){
|
||||||
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
|
||||||
SQLEngine.Dispose();
|
SQLEngine.Dispose();
|
||||||
|
@ -27,29 +28,27 @@ namespace Saviour_Backup_System
|
||||||
conn.Open();
|
conn.Open();
|
||||||
|
|
||||||
cmd.CommandText = "INSERT INTO Properties VALUES (?,?);";
|
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.Add(new SqlCeParameter("VALUE", SqlDbType.NText));
|
||||||
|
|
||||||
cmd.Parameters["PROPERTY"].Value = "Startup";
|
cmd.Parameters["PROPERTY"].Value = "Startup";
|
||||||
cmd.Parameters["VALUE"].Value = "FALSE";
|
cmd.Parameters["VALUE"].Value = "FALSE";
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
cmd.Parameters["PROPERTY"].Value = "Save_Location";
|
cmd.Parameters["PROPERTY"].Value = "Save_Location";
|
||||||
string saveLocation;
|
string saveLocation;
|
||||||
string username = Environment.UserName;
|
|
||||||
switch (OSInfo.Name)
|
switch (OSInfo.Name)
|
||||||
{
|
{
|
||||||
case("Windows XP"):
|
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;
|
break;
|
||||||
case("Windows Vista"):
|
case("Windows Vista"):
|
||||||
saveLocation = @"C:\Users\" + username + @"\Saviour Backup System\My Backups\";
|
saveLocation = @"C:\Users\" + setup.username + @"\Saviour Backup System\My Backups\";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
saveLocation = @"C:\";
|
saveLocation = @"C:\";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmd.Parameters["VALUE"].Value = "";
|
cmd.Parameters["VALUE"].Value = saveLocation;
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
cmd.Parameters["PROPERTY"].Value = "Window_Style";
|
cmd.Parameters["PROPERTY"].Value = "Window_Style";
|
||||||
|
|
|
@ -13,20 +13,18 @@ namespace Saviour_Backup_System
|
||||||
{
|
{
|
||||||
class setup
|
class setup
|
||||||
{
|
{
|
||||||
static string databaseName = database.databaseName;
|
static string databaseName = databaseTools.databaseName;
|
||||||
internal static string[] runtimeArguements = null;
|
internal static string[] runtimeArguements = null;
|
||||||
internal static mainWindow MW;
|
internal static mainWindow MW;
|
||||||
internal static notificationIcon icon;
|
internal static notificationIcon icon;
|
||||||
|
internal static string username = Environment.UserName;
|
||||||
|
|
||||||
internal static void initProgram(string[] args)
|
internal static void initProgram(string[] args)
|
||||||
{
|
{
|
||||||
runtimeArguements = args;
|
runtimeArguements = args;
|
||||||
|
|
||||||
icon = new notificationIcon();
|
icon = new notificationIcon();
|
||||||
MW = new mainWindow();
|
MW = new mainWindow();
|
||||||
Application.Run(MW);
|
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.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue