private void toolStripMenuItemAddProject_Click(object sender, EventArgs e) { TreeNode selectedNode = this.treeViewProjectList.SelectedNode; if (selectedNode == null) { CommonUtil.Alert("提示", "请选择或新建分组."); } else { TreeNode groupNode = ((selectedNode.Tag is Proj_Main) ? selectedNode.Parent : selectedNode); Proj_Group group = (Proj_Group)groupNode.Tag; string id = group.Id + "_New_Project"; NDATabPage tabPage = CheckExistTabPage(id); if (tabPage == null) { UserControlEditProject projectControl = new UserControlEditProject(group.Id, null); projectControl.AfterSaveEvent += new AfterSaveHandler(projectControl_AfterSaveEvent); projectControl.Dock = DockStyle.Fill; tabPage = this.CreateTabPage(id, "新建项目"); tabPage.Controls.Add(projectControl); tabPage.BeforeTabPageCloseEvent += new BeforeTabPageCloseHandler(tabPage_ProjectBeforeTabPageCloseEvent); } this.tabControlMain.SelectedTab = tabPage; } }
private Proj_Main GetProject(string groupName, string projectName) { TreeNodeCollection allGroupNodes = this.treeViewProjectList.Nodes; if (allGroupNodes != null) { foreach (TreeNode groupNode in allGroupNodes) { Proj_Group group = groupNode.Tag as Proj_Group; if (group.Name == groupName) { TreeNodeCollection allProjectNodes = groupNode.Nodes; if (allProjectNodes != null) { foreach (TreeNode projectNode in allProjectNodes) { Proj_Main proj = projectNode.Tag as Proj_Main; if (proj.Name == projectName) { return(proj); } } } } } } return(null); }
private TreeNode ShowGroup(Proj_Group group, bool checkExist) { //如果没有 if (checkExist) { foreach (TreeNode node in this.treeViewProjectList.Nodes) { Proj_Group nodeGroup = (Proj_Group)node.Tag; if (nodeGroup.Id == group.Id) { node.Tag = group; node.Text = group.Name; return(node); } } } //如果不是已存在的分组,那么新增一个 TreeNode newNode = new TreeNode(); newNode.Tag = group; newNode.Text = group.Name; this.treeViewProjectList.Nodes.Add(newNode); return(newNode); }
private bool DeleteGroup(Proj_Group group) { if (CommonUtil.Confirm("确认", "确认删除分组 '" + group.Name + "' 吗?")) { return(ProjectTaskAccess.DeleteGroup(group.Id)); } else { return(false); } }
private TreeNode GetGroupNode(string groupId) { foreach (TreeNode node in this.treeViewProjectList.Nodes) { Proj_Group group = (Proj_Group)node.Tag; if (group.Id == groupId) { return(node); } } return(null); }
private void EditNodeObject(TreeNode selectedNode) { if (selectedNode == null) { CommonUtil.Alert("提示", "无选中项"); } else { if (selectedNode.Tag is Proj_Group) { Proj_Group group = (Proj_Group)selectedNode.Tag; string id = group.Id; NDATabPage tabPage = CheckExistTabPage(id); if (tabPage == null) { UserControlEditGroup groupControl = new UserControlEditGroup(group); groupControl.AfterSaveEvent += new AfterSaveHandler(groupControl_AfterSaveEvent); groupControl.Dock = DockStyle.Fill; tabPage = this.CreateTabPage(id, "分组:" + group.Name); tabPage.Controls.Add(groupControl); tabPage.BeforeTabPageCloseEvent += new BeforeTabPageCloseHandler(tabPage_GroupBeforeTabPageCloseEvent); } this.tabControlMain.SelectedTab = tabPage; } else if (selectedNode.Tag is Proj_Main) { Proj_Main project = (Proj_Main)selectedNode.Tag; Proj_Group group = (Proj_Group)selectedNode.Parent.Tag; string id = project.Id; NDATabPage tabPage = CheckExistTabPage(id); if (tabPage == null) { UserControlEditProject projectControl = new UserControlEditProject(group.Id, project); projectControl.AfterSaveEvent += new AfterSaveHandler(projectControl_AfterSaveEvent); projectControl.Dock = DockStyle.Fill; tabPage = this.CreateTabPage(id, "项目:" + project.Name); tabPage.Controls.Add(projectControl); tabPage.BeforeTabPageCloseEvent += new BeforeTabPageCloseHandler(tabPage_ProjectBeforeTabPageCloseEvent); } this.tabControlMain.SelectedTab = tabPage; } } }
private bool Check() { string groupName = this.textBoxName.Text.Trim(); if (CommonUtil.IsNullOrBlank(groupName)) { CommonUtil.Alert("验证", "请录入组名."); return(false); } else { //新建分组 if (this.Group == null) { this.Group = new Proj_Group(); this.Group.Name = groupName; this.Group.Description = this.textBoxDescription.Text.Trim(); return(true); } else { //判断此组名是否存在且Id不同 Proj_Group g = ProjectTaskAccess.GetGroupInfoByNameFromDB(groupName); if (g != null && g.Id != this.Group.Id) { CommonUtil.Alert("验证", "已存在的组名,请使用其它名称."); return(false); } else { this.Group.Name = groupName; this.Group.Description = this.textBoxDescription.Text.Trim(); return(true); } } } }
private void RefreshGroupNodeText(TreeNode groupNode) { Proj_Group group = (Proj_Group)groupNode.Tag; groupNode.Text = group.Name + "(" + groupNode.Nodes.Count.ToString() + ")"; }
public UserControlEditGroup(Proj_Group group) { InitializeComponent(); this.Group = group; this.Load += new EventHandler(UserControlEditGroup_Load); }