//changes the contents in the textboxes and listboxes when the value in the drop down box changes private void JobBox_SelectedIndexChanged(object sender, EventArgs e) { showSector(); showDescription(); showJobBenefits(); if (RemvBeneList.Items.Count == 0) { RemvBeneBox.Clear(); } }
//Removes the chosen entitlement from the chosen Job private void RemvBeneBtn_Click(object sender, EventArgs e) { if (JobBox.Items.Count > 0) { if (RemvBeneList.Items.Count > 0) { String query = "Delete from [Job Benefits] where JobID = (Select [JobID] from Jobs where [Job Name] = @JobName) and EntitlementID = @EntitlementID"; using (connection = new SqlConnection(connectionString)) using (SqlCommand command = new SqlCommand(query, connection)) using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { connection.Open(); command.Parameters.AddWithValue("@JobName", JobBox.Text); command.Parameters.AddWithValue("@EntitlementID", RemvBeneList.Text); try { command.ExecuteNonQuery(); } catch { } } showJobBenefits(); if (RemvBeneList.Items.Count == 0) { RemvBeneBox.Clear(); } } else { MessageBox.Show("No Benefits to remove"); } } else { MessageBox.Show("No Job to remove benefits from."); } }