if (allStatusCheckBox.Checked != true)
{
if (assComboBox.SelectedIndex != -1 && revComboBox.SelectedIndex != -1)
{
dataSda = new SqlDataAdapter("SELECT DATAACTUALID WHERE ASSIGNEDSTATUS LIKE '" + statusComboBox.SelectedValue + "' AND A_ASSIGNEDTO.EMP_ID LIKE '" + assComboBox.SelectedValue + "%' AND A_TOBEREVIEWEDBY.EMP_ID LIKE '" + revComboBox.SelectedValue + "%'", patientCon);
}
else if (assComboBox.SelectedIndex != -1 && revComboBox.SelectedIndex == -1)
{
dataSda = new SqlDataAdapter("SELECT DATAACTUALID WHERE ASSIGNEDSTATUS LIKE '" + statusComboBox.SelectedValue + "' AND A_ASSIGNEDTO.EMP_ID LIKE '" + assComboBox.SelectedValue + "%'", patientCon);
}
else if (assComboBox.SelectedIndex == -1 && revComboBox.SelectedIndex != -1)
{
dataSda = new SqlDataAdapter("SELECT DATAACTUALID WHERE ASSIGNEDSTATUS LIKE '" + statusComboBox.SelectedValue + "' AND A_TOBEREVIEWEDBY.EMP_ID LIKE '" + revComboBox.SelectedValue + "%'", patientCon);
}
else
{
dataSda = new SqlDataAdapter("SELECT DATAACTUALID WHERE ASSIGNEDSTATUS LIKE '" + statusComboBox.SelectedValue + "'", patientCon);
}
}
else
{
//REPEAT WITHOUT STATUSCOMBOX.SELECTED VALUE
}
Basically the point of this code is to display some information based on whether certain filters have been applied. However with my current approach every time I apply a new filter my number of if statements is growing exponentially. I am worried my code will soon become slow and hard to manage as I apply more filters. Is there a better way of achieving the same results?