private async void Dpf_FormClosing2(object sender, FormClosingEventArgs e) { if (sender is RangeDatePickerForm dpf && dpf.DialogResult == DialogResult.OK) { var reportSource = await _service.GetEntitiesAsync <Children>(x => x.DateOfRequest >= dpf.Start && x.DateOfRequest <= dpf.End); if (reportSource.Length == 0) { MessageBox.Show("Не найдено данных для отображения, попробуйте изменить период выборки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var gr = reportSource.GroupBy(x => new DateTime(x.EnteredDate.Value.Year, x.EnteredDate.Value.Month, 1)) .Select(x => new CountReport() { DateTime = x.Key.Date, Count = x.Count() }).ToArray(); Visible = false; ReportForm rf = UnityContainerIoC.Container.Resolve <ReportForm>(new ParameterOverride(typeof(string), "ReqGraphReport"), new ParameterOverride(typeof(object), gr)); rf.ShowDialog(); Visible = true; } }
private async void Dpf_FormClosing(object sender, FormClosingEventArgs e) { if (sender is RangeDatePickerForm dpf && dpf.DialogResult == DialogResult.OK) { var reportSource = await _service.GetEntitiesAsync <Visit>(x => x.Date >= dpf.Start && x.Date <= dpf.End && x.StatusId != 5); if (reportSource.Length == 0) { MessageBox.Show("Не найдено данных для отображения, попробуйте изменить период выборки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var gr = reportSource.GroupBy(x => new { x.Date.Date, x.Status.Long }).Select(x => new VisitReport() { Date = x.Key.Date, Title = x.Key.Long, Count = x.Count() }).ToArray(); Visible = false; ReportForm rf = UnityContainerIoC.Container.Resolve <ReportForm>(new ParameterOverride(typeof(string), "VisitReport"), new ParameterOverride(typeof(object), gr)); rf.ShowDialog(); Visible = true; } }
private void printBtn_Click(object sender, EventArgs e) { if (_data != null && _data.Any()) { ReportForm rf = UnityContainerIoC.Container.Resolve <ReportForm>(new ParameterOverride(typeof(string), "VisitFilterReport"), new ParameterOverride(typeof(object), _data)); rf.ShowDialog(); } }
private async void resizebleMaterialRaisedButton1_Click(object sender, EventArgs e) { if (dgv.SelectedRows.Count <= 0) { return; } if (dgv.SelectedRows[0].DataBoundItem is Group item) { var data = await _dataService.GetEntitiesAsync <Children>(x => x.GroupId == item.GroupId); Visible = false; ReportForm rf = UnityContainerIoC.Container.Resolve <ReportForm>(new ParameterOverride(typeof(string), "ChildReport"), new ParameterOverride(typeof(object), data)); rf.ShowDialog(); Visible = true; } }
private async void Dpf_FormClosing3(object sender, FormClosingEventArgs e) { if (sender is RangeDatePickerForm dpf && dpf.DialogResult == DialogResult.OK) { var reportSource = await _service.GetEntitiesAsync <Children>(x => x.EnteredDate != null && x.EnteredDate >= dpf.Start && x.EnteredDate <= dpf.End); var total = new List <CountReport>(); var countMonth = Math.Ceiling((dpf.End - dpf.Start).TotalDays / 29); var start = new DateTime(dpf.Start.Year, dpf.Start.Month, 1); for (int i = 0; i < countMonth; i++) { var end = start.AddMonths(i + 1); total.Add(new CountReport() { DateTime = start.AddMonths(i), Count = reportSource.Count(x => x.EnteredDate.Value <= end && (x.GraduatedDate == null || x.GraduatedDate.Value >= end)) }); } if (reportSource.Length == 0) { MessageBox.Show("Не найдено данных для отображения, попробуйте изменить период выборки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Visible = false; ReportForm rf = UnityContainerIoC.Container.Resolve <ReportForm>(new ParameterOverride(typeof(string), "CountGraphReport"), new ParameterOverride(typeof(object), total.ToArray())); rf.ShowDialog(); Visible = true; } }
private async void materialRaisedButton3_Click(object sender, EventArgs e) { if (_validator.CheckAll()) { MessageBox.Show("Формирование отчета может занять некоторое время, пожалуйста, подождите", "Подождите", MessageBoxButtons.OK); var gr = dep_cmbx.SelectedItem as Group; var start = new DateTime(date_dtpc.Value.Year, date_dtpc.Value.Month, 1); var end = start.AddMonths(1).Subtract(new TimeSpan(0, 0, 1)); var countDays = Math.Round((end - start).TotalDays); try { Visit[] items; //Получим учеников у кого нет посещений за выбранный период //получим кол-во дней var children = await _service.GetEntitiesAsync <Children>(x => x.GroupId == gr.GroupId); var childVisits = children.Select(x => new { x.ChildrenId, _service.GetEntitiesAsync <Visit>(c => c.ChildrenId == x.ChildrenId && c.Date >= start && c.Date <= end).Result }).ToArray(); //Получаем детей у кого кол-во посещений меньше кол-ва дней в месяце var missChildren = childVisits.Where(x => x.Result.Length < countDays).ToArray(); if (missChildren.Length > 0) { MessageBox.Show("Обнаружены воспитанники у которых не сформирован журнал посещений. " + "Журнал будет создан, пожалуйста, подождите." + "Это может занять до 1 минуты", "Пожалуйста подождите", MessageBoxButtons.OK, MessageBoxIcon.Information); toolStripProgressBar1.Maximum = missChildren.Length; toolStripProgressBar1.Value = 0; } foreach (var miss in missChildren) { var startdate = start; for (int i = 0; i < countDays; i++) { if (miss.Result.Any(x => x.Date.Date == startdate.AddDays(i).Date)) { continue; } else { await _service.AddEntityAsync(new Visit() { ChildrenId = miss.ChildrenId, Date = start.Date.AddDays(i), StatusId = 6 }); } } toolStripProgressBar1.Value++; } toolStripProgressBar1.Value = 0; items = await _service.GetEntitiesAsync <Visit>(x => x.Children.GroupId == gr.GroupId && x.Date >= start && x.Date <= end); if (items.Length > 0) { try { var table = await VisitJournal.GetVisitGournal(items, start); Visible = false; ReportForm rf = UnityContainerIoC.Container.Resolve <ReportForm>(new ParameterOverride(typeof(string), "ScheduleTableReport"), new ParameterOverride(typeof(object), (table, gr.Title, start.ToString("MMMM yyyy")))); rf.ShowDialog(); Visible = true; } catch (Exception ex) { MessageBox.Show($"Ошибка при формировании таблицы посещений. " + $"На дату {start.ToString("dd/MM/yyyy")} " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { var childrens = await _service.GetEntitiesAsync <Children>(); childrens = childrens.Where(x => x.Group != null && x.GroupId == gr.GroupId) .ToArray(); if (childrens.Length == 0) { MessageBox.Show("Нет воспитанников в выбранной группе" , "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }