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.TransSetting: if (this._tranproperty == null) { _tranproperty = new TransProperty(); this.splitContainer1.Panel2.Controls.Add(_tranproperty); } SetPanel2ControlsVisible(_tranproperty); _Trans.TransName = string.IsNullOrEmpty(_Trans.TransName) ? _funNode.Text : _Trans.TransName; _Trans.Package = string.IsNullOrEmpty(_Trans.Package) ? _funNode.Package : _Trans.Package; //if (ModelDesignProject.ExitsDataSource(_fm.FormId, _fm.Package)) //{ // _fm.DSID = _fm.FormId; //} _tranproperty.SetPropertyValue(_Trans, libnode); break; case NodeType.TransField: if (_transFieldlst != null) { foreach (TransFieldProperty item in _transFieldlst) { if (string.Compare(item.Name, libnode.NodeId) == 0) { SetPanel2ControlsVisible(item); exists = true; break; } } if (!exists) //还未创建对应的控件 { TransFieldProperty transfdp = new TransFieldProperty(libnode.NodeId); transfdp.Dock = DockStyle.Fill; this._transFieldlst.Add(transfdp); this.splitContainer1.Panel2.Controls.Add(transfdp); //LibReportGrid librptgd = _rpt.GridGroups.FindFirst("GridGroupID", ((LibTreeNode)libnode.Parent).NodeId); transfdp.SetPropertyValue(_Trans.TransFields.FindFirst("ID", libnode.NodeId), libnode); SetPanel2ControlsVisible(transfdp); } } break; } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { LibTreeNode curentNode = (LibTreeNode)this.treeView1.SelectedNode; switch (e.ClickedItem.Name) { case "andTransField": //添加转单字段 if (this._Trans.TransFields == null) { _Trans.TransFields = new LibCollection <LibTransFieldMap>(); } var existfields = _Trans.TransFields.Tolist(); if (string.IsNullOrEmpty(_Trans.SrcProgId)) { ExceptionManager.ThrowError("来源单progid 必填"); //MessageHandle.ShowMessage("来源单progid 必填",false); } var formpage = ModelDesignProject.GetFormSourceByFormId(_Trans.SrcProgId); LibDataSource ds = ModelDesignProject.GetDataSourceById(formpage.DSID); Panel p = new Panel(); p.Dock = DockStyle.Fill; p.Name = "pfieldcollection"; p.AutoScroll = true; TreeView tree = new TreeView(); //tree.AfterCheck += new TreeViewEventHandler(Gridtree_AfterCheck); tree.CheckBoxes = true; tree.Dock = DockStyle.Fill; p.Controls.Add(tree); LibTreeNode _node; if (ds.DefTables != null) { List <ExistField> exists = new List <ExistField>(); foreach (var item in existfields) { exists.Add(new ExistField { Name = item.SrcFieldNm, FromTableNm = item.SrcTableNm }); } DSUtiles.GetAllFieldsByDS(ds, tree, exists); } FieldCollectionForm fielsform = new FieldCollectionForm(p); DialogResult dialog = fielsform.ShowDialog(this); if (dialog == DialogResult.OK) { curentNode.Nodes.Clear(); if (_Trans.TransFields != null && _Trans.TransFields.Count > 0) { _Trans.TransFields.RemoveAll(); } foreach (LibTreeNode deftb in tree.Nodes) { foreach (LibTreeNode tbstruct in deftb.Nodes) { foreach (LibTreeNode f in tbstruct.Nodes) { if (!f.Checked) { continue; } #region 添加节点 //树节点 LibTreeNode fieldNode = new LibTreeNode(); fieldNode.NodeId = Guid.NewGuid().ToString(); fieldNode.NodeType = NodeType.TransField; fieldNode.Name = f.Name; fieldNode.Text = fieldNode.Name; curentNode.Nodes.Add(fieldNode); //控件属性 TransFieldProperty fieldProperty = new TransFieldProperty(fieldNode.NodeId); _transFieldlst.Add(fieldProperty); fieldProperty.Dock = DockStyle.Fill; this.splitContainer1.Panel2.Controls.Add(fieldProperty); //对应实体 LibTransFieldMap libtransfield = new LibTransFieldMap(); libtransfield.ID = fieldNode.NodeId; libtransfield.SrcFieldNm = f.Name; libtransfield.SrcTableNm = (bool)f.Tag ? tbstruct.Name : string.Empty; //libtransfield.FromDefTableNm = (bool)f.Tag ? deftb.Name : string.Empty; libtransfield.SrcTableIndex = Convert.ToInt32(tbstruct.NodeId); libtransfield.SrcFieldDisplay = f.Text; //libtransfield.Isdefine = !(bool)f.Tag; _Trans.TransFields.Add(libtransfield); fieldProperty.SetPropertyValue(libtransfield, fieldNode); #endregion } } } UpdateTabPageText(); } break; } }