private void AddNewNode(string Action, string txtLocalPath, string StrTitle) { TreeNodeEx theNode = (TreeNodeEx)treeView1.SelectedNode; int orderindex = (new BLL.T_CellAndEFile_BLL()).GetMaxOrderIndex(theNode.Name, Globals.ProjectNO);//treesData.GetNextIndex(theNode.Name, Globals.ProjectNO); string ParentID = theNode.Name; string Filepath = txtLocalPath; string Title = StrTitle; string ProjectNO = Globals.ProjectNO; fileModel = new ERM.MDL.T_FileList(); fileModel.gdwj = Title; fileModel.wjtm = Title; fileModel.FileID = Guid.NewGuid().ToString(); fileModel.ParentID = ParentID; fileModel.ProjectNO = ProjectNO; fileModel.OrderIndex = (new BLL.T_FileList_BLL()).GetMaxOrderIndex(ParentID, Globals.ProjectNO) + 1; fileModel.isvisible = 1; fileModel.fileStatus = "0"; fileModel.FL = 0; (new BLL.T_FileList_BLL()).Add(fileModel); MDL.T_CellAndEFile cellMode = new ERM.MDL.T_CellAndEFile(); cellMode.CellID = Guid.NewGuid().ToString(); if (!System.IO.File.Exists(Filepath)) { TXMessageBoxExtensions.Info("文件不存在!"); return; } System.IO.File.Copy(Filepath, Globals.ProjectPath + "ODOC\\" + cellMode.CellID + ".cll", true); cellMode.filepath = "ODOC\\" + cellMode.CellID + ".cll"; cellMode.orderindex = orderindex + 1; cellMode.FileID = fileModel.FileID; cellMode.isvisible = 1; cellMode.EFileType = true;//电子文件类型,0=false 系统的,-1=true 用户上传的 cellMode.ProjectNO = ProjectNO; cellMode.title = Title; cellBLL.Add(cellMode); TreeNodeEx newNode = new TreeNodeEx(); newNode.Name = cellMode.FileID; newNode.ImageIndex = 2; newNode.SelectedImageIndex = 2; newNode.Text = cellMode.title; theNode.Nodes.Add(newNode); theNode.Expand(); }
/// <summary> /// 添加自定义模版到工程资料用表模版表 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddTemplate(ERM.MDL.T_CellAndEFile model) { string Sql = "insert into Cell_Templet (id,ProjectNO,TreePath,parentid,PTreePath,title,filepath,examplepath,codeno,customdefine,codetype,ys,orderindex,isvisible ) values('" + model.id + "','" + model.ProjectNO + "','" + model.TreePath + "','" + model.parentid + "','" + model.PTreePath + "','" + model.title + "','" + model.filepath + "','" + model.examplepath + "','" + model.codeno + "','" + model.customdefine + "','" + model.codetype + "',0,'" + model.orderindex + "','" + model.isvisible + "' )"; try { return(DbHelperOleDb.ExecuteSql(Sql)); } catch (Exception e) { throw e; } }
private ERM.MDL.T_CellAndEFile Command_GetModel(DataRowView tRow) { ERM.MDL.T_CellAndEFile M_Cell_Templet = new ERM.MDL.T_CellAndEFile(); M_Cell_Templet.id = tRow["id"].ToString(); //节点唯一ID M_Cell_Templet.title = tRow["title"].ToString(); //标题 M_Cell_Templet.filepath = tRow["filepath"].ToString(); //华表路径 M_Cell_Templet.examplepath = tRow["examplepath"].ToString(); //范例文件 M_Cell_Templet.codeno = tRow["codeno"].ToString(); //表格代码 M_Cell_Templet.codetype = Convert.ToInt32(tRow["codetype"]); //结点类型 M_Cell_Templet.customdefine = Convert.ToInt32(tRow["customdefine"]); //用户自定义 M_Cell_Templet.fbmc = tRow["fbmc"].ToString(); //分部名称 M_Cell_Templet.fxmc = tRow["fxmc"].ToString(); //分项名称 M_Cell_Templet.isvisible = Convert.ToInt16(tRow["isvisible"]); //是否可见 M_Cell_Templet.orderindex = Convert.ToInt32(tRow["orderindex"]); //顺序号 M_Cell_Templet.parentid = tRow["parentid"].ToString(); //父节点ID M_Cell_Templet.ys = Convert.ToInt32(tRow["ys"]); //页数 M_Cell_Templet.zfbmc = tRow["zfbmc"].ToString(); //子分部名称 M_Cell_Templet.zrr = tRow["zrr"].ToString(); //责任人 M_Cell_Templet.ProjectNO = CPROJECTNO; //工程编号 return(M_Cell_Templet); }
/// <summary> /// 获取树的节点,跟其他方法合用 /// </summary> /// <param name="nodes">TreeNodeCollection</param> /// <param name="nodeID">要查询的节点</param> private void LoadChildNodes(TreeNodeEx pParentNode, string parentID, bool withImage, bool IsAll) { if (ds == null) { return; } DataView dataView = new DataView(ds.Tables[0]); dataView.RowFilter = "ParentID='" + parentID + "'"; TreeNodeEx[] tNodes = new TreeNodeEx[dataView.Count]; int tNodesCount = 0; foreach (DataRowView drv in dataView) { TreeNodeEx node = new TreeNodeEx(); if (this.Command_IsSelectFile(Convert.ToInt32(drv["imageindex"]))) { ERM.MDL.T_FileList M_FileRecording_Templet = this.Command_GetFile(drv); //获取文件对象模型 node.Name = M_FileRecording_Templet.id; //节点唯一ID,用来检索 node.Text = M_FileRecording_Templet.gdwj; //标题 node.Tag = M_FileRecording_Templet; //是否最后一个节点,范例路径,是否用户定义表格,附件 node.Checked = M_FileRecording_Templet.isvisible == 1 ? true : false; //是否可见 } else if (this.Command_IsSelectModel(Convert.ToInt32(drv["imageindex"]))) { ERM.MDL.T_CellAndEFile M_Cell_Templet = this.Command_GetModel(drv); //获取文件对象模型 node.Name = M_Cell_Templet.id; //节点唯一ID,用来检索 node.Text = M_Cell_Templet.title; //标题 node.Tag = M_Cell_Templet; //是否最后一个节点,范例路径,是否用户定义表格,附件 node.Checked = M_Cell_Templet.isvisible == 1 ? true : false; //是否可见 node.NodeKey = M_Cell_Templet.codeno; node.NodeValue = M_Cell_Templet.filepath; } else if (this.Command_IsSelectRoot(Convert.ToInt32(drv["imageindex"]))) { ERM.MDL.T_FileList M_FileRecording_Templet = this.Command_GetFile(drv); //获取文件对象模型 node.Name = M_FileRecording_Templet.id; //节点唯一ID,用来检索 node.Text = M_FileRecording_Templet.gdwj; //标题 node.Tag = M_FileRecording_Templet; //是否最后一个节点,范例路径,是否用户定义表格,附件 node.Checked = M_FileRecording_Templet.isvisible == 1 ? true : false; //是否可见 } if (withImage) { node.ImageIndex = Convert.ToInt32(drv["imageindex"]); node.SelectedImageIndex = Convert.ToInt32(drv["imageindex"]); } node.Text = drv["title"].ToString(); if (node.ImageIndex != 2) { if (IsAll) { LoadChildNodes(node, node.Name, true, true); node.IsFirstExpand = false; } else { TreeNodeEx node1 = new TreeNodeEx(); node1.Name = "临时数据"; node1.Text = "临时数据"; node.Nodes.Add(node1); } } tNodes.SetValue(node, tNodesCount++); } if (80 < tNodes.Length) //如果其含有的子节点数大于80个,启动BeginUpdate方法 { pParentNode.TreeView.BeginUpdate(); pParentNode.Nodes.AddRange(tNodes); pParentNode.TreeView.EndUpdate(); } else { pParentNode.Nodes.AddRange(tNodes); } }