// // GridCellValueChanging event allows to prevent the cell value changing or modify the new cell value. // Note: Some columns hide/unhide dynamically but this does not affect the column index in the event parameters - // it includes hidden columns. // private void queryBuilder1_GridCellValueChanging(UnionSubQuery unionSubQuery, QueryColumnList criteriaList, QueryColumnListItem criteriaItem, int column, int row, object oldValue, ref object newValue, ref bool abort) private void QBuilder_QueryColumnListItemChanging(QueryColumnList queryColumnList, QueryColumnListItem queryColumnListItem, QueryColumnListItemProperty property, int conditionIndex, object oldValue, ref object newValue, ref bool abort) { if (!CbQueryColumnListItemChanging.Checked) { return; } AddRowToReport("QueryColumnListItemChanging. Changes column \"" + property + "\""); if (property == QueryColumnListItemProperty.Expression) // Prevent changes in the Expression column. { abort = true; } else if (property == QueryColumnListItemProperty.Alias) // Alias column. Lets add the underscore char in the beginning of all aliases, for example. { if (newValue != null && newValue is string) { var s = (string)newValue; if (s.Length > 0 && !s.StartsWith("_")) { s = "_" + s; newValue = s; } } } }
public static void DumpSelectedExpressionsInfoFromUnionSubQuery(StringBuilder stringBuilder, UnionSubQuery unionSubQuery) { // get list of CriteriaItems QueryColumnList criteriaList = unionSubQuery.QueryColumnList; // dump all items for (int i = 0; i < criteriaList.Count; i++) { QueryColumnListItem criteriaItem = criteriaList[i]; // only items have .Select property set to True goes to SELECT list if (!criteriaItem.Selected) { continue; } // separator if (stringBuilder.Length > 0) { stringBuilder.AppendLine(); } DumpSelectedExpressionInfo(stringBuilder, criteriaItem); DumpSelectedExpressionsStatistics(stringBuilder, criteriaItem); } }
private void AddWhereCondition(QueryColumnList columnList, QueryColumnListItem whereListItem, string condition) { bool whereFound = false; // GetMaxConditionCount: returns the number of non-empty criteria columns in the grid. for (int i = 0; i < columnList.GetMaxConditionCount(); i++) { // CollectCriteriaItemsWithWhereCondition: // This function returns the list of conditions that were found in // the i-th criteria column, applied to specific clause (WHERE or HAVING). // Thus, this function collects all conditions joined with AND // within one OR group (one grid column). List<QueryColumnListItem> foundColumnItems = new List<QueryColumnListItem>(); CollectCriteriaItemsWithWhereCondition(columnList, i, foundColumnItems); // if found some conditions in i-th column, append condition to i-th column if (foundColumnItems.Count > 0) { whereListItem.ConditionStrings[i] = condition; whereFound = true; } } // if there are no cells with "where" conditions, add condition to new column if (!whereFound) { whereListItem.ConditionStrings[columnList.GetMaxConditionCount()] = condition; } }
public string DumpSelectedExpressionsInfoFromUnionSubQuery(UnionSubQuery unionSubQuery) { var stringBuilder = new StringBuilder(); // get list of CriteriaItems QueryColumnList criteriaList = unionSubQuery.QueryColumnList; // dump all items for (int i = 0; i < criteriaList.Count; i++) { QueryColumnListItem criteriaItem = criteriaList[i]; // only items have .Select property set to True goes to SELECT list if (!criteriaItem.Select) { continue; } // separator if (stringBuilder.Length > 0) { stringBuilder.AppendLine("<br />"); } DumpSelectedExpressionInfo(stringBuilder, criteriaItem); } return(stringBuilder.ToString()); }
private void ClearWhere(UnionSubQuery unionSubQuery) { // get reference to QueryColumnList QueryColumnList cl = unionSubQuery.QueryColumnList; // disable SQL updating for QueryBuilder queryBuilder1.BeginUpdate(); try { // clear old Where for (int i = 0; i < cl.Count; i++) { QueryColumnListItem ci = cl[i]; if (ci.ConditionType == ConditionType.Where) { // clear all WHERE expressions in a row for (int j = 0; j < ci.ConditionCount; j++) { ci.ConditionStrings[j] = ""; } } } } finally { queryBuilder1.EndUpdate(); } }
private void QBuilder_QueryColumnListItemChanged(QueryColumnList queryColumnList, QueryColumnListItem queryColumnListItem, QueryColumnListItemProperty property, int conditionIndex, object newValue) { if (CbQueryColumnListItemChanged.Checked != true) { return; } AddRowToReport("QueryColumnListItemChanged property \"" + property + "\" changed"); }
private void QBuilder_OnQueryColumnListItemChanged(QueryColumnList querycolumnlist, QueryColumnListItem querycolumnlistitem, QueryColumnListItemProperty property, int conditionindex, object newvalue) { if (CbQueryColumnListItemChanged.IsChecked != true) { return; } BoxLogEvents.Text = "QueryColumnListItemChanged property \"" + property + "\" changed" + Environment.NewLine + BoxLogEvents.Text; }
private void CollectCriteriaItemsWithWhereCondition(QueryColumnList criteriaList, int columnIndex, IList<QueryColumnListItem> result) { result.Clear(); foreach (var item in criteriaList) { if (item.ConditionType == ConditionType.Where && item.ConditionCount > columnIndex && item.GetASTCondition(columnIndex) != null) { result.Add(item); } } }
private void CollectCriteriaItemsWithWhereCondition(QueryColumnList criteriaList, int columnIndex, IList <QueryColumnListItem> result) { result.Clear(); for (int i = 0; i < criteriaList.Count; i++) { if (criteriaList[i].ConditionType == ConditionType.Where && criteriaList[i].ConditionCount > columnIndex && criteriaList[i].GetASTCondition(columnIndex) != null) { result.Add(criteriaList[i]); } } }
// // GridCellValueChanging event allows to prevent the cell value changing or modify the new cell value. // Note: Some columns hide/unhide dynamically but this does not affect the column index in the event parameters - // it includes hidden columns. // private void QBuilder_OnQueryColumnListItemChanging(QueryColumnList querycolumnlist, QueryColumnListItem querycolumnlistitem, QueryColumnListItemProperty property, int conditionindex, object oldvalue, ref object newValue, ref bool abort) { if (CbQueryColumnListItemChanging.IsChecked != true) { return; } BoxLogEvents.Text = "QueryColumnListItemChanging Changing the value for property \"" + property + "\"" + Environment.NewLine + BoxLogEvents.Text; if (property == QueryColumnListItemProperty.Expression) // Prevent changes in the Expression column. { abort = true; return; } if (property != QueryColumnListItemProperty.Alias) { return; } var s = newValue as string; if (s == null) { return; } if (s.Length <= 0 || s.StartsWith("_")) { return; } s = "_" + s; newValue = s; }
private void QueryBuilder1_QueryColumnListItemChanging(QueryColumnList queryColumnList, QueryColumnListItem queryColumnListItem, QueryColumnListItemProperty property, int conditionIndex, object oldValue, ref object newValue, ref bool abort) { }