示例#1
0
        /// <summary>
        /// Event method to call method to create doc word and call method to modify the excel file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnWord_Click(object sender, RoutedEventArgs e)
        {
            if (dataMigration.SelectedItem == null)
            {
                return;
            }

            CheckWordProcesses();

            MigrationElement currentElement = (MigrationElement)dataMigration.SelectedItem;

            Process(currentElement);

            List <MigrationElement> element = new List <MigrationElement>();

            element.Add(currentElement);

            KillWord();
            try
            {
                ReportCreator myCreator = new ReportCreator(element, _offerBxPath, _offerAnPath, _offerVvPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Method to call CreateWordDocument method
        /// </summary>
        /// <param name="currentElement"></param>
        private void Process(MigrationElement currentElement)
        {
            try
            {
                string        fileIn;
                WordReadWrite WordProcess = new WordReadWrite();

                if (!Directory.Exists(_basePath + Properties.Settings.Default.ResultPath))
                {
                    Directory.CreateDirectory(_basePath + Properties.Settings.Default.ResultPath);
                }

                string pathOut   = _basePath + Properties.Settings.Default.ResultPath;
                string pathPhyFr = _basePath + Properties.Settings.Default.PathPhysFrTemplate;
                string pathPhyNl = _basePath + Properties.Settings.Default.PathPhysNlTemplate;
                string pathMorFr = _basePath + Properties.Settings.Default.PathMoraFrTemplate;
                string pathMorNl = _basePath + Properties.Settings.Default.PathMoraNlTemplate;

                if (currentElement.PhysicalPerson)
                {
                    fileIn = currentElement.Langue.Trim().ToUpper().Equals("N") ? pathPhyNl : pathPhyFr;
                }
                else
                {
                    fileIn = currentElement.Langue.Trim().ToUpper().Equals("N") ? pathMorNl : pathMorFr;
                }

                string fileOut;
                if (currentElement.PhysicalPerson)
                {
                    fileOut = pathOut + currentElement.DocumentName + ".docx";
                }
                else
                {
                    fileOut = pathOut + currentElement.DocumentName + ".docx";
                }

                WordProcess.CreatWordDocument(fileIn, fileOut, currentElement);

                System.Diagnostics.Process.Start(pathOut);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }