//Deletes everything in the job benefits table private void ClearJobBeneBtn_Click(object sender, EventArgs e) { DialogResult Dr = MessageBox.Show("You pressed the button to completely clear all your jobs of their current benefits. Are you sure you want to do this?", "Clear Job Benefits", MessageBoxButtons.YesNo); if (Dr == DialogResult.Yes) { String query = "Delete from [Job Benefits]; "; 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(); EditJob En = new EditJob(); En.Show(); } }
//closes the current page and then opens the Edit Job page when the button is pressed private void EditJobBeneBtn_Click(object sender, EventArgs e) { this.Hide(); EditJob Ee = new EditJob(); 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(); EditJob En = new EditJob(); En.Show(); } } }