151 lines
5.5 KiB
C#
151 lines
5.5 KiB
C#
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, IPaymentReceiptProcessData
|
|
{
|
|
|
|
public string DataTemplate { get; set; } = "";
|
|
public IntermediateFormat DataFormat { get; set; } = IntermediateFormat.Text;
|
|
public string OutputDirectory { get; set; } = "";
|
|
public string FileNamePattern { get; set; } = "{Number}-{Date}";
|
|
public DateTime StartDate { get; set; }
|
|
public DateTime EndDate { get; set; }
|
|
|
|
|
|
private TextBox tbTemplate;
|
|
private ComboBox cbDataFormat;
|
|
private TextBox tbOutputDirectory;
|
|
private TextBox tbFileNamePattern;
|
|
private DateTimePicker dtStartDate;
|
|
private DateTimePicker dtEndDate;
|
|
|
|
public frmPaymentReceipts()
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
this.StartPosition = FormStartPosition.CenterParent;
|
|
this.Size = new System.Drawing.Size(500, 400);
|
|
this.Text = "Generate payment receipts";
|
|
this.Controls.Add(new Label()
|
|
{
|
|
Text = "Input template:",
|
|
Location = new Point(lm, 0 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
this.Controls.Add(tbTemplate = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 0 * line + tm),
|
|
Width = 200,
|
|
});
|
|
Button btnBrowseTemplate;
|
|
this.Controls.Add(btnBrowseTemplate = new Button()
|
|
{
|
|
Text = "...",
|
|
Location = new Point(lm + 333, 0 * line + tm),
|
|
Width = 40,
|
|
});
|
|
btnBrowseTemplate.Click += btnBrowseTemplate_Click;
|
|
|
|
this.Controls.Add(new Label()
|
|
{
|
|
Text = "Data format:",
|
|
Location = new Point(lm, 1 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
this.Controls.Add(cbDataFormat = new ComboBox()
|
|
{
|
|
DropDownStyle = ComboBoxStyle.DropDownList,
|
|
Location = new Point(lm + 113, 1 * line + tm),
|
|
Width = 200,
|
|
});
|
|
foreach (IntermediateFormat fmt in Enum.GetValues(typeof(IntermediateFormat)))
|
|
cbDataFormat.Items.Add(fmt);
|
|
|
|
this.Controls.Add(new Label()
|
|
{
|
|
Text = "Output directory:",
|
|
Location = new Point(lm, 2 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
this.Controls.Add(tbOutputDirectory = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 2 * line + tm),
|
|
Width = 200,
|
|
});
|
|
Button btnBrowseOutputDir;
|
|
this.Controls.Add(btnBrowseOutputDir = new Button()
|
|
{
|
|
Text = "...",
|
|
Location = new Point(lm + 333, 2 * line + tm),
|
|
Width = 40,
|
|
});
|
|
btnBrowseOutputDir.Click += btnBrowseOutputDir_Click;
|
|
|
|
this.Controls.Add(new Label()
|
|
{
|
|
Text = "Filename pattern:",
|
|
Location = new Point(lm, 3 * line + tm + labelOffs),
|
|
Size = new Size(110, labelHeight),
|
|
TextAlign = ContentAlignment.BottomRight,
|
|
});
|
|
this.Controls.Add(tbFileNamePattern = new TextBox()
|
|
{
|
|
Location = new Point(lm + 113, 3 * line + tm),
|
|
Width = 240,
|
|
});
|
|
|
|
|
|
AddOkCancel(this, btnOK_Click, btnCancel_Click);
|
|
|
|
//We must run the filling of the data fields in the load event, as they
|
|
//might have been changed after the constructor is executed
|
|
this.Shown += (sender, e) =>
|
|
{
|
|
tbTemplate.Text = DataTemplate;
|
|
cbDataFormat.SelectedItem = DataFormat;
|
|
tbOutputDirectory.Text = OutputDirectory;
|
|
};
|
|
}
|
|
|
|
private void btnBrowseTemplate_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
DialogResult dr = ofd.ShowDialog();
|
|
if(dr == DialogResult.OK)
|
|
{
|
|
tbTemplate.Text = ofd.FileName;
|
|
}
|
|
}
|
|
|
|
private void btnBrowseOutputDir_Click(object sender, EventArgs e)
|
|
{
|
|
FolderBrowserDialog fbd = new FolderBrowserDialog();
|
|
DialogResult dr = fbd.ShowDialog();
|
|
if (dr == DialogResult.OK)
|
|
{
|
|
tbOutputDirectory.Text = fbd.SelectedPath;
|
|
}
|
|
}
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
DataTemplate = tbTemplate.Text;
|
|
DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
} |