private void buttonToPdf_Click(object sender, RoutedEventArgs e) { if (datePickerFrom.SelectedDate >= datePickerTo.SelectedDate) { MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { logic.SaveCosmeticsToPdfFile(new ReportBindingModelEmployee { FileName = "D:\\Otchet.pdf", DateFrom = datePickerFrom.SelectedDate, DateTo = datePickerTo.SelectedDate, EmployeeId = id }); MailLogic.MailSendAsync(new MailSendInfo { MailAddress = _employeeStorage.GetElement(new EmployeeBindingModel { Id = id })?.EMail, Subject = $"Отчет", Text = "Отчет по косметике за период c " + datePickerFrom.SelectedDate.Value.ToShortDateString() + " по " + datePickerTo.SelectedDate.Value.ToShortDateString(), File = "D:\\Otchet.pdf" }); MessageBox.Show("Сообщение отправлено", "Успех", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void buttonToPdf_Click(object sender, RoutedEventArgs e) { if (datePickerFrom.SelectedDate >= datePickerTo.SelectedDate) { MessageBox.Show("Неверное выставление даты начала", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { logic.SaveDiseasesToPdfFile(new ReportBindingModel { FileName = "D:\\Otchet.pdf", DateFrom = datePickerFrom.SelectedDate, DateTo = datePickerTo.SelectedDate, DoctorId = id }); MailLogic.MailSendAsync(new MailSendInfo { MailAddress = _doctorStorage.GetElement(new DoctorBindingModel { Id = id })?.EMail, Subject = $"Отчет", Text = "Отчет по заболеваниям за период c " + datePickerFrom.SelectedDate.Value.ToShortDateString() + " по " + datePickerTo.SelectedDate.Value.ToShortDateString(), File = "D:\\Otchet.pdf" }); MessageBox.Show("Сообщение отправлено", "Успех", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void SendMail(ReportBindingModel model) { _report.SaveRoutesToPdfFile(model); MailLogic.MailSendAsync(new MailSendInfo { MailAddress = model.UserEmail, Subject = "Отчет", Text = "Отчет по маршрутам", ReportFile = model.FileName }); }
public IActionResult SendMail([Bind("DateTo,DateFrom")] ReportBindingModel model) { model.FileName = @".\wwwroot\list\SocietiesList.pdf"; model.ClientId = Program.Client.Id; _reportLogic.SaveSocietiesToPdfFile(model); MailLogic.MailSendAsync(new MailSendInfo { MailAddress = Program.Client.Login, Subject = "Отчет", Text = "Отчет по кружкам", ReportFile = model.FileName }); return(RedirectToAction("Index")); }