From 2b6e48c3eff74ba900b4bfefa6357e98f902a1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Wed, 6 Sep 2023 22:04:24 +0200 Subject: [PATCH] =?UTF-8?q?Nytt=20s=C3=B6kf=C3=B6nster=20tillagt,=20ny=20m?= =?UTF-8?q?etod=20f=C3=B6r=20att=20s=C3=B6ka=20betalningar=20mellan=202=20?= =?UTF-8?q?datum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormDi.BLI/IAccountRecordRepository.cs | 1 + WinFormDi.BLR/AccountRecordRepository.cs | 22 ++++ WinFormDi/ContainerConfig.cs | 8 +- WinFormDi/MainWindow.Designer.cs | 30 ++++- WinFormDi/MainWindow.cs | 15 ++- WinFormDi/Program.cs | 2 +- WinFormDi/frmReadPayments.Designer.cs | 1 + WinFormDi/frmReadPayments.cs | 5 +- WinFormDi/frmSearchData.Designer.cs | 132 ++++++++++++++++++++++ WinFormDi/frmSearchData.cs | 29 +++++ WinFormDi/frmSearchData.resx | 120 ++++++++++++++++++++ 11 files changed, 356 insertions(+), 9 deletions(-) create mode 100644 WinFormDi/frmSearchData.Designer.cs create mode 100644 WinFormDi/frmSearchData.cs create mode 100644 WinFormDi/frmSearchData.resx diff --git a/WinFormDi.BLI/IAccountRecordRepository.cs b/WinFormDi.BLI/IAccountRecordRepository.cs index 9a57c35..ba09f1c 100644 --- a/WinFormDi.BLI/IAccountRecordRepository.cs +++ b/WinFormDi.BLI/IAccountRecordRepository.cs @@ -6,6 +6,7 @@ namespace WinFormDiApp.BLI { bool AddAccountRecord(AccountRecord record); bool DeleteAccountRecord(AccountRecord record); + IEnumerable GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo); IEnumerable GetAllAccounts(); } } \ No newline at end of file diff --git a/WinFormDi.BLR/AccountRecordRepository.cs b/WinFormDi.BLR/AccountRecordRepository.cs index 4ad49cc..cb6a5a5 100644 --- a/WinFormDi.BLR/AccountRecordRepository.cs +++ b/WinFormDi.BLR/AccountRecordRepository.cs @@ -50,6 +50,28 @@ public class AccountRecordRepository : IAccountRecordRepository return false; } + public IEnumerable GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo) + { + IEnumerable result = null; + using (ApplicationDbContext dc = _dataContext) + { + result = (from acc in dc.AccountRecords + where acc.BetalDatum>dateFrom && acc.BetalDatum GetAllAccounts() { return _dataContext.AccountRecords; diff --git a/WinFormDi/ContainerConfig.cs b/WinFormDi/ContainerConfig.cs index 1068567..64d918f 100644 --- a/WinFormDi/ContainerConfig.cs +++ b/WinFormDi/ContainerConfig.cs @@ -37,14 +37,14 @@ namespace WinFormDiApp .AddDbContext(options => options.UseSqlite(conn)) .AddTransient() - .AddTransient() - .AddTransient() + .AddTransient() + .AddTransient() .AddTransient() .AddTransient() .AddTransient() .AddTransient() - .AddTransient(); - + .AddTransient() + .AddTransient(); }); return builder.Build(); } diff --git a/WinFormDi/MainWindow.Designer.cs b/WinFormDi/MainWindow.Designer.cs index 3bdd1a3..03ffa91 100644 --- a/WinFormDi/MainWindow.Designer.cs +++ b/WinFormDi/MainWindow.Designer.cs @@ -32,6 +32,8 @@ goodbyeText = new Label(); btnCheckPayments = new Button(); btnLoadPayments = new Button(); + btnSearchPayments = new Button(); + btnClose = new Button(); SuspendLayout(); // // helloText @@ -56,7 +58,7 @@ // // btnCheckPayments // - btnCheckPayments.Location = new Point(73, 46); + btnCheckPayments.Location = new Point(75, 70); btnCheckPayments.Name = "btnCheckPayments"; btnCheckPayments.Size = new Size(156, 23); btnCheckPayments.TabIndex = 2; @@ -66,7 +68,7 @@ // // btnLoadPayments // - btnLoadPayments.Location = new Point(73, 75); + btnLoadPayments.Location = new Point(75, 41); btnLoadPayments.Name = "btnLoadPayments"; btnLoadPayments.Size = new Size(156, 23); btnLoadPayments.TabIndex = 3; @@ -74,11 +76,33 @@ btnLoadPayments.UseVisualStyleBackColor = true; btnLoadPayments.Click += btnLoadPayments_Click; // + // btnSearchPayments + // + btnSearchPayments.Location = new Point(75, 99); + btnSearchPayments.Name = "btnSearchPayments"; + btnSearchPayments.Size = new Size(156, 23); + btnSearchPayments.TabIndex = 4; + btnSearchPayments.Text = "Sök betalningar"; + btnSearchPayments.UseVisualStyleBackColor = true; + btnSearchPayments.Click += btnSearchPayments_Click; + // + // btnClose + // + btnClose.Location = new Point(713, 420); + btnClose.Name = "btnClose"; + btnClose.Size = new Size(75, 23); + btnClose.TabIndex = 5; + btnClose.Text = "Stäng"; + btnClose.UseVisualStyleBackColor = true; + btnClose.Click += btnClose_Click; + // // MainWindow // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); + Controls.Add(btnClose); + Controls.Add(btnSearchPayments); Controls.Add(btnLoadPayments); Controls.Add(btnCheckPayments); Controls.Add(goodbyeText); @@ -98,5 +122,7 @@ private Label goodbyeText; private Button btnCheckPayments; private Button btnLoadPayments; + private Button btnSearchPayments; + private Button btnClose; } } \ No newline at end of file diff --git a/WinFormDi/MainWindow.cs b/WinFormDi/MainWindow.cs index 462d6c3..2efbcb9 100644 --- a/WinFormDi/MainWindow.cs +++ b/WinFormDi/MainWindow.cs @@ -16,17 +16,20 @@ namespace WinFormDiApp private readonly IMessages _messages; private readonly frmPayments _payments; private readonly frmReadPayments _readPayments; + private readonly frmSearchData _searchData; public MainWindow( IMessages messages, frmPayments payments, - frmReadPayments readPayments + frmReadPayments readPayments, + frmSearchData searchData ) { InitializeComponent(); _messages = messages; _payments = payments; _readPayments = readPayments; + _searchData = searchData; } private void MainWindow_Load(object sender, EventArgs e) @@ -49,5 +52,15 @@ namespace WinFormDiApp { _readPayments.ShowDialog(); } + + private void btnSearchPayments_Click(object sender, EventArgs e) + { + _searchData.ShowDialog(); + } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } } } diff --git a/WinFormDi/Program.cs b/WinFormDi/Program.cs index ab8fa4e..8a5187a 100644 --- a/WinFormDi/Program.cs +++ b/WinFormDi/Program.cs @@ -20,7 +20,7 @@ namespace WinFormDiApp Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File(@"D:\logs\winformApp.txt",restrictedToMinimumLevel:Serilog.Events.LogEventLevel.Information, - rollingInterval: RollingInterval.Day) + rollingInterval: RollingInterval.Day) .CreateLogger(); var host = ContainerConfig.Configure(CreateHostBuilder(args)); diff --git a/WinFormDi/frmReadPayments.Designer.cs b/WinFormDi/frmReadPayments.Designer.cs index 5913225..66d7453 100644 --- a/WinFormDi/frmReadPayments.Designer.cs +++ b/WinFormDi/frmReadPayments.Designer.cs @@ -192,6 +192,7 @@ Name = "frmReadPayments"; StartPosition = FormStartPosition.CenterScreen; Text = "frmReadPayments"; + Shown += frmReadPayments_Shown; ResumeLayout(false); PerformLayout(); } diff --git a/WinFormDi/frmReadPayments.cs b/WinFormDi/frmReadPayments.cs index db93a10..6e9143c 100644 --- a/WinFormDi/frmReadPayments.cs +++ b/WinFormDi/frmReadPayments.cs @@ -64,6 +64,9 @@ namespace WinFormDiApp btnStartRead.Visible = false; } - + private void frmReadPayments_Shown(object sender, EventArgs e) + { + lvPayouts.Items.Clear(); + } } } diff --git a/WinFormDi/frmSearchData.Designer.cs b/WinFormDi/frmSearchData.Designer.cs new file mode 100644 index 0000000..fc6fa17 --- /dev/null +++ b/WinFormDi/frmSearchData.Designer.cs @@ -0,0 +1,132 @@ +namespace WinFormDiApp +{ + partial class frmSearchData + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + btnClose = new Button(); + lblHeader = new Label(); + lblDateFrom = new Label(); + dtpFrom = new DateTimePicker(); + lblDateTo = new Label(); + dtpTo = new DateTimePicker(); + btnStartSearch = new Button(); + SuspendLayout(); + // + // btnClose + // + btnClose.Location = new Point(713, 415); + btnClose.Name = "btnClose"; + btnClose.Size = new Size(75, 23); + btnClose.TabIndex = 0; + btnClose.Text = "Stäng"; + btnClose.UseVisualStyleBackColor = true; + btnClose.Click += btnClose_Click; + // + // lblHeader + // + lblHeader.AutoSize = true; + lblHeader.Font = new Font("Segoe UI", 13F, FontStyle.Bold, GraphicsUnit.Point); + lblHeader.Location = new Point(21, 17); + lblHeader.Name = "lblHeader"; + lblHeader.Size = new Size(223, 25); + lblHeader.TabIndex = 2; + lblHeader.Text = "Sök data mellan 2 datum"; + // + // lblDateFrom + // + lblDateFrom.AutoSize = true; + lblDateFrom.Location = new Point(21, 65); + lblDateFrom.Name = "lblDateFrom"; + lblDateFrom.Size = new Size(68, 15); + lblDateFrom.TabIndex = 3; + lblDateFrom.Text = "Från datum"; + // + // dtpFrom + // + dtpFrom.Format = DateTimePickerFormat.Short; + dtpFrom.Location = new Point(95, 59); + dtpFrom.Name = "dtpFrom"; + dtpFrom.Size = new Size(112, 23); + dtpFrom.TabIndex = 4; + // + // lblDateTo + // + lblDateTo.AutoSize = true; + lblDateTo.Location = new Point(233, 65); + lblDateTo.Name = "lblDateTo"; + lblDateTo.Size = new Size(60, 15); + lblDateTo.TabIndex = 5; + lblDateTo.Text = "Till datum"; + // + // dtpTo + // + dtpTo.Format = DateTimePickerFormat.Short; + dtpTo.Location = new Point(310, 59); + dtpTo.Name = "dtpTo"; + dtpTo.Size = new Size(100, 23); + dtpTo.TabIndex = 6; + // + // btnStartSearch + // + btnStartSearch.Location = new Point(443, 61); + btnStartSearch.Name = "btnStartSearch"; + btnStartSearch.Size = new Size(96, 23); + btnStartSearch.TabIndex = 7; + btnStartSearch.Text = "Starta sökning"; + btnStartSearch.UseVisualStyleBackColor = true; + // + // frmSearchData + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(btnStartSearch); + Controls.Add(dtpTo); + Controls.Add(lblDateTo); + Controls.Add(dtpFrom); + Controls.Add(lblDateFrom); + Controls.Add(lblHeader); + Controls.Add(btnClose); + Name = "frmSearchData"; + StartPosition = FormStartPosition.CenterScreen; + Text = "frmSearchData"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button btnClose; + private Label lblHeader; + private Label lblDateFrom; + private DateTimePicker dtpFrom; + private Label lblDateTo; + private DateTimePicker dtpTo; + private Button btnStartSearch; + } +} \ No newline at end of file diff --git a/WinFormDi/frmSearchData.cs b/WinFormDi/frmSearchData.cs new file mode 100644 index 0000000..64403f5 --- /dev/null +++ b/WinFormDi/frmSearchData.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using WinFormDiApp.BLI; + +namespace WinFormDiApp +{ + public partial class frmSearchData : Form + { + private readonly IAccountRecordRepository _accountRecordRepository; + + public frmSearchData(IAccountRecordRepository accountRecordRepository) + { + InitializeComponent(); + _accountRecordRepository = accountRecordRepository; + } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } + } +} diff --git a/WinFormDi/frmSearchData.resx b/WinFormDi/frmSearchData.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/WinFormDi/frmSearchData.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file