Example #1
0
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            string pathDocument = AppDomain.CurrentDomain.BaseDirectory + "Отчет" + ".docx";


            DocX document = DocX.Create(pathDocument);


            Xceed.Document.NET.Paragraph paragraph = document.InsertParagraph();

            paragraph.Alignment = Alignment.center;


            paragraph.AppendLine("Отчет").Bold().Font("Times New Roman").FontSize(14);

            Xceed.Document.NET.Paragraph paragraph2 = document.InsertParagraph();
            paragraph2.Font("Times New Roman");
            paragraph2.FontSize(14);
            paragraph2.Alignment = Alignment.left;
            paragraph2.AppendLine("Список товаров: ").Font("Times New Roman").FontSize(14).Bold();
            paragraph2.AppendLine();
            foreach (Product product in config.list.AllProducts)
            {
                paragraph2.AppendLine("Название: " + product.Name).Font("Times New Roman").FontSize(14);
                paragraph2.AppendLine("Описание: " + product.Desc).Font("Times New Roman").FontSize(12);
                paragraph2.AppendLine();
            }
            paragraph2.AppendLine("Список товаров на складе: ").Font("Times New Roman").FontSize(14).Bold();
            paragraph2.AppendLine();
            foreach (StroredProduct product in config.list.AllstroredProducts)
            {
                paragraph2.AppendLine("Название: " + product.product.Name).Font("Times New Roman").FontSize(14);
                paragraph2.AppendLine("Полочка: " + product.polka).Font("Times New Roman").FontSize(12);
                paragraph2.AppendLine("Количество: " + product.count).Font("Times New Roman").FontSize(12);
                paragraph2.AppendLine("Поставщик: " + product.Postavshick.name).Font("Times New Roman").FontSize(12);
                paragraph2.AppendLine();
            }
            paragraph2.AppendLine("Список заказов: ").Font("Times New Roman").FontSize(14).Bold();
            paragraph2.AppendLine();
            foreach (Zakaz product in config.list.AllZakazs)
            {
                paragraph2.AppendLine("Название товара: " + product.stroredProduct.Name).Font("Times New Roman").FontSize(14);
                paragraph2.AppendLine("Поставщик: " + product.postavshick.name).Font("Times New Roman").FontSize(14);
                paragraph2.AppendLine("Информация по данному поставщику: ").Font("Times New Roman").FontSize(14);
                paragraph2.AppendLine("Адрес: " + product.postavshick.adress);
                paragraph2.AppendLine("Телефон: " + product.postavshick.tel);
            }
            document.Save();
            Process.Start(AppDomain.CurrentDomain.BaseDirectory + "Отчет" + ".docx");
        }
Example #2
0
        private void StartTest_Copy_Click(object sender, RoutedEventArgs e)
        {
            string pathDocument = AppDomain.CurrentDomain.BaseDirectory + "Отчет " + FIOLABEL.Content + ".docx";

            // создаём документ
            DocX document = DocX.Create(pathDocument);


            Xceed.Document.NET.Paragraph paragraph = document.InsertParagraph();
            // выравниваем параграф по правой стороне
            paragraph.Alignment = Alignment.center;

            // добавляем отдельную строку со своим форматированием
            paragraph.AppendLine("Служба персонала").Bold().Font("Times New Roman").FontSize(14);
            paragraph.AppendLine("ООО \"Эрнис\"").Bold().Font("Times New Roman").FontSize(14);
            paragraph.AppendLine("ПРОТОКОЛ ТЕСТИРОВАНИЯ").Bold().Font("Times New Roman").FontSize(14);
            Xceed.Document.NET.Paragraph paragraph2 = document.InsertParagraph();
            paragraph2.Font("Times New Roman");
            paragraph2.FontSize(14);
            paragraph2.Alignment = Alignment.left;
            paragraph2.AppendLine("Фамилия: " + _loginPage.SerName.Text).Font("Times New Roman").FontSize(14);
            paragraph2.AppendLine("Имя: " + _loginPage.Name.Text).Font("Times New Roman").FontSize(14);
            paragraph2.AppendLine("Отчество: " + _loginPage.ser2.Text).Font("Times New Roman").FontSize(14);
            paragraph2.AppendLine();
            paragraph2.AppendLine("Всего вопросов: " + scrambled.Count()).Font("Times New Roman").FontSize(14);
            paragraph2.AppendLine("Правильных ответов: " + rightanswes + " (" + (Math.Truncate((double)rightanswes * 100 / (double)scrambled.Count())) + "%)").Font("Times New Roman").FontSize(14);
            Xceed.Document.NET.Paragraph paragraph3 = document.InsertParagraph().Font("Times New Roman").FontSize(14);
            paragraph3.Alignment = Alignment.right;
            paragraph3.Font("Times New Roman");
            paragraph3.FontSize(14);
            paragraph3.AppendLine();
            DateTime time = DateTime.Today;

            if (time.Month < 10)
            {
                paragraph3.AppendLine("Дата: " + time.Day + ".0" + time.Month + "." + time.Year).Font("Times New Roman").FontSize(14);
            }
            else
            {
                paragraph3.AppendLine("Дата: " + time.Day + "." + time.Month + "." + time.Year).Font("Times New Roman").FontSize(14);
            }
            paragraph3.AppendLine("ФИО контролирующего:___________________________________").Font("Times New Roman").FontSize(14);
            paragraph3.AppendLine("Подпись тестируемого:__________________________________").Font("Times New Roman").FontSize(14);
            paragraph3.InsertPageBreakAfterSelf();
            document.InsertSectionPageBreak();
            Xceed.Document.NET.Paragraph paragraph4 = document.InsertParagraph();

            paragraph4.Alignment = Alignment.left;

            paragraph4.AppendLine("Неверные ответы:").Font("Times New Roman").FontSize(14).Alignment = Alignment.center;
            paragraph4.AppendLine().Alignment = Alignment.left;;
            foreach (FailedQuestion failed in otchet)
            {
                paragraph4.AppendLine(failed.text).Font("Times New Roman").FontSize(14);
                paragraph4.AppendLine("Ответ тестируемого:").Font("Times New Roman").FontSize(14);
                foreach (Answer answer in failed.FailedAnswers)
                {
                    paragraph4.AppendLine("-" + answer.text).Font("Times New Roman").FontSize(14);
                }
                paragraph4.AppendLine("Правильный ответ:").Font("Times New Roman").FontSize(14);
                foreach (Answer answer in failed.CorrectAnswers)
                {
                    paragraph4.AppendLine("-" + answer.text).Font("Times New Roman").FontSize(14);
                }
                paragraph4.AppendLine();
            }

            paragraph4.AppendLine("Верные ответы:").Font("Times New Roman").FontSize(14).Alignment = Alignment.center;;
            paragraph4.AppendLine().Alignment = Alignment.left;;
            foreach (Question failed in otchet2)
            {
                paragraph4.AppendLine(failed.text).Font("Times New Roman").FontSize(14);
                paragraph4.AppendLine("Ответ тестируемого:").Font("Times New Roman").FontSize(14);
                foreach (Answer answer in failed.answers.Where(x => x.right == true))
                {
                    paragraph4.AppendLine("-" + answer.text).Font("Times New Roman").FontSize(14);
                }
                paragraph4.AppendLine();
            }



            // сохраняем документ
            document.Save();
            Process.Start(AppDomain.CurrentDomain.BaseDirectory + "Отчет " + FIOLABEL.Content + ".docx");
        }