private void buttonUpdateTestRecord_Click(object sender, RoutedEventArgs e) { try { if (datepickerTestDate.SelectedDate == null) { MessageBox.Show("Вы не ввели дату сдачи анализа!", "Внимание!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } MedicalTest test = ((IDataContextProvider <MedicalTest>)containerTestControl.Children[0]).ProvideDataContext(); test.PatientID = CurrentPatient.ID; test.Treatment = textboxTreatment.Text; test.Date = datepickerTestDate.SelectedDate ?? DateTime.Now.Date; foreach (var attachment in attachments_) { attachment.TableOwner = test.GetType().FullName; attachment.TestID = test.ID; } test.Attachments = attachments_.ToList(); PatientDB.Instance.AddAnalysis(ref test, test_type); MessageBox.Show("Результаты анализов сохранены!", "", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception exception) { MessageBox.Show(String.Format("Обнаружена ошибка при работе программы!\n{0}", exception.Message), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } }
public static void CreateTestReport(Patient patient, MedicalTest test, string file_path) { if (file_path == null) { return; } Type test_type = test.GetType(); using (DocX document = DocX.Create(file_path)) { Novacode.Paragraph header = document.InsertParagraph( //selected_procedure.ProcedureType.First().ToString().ToUpper() + String.Join("", selected_procedure.ProcedureType.Skip(1)).ToLower(), test_type.GetCustomAttribute <DisplayNameAttribute>().DisplayName, false, new Formatting() { FontFamily = new System.Drawing.FontFamily("Times New Roman"), Size = 16D } ); header.Alignment = Alignment.center; header.Bold(); document.InsertParagraph(" "); Novacode.Table patient_info = document.AddTable(5, 2); patient_info.Rows[0].Cells[0].Paragraphs.First().Append("ФИО пациента").Bold(); patient_info.Rows[0].Cells[1].Paragraphs.First().Append(patient.LastName + " " + patient.FirstName + " " + patient.Patronym); patient_info.Rows[1].Cells[0].Paragraphs.First().Append("Пол").Bold(); patient_info.Rows[1].Cells[1].Paragraphs.First().Append(patient.Sex == Sex.мужской ? "мужской" : "женский"); patient_info.Rows[2].Cells[0].Paragraphs.First().Append("Дата рождения").Bold(); patient_info.Rows[2].Cells[1].Paragraphs.First().Append(patient.Birthdate.ToShortDateString()); patient_info.Rows[3].Cells[0].Paragraphs.First().Append("Адрес проживания").Bold(); patient_info.Rows[3].Cells[1].Paragraphs.First().Append( patient.PostIndex + ", " + patient.Country + ", " + patient.Region + ", " + patient.City + ", " + patient.Address ); patient_info.Rows[4].Cells[0].Paragraphs.First().Append("Номер карты").Bold(); patient_info.Rows[4].Cells[1].Paragraphs.First().Append(patient.CardNumber.ToString()); patient_info.Alignment = Alignment.left; patient_info.AutoFit = AutoFit.Window; PropertyInfo[] indicators = test_type.GetProperties().Where(x => x.IsDefined(typeof(TestInfo))).ToArray(); Novacode.Table test_info = document.AddTable(indicators.Count(), 2); int k = 0; foreach (var indicator in indicators) { test_info.Rows[k].Cells[0].Paragraphs.First().Append(indicator.GetCustomAttribute <TestInfo>().DisplayName); object property_value = indicator.GetValue(test); test_info.Rows[k].Cells[1].Paragraphs.First().Append(property_value != null ? property_value.ToString() : ""); k++; } test_info.Alignment = Alignment.left; test_info.AutoFit = AutoFit.Window; document.InsertTable(patient_info); document.InsertParagraph(" "); document.InsertTable(test_info); document.Save(); } }