/// <summary> /// 绑定子节点 /// </summary> /// <param name="tn"></param> /// <param name="parent"></param> private void GetCentralChild(DevExpress.XtraTreeList.Nodes.TreeListNode tn, int parent) { // 添加文件夹 var items = from s in docTemplateTreeList where s.parent_id != 0 && s.parent_id == parent select s; if (items.Count() >= 1) { foreach (var st in items) { DevExpress.XtraTreeList.Nodes.TreeListNode tns = tn.TreeList.AppendNode(st.id, tn); tns.SetValue(TemplateName, st.name); tns.SetValue(TemplateId, st.id); tns.SetValue(TemplateType, "Files"); tns.Tag = st; GetCentralChild(tns, st.id); } } // 添加文件 var file = from s in docTemplateList where s.parent_id != 0 && s.parent_id == parent select s; if (file.Count() < 1) { return; } foreach (var st in file) { DevExpress.XtraTreeList.Nodes.TreeListNode tns = tn.TreeList.AppendNode(st.id, tn); tns.SetValue(TemplateName, st.name); tns.SetValue(TemplateId, st.id); tns.SetValue(TemplateType, "File"); tns.Tag = st; } }
public static void InitTree(DevExpress.XtraTreeList.TreeList treeList) { treeList.Nodes.Clear(); treeList.AppendNode("全部", -1).SetValue(0, "全部"); treeList.AppendNode("事件", -1).SetValue(0, "事件"); DevExpress.XtraTreeList.Nodes.TreeListNode node1 = treeList.AppendNode("麻药", -1); node1.SetValue(0, "麻药"); treeList.AppendNode("用药", -1).SetValue(0, "用药"); treeList.AppendNode("输血", -1).SetValue(0, "输血"); treeList.AppendNode("输液", -1).SetValue(0, "输液"); treeList.AppendNode("输氧", -1).SetValue(0, "输氧"); treeList.AppendNode("岀液", -1).SetValue(0, "岀液"); treeList.AppendNode("手术", -1).SetValue(0, "手术"); treeList.AppendNode("麻醉", -1).SetValue(0, "麻醉"); treeList.AppendNode("插管", -1).SetValue(0, "插管"); treeList.AppendNode("置管", -1).SetValue(0, "置管"); treeList.AppendNode("拔管", -1).SetValue(0, "拔管"); DevExpress.XtraTreeList.Nodes.TreeListNode node2 = treeList.AppendNode("呼吸", -1); node2.SetValue(0, "呼吸"); treeList.AppendNode("附记项目", -1).SetValue(0, "附记项目"); treeList.AppendNode("其他", -1).SetValue(0, "其他"); treeList.AppendNode("诱导", -1).SetValue(0, "诱导"); treeList.AppendNode("镇痛", -1).SetValue(0, "镇痛"); treeList.AppendNode("抗生素", -1).SetValue(0, "抗生素"); treeList.AppendNode("特殊材料", -1).SetValue(0, "特殊材料"); treeList.AppendNode("吸入麻药", node1).SetValue(0, "吸入麻药"); treeList.AppendNode("局部麻药", node1).SetValue(0, "局部麻药"); treeList.AppendNode("静脉麻药", node1).SetValue(0, "静脉麻药"); treeList.AppendNode("辅助呼吸", node2).SetValue(0, "辅助呼吸"); treeList.AppendNode("控制呼吸", node2).SetValue(0, "控制呼吸"); treeList.AppendNode("自主呼吸", node2).SetValue(0, "自主呼吸"); }
/// <summary> /// treeList绑定 /// </summary> /// <param name="parent">父ID</param> private void TreeListBind(int parent) { try { this.TreeUser.treeList1.Nodes.Clear(); if (departsList.Count < 1) { return; } var items = from s in departsList where s.parent_id == parent select s; if (items.Count() < 1) { return; } foreach (var st in items) { DevExpress.XtraTreeList.Nodes.TreeListNode tn = this.TreeUser.treeList1.AppendNode(st.id, null); tn.SetValue(TemplateName, st.name); tn.Tag = st; GetCentralChild(tn, st.id); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void treeListMenuInfo_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e) { Menuinfo menuinfo = treeListMenuInfo.GetDataRecordByNode(e.Node) as Menuinfo; menuinfoPowerClient.PropertyValueChanged(menuinfo, e.Column.FieldName); if (e.Value.ToString() == "True") { DevExpress.XtraTreeList.Nodes.TreeListNode node = e.Node.ParentNode; while (node != null) { if (node.GetValue("CheckValue").ToString() == "True") { node = node.ParentNode; continue; } menuinfo = treeListMenuInfo.GetDataRecordByNode(node) as Menuinfo; menuinfo.Check(true); menuinfoPowerClient.PropertyValueChanged(menuinfo, e.Column.FieldName); node.SetValue("CheckValue", true); node = node.ParentNode; } } }
protected override void AddObject() { CodeEditWindow form = new CodeEditWindow(2, CharacterCasing.Upper, false); form.FormClosed += (o, e) => { if (form.DialogResult == System.Windows.Forms.DialogResult.OK) { T_CodeType codeType = new T_CodeType() { Code = form.Code, Desc = form.Desc }; if (this.MatCodeTreeList.DataSource != null) { List <T_CodeType> codeList = this.MatCodeTreeList.DataSource as List <T_CodeType>; codeType.Id = codeList.Select(t => t.Id).Max() + 1; } else { codeType.Id = 0; } if (this.MatCodeTreeList.FocusedNode == null) { codeType.ParentId = -1; } else { codeType.ParentId = Convert.ToInt16(this.MatCodeTreeList.FocusedNode.GetValue("Id")); } //_Proxy.AddCodeType(codeType); this.MatCodeTreeList.BeginUnboundLoad(); DevExpress.XtraTreeList.Nodes.TreeListNode node = this.MatCodeTreeList.AppendNode(codeType, this.MatCodeTreeList.FocusedNode); node.SetValue("Id", codeType.Id); node.SetValue("Code", codeType.Code); node.SetValue("Desc", codeType.Desc); this.MatCodeTreeList.EndUnboundLoad(); } }; form.ShowDialog(); }
private void btnThem_Child_Click(object sender, EventArgs e) { if (!this.EnableAdd) { GoobizFrame.Windows.Forms.UserMessage.Show("SYS_NOTALLOW_ADD", new string[] { }); return; } //if (Convert.ToBoolean(treelist_Phucap.FocusedNode.GetValue("Phucap_Chung"))) //{ // return; //} treelist_Phucap.LockReloadNodes(); try { Frmrex_Dm_Chucvu_Add frmrex_Chucvu = new Frmrex_Dm_Chucvu_Add(true); GoobizFrame.Windows.MdiUtils.ThemeSettings.SetDialogShow(frmrex_Chucvu); frmrex_Chucvu.StartPosition = FormStartPosition.CenterScreen; frmrex_Chucvu.ShowDialog(); DevExpress.XtraTreeList.Nodes.TreeListNode nodeParent = treelist_Phucap.FocusedNode; if (frmrex_Chucvu.row_Select != null) { var Id_Dm_Phucap = long.MaxValue; foreach (DataRow r in frmrex_Chucvu.row_Select) { DevExpress.XtraTreeList.Nodes.TreeListNode node = treelist_Phucap.AppendNode(new object[] { }, nodeParent); node.SetValue("Id_Dm_Phucap", Id_Dm_Phucap--); node.SetValue("Ma_Phucap", r["Ma_Chucvu"]); node.SetValue("Ten_Phucap", r["Ten_Chucvu"]); node.SetValue("Id_Chucvu", r["Id_Chucvu"]); treelist_Phucap.Nodes.Add(node); treelist_Phucap.SetFocusedNode(node); } } } catch (Exception ex) { GoobizFrame.Windows.TrayMessage.TrayMessage.Status = new GoobizFrame.Windows.TrayMessage.TrayMessageInfo(MessageBoxIcon.Asterisk, ex.Message, ex.StackTrace); } finally { treelist_Phucap.UnlockReloadNodes(); } }
/*专业班级树中显示所有的学院专业班级信息*/ private void showAllClass() { //string sql = "select CollName,MajorName,ClassName from Collage, Major, Class where Collage.CollNo = Major.CollNo and Major.MajorNo = Class.MajorNo"; string sql = "select ClassName from Class"; DataSet dataSet = GetData(sql); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { //添加一级节点 DevExpress.XtraTreeList.Nodes.TreeListNode FistLevelNode = treeListClass.AppendNode(null, null); //添加第一节点显示的值 FistLevelNode.SetValue(treeListClass.Columns[0], dataRow["ClassName"].ToString().Trim()); /* * //if (dr["CollName"].ToString().Trim() != "") * //{ * DevExpress.XtraTreeList.Nodes.TreeListNode FistLevelNode = treeList1.AppendNode(null, null);//添加一级节点 * if (FistLevelNode != null) * FistLevelNode.SetValue(treeList1.Columns[0], dr["CollName"].ToString().Trim());//添加第一节点显示的值 * * foreach (DataRow dr_ in dataSet.Tables[0].Rows) * { * //if (dr_["MajorName"].ToString().Trim() != "") * //{ * DevExpress.XtraTreeList.Nodes.TreeListNode SecondLevelNode = null; * if (dr["CollName"].ToString().Trim() == dr_["MajorName"].ToString().Trim()) * { * SecondLevelNode = treeList1.AppendNode(null, FistLevelNode.Id);//添加二级节点 * if (SecondLevelNode != null) * SecondLevelNode.SetValue(treeList1.Columns[0], dr_["MaJorName"].ToString().Trim());//添加节点显示的值 * * foreach (DataRow dr_temp in dataSet.Tables[0].Rows) * { * if (dr_temp["ClassName"].ToString().Trim() == dr_["MajorName"].ToString().Trim()) * { * DevExpress.XtraTreeList.Nodes.TreeListNode ThirdLevelNode = treeList1.AppendNode(null, SecondLevelNode.Id);//添加三级节点 * if (ThirdLevelNode != null) * ThirdLevelNode.SetValue(treeList1.Columns[0], dr_temp["ClassName"].ToString().Trim());//添加节点显示的值 * } * } * } * //} * // } * * * }*/ } }
private void AutoSetMenuSort(DevExpress.XtraTreeList.Nodes.TreeListNode node) { node.SetValue("iSort", iSort); iSort++; foreach (DevExpress.XtraTreeList.Nodes.TreeListNode item in node.Nodes) { item.SetValue("iSort", iSort); iSort++; if (item.HasChildren && item.HasAsParent(node)) { AutoSetMenuSort(item); } } }
/// <summary> /// treeList绑定 /// </summary> /// <param name="parent">父ID</param> private void TreeListBind(int parent) { this.TreeDocTemplate.treeList1.Nodes.Clear(); if (docTemplateTreeList.Count < 1) { return; } var items = from s in docTemplateTreeList where s.parent_id == parent select s; if (items.Count() < 1) { return; } foreach (var st in items) { DevExpress.XtraTreeList.Nodes.TreeListNode tn = this.TreeDocTemplate.treeList1.AppendNode(st.id, null); tn.SetValue(TemplateName, st.name); tn.SetValue(TemplateId, st.id); tn.SetValue(TemplateType, "Files"); tn.Tag = st; GetCentralChild(tn, st.id); } }
/*专业班级树中显示所有的学院专业班级信息*/ private void showAllClass() { //string sql = "select CollName,MajorName,ClassName from Collage, Major, Class where Collage.CollNo = Major.CollNo and Major.MajorNo = Class.MajorNo"; string sql = "select MajorName from Major"; DataSet dataSet = GetData(sql); foreach (DataRow dataRow in dataSet.Tables[0].Rows) { //添加一级节点 DevExpress.XtraTreeList.Nodes.TreeListNode FistLevelNode = treeListMajor.AppendNode(null, null); //添加第一节点显示的值 FistLevelNode.SetValue(treeListMajor.Columns[0], dataRow["MajorName"].ToString().Trim()); } }
/// <summary> /// 绑定子节点 /// </summary> /// <param name="tn"></param> /// <param name="parent"></param> private void GetCentralChild(DevExpress.XtraTreeList.Nodes.TreeListNode tn, int parent, String parentAllName) { // 添加文件夹 var items = from s in docTlist where s.parent_id != 0 && s.parent_id == parent select s; if (items.Count() < 1) { return; } foreach (var st in items) { DevExpress.XtraTreeList.Nodes.TreeListNode tns = tn.TreeList.AppendNode(st.id, tn); tns.SetValue(DocName, st.name); tns.SetValue(DocID, st.id); tns.SetValue(DocType, "Files"); tns.ImageIndex = 0; st.all_name = parentAllName + "\\" + st.name; tns.Tag = st; GetCentralChild(tns, st.id, parentAllName + "\\" + st.name); } // 添加文件 var file = from s in doclist where s.document_type_id != 0 && s.document_type_id == parent select s; if (file.Count() < 1) { return; } foreach (var st in file) { DevExpress.XtraTreeList.Nodes.TreeListNode tns = tn.TreeList.AppendNode(st.id, tn); tns.SetValue(DocName, st.cn_name); tns.SetValue(DocID, st.id); tns.SetValue(DocType, "File"); tns.Tag = st; tn.ImageIndex = 1; } }
/*当打开界面的时候,就执行一次,刷新学院树*/ private void showAllCollage() { string sql = "select CollName from Collage"; DataSet dataSet = GetData(sql); //循环,将查询的学院信息显示在树中 foreach (DataRow dataRow in dataSet.Tables[0].Rows) { //添加一级节点 DevExpress.XtraTreeList.Nodes.TreeListNode FistLevelNode = treeListCollageList.AppendNode(null, null); //添加第一节点显示的值 FistLevelNode.SetValue(treeListCollageList.Columns[0], dataRow["CollName"].ToString().Trim()); } }
/// <summary> /// 文件夹点击 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Name == "toolStripMenuItem1") { doc_template_tree tTree = new doc_template_tree(); tTree.parent_id = ((doc_template_tree)node.Tag).id; tTree.parent_name = ((doc_template_tree)node.Tag).name; // 新建分类 BuildDocTemplateCategory category = new BuildDocTemplateCategory(tTree, 1); if (category.ShowDialog() == DialogResult.OK) { //新建分类成功! DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(category.docTemplateTree.id, node); tns.SetValue(TemplateName, category.docTemplateTree.name); tns.SetValue(TemplateId, category.docTemplateTree.id); tns.SetValue(TemplateType, "Files"); tns.Tag = category.docTemplateTree; } } else if (e.ClickedItem.Name == "toolStripMenuItem2") { // 修改分类 doc_template_tree tTree = (doc_template_tree)node.Tag; BuildDocTemplateCategory category = new BuildDocTemplateCategory(tTree, 2); if (category.ShowDialog() == DialogResult.OK) { //修改分类成功! node.SetValue(TemplateName, category.docTemplateTree.name); node.Tag = category.docTemplateTree; } } else if (e.ClickedItem.Name == "toolStripMenuItem3") { // 删除分类 doc_template_tree tTree = (doc_template_tree)node.Tag; if (DialogResult.OK == MessageBox.Show("确定删除这行数据!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { bool flag = WcfServiceLocator.Create <IDocTemplateCategoryManage>().delDocumentTemplateTree(tTree); if (flag) { // 访问后台删除数据 this.TreeDocTemplate.treeList1.DeleteNode(node); } } } else if (e.ClickedItem.Name == "toolStripMenuItem4") { // 分类属性 doc_template_tree tTree = (doc_template_tree)node.Tag; BuildDocTemplateCategory category = new BuildDocTemplateCategory(tTree, 3); category.ShowDialog(); } else if (e.ClickedItem.Name == "toolStripMenuItem10") { // 新建模板文档 doc_template docTemplate = new doc_template(); docTemplate.parent_id = ((doc_template_tree)node.Tag).id; docTemplate.parent_name = ((doc_template_tree)node.Tag).name; BuildDocTemplate bulidDocTemlate = new BuildDocTemplate(docTemplate, 1); if (bulidDocTemlate.ShowDialog() == DialogResult.OK) { // 新建模板文档成功! //新建分类成功! DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(bulidDocTemlate.docTemplate.id, node); tns.SetValue(TemplateName, bulidDocTemlate.docTemplate.name); tns.SetValue(TemplateId, bulidDocTemlate.docTemplate.id); tns.SetValue(TemplateType, "Files"); tns.Tag = bulidDocTemlate.docTemplate; } } }
/// <summary> /// 右键文档夹菜单事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void contextMenuFiles_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { this.contextMenuFiles.Visible = false; if (e.ClickedItem.Name == "cutFileItem") { // 剪切 cutNode = node; this.cutFileItem.Enabled = false; this.cutItem.Enabled = false; this.copyDocClassItem.Enabled = false; this.pasteItem.Enabled = true; } else if (e.ClickedItem.Name == "pasteItem") { // 粘贴 if (cutNode.Tag.GetType() == typeof(document)) { // 更新后台的数据 document doc = ((document)cutNode.Tag); doc.document_type_id = ((document_tree)node.Tag).id; doc.document_type_name = ((document_tree)node.Tag).name; // 调用接口来更新后台数据 //粘贴的当前节点添加 DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(doc.id, node); tns.SetValue(DocName, doc.cn_name); tns.SetValue(DocID, doc.id); tns.SetValue(DocType, "File"); tns.Tag = doc; //剪切的当前节点减少 this.treeList1.DeleteNode(cutNode); } else { document_tree docTree = (document_tree)cutNode.Tag; docTree.parent_id = ((document_tree)node.Tag).id; docTree.parent_name = ((document_tree)node.Tag).name; // 调用接口来更新后台数据 //粘贴的当前节点添加 DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docTree.id, node); tns.SetValue(DocName, docTree.name); tns.SetValue(DocID, docTree.id); tns.SetValue(DocType, "Files"); tns.ImageIndex = 0; tns.Tag = docTree; GetCentralChild(tns, docTree.id, docTree.all_name); //剪切的当前节点减少 this.treeList1.DeleteNode(cutNode); } this.cutFileItem.Enabled = true; this.cutItem.Enabled = true; this.copyDocClassItem.Enabled = true; this.pasteItem.Enabled = false; } else if (e.ClickedItem.Name == "copyDocClassItem") { // 复制文档分类 this.cutFileItem.Enabled = false; this.cutItem.Enabled = false; this.copyDocClassItem.Enabled = false; this.pasteItem.Enabled = true; } else if (e.ClickedItem.Name == "expandAllItem") { // 展开 node.ExpandAll(); } else if (e.ClickedItem.Name == "collapseAllItem") { // 折叠 treeList1.CollapseAll(); } else if (e.ClickedItem.Name == "loadingItem") { // 加载文档 // 加载文档是指将该分类的分类和文档呈树形显示供查看其中内容; } else if (e.ClickedItem.Name == "addDocItem") { // 录入已有文档 // 录入已有文档是指将本地已完成的文档录入到PDM系统中; document document = new document(); document.document_type_id = ((document_tree)node.Tag).id; document.document_type_name = ((document_tree)node.Tag).all_name; DocModify docModify = new DocModify(document, 1); if (DialogResult.OK == docModify.ShowDialog()) { DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docModify.docSave.id, node); tns.SetValue(DocName, docModify.docSave.cn_name); tns.SetValue(DocID, docModify.docSave.id); tns.SetValue(DocType, "Files"); tns.Tag = docModify.docSave; // 修改文档成功! MessageBox.Show("创建成功!"); } } else if (e.ClickedItem.Name == "importItem") { // 批量导入文档 // 文档批量导入是指将本地已完成的多个文档一次录入到PDM系统中; DocBulkImport import = new DocBulkImport((document_tree)node.Tag); if (DialogResult.OK == import.ShowDialog()) { // 批量导入成功! } } else if (e.ClickedItem.Name == "downDocItem") { // 下载 // 打开文件夹 FolderBrowserDialog dlg = new FolderBrowserDialog(); if (dlg.ShowDialog() == DialogResult.OK) { // 开启socket文件 SocketServer s = new SocketServer("127.0.0.1", 7774, dlg.SelectedPath + "\\"); s.start(); var files = from d in doclist where d.document_type_id != 0 && d.document_type_id == ((document_tree)node.Tag).id select d; if (files.Count() < 1) { return; } List <document> list = new List <document>(); foreach (document st in files) { st.ipaddress = "127.0.0.1"; st.port = 7774; list.Add(st); } bool flag = WcfServiceLocator.Create <IDocManageTool>().downDocumentAll(list); while (!(flag && s.flag)) { System.Threading.Thread.Sleep(1000); } s.lisner.Stop(); s.TempThread.Abort(); } } else if (e.ClickedItem.Name == "updateDocTreeStatusItem") { // 更新文档状态 // 更新文档状态是指将该分类下文档状态已改变而显示界面上无变化时,点击改变界面显示; } else if (e.ClickedItem.Name == "grantDocItem") { // 发放文档 // } else if (e.ClickedItem.Name == "permissionApplyDocItem") { // 申请权限 } else if (e.ClickedItem.Name == "scanDocGrantRItem") { // 查看文档发放规则 } else if (e.ClickedItem.Name == "addDocTreeItem") { // 增加文档分类 document_tree doct = new document_tree(); doct.parent_id = ((document_tree)node.Tag).id; doct.parent_name = ((document_tree)node.Tag).name; BuildDocCategory docCat = new BuildDocCategory(doct, 1); if (docCat.ShowDialog() == DialogResult.OK) { DevExpress.XtraTreeList.Nodes.TreeListNode tns = node.TreeList.AppendNode(docCat.docTree.id, node); tns.SetValue(DocName, docCat.docTree.name); tns.SetValue(DocID, docCat.docTree.id); tns.SetValue(DocType, "Files"); docCat.docTree.all_name = ((document_tree)(node.Tag)).all_name + @"\" + docCat.docTree.name; tns.Tag = docCat.docTree; // 添加成功! } } else if (e.ClickedItem.Name == "updatedocTreeItem") { // 修改文档分类 document_tree docType = new document_tree(); docType.parent_id = ((document_tree)node.Tag).parent_id; docType.parent_name = ((document_tree)node.Tag).parent_name; docType.id = ((document_tree)node.Tag).id; docType.name = ((document_tree)node.Tag).name; BuildDocCategory docCat = new BuildDocCategory(docType, 2); if (docCat.ShowDialog() == DialogResult.OK) { // 修改成功! ((document_tree)node.Tag).name = docCat.docTree.name; node.SetValue(DocName, docCat.docTree.name); } } else if (e.ClickedItem.Name == "delDocTreeItem") { // 删除文档分类 if (MessageBox.Show("确认删除?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { bool flag = WcfServiceLocator.Create <IDocManageTool>().delDocumentTree((document_tree)node.Tag); if (flag) { // 删除文件夹 this.treeList1.DeleteNode(node); } } } else if (e.ClickedItem.Name == "scanDocTypeItem") { // 查看文档分类 document_tree docType = new document_tree(); docType.parent_id = ((document_tree)node.Tag).parent_id; docType.parent_name = ((document_tree)node.Tag).parent_name; docType.id = ((document_tree)node.Tag).id; docType.name = ((document_tree)node.Tag).name; BuildDocCategory docCat = new BuildDocCategory(docType, 3); docCat.ShowDialog(); } else if (e.ClickedItem.Name == "execlEmportItem") { // excel导出 } else if (e.ClickedItem.Name == "userImportItem") { // 自定义导出 } else if (e.ClickedItem.Name == "docCountStaItem") { // 文档数量统计,统计该节点下文件的数目 int count = GetChildNodes(node); MessageBox.Show("共有文档" + count + "个"); } }
private void SetCheckValue(DevExpress.XtraTreeList.Nodes.TreeListNode node, bool value) { node.SetValue("Bool0", value); node.SetValue("Bool1", value); }