Esempio n. 1
0
        private void CheckCabLine()
        {
            try
            {
                Object template     = @"C:\Users\Twent\Desktop\Templates\CheckCabLine.docx";
                Object newTemplate  = false;
                Object documentType = Word.Word.WdNewDocumentType.wdNewBlankDocument;
                Object visible      = true;



                worddocument = wordapp.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
                GenFormat();

                //Чтото происходит

                Save();
            }
            catch (Exception)
            {
                wordapp.Quit(ref falseObj, ref missingObj, ref missingObj);
                worddocument = null;
                wordapp      = null;
                genFaultActive();
            }
        }
Esempio n. 2
0
        private void CabLine()
        {
            try
            {
                Object template     = @"C:\Users\Twent\Desktop\Templates\CabLine1.docx";
                Object newTemplate  = false;
                Object documentType = Word.Word.WdNewDocumentType.wdNewBlankDocument;
                Object visible      = true;



                worddocument = wordapp.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible); //создание объекта документа по шаблону
                GenFormat();

                Save();

                //
                //вывод таблицы из проги и вставка в документ
                //резерв table2
            }
            catch (Exception)
            {
                wordapp.Quit(ref falseObj, ref missingObj, ref missingObj);
                worddocument = null;
                wordapp      = null;
                genFaultActive();
            }
        }
        public void mudarTudo(Word.Word.Document contrato, object branco, string substituir, string encontrarTexto)
        {
            Word.Word.Range mudar = contrato.Range(ref branco, ref branco);

            object FindText       = encontrarTexto;
            object ReplaceWith    = substituir;
            object MatchWholeWord = true;
            object Forward        = false;

            mudar.Find.Execute(ref FindText, ref branco, ref MatchWholeWord, ref branco, ref branco, ref branco, ref Forward, ref branco, ref branco,
                               ref ReplaceWith, Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll, ref branco, ref branco, ref branco);
        }
Esempio n. 4
0
        private void Save()
        {
            //здесь будет сохранение
            Object fileName   = SavePath + @"\" + textBox3.Text + "-" + NumOfProt + "-2020" + " " + SaveName + ".docx";
            Object fileFormat = Word.Word.WdSaveFormat.wdFormatDocumentDefault;

            worddocument.SaveAs2(ref fileName, ref fileFormat);
            worddocument.Close(ref falseObj, ref missingObj, ref missingObj);

            worddocument = null;
            //wordapp = null;
            //Вывод сообщения?
            //label27.Text = "Завершено"; //это ваще потом сделать
        }
