/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { docTemplateTree.name = this.txtName.Text; if (actionType == 1) { docTemplateTree = WcfServiceLocator.Create <IDocTemplateCategoryManage>().insertDocumentTemplateTree(docTemplateTree); // 新建 } else if (actionType == 2) { docTemplateTree = WcfServiceLocator.Create <IDocTemplateCategoryManage>().updateDocumentTemplateTree(docTemplateTree); // 修改 } // 保存新建的分类 DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 获取所有文档模板树 /// </summary> /// <param name="docType"></param> /// <returns></returns> public List <doc_template_tree> getAllDocumentTemplateTree() { List <doc_template_tree> docTemplateTree = new List <doc_template_tree>(); doc_template_tree DOC = new doc_template_tree(); DOC.id = 1; DOC.name = "设计文档"; DOC.parent_id = -1; docTemplateTree.Add(DOC); doc_template_tree DOC1 = new doc_template_tree(); DOC1.id = 2; DOC1.name = "办公文档"; DOC1.parent_id = -1; docTemplateTree.Add(DOC1); return(docTemplateTree); }
/// <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> /// <returns></returns> public bool delDocumentTemplateTree(doc_template_tree docTemplateTree) { return(true); }
/// <summary> /// 更新文档模板文件夹 /// </summary> /// <param name="docTemplateTree"></param> /// <returns></returns> public doc_template_tree updateDocumentTemplateTree(doc_template_tree docTemplateTree) { return(docTemplateTree); }
/// <summary> /// 插入文档模板文件夹 /// </summary> /// <param name="docTemplateTree"></param> /// <returns></returns> public doc_template_tree insertDocumentTemplateTree(doc_template_tree docTemplateTree) { return(docTemplateTree); }
/// <summary> /// 带参数的构造函数 /// </summary> /// <param name="docTemplateTree"></param> /// <param name="actionType"></param> public BuildDocTemplateCategory(doc_template_tree docTemplateTree, int actionType) { InitializeComponent(); this.docTemplateTree = docTemplateTree; this.actionType = actionType; }