//Deletes all job benefits, updates all JobID fields to NULL and deletes all jobs from database private void ClearJobsBtn_Click(object sender, EventArgs e) { DialogResult Dr = MessageBox.Show("You pressed the button to completely clear all your jobs from the database. Are you sure you want to do this?", "Clear Jobs", MessageBoxButtons.YesNo); if (Dr == DialogResult.Yes) { String query = "Delete from [Job Benefits]; " + "Update Employee set JobID = NULL; " + "Delete from Jobs;"; using (connection = new SqlConnection(connectionString)) using (SqlCommand command = new SqlCommand(query, connection)) using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.Hide(); EditEmploy En = new EditEmploy(); En.Show(); } }
//closes the current page and then opens the Edit Employee page when the button is pressed private void EditEmployBeneBtn_Click(object sender, EventArgs e) { this.Hide(); EditEmploy Ee = new EditEmploy(); Ee.Show(); }
//deletes everything in the database private void ClearDatabaseBtn_Click(object sender, EventArgs e) { DialogResult Dr = MessageBox.Show("You pressed the button to completely clear your database of all data. Are you sure you want to do this?", "Clear Database", MessageBoxButtons.YesNo); if (Dr == DialogResult.Yes) { DialogResult dr = MessageBox.Show("Are you completely sure that you wish to clear your database? You cannot retrieve your database and it will be deleted forever", "Clear Database", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { String query = "Delete from [Employee Benefits]; " + "Delete from [Job Benefits]; " + "Delete from Entitlements; " + "Delete from Employee; " + "Delete from Jobs;"; using (connection = new SqlConnection(connectionString)) using (SqlCommand command = new SqlCommand(query, connection)) using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } this.Hide(); EditEmploy En = new EditEmploy(); En.Show(); } } }