Esempio n. 5
0
        //-----------------------------------------
        private void CreateWordDocument(object filename, object saveAs, object imagePath)
        {
            object missing  = Missing.Value;
            string tempPath = null;

            Word.Word.Application wordApp = new Word.Word.Application();
            Word.Word.Document    aDoc    = null;
            if (File.Exists((string)filename))
            {
                DateTime today     = DateTime.Now;
                object   readOnly  = false;
                object   isVisible = true;
                wordApp.Visible = true;
                aDoc            = wordApp.Documents.Open(ref filename, ref missing, ref readOnly
                                                         , ref missing, ref missing, ref missing
                                                         , ref missing, ref missing, ref missing
                                                         , ref missing, ref missing, ref missing
                                                         , ref missing, ref missing, ref missing, ref missing);
                aDoc.Activate();

                //Find and replace:
                this.FindAndReplace(wordApp, "$$EmployeeID$$", _presenter.CurrentEmployee.AppUser.EmployeeNo);
                this.FindAndReplace(wordApp, "$$FirstName$$", _presenter.CurrentEmployee.FirstName);
                this.FindAndReplace(wordApp, "$$LastName$$", _presenter.CurrentEmployee.LastName);
                this.FindAndReplace(wordApp, "$$EmailAddress$$", _presenter.CurrentEmployee.ChaiEMail);


                //insert the picture:


                Object oMissed           = aDoc.Paragraphs[1].Range; //the position you want to insert
                Object oLinkToFile       = false;                    //default
                Object oSaveWithDocument = true;                     //default
                aDoc.InlineShapes.AddPicture(tempPath, ref oLinkToFile, ref oSaveWithDocument, ref oMissed);

                #region Print Document :
                #endregion
            }
        }
        public void PreencherNoWord(ModeloCarne modeloCarne, ProgressBar progressBar)
        {
            int quantosCarnes;

            object campoBranco = System.Reflection.Missing.Value;

            Word.Word.Application oApp = new Word.Word.Application();
            progressBar.Value = 2;
            object caminhoContrato = System.IO.Path.GetFullPath("Carne\\" + modeloCarne.mes + ".docx");

            progressBar.Value = 4;
            Word.Word.Document contrato = oApp.Documents.Add(ref caminhoContrato, false, ref campoBranco, false);
            progressBar.Value = 6;
            mudarTudo(contrato, campoBranco, modeloCarne.nomeAluno, "[nomealuno]");
            progressBar.Value = 8;
            mudarTudo(contrato, campoBranco, modeloCarne.mensalidadeNormal, "[valornormal]");
            progressBar.Value = 10;
            mudarTudo(contrato, campoBranco, modeloCarne.mensalidadeDesconto, "[valordesconto]");
            progressBar.Value = 12;
            mudarTudo(contrato, campoBranco, modeloCarne.portugues, "[P]");
            progressBar.Value = 16;
            mudarTudo(contrato, campoBranco, modeloCarne.matematica, "[M]");
            progressBar.Value = 18;
            mudarTudo(contrato, campoBranco, modeloCarne.ingles, "[I]");
            progressBar.Value = 20;

            if (modeloCarne.mes <= 9)
            {
                quantosCarnes = 9 - (modeloCarne.mes - 1);

                for (int x = 1; x <= quantosCarnes; x++)
                {
                    progressBar.Value += 80 / quantosCarnes;
                    mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year, modeloCarne.mes + (x - 1)), "[" + x + "]");
                }
            }
            else
            {
                if (modeloCarne.mes == 10)
                {
                    for (int x = 1; x <= 3; x++)
                    {
                        progressBar.Value += 80 / 12;
                        mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year, modeloCarne.mes + (x - 1)), "[" + x + "]");
                    }

                    for (int x = 4; x <= 12; x++)
                    {
                        progressBar.Value += 80 / 12;
                        mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year + 1, (x - 3)), "[" + x + "]");
                    }
                }
                else if (modeloCarne.mes == 11)
                {
                    for (int x = 1; x <= 2; x++)
                    {
                        progressBar.Value += 80 / 11;
                        mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year, modeloCarne.mes + (x - 1)), "[" + x + "]");
                    }

                    for (int x = 3; x <= 11; x++)
                    {
                        progressBar.Value += 80 / 11;
                        mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year + 1, (x - 2)), "[" + x + "]");
                    }
                }
                else
                {
                    progressBar.Value += 80 / 10;
                    mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year, 12), "[1]");

                    for (int x = 2; x <= 10; x++)
                    {
                        progressBar.Value += 80 / 10;
                        mudarTudo(contrato, campoBranco, quintoDia.RetornaQuintoDiaUtil(DateTime.Now.Year + 1, (x - 1)), "[" + x + "]");
                    }
                }
            }

            oApp.Visible = true;
        }
