コード例 #1
0
        // update table tree to reflect new connection string
        private void UpdateTableTree()
        {
            // initialize table tree
            NGTreeNode rootNode = new NGTreeNodeWithImageIndex();
            var        ndTables = new NGTreeNodeWithImageIndex {
                Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0
            };
            var ndViews = new NGTreeNodeWithImageIndex {
                Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1
            };

            // populate using current schema
            if (Schema != null)
            {
                // populate the tree
                foreach (System.Data.DataTable dt in Schema.Tables)
                {
                    // create new node, save table in tag property
                    var node = new NGTreeNodeWithImageIndex {
                        Text = dt.TableName
                    };
                    node.Tag = dt;

                    // add new node to appropriate parent
                    switch (OleDbSchema.GetTableType(dt))
                    {
                    case TableType.Table:
                        ndTables.Nodes.Add(node);
                        node.ImageIndex = node.SelectedImageIndex = 0;
                        AddDataColumns(node, dt);
                        break;

                    case TableType.View:
                        ndViews.Nodes.Add(node);
                        node.ImageIndex = node.SelectedImageIndex = 1;
                        AddDataColumns(node, dt);
                        break;
                    }
                }

                // add non-empty nodes to tree
                foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews })
                {
                    if (nd.Nodes.Count > 0)
                    {
                        nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count);
                        rootNode.Nodes.Add(nd);
                    }
                }

                // expand tables node
                ndTables.IsExpanded = true;

                _treeTableNodes = rootNode;
                if (null != _view)
                {
                    _view.SetTableTreeDataSource(_treeTableNodes);
                }
            }
        }
コード例 #2
0
 private void AddDataColumns(NGTreeNode node, System.Data.DataTable dt)
 {
     foreach (System.Data.DataColumn col in dt.Columns)
     {
         var field = new NGTreeNodeWithImageIndex {
             Text = col.ColumnName
         };
         field.Tag                = col;
         field.ImageIndex         = 3;
         field.SelectedImageIndex = 3;
         node.Nodes.Add(field);
     }
 }
コード例 #3
0
		private void AddDataColumns(NGTreeNode node, System.Data.DataTable dt)
		{
			foreach (System.Data.DataColumn col in dt.Columns)
			{
				var field = new NGTreeNodeWithImageIndex { Text = col.ColumnName };
				field.Tag = col;
				field.ImageIndex = 3;
				field.SelectedImageIndex = 3;
				node.Nodes.Add(field);
			}
		}
コード例 #4
0
		// update table tree to reflect new connection string
		private void UpdateTableTree()
		{
			// initialize table tree
			NGTreeNode rootNode = new NGTreeNodeWithImageIndex();
			var ndTables = new NGTreeNodeWithImageIndex { Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0 };
			var ndViews = new NGTreeNodeWithImageIndex { Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1 };

			// populate using current schema
			if (Schema != null)
			{
				// populate the tree
				foreach (System.Data.DataTable dt in Schema.Tables)
				{
					// create new node, save table in tag property
					var node = new NGTreeNodeWithImageIndex { Text = dt.TableName };
					node.Tag = dt;

					// add new node to appropriate parent
					switch (OleDbSchema.GetTableType(dt))
					{
						case TableType.Table:
							ndTables.Nodes.Add(node);
							node.ImageIndex = node.SelectedImageIndex = 0;
							AddDataColumns(node, dt);
							break;

						case TableType.View:
							ndViews.Nodes.Add(node);
							node.ImageIndex = node.SelectedImageIndex = 1;
							AddDataColumns(node, dt);
							break;
					}
				}

				// add non-empty nodes to tree
				foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews })
				{
					if (nd.Nodes.Count > 0)
					{
						nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count);
						rootNode.Nodes.Add(nd);
					}
				}

				// expand tables node
				ndTables.IsExpanded = true;

				_treeTableNodes = rootNode;
				if (null != _view)
					_view.SetTableTreeDataSource(_treeTableNodes);
			}
		}
コード例 #5
0
        private void UpdateTableTree()
        {
            // initialize table tree
            var nodes = _treeRootNode.Nodes;

            nodes.Clear();
            var ndTables = new NGTreeNodeWithImageIndex()
            {
                Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0
            };
            var ndViews = new NGTreeNodeWithImageIndex()
            {
                Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1
            };
            var ndProcs = new NGTreeNodeWithImageIndex()
            {
                Text = Current.ResourceService.GetString("Gui.DataConnection.StoredProcedures"), ImageIndex = 2, SelectedImageIndex = 2
            };

            // populate using current schema
            if (_schema != null)
            {
                // populate the tree
                foreach (System.Data.DataTable dt in _schema.Tables)
                {
                    // create new node, save table in tag property
                    var node = new NGTreeNodeWithImageIndex()
                    {
                        Text = dt.TableName
                    };
                    node.Tag = dt;
                    if (IsTableNameIdentical(dt.TableName, TableName))
                    {
                        node.IsExpanded = true;
                        node.IsSelected = true;
                    }

                    // add new node to appropriate parent
                    switch (OleDbSchema.GetTableType(dt))
                    {
                    case TableType.Table:
                        ndTables.Nodes.Add(node);
                        node.ImageIndex = node.SelectedImageIndex = 0;
                        break;

                    case TableType.View:
                        ndViews.Nodes.Add(node);
                        node.ImageIndex = node.SelectedImageIndex = 1;
                        break;

                    case TableType.Procedure:
                        ndProcs.Nodes.Add(node);
                        node.ImageIndex = node.SelectedImageIndex = 2;
                        break;
                    }
                }

                // add non-empty nodes to tree
                foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews, ndProcs })
                {
                    if (nd.Nodes.Count > 0)
                    {
                        nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count);
                        nodes.Add(nd);
                    }
                }

                // expand tables node
                ndTables.IsExpanded = true;

                // done
                if (null != _view)
                {
                    _view.SetTreeSource(_treeRootNode);
                }
            }
        }
コード例 #6
0
		private void UpdateTableTree()
		{
			// initialize table tree
			var nodes = _treeRootNode.Nodes;
			nodes.Clear();
			var ndTables = new NGTreeNodeWithImageIndex() { Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0 };
			var ndViews = new NGTreeNodeWithImageIndex() { Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1 };
			var ndProcs = new NGTreeNodeWithImageIndex() { Text = Current.ResourceService.GetString("Gui.DataConnection.StoredProcedures"), ImageIndex = 2, SelectedImageIndex = 2 };

			// populate using current schema
			if (_schema != null)
			{
				// populate the tree
				foreach (System.Data.DataTable dt in _schema.Tables)
				{
					// create new node, save table in tag property
					var node = new NGTreeNodeWithImageIndex() { Text = dt.TableName };
					node.Tag = dt;
					if (IsTableNameIdentical(dt.TableName, TableName))
					{
						node.IsExpanded = true;
						node.IsSelected = true;
					}

					// add new node to appropriate parent
					switch (OleDbSchema.GetTableType(dt))
					{
						case TableType.Table:
							ndTables.Nodes.Add(node);
							node.ImageIndex = node.SelectedImageIndex = 0;
							break;

						case TableType.View:
							ndViews.Nodes.Add(node);
							node.ImageIndex = node.SelectedImageIndex = 1;
							break;

						case TableType.Procedure:
							ndProcs.Nodes.Add(node);
							node.ImageIndex = node.SelectedImageIndex = 2;
							break;
					}
				}

				// add non-empty nodes to tree
				foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews, ndProcs })
				{
					if (nd.Nodes.Count > 0)
					{
						nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count);
						nodes.Add(nd);
					}
				}

				// expand tables node
				ndTables.IsExpanded = true;

				// done
				if (null != _view)
				{
					_view.SetTreeSource(_treeRootNode);
				}
			}
		}