Exemplo n.º 1
0
        private void ReplaceText(string textToReplace, string replacedText)
        {
            Object missing = Type.Missing;
            Object wrap    = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;
            Object replace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;

            Microsoft.Office.Interop.Word.Range content;
            content = wordDoc.Range(wordDoc.Content.Start, wordDoc.Content.End);

            Microsoft.Office.Interop.Word.Find find = wordApp.Selection.Find;

            find.Text             = replacedText;
            find.Replacement.Text = textToReplace;

            find.Execute(
                FindText: Type.Missing,
                MatchCase: false,
                MatchWholeWord: false,
                MatchWildcards: false,
                MatchAllWordForms: false,
                Forward: true,
                Wrap: wrap,
                Format: false,
                ReplaceWith: missing,
                Replace: replace
                );
        }
Exemplo n.º 2
0
        // Will print discharge paper's for the patient
        private void dischargePatient_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();               //you need this
            var myWordDoc = app.Documents.Open(@"F:\PIMS_Final\PIMS DISCHARGE FORM.docx", ReadOnly: false, Visible: true); //filepath of document

            app.Visible = true;

            Microsoft.Office.Interop.Word.Find fndlastName = myWordDoc.ActiveWindow.Selection.Find;
            fndlastName.Text             = "@lname";
            fndlastName.Replacement.Text = Program.currentPatient.directory.lName.ToString();
            fndlastName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find fndfirstName = myWordDoc.ActiveWindow.Selection.Find;
            fndfirstName.Text             = "@fname";
            fndfirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
            fndfirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            /*
             * Microsoft.Office.Interop.Word.Find fndfirstName = myWordDoc.ActiveWindow.Selection.Find;
             * fndfirstName.Text = "@fname";
             * fndfirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
             * fndfirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
             *
             * Microsoft.Office.Interop.Word.Find fndfirstName = myWordDoc.ActiveWindow.Selection.Find;
             * fndfirstName.Text = "@fname";
             * fndfirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
             * fndfirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
             *
             * Microsoft.Office.Interop.Word.Find fndfirstName = myWordDoc.ActiveWindow.Selection.Find;
             * fndfirstName.Text = "@fname";
             * fndfirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
             * fndfirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
             *
             * Microsoft.Office.Interop.Word.Find fndfirstName = myWordDoc.ActiveWindow.Selection.Find;
             * fndfirstName.Text = "@fname";
             * fndfirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
             * fndfirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
             *
             * Microsoft.Office.Interop.Word.Find fndfirstName = myWordDoc.ActiveWindow.Selection.Find;
             * fndfirstName.Text = "@fname";
             * fndfirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
             * fndfirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
             */
            myWordDoc.SaveAs2(@"F:\PIMS_Final\" + Program.currentPatient.directory.lName + "." + Program.currentPatient.directory.fName + ".Discharge Form.docx");
            myWordDoc.PrintPreview();

            updateMyPatient();
        }
Exemplo n.º 3
0
        private void ReplaceText(string textToReplace, string replacedText)
        {
            Object missing = Type.Missing;

            Microsoft.Office.Interop.Word.Range selText;
            selText = wordDoc.Range(wordDoc.Content.Start, wordDoc.Content.End);

            Microsoft.Office.Interop.Word.Find find = wordApp.Selection.Find;
            find.Text             = replacedText;
            find.Replacement.Text = textToReplace;

            Object wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;

            Object replace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;

            find.Execute(Type.Missing, false, false, false, missing, false, true, wrap, false, missing, replace);
        }
Exemplo n.º 4
0
        public static Result Replace(
            this Microsoft.Office.Interop.Word.Find find,
            Microsoft.Office.Interop.Word.WdReplace wordReplace,
            Action <ReplaceOptions> configureOptions = null)
        {
            ReplaceOptions options = ReplaceOptions.Default;

            configureOptions?.Invoke(options);
            try
            {
                bool success = find.Execute(
                    FindText: find.Text,
                    MatchCase: options.MatchCase,
                    MatchWholeWord: options.MatchWholeWord,
                    MatchWildcards: options.MatchWildcards,
                    MatchSoundsLike: options.MatchSoundsLike,
                    MatchAllWordForms: options.MatchAllWordForms,
                    Forward: options.Forward,
                    Wrap: options.Wrap,
                    Format: options.Format,
                    ReplaceWith: find.Replacement.Text,
                    Replace: wordReplace,
                    MatchKashida: options.MatchKashida,
                    MatchDiacritics: options.MatchDiacritics,
                    MatchAlefHamza: options.MatchAlefHamza,
                    MatchControl: options.MatchControl);

                return(success
                    ? Result.Ok()
                    : Result.Fail("Something went wrong"));
            }
            catch (COMException ex)
            {
                return(Result.Fail(ex.Message + ". Check if word is already open prior to running program"));
            }
            catch (Exception ex)
            {
                return(Result.Fail(ex.Message));
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            object filename1 = Application.StartupPath + "\\bin\\" + Global.templateName;

            object G_Missing = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document    wordDoc;
            wordDoc = wordApp.Documents.Open(filename1);
            wordDoc.ActiveWindow.Visible = false;//打开word

            Microsoft.Office.Interop.Word.Range myRange = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f       = myRange.Find;
            f.Text = "布点数量:";
            f.ClearFormatting();

            bool finded = f.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                    );

            myRange      = wordDoc.Range(myRange.End, myRange.End + 10);
            myRange.Text = textBox1.Text;

            Microsoft.Office.Interop.Word.Range myRange1 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f1       = myRange1.Find;
            f1.Text = "仪表编号:";
            f1.ClearFormatting();

            bool finded1 = f1.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange1      = wordDoc.Range(myRange1.End, myRange1.End + 13);
            myRange1.Text = textBox1.Text;


            Microsoft.Office.Interop.Word.Range myRange2 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f2       = myRange2.Find;
            f2.Text = "检测状态:空载(半载或满载)";
            f2.ClearFormatting();

            bool finded2 = f2.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange2      = wordDoc.Range(myRange2.End - 9, myRange2.End);
            myRange2.Text = comboBox1.Text;


            wordDoc.Save();
            wordDoc.Close(ref G_Missing, ref G_Missing, ref G_Missing);
            wordApp.Quit(ref G_Missing, ref G_Missing, ref G_Missing);
            wordApp = null;

            string ImagePath     = pictureBox1.ImageLocation;
            string strKey        = "示意图:(上层,中层,下层)";
            object MissingValue  = Type.Missing;
            bool   isFindSealLoc = false;

            Microsoft.Office.Interop.Word.Application wp = null;
            Microsoft.Office.Interop.Word.Document    wd = null;
            try
            {
                wp = new Microsoft.Office.Interop.Word.Application();
                wd = wp.Documents.Open(ref filename1, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue);
                wp.Selection.Find.ClearFormatting();
                wp.Selection.Find.Replacement.ClearFormatting();
                wp.Selection.Find.Text = strKey;
                object objReplace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                              ref MissingValue, ref MissingValue, ref MissingValue,
                                              ref MissingValue, ref MissingValue, ref MissingValue,
                                              ref MissingValue, ref objReplace, ref MissingValue,
                                              ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor           = wp.Selection.Range;
                    object LinkToFile       = false;
                    object SaveWithDocument = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape = wp.Selection.InlineShapes.AddPicture(
                        ImagePath, ref LinkToFile, ref SaveWithDocument, ref Anchor);
                    Inlineshape.Select();
                    Microsoft.Office.Interop.Word.Shape shape = Inlineshape.ConvertToShape();
                    shape.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd != null)
                {
                    wd.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd);
                    wd = null;
                }
                if (wp != null)
                {
                    wp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp);
                    wp = null;
                }
            }

            string filename = Environment.CurrentDirectory.ToString() + "\\bin\\" + Global.templateName + ".doc";

            Spire.Doc.Document document = new Spire.Doc.Document(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox   = document.TextBoxes[0];
            Spire.Doc.Documents.Paragraph paragraph = textBox.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange = paragraph.AppendText(textBox3.Text);
            document.SaveToFile(filename, FileFormat.Docx);
            this.Close();
        }