Esempio n. 7
0
        public void PreencherNoWord(ModeloContrato modeloContrato, ProgressBar progressBar)
        {
            progressBar.Value = 23;
            object campoBranco = System.Reflection.Missing.Value;

            Word.Word.Application oApp = new Word.Word.Application();

            object caminhoContrato = System.IO.Path.GetFullPath("Contrato.doc");

            Word.Word.Document contrato = oApp.Documents.Add(ref caminhoContrato, false, ref campoBranco, false);

            progressBar.Value = 26;

            mudar(contrato, campoBranco, modeloContrato.nomeAluno, "[nomeAluno]");
            progressBar.Value = 29;
            mudar(contrato, campoBranco, modeloContrato.dataNascimentoAluno, "[dataNascimentoAluno]");
            progressBar.Value = 32;
            mudar(contrato, campoBranco, modeloContrato.telefoneAluno, "[telefoneAluno]");
            progressBar.Value = 35;
            mudar(contrato, campoBranco, modeloContrato.celularAluno, "[celularAluno]");
            progressBar.Value = 38;
            mudar(contrato, campoBranco, modeloContrato.nomeContratante, "[nomeContratante]");
            progressBar.Value = 41;
            mudar(contrato, campoBranco, modeloContrato.nomeContratante, "[nomeContratante]");
            progressBar.Value = 44;
            mudar(contrato, campoBranco, modeloContrato.telefoneContratante, "[telefoneContratante]");
            progressBar.Value = 47;
            mudar(contrato, campoBranco, modeloContrato.celularContratante, "[celularContratante]");
            progressBar.Value = 50;
            mudar(contrato, campoBranco, modeloContrato.rgContratante, "[rgContratante]");
            progressBar.Value = 53;
            mudar(contrato, campoBranco, modeloContrato.cpfContratante, "[cpfContratante]");
            progressBar.Value = 56;
            mudar(contrato, campoBranco, modeloContrato.enderecoContratante, "[enderecoContratante]");
            progressBar.Value = 59;
            mudar(contrato, campoBranco, modeloContrato.matematica, "[matematica]");
            progressBar.Value = 62;
            mudar(contrato, campoBranco, modeloContrato.portugues, "[portugues]");
            progressBar.Value = 65;
            mudar(contrato, campoBranco, modeloContrato.ingles, "[ingles]");
            progressBar.Value = 68;
            mudar(contrato, campoBranco, modeloContrato.seisMeses, "[seisMeses]");
            progressBar.Value = 71;
            mudar(contrato, campoBranco, modeloContrato.dozeMeses, "[dozeMeses]");
            progressBar.Value = 74;
            mudar(contrato, campoBranco, modeloContrato.inicioDoCurso, "[inicioDoCurso]");
            progressBar.Value = 77;
            mudar(contrato, campoBranco, modeloContrato.diasDaSemana, "[diasDaSemana]");
            progressBar.Value = 80;
            mudar(contrato, campoBranco, modeloContrato.horarios, "[horarios]");
            progressBar.Value = 82;
            mudar(contrato, campoBranco, modeloContrato.taxaMatricula, "[taxaMatricula]");
            progressBar.Value = 84;
            mudar(contrato, campoBranco, modeloContrato.taxaMatriculaExtenso, "[taxaMatriculaExtenso]");
            progressBar.Value = 86;
            mudar(contrato, campoBranco, modeloContrato.mensalidade, "[mensalidade]");
            progressBar.Value = 88;
            mudar(contrato, campoBranco, modeloContrato.mensalidadeExtenso, "[mensalidadeExtenso]");
            progressBar.Value = 90;
            mudar(contrato, campoBranco, modeloContrato.dataFinalContrato, "[dataFinalContrato]");
            progressBar.Value = 92;
            mudar(contrato, campoBranco, modeloContrato.nomeTestemunha1, "[nomeTestemunha1]");
            progressBar.Value = 94;
            mudar(contrato, campoBranco, modeloContrato.rgTestemunha1, "[rgTestemunha1]");
            progressBar.Value = 96;
            mudar(contrato, campoBranco, modeloContrato.nomeTestemunha2, "[nomeTestemunha2]");
            progressBar.Value = 98;
            mudar(contrato, campoBranco, modeloContrato.rgTestemunha2, "[rgTestemunha2]");
            progressBar.Value = 99;

            oApp.Visible = true;
        }