Сдано
This commit is contained in:
parent
a1a7cad61f
commit
b9a375ab27
@ -20,9 +20,9 @@ namespace ProjectTourAgency.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_addMoneyRepository = addMoneyRepository ??
|
_addMoneyRepository = addMoneyRepository ??
|
||||||
throw new ArgumentNullException(nameof(addMoneyRepository));
|
throw new ArgumentNullException(nameof(addMoneyRepository));
|
||||||
comboBoxClientId.DataSource = clientRepository.ReadClients();
|
comboBoxClientId.DataSource = addMoneyRepository.ReadAddMoneys();
|
||||||
comboBoxClientId.DisplayMember = "Name";
|
comboBoxClientId.DisplayMember = "ClientName";
|
||||||
comboBoxClientId.ValueMember = "Id";
|
comboBoxClientId.ValueMember = "ClientId";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSave_Click(object sender, EventArgs e)
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
@ -28,7 +28,7 @@ internal class ChartReport
|
|||||||
{
|
{
|
||||||
new PdfBuilder(filePath)
|
new PdfBuilder(filePath)
|
||||||
.AddHeader("Операции пополнения")
|
.AddHeader("Операции пополнения")
|
||||||
.AddPieChart("Пополнения счетов клиентов", GetData(dateTime))
|
.AddPieChart($"Пополнения счетов клиентов за {dateTime.ToString("d MMMM yyyy")}", GetData(dateTime))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -44,7 +44,7 @@ internal class ChartReport
|
|||||||
{
|
{
|
||||||
return _addMoneyRepository
|
return _addMoneyRepository
|
||||||
.ReadAddMoneys(dateFrom: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
|
.ReadAddMoneys(dateFrom: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
|
||||||
.GroupBy(x => x.ClientId, (key, group) => new { Id = key, Count = group.Count() })
|
.GroupBy(x => x.ClientName, (key, group) => new { Id = key, Count = group.Count() })
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ namespace ProjectTourAgency.Reports
|
|||||||
|
|
||||||
private List<string[]> GetData(int tourId, DateTime startDate, DateTime endDate)
|
private List<string[]> GetData(int tourId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
|
|
||||||
var tourData = _tourRepository.ReadTours(startDate, endDate, tourId)
|
var tourData = _tourRepository.ReadTours(startDate, endDate, tourId)
|
||||||
.SelectMany(x => x.ClientTours
|
.SelectMany(x => x.ClientTours
|
||||||
.Select(y => new {
|
.Select(y => new {
|
||||||
@ -56,10 +55,8 @@ namespace ProjectTourAgency.Reports
|
|||||||
CountOut = (int?)y.Cost
|
CountOut = (int?)y.Cost
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
var clientId = tourData.Select(x => x.ClientId).Distinct().ToList();
|
||||||
var clientId = tourData.Select(x =>x.ClientId).Distinct().ToList();
|
|
||||||
|
|
||||||
|
|
||||||
var addMoneyData = _addMoneyRepository.ReadAddMoneys(startDate, endDate)
|
var addMoneyData = _addMoneyRepository.ReadAddMoneys(startDate, endDate)
|
||||||
.Where(x => clientId.Contains(x.ClientId))
|
.Where(x => clientId.Contains(x.ClientId))
|
||||||
.Select(x => new {
|
.Select(x => new {
|
||||||
@ -70,24 +67,33 @@ namespace ProjectTourAgency.Reports
|
|||||||
CountOut = (int?)null
|
CountOut = (int?)null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Объединяем данные и группируем по клиенту и дате
|
||||||
var data = tourData
|
var data = tourData
|
||||||
.Union(addMoneyData)
|
.Union(addMoneyData)
|
||||||
|
.GroupBy(x => new { x.ClientId, x.ClientName, x.Date })
|
||||||
|
.Select(g => new {
|
||||||
|
ClientName = g.Key.ClientName,
|
||||||
|
Date = g.Key.Date,
|
||||||
|
CountIn = g.Sum(x => x.CountIn ?? 0),
|
||||||
|
CountOut = g.Sum(x => x.CountOut ?? 0)
|
||||||
|
})
|
||||||
.OrderBy(x => x.Date);
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
return new List<string[]>() { item }
|
return new List<string[]>() { item }
|
||||||
.Union(data.Select(x => new string[] {
|
.Union(data.Select(x => new string[] {
|
||||||
x.ClientName.ToString(),
|
x.ClientName,
|
||||||
x.Date.ToString(),
|
x.Date.ToString("dd.MM.yyyy"), // Форматируем дату
|
||||||
x.CountIn?.ToString() ?? "NO",
|
x.CountIn == 0 ? "NO" : x.CountIn.ToString(),
|
||||||
x.CountOut?.ToString() ?? "NO"}))
|
x.CountOut == 0 ? "NO" : x.CountOut.ToString()
|
||||||
|
}))
|
||||||
.Union(new[] { new string[] {
|
.Union(new[] { new string[] {
|
||||||
"Всего",
|
"Всего",
|
||||||
"",
|
"",
|
||||||
data.Sum(x => x.CountIn ?? 0) == 0 ? "NO" : data.Sum(x => x.CountIn ?? 0).ToString(),
|
data.Sum(x => x.CountIn) == 0 ? "NO" : data.Sum(x => x.CountIn).ToString(),
|
||||||
data.Sum(x => x.CountOut ?? 0) == 0 ? "NO" : data.Sum(x => x.CountOut ?? 0).ToString()
|
data.Sum(x => x.CountOut) == 0 ? "NO" : data.Sum(x => x.CountOut).ToString()
|
||||||
}})
|
}})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user