Example #1
0
        private void TestButton_Click(object sender, EventArgs e)
        {
            if (FilterPanel.Controls.Count > 0)
            {
                DataGridView    grid         = ResultView;
                string          tableName    = "";
                string          columnName   = "";
                string          operation    = "";
                string          value        = "";
                List <string[]> whereClauses = new List <string[]>();

                foreach (InitialFilter item in FilterPanel.Controls.OfType <InitialFilter>())
                {
                    tableName  = item.TableBoxText;
                    columnName = item.ColumnBoxText;
                    operation  = item.OpBoxText;
                    value      = item.ValueBoxText;


                    // Adjusting for string query LIKE % %
                    if (SearchBL.IsColumnTypeString(item.TableBoxText, item.ColumnBoxText))
                    {
                        value = "%" + item.ValueBoxText + "%";
                    }

                    SearchBL.GetResultSetWithWhereClauses(grid, tableName, columnName, operation, value, whereClauses);
                }

                if (FilterPanel.Controls.Count > 1)
                {
                    foreach (ExtraFilter exFilter in FilterPanel.Controls.OfType <ExtraFilter>())
                    {
                        string[] whereArguments = new string[4];
                        whereArguments[0] = exFilter.ExLogicalBoxText; // AND or OR
                        whereArguments[1] = exFilter.ExColumnBoxText;  // Column
                        whereArguments[2] = exFilter.ExOpBoxText;      // Operator
                        whereArguments[3] = exFilter.ExValueBoxText;   // Value


                        // Adjusting for string query LIKE % %
                        if (SearchBL.IsColumnTypeString(tableName, whereArguments[1]))
                        {
                            whereArguments[3] = "%" + whereArguments[3] + "%";
                        }

                        whereClauses.Add(whereArguments);
                    }
                    SearchBL.GetResultSetWithWhereClauses(grid, tableName, columnName, operation, value, whereClauses);
                }
            }
        }