200824PX Added form for preparing processing of payment receipts, moved AddOkCancel() to separate class

This commit is contained in:
phantomix 2020-08-24 18:48:02 +02:00
parent bf2c2f4978
commit fc97fa4695
5 changed files with 101 additions and 33 deletions

View File

@ -192,6 +192,8 @@
<Compile Include="core\Cronjob.cs" />
<Compile Include="core\ProcessCsv.cs" />
<Compile Include="core\Utils.cs" />
<Compile Include="view\frmPaymentReceipts.cs" />
<Compile Include="view\FormWithOkCancel.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

44
view/FormWithOkCancel.cs Normal file
View File

@ -0,0 +1,44 @@
using System;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace dezentrale.view
{
public class FormWithOkCancel : Form
{
protected const int margin = 5;
protected const int lm = margin; //Left margin
protected const int tm = margin; //Top margin
protected const int rm = 20; //Right margin
protected const int line = 20 + margin; //lineheight
protected const int labelHeight = 14;
protected const int labelOffs = 3;
protected void AddOkCancel(Control parent, EventHandler okEvent, EventHandler cancelEvent, bool writeEnabled = true)
{
//Console.WriteLine($"frmMoneyTransfer.AddOkCancel(writeEnabled={writeEnabled})");
Button ok = new Button()
{
Text = "OK",
Location = new System.Drawing.Point(parent.Width - 160 - rm, parent.Height - 57),
Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
Enabled = writeEnabled,
};
if (writeEnabled) ok.Click += okEvent;
Button cancel = new Button()
{
Text = "Cancel",
Location = new System.Drawing.Point(parent.Width - 75 - rm, parent.Height - 57),
Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
};
cancel.Click += cancelEvent;
parent.Controls.Add(ok);
parent.Controls.Add(cancel);
}
}
}

View File

@ -10,16 +10,8 @@ using dezentrale.model;
namespace dezentrale.view
{
public class frmConfiguration : Form
public class frmConfiguration : FormWithOkCancel
{
private const int margin = 5;
private const int lm = margin; //Left margin
private const int tm = margin; //Top margin
private const int rm = 20; //Right margin
private const int line = 20 + margin; //lineheight
private const int labelHeight = 14;
private const int labelOffs = 3;
//Generic settings
private TextBox tbDbDirectory;
private TextBox tbRegularPayment;
@ -54,28 +46,6 @@ namespace dezentrale.view
private TextBox tbIeHgPassword;
private TextBox tbIeHgURL;
private void AddOkCancel(Control parent, EventHandler okEvent, EventHandler cancelEvent, bool writeEnabled = true)
{
//Console.WriteLine($"frmMoneyTransfer.AddOkCancel(writeEnabled={writeEnabled})");
Button ok = new Button()
{
Text = "OK",
Location = new System.Drawing.Point(parent.Width - 170 - rm, parent.Height - 87),
Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
Enabled = writeEnabled,
};
if (writeEnabled) ok.Click += okEvent;
Button cancel = new Button()
{
Text = "Cancel",
Location = new System.Drawing.Point(parent.Width - 85 - rm, parent.Height - 87),
Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
};
cancel.Click += cancelEvent;
parent.Controls.Add(ok);
parent.Controls.Add(cancel);
}
public TabPage BuildGenericGui()
{
TabPage gui = new TabPage("Generic");

View File

@ -55,7 +55,8 @@ namespace dezentrale.view
new MenuItem("Payments")
{ MenuItems = {
new MenuItem("&Add new MoneyTransfer", mnuMain_Payments_Add) { Enabled = true },
new MenuItem("Process CSV...", mnuMain_Payments_ProcessCSV),
new MenuItem("Process CSV...", mnuMain_Payments_ProcessCSV),
new MenuItem("Generate payment receipts...", mnuMain_Payments_Receipts),
} },
new MenuItem("Help")
{ MenuItems = {
@ -238,7 +239,15 @@ namespace dezentrale.view
if (dr == DialogResult.OK)
ProcessCsv.ProcessCSV(ofd.FileName);
}
private void mnuMain_Payments_Receipts(object sender, EventArgs e)
{
frmPaymentReceipts receipts = new frmPaymentReceipts();
DialogResult dr = receipts.ShowDialog();
if(dr == DialogResult.OK)
{
}
}
private void mnuMain_Help_About(object sender, EventArgs e)
{
MessageBox.Show("mnuMain_Help_About");

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using dezentrale.core;
using dezentrale.model;
using dezentrale.model.money;
namespace dezentrale.view
{
public class frmPaymentReceipts : FormWithOkCancel
{
public string SvgTemplate { get; set; } = "";
public string OutputDirectory { get; set; } = "";
public string FileNamePattern { get; set; } = "{Number}-{Date}";
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
private TextBox tbSvgTemplate;
private TextBox tbOutputDirectory;
private TextBox tbFileNamePattern;
private DateTimePicker dtStartDate;
private DateTimePicker dtEndDate;
public frmPaymentReceipts()
{
AddOkCancel(this, btnOK_Click, btnCancel_Click);
}
private void btnOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}