1
Fork 0

added more verification and prepared for database addition

This commit is contained in:
Jake Howard 2014-11-25 22:20:37 +00:00
parent d5a54ade15
commit 812d63858b

View file

@ -8,6 +8,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO; using System.IO;
using System.Data.SqlServerCe;
namespace Saviour_Backup_System namespace Saviour_Backup_System
{ {
@ -41,8 +42,12 @@ namespace Saviour_Backup_System
} }
} }
private void createButton_Click(object sender, EventArgs e) private void createButton_Click(object sender, EventArgs e) {
{ if ((folderPath.Text == "") || (previousBackupInput.Text == "") || (compressionTypeDropdown.Text == "") || (drivesDropdown.Text == "")){
MessageBox.Show("You have not filled in every element, Please try again!", "Not everything is complete", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
statusProgress.Text = "Initialising..."; statusProgress.Text = "Initialising...";
int initHeight = 299; int initHeight = 299;
while (this.Size.Height != 330) { while (this.Size.Height != 330) {
@ -50,36 +55,41 @@ namespace Saviour_Backup_System
this.Size = new Size(583, initHeight); this.Size = new Size(583, initHeight);
Thread.Sleep(10); Thread.Sleep(10);
} }
try { //check validity of input from user
if ((folderPath.Text == "") || (previousBackupInput.Text == "") || (compressionTypeDropdown.Text == "") || (drivesDropdown.Text == "")){ statusProgress.Text = "Checking form...";
MessageBox.Show("You have not filled in every element, Please try again!", "Not everything is complete", MessageBoxButtons.OK, MessageBoxIcon.Error); if (!Directory.Exists(folderPath.Text)) {
return; DialogResult result = MessageBox.Show("The folder path you have entered doesnt exist, would you like to create it?", "Create Folder", MessageBoxButtons.YesNo);
} if (result == DialogResult.Yes) {
try { Directory.CreateDirectory(folderPath.Text);
} catch {
if (!Directory.Exists(folderPath.Text) { MessageBox.Show("Error Creating Folder! Please check the path and try agian.", "Error creating folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
DialogResult result = MessageBox.Show("The folder path you have entered doesnt exist, would you like to create it?", "Create Folder", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes){
try{
Directory.CreateDirectory(folderPath.Text);
} catch{
MessageBox.Show("Error Creating Folder!");
return;
}
} else {
return;
} }
} }
} finally {
while (this.Size.Height != 299) {
initHeight--;
this.Size = new Size(583, initHeight);
Thread.Sleep(10);
}
statusProgress.ResetText();
statusProgress.Value = 0;
} }
else if (compressionTypeDropdown.Text == "None" && unifiedFileSwitch.Value == true) {
MessageBox.Show("You cannot have a unified file without some form of compression, please select again.", "Compression Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
createRecord();
}
while (this.Size.Height != 299) {
initHeight--;
this.Size = new Size(583, initHeight);
Thread.Sleep(10);
}
}
private void createRecord()
{
SqlCeConnection conn = databaseTools.conn;
SqlCeCommand cmd = conn.CreateCommand();
conn.Open();
conn.Close();
MessageBox.Show("Record created successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
} }
} }