private void btnOK_Click(object sender, RoutedEventArgs e) { Epi.ImportExport.Filters.ConditionJoinTypes op = Epi.ImportExport.Filters.ConditionJoinTypes.And; if (cmbLogicalOperator.SelectedIndex == 2) { op = Epi.ImportExport.Filters.ConditionJoinTypes.Or; } Filters = new RowFilters(this.DataHelper.Database, op); if (Click != null) { if (includeCasesOnly.IsChecked == true) { IncludeCases = true; IncludeCaseExposures = true; IncludeContacts = false; } if (includeCasesContacts.IsChecked == true) { IncludeCases = true; IncludeCaseExposures = true; IncludeContacts = true; } if (checkboxDeidentifyData.IsChecked == true) { DeIdentifyData = true; } else { DeIdentifyData = false; } switch (cmbRecordProcessingScope.SelectedIndex) { case 0: RecordProcessingScope = Epi.RecordProcessingScope.Undeleted; break; case 1: RecordProcessingScope = Epi.RecordProcessingScope.Deleted; break; case 2: RecordProcessingScope = Epi.RecordProcessingScope.Both; break; } // NOTE: Contact-only exports were removed at request of project coordinator... //if (includeContactsOnly.IsChecked == true) //{ // IncludeCases = false; // IncludeCaseExposures = false; // IncludeContacts = true; //} IDbDriver db = this.DataHelper.Database; // data package filters if (checkboxFilterData.IsChecked == true) { string varName1 = cmbVariableName1.Text.Trim(); string value1 = tboxValue1.Text.Trim(); string varName2 = cmbVariableName2.Text.Trim(); string value2 = tboxValue2.Text.Trim(); #region Check to see if user's filtering options make sense if (String.IsNullOrEmpty(varName1) && String.IsNullOrEmpty(value1)) { MessageBox.Show("Neither a variable nor a value have been selected for the first condition. Please ensure both a variable and a value are present before proceeding.", "Missing filter information", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!String.IsNullOrEmpty(varName1) && String.IsNullOrEmpty(value1)) { MessageBox.Show("A variable has been selected for the first condition, but no value has been specified. Please specify a value and try again.", "No value specified", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!String.IsNullOrEmpty(value1) && String.IsNullOrEmpty(varName1)) { MessageBox.Show("A value has been selected for the first condition, but no variable has been specified. Please specify a variable on which to filter and try again.", "No variable specified", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (cmbLogicalOperator.SelectedIndex == 1 && String.IsNullOrEmpty(varName2) && String.IsNullOrEmpty(value2)) { MessageBox.Show("Neither a variable nor a value have been selected for the second condition. Please ensure both a variable and a value are present before proceeding.", "Missing filter information", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (cmbLogicalOperator.SelectedIndex == 1 && !String.IsNullOrEmpty(varName2) && String.IsNullOrEmpty(value2)) { MessageBox.Show("A variable has been selected for the second condition, but no value has been specified. Please specify a value and try again.", "No value specified", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (cmbLogicalOperator.SelectedIndex == 1 && !String.IsNullOrEmpty(value2) && String.IsNullOrEmpty(varName2)) { MessageBox.Show("A value has been selected for the second condition, but no variable has been specified. Please specify a variable on which to filter and try again.", "No variable specified", MessageBoxButton.OK, MessageBoxImage.Error); return; } #endregion if (!String.IsNullOrEmpty(varName1) && !String.IsNullOrEmpty(value1)) { if (cmbOperator1.SelectedIndex == 0) { TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName1 + "] = @" + varName1 + "", "" + varName1 + "", "@" + varName1 + "", value1); tfc.Description = "" + varName1 + " equals " + value1; Filters.Add(tfc); } else { value1 = "%" + value1 + "%"; TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName1 + "] LIKE @" + varName1 + "", "" + varName1 + "", "@" + varName1 + "", value1); tfc.Description = "" + varName1 + " contains " + value1; Filters.Add(tfc); } } if (!String.IsNullOrEmpty(varName2) && !String.IsNullOrEmpty(value2)) { if (cmbOperator2.SelectedIndex == 0) { TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName2 + "] = @" + varName2 + "", "" + varName2 + "", "@" + varName2 + "", value2); tfc.Description = "" + varName2 + " equals " + value2; Filters.Add(tfc); } else { value2 = "%" + value2 + "%"; TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName2 + "] LIKE @" + varName2 + "", "" + varName2 + "", "@" + varName2 + "", value2); tfc.Description = "" + varName2 + " contains " + value2; Filters.Add(tfc); } } } RoutedEventArgs args = new RoutedEventArgs(CaseExportOptions.OkClickEvent); Click(this, args); } }