added delete button for records
This commit is contained in:
parent
dd024561d8
commit
b9a5be0b30
2 changed files with 19 additions and 2 deletions
|
@ -65,6 +65,13 @@ namespace Saviour_Backup_System
|
||||||
setup.ABW.ShowDialog();
|
setup.ABW.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void backupViewer_Load(object sender, EventArgs e) { refreshButton.PerformClick(); } //refresh the database view when form loaded
|
private void backupViewer_Load(object sender, EventArgs e) { refreshButton.PerformClick(); }
|
||||||
|
|
||||||
|
private void deleteButton_Click(object sender, EventArgs e) {
|
||||||
|
selectedDriveCreationDate = (Int64)dataGridView.SelectedRows[0].Cells[1].Value;
|
||||||
|
string driveLabel = (string)dataGridView.SelectedRows[0].Cells[0].Value;
|
||||||
|
databaseTools.deleteDriveRecord(selectedDriveCreationDate);
|
||||||
|
MessageBox.Show("Drive '" + driveLabel + "' has been removed.", "Drive Record Removed", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -181,8 +181,18 @@ namespace Saviour_Backup_System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deleteDriveRecord(Int64 creationDate) {
|
||||||
|
conn.Open();
|
||||||
|
cmd.CommandText = "DELETE FROM RecordSet, Drive WHERE Creation_Date=? AND Recordset.Drive_ID = Drive.ID;";
|
||||||
|
cmd.Parameters.Add(new SqlCeParameter("Creation Date", SqlDbType.BigInt));
|
||||||
|
cmd.Parameters["Creation Date"].Value = creationDate;
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
public static void updateDriveRecord(string backupName, string backupLocation, bool automatic, bool compression, int previousBackups, Int64 creationDate)
|
public static void updateDriveRecord(string backupName, string backupLocation, bool automatic, bool compression, int previousBackups, Int64 creationDate)
|
||||||
{;
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
cmd.CommandText = "UPDATE Recordset SET Name=?, Backup_Location=?, Automatic=?, Compression=?, Previous_Backups=? WHERE Creation_Date=?;";
|
cmd.CommandText = "UPDATE Recordset SET Name=?, Backup_Location=?, Automatic=?, Compression=?, Previous_Backups=? WHERE Creation_Date=?;";
|
||||||
cmd.Parameters.Add(new SqlCeParameter("Backup Name", SqlDbType.NText));
|
cmd.Parameters.Add(new SqlCeParameter("Backup Name", SqlDbType.NText));
|
||||||
|
|
Reference in a new issue