Exemplo n.º 1
0
        private void CreateDocument()
        {
            object[] obj = stack.ToArray();
            for (int i = 0; i < obj.Length; i++)
            {
                System.Xml.XmlElement element = (System.Xml.XmlElement)obj[i];
                if (!"".Equals(element.GetAttribute("RTF")))
                {
                    WinWordControlEx.AddRtf(element.GetAttribute("RTF"));
                    WinWordControlEx.InsertTitle(element.GetAttribute("TITLE"), element.GetAttribute("INDEX"));
                }
                else if (!"".Equals(element.GetAttribute("DOC")))
                {
                    WinWordControlEx.AddDoc(element.GetAttribute("DOC"));
                    WinWordControlEx.InsertTitle(element.GetAttribute("TITLE"), element.GetAttribute("INDEX"));
                }
                else if ("0".Equals(element.GetAttribute("LEVEL")))
                {
                    WinWordControlEx.InsertTitle(element.GetAttribute("TITLE"), element.GetAttribute("INDEX"));
                }
                //element.("aaa.xml");

                progressBar.Value = (int)(i * 100 / obj.Length);//根据添加的内容的多少,进度条显示操作的执行进度
            }
        }
Exemplo n.º 2
0
 private void ReplaceString(string[] keys, object[] values)
 {
     for (int i = 0; i < keys.Length; i++)
     {
         WinWordControlEx.Replace(keys[i], values[i].ToString());
     }
 }
Exemplo n.º 3
0
 private void BtnSave_Click(object sender, System.EventArgs e)
 {
     template.Title = TbxTitle.Text;
     template.Key   = TbxKey.Text;
     if (RichTextBoxEx.Visible)
     {
         template.Content = System.Text.Encoding.UTF8.GetBytes(RichTextBoxEx.GetContent());
         template.Type    = Framework.Entity.Template.RTF;
     }
     else if (WinWordControlEx.Visible)
     {
         template.Content = WinWordControlEx.GetWordStream(path);
         template.Type    = Framework.Entity.Template.DOC;
     }
     else
     {
         template.Content = WinExcelControlEx.GetExcelStream(path);
         template.Type    = Framework.Entity.Template.XLS;
     }
     template.State = CbxState.SelectedIndex;
     if (flag)
     {
         utilService.Update(template);
     }
     else
     {
         utilService.Insert(template);
     }
     RefreshIntance();
     this.Close();
 }
Exemplo n.º 4
0
 public void InitForm()
 {
     RichTextBoxEx.Visible     = true;
     WinWordControlEx.Visible  = false;
     WinExcelControlEx.Visible = false;
     if (flag)
     {
         TbxTitle.Text          = template.Title;
         TbxKey.Text            = template.Key;
         CbxState.SelectedIndex = template.State;
         if (template.Type == Framework.Entity.Template.RTF)
         {
             RichTextBoxEx.Visible     = true;
             WinWordControlEx.Visible  = false;
             WinExcelControlEx.Visible = false;
             RichTextBoxEx.SetContent(System.Text.Encoding.Default.GetString(template.Content));
         }
         else if (template.Type == Framework.Entity.Template.DOC)
         {
             RichTextBoxEx.Visible     = false;
             WinWordControlEx.Visible  = true;
             WinExcelControlEx.Visible = false;
             path = WinWordControlEx.RandomPath;
             WinWordControlEx.SetWordStream(template.Content, path);
         }
         else
         {
             RichTextBoxEx.Visible     = false;
             WinWordControlEx.Visible  = false;
             WinExcelControlEx.Visible = true;
             path = WinExcelControlEx.RandomPath;
             WinExcelControlEx.ShowExcel(template.Content, path);
         }
     }
 }
Exemplo n.º 5
0
 private void CreateModule(object obj, Framework.Entity.Template template)
 {
     System.Reflection.MethodInfo[] methods = obj.GetType().GetMethods();
     if (template.Type == Framework.Entity.Template.RTF)
     {
         RichTextBoxEx.SetContent(Framework.Class.ConvertTool.ConvertStringToRtf(""));
         string content = System.Text.Encoding.Default.GetString(template.Content);
         for (int i = 0, index = 0; i < methods.Length; i++)
         {
             if (methods[i].Name.StartsWith("get"))
             {
                 content = content.Replace("@" + index + "@", Framework.Class.ConvertTool.FormatRtf(Framework.Class.ConvertTool.ConvertStringToRtf(methods[i].Invoke(obj, null) + "")));
                 index++;
             }
         }
         RichTextBoxEx.Visible    = true;
         WinWordControlEx.Visible = false;
         RichTextBoxEx.SetContent(content);
     }
     else
     {
         RichTextBoxEx.Visible    = false;
         WinWordControlEx.Visible = true;
         path = WinWordControlEx.RandomPath;
         WinWordControlEx.SetWordStream(template.Content, path);
         for (int i = 0, index = 0; i < methods.Length; i++)
         {
             if (methods[i].Name.StartsWith("get"))
             {
                 WinWordControlEx.Replace("@" + index + "@", methods[i].Invoke(obj, null) + "");
                 index++;
             }
         }
     }
 }
Exemplo n.º 6
0
        private void CreateModule(Framework.Entity.Template template, System.Collections.ArrayList array, object @class)
        {
            path = WinWordControlEx.RandomPath;
            WinWordControlEx.SetWordStream(template.Content, path);
            if (@class.GetType().Equals(new Framework.Model.PlanLabor().GetType()))
            {
                WinWordControlEx.InsertTable(1, 3, array);
            }
            else if (@class.GetType().Equals(new Framework.Model.PlanMachine().GetType()))
            {
                WinWordControlEx.InsertTable(1, 3, array);
            }
            else if (@class.GetType().Equals(new Framework.Model.PlanMaterial().GetType()))
            {
                WinWordControlEx.InsertTable(1, 2, array);
            }
            else if (@class.GetType().Equals(new Framework.Model.ManageMember().GetType()))
            {
                WinWordControlEx.InsertTable(1, 2, array);
            }

            else if (@class.GetType().Equals(new Framework.Model.PrepareMaterial().GetType()))
            {
                //WinWordControlEx.InsertTable(1, 3, array);//表显示,括号内三项含义依次为“文档中第1个表;从该表的第3行开始插入;向表中插入的数据”
                for (int i = 0; i < array.Count; i++)
                {
                    object[] obj = (object[])array[i];
                    if (i == (array.Count - 1))
                    {
                        WinWordControlEx.Replace("@1@", obj[1].ToString());
                    }
                    else
                    {
                        WinWordControlEx.Replace("@1@", obj[1].ToString() + "、@1@");
                    }
                }
            }

            else if (@class.GetType().Equals(new Framework.Model.PrepareMachineTool().GetType()))
            {
                //WinWordControlEx.InsertTable(1, 3, array);//表显示,括号内三项含义依次为“文档中第1个表;从该表的第3行开始插入;向表中插入的数据”
                for (int i = 0; i < array.Count; i++)
                {
                    object[] obj = (object[])array[i];

                    if (i == (array.Count - 1))
                    {
                        WinWordControlEx.Replace("@1@", obj[1].ToString());
                    }
                    else
                    {
                        WinWordControlEx.Replace("@1@", obj[1].ToString() + "、@1@");
                    }
                }
            }
        }
Exemplo n.º 7
0
 private void BtnAdd_Click(object sender, System.EventArgs e)
 {
     System.Xml.XmlElement element = Framework.Class.XmlTool.FindChapterByCid(chapter.Id);
     if (RichTextBoxEx.Visible == true)
     {
         element.SetAttribute("RTF", RichTextBoxEx.GetContent());
     }
     else
     {
         element.SetAttribute("DOC", WinWordControlEx.GetWordString(path));
     }
     DevComponents.DotNetBar.MessageBoxEx.Show("添加成功!", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
 }
Exemplo n.º 8
0
 private void UclExcel_Load(object sender, System.EventArgs e)
 {
     chapter = (Framework.Entity.Chapter) this.Tag;
     System.Xml.XmlElement element = Framework.Class.XmlTool.FindChapterByCid(chapter.Id);
     if (!element.GetAttribute("DOC").Equals(""))
     {
         path = WinWordControlEx.RandomPath;
         WinWordControlEx.SetWordString(element.GetAttribute("DOC"), path);
     }
     else
     {
         ShowFrmProfile();
     }
 }
Exemplo n.º 9
0
 private void BtnImportWord_Click(object sender, System.EventArgs e)
 {
     System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
     openFileDialog.FileName = "Word文档";
     openFileDialog.Filter   = "Word文档(*.doc)|*.doc";
     if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         RichTextBoxEx.Visible     = false;
         WinWordControlEx.Visible  = true;
         WinExcelControlEx.Visible = false;
         path = openFileDialog.FileName;
         WinWordControlEx.LoadWord(path);
     }
 }
