Summering av sökta transaktioner

This commit is contained in:
2024-02-09 23:51:56 +01:00
parent a215b54d0d
commit a16137072b
5 changed files with 60 additions and 24 deletions

View File

@ -46,7 +46,9 @@ public class ReadingIn : IReadingIn, IDisposable
if (prt) if (prt)
{ {
//Console.WriteLine(); //Console.WriteLine();
record.Id = row;
_logger.LogInformation(record.ToString()); _logger.LogInformation(record.ToString());
record.Id = 0;
records.Add(record); records.Add(record);
} }
prt = false; prt = false;
@ -132,10 +134,10 @@ public class ReadingIn : IReadingIn, IDisposable
var restab = readXLS(fullFileName); var restab = readXLS(fullFileName);
if (restab != null) if (restab != null)
{ {
restab.ToList().ForEach(x => //restab.ToList().ForEach(x =>
{ //{
_logger.LogInformation(x.ToString()); // _logger.LogInformation(x.ToString());
}); //});
try try
{ {

View File

@ -11,7 +11,7 @@
}, },
"Debug": { "Debug": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Warning",
"Microsoft*": "Warning" "Microsoft*": "Warning"
} }
}, },

View File

@ -36,13 +36,16 @@
dtpTo = new DateTimePicker(); dtpTo = new DateTimePicker();
btnStartSearch = new Button(); btnStartSearch = new Button();
flpPanel1 = new FlowLayoutPanel(); flpPanel1 = new FlowLayoutPanel();
label1 = new Label();
txtSoekSumma = new TextBox();
SuspendLayout(); SuspendLayout();
// //
// btnClose // btnClose
// //
btnClose.Location = new Point(713, 415); btnClose.Location = new Point(816, 577);
btnClose.Margin = new Padding(3, 4, 3, 4);
btnClose.Name = "btnClose"; btnClose.Name = "btnClose";
btnClose.Size = new Size(75, 23); btnClose.Size = new Size(86, 31);
btnClose.TabIndex = 0; btnClose.TabIndex = 0;
btnClose.Text = "Stäng"; btnClose.Text = "Stäng";
btnClose.UseVisualStyleBackColor = true; btnClose.UseVisualStyleBackColor = true;
@ -52,51 +55,54 @@
// //
lblHeader.AutoSize = true; lblHeader.AutoSize = true;
lblHeader.Font = new Font("Segoe UI", 13F, FontStyle.Bold, GraphicsUnit.Point); lblHeader.Font = new Font("Segoe UI", 13F, FontStyle.Bold, GraphicsUnit.Point);
lblHeader.Location = new Point(21, 17); lblHeader.Location = new Point(24, 23);
lblHeader.Name = "lblHeader"; lblHeader.Name = "lblHeader";
lblHeader.Size = new Size(223, 25); lblHeader.Size = new Size(271, 30);
lblHeader.TabIndex = 2; lblHeader.TabIndex = 2;
lblHeader.Text = "Sök data mellan 2 datum"; lblHeader.Text = "Sök data mellan 2 datum";
// //
// lblDateFrom // lblDateFrom
// //
lblDateFrom.AutoSize = true; lblDateFrom.AutoSize = true;
lblDateFrom.Location = new Point(21, 65); lblDateFrom.Location = new Point(24, 87);
lblDateFrom.Name = "lblDateFrom"; lblDateFrom.Name = "lblDateFrom";
lblDateFrom.Size = new Size(68, 15); lblDateFrom.Size = new Size(84, 20);
lblDateFrom.TabIndex = 3; lblDateFrom.TabIndex = 3;
lblDateFrom.Text = "Från datum"; lblDateFrom.Text = "Från datum";
// //
// dtpFrom // dtpFrom
// //
dtpFrom.Format = DateTimePickerFormat.Short; dtpFrom.Format = DateTimePickerFormat.Short;
dtpFrom.Location = new Point(95, 59); dtpFrom.Location = new Point(109, 79);
dtpFrom.Margin = new Padding(3, 4, 3, 4);
dtpFrom.Name = "dtpFrom"; dtpFrom.Name = "dtpFrom";
dtpFrom.Size = new Size(112, 23); dtpFrom.Size = new Size(127, 27);
dtpFrom.TabIndex = 4; dtpFrom.TabIndex = 4;
// //
// lblDateTo // lblDateTo
// //
lblDateTo.AutoSize = true; lblDateTo.AutoSize = true;
lblDateTo.Location = new Point(233, 65); lblDateTo.Location = new Point(266, 87);
lblDateTo.Name = "lblDateTo"; lblDateTo.Name = "lblDateTo";
lblDateTo.Size = new Size(60, 15); lblDateTo.Size = new Size(76, 20);
lblDateTo.TabIndex = 5; lblDateTo.TabIndex = 5;
lblDateTo.Text = "Till datum"; lblDateTo.Text = "Till datum";
// //
// dtpTo // dtpTo
// //
dtpTo.Format = DateTimePickerFormat.Short; dtpTo.Format = DateTimePickerFormat.Short;
dtpTo.Location = new Point(310, 59); dtpTo.Location = new Point(354, 79);
dtpTo.Margin = new Padding(3, 4, 3, 4);
dtpTo.Name = "dtpTo"; dtpTo.Name = "dtpTo";
dtpTo.Size = new Size(100, 23); dtpTo.Size = new Size(114, 27);
dtpTo.TabIndex = 6; dtpTo.TabIndex = 6;
// //
// btnStartSearch // btnStartSearch
// //
btnStartSearch.Location = new Point(443, 61); btnStartSearch.Location = new Point(506, 81);
btnStartSearch.Margin = new Padding(3, 4, 3, 4);
btnStartSearch.Name = "btnStartSearch"; btnStartSearch.Name = "btnStartSearch";
btnStartSearch.Size = new Size(96, 23); btnStartSearch.Size = new Size(110, 31);
btnStartSearch.TabIndex = 7; btnStartSearch.TabIndex = 7;
btnStartSearch.Text = "Starta sökning"; btnStartSearch.Text = "Starta sökning";
btnStartSearch.UseVisualStyleBackColor = true; btnStartSearch.UseVisualStyleBackColor = true;
@ -106,16 +112,38 @@
// //
flpPanel1.AutoScroll = true; flpPanel1.AutoScroll = true;
flpPanel1.BackColor = Color.Silver; flpPanel1.BackColor = Color.Silver;
flpPanel1.Location = new Point(21, 102); flpPanel1.Location = new Point(24, 136);
flpPanel1.Margin = new Padding(3, 4, 3, 4);
flpPanel1.Name = "flpPanel1"; flpPanel1.Name = "flpPanel1";
flpPanel1.Size = new Size(668, 314); flpPanel1.Size = new Size(763, 419);
flpPanel1.TabIndex = 8; flpPanel1.TabIndex = 8;
// //
// label1
//
label1.AutoSize = true;
label1.Location = new Point(287, 582);
label1.Name = "label1";
label1.Size = new Size(149, 20);
label1.TabIndex = 9;
label1.Text = "Totalt för sökt period";
//
// txtSoekSumma
//
txtSoekSumma.BackColor = SystemColors.ButtonHighlight;
txtSoekSumma.Font = new Font("Segoe UI", 14F, FontStyle.Bold, GraphicsUnit.Point);
txtSoekSumma.Location = new Point(453, 570);
txtSoekSumma.Name = "txtSoekSumma";
txtSoekSumma.ReadOnly = true;
txtSoekSumma.Size = new Size(210, 39);
txtSoekSumma.TabIndex = 10;
//
// frmSearchData // frmSearchData
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(914, 621);
Controls.Add(txtSoekSumma);
Controls.Add(label1);
Controls.Add(flpPanel1); Controls.Add(flpPanel1);
Controls.Add(btnStartSearch); Controls.Add(btnStartSearch);
Controls.Add(dtpTo); Controls.Add(dtpTo);
@ -124,6 +152,7 @@
Controls.Add(lblDateFrom); Controls.Add(lblDateFrom);
Controls.Add(lblHeader); Controls.Add(lblHeader);
Controls.Add(btnClose); Controls.Add(btnClose);
Margin = new Padding(3, 4, 3, 4);
Name = "frmSearchData"; Name = "frmSearchData";
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
Text = "frmSearchData"; Text = "frmSearchData";
@ -141,5 +170,7 @@
private DateTimePicker dtpTo; private DateTimePicker dtpTo;
private Button btnStartSearch; private Button btnStartSearch;
private FlowLayoutPanel flpPanel1; private FlowLayoutPanel flpPanel1;
private Label label1;
private TextBox txtSoekSumma;
} }
} }

View File

@ -40,6 +40,7 @@ namespace WinFormDiApp
private void btnStartSearch_Click(object sender, EventArgs e) private void btnStartSearch_Click(object sender, EventArgs e)
{ {
double SearchedSum = 0;
flpPanel1.Controls.Clear(); flpPanel1.Controls.Clear();
foundRecs = _accountRecordRepository.GetAllAccBetweenDates(dtpFrom.Value, dtpTo.Value); foundRecs = _accountRecordRepository.GetAllAccBetweenDates(dtpFrom.Value, dtpTo.Value);
if (foundRecs.Any()) if (foundRecs.Any())
@ -48,8 +49,10 @@ namespace WinFormDiApp
foreach (var account in aggregates) foreach (var account in aggregates)
{ {
var ucCustV = createAndFillUCcv(account); var ucCustV = createAndFillUCcv(account);
SearchedSum += Convert.ToDouble(ucCustV.Amount);
flpPanel1.Controls.Add(ucCustV); flpPanel1.Controls.Add(ucCustV);
} }
txtSoekSumma.Text=SearchedSum.ToString();
} }
else else
{ {

View File

@ -18,7 +18,7 @@ namespace WinFormDiApp.BL.Models
public override string ToString() public override string ToString()
{ {
//return base.ToString(); //return base.ToString();
return $"BetalDatum:{BetalDatum}, Mottagare:{Mottagare}, Konto:{Konto}, Belopp:{Belopp}, Avisering:{Avisering}"; return $"\"Rad{Id}\": {{\"BetalDatum\": \"{BetalDatum}\", \"Mottagare\": \"{Mottagare}\", \"Konto\": \"{Konto}\", \"Belopp\": \"{Belopp}\", \"Avisering\": \"{Avisering}\"}},";
} }
} }
} }