Exemplo n.º 1
0
 public CustomParentNode(QView view)
     : base(view.Name)
 {
     this.view = view;
 }
Exemplo n.º 2
0
        //=============Handling item selecting on TreeView=================================//
        private void tvAvailableColumns_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.ForeColor == Color.Purple) //if a node is purple, that means a user select already, simply returns
            {
                return;
            }
            if (e.Node.Parent != null && e.Node.Parent.GetType() == typeof(CustomParentNode)) //if select child node which is column of a table
            {
                CustomParentNode cpn = (CustomParentNode)e.Node.Parent;
                CustomChildNode ccn = (CustomChildNode)e.Node;
                table = cpn.Table;
                view = cpn.View;
                tableFunction = cpn.TableFunction;
                if (view == null && tableFunction == null)
                    tableName = table.Name;
                else if (table == null && tableFunction == null)
                    tableName = view.Name;
                else if (table != null && view == null)
                    tableName = tableFunction.Name;

                index++;
                columnName = ccn.Column.Name;
                alias = ccn.Column.Alias;
                dataType = ccn.Column.DataType;

                populateDataGridView(dgvSelectedColumns);
                e.Node.Parent.ForeColor = Color.Purple;
                e.Node.ForeColor = Color.Purple;

                //-------------------------------------Tricky part here:------------------------------------------------------//
                //check dictionary for values of a given key. If the key has no value, add new value associated with key
                //If the dictionary already has the key, add more values for that key
                List<QColumn> existing;
                if (!sqlFields.TryGetValue(tableName, out existing))
                {
                    existing = new List<QColumn>();
                    sqlFields[tableName] = existing;
                }
                QColumn c = new QColumn(tableName + "." + "[" + columnName + "]", dataType);
                c.Index = index;
                existing.Add(c);
                existing.Sort();
                //-------------------------------------End Tricky part here:------------------------------------------------------//
                //after we populate our dictionary, pull out keys and list of value
                populateSelectedTableList();
                if (selectedColumns.Count == 0)
                {
                    populateSelectedColumnList();
                }
                else
                {
                    QColumn col = new QColumn(tableName + "." + "[" + columnName + "]", dataType);
                    col.Index = index;
                    selectedColumns.Add(col);
                    selectedColumns.Sort();
                }
            }
            else
            {
                tableName = e.Node.Text;
                columnName = "*";
            }
            bindGroupColumns();
            generateSQLStatement();
        }