Exemplo n.º 10
0
        private void UclInsertText_Load(object sender, System.EventArgs e)
        {
            chapter = (Framework.Entity.Chapter) this.Tag;
            System.Xml.XmlElement element = Framework.Class.XmlTool.FindChapterByCid(chapter.Id);
            if (!element.GetAttribute("DOC").Equals(""))
            {
                path = WinWordControlEx.RandomPath;
                WinWordControlEx.SetWordString(element.GetAttribute("DOC"), path);
            }
            else
            {
                Framework.Entity.Model     model = (Framework.Entity.Model)utilService.FindById(new Framework.Entity.Model(), chapter.Model);
                System.Reflection.Assembly ass   = System.Reflection.Assembly.LoadFrom(System.Windows.Forms.Application.ExecutablePath.Replace("\\" + System.Windows.Forms.Application.StartupPath, ""));

                ShowFrmProfile(model, ass);
            }
        }
Exemplo n.º 11
0
        public void InitForm()
        {
            WinWordControlEx.CreateShowFile();
            System.Xml.XmlElement element = Framework.Class.XmlTool.FindChapterByCid(2);
            SearchChapter(Framework.Entity.Chapter.ROOT, 0, "");
            CreateDocument();
            //创建完doc后调出来再写好标题,最终解决办法了
            //WinWordControlEx.LoadWord(WinWordControlEx.ShowPath);
            //WinWordControlEx.SaveWord("Word.doc");
            WinWordControlEx.InsertBT();

            WinWordControlEx.LoadWord(WinWordControlEx.ShowPath);


            progressBar.Visible = false; //文档加载完成后,隐藏进度条
            lbl_waiter.Visible  = false; //文档加载完成后,隐藏提示的lable标签
        }
Exemplo n.º 12
0
        private void UclEditor_Load(object sender, System.EventArgs e)
        {
            chapter = (Framework.Entity.Chapter) this.Tag;
            System.Xml.XmlElement element = Framework.Class.XmlTool.FindChapterByCid(chapter.Id);
            string doc = element.GetAttribute("DOC");

            if (!doc.Equals(""))
            {
                RichTextBoxEx.Visible    = false;
                WinWordControlEx.Visible = true;
                path = WinWordControlEx.RandomPath;
                WinWordControlEx.SetWordString(element.GetAttribute("DOC"), path);
            }
            else
            {
                RichTextBoxEx.Visible    = true;
                WinWordControlEx.Visible = false;
                RichTextBoxEx.SetContent(element.GetAttribute("RTF"));
            }
            CreateTemplateList();
        }
