public virtual WhereClause CreateWhereClause(String searchText, String fromSearchControl, String AutoTypeAheadSearch, String AutoTypeAheadWordSeparators) { // This CreateWhereClause is used for loading list of suggestions for Auto Type-Ahead feature. UOMTable.Instance.InnerFilter = null; WhereClause wc = new WhereClause(); // Compose the WHERE clause consiting of: // 1. Static clause defined at design time. // 2. User selected search criteria. // 3. User selected filter criteria. String appRelativeVirtualPath = (String)HttpContext.Current.Session["AppRelativeVirtualPath"]; // Adds clauses if values are selected in Filter controls which are configured in the page. String UOMDescriptionFilterSelectedValue = (String)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "UOMDescriptionFilter_Ajax"]; if (MiscUtils.IsValueSelected(UOMDescriptionFilterSelectedValue)) { wc.iAND(UOMTable.UOMDescription, BaseFilter.ComparisonOperator.EqualsTo, UOMDescriptionFilterSelectedValue, false, false); } String UOMNameFilterSelectedValue = (String)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "UOMNameFilter_Ajax"]; if (MiscUtils.IsValueSelected(UOMNameFilterSelectedValue)) { wc.iAND(UOMTable.UOMName, BaseFilter.ComparisonOperator.EqualsTo, UOMNameFilterSelectedValue, false, false); } if (MiscUtils.IsValueSelected(searchText) && fromSearchControl == "UOMSearch") { String formatedSearchText = searchText; // strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored. if (searchText.StartsWith("...")) { formatedSearchText = searchText.Substring(3,searchText.Length-3); } if (searchText.EndsWith("...")) { formatedSearchText = searchText.Substring(0,searchText.Length-3); } // After stripping "...", trim any leading and trailing whitespaces formatedSearchText = formatedSearchText.Trim(); // After stripping "..." see if the search text is null or empty. if (MiscUtils.IsValueSelected(searchText)) { // These clauses are added depending on operator and fields selected in Control's property page, bindings tab. WhereClause search = new WhereClause(); if (StringUtils.InvariantLCase(AutoTypeAheadSearch).Equals("wordsstartingwithsearchstring")) { search.iOR(UOMTable.UOMName, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false); search.iOR(UOMTable.UOMName, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false); search.iOR(UOMTable.UOMDescription, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false); search.iOR(UOMTable.UOMDescription, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false); } else { search.iOR(UOMTable.UOMName, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false); search.iOR(UOMTable.UOMDescription, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false); } wc.iAND(search); } } return wc; }
protected virtual WhereClause CreateWhereClause() { WhereClause whereClause = new WhereClause(); BaseClasses.Data.BaseColumn displayCol = this.GetTable().TableDefinition.ColumnList.GetByAnyName(this.DisplayField); if (MiscUtils.IsValueSelected(this.StartsWith)) { // Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored. if (this.StartsWith.Text.StartsWith("...")) { this.StartsWith.Text = this.StartsWith.Text.Substring(3, this.StartsWith.Text.Length - 3); } if (this.StartsWith.Text.EndsWith("...")) { this.StartsWith.Text = this.StartsWith.Text.Substring(0, this.StartsWith.Text.Length - 3); } this.StartsWith.Text = this.StartsWith.Text.Trim(); if (displayCol != null) { whereClause.iAND(displayCol, BaseFilter.ComparisonOperator.Starts_With, this.StartsWith.Text, true, false); } else { List<BaseClasses.Data.BaseColumn> dfkaColumns = GetDFKAColumns(); WhereClause wc = new WhereClause(); if (dfkaColumns != null) { if (dfkaColumns.Count > 0) { foreach (BaseClasses.Data.BaseColumn col in dfkaColumns) { if (col.ColumnType.Equals(BaseColumn.ColumnTypes.String)) wc.iOR(col, BaseFilter.ComparisonOperator.Starts_With, this.StartsWith.Text, true, false); } whereClause.iAND(wc); } } } } if (MiscUtils.IsValueSelected(this.Contains)) { // Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored. if (this.Contains.Text.StartsWith("...")) { this.Contains.Text = this.Contains.Text.Substring(3, this.Contains.Text.Length - 3); } if (this.StartsWith.Text.EndsWith("...")) { this.Contains.Text = this.Contains.Text.Substring(0, this.Contains.Text.Length - 3); } this.Contains.Text = this.Contains.Text.Trim(); if (displayCol != null) { whereClause.iAND(displayCol, BaseFilter.ComparisonOperator.Contains, this.Contains.Text, true, false); } else { WhereClause wc = new WhereClause(); List<BaseClasses.Data.BaseColumn> dfkaColumns = GetDFKAColumns(); foreach (BaseClasses.Data.BaseColumn col in dfkaColumns) { if (col.ColumnType.Equals(BaseColumn.ColumnTypes.String)) wc.iOR(col, BaseFilter.ComparisonOperator.Contains, this.Contains.Text, true, false); } whereClause.iAND(wc); } } return whereClause; }
public virtual WhereClause CreateWhereClause() { // This CreateWhereClause is used for loading the data. UOMTable.Instance.InnerFilter = null; WhereClause wc = new WhereClause(); // CreateWhereClause() Compose the WHERE clause consiting of: // 1. Static clause defined at design time. // 2. User selected search criteria. // 3. User selected filter criteria. if (MiscUtils.IsValueSelected(this.UOMDescriptionFilter)) { wc.iAND(UOMTable.UOMDescription, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.UOMDescriptionFilter, this.GetFromSession(this.UOMDescriptionFilter)), false, false); } if (MiscUtils.IsValueSelected(this.UOMNameFilter)) { wc.iAND(UOMTable.UOMName, BaseFilter.ComparisonOperator.EqualsTo, MiscUtils.GetSelectedValue(this.UOMNameFilter, this.GetFromSession(this.UOMNameFilter)), false, false); } if (MiscUtils.IsValueSelected(this.UOMSearch)) { // Strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored. if (this.UOMSearch.Text.StartsWith("...")) { this.UOMSearch.Text = this.UOMSearch.Text.Substring(3,this.UOMSearch.Text.Length-3); } if (this.UOMSearch.Text.EndsWith("...")) { this.UOMSearch.Text = this.UOMSearch.Text.Substring(0,this.UOMSearch.Text.Length-3); // Strip the last word as well as it is likely only a partial word int endindex = this.UOMSearch.Text.Length - 1; while (!Char.IsWhiteSpace(UOMSearch.Text[endindex]) && endindex > 0) { endindex--; } if (endindex > 0) { this.UOMSearch.Text = this.UOMSearch.Text.Substring(0, endindex); } } string formatedSearchText = MiscUtils.GetSelectedValue(this.UOMSearch, this.GetFromSession(this.UOMSearch)); // After stripping "..." see if the search text is null or empty. if (MiscUtils.IsValueSelected(this.UOMSearch)) { // These clauses are added depending on operator and fields selected in Control's property page, bindings tab. WhereClause search = new WhereClause(); search.iOR(UOMTable.UOMName, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false); search.iOR(UOMTable.UOMDescription, BaseFilter.ComparisonOperator.Contains, formatedSearchText, true, false); wc.iAND(search); } } return wc; }
// This CreateWhereClause is used for loading list of suggestions for Auto Type-Ahead feature. public virtual WhereClause CreateWhereClause(string searchText, bool bStartsWith, string AutoTypeAheadWordSeparators) { WhereClause wc = new WhereClause(); // Compose the WHERE clause consiting of: // 1. Static clause defined at design time. // 2. User selected filter criteria. // 3. User selected search criteria. string appRelativeVirtualPath = (string)HttpContext.Current.Session["AppRelativeVirtualPath"]; BaseClasses.Data.BaseColumn displayCol = this.GetTable().TableDefinition.ColumnList.GetByAnyName(this.DisplayField); // Adds clauses if values are selected in Filter controls which are configured in the page. if (MiscUtils.IsValueSelected(searchText)) { string formatedSearchText = searchText; // strip "..." from begin and ending of the search text, otherwise the search will return 0 values as in database "..." is not stored. if (searchText.StartsWith("...")) { formatedSearchText = searchText.Substring(3, searchText.Length - 3); } if (searchText.EndsWith("...")) { formatedSearchText = searchText.Substring(0, searchText.Length - 3); } //After stripping "...", trim any leading and trailing whitespaces formatedSearchText = formatedSearchText.Trim(); // These clauses are added depending on operator and fields selected in Control's property page, bindings tab. WhereClause search = new WhereClause(); if (displayCol != null) { if (bStartsWith) { // Search Text specified in Starts With textbox search.iOR(displayCol, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false); } else { // Search Text specified in Contains textbox search.iOR(displayCol, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false); search.iOR(displayCol, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false); } } else { List<BaseClasses.Data.BaseColumn> dfkaColumns = GetDFKAColumns(); foreach (BaseClasses.Data.BaseColumn col in dfkaColumns) { if (col.ColumnType.Equals(BaseColumn.ColumnTypes.String)) { if (bStartsWith) { // Search Text specified in Starts With textbox search.iOR(col, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false); } else { // Search Text specified in Contains textbox search.iOR(col, BaseFilter.ComparisonOperator.Starts_With, formatedSearchText, true, false); search.iOR(col, BaseFilter.ComparisonOperator.Contains, AutoTypeAheadWordSeparators + formatedSearchText, true, false); } } } } wc.iAND(search); } // The Ajax call may come from one of the fields (e.g., StartsWith). But the user may have some text in the other field. // So we need to add the clause for the other field. if (displayCol != null) { if (!(bStartsWith)) { // This was the Contains textbox that was used in Ajax, so add the StartsWith clause. string StartsWithSearchSelectedValue = (string)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "StartsWithSearch_Ajax"]; if (MiscUtils.IsValueSelected(StartsWithSearchSelectedValue)) { wc.iAND(displayCol, BaseFilter.ComparisonOperator.Starts_With, StartsWithSearchSelectedValue, false, false); } } else { // This was the StartsWith textbox that was used in Ajax, so add the Contains clause. string ContainsSelectedValue = (string)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "ContainsSearch_Ajax"]; if (MiscUtils.IsValueSelected(ContainsSelectedValue)) { wc.iAND(displayCol, BaseFilter.ComparisonOperator.Contains, ContainsSelectedValue, false, false); } } } else { List<BaseClasses.Data.BaseColumn> dfkaColumns = GetDFKAColumns(); WhereClause wcAllColumns = new WhereClause(); foreach (BaseClasses.Data.BaseColumn col in dfkaColumns) { if (col.ColumnType.Equals(BaseColumn.ColumnTypes.String)) { if (!(bStartsWith)) { // This was the Contains textbox that was used in Ajax, so add the StartsWith clause. string StartsWithSearchSelectedValue = (string)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "StartsWithSearch_Ajax"]; if (MiscUtils.IsValueSelected(StartsWithSearchSelectedValue)) { wcAllColumns.iOR(col, BaseFilter.ComparisonOperator.Starts_With, StartsWithSearchSelectedValue, false, false); } } else { // This was the StartsWith textbox that was used in Ajax, so add the Contains clause. string ContainsSelectedValue = (string)HttpContext.Current.Session[HttpContext.Current.Session.SessionID + appRelativeVirtualPath + "ContainsSearch_Ajax"]; if (MiscUtils.IsValueSelected(ContainsSelectedValue)) { wcAllColumns.iOR(col, BaseFilter.ComparisonOperator.Contains, ContainsSelectedValue, false, false); } } } } wc.iAND(wcAllColumns); } return wc; }