Exemplo n.º 6
0
        // Will allow the Volunteer to print the patient's information
        private void printButon_Click(object sender, EventArgs e)
        {
            if (Program.currentPatient.directory.location.bedNum != 0 && Program.currentPatient.directory.location.bedNum != null)
            {
                string noInfo = "Information not provided";

                Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
                var myWordDoc = app.Documents.Open(@"F:\PIMS_Final\FORMS\PIMS VOLUNTEER FORM.docx", ReadOnly: false, Visible: true);
                app.Visible = true;

                Microsoft.Office.Interop.Word.Find fndLastName = myWordDoc.ActiveWindow.Selection.Find;
                fndLastName.Text = "@lname";

                if (Program.currentPatient.directory.lName.ToString() == "")
                {
                    fndLastName.Replacement.Text = noInfo;
                }
                else
                {
                    fndLastName.Replacement.Text = Program.currentPatient.directory.lName.ToString();
                }
                fndLastName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find fndFirstName = myWordDoc.ActiveWindow.Selection.Find;
                fndFirstName.Text = "@fname";

                if (Program.currentPatient.directory.fName.ToString() == "")
                {
                    fndFirstName.Replacement.Text = noInfo;
                }
                else
                {
                    fndFirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
                }
                fndFirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find fndDOB = myWordDoc.ActiveWindow.Selection.Find;
                fndDOB.Text = "@dob";

                if (Program.currentPatient.directory.DOB.Date.ToShortDateString() == "")
                {
                    fndDOB.Replacement.Text = noInfo;
                }
                else
                {
                    fndDOB.Replacement.Text = Program.currentPatient.directory.DOB.Date.ToShortDateString();
                }
                fndDOB.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find findGender = myWordDoc.ActiveWindow.Selection.Find;
                findGender.Text             = "@gender";
                findGender.Replacement.Text = Program.currentPatient.directory.gender ? "M" : "F";
                findGender.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find findFloor = myWordDoc.ActiveWindow.Selection.Find;
                findFloor.Text = "@floor";

                if (Program.currentPatient.directory.location.floor.ToString() == "")
                {
                    findFloor.Replacement.Text = noInfo;
                }
                else
                {
                    findFloor.Replacement.Text = Program.currentPatient.directory.location.floor.ToString();
                }
                findFloor.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find findRoom = myWordDoc.ActiveWindow.Selection.Find;
                findRoom.Text = "@room";

                if (Program.currentPatient.directory.location.floor.ToString() == "")
                {
                    findRoom.Replacement.Text = noInfo;
                }
                else
                {
                    findRoom.Replacement.Text = Program.currentPatient.directory.location.floor.ToString();
                }
                findRoom.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find findBed = myWordDoc.ActiveWindow.Selection.Find;
                findBed.Text = "@bed";

                if (Program.currentPatient.directory.location.bedNum.ToString() == "")
                {
                    findBed.Replacement.Text = noInfo;
                }
                else
                {
                    findBed.Replacement.Text = Program.currentPatient.directory.location.bedNum.ToString();
                }
                findBed.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                Microsoft.Office.Interop.Word.Find findUnit = myWordDoc.ActiveWindow.Selection.Find;
                findUnit.Text = "@unit";

                if (Program.currentPatient.directory.location.unit.ToString() == "")
                {
                    findUnit.Replacement.Text = noInfo;
                }
                else
                {
                    findUnit.Replacement.Text = Program.currentPatient.directory.location.unit.ToString();
                }
                findUnit.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

                myWordDoc.SaveAs2(@"F:\PIMS_Final\FORMS\" + Program.currentPatient.directory.lName + "." + Program.currentPatient.directory.fName + ".Volunteer Information.pdf");
                myWordDoc.PrintPreview();
            }
            else
            {
                // Display information message
                MessageBox.Show("Patient is not admitted in the hospital.\n There is no need to print this information.",
                                "No information to print!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            object filename1 = Application.StartupPath + "\\bin\\" + Global.templateName;

            object G_Missing = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document    wordDoc;
            wordDoc = wordApp.Documents.Open(filename1);
            wordDoc.ActiveWindow.Visible = false;//打开word

            Microsoft.Office.Interop.Word.Range myRange = wordDoc.Range();

            Microsoft.Office.Interop.Word.Find f = myRange.Find;
            f.Text = "布点数量:";
            f.ClearFormatting();

            bool finded = f.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                    );

            myRange      = wordDoc.Range(myRange.End, myRange.End + 6);
            myRange.Text = textBox1.Text;

            Microsoft.Office.Interop.Word.Range myRange1 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f1       = myRange1.Find;
            f1.Text = "仪表编号:";
            f1.ClearFormatting();

            bool finded1 = f1.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange1      = wordDoc.Range(myRange1.End, myRange1.End + 9);
            myRange1.Text = textBox2.Text;

            Microsoft.Office.Interop.Word.Range myRange2 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f2       = myRange2.Find;
            f2.Text = "测量点数量:";
            f2.ClearFormatting();

            bool finded2 = f2.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange2      = wordDoc.Range(myRange2.End, myRange2.End + 6);
            myRange2.Text = textBox6.Text;

            Microsoft.Office.Interop.Word.Range myRange3 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f3       = myRange3.Find;
            f3.Text = "仪表编号: ";
            f3.ClearFormatting();

            bool finded3 = f3.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange3      = wordDoc.Range(myRange3.End, myRange3.End + 8);
            myRange3.Text = textBox5.Text;

            Microsoft.Office.Interop.Word.Range myRange4 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f4       = myRange4.Find;
            f4.Text = "测量点数量: ";
            f4.ClearFormatting();

            bool finded4 = f4.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange4      = wordDoc.Range(myRange4.End, myRange4.End + 5);
            myRange4.Text = textBox9.Text;

            Microsoft.Office.Interop.Word.Range myRange5 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f5       = myRange5.Find;
            f5.Text = "仪表编号:  ";
            f5.ClearFormatting();

            bool finded5 = f5.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange5      = wordDoc.Range(myRange5.End, myRange5.End + 7);
            myRange5.Text = textBox8.Text;

            Microsoft.Office.Interop.Word.Range myRange6 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f6       = myRange6.Find;
            f6.Text = "测量点数量:  ";
            f6.ClearFormatting();

            bool finded6 = f6.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange6      = wordDoc.Range(myRange6.End, myRange6.End + 4);
            myRange6.Text = textBox12.Text;

            Microsoft.Office.Interop.Word.Range myRange7 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f7       = myRange7.Find;
            f7.Text = "仪表编号:   ";
            f7.ClearFormatting();

            bool finded7 = f7.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange7      = wordDoc.Range(myRange7.End, myRange7.End + 6);
            myRange7.Text = textBox11.Text;

            Microsoft.Office.Interop.Word.Range myRange8 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f8       = myRange8.Find;
            f8.Text = "测量点数量:   ";
            f8.ClearFormatting();

            bool finded8 = f8.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange8      = wordDoc.Range(myRange8.End, myRange8.End + 3);
            myRange8.Text = textBox15.Text;

            Microsoft.Office.Interop.Word.Range myRange9 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f9       = myRange9.Find;
            f9.Text = "仪表编号:    ";
            f9.ClearFormatting();

            bool finded9 = f9.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange9      = wordDoc.Range(myRange9.End, myRange9.End + 5);
            myRange9.Text = textBox14.Text;

            Microsoft.Office.Interop.Word.Range myRange10 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f10       = myRange10.Find;
            f10.Text = "测量点数量:    ";
            f10.ClearFormatting();

            bool finded10 = f10.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                        );

            myRange10      = wordDoc.Range(myRange10.End, myRange10.End + 2);
            myRange10.Text = textBox18.Text;

            Microsoft.Office.Interop.Word.Range myRange11 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f11       = myRange11.Find;
            f11.Text = "仪表编号:     ";
            f11.ClearFormatting();

            bool finded11 = f11.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                        );

            myRange11      = wordDoc.Range(myRange11.End, myRange11.End + 4);
            myRange11.Text = textBox17.Text;

            Microsoft.Office.Interop.Word.Range myRange12 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f12       = myRange12.Find;
            f12.Text = "测量点数量:     ";
            f12.ClearFormatting();

            bool finded12 = f12.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                        );

            myRange12      = wordDoc.Range(myRange12.End, myRange12.End + 1);
            myRange12.Text = textBox21.Text;

            Microsoft.Office.Interop.Word.Range myRange13 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f13       = myRange13.Find;
            f13.Text = "仪表编号:      ";
            f13.ClearFormatting();

            bool finded13 = f13.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                        );

            myRange13      = wordDoc.Range(myRange13.End, myRange13.End + 3);
            myRange13.Text = textBox20.Text;


            wordDoc.Save();
            wordDoc.Close();
            wordApp.Quit();
            wordApp = null;



            string ImagePath     = pictureBox1.ImageLocation;
            string strKey        = "示意图:(上层,中层,下层)";
            object MissingValue  = Type.Missing;
            bool   isFindSealLoc = false;

            Microsoft.Office.Interop.Word.Application wp = null;
            Microsoft.Office.Interop.Word.Document    wd = null;
            try
            {
                wp = new Microsoft.Office.Interop.Word.Application();
                wd = wp.Documents.Open(ref filename1, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue,
                                       ref MissingValue, ref MissingValue);
                wp.Selection.Find.ClearFormatting();
                wp.Selection.Find.Replacement.ClearFormatting();
                wp.Selection.Find.Text = strKey;
                object objReplace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                              ref MissingValue, ref MissingValue, ref MissingValue,
                                              ref MissingValue, ref MissingValue, ref MissingValue,
                                              ref MissingValue, ref objReplace, ref MissingValue,
                                              ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor           = wp.Selection.Range;
                    object LinkToFile       = false;
                    object SaveWithDocument = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape = wp.Selection.InlineShapes.AddPicture(
                        ImagePath, ref LinkToFile, ref SaveWithDocument, ref Anchor);
                    Inlineshape.Select();
                    Microsoft.Office.Interop.Word.Shape shape = Inlineshape.ConvertToShape();
                    shape.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd != null)
                {
                    wd.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd);
                    wd = null;
                }
                if (wp != null)
                {
                    wp.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp);
                    wp = null;
                }
            }

            string ImagePath1     = pictureBox2.ImageLocation;
            string strKey1        = "6.1.2风机出风口布点";
            object MissingValue1  = Type.Missing;
            bool   isFindSealLoc1 = false;

            Microsoft.Office.Interop.Word.Application wp1 = null;
            Microsoft.Office.Interop.Word.Document    wd1 = null;
            try
            {
                wp1 = new Microsoft.Office.Interop.Word.Application();
                wd1 = wp1.Documents.Open(ref filename1, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue);
                wp1.Selection.Find.ClearFormatting();
                wp1.Selection.Find.Replacement.ClearFormatting();
                wp1.Selection.Find.Text = strKey1;
                object objReplace1 = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp1.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref objReplace1, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor1           = wp1.Selection.Range;
                    object LinkToFile1       = false;
                    object SaveWithDocument1 = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape1 = wp1.Selection.InlineShapes.AddPicture(
                        ImagePath1, ref LinkToFile1, ref SaveWithDocument1, ref Anchor1);
                    Inlineshape1.Select();
                    Microsoft.Office.Interop.Word.Shape shape1 = Inlineshape1.ConvertToShape();
                    shape1.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc1 = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd1 != null)
                {
                    wd1.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd1);
                    wd1 = null;
                }
                if (wp1 != null)
                {
                    wp1.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp1);
                    wp1 = null;
                }
            }

            string ImagePath2     = pictureBox3.ImageLocation;
            string strKey2        = "6.1.3出入口布点";
            object MissingValue2  = Type.Missing;
            bool   isFindSealLoc2 = false;

            Microsoft.Office.Interop.Word.Application wp2 = null;
            Microsoft.Office.Interop.Word.Document    wd2 = null;
            try
            {
                wp2 = new Microsoft.Office.Interop.Word.Application();
                wd2 = wp2.Documents.Open(ref filename1, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue);
                wp2.Selection.Find.ClearFormatting();
                wp2.Selection.Find.Replacement.ClearFormatting();
                wp2.Selection.Find.Text = strKey2;
                object objReplace2 = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp2.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref objReplace2, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor2           = wp2.Selection.Range;
                    object LinkToFile2       = false;
                    object SaveWithDocument2 = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape2 = wp2.Selection.InlineShapes.AddPicture(
                        ImagePath2, ref LinkToFile2, ref SaveWithDocument2, ref Anchor2);
                    Inlineshape2.Select();
                    Microsoft.Office.Interop.Word.Shape shape2 = Inlineshape2.ConvertToShape();
                    shape2.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc2 = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd2 != null)
                {
                    wd2.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd2);
                    wd2 = null;
                }
                if (wp2 != null)
                {
                    wp2.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp2);
                    wp2 = null;
                }
            }

            string ImagePath3     = pictureBox4.ImageLocation;
            string strKey3        = "6.1.4死角布点";
            object MissingValue3  = Type.Missing;
            bool   isFindSealLoc3 = false;

            Microsoft.Office.Interop.Word.Application wp3 = null;
            Microsoft.Office.Interop.Word.Document    wd3 = null;
            try
            {
                wp3 = new Microsoft.Office.Interop.Word.Application();
                wd3 = wp3.Documents.Open(ref filename1, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue);
                wp3.Selection.Find.ClearFormatting();
                wp3.Selection.Find.Replacement.ClearFormatting();
                wp3.Selection.Find.Text = strKey3;
                object objReplace3 = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp3.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref objReplace3, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor3           = wp3.Selection.Range;
                    object LinkToFile3       = false;
                    object SaveWithDocument3 = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape3 = wp3.Selection.InlineShapes.AddPicture(
                        ImagePath3, ref LinkToFile3, ref SaveWithDocument3, ref Anchor3);
                    Inlineshape3.Select();
                    Microsoft.Office.Interop.Word.Shape shape3 = Inlineshape3.ConvertToShape();
                    shape3.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc3 = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd3 != null)
                {
                    wd3.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd3);
                    wd3 = null;
                }
                if (wp3 != null)
                {
                    wp3.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp3);
                    wp3 = null;
                }
            }

            string ImagePath4     = pictureBox5.ImageLocation;
            string strKey4        = "6.1.5死角布点";
            object MissingValue4  = Type.Missing;
            bool   isFindSealLoc4 = false;

            Microsoft.Office.Interop.Word.Application wp4 = null;
            Microsoft.Office.Interop.Word.Document    wd4 = null;
            try
            {
                wp4 = new Microsoft.Office.Interop.Word.Application();
                wd4 = wp4.Documents.Open(ref filename1, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue);
                wp4.Selection.Find.ClearFormatting();
                wp4.Selection.Find.Replacement.ClearFormatting();
                wp4.Selection.Find.Text = strKey4;
                object objReplace4 = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp4.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref objReplace4, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor4           = wp4.Selection.Range;
                    object LinkToFile4       = false;
                    object SaveWithDocument4 = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape4 = wp4.Selection.InlineShapes.AddPicture(
                        ImagePath4, ref LinkToFile4, ref SaveWithDocument4, ref Anchor4);
                    Inlineshape4.Select();
                    Microsoft.Office.Interop.Word.Shape shape4 = Inlineshape4.ConvertToShape();
                    shape4.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc4 = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd4 != null)
                {
                    wd4.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd4);
                    wd4 = null;
                }
                if (wp4 != null)
                {
                    wp4.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp4);
                    wp4 = null;
                }
            }

            string ImagePath5     = pictureBox6.ImageLocation;
            string strKey5        = "6.1.6货架布点";
            object MissingValue5  = Type.Missing;
            bool   isFindSealLoc5 = false;

            Microsoft.Office.Interop.Word.Application wp5 = null;
            Microsoft.Office.Interop.Word.Document    wd5 = null;
            try
            {
                wp5 = new Microsoft.Office.Interop.Word.Application();
                wd5 = wp5.Documents.Open(ref filename1, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue);
                wp5.Selection.Find.ClearFormatting();
                wp5.Selection.Find.Replacement.ClearFormatting();
                wp5.Selection.Find.Text = strKey5;
                object objReplace5 = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp5.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref objReplace5, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor5           = wp5.Selection.Range;
                    object LinkToFile5       = false;
                    object SaveWithDocument5 = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape5 = wp5.Selection.InlineShapes.AddPicture(
                        ImagePath5, ref LinkToFile5, ref SaveWithDocument5, ref Anchor5);
                    Inlineshape5.Select();
                    Microsoft.Office.Interop.Word.Shape shape5 = Inlineshape5.ConvertToShape();
                    shape5.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc5 = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd5 != null)
                {
                    wd5.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd5);
                    wd5 = null;
                }
                if (wp5 != null)
                {
                    wp5.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp5);
                    wp5 = null;
                }
            }

            string ImagePath6     = pictureBox7.ImageLocation;
            string strKey6        = "6.1.7监控系统探头及验证环境布点";
            object MissingValue6  = Type.Missing;
            bool   isFindSealLoc6 = false;

            Microsoft.Office.Interop.Word.Application wp6 = null;
            Microsoft.Office.Interop.Word.Document    wd6 = null;
            try
            {
                wp6 = new Microsoft.Office.Interop.Word.Application();
                wd6 = wp6.Documents.Open(ref filename1, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue,
                                         ref MissingValue, ref MissingValue);
                wp6.Selection.Find.ClearFormatting();
                wp6.Selection.Find.Replacement.ClearFormatting();
                wp6.Selection.Find.Text = strKey6;
                object objReplace6 = Microsoft.Office.Interop.Word.WdReplace.wdReplaceNone;
                if (wp6.Selection.Find.Execute(ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue,
                                               ref MissingValue, ref objReplace6, ref MissingValue,
                                               ref MissingValue, ref MissingValue, ref MissingValue))
                {
                    object Anchor6           = wp6.Selection.Range;
                    object LinkToFile6       = false;
                    object SaveWithDocument6 = true;
                    Microsoft.Office.Interop.Word.InlineShape Inlineshape6 = wp6.Selection.InlineShapes.AddPicture(
                        ImagePath6, ref LinkToFile6, ref SaveWithDocument6, ref Anchor6);
                    Inlineshape6.Select();
                    Microsoft.Office.Interop.Word.Shape shape6 = Inlineshape6.ConvertToShape();
                    shape6.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapBehind;

                    isFindSealLoc6 = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                if (wd6 != null)
                {
                    wd6.Close();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wd6);
                    wd6 = null;
                }
                if (wp6 != null)
                {
                    wp6.Quit();
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(wp6);
                    wp6 = null;
                }
                MessageBox.Show("导入成功!");
            }


            #region  除后台word占用。
            System.Diagnostics.Process myproc = new System.Diagnostics.Process();
            //得到所有打开的进程
            try
            {
                foreach (Process thisproc in Process.GetProcessesByName("WINWORD"))
                {
                    if (!thisproc.CloseMainWindow())
                    {
                        thisproc.Kill();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("杀死" + "WINWORD" + "失败!");
            }
            #endregion


            string             filename = Environment.CurrentDirectory.ToString() + "\\bin\\" + Global.templateName + ".doc";
            Spire.Doc.Document document = new Spire.Doc.Document(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox   = document.TextBoxes[2];
            Spire.Doc.Documents.Paragraph paragraph = textBox.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange = paragraph.AppendText(textBox3.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox111 = document.TextBoxes[3];
            Spire.Doc.Documents.Paragraph paragraph1 = textBox111.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange1 = paragraph1.AppendText(textBox4.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox22  = document.TextBoxes[4];
            Spire.Doc.Documents.Paragraph paragraph2 = textBox22.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange2 = paragraph2.AppendText(textBox7.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox33   = document.TextBoxes[5];
            Spire.Doc.Documents.Paragraph paragraph33 = textBox33.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange33 = paragraph33.AppendText(textBox10.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox55  = document.TextBoxes[6];
            Spire.Doc.Documents.Paragraph paragraph5 = textBox55.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange5 = paragraph5.AppendText(textBox13.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox66  = document.TextBoxes[7];
            Spire.Doc.Documents.Paragraph paragraph6 = textBox66.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange6 = paragraph6.AppendText(textBox16.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            Spire.Doc.Fields.TextBox      textBox88  = document.TextBoxes[8];
            Spire.Doc.Documents.Paragraph paragraph8 = textBox88.Body.AddParagraph();
            Spire.Doc.Fields.TextRange    textRange8 = paragraph8.AppendText(textBox19.Text);
            document.SaveToFile(filename, FileFormat.Docx);

            MessageBox.Show("导入成功!");
            this.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            object filename = Application.StartupPath + "\\bin\\" + Global.templateName;

            object G_Missing = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
            Microsoft.Office.Interop.Word.Document    wordDoc;
            wordDoc = wordApp.Documents.Open(filename);
            wordDoc.ActiveWindow.Visible = false;//打开word

            Microsoft.Office.Interop.Word.Range myRange = wordDoc.Range();

            Microsoft.Office.Interop.Word.Find f = myRange.Find;
            f.Text = "环境温度:";
            f.ClearFormatting();

            bool finded = f.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                    ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                    );

            myRange      = wordDoc.Range(myRange.End, myRange.End + 16);
            myRange.Text = textBox1.Text;

            Microsoft.Office.Interop.Word.Range myRange1 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f1       = myRange1.Find;
            f1.Text = "环境湿度:";
            f1.ClearFormatting();

            bool finded1 = f1.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange1      = wordDoc.Range(myRange1.End, myRange1.End + 16);
            myRange1.Text = textBox2.Text;

            Microsoft.Office.Interop.Word.Range myRange2 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f2       = myRange2.Find;
            f2.Text = "结果:";
            f2.ClearFormatting();

            bool finded2 = f2.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange2      = wordDoc.Range(myRange2.End, myRange2.End + 49);
            myRange2.Text = textBox3.Text;

            Microsoft.Office.Interop.Word.Range myRange3 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f3       = myRange3.Find;
            f3.Text = "检查人.:";
            f3.ClearFormatting();

            bool finded3 = f3.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange3      = wordDoc.Range(myRange3.End, myRange3.End + 18);
            myRange3.Text = textBox4.Text;

            Microsoft.Office.Interop.Word.Range myRange4 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f4       = myRange4.Find;
            f4.Text = "检查日期.: ";
            f4.ClearFormatting();

            bool finded4 = f4.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange4      = wordDoc.Range(myRange4.End, myRange4.End + 21);
            myRange4.Text = textBox5.Text;

            Microsoft.Office.Interop.Word.Range myRange5 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f5       = myRange5.Find;
            f5.Text = "复核人.:";
            f5.ClearFormatting();

            bool finded5 = f5.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange5      = wordDoc.Range(myRange5.End, myRange5.End + 18);
            myRange5.Text = textBox6.Text;

            Microsoft.Office.Interop.Word.Range myRange6 = wordDoc.Range();
            Microsoft.Office.Interop.Word.Find  f6       = myRange6.Find;
            f6.Text = "复核日期.:";
            f6.ClearFormatting();

            bool finded6 = f6.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                      ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                      );

            myRange6      = wordDoc.Range(myRange6.End, myRange6.End + 10);
            myRange6.Text = textBox7.Text;

            Microsoft.Office.Interop.Word.Table nowtable = wordDoc.Tables[7];
            nowtable.Cell(1, 2).Range.InsertAfter(textBox10.Text);
            nowtable.Cell(2, 2).Range.InsertAfter(textBox8.Text);
            nowtable.Cell(3, 2).Range.InsertAfter(textBox9.Text);
            nowtable.Cell(4, 1).Range.InsertAfter(textBox12.Text);
            nowtable.Cell(4, 2).Range.InsertAfter(textBox11.Text);

            wordDoc.Save();
            wordApp.Quit(null, null, null);
            wordApp = null;
            this.Close();
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox2.Text != "")
            {
                #region 冷库
                if (comboBox2.Text == "冷库验证项目模拟报告模板")
                {
                    object filename = Application.StartupPath + "\\bin\\" + Global.templateName;

                    object G_Missing = System.Reflection.Missing.Value;
                    Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                    Microsoft.Office.Interop.Word.Document    wordDoc;
                    wordDoc = wordApp.Documents.Open(filename);
                    wordDoc.ActiveWindow.Visible = false;//打开word

                    Microsoft.Office.Interop.Word.Range myRange = wordDoc.Range();

                    Microsoft.Office.Interop.Word.Find f = myRange.Find;
                    f.Text = "冷库名称/编号:";
                    f.ClearFormatting();

                    bool finded = f.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                            );

                    myRange      = wordDoc.Range(myRange.End, myRange.End + 28);
                    myRange.Text = textBox1.Text;

                    Microsoft.Office.Interop.Word.Range myRange1 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f1       = myRange1.Find;
                    f1.Text = ":长";
                    f1.ClearFormatting();

                    bool finded1 = f1.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange1      = wordDoc.Range(myRange1.End, myRange1.End + 4);
                    myRange1.Text = textBox2.Text;

                    Microsoft.Office.Interop.Word.Range myRange2 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f2       = myRange2.Find;
                    f2.Text = ",宽";
                    f2.ClearFormatting();

                    bool finded2 = f2.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange2      = wordDoc.Range(myRange2.End, myRange2.End + 4);
                    myRange2.Text = textBox4.Text;

                    Microsoft.Office.Interop.Word.Range myRange3 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f3       = myRange3.Find;
                    f3.Text = ",高";
                    f3.ClearFormatting();

                    bool finded3 = f3.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange3      = wordDoc.Range(myRange3.End, myRange3.End + 4);
                    myRange3.Text = textBox5.Text;

                    Microsoft.Office.Interop.Word.Range myRange4 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f4       = myRange4.Find;
                    f4.Text = "体积约为";
                    f4.ClearFormatting();

                    bool finded4 = f4.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange4      = wordDoc.Range(myRange4.End, myRange4.End + 6);
                    myRange4.Text = textBox6.Text;

                    Microsoft.Office.Interop.Word.Range myRange5 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f5       = myRange5.Find;
                    f5.Text = "出入口";
                    f5.ClearFormatting();

                    bool finded5 = f5.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange5      = wordDoc.Range(myRange5.End, myRange5.End + 4);
                    myRange5.Text = textBox3.Text;

                    Microsoft.Office.Interop.Word.Range myRange6 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f6       = myRange6.Find;
                    f6.Text = "货架数量";
                    f6.ClearFormatting();

                    bool finded6 = f6.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange6      = wordDoc.Range(myRange6.End, myRange6.End + 5);
                    myRange6.Text = textBox7.Text;

                    Microsoft.Office.Interop.Word.Range myRange7 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f7       = myRange7.Find;
                    f7.Text = "监控系统探头";
                    f7.ClearFormatting();

                    bool finded7 = f7.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange7      = wordDoc.Range(myRange7.End, myRange7.End + 6);
                    myRange7.Text = textBox8.Text;

                    Microsoft.Office.Interop.Word.Range myRange8 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f8       = myRange8.Find;
                    f8.Text = "6风机";
                    f8.ClearFormatting();

                    bool finded8 = f8.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange8      = wordDoc.Range(myRange8.End, myRange8.End + 4);
                    myRange8.Text = textBox9.Text;

                    Microsoft.Office.Interop.Word.Range myRange9 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f9       = myRange9.Find;
                    f9.Text = "(  ";
                    f9.ClearFormatting();

                    bool finded9 = f9.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange9      = wordDoc.Range(myRange9.End, myRange9.End + 2);
                    myRange9.Text = textBox10.Text;

                    Microsoft.Office.Interop.Word.Range myRange10 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f10       = myRange10.Find;
                    f10.Text = "~";
                    f10.ClearFormatting();

                    bool finded10 = f10.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                                );

                    myRange10      = wordDoc.Range(myRange10.End, myRange10.End + 2);
                    myRange10.Text = textBox12.Text;

                    Microsoft.Office.Interop.Word.Range myRange11 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f11       = myRange11.Find;
                    f11.Text = "(   ";
                    f11.ClearFormatting();

                    bool finded11 = f11.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                                );

                    myRange11      = wordDoc.Range(myRange11.End, myRange11.End + 2);
                    myRange11.Text = textBox11.Text;

                    Microsoft.Office.Interop.Word.Range myRange12 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f12       = myRange12.Find;
                    f12.Text = "~ ";
                    f12.ClearFormatting();

                    bool finded12 = f12.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                                );

                    myRange12      = wordDoc.Range(myRange12.End, myRange12.End + 2);
                    myRange12.Text = textBox13.Text;

                    wordDoc.Close();
                    wordApp.Quit();
                    wordApp = null;

                    try
                    {
                        Global.objectLen    = Convert.ToDouble(textBox2.Text);
                        Global.objectWidth  = Convert.ToDouble(textBox4.Text);
                        Global.objectHeight = Convert.ToDouble(textBox5.Text);


                        Global.tempLimitLow  = Convert.ToDouble(textBox10.Text);
                        Global.tempLimitHigh = Convert.ToDouble(textBox12.Text);
                    }
                    catch (Exception)
                    {
                    }
                    this.Close();
                }
                #endregion

                #region 灭菌器
                if (comboBox2.Text == "灭菌器验证项目模拟报告模板")
                {
                    object filename = Application.StartupPath + "\\bin\\" + Global.templateName;
                    Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                    Microsoft.Office.Interop.Word.Document    wordDoc;
                    wordDoc = wordApp.Documents.Open(filename);
                    wordDoc.ActiveWindow.Visible = false;
                    Microsoft.Office.Interop.Word.Table nowtable2 = wordDoc.Tables[4];
                    nowtable2.Cell(2, 3).Range.InsertAfter(textBox25.Text);
                    nowtable2.Cell(3, 3).Range.InsertAfter(textBox26.Text);
                    nowtable2.Cell(4, 3).Range.InsertAfter(textBox27.Text);
                    nowtable2.Cell(5, 3).Range.InsertAfter(textBox28.Text);
                    nowtable2.Cell(2, 4).Range.InsertAfter(textBox29.Text);
                    nowtable2.Cell(3, 4).Range.InsertAfter(textBox30.Text);
                    nowtable2.Cell(4, 4).Range.InsertAfter(textBox31.Text);
                    nowtable2.Cell(5, 4).Range.InsertAfter(textBox32.Text);
                    nowtable2.Cell(6, 1).Range.InsertAfter(textBox34.Text);
                    nowtable2.Cell(6, 2).Range.InsertAfter(textBox44.Text);
                    nowtable2.Cell(7, 1).Range.InsertAfter(textBox45.Text);
                    nowtable2.Cell(7, 2).Range.InsertAfter(textBox46.Text);

                    Microsoft.Office.Interop.Word.Table nowtable = wordDoc.Tables[5];
                    nowtable.Cell(2, 4).Range.InsertAfter(textBox33.Text);
                    nowtable.Cell(3, 4).Range.InsertAfter(textBox39.Text);
                    nowtable.Cell(4, 4).Range.InsertAfter(textBox41.Text);
                    nowtable.Cell(5, 4).Range.InsertAfter(textBox47.Text);
                    nowtable.Cell(6, 4).Range.InsertAfter(textBox48.Text);
                    nowtable.Cell(7, 1).Range.InsertAfter(textBox34.Text);
                    nowtable.Cell(7, 2).Range.InsertAfter(textBox44.Text);
                    nowtable.Cell(8, 1).Range.InsertAfter(textBox45.Text);
                    nowtable.Cell(8, 2).Range.InsertAfter(textBox46.Text);

                    Microsoft.Office.Interop.Word.Table nowtable1 = wordDoc.Tables[6];
                    nowtable1.Cell(2, 4).Range.InsertAfter(textBox35.Text);
                    nowtable1.Cell(3, 4).Range.InsertAfter(textBox36.Text);
                    nowtable1.Cell(4, 4).Range.InsertAfter(textBox37.Text);
                    nowtable1.Cell(5, 4).Range.InsertAfter(textBox38.Text);
                    nowtable1.Cell(6, 4).Range.InsertAfter(textBox40.Text);
                    nowtable1.Cell(7, 4).Range.InsertAfter(textBox42.Text);
                    nowtable1.Cell(8, 4).Range.InsertAfter(textBox43.Text);
                    nowtable1.Cell(9, 1).Range.InsertAfter(textBox34.Text);
                    nowtable1.Cell(9, 2).Range.InsertAfter(textBox44.Text);
                    nowtable1.Cell(10, 1).Range.InsertAfter(textBox45.Text);
                    nowtable1.Cell(10, 2).Range.InsertAfter(textBox46.Text);
                    wordDoc.Save();
                    wordApp.Quit();
                    wordApp = null;
                    this.Close();



                    try
                    {
                        Global.objectLen    = Convert.ToDouble(textBox15.Text);
                        Global.objectWidth  = Convert.ToDouble(textBox19.Text);
                        Global.objectHeight = Convert.ToDouble(textBox20.Text);



                        Global.tempLimitLow = Convert.ToDouble(textBox16.Text);

                        Global.tempLimitHigh = Convert.ToDouble(textBox18.Text);
                    }
                    catch (Exception)
                    {
                    }
                }

                #endregion

                #region 高温热处理炉
                if (comboBox2.Text == "高温热处理炉验证项目模拟报告模板")
                {
                    object filename = Application.StartupPath + "\\bin\\" + Global.templateName;

                    object G_Missing = System.Reflection.Missing.Value;
                    Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                    Microsoft.Office.Interop.Word.Document    wordDoc;
                    wordDoc = wordApp.Documents.Open(filename);
                    wordDoc.ActiveWindow.Visible = false;//打开word

                    Microsoft.Office.Interop.Word.Range myRange = wordDoc.Range();

                    Microsoft.Office.Interop.Word.Find f = myRange.Find;
                    f.Text = "2.1.1热处理炉型号/编号:";
                    f.ClearFormatting();

                    bool finded = f.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                            );

                    myRange      = wordDoc.Range(myRange.End, myRange.End + 28);
                    myRange.Text = textBox14.Text;

                    Microsoft.Office.Interop.Word.Range myRange1 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f1       = myRange1.Find;
                    f1.Text = "2.1.2热处理炉制造厂家:";
                    f1.ClearFormatting();

                    bool finded1 = f1.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange1      = wordDoc.Range(myRange1.End, myRange1.End + 28);
                    myRange1.Text = textBox23.Text;

                    Microsoft.Office.Interop.Word.Range myRange2 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f2       = myRange2.Find;
                    f2.Text = "2.1.3热处理炉规格(内径):长";
                    f2.ClearFormatting();

                    bool finded2 = f2.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange2      = wordDoc.Range(myRange2.End, myRange2.End + 4);
                    myRange2.Text = textBox15.Text;

                    Microsoft.Office.Interop.Word.Range myRange3 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f3       = myRange3.Find;
                    f3.Text = ",宽";
                    f3.ClearFormatting();

                    bool finded3 = f3.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange3      = wordDoc.Range(myRange3.End, myRange3.End + 4);
                    myRange3.Text = textBox19.Text;

                    Microsoft.Office.Interop.Word.Range myRange4 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f4       = myRange4.Find;
                    f4.Text = ",高";
                    f4.ClearFormatting();

                    bool finded4 = f4.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange4      = wordDoc.Range(myRange4.End, myRange4.End + 4);
                    myRange4.Text = textBox20.Text;

                    Microsoft.Office.Interop.Word.Range myRange5 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f5       = myRange5.Find;
                    f5.Text = "体积约为";
                    f5.ClearFormatting();

                    bool finded5 = f5.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange5      = wordDoc.Range(myRange5.End, myRange5.End + 6);
                    myRange5.Text = textBox21.Text;

                    Microsoft.Office.Interop.Word.Range myRange6 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f6       = myRange6.Find;
                    f6.Text = "2.1.4监控系统探头";
                    f6.ClearFormatting();

                    bool finded6 = f6.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange6      = wordDoc.Range(myRange6.End, myRange6.End + 6);
                    myRange6.Text = textBox17.Text;

                    Microsoft.Office.Interop.Word.Range myRange7 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f7       = myRange7.Find;
                    f7.Text = "(  ";
                    f7.ClearFormatting();

                    bool finded7 = f7.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange7      = wordDoc.Range(myRange7.End, myRange7.End + 5);
                    myRange7.Text = textBox16.Text;

                    Microsoft.Office.Interop.Word.Range myRange8 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f8       = myRange8.Find;
                    f8.Text = "~";
                    f8.ClearFormatting();

                    bool finded8 = f8.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange8      = wordDoc.Range(myRange8.End, myRange8.End + 7);
                    myRange8.Text = textBox18.Text;

                    Microsoft.Office.Interop.Word.Range myRange9 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f9       = myRange9.Find;
                    f9.Text = "2.2.2保温精度范围:";
                    f9.ClearFormatting();

                    bool finded9 = f9.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                              ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                              );

                    myRange9      = wordDoc.Range(myRange9.End, myRange9.End + 7);
                    myRange9.Text = textBox22.Text;

                    Microsoft.Office.Interop.Word.Range myRange10 = wordDoc.Range();
                    Microsoft.Office.Interop.Word.Find  f10       = myRange10.Find;
                    f10.Text = "2.2.3常用温度值:";
                    f10.ClearFormatting();

                    bool finded10 = f10.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                                ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                                );

                    myRange10      = wordDoc.Range(myRange10.End, myRange10.End + 12);
                    myRange10.Text = textBox24.Text;

                    wordDoc.Save();
                    wordApp.Quit();
                    wordApp = null;
                    this.Close();
                }
                #endregion
            }
            else
            {
                MessageBox.Show("请选择报表模板。");
            }
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region  除后台占用
            System.Diagnostics.Process myproc = new System.Diagnostics.Process();
            //得到所有打开的进程
            try
            {
                foreach (Process thisproc in Process.GetProcessesByName("WINWORD"))
                {
                    if (!thisproc.CloseMainWindow())
                    {
                        thisproc.Kill();
                    }
                }
            }
            catch (Exception ea)
            {
                MessageBox.Show("杀死" + "WINWORD" + "失败!");
            }
            #endregion

            try
            {
                #region 从Resource文件夹提取模板
                FileInfo f111 = new FileInfo(System.Windows.Forms.Application.StartupPath + "\\bin\\" + Global.templateName + ".doc");
                if (f111.Exists)
                {
                    f111.Delete();
                    FileInfo f222 = new FileInfo(System.Windows.Forms.Application.StartupPath + "\\bin\\" + "\\Resource\\" + Global.templateName + ".doc");
                    f222.CopyTo(System.Windows.Forms.Application.StartupPath + "\\bin\\" + Global.templateName + ".doc");
                }
                else
                {
                    FileInfo f222 = new FileInfo(System.Windows.Forms.Application.StartupPath + "\\bin\\" + "\\Resource\\" + Global.templateName + ".doc");
                    f222.CopyTo(System.Windows.Forms.Application.StartupPath + "\\bin\\" + Global.templateName + ".doc");
                }
                #endregion
            }
            catch (Exception)
            {
                MessageBox.Show("调取模板错误。");
            }

            try
            {
                object filename = Application.StartupPath + "\\bin\\" + Global.templateName;

                object G_Missing = System.Reflection.Missing.Value;
                Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                Microsoft.Office.Interop.Word.Document    wordDoc;
                wordDoc = wordApp.Documents.Open(filename);
                wordDoc.ActiveWindow.Visible = false;//打开word

                Microsoft.Office.Interop.Word.Range myRange = wordDoc.Range();

                Microsoft.Office.Interop.Word.Find f = myRange.Find;
                f.Text = "委托单位:";
                f.ClearFormatting();

                bool finded = f.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                        ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                        );

                myRange      = wordDoc.Range(myRange.End, myRange.End + 28);
                myRange.Text = textBox1.Text;

                Microsoft.Office.Interop.Word.Range myRange1 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f1       = myRange1.Find;
                f1.Text = "验证对象:";
                f1.ClearFormatting();

                bool finded1 = f1.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange1      = wordDoc.Range(myRange1.End, myRange1.End + 28);
                myRange1.Text = textBox2.Text;

                Microsoft.Office.Interop.Word.Range myRange2 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f2       = myRange2.Find;
                f2.Text = "验证地点:";
                f2.ClearFormatting();

                bool finded2 = f2.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange2      = wordDoc.Range(myRange2.End, myRange2.End + 24);
                myRange2.Text = textBox3.Text;

                Microsoft.Office.Interop.Word.Range myRange3 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f3       = myRange3.Find;
                f3.Text = "验证时间:";
                f3.ClearFormatting();

                bool finded3 = f3.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange3      = wordDoc.Range(myRange3.End, myRange3.End + 4);
                myRange3.Text = textBox4.Text;

                Microsoft.Office.Interop.Word.Range myRange4 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f4       = myRange4.Find;
                f4.Text = "年";
                f4.ClearFormatting();

                bool finded4 = f4.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange4      = wordDoc.Range(myRange4.End, myRange4.End + 2);
                myRange4.Text = textBox5.Text;

                Microsoft.Office.Interop.Word.Range myRange5 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f5       = myRange5.Find;
                f5.Text = "月";
                f5.ClearFormatting();

                bool finded5 = f5.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange5      = wordDoc.Range(myRange5.End, myRange5.End + 2);
                myRange5.Text = textBox6.Text;

                Microsoft.Office.Interop.Word.Range myRange6 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f6       = myRange6.Find;
                f6.Text = "至 ";
                f6.ClearFormatting();

                bool finded6 = f6.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange6      = wordDoc.Range(myRange6.End, myRange6.End + 4);
                myRange6.Text = textBox7.Text;

                Microsoft.Office.Interop.Word.Range myRange7 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f7       = myRange7.Find;
                f7.Text = "年 ";
                f7.ClearFormatting();

                bool finded7 = f7.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange7      = wordDoc.Range(myRange7.End, myRange7.End + 1);
                myRange7.Text = textBox8.Text;

                Microsoft.Office.Interop.Word.Range myRange8 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f8       = myRange8.Find;
                f8.Text = "月 ";
                f8.ClearFormatting();

                bool finded8 = f8.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange8      = wordDoc.Range(myRange8.End, myRange8.End + 1);
                myRange8.Text = textBox9.Text;

                Microsoft.Office.Interop.Word.Range myRange9 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f9       = myRange9.Find;
                f9.Text = "编写人员:";
                f9.ClearFormatting();

                bool finded9 = f9.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                          ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                          );

                myRange9      = wordDoc.Range(myRange9.End, myRange9.End + 16);
                myRange9.Text = textBox10.Text;

                Microsoft.Office.Interop.Word.Range myRange10 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f10       = myRange10.Find;
                f10.Text = "审核人员:";
                f10.ClearFormatting();

                bool finded10 = f10.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                            );

                myRange10      = wordDoc.Range(myRange10.End, myRange10.End + 14);
                myRange10.Text = textBox11.Text;

                Microsoft.Office.Interop.Word.Range myRange11 = wordDoc.Range();
                Microsoft.Office.Interop.Word.Find  f11       = myRange11.Find;
                f11.Text = "批准人员:";
                f11.ClearFormatting();

                bool finded11 = f11.Execute(ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing,
                                            ref G_Missing, ref G_Missing, ref G_Missing, ref G_Missing
                                            );

                myRange11      = wordDoc.Range(myRange11.End, myRange11.End + 14);
                myRange11.Text = textBox12.Text;

                wordDoc.Save();
                wordApp.Quit();
                wordApp = null;

                MessageBox.Show("成功调取模板并导入基本信息。");

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("请检查模板。");
            }
        }