Exemplo n.º 13
0
        private void CreateTemplateList()
        {
            DevComponents.AdvTree.Node rootNode = new DevComponents.AdvTree.Node(chapter.Title);
            rootNode.Expanded = true;
            AdvTree.Nodes.Add(rootNode);
            System.Collections.ArrayList templateList = contentService.GetTemplateByChapter(chapter.Id);
            foreach (Framework.Entity.Template template in templateList)
            {
                DevComponents.AdvTree.Node node = new DevComponents.AdvTree.Node(template.Title);
                node.Tag = template;

                node.Expanded         = true;
                node.NodeDoubleClick += new System.EventHandler(delegate(object o, System.EventArgs a)
                {
                    foreach (Framework.Entity.Template template1 in templateList) //这层foreeach用于双击节点时,重新的到所有的节点
                    {
                        if (template1.Title == node.Text)                         //如果
                        {
                            DevComponents.AdvTree.Node nd = (DevComponents.AdvTree.Node)o;
                            Framework.Entity.Template tmp = (Framework.Entity.Template)nd.Tag;
                            if (template1.Type == Framework.Entity.Template.RTF)
                            {
                                RichTextBoxEx.Visible    = true;
                                WinWordControlEx.Visible = false;
                                RichTextBoxEx.SetContent(System.Text.Encoding.Default.GetString(template1.Content));
                            }
                            else
                            {
                                RichTextBoxEx.Visible    = false;
                                WinWordControlEx.Visible = true;
                                path = WinWordControlEx.RandomPath;
                                WinWordControlEx.SetWordStream(template1.Content, path);
                            }
                            break;
                        }
                    }
                });
                rootNode.Nodes.Add(node);
            }
        }
Exemplo n.º 14
0
 private void UclProperty_Load(object sender, System.EventArgs e)
 {
     chapter = (Framework.Entity.Chapter) this.Tag;
     System.Xml.XmlElement element = Framework.Class.XmlTool.FindChapterByCid(chapter.Id);
     if (!element.GetAttribute("RTF").Equals(""))
     {
         RichTextBoxEx.Visible    = true;
         WinWordControlEx.Visible = false;
         RichTextBoxEx.SetContent(element.GetAttribute("RTF"));
     }
     else if (!element.GetAttribute("DOC").Equals(""))
     {
         RichTextBoxEx.Visible    = false;
         WinWordControlEx.Visible = true;
         path = WinWordControlEx.RandomPath;
         WinWordControlEx.SetWordString(element.GetAttribute("DOC"), path);
     }
     else
     {
         ShowFrmProfile();
     }
 }
Exemplo n.º 15
0
 private void UclChart_Load(object sender, System.EventArgs e)
 {
     WinWordControlEx.LoadWord(@"C:/123.doc");
 }
Exemplo n.º 16
0
        private void CreateModule(Framework.Entity.Template template, System.Collections.ArrayList array, object @class, object[] data)
        {
            path = WinWordControlEx.RandomPath;

            WinWordControlEx.CreateTempFile(template.Content, path);

            if (@class.GetType().Equals(new Framework.Model.InsertTextPileProject().GetType()))
            {
                WinWordControlEx.LoadWord(path);

                #region                                                                  //选顶某“桩基工程”后,与其对应的内容自动生成在文档中的相应位置。
                string NewWord = "$1$";
                for (int i = 0; i < System.Convert.ToInt16(data[7].ToString()) - 1; i++) //data[7] = count,通过data[7].ToString()确定选择的工程的数目,从而确定需要几个“$1$”符
                {
                    NewWord += "\n$1$";                                                  //每添加一种工程,模板文档中就多添加一个“$1$”符号
                }
                WinWordControlEx.Replace("$1$", NewWord);                                //调用的是Replace(string strOldText,string strNewText, string path)

                for (int i = 0; i < System.Convert.ToInt16(data[7].ToString()); i++)     //用文字图标等内容,把文档中的“$1$”替换掉
                {
                    tempInsertText = contentService.GetTemplateByTitle(data[i].ToString());
                    WinWordControlEx.Replace(tempInsertText.Content, "$1$");//调用的是Replace(byte[] buffByte, string strOldText, string path)
                }
                #endregion
            }
            else if (@class.GetType().Equals(new Framework.Model.InsertTextWinterMeasure().GetType()))
            {
                WinWordControlEx.LoadWord(path);

                #region                                                                  //选出“工程”后,与其对应的内容自动生成在文档中的相应位置。
                string NewWord = "$1$";
                for (int i = 0; i < System.Convert.ToInt16(data[7].ToString()) - 1; i++) //data[7] = count,通过data[7].ToString()确定选择的工程的数目,从而确定需要几个“$1$”符
                {
                    NewWord += "\n$1$";                                                  //每添加一种工程,模板文档中就多添加一个“$1$”符号
                }
                WinWordControlEx.Replace("$1$", NewWord, path);                          //调用的是Replace(string strOldText,string strNewText, string path)

                for (int i = 0; i < System.Convert.ToInt16(data[7].ToString()); i++)     //用文字图标等内容,把文档中的“$1$”替换掉
                {
                    tempInsertText = contentService.GetTemplateByTitle(data[i].ToString());
                    WinWordControlEx.Replace(tempInsertText.Content, "$1$");//调用的是Replace(byte[] buffByte, string strOldText, string path)
                }
                #endregion
            }
            else if (@class.GetType().Equals(new Framework.Model.InsertTextWinterMaintain().GetType()))
            {
                WinWordControlEx.LoadWord(path);
                #region                                                                  //选出“工程”后,与其对应的内容自动生成在文档中的相应位置。
                string NewWord = "$1$";
                for (int i = 0; i < System.Convert.ToInt16(data[2].ToString()) - 1; i++) //data[3] = count,通过data[7].ToString()确定选择的工程的数目,从而确定需要几个“$1$”符
                {
                    NewWord += "\n$1$";                                                  //每添加一种工程,模板文档中就多添加一个“$1$”符号
                }
                WinWordControlEx.Replace("$1$", NewWord, path);                          //调用的是Replace(string strOldText,string strNewText, string path)

                for (int i = 0; i < System.Convert.ToInt16(data[2].ToString()); i++)     //用文字图标等内容,把文档中的“$1$”替换掉
                {
                    tempInsertText = contentService.GetTemplateByTitle(data[i].ToString());
                    WinWordControlEx.Replace(tempInsertText.Content, "$1$");//调用的是Replace(byte[] buffByte, string strOldText, string path)
                }
                #endregion
            }
            else if (@class.GetType().Equals(new Framework.Model.InsertTextRoof().GetType()))
            {
                #region                                                                  //确定有多少出要替换
                string NewWord = "$1$";
                for (int i = 0; i < System.Convert.ToInt16(data[8].ToString()) - 1; i++) //data[8] = count,通过data[8].ToString()确定选择的工程的数目,从而确定需要几个“$1$”符
                {
                    NewWord += "\n$1$";                                                  //每添加一种工程,模板文档中就多添加一个“$1$”符号
                }
                WinWordControlEx.Replace("$1$", NewWord, path);                          //调用的是Replace(string strOldText,string strNewText, string path)

                NewWord = "$2$";
                for (int i = 0; i < System.Convert.ToInt16(data[9].ToString()) - 1; i++)
                {
                    NewWord += "\n$2$";
                }
                WinWordControlEx.Replace("$2$", NewWord, path);

                NewWord = "$3$";
                for (int i = 0; i < System.Convert.ToInt16(data[9].ToString()) - 1; i++)
                {
                    NewWord += "\n$3$";
                }
                WinWordControlEx.Replace("$3$", NewWord, path);
                #endregion

                #region//替换文字
                for (int i = 0; i < System.Convert.ToInt16(data[8].ToString()); i++)
                {
                    tempInsertText = contentService.GetTemplateByTitle(data[i].ToString());
                    WinWordControlEx.Replace(tempInsertText.Content, "$1$");//调用的是Replace(byte[] buffByte, string strOldText, string path)
                }

                for (int i = 0; i < System.Convert.ToInt16(data[9].ToString()); i++)
                {
                    tempInsertText = contentService.GetTemplateByTitle(data[i + 4].ToString());
                    WinWordControlEx.Replace(tempInsertText.Content, "$2$");
                }
                for (int i = 0; i < System.Convert.ToInt16(data[10].ToString()); i++)
                {
                    tempInsertText = contentService.GetTemplateByTitle(data[i + 6].ToString());
                    WinWordControlEx.Replace(tempInsertText.Content, "$3$");
                }
                #endregion

                WinWordControlEx.LoadWord(path);
            }
        }
Exemplo n.º 17
0
 private void BtnCreate_Click(object sender, System.EventArgs e)
 {
     System.Data.DataTable dtsheet = new System.Data.DataTable();
     WinWordControlEx.InsertChart(dtsheet);
 }