Infört en möjlighet att rensa transtabellen
This commit is contained in:
51
WinFormDi/MainWindow.Designer.cs
generated
51
WinFormDi/MainWindow.Designer.cs
generated
@ -35,15 +35,16 @@
|
||||
btnSearchPayments = new Button();
|
||||
btnClose = new Button();
|
||||
btnEdit = new Button();
|
||||
btnClearRecords = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// helloText
|
||||
//
|
||||
helloText.AutoSize = true;
|
||||
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.Size = new Size(45, 19);
|
||||
helloText.Size = new Size(52, 23);
|
||||
helloText.TabIndex = 0;
|
||||
helloText.Text = "------";
|
||||
//
|
||||
@ -51,17 +52,18 @@
|
||||
//
|
||||
goodbyeText.AutoSize = true;
|
||||
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.Size = new Size(45, 19);
|
||||
goodbyeText.Size = new Size(52, 23);
|
||||
goodbyeText.TabIndex = 1;
|
||||
goodbyeText.Text = "------";
|
||||
//
|
||||
// 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.Size = new Size(156, 23);
|
||||
btnCheckPayments.Size = new Size(178, 31);
|
||||
btnCheckPayments.TabIndex = 2;
|
||||
btnCheckPayments.Text = "Kontrollera Betalningar";
|
||||
btnCheckPayments.UseVisualStyleBackColor = true;
|
||||
@ -69,9 +71,10 @@
|
||||
//
|
||||
// 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.Size = new Size(156, 23);
|
||||
btnLoadPayments.Size = new Size(178, 31);
|
||||
btnLoadPayments.TabIndex = 3;
|
||||
btnLoadPayments.Text = "Ladda betalningar";
|
||||
btnLoadPayments.UseVisualStyleBackColor = true;
|
||||
@ -79,9 +82,10 @@
|
||||
//
|
||||
// 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.Size = new Size(156, 23);
|
||||
btnSearchPayments.Size = new Size(178, 31);
|
||||
btnSearchPayments.TabIndex = 4;
|
||||
btnSearchPayments.Text = "Sök betalningar";
|
||||
btnSearchPayments.UseVisualStyleBackColor = true;
|
||||
@ -89,9 +93,10 @@
|
||||
//
|
||||
// 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.Size = new Size(75, 23);
|
||||
btnClose.Size = new Size(86, 31);
|
||||
btnClose.TabIndex = 5;
|
||||
btnClose.Text = "Stäng";
|
||||
btnClose.UseVisualStyleBackColor = true;
|
||||
@ -99,19 +104,31 @@
|
||||
//
|
||||
// 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.Size = new Size(156, 23);
|
||||
btnEdit.Size = new Size(178, 31);
|
||||
btnEdit.TabIndex = 6;
|
||||
btnEdit.Text = "Justera/Addera betalning";
|
||||
btnEdit.UseVisualStyleBackColor = true;
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
ClientSize = new Size(914, 600);
|
||||
Controls.Add(btnClearRecords);
|
||||
Controls.Add(btnEdit);
|
||||
Controls.Add(btnClose);
|
||||
Controls.Add(btnSearchPayments);
|
||||
@ -119,6 +136,7 @@
|
||||
Controls.Add(btnCheckPayments);
|
||||
Controls.Add(goodbyeText);
|
||||
Controls.Add(helloText);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "MainWindow";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "MainWindow";
|
||||
@ -137,5 +155,6 @@
|
||||
private Button btnSearchPayments;
|
||||
private Button btnClose;
|
||||
private Button btnEdit;
|
||||
private Button btnClearRecords;
|
||||
}
|
||||
}
|
||||
@ -71,5 +71,12 @@ namespace WinFormDiApp
|
||||
{
|
||||
_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();
|
||||
ch6_Avisering = new ColumnHeader();
|
||||
btnClose = new Button();
|
||||
btnRensa = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// lvPayments
|
||||
@ -43,9 +44,10 @@
|
||||
lvPayments.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
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.Location = new Point(28, 55);
|
||||
lvPayments.Location = new Point(32, 73);
|
||||
lvPayments.Margin = new Padding(3, 4, 3, 4);
|
||||
lvPayments.Name = "lvPayments";
|
||||
lvPayments.Size = new Size(805, 286);
|
||||
lvPayments.Size = new Size(919, 380);
|
||||
lvPayments.TabIndex = 0;
|
||||
lvPayments.UseCompatibleStateImageBehavior = false;
|
||||
lvPayments.View = View.Details;
|
||||
@ -81,21 +83,35 @@
|
||||
//
|
||||
// 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.Size = new Size(75, 23);
|
||||
btnClose.Size = new Size(86, 31);
|
||||
btnClose.TabIndex = 1;
|
||||
btnClose.Text = "Stäng";
|
||||
btnClose.UseVisualStyleBackColor = true;
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(856, 453);
|
||||
ClientSize = new Size(978, 604);
|
||||
Controls.Add(btnRensa);
|
||||
Controls.Add(btnClose);
|
||||
Controls.Add(lvPayments);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "frmPayments";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "frmPayments";
|
||||
@ -114,5 +130,6 @@
|
||||
private ColumnHeader ch6_Avisering;
|
||||
private Button btnClose;
|
||||
private ColumnHeader ch5_Förfallodag;
|
||||
private Button btnRensa;
|
||||
}
|
||||
}
|
||||
@ -14,8 +14,21 @@ namespace WinFormDiApp
|
||||
{
|
||||
public partial class frmPayments : Form
|
||||
{
|
||||
private bool _enableClearing;
|
||||
private readonly IAccountRecordRepository _accountRecordRepository;
|
||||
|
||||
public bool EnableClearing
|
||||
{
|
||||
get
|
||||
{
|
||||
return _enableClearing;
|
||||
}
|
||||
set
|
||||
{
|
||||
_enableClearing = value;
|
||||
}
|
||||
}
|
||||
|
||||
public frmPayments(IAccountRecordRepository accountRecordRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -26,7 +39,9 @@ namespace WinFormDiApp
|
||||
private void frmPayments_Load(object sender, EventArgs e)
|
||||
{
|
||||
//MessageBox.Show("Load");
|
||||
btnRensa.Visible = _enableClearing;
|
||||
lvPayments.Items.Clear();
|
||||
|
||||
if (CustomPayments != null)
|
||||
{
|
||||
foreach (var account in CustomPayments)
|
||||
@ -65,5 +80,26 @@ namespace WinFormDiApp
|
||||
}
|
||||
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