Nytt sökfönster tillagt, ny metod för att söka betalningar mellan 2 datum

This commit is contained in:
2023-09-06 22:04:24 +02:00
parent 4a8fec1d5f
commit 2b6e48c3ef
11 changed files with 356 additions and 9 deletions

View File

@ -6,6 +6,7 @@ namespace WinFormDiApp.BLI
{ {
bool AddAccountRecord(AccountRecord record); bool AddAccountRecord(AccountRecord record);
bool DeleteAccountRecord(AccountRecord record); bool DeleteAccountRecord(AccountRecord record);
IEnumerable<AccountRecord> GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo);
IEnumerable<AccountRecord> GetAllAccounts(); IEnumerable<AccountRecord> GetAllAccounts();
} }
} }

View File

@ -50,6 +50,28 @@ public class AccountRecordRepository : IAccountRecordRepository
return false; return false;
} }
public IEnumerable<AccountRecord> GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo)
{
IEnumerable<AccountRecord> result = null;
using (ApplicationDbContext dc = _dataContext)
{
result = (from acc in dc.AccountRecords
where acc.BetalDatum>dateFrom && acc.BetalDatum <dateTo
orderby acc.Mottagare, acc.BetalDatum descending
select new AccountRecord
{
Id = acc.Id,
BetalDatum = acc.BetalDatum,
Mottagare = acc.Mottagare,
Avisering = acc.Avisering,
Belopp = acc.Belopp,
Konto = acc.Konto,
Stored = acc.Stored
}).ToList();
}
return result;
}
public IEnumerable<AccountRecord> GetAllAccounts() public IEnumerable<AccountRecord> GetAllAccounts()
{ {
return _dataContext.AccountRecords; return _dataContext.AccountRecords;

View File

@ -37,14 +37,14 @@ namespace WinFormDiApp
.AddDbContext<ApplicationDbContext>(options => .AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(conn)) options.UseSqlite(conn))
.AddTransient<IMessages, Messages>() .AddTransient<IMessages, Messages>()
.AddTransient<IAccountRecordRepository,AccountRecordRepository>() .AddTransient<IAccountRecordRepository, AccountRecordRepository>()
.AddTransient<IMemberRepository,MemberRepository>() .AddTransient<IMemberRepository, MemberRepository>()
.AddTransient<IReadingIn, ReadingIn>() .AddTransient<IReadingIn, ReadingIn>()
.AddTransient<IExcellent, Excellent>() .AddTransient<IExcellent, Excellent>()
.AddTransient<MainWindow>() .AddTransient<MainWindow>()
.AddTransient<frmReadPayments>() .AddTransient<frmReadPayments>()
.AddTransient<frmPayments>(); .AddTransient<frmPayments>()
.AddTransient<frmSearchData>();
}); });
return builder.Build(); return builder.Build();
} }

View File

@ -32,6 +32,8 @@
goodbyeText = new Label(); goodbyeText = new Label();
btnCheckPayments = new Button(); btnCheckPayments = new Button();
btnLoadPayments = new Button(); btnLoadPayments = new Button();
btnSearchPayments = new Button();
btnClose = new Button();
SuspendLayout(); SuspendLayout();
// //
// helloText // helloText
@ -56,7 +58,7 @@
// //
// btnCheckPayments // btnCheckPayments
// //
btnCheckPayments.Location = new Point(73, 46); btnCheckPayments.Location = new Point(75, 70);
btnCheckPayments.Name = "btnCheckPayments"; btnCheckPayments.Name = "btnCheckPayments";
btnCheckPayments.Size = new Size(156, 23); btnCheckPayments.Size = new Size(156, 23);
btnCheckPayments.TabIndex = 2; btnCheckPayments.TabIndex = 2;
@ -66,7 +68,7 @@
// //
// btnLoadPayments // btnLoadPayments
// //
btnLoadPayments.Location = new Point(73, 75); btnLoadPayments.Location = new Point(75, 41);
btnLoadPayments.Name = "btnLoadPayments"; btnLoadPayments.Name = "btnLoadPayments";
btnLoadPayments.Size = new Size(156, 23); btnLoadPayments.Size = new Size(156, 23);
btnLoadPayments.TabIndex = 3; btnLoadPayments.TabIndex = 3;
@ -74,11 +76,33 @@
btnLoadPayments.UseVisualStyleBackColor = true; btnLoadPayments.UseVisualStyleBackColor = true;
btnLoadPayments.Click += btnLoadPayments_Click; 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 // MainWindow
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(btnClose);
Controls.Add(btnSearchPayments);
Controls.Add(btnLoadPayments); Controls.Add(btnLoadPayments);
Controls.Add(btnCheckPayments); Controls.Add(btnCheckPayments);
Controls.Add(goodbyeText); Controls.Add(goodbyeText);
@ -98,5 +122,7 @@
private Label goodbyeText; private Label goodbyeText;
private Button btnCheckPayments; private Button btnCheckPayments;
private Button btnLoadPayments; private Button btnLoadPayments;
private Button btnSearchPayments;
private Button btnClose;
} }
} }

View File

@ -16,17 +16,20 @@ namespace WinFormDiApp
private readonly IMessages _messages; private readonly IMessages _messages;
private readonly frmPayments _payments; private readonly frmPayments _payments;
private readonly frmReadPayments _readPayments; private readonly frmReadPayments _readPayments;
private readonly frmSearchData _searchData;
public MainWindow( public MainWindow(
IMessages messages, IMessages messages,
frmPayments payments, frmPayments payments,
frmReadPayments readPayments frmReadPayments readPayments,
frmSearchData searchData
) )
{ {
InitializeComponent(); InitializeComponent();
_messages = messages; _messages = messages;
_payments = payments; _payments = payments;
_readPayments = readPayments; _readPayments = readPayments;
_searchData = searchData;
} }
private void MainWindow_Load(object sender, EventArgs e) private void MainWindow_Load(object sender, EventArgs e)
@ -49,5 +52,15 @@ namespace WinFormDiApp
{ {
_readPayments.ShowDialog(); _readPayments.ShowDialog();
} }
private void btnSearchPayments_Click(object sender, EventArgs e)
{
_searchData.ShowDialog();
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
} }
} }

View File

@ -192,6 +192,7 @@
Name = "frmReadPayments"; Name = "frmReadPayments";
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
Text = "frmReadPayments"; Text = "frmReadPayments";
Shown += frmReadPayments_Shown;
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }

View File

@ -64,6 +64,9 @@ namespace WinFormDiApp
btnStartRead.Visible = false; btnStartRead.Visible = false;
} }
private void frmReadPayments_Shown(object sender, EventArgs e)
{
lvPayouts.Items.Clear();
}
} }
} }

132
WinFormDi/frmSearchData.Designer.cs generated Normal file
View File

@ -0,0 +1,132 @@
namespace WinFormDiApp
{
partial class frmSearchData
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>