имбища

This commit is contained in:
the 2024-06-25 19:23:43 +04:00
parent a3390f0576
commit 472b98ba57
2 changed files with 130 additions and 17 deletions

View File

@ -34,6 +34,11 @@
dateTimePickerTo = new DateTimePicker();
dateTimePickerFrom = new DateTimePicker();
panel1 = new Panel();
checkBoxPending = new CheckBox();
checkBoxArriving = new CheckBox();
checkBoxCompleted = new CheckBox();
label2 = new Label();
label1 = new Label();
((System.ComponentModel.ISupportInitialize)chart).BeginInit();
panel1.SuspendLayout();
SuspendLayout();
@ -45,17 +50,16 @@
chart.Dock = DockStyle.Bottom;
legend1.Name = "Legend1";
chart.Legends.Add(legend1);
chart.Location = new Point(0, 12);
chart.Location = new Point(0, 30);
chart.Name = "chart";
chart.Size = new Size(800, 438);
chart.Size = new Size(800, 420);
chart.TabIndex = 0;
chart.Text = "chart1";
chart.Click += chart_Click;
//
// dateTimePickerTo
//
dateTimePickerTo.Dock = DockStyle.Left;
dateTimePickerTo.Location = new Point(0, 0);
dateTimePickerTo.Location = new Point(24, -1);
dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(200, 23);
dateTimePickerTo.TabIndex = 1;
@ -63,8 +67,7 @@
//
// dateTimePickerFrom
//
dateTimePickerFrom.Dock = DockStyle.Right;
dateTimePickerFrom.Location = new Point(598, 0);
dateTimePickerFrom.Location = new Point(262, -1);
dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(200, 23);
dateTimePickerFrom.TabIndex = 2;
@ -73,6 +76,11 @@
// panel1
//
panel1.BorderStyle = BorderStyle.FixedSingle;
panel1.Controls.Add(checkBoxPending);
panel1.Controls.Add(checkBoxArriving);
panel1.Controls.Add(checkBoxCompleted);
panel1.Controls.Add(label2);
panel1.Controls.Add(label1);
panel1.Controls.Add(dateTimePickerFrom);
panel1.Controls.Add(dateTimePickerTo);
panel1.Dock = DockStyle.Top;
@ -81,6 +89,57 @@
panel1.Size = new Size(800, 24);
panel1.TabIndex = 3;
//
// checkBoxPending
//
checkBoxPending.AutoSize = true;
checkBoxPending.Location = new Point(481, 3);
checkBoxPending.Name = "checkBoxPending";
checkBoxPending.Size = new Size(92, 19);
checkBoxPending.TabIndex = 7;
checkBoxPending.Text = "В ожидании";
checkBoxPending.UseVisualStyleBackColor = true;
checkBoxPending.CheckedChanged += checkBoxPending_CheckedChanged;
//
// checkBoxArriving
//
checkBoxArriving.AutoSize = true;
checkBoxArriving.Location = new Point(590, 3);
checkBoxArriving.Name = "checkBoxArriving";
checkBoxArriving.Size = new Size(61, 19);
checkBoxArriving.TabIndex = 6;
checkBoxArriving.Text = "В пути";
checkBoxArriving.UseVisualStyleBackColor = true;
checkBoxArriving.CheckedChanged += checkBoxArriving_CheckedChanged;
//
// checkBoxCompleted
//
checkBoxCompleted.AutoSize = true;
checkBoxCompleted.Location = new Point(668, 4);
checkBoxCompleted.Name = "checkBoxCompleted";
checkBoxCompleted.Size = new Size(104, 19);
checkBoxCompleted.TabIndex = 5;
checkBoxCompleted.Text = "Завершенные";
checkBoxCompleted.UseVisualStyleBackColor = true;
checkBoxCompleted.CheckedChanged += checkBoxCompleted_CheckedChanged;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(230, 5);
label2.Name = "label2";
label2.Size = new Size(26, 15);
label2.TabIndex = 4;
label2.Text = "По:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(3, 5);
label1.Name = "label1";
label1.Size = new Size(18, 15);
label1.TabIndex = 3;
label1.Text = "С:";
//
// FormStatistics
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -93,6 +152,7 @@
Load += FormStatistics_Load;
((System.ComponentModel.ISupportInitialize)chart).EndInit();
panel1.ResumeLayout(false);
panel1.PerformLayout();
ResumeLayout(false);
}
@ -102,5 +162,10 @@
private DateTimePicker dateTimePickerTo;
private DateTimePicker dateTimePickerFrom;
private Panel panel1;
private Label label2;
private Label label1;
private CheckBox checkBoxPending;
private CheckBox checkBoxArriving;
private CheckBox checkBoxCompleted;
}
}

