コード例 #1
0
        /// <summary>创建数据源</summary>
        /// <param name="args"></param>
        private void AddDS(Dictionary <object, object> args)
        {
            TreeNode dsNode = null;

            if (args != null && args.Count > 0)
            {
                dsNode      = new TreeNode();
                dsNode.Name = args["DSName"].ToString();
                dsNode.Text = args["DSDisplayText"].ToString();
            }
            if (dsNode != null)
            {
                this.tableStructTree.Nodes[0].Nodes.Add(dsNode);
                dsNode.Checked = true;
                int dsId = 0;
                Int32.TryParse(args["DSID"].ToString(), out dsId);
                this.tableStructTree.SelectedNode = dsNode;
                this.txtDSId.Text          = dsId.ToString();
                this.txtDSName.Text        = args["DSName"].ToString();
                this.txtDSdisplaytext.Text = args["DSDisplayText"].ToString();
                this.txtDSPackage.Text     = args["DSPackage"].ToString();

                DataSource ds = new DataSource();
                ds.DSID           = dsId;
                ds.DataSourceName = args["DSName"].ToString();
                //ds.DSDisplayText = args["DSDisplayText"].ToString();
                ds.Package = args["DSPackage"].ToString();
                ModelDesignProject.CreateDS(ds);
            }
        }
コード例 #2
0
        private void InitializeControl()
        {
            _currentDS = ModelDesignProject.GetDataSource(_dsId);
            if (_currentDS.DefTables != null)
            {
                foreach (DefineTable defTB in _currentDS.DefTables)
                {
                    TreeNode nodeDefTable = new TreeNode();
                    SetDefineTableNode(defTB, nodeDefTable);
                    TreeNode nodeDTStruct;
                    TreeNode nodeField;
                    foreach (DataTableStruct dtStruct in defTB.TableStruct)
                    {
                        nodeDTStruct = new TreeNode();
                        SetTableStructNode(dtStruct, nodeDTStruct);
                        foreach (LibField field in dtStruct.Fields)
                        {
                            nodeField = new TreeNode();
                            SetFieldNode(field, nodeField);
                            nodeDTStruct.Nodes.Add(nodeField);
                        }
                        nodeDefTable.Nodes.Add(nodeDTStruct);
                    }
                    this.treeView1.Nodes["defineTableCollection"].Nodes.Add(nodeDefTable);
                }
            }
            else
            {
                _currentDS.DefTables = new SDPCRL.CORE.LibCollection <DefineTable>();
                TreeNode nodeDefTable = new TreeNode();

                DefineTable defTable = new DefineTable();
                defTable.ID          = DataSourceInfoBLL.GetMaxDefTBID(_dsId) + 1;
                defTable.TableName   = "defineTable1";
                defTable.DisplayName = "自定义数据表";
                SetDefineTableNode(defTable, nodeDefTable);
                _currentDS.DefTables.Add(defTable);

                defTable.TableStruct = new SDPCRL.CORE.LibCollection <DataTableStruct>();
                TreeNode tableStruct = new TreeNode();
                nodeDefTable.Nodes.Add(tableStruct);

                DataTableStruct dbStruct = new DataTableStruct();
                dbStruct.Name        = "dataTableStruct1";
                dbStruct.DisplayName = "数据表结构";
                SetTableStructNode(dbStruct, tableStruct);
                defTable.TableStruct.Add(dbStruct);
                this.treeView1.Nodes["defineTableCollection"].Nodes.Add(nodeDefTable);
                this.treeView1.SelectedNode = tableStruct;;
                nodeDefTable.Expand();
            }
            ModelDesignProject.CreateDS(_currentDS);
        }