private void btnOK_Click(object sender, EventArgs e) { DataVerifier dv = new DataVerifier(); dv.Check(_title == null, "请选择要添加标题还是正文!"); if (dv.Pass) { _title.TContent.ConContent = txtContent.Text; if (isadd) { if (AddCheck()) { AddTreeNode(); } } else { UpTreeNode(); } } dv.ShowMsgIfFailed(); }
private void btnFile_Click(object sender, EventArgs e) { index = 0; DataVerifier dv = new DataVerifier(); dv.Check(selectedNode == null, "请选择上级节点来添加表格"); if (dv.Pass) { using (OpenFileDialog file = new OpenFileDialog()) { if (file.ShowDialog() == DialogResult.OK) { var Appendixs = new List <Appendix>(); Appendixs.Add( new FileAppendix() { Type = 1, Title = file.SafeFileName.Substring(0, file.SafeFileName.LastIndexOf(".")), FileName = new Content() { ConType = "附件", ConContent = file.FileName }, FilePath = file.FileName } ); Title title = new Title() { ID = ++id, Parent = ((Title)selectedNode.Tag).ID, TContent = new Content() { ConType = "正文表格", ConContent = file.SafeFileName.Substring(0, file.SafeFileName.LastIndexOf(".")) }, Appendixs = Appendixs }; TreeNode n = new TreeNode() { Tag = title, Text = title.TContent.ConContent }; if (treeView1.Nodes == null) { treeView1.Nodes.Add(n); } else if (treeView1.SelectedNode != null) { treeView1.SelectedNode.Nodes.Add(n); } else { treeView1.Nodes.Add(n); } treeView1.ExpandAll(); } } } dv.ShowMsgIfFailed(); }
private bool AddCheck() { DataVerifier dv = new DataVerifier(); dv.Check(selectedNode == null && index > 1, "请按照 一级标题->二级标题->三级标题->四级标题 的顺序添加!"); if (selectedNode != null) { int pindex = stitle.ToList().FindIndex(a => ((Title)selectedNode.Tag).TContent.ConType == a); dv.CheckIfBeforePass(pindex == 0 && index != 0, "请非正文后面添加下级标题!"); dv.CheckIfBeforePass(index != 0 && pindex != 0 && index != pindex + 1, "请按照 一级标题->二级标题->三级标题->四级标题 的顺序添加!"); } dv.ShowMsgIfFailed(); return(dv.Pass); }
private void SetTitle(int id) { DataVerifier dv = new DataVerifier(); dv.Check(index != 1 && selectedNode == null, "添加队一级标题以外的内容时请先选择它的上级内容"); if (dv.Pass) { _title = new Title() { ID = id, TContent = new Content() { ConType = stitle[index] }, Parent = index == 1 ? 0 : ((Title)selectedNode.Tag).ID }; txtContent.Text = ""; txtContent.Focus(); } dv.ShowMsgIfFailed(); }
private bool DelCheck() { DataVerifier dv = new DataVerifier(); dv.Check(selectedNode == null, "请选择要删除的节点"); if (selectedNode != null) { if (selectedNode.Nodes.Count > 0) { var child = selectedNode.Nodes[0]; int sindex = stitle.ToList().FindIndex(a => ((Title)selectedNode.Tag).TContent.ConType == a); if (child != null) { int cindex = stitle.ToList().FindIndex(a => ((Title)child.Tag).TContent.ConType == a); dv.CheckIfBeforePass(sindex > 0 && cindex > 0, "请按照 一级标题->二级标题->三级标题->四级标题 的顺序"); } } } dv.ShowMsgIfFailed(); return(dv.Pass); }
private void btnAppendix_Click(object sender, EventArgs e) { DataVerifier dv = new DataVerifier(); dv.Check(n == null, "请先添加通知模板再添加附件"); if (dv.Pass) { var index = (int)ddlWord.SelectedValue; FileAppendix f = null; if (index == -1) { f = new FileAppendix(); } else { dv.Check(n.Appendixs[index].Type != 1, "修改附件时请选择对应的附件类型"); if (dv.Pass) { f = (FileAppendix)n.Appendixs[index]; } } if (dv.Pass) { using (OpenFileDialog file = new OpenFileDialog()) { if (file.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (index == -1) { f.Type = 1; f.Title = file.SafeFileName.Substring(0, file.SafeFileName.LastIndexOf(".")); f.FileName = new Content() { ConType = "附件", ConContent = file.FileName }; f.FilePath = file.FileName; if (n.Appendixs == null) { n.Appendixs = new List <Appendix>(); } n.Appendixs.Add(f); DDLSource source = new DDLSource() { Index = n.Appendixs.Count - 1, Text = "【文件】" + f.Title }; dDLSourceBindingSource.List.Add(source); } else { n.Appendixs[index] = f; ((DDLSource)dDLSourceBindingSource.Current).Text = "【文件】" + f.Title; BindDDL(); } } } } } dv.ShowMsgIfFailed(); }
private void btnWord_Click(object sender, EventArgs e) { DataVerifier dv = new DataVerifier(); dv.Check(n == null, "请先添加通知模板再添加附件"); if (dv.Pass) { var index = (int)ddlWord.SelectedValue; WordsAppendix words = null; FormWordsAppendix f; if (index >= 0) { dv.Check(n.Appendixs[index].Type != 0, "修改附件时请选择对应的附件类型"); if (dv.Pass) { words = (WordsAppendix)n.Appendixs[index]; } } if (dv.Pass) { f = new FormWordsAppendix(words); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (f.Appendix.Timu == null) { return; } f.Appendix.Type = 0; f.Appendix.Title = f.Appendix.Timu.ConContent; if (index == -1) { if (n.Appendixs == null) { n.Appendixs = new List <Appendix>(); } n.Appendixs.Add(f.Appendix); dDLSourceBindingSource.List.Add(new DDLSource() { Index = n.Appendixs.Count - 1, Text = "【文字】" + f.Appendix.Title }); } else { n.Appendixs[index] = f.Appendix; ((DDLSource)dDLSourceBindingSource.Current).Text = "【文字】" + f.Appendix.Title; BindDDL(); } } } } dv.ShowMsgIfFailed(); }