Infört en möjlighet att rensa transtabellen
This commit is contained in:
@ -7,6 +7,7 @@ namespace WinFormDiApp.BLI
|
|||||||
bool AddAccountRecord(AccountRecord record);
|
bool AddAccountRecord(AccountRecord record);
|
||||||
AccountRecord SaveAcountRecord(AccountRecord record);
|
AccountRecord SaveAcountRecord(AccountRecord record);
|
||||||
bool DeleteAccountRecord(AccountRecord record);
|
bool DeleteAccountRecord(AccountRecord record);
|
||||||
|
bool DeleteAllAccountRecords();
|
||||||
IEnumerable<AccountRecord> GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo);
|
IEnumerable<AccountRecord> GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo);
|
||||||
IEnumerable<AccountRecord> GetAllAccounts();
|
IEnumerable<AccountRecord> GetAllAccounts();
|
||||||
AccountRecord GetAccount(int id);
|
AccountRecord GetAccount(int id);
|
||||||
|
|||||||
@ -87,6 +87,21 @@ public class AccountRecordRepository : IAccountRecordRepository
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DeleteAllAccountRecords()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var all = from c in _dataContext.AccountRecords select c;
|
||||||
|
_dataContext.AccountRecords.RemoveRange(all);
|
||||||
|
_dataContext.SaveChanges();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError("Error occured in DeleteAllAccountRecord :-->{iMessage}", e.Message);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public IEnumerable<AccountRecord> GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo)
|
public IEnumerable<AccountRecord> GetAllAccBetweenDates(DateTime dateFrom, DateTime dateTo)
|
||||||
{
|
{
|
||||||
IEnumerable<AccountRecord> result = null;
|
IEnumerable<AccountRecord> result = null;
|
||||||
|
|||||||
51
WinFormDi/MainWindow.Designer.cs
generated
51
WinFormDi/MainWindow.Designer.cs
generated
@ -35,15 +35,16 @@
|
|||||||
btnSearchPayments = new Button();
|
btnSearchPayments = new Button();
|
||||||
btnClose = new Button();
|
btnClose = new Button();
|
||||||
btnEdit = new Button();
|
btnEdit = new Button();
|
||||||
|
btnClearRecords = new Button();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// helloText
|
// helloText
|
||||||
//
|
//
|
||||||
helloText.AutoSize = true;
|
helloText.AutoSize = true;
|
||||||
helloText.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
helloText.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
helloText.Location = new Point(12, 9);
|
helloText.Location = new Point(14, 12);
|
||||||
helloText.Name = "helloText";
|
helloText.Name = "helloText";
|
||||||
helloText.Size = new Size(45, 19);
|
helloText.Size = new Size(52, 23);
|
||||||
helloText.TabIndex = 0;
|
helloText.TabIndex = 0;
|
||||||
helloText.Text = "------";
|
helloText.Text = "------";
|
||||||
//
|
//
|
||||||
@ -51,17 +52,18 @@
|
|||||||
//
|
//
|
||||||
goodbyeText.AutoSize = true;
|
goodbyeText.AutoSize = true;
|
||||||
goodbyeText.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
goodbyeText.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
goodbyeText.Location = new Point(12, 422);
|
goodbyeText.Location = new Point(14, 563);
|
||||||
goodbyeText.Name = "goodbyeText";
|
goodbyeText.Name = "goodbyeText";
|
||||||
goodbyeText.Size = new Size(45, 19);
|
goodbyeText.Size = new Size(52, 23);
|
||||||
goodbyeText.TabIndex = 1;
|
goodbyeText.TabIndex = 1;
|
||||||
goodbyeText.Text = "------";
|
goodbyeText.Text = "------";
|
||||||
//
|
//
|
||||||
// btnCheckPayments
|
// btnCheckPayments
|
||||||
//
|
//
|
||||||
btnCheckPayments.Location = new Point(75, 70);
|
btnCheckPayments.Location = new Point(86, 93);
|
||||||
|
btnCheckPayments.Margin = new Padding(3, 4, 3, 4);
|
||||||
btnCheckPayments.Name = "btnCheckPayments";
|
btnCheckPayments.Name = "btnCheckPayments";
|
||||||
btnCheckPayments.Size = new Size(156, 23);
|
btnCheckPayments.Size = new Size(178, 31);
|
||||||
btnCheckPayments.TabIndex = 2;
|
btnCheckPayments.TabIndex = 2;
|
||||||
btnCheckPayments.Text = "Kontrollera Betalningar";
|
btnCheckPayments.Text = "Kontrollera Betalningar";
|
||||||
btnCheckPayments.UseVisualStyleBackColor = true;
|
btnCheckPayments.UseVisualStyleBackColor = true;
|
||||||
@ -69,9 +71,10 @@
|
|||||||
//
|
//
|
||||||
// btnLoadPayments
|
// btnLoadPayments
|
||||||
//
|
//
|
||||||
btnLoadPayments.Location = new Point(75, 41);
|
btnLoadPayments.Location = new Point(86, 55);
|
||||||
|
btnLoadPayments.Margin = new Padding(3, 4, 3, 4);
|
||||||
btnLoadPayments.Name = "btnLoadPayments";
|
btnLoadPayments.Name = "btnLoadPayments";
|
||||||
btnLoadPayments.Size = new Size(156, 23);
|
btnLoadPayments.Size = new Size(178, 31);
|
||||||
btnLoadPayments.TabIndex = 3;
|
btnLoadPayments.TabIndex = 3;
|
||||||
btnLoadPayments.Text = "Ladda betalningar";
|
btnLoadPayments.Text = "Ladda betalningar";
|
||||||
btnLoadPayments.UseVisualStyleBackColor = true;
|
btnLoadPayments.UseVisualStyleBackColor = true;
|
||||||
@ -79,9 +82,10 @@
|
|||||||
//
|
//
|
||||||
// btnSearchPayments
|
// btnSearchPayments
|
||||||
//
|
//
|
||||||
btnSearchPayments.Location = new Point(75, 99);
|
btnSearchPayments.Location = new Point(86, 132);
|
||||||
|
btnSearchPayments.Margin = new Padding(3, 4, 3, 4);
|
||||||
btnSearchPayments.Name = "btnSearchPayments";
|
btnSearchPayments.Name = "btnSearchPayments";
|
||||||
btnSearchPayments.Size = new Size(156, 23);
|
btnSearchPayments.Size = new Size(178, 31);
|
||||||
btnSearchPayments.TabIndex = 4;
|
btnSearchPayments.TabIndex = 4;
|
||||||
btnSearchPayments.Text = "Sök betalningar";
|
btnSearchPayments.Text = "Sök betalningar";
|
||||||
btnSearchPayments.UseVisualStyleBackColor = true;
|
btnSearchPayments.UseVisualStyleBackColor = true;
|
||||||
@ -89,9 +93,10 @@
|
|||||||
//
|
//
|
||||||
// btnClose
|
// btnClose
|
||||||
//
|
//
|
||||||
btnClose.Location = new Point(713, 420);
|
btnClose.Location = new Point(815, 560);
|
||||||
|
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 = 5;
|
btnClose.TabIndex = 5;
|
||||||
btnClose.Text = "Stäng";
|
btnClose.Text = "Stäng";
|
||||||
btnClose.UseVisualStyleBackColor = true;
|
btnClose.UseVisualStyleBackColor = true;
|
||||||
@ -99,19 +104,31 @@
|
|||||||
//
|
//
|
||||||
// btnEdit
|
// btnEdit
|
||||||
//
|
//
|
||||||
btnEdit.Location = new Point(75, 128);
|
btnEdit.Location = new Point(86, 171);
|
||||||
|
btnEdit.Margin = new Padding(3, 4, 3, 4);
|
||||||
btnEdit.Name = "btnEdit";
|
btnEdit.Name = "btnEdit";
|
||||||
btnEdit.Size = new Size(156, 23);
|
btnEdit.Size = new Size(178, 31);
|
||||||
btnEdit.TabIndex = 6;
|
btnEdit.TabIndex = 6;
|
||||||
btnEdit.Text = "Justera/Addera betalning";
|
btnEdit.Text = "Justera/Addera betalning";
|
||||||
btnEdit.UseVisualStyleBackColor = true;
|
btnEdit.UseVisualStyleBackColor = true;
|
||||||
btnEdit.Click += btnEdit_Click;
|
btnEdit.Click += btnEdit_Click;
|
||||||
//
|
//
|
||||||
|
// btnClearRecords
|
||||||
|
//
|
||||||
|
btnClearRecords.Location = new Point(91, 211);
|
||||||
|
btnClearRecords.Name = "btnClearRecords";
|
||||||
|
btnClearRecords.Size = new Size(173, 29);
|
||||||
|
btnClearRecords.TabIndex = 7;
|
||||||
|
btnClearRecords.Text = "Töm databasen";
|
||||||
|
btnClearRecords.UseVisualStyleBackColor = true;
|
||||||
|
btnClearRecords.Click += btnClearRecords_Click;
|
||||||
|
//
|
||||||
// MainWindow
|
// MainWindow
|
||||||
//
|
//
|
||||||
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, 600);
|
||||||
|
Controls.Add(btnClearRecords);
|
||||||
Controls.Add(btnEdit);
|
Controls.Add(btnEdit);
|
||||||
Controls.Add(btnClose);
|
Controls.Add(btnClose);
|
||||||
Controls.Add(btnSearchPayments);
|
Controls.Add(btnSearchPayments);
|
||||||
@ -119,6 +136,7 @@
|
|||||||
Controls.Add(btnCheckPayments);
|
Controls.Add(btnCheckPayments);
|
||||||
Controls.Add(goodbyeText);
|
Controls.Add(goodbyeText);
|
||||||
Controls.Add(helloText);
|
Controls.Add(helloText);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "MainWindow";
|
Name = "MainWindow";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "MainWindow";
|
Text = "MainWindow";
|
||||||
@ -137,5 +155,6 @@
|
|||||||
private Button btnSearchPayments;
|
private Button btnSearchPayments;
|
||||||
private Button btnClose;
|
private Button btnClose;
|
||||||
private Button btnEdit;
|
private Button btnEdit;
|
||||||
|
private Button btnClearRecords;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,5 +71,12 @@ namespace WinFormDiApp
|
|||||||
{
|
{
|
||||||
_editPayment.ShowDialog();
|
_editPayment.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnClearRecords_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_payments.EnableClearing = true;
|
||||||
|
_payments.ShowDialog();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
WinFormDi/frmPayments.Designer.cs
generated
29
WinFormDi/frmPayments.Designer.cs
generated
@ -36,6 +36,7 @@
|
|||||||
ch5_Förfallodag = new ColumnHeader();
|
ch5_Förfallodag = new ColumnHeader();
|
||||||
ch6_Avisering = new ColumnHeader();
|
ch6_Avisering = new ColumnHeader();
|
||||||
btnClose = new Button();
|
btnClose = new Button();
|
||||||
|
btnRensa = new Button();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// lvPayments
|
// lvPayments
|
||||||
@ -43,9 +44,10 @@
|
|||||||
lvPayments.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
lvPayments.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
lvPayments.BackColor = Color.FromArgb(192, 255, 255);
|
lvPayments.BackColor = Color.FromArgb(192, 255, 255);
|
||||||
lvPayments.Columns.AddRange(new ColumnHeader[] { ch1_Id, ch2_Mottagare, ch3_Konto, ch4_Belopp, ch5_Förfallodag, ch6_Avisering });
|
lvPayments.Columns.AddRange(new ColumnHeader[] { ch1_Id, ch2_Mottagare, ch3_Konto, ch4_Belopp, ch5_Förfallodag, ch6_Avisering });
|
||||||
lvPayments.Location = new Point(28, 55);
|
lvPayments.Location = new Point(32, 73);
|
||||||
|
lvPayments.Margin = new Padding(3, 4, 3, 4);
|
||||||
lvPayments.Name = "lvPayments";
|
lvPayments.Name = "lvPayments";
|
||||||
lvPayments.Size = new Size(805, 286);
|
lvPayments.Size = new Size(919, 380);
|
||||||
lvPayments.TabIndex = 0;
|
lvPayments.TabIndex = 0;
|
||||||
lvPayments.UseCompatibleStateImageBehavior = false;
|
lvPayments.UseCompatibleStateImageBehavior = false;
|
||||||
lvPayments.View = View.Details;
|
lvPayments.View = View.Details;
|
||||||
@ -81,21 +83,35 @@
|
|||||||
//
|
//
|
||||||
// btnClose
|
// btnClose
|
||||||
//
|
//
|
||||||
btnClose.Location = new Point(758, 418);
|
btnClose.Location = new Point(866, 557);
|
||||||
|
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 = 1;
|
btnClose.TabIndex = 1;
|
||||||
btnClose.Text = "Stäng";
|
btnClose.Text = "Stäng";
|
||||||
btnClose.UseVisualStyleBackColor = true;
|
btnClose.UseVisualStyleBackColor = true;
|
||||||
btnClose.Click += btnClose_Click;
|
btnClose.Click += btnClose_Click;
|
||||||
//
|
//
|
||||||
|
// btnRensa
|
||||||
|
//
|
||||||
|
btnRensa.Location = new Point(766, 559);
|
||||||
|
btnRensa.Name = "btnRensa";
|
||||||
|
btnRensa.Size = new Size(94, 29);
|
||||||
|
btnRensa.TabIndex = 2;
|
||||||
|
btnRensa.Text = "Rensa ";
|
||||||
|
btnRensa.UseVisualStyleBackColor = true;
|
||||||
|
btnRensa.Visible = false;
|
||||||
|
btnRensa.Click += btnRensa_Click;
|
||||||
|
//
|
||||||
// frmPayments
|
// frmPayments
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(856, 453);
|
ClientSize = new Size(978, 604);
|
||||||
|
Controls.Add(btnRensa);
|
||||||
Controls.Add(btnClose);
|
Controls.Add(btnClose);
|
||||||
Controls.Add(lvPayments);
|
Controls.Add(lvPayments);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "frmPayments";
|
Name = "frmPayments";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "frmPayments";
|
Text = "frmPayments";
|
||||||
@ -114,5 +130,6 @@
|
|||||||
private ColumnHeader ch6_Avisering;
|
private ColumnHeader ch6_Avisering;
|
||||||
private Button btnClose;
|
private Button btnClose;
|
||||||
private ColumnHeader ch5_Förfallodag;
|
private ColumnHeader ch5_Förfallodag;
|
||||||
|
private Button btnRensa;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,8 +14,21 @@ namespace WinFormDiApp
|
|||||||
{
|
{
|
||||||
public partial class frmPayments : Form
|
public partial class frmPayments : Form
|
||||||
{
|
{
|
||||||
|
private bool _enableClearing;
|
||||||
private readonly IAccountRecordRepository _accountRecordRepository;
|
private readonly IAccountRecordRepository _accountRecordRepository;
|
||||||
|
|
||||||
|
public bool EnableClearing
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _enableClearing;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_enableClearing = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public frmPayments(IAccountRecordRepository accountRecordRepository)
|
public frmPayments(IAccountRecordRepository accountRecordRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -26,7 +39,9 @@ namespace WinFormDiApp
|
|||||||
private void frmPayments_Load(object sender, EventArgs e)
|
private void frmPayments_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//MessageBox.Show("Load");
|
//MessageBox.Show("Load");
|
||||||
|
btnRensa.Visible = _enableClearing;
|
||||||
lvPayments.Items.Clear();
|
lvPayments.Items.Clear();
|
||||||
|
|
||||||
if (CustomPayments != null)
|
if (CustomPayments != null)
|
||||||
{
|
{
|
||||||
foreach (var account in CustomPayments)
|
foreach (var account in CustomPayments)
|
||||||
@ -65,5 +80,26 @@ namespace WinFormDiApp
|
|||||||
}
|
}
|
||||||
else CustomPayments = null;
|
else CustomPayments = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnRensa_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(MessageBox.Show("Verkligen Säker på att rensa DB?","Payments", MessageBoxButtons.YesNo, MessageBoxIcon.Question)==DialogResult.Yes)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Nu rensar vi");
|
||||||
|
_accountRecordRepository.DeleteAllAccountRecords();
|
||||||
|
|
||||||
|
lvPayments.Items.Clear();
|
||||||
|
var payments = _accountRecordRepository.GetAllAccounts();
|
||||||
|
foreach (var account in payments)
|
||||||
|
{
|
||||||
|
var lvitem = lvPayments.Items.Add(account.Id.ToString());
|
||||||
|
lvitem.SubItems.Add(account.Mottagare);
|
||||||
|
lvitem.SubItems.Add(account.Konto);
|
||||||
|
lvitem.SubItems.Add(account.Belopp.ToString());
|
||||||
|
lvitem.SubItems.Add(account.BetalDatum.ToShortDateString());
|
||||||
|
lvitem.SubItems.Add(account.Avisering);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user