Exemplo n.º 11
0
        // Will allow the user to print the patient's insurance information
        private void printButton_Click(object sender, EventArgs e)
        {
            string noInfo = "Information not provided";

            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
            var myWordDoc = app.Documents.Open(@"F:\PIMS_Final\FORMS\PIMS INSURANCE FORM.docx", ReadOnly: false, Visible: true);

            app.Visible = true;

            Microsoft.Office.Interop.Word.Find fndLastName = myWordDoc.ActiveWindow.Selection.Find;
            fndLastName.Text = "@lname";

            if (Program.currentPatient.directory.lName.ToString() == "")
            {
                fndLastName.Replacement.Text = noInfo;
            }
            else
            {
                fndLastName.Replacement.Text = Program.currentPatient.directory.lName.ToString();
            }
            fndLastName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find fndFirstName = myWordDoc.ActiveWindow.Selection.Find;
            fndFirstName.Text = "@fname";

            if (Program.currentPatient.directory.fName.ToString() == "")
            {
                fndFirstName.Replacement.Text = noInfo;
            }
            else
            {
                fndFirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
            }
            fndFirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findProvider = myWordDoc.ActiveWindow.Selection.Find;
            findProvider.Text = "@provider";

            if (Program.currentPatient.billing.insurance.provider.ToString() == "")
            {
                findProvider.Replacement.Text = noInfo;
            }
            else
            {
                findProvider.Replacement.Text = Program.currentPatient.billing.insurance.provider.ToString();
            }
            findProvider.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findBIN = myWordDoc.ActiveWindow.Selection.Find;
            findBIN.Text = "@bin";

            if (Program.currentPatient.billing.insurance.bin.ToString() == "")
            {
                findBIN.Replacement.Text = noInfo;
            }
            else
            {
                findBIN.Replacement.Text = Program.currentPatient.billing.insurance.bin.ToString();
            }
            findBIN.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findID = myWordDoc.ActiveWindow.Selection.Find;
            findID.Text = "@id";

            if (Program.currentPatient.billing.insurance.id.ToString() == "")
            {
                findID.Replacement.Text = noInfo;
            }
            else
            {
                findID.Replacement.Text = Program.currentPatient.billing.insurance.id.ToString();
            }
            findID.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findPCN = myWordDoc.ActiveWindow.Selection.Find;
            findPCN.Text = "@pcn";

            if (Program.currentPatient.billing.insurance.pcn.ToString() == "")
            {
                findPCN.Replacement.Text = noInfo;
            }
            else
            {
                findPCN.Replacement.Text = Program.currentPatient.billing.insurance.pcn.ToString();
            }
            findPCN.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findGroup = myWordDoc.ActiveWindow.Selection.Find;
            findGroup.Text = "@group";

            if (Program.currentPatient.billing.insurance.groupNum.ToString() == "")
            {
                findGroup.Replacement.Text = noInfo;
            }
            else
            {
                findGroup.Replacement.Text = Program.currentPatient.billing.insurance.groupNum.ToString();
            }
            findGroup.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findTpye = myWordDoc.ActiveWindow.Selection.Find;
            findTpye.Text = "@type";

            if (Program.currentPatient.billing.insurance.insuranceType.ToString() == "")
            {
                findTpye.Replacement.Text = noInfo;
            }
            else
            {
                findTpye.Replacement.Text = Program.currentPatient.billing.insurance.insuranceType.ToString();
            }
            findTpye.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            myWordDoc.SaveAs2(@"F:\PIMS_Final\" + Program.currentPatient.directory.lName + "." + Program.currentPatient.directory.fName + ".Insurance Information.pdf");
            myWordDoc.PrintPreview();
        }
Exemplo n.º 12
0
        // Will allow the user to print the patient's profile information
        private void printButton_Click(object sender, EventArgs e)
        {
            string noInfo = "Information not provided";

            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
            var myWordDoc = app.Documents.Open(@"F:\PIMS_Final\FORMS\PIMS PROFILE FORM.docx", ReadOnly: false, Visible: true);

            app.Visible = true;

            Microsoft.Office.Interop.Word.Find fndLastName = myWordDoc.ActiveWindow.Selection.Find;
            fndLastName.Text = "@lname";

            if (Program.currentPatient.directory.lName.ToString() == "")
            {
                fndLastName.Replacement.Text = noInfo;
            }
            else
            {
                fndLastName.Replacement.Text = Program.currentPatient.directory.lName.ToString();
            }
            fndLastName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find fndFirstName = myWordDoc.ActiveWindow.Selection.Find;
            fndFirstName.Text = "@fname";

            if (Program.currentPatient.directory.fName.ToString() == "")
            {
                fndFirstName.Replacement.Text = noInfo;
            }
            else
            {
                fndFirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
            }
            fndFirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find fndDOB = myWordDoc.ActiveWindow.Selection.Find;
            fndDOB.Text = "@dob";

            if (Program.currentPatient.directory.DOB.Date.ToShortDateString() == "")
            {
                fndDOB.Replacement.Text = noInfo;
            }
            else
            {
                fndDOB.Replacement.Text = Program.currentPatient.directory.DOB.Date.ToShortDateString();
            }
            fndDOB.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findGender = myWordDoc.ActiveWindow.Selection.Find;
            findGender.Text             = "@gender";
            findGender.Replacement.Text = Program.currentPatient.directory.gender ? "M" : "F";
            findGender.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find fndStreet = myWordDoc.ActiveWindow.Selection.Find;
            fndStreet.Text = "@street";

            if (Program.currentPatient.directory.strAddress.ToString() == "")
            {
                fndStreet.Replacement.Text = noInfo;
            }
            else
            {
                fndStreet.Replacement.Text = Program.currentPatient.directory.strAddress.ToString();
            }
            fndStreet.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findCity = myWordDoc.ActiveWindow.Selection.Find;
            findCity.Text = "@city";

            if (Program.currentPatient.directory.city.ToString() == "")
            {
                findCity.Replacement.Text = noInfo;
            }
            else
            {
                findCity.Replacement.Text = Program.currentPatient.directory.city.ToString();
            }
            findCity.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findState = myWordDoc.ActiveWindow.Selection.Find;
            findState.Text = "@state";

            if (Program.currentPatient.directory.state.ToString() == "")
            {
                findState.Replacement.Text = noInfo;
            }
            else
            {
                findState.Replacement.Text = Program.currentPatient.directory.state.ToString();
            }
            findState.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findZip = myWordDoc.ActiveWindow.Selection.Find;
            findZip.Text = "@zip";

            if (Program.currentPatient.directory.zip.ToString() == "")
            {
                findZip.Replacement.Text = noInfo;
            }
            else
            {
                findZip.Replacement.Text = Program.currentPatient.directory.zip.ToString();
            }
            findZip.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findPhone1 = myWordDoc.ActiveWindow.Selection.Find;
            findPhone1.Text = "@phone1";

            if (Program.currentPatient.directory.phoneNum1.ToString() == "")
            {
                findPhone1.Replacement.Text = noInfo;
            }
            else
            {
                findPhone1.Replacement.Text = Program.currentPatient.directory.phoneNum1.ToString();
            }
            findPhone1.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findPhone2 = myWordDoc.ActiveWindow.Selection.Find;
            findPhone2.Text = "@phone2";

            if (Program.currentPatient.directory.phoneNum2.ToString() == "")
            {
                findPhone1.Replacement.Text = noInfo;
            }
            else
            {
                findPhone2.Replacement.Text = Program.currentPatient.directory.phoneNum2.ToString();
            }
            findPhone2.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findPhone3 = myWordDoc.ActiveWindow.Selection.Find;
            findPhone3.Text = "@phone3";

            if (Program.currentPatient.directory.workphone.ToString() == "")
            {
                findPhone3.Replacement.Text = noInfo;
            }
            else
            {
                findPhone3.Replacement.Text = Program.currentPatient.directory.workphone.ToString();
            }
            findPhone3.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findCName1 = myWordDoc.ActiveWindow.Selection.Find;
            findCName1.Text = "@cName1";

            if (Program.currentPatient.directory.emerContact1.name.ToString() == "")
            {
                findCName1.Replacement.Text = noInfo;
            }
            else
            {
                findCName1.Replacement.Text = Program.currentPatient.directory.emerContact1.name.ToString();
            }
            findCName1.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findCPhone1 = myWordDoc.ActiveWindow.Selection.Find;
            findCPhone1.Text = "@cPhone1";

            if (Program.currentPatient.directory.emerContact1.phoneNum.ToString() == "")
            {
                findCPhone1.Replacement.Text = noInfo;
            }
            else
            {
                findCPhone1.Replacement.Text = Program.currentPatient.directory.emerContact1.phoneNum.ToString();
            }
            findCPhone1.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findCName2 = myWordDoc.ActiveWindow.Selection.Find;
            findCName2.Text = "@cName2";

            if (Program.currentPatient.directory.emerContact2.name.ToString() == "")
            {
                findCName2.Replacement.Text = noInfo;
            }
            else
            {
                findCName2.Replacement.Text = Program.currentPatient.directory.emerContact2.name.ToString();
            }
            findCName2.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find findCPhone2 = myWordDoc.ActiveWindow.Selection.Find;
            findCPhone2.Text = "@cPhone2";

            if (Program.currentPatient.directory.emerContact2.phoneNum.ToString() == "")
            {
                findCPhone2.Replacement.Text = noInfo;
            }
            else
            {
                findCPhone2.Replacement.Text = Program.currentPatient.directory.emerContact2.phoneNum.ToString();
            }
            findCPhone2.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            myWordDoc.SaveAs2(@"F:\PIMS_Final\" + Program.currentPatient.directory.lName + "." + Program.currentPatient.directory.fName + ".Profile Information.pdf");
            myWordDoc.PrintPreview();
        }
Exemplo n.º 13
0
        // Will allow the user to print the patient's billing information
        private void printButton_Click(object sender, EventArgs e)
        {
            // if (Program.currentPatient.directory.location.bedNum == 0)
            //{
            //    // Display information message
            //    MessageBox.Show("Patient is not admitted in the hospital.\n There is no need to print this information.",
            //    "No information to print!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
            //else
            //{
            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
            var myWordDoc = app.Documents.Open(@"F:\PIMS_Final\FORMS\PIMS BILLING FORM.docx", ReadOnly: false, Visible: true);

            app.Visible = true;

            Microsoft.Office.Interop.Word.Find fndLastName = myWordDoc.ActiveWindow.Selection.Find;
            fndLastName.Text             = "@lname";
            fndLastName.Replacement.Text = Program.currentPatient.directory.lName.ToString();
            fndLastName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            Microsoft.Office.Interop.Word.Find fndFirstName = myWordDoc.ActiveWindow.Selection.Find;
            fndFirstName.Text             = "@fname";
            fndFirstName.Replacement.Text = Program.currentPatient.directory.fName.ToString();
            fndFirstName.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);

            //Microsoft.Office.Interop.Word.Table newTable = new this;


            Microsoft.Office.Interop.Word.Find billing = myWordDoc.ActiveWindow.Selection.Find;
            billing.Text = "@billing";
            //billing.Replacement.Text = ;
            billing.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);



            myWordDoc.SaveAs2(@"F:\PIMS_Final\" + Program.currentPatient.directory.lName + "." + Program.currentPatient.directory.fName + ".Billing Information.pdf");
            myWordDoc.PrintPreview();
            //}



            // Instantiate new printInfo object to print page
            PIMSController.PrintInfo document = new PIMSController.PrintInfo();

            using (System.IO.StreamWriter file = new System.IO.StreamWriter("MyFile.txt"))
            {
                file.WriteLine("PATIENT BILLING ADDRESS\n");
                String address = String.Format("{0}, {1} \n{2} \n{3}, {4} \n{5}\n\n", Program.currentPatient.directory.lName, Program.currentPatient.directory.fName, Program.currentPatient.directory.strAddress,
                                               Program.currentPatient.directory.city, Program.currentPatient.directory.state, Program.currentPatient.directory.zip);
                file.WriteLine(address);

                file.WriteLine("BILLING REPORT\n");

                file.WriteLine(String.Format("{0, -15}{1, 12}{2, 12}{3, 12}{4, 12}{5, 12}\n", "Billing Item", "Cost", "Paid", "Covered", "Amount Due", "Date Due"));

                foreach (PIMSController.BillingLineItem item in Program.currentPatient.billing.items)
                {
                    file.WriteLine(String.Format("{0, -15}{1, 12:.00}{2, 12:.00}{3, 12:.00}{4, 12:.00}{5, 12}\n", item.item, ((float)item.cost) / 100, ((float)item.paid) / 100, ((float)item.insPaid) / 100, ((float)(item.cost - item.paid - item.insPaid)) / 100, item.dueDate.Date.ToString("d")));
                }
            }

            // Call the print function in the print class
            document.printButton_Click();
        }
Exemplo n.º 14
0
        private async Task ProcessLabels(string title, string content, QRCode qrCode, string saveLocation, bool open)
        {
            object        missing     = System.Reflection.Missing.Value;
            object        readOnly    = true;
            object        visible     = false;
            object        saveChanges = false;
            List <string> lookupKeys  = new List <string> {
                "<title>", "<content>", "<image>"
            };

            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();

            Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(@"C:\Users\Vince\Documents\QrCodeLabelTemp.dotx", ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing
                                                                            , ref missing, ref missing, ref visible, ref missing, ref missing, ref missing, ref missing);
            // Activate document
            doc.Activate();

            try
            {
                //----------------------Replace--------------------------------
                Microsoft.Office.Interop.Word.Find fnd = app.ActiveWindow.Selection.Find;
                fnd.ClearFormatting();
                fnd.Replacement.ClearFormatting();
                fnd.Forward = true;
                fnd.Wrap    = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue;

                string imagePath = "code.png";

                foreach (string key in lookupKeys)
                {
                    var keyword = key;
                    var sel     = app.Selection;
                    sel.Find.Text = string.Format("[{0}]", keyword);
                    app.Selection.Find.Execute(keyword);

                    int count = doc.Paragraphs.Count;

                    for (int i = 1; i < count; i++)
                    {
                        Microsoft.Office.Interop.Word.Range range = doc.Paragraphs[i].Range;


                        if (range.Text.Trim().Contains(keyword.Trim()))
                        {
                            //gets desired range here it gets last character to make superscript in range
                            Microsoft.Office.Interop.Word.Range temprange = doc.Range(range.End - key.Length + 1, range.End);//keyword is of 4 charecter range.End - 4
                            temprange.Select();
                            sel = app.Selection;
                            //currentSelection.Font.Superscript = 1;
                            sel.Find.Execute(Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceOne);
                            sel.Range.Select();


                            if (key == "<image>")
                            {
                                var imagePath1 = Path.GetFullPath(string.Format(imagePath, keyword));
                                Microsoft.Office.Interop.Word.InlineShape shape = sel.InlineShapes.AddPicture(FileName: imagePath1, LinkToFile: false, SaveWithDocument: true);
                                shape.Width  = 125f;
                                shape.Height = 125f;
                            }
                            else
                            {
                                if (key == "<title>")
                                {
                                    sel.Text = title;
                                }
                                else
                                {
                                    sel.Text = content;
                                }
                            }
                        }
                    }
                }


                Task t = Task.Run(() => SaveFile(doc, saveLocation));
                await t.ContinueWith((t1) =>
                {
                    if (t.IsCompleted)
                    {
                        if (open)
                        {
                            Console.WriteLine("IM CALLED");
                            Microsoft.Office.Interop.Word.Application ap = new Microsoft.Office.Interop.Word.Application();
                            ap.Visible = true;

                            Microsoft.Office.Interop.Word.Document document = ap.Documents.Open(saveLocation, ConfirmConversions: false, ReadOnly: true);
                        }
                    }
                });
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
            }

            finally
            {
                if (doc != null)
                {
                    ((Microsoft.Office.Interop.Word._Document)doc).Close(ref saveChanges, ref missing, ref missing);
                    Marshal.FinalReleaseComObject(doc);
                }
                if (app != null)
                {
                    ((Microsoft.Office.Interop.Word._Application)app).Quit();
                    Marshal.FinalReleaseComObject(app);
                }
            }
        }