Beispiel #1
0
        /// <summary>字段节点上的右键菜单</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextMenuStrip4_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            LibTreeNode        curentNode      = (LibTreeNode)this.treeView1.SelectedNode;
            LibDefineTable     defineTB        = _ds.DefTables.FindFirst("ID", ((LibTreeNode)curentNode.Parent.Parent).NodeId);
            LibDataTableStruct currentTBStruct = defineTB.TableStruct.FindFirst("ID", ((LibTreeNode)curentNode.Parent).NodeId);

            switch (e.ClickedItem.Name)
            {
            case "deleteField":    //删除字段节点
                //LibField f= currentTBStruct.Fields.FindFirst("ID", curentNode.NodeId);
                //currentTBStruct.Fields.Remove(f);
                currentTBStruct.Fields.Remove("ID", curentNode.NodeId);
                DefFieldProperty fp = this._fieldPropertylst.FirstOrDefault(i => i.Name == curentNode.NodeId);
                if (fp != null)
                {
                    this._fieldPropertylst.Remove(fp);
                }
                this.treeView1.Nodes.Remove(curentNode);
                UpdateTabPageText();
                break;
            }
        }
Beispiel #2
0
        private void DoCreateField(string fieldnm, string displaynm, LibSysField sysfd, LibTreeNode currentNode, LibDataTableStruct currentTBStruct)
        {
            LibTreeNode fieldNode = new LibTreeNode();

            fieldNode.NodeId   = Guid.NewGuid().ToString();
            fieldNode.Name     = sysfd != null ? sysfd.Name : fieldnm;
            fieldNode.Text     = sysfd != null ? sysfd.DisplayName : displaynm;
            fieldNode.NodeType = NodeType.Field;
            currentNode.Nodes.Add(fieldNode);

            DefFieldProperty fieldP = new DefFieldProperty(fieldNode.NodeId);

            fieldP.Dock = DockStyle.Fill;
            this._fieldPropertylst.Add(fieldP);
            this.splitContainer1.Panel2.Controls.Add(fieldP);

            LibField field = new LibField();

            field.ID          = fieldNode.NodeId;
            field.Name        = fieldNode.Name;
            field.DisplayName = fieldNode.Text;
            if (sysfd != null)
            {
                field.FieldType   = sysfd.FieldType;
                field.FieldLength = sysfd.FieldLength;
            }
            else
            {
                field.FieldType   = LibFieldType.String;
                field.FieldLength = 50;
            }
            field.IsActive  = true;
            field.AllowNull = true;
            field.SysField  = sysfd != null;

            currentTBStruct.Fields.Add(field);

            fieldP.SetPropertyValue(field, fieldNode);
        }
Beispiel #3
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LibTreeNode libnode = (LibTreeNode)e.Node;

            if (libnode == null)
            {
                return;
            }
            bool exists = false;

            switch (libnode.NodeType)
            {
            case NodeType.DefDataSet:
                if (this._dsProperty == null)
                {
                    _dsProperty = new DataSourceProperty();
                    this.splitContainer1.Panel2.Controls.Add(_dsProperty);
                }
                SetPanel2ControlsVisible(_dsProperty);

                _ds.DataSourceName = string.IsNullOrEmpty(_ds.DataSourceName) ? _funNode.Text : _ds.DataSourceName;
                _ds.Package        = string.IsNullOrEmpty(_ds.Package) ? _funNode.Package : _ds.Package;
                _dsProperty.SetPropertyValue(_ds, libnode);
                break;

            case NodeType.DefindTable:
                if (this._defTBPropertylst != null)
                {
                    foreach (DefTBProperty item in _defTBPropertylst)
                    {
                        if (string.Compare(item.Name, libnode.NodeId) == 0)
                        {
                            SetPanel2ControlsVisible(item);
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)     //还未创建对应的控件
                    {
                        DefTBProperty deftbp = new DefTBProperty(libnode.NodeId);
                        deftbp.Dock = DockStyle.Fill;
                        this._defTBPropertylst.Add(deftbp);
                        this.splitContainer1.Panel2.Controls.Add(deftbp);
                        deftbp.SetPropertyValue(_ds.DefTables.FindFirst("ID", libnode.NodeId), libnode);

                        SetPanel2ControlsVisible(deftbp);
                    }
                }

                break;

            case NodeType.TableStruct:
                if (this._tbStructPropertylst != null)
                {
                    foreach (TBStructProperty item in _tbStructPropertylst)
                    {
                        if (string.Compare(item.Name, libnode.NodeId) == 0)
                        {
                            SetPanel2ControlsVisible(item);
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)     //还未创建对应的控件
                    {
                        TBStructProperty tbstrucp = new TBStructProperty(libnode.NodeId);
                        tbstrucp.Dock = DockStyle.Fill;
                        this._tbStructPropertylst.Add(tbstrucp);
                        this.splitContainer1.Panel2.Controls.Add(tbstrucp);
                        LibDefineTable deftb = _ds.DefTables.FindFirst("ID", ((LibTreeNode)libnode.Parent).NodeId);
                        tbstrucp.SetPropertyValue(deftb.TableStruct.FindFirst("ID", libnode.NodeId), libnode);

                        SetPanel2ControlsVisible(tbstrucp);
                    }
                }
                break;

            case NodeType.Field:
                if (this._fieldPropertylst != null)
                {
                    foreach (DefFieldProperty item in _fieldPropertylst)
                    {
                        if (string.Compare(item.Name, libnode.NodeId) == 0)
                        {
                            SetPanel2ControlsVisible(item);
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)     //还未创建对应的控件
                    {
                        DefFieldProperty fieldp = new DefFieldProperty(libnode.NodeId);
                        fieldp.Dock = DockStyle.Fill;
                        this._fieldPropertylst.Add(fieldp);
                        this.splitContainer1.Panel2.Controls.Add(fieldp);
                        LibDefineTable     deftb    = _ds.DefTables.FindFirst("ID", ((LibTreeNode)libnode.Parent.Parent).NodeId);
                        LibDataTableStruct dtstruct = deftb.TableStruct.FindFirst("ID", ((LibTreeNode)libnode.Parent).NodeId);
                        fieldp.SetPropertyValue(dtstruct.Fields.FindFirst("ID", libnode.NodeId), libnode);

                        SetPanel2ControlsVisible(fieldp);
                    }
                }
                break;
            }
        }