View File

@ -1,5 +1,6 @@
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using DataModels.Enums;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@ -37,18 +38,50 @@ namespace WinFormsApp
DateStart = dateTimePickerTo.Value,
DateEnd = dateTimePickerFrom.Value,
});
var date = dateTimePickerTo.Value;
chart.Series.Add("Completed");
chart.Series["Completed"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.String;
for (int i = 0; i < diff_month(dateTimePickerFrom.Value, dateTimePickerTo.Value); i++)
if (checkBoxPending.Checked)
{
var count = list.Where(x => x.Date.Month == date.Month).ToList().Count;
DataPoint dataPoint = new DataPoint();
dataPoint.XValue = i;
dataPoint.Label = $"{date.Year}.{date.Month}";
dataPoint.SetValueY(count);
chart.Series["Completed"].Points.Add(dataPoint);
date = date.AddMonths(1);
var date = dateTimePickerTo.Value;
chart.Series.Add("Pending");
for (int i = 0; i < diff_month(dateTimePickerFrom.Value, dateTimePickerTo.Value); i++)
{
var count = list.Where(x => x.Date.Month == date.Month && x.Status == SupplyStatus.Pending).ToList().Count;
DataPoint dataPoint = new DataPoint();
dataPoint.XValue = i;
dataPoint.Label = $"{date.Year}.{date.Month}";
dataPoint.SetValueY(count);
chart.Series["Pending"].Points.Add(dataPoint);
date = date.AddMonths(1);
}
}
if (checkBoxArriving.Checked)
{
var date = dateTimePickerTo.Value;
chart.Series.Add("Arriving");
for (int i = 0; i < diff_month(dateTimePickerFrom.Value, dateTimePickerTo.Value); i++)
{
var count = list.Where(x => x.Date.Month == date.Month && x.Status == SupplyStatus.Arriving).ToList().Count;
DataPoint dataPoint = new DataPoint();
dataPoint.XValue = i;
dataPoint.Label = $"{date.Year}.{date.Month}";
dataPoint.SetValueY(count);
chart.Series["Arriving"].Points.Add(dataPoint);
date = date.AddMonths(1);
}
}
if (checkBoxCompleted.Checked)
{
var date = dateTimePickerTo.Value;
chart.Series.Add("Completed");
for (int i = 0; i < diff_month(dateTimePickerFrom.Value, dateTimePickerTo.Value); i++)
{
var count = list.Where(x => x.Date.Month == date.Month && x.Status == SupplyStatus.Completed).ToList().Count;
DataPoint dataPoint = new DataPoint();
dataPoint.XValue = i;
dataPoint.Label = $"{date.Year}.{date.Month}";
dataPoint.SetValueY(count);
chart.Series["Completed"].Points.Add(dataPoint);
date = date.AddMonths(1);
}
}
}
@ -71,5 +104,20 @@ namespace WinFormsApp
{
return (d1.Year - d2.Year) * 12 + d1.Month - d2.Month;
}
private void checkBoxPending_CheckedChanged(object sender, EventArgs e)
{
LoadData();
}
private void checkBoxArriving_CheckedChanged(object sender, EventArgs e)
{
LoadData();
}
private void checkBoxCompleted_CheckedChanged(object sender, EventArgs e)
{
LoadData();
}
}
}