190614PX Added generic configuration ui, MoneyTransfer Read-Only assignment, some code cleanup
This commit is contained in:
parent
459e066aae
commit
68105fb561
46
Program.cs
46
Program.cs
|
@ -26,7 +26,7 @@ namespace dezentrale
|
|||
{
|
||||
public class Program
|
||||
{
|
||||
public static uint VersionNumber { get; private set; } = 0x19061300;
|
||||
public static uint VersionNumber { get; private set; } = 0x19061400;
|
||||
public static string VersionString { get; private set; } = $"{VersionNumber:x}";
|
||||
|
||||
public static string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
|
@ -160,7 +160,7 @@ namespace dezentrale
|
|||
Console.WriteLine("Error while loading member files:");
|
||||
Console.WriteLine(ex.Message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (ProgramMode)
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ namespace dezentrale
|
|||
|
||||
BankTransfer bt = new BankTransfer(headlineFields, l);
|
||||
//TBD: search for duplicates
|
||||
MoneyTransfers.Entries.Add(bt);
|
||||
MoneyTransfers.AddEntry(bt);
|
||||
tmpList.Add(bt);
|
||||
}
|
||||
|
||||
|
@ -242,6 +242,7 @@ namespace dezentrale
|
|||
changedMembers.Add(m);
|
||||
m.StartLogEvent("Incoming bank transfer", LogEvent.eEventType.MembershipPayment, "automatic");
|
||||
m.ApplyMoneyTransfer(bt);
|
||||
bt.AssignFixed = true;
|
||||
break; //this is important. We don't want to assign this to multiple members.
|
||||
}
|
||||
}
|
||||
|
@ -251,6 +252,8 @@ namespace dezentrale
|
|||
if (!MoneyTransfers.SaveToFile())
|
||||
return false;
|
||||
bool ret = true;
|
||||
/*
|
||||
//automaticly saved in ApplyMoneyTransfer()
|
||||
foreach (Member m in changedMembers)
|
||||
{
|
||||
if (m.CurrentLog != null)
|
||||
|
@ -266,7 +269,7 @@ namespace dezentrale
|
|||
ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
//TBD: mail to schatzmeister if there are unassigned transfers
|
||||
|
||||
return ret;
|
||||
|
@ -277,6 +280,41 @@ namespace dezentrale
|
|||
Console.WriteLine(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static string PadLeft(string input, uint totalLength)
|
||||
{
|
||||
if (input.Length < totalLength)
|
||||
return new string(' ', (int)(totalLength - input.Length)) + input;
|
||||
else
|
||||
return input;
|
||||
}
|
||||
//TBD: This is an utility function and should reside in an extra class
|
||||
public static string Int64FPToString(Int64 value)
|
||||
{
|
||||
//float fValue = ((float) value) / 100;
|
||||
//return $"{fValue:0.00}";
|
||||
Int64 intPart = value / 100;
|
||||
Int64 decPart = (intPart < 0 ? -1 : 1) * (value % 100);
|
||||
return $"{intPart},{decPart:D2}";
|
||||
}
|
||||
//TBD: This is an utility function and should reside in an extra class
|
||||
public static Int64 StringToInt64FP(string value)
|
||||
{
|
||||
if (value == null) return 0;
|
||||
if (!value.Contains(".") && !value.Contains(","))
|
||||
{
|
||||
return Convert.ToInt64(value) * 100;
|
||||
}
|
||||
|
||||
int i = value.IndexOf('.');
|
||||
if (i < 0) i = value.IndexOf(',');
|
||||
string intPart = value.Substring(0, i);
|
||||
string decPart = value.Substring(i + 1);
|
||||
|
||||
Int64 ip64 = Convert.ToInt64(intPart);
|
||||
return (ip64 * 100) + (ip64 > 0 ? Convert.ToInt64(decPart) : -Convert.ToInt64(decPart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ namespace dezentrale.model
|
|||
[XmlElement] public string LocalUser { get; set; } = "John Doe";
|
||||
[XmlElement] public string KeylockCombination { get; set; } = "0000";
|
||||
|
||||
[XmlElement] public List<KeyValue> MoneyTransferRegEx { get; set; } = new List<KeyValue>();
|
||||
|
||||
//UI: lstMembers: Columns
|
||||
|
||||
[XmlElement] public DateTime LastCronjobRun { get; set; } = DateTime.Now;
|
||||
[XmlElement] public List<KeyValue> MoneyTransferRegEx { get; set; } = new List<KeyValue>(); //This doesn't belong here! Move to new file within db-data!
|
||||
[XmlElement] public DateTime LastCronjobRun { get; set; } = DateTime.Now; //This doesn't belong here! Move to new file within db-data!
|
||||
|
||||
[XmlIgnore] public static string DefaultDbDirectory{ get; private set; } = "db-data";
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@ namespace dezentrale.model
|
|||
{
|
||||
if (memberList && m.AccountBalance != 0)
|
||||
{
|
||||
string formattedBalance = m.AccountBalanceString;
|
||||
while (formattedBalance.Length < 8) formattedBalance = " " + formattedBalance;
|
||||
string formattedBalance = Program.PadLeft(Program.Int64FPToString(m.AccountBalance), 8);
|
||||
//while (formattedBalance.Length < 8) formattedBalance = " " + formattedBalance;
|
||||
|
||||
string formattedStatus = $"{m.Status}";
|
||||
while (formattedStatus.Length < 8) formattedStatus = formattedStatus + " ";
|
||||
string formattedStatus = Program.PadLeft($"{m.Status}", 8);
|
||||
//while (formattedStatus.Length < 8) formattedStatus = formattedStatus + " ";
|
||||
mList += $"{m.Number:D3} | {formattedBalance} | {formattedStatus} | {m.Nickname}\n";
|
||||
}
|
||||
totalBalance += m.AccountBalance;
|
||||
|
@ -66,7 +66,7 @@ namespace dezentrale.model
|
|||
}
|
||||
}
|
||||
Body =
|
||||
$"Out of {Program.members.Entries.Count}, there are {activeMembers} active ones.\n"
|
||||
$"Out of {Program.members.Entries.Count}, there are {activeMembers} active members.\n"
|
||||
+ $"Out of these, {regularMembers} are regular and {foerderMembers} are \"Foerdermitglied\"\n"
|
||||
+ $"{unGreetedMembers} members are \"uninitialized or greeted\", waiting for spawn/activation.\n"
|
||||
+ $"{disabledMembers} accounts are disabled at this point.\n"
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace dezentrale.model.money
|
|||
{
|
||||
[XmlInclude(typeof(BankTransfer))]
|
||||
[XmlInclude(typeof(CashTransfer))]
|
||||
public class MoneyTransfer
|
||||
public class MoneyTransfer : IEquatable<MoneyTransfer>, IComparable<MoneyTransfer>
|
||||
{
|
||||
public enum eTransferType
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ namespace dezentrale.model.money
|
|||
}
|
||||
|
||||
//This is the connection to the rest of the database
|
||||
[XmlAttribute] public bool AssignFixed { get; set; } = false;
|
||||
[XmlElement] public string Id { get; set; } = null;
|
||||
[XmlElement] public uint MemberNumber { get; set; } = 0;
|
||||
|
||||
|
@ -30,12 +31,25 @@ namespace dezentrale.model.money
|
|||
[XmlElement] public string Currency { get; set; } = "EUR";
|
||||
[XmlElement] public string TransferReason { get; set; } = "";
|
||||
|
||||
[XmlIgnore] public string AmountString { get { return $"{((float) Amount / 100)}"; } }
|
||||
[XmlIgnore] public string AmountString { get { return Program.Int64FPToString(Amount);/* $"{((float) Amount / 100)}";*/ } }
|
||||
|
||||
public override string ToString() { return Id; }
|
||||
public MoneyTransfer()
|
||||
{
|
||||
Id = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public bool Equals(MoneyTransfer other)
|
||||
{
|
||||
return (Amount == other.Amount)
|
||||
&& Currency.Equals(other.Currency)
|
||||
&& ValutaDate.Equals(other.ValutaDate);
|
||||
}
|
||||
|
||||
public int CompareTo(MoneyTransfer other)
|
||||
{
|
||||
if (other == null) return 1;
|
||||
else return ValutaDate.CompareTo(other.ValutaDate);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,5 +30,11 @@ namespace dezentrale.model.money
|
|||
{
|
||||
return SaveToFile(this);
|
||||
}
|
||||
|
||||
public void AddEntry(MoneyTransfer mt)
|
||||
{
|
||||
Entries.Add(mt);
|
||||
Entries.Sort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -11,14 +12,211 @@ namespace dezentrale.view
|
|||
{
|
||||
public class frmConfiguration : Form
|
||||
{
|
||||
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
|
||||
|
||||
public frmConfiguration(Configuration config)
|
||||
//Generic settings
|
||||
private TextBox tbDbDirectory;
|
||||
private TextBox tbRegularPayment;
|
||||
private ComboBox cbRegularCurrency;
|
||||
private TextBox tbLocalUser;
|
||||
private TextBox tbKeylockCombination;
|
||||
|
||||
|
||||
|
||||
|
||||
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");
|
||||
gui.Controls.Add(new Label()
|
||||
{
|
||||
Text = "DbDirectory:",
|
||||
Location = new Point(lm, 0 * line + tm + 5),
|
||||
Size = new Size(110, 12),
|
||||
TextAlign = ContentAlignment.BottomRight,
|
||||
});
|
||||
gui.Controls.Add(tbDbDirectory = new TextBox()
|
||||
{
|
||||
Location = new Point(lm + 113, 0 * line + tm),
|
||||
Width = 600,
|
||||
});
|
||||
//[XmlElement] public uint RegularPaymentAmount { get; set; } = 3200; //cents
|
||||
//[XmlElement] public string RegularPaymentCurrency { get; set; } = "EUR";
|
||||
gui.Controls.Add(new Label()
|
||||
{
|
||||
Text = "RegularPayment:",
|
||||
Location = new Point(lm, 1 * line + tm + 5),
|
||||
Size = new Size(110, 12),
|
||||
TextAlign = ContentAlignment.BottomRight,
|
||||
});
|
||||
gui.Controls.Add(tbRegularPayment = new TextBox()
|
||||
{
|
||||
Text = "0,00",
|
||||
Location = new Point(lm + 113, 1 * line + tm),
|
||||
Width = 100,
|
||||
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
||||
TextAlign = HorizontalAlignment.Right,
|
||||
});
|
||||
gui.Controls.Add(cbRegularCurrency = new ComboBox()
|
||||
{
|
||||
Location = new Point(lm + 223, 1 * line + tm),
|
||||
Width = 70,
|
||||
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
||||
ForeColor = Color.Black,
|
||||
});
|
||||
cbRegularCurrency.Items.Add("EUR");
|
||||
cbRegularCurrency.SelectedIndex = 0;
|
||||
|
||||
gui.Controls.Add(new Label()
|
||||
{
|
||||
Text = "LocalUser:",
|
||||
Location = new Point(lm, 2 * line + tm + 5),
|
||||
Size = new Size(110, 12),
|
||||
TextAlign = ContentAlignment.BottomRight,
|
||||
});
|
||||
gui.Controls.Add(tbLocalUser = new TextBox()
|
||||
{
|
||||
Location = new Point(lm + 113, 2 * line + tm),
|
||||
Width = 100,
|
||||
});
|
||||
gui.Controls.Add(new Label()
|
||||
{
|
||||
Text = "KeylockCombination:",
|
||||
Location = new Point(lm, 3 * line + tm + 5),
|
||||
Size = new Size(110, 12),
|
||||
TextAlign = ContentAlignment.BottomRight,
|
||||
});
|
||||
gui.Controls.Add(tbKeylockCombination = new TextBox()
|
||||
{
|
||||
Location = new Point(lm + 113, 3 * line + tm),
|
||||
Width = 100,
|
||||
});
|
||||
|
||||
tbDbDirectory.Text = Program.config.DbDirectory;
|
||||
tbRegularPayment.Text = Program.Int64FPToString(Program.config.RegularPaymentAmount);
|
||||
if (Program.config.RegularPaymentCurrency != "EUR")
|
||||
{
|
||||
cbRegularCurrency.Items.Add(Program.config.RegularPaymentCurrency);
|
||||
cbRegularCurrency.SelectedIndex = 1;
|
||||
}
|
||||
tbLocalUser.Text = Program.config.LocalUser;
|
||||
tbKeylockCombination.Text = Program.config.KeylockCombination;
|
||||
return gui;
|
||||
}
|
||||
public TabPage BuildSmtpGui()
|
||||
{
|
||||
TabPage gui = new TabPage("Mail Settings");
|
||||
//SMTP settings
|
||||
/* [XmlElement] public bool Enabled { get; set; } = false;
|
||||
[XmlElement] public string Host { get; set; } = "localhost";
|
||||
[XmlElement] public int Port { get; set; } = 587;
|
||||
[XmlElement] public bool SSL { get; set; } = true;
|
||||
[XmlElement] public string From { get; set; } = "John Doe <john.doe@example.com>";
|
||||
[XmlElement] public string UserName { get; set; } = "username"; //you might need to use a complete e-mail address here.
|
||||
[XmlElement] public string Password { get; set; } = "password";
|
||||
[XmlElement] public string CcTo { get; set; } = "John Doe <john.doe@example.com>"; //this helps to keep track on outgoing mails. use null or "" to disable.
|
||||
*/
|
||||
//VS settings
|
||||
/* [XmlElement] public string VSName { get; set; } = "dezentrale Vorstand";
|
||||
[XmlElement] public string VSEmail { get; set; } = "vorstand@dezentrale.space";*/
|
||||
return gui;
|
||||
}
|
||||
public TabPage BuildMoneyTransfersGui()
|
||||
{
|
||||
TabPage gui = new TabPage("MoneyTransfers");
|
||||
//use MoneyTransferList for that, not Program.config
|
||||
//[XmlElement] public List<KeyValue> MoneyTransferRegEx { get; set; } = new List<KeyValue>();
|
||||
return gui;
|
||||
}
|
||||
public TabPage BuildImportExportGui()
|
||||
{
|
||||
TabPage gui = new TabPage("Import / Export");
|
||||
/* [XmlElement] public string ZipFile { get; set; } = "fnord.zip";
|
||||
[XmlElement] public string ZipPassword { get; set; } = "";
|
||||
[XmlElement] public bool GpgEnabled { get; set; } = true;
|
||||
[XmlElement] public string GpgFile { get; set; } = "fnord.gpg";
|
||||
[XmlElement] public string GpgPassword { get; set; } = "fnord";
|
||||
[XmlElement] public bool HgEnabled { get; set; } = false;
|
||||
[XmlElement] public string HgUserName { get; set; } = "";
|
||||
[XmlElement] public string HgPassword { get; set; } = "";
|
||||
[XmlElement] public string HgURL { get; set; } = "";
|
||||
[XmlElement] public bool GitEnabled { get; set; } = false;
|
||||
[XmlElement] public string GitUserName { get; set; } = "";
|
||||
[XmlElement] public string GitPassword { get; set; } = "";*/
|
||||
return gui;
|
||||
}
|
||||
public frmConfiguration()
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
public void FillConfig(Configuration config)
|
||||
this.StartPosition = FormStartPosition.CenterParent;
|
||||
this.Size = new System.Drawing.Size(800, 600);
|
||||
this.Text = "dezentrale-members :: Configuration";
|
||||
this.Controls.Add(new TabControl()
|
||||
{
|
||||
Size = new System.Drawing.Size(this.Width - 16, this.Height - 95),
|
||||
TabPages =
|
||||
{
|
||||
BuildGenericGui(),
|
||||
BuildSmtpGui(),
|
||||
BuildMoneyTransfersGui(),
|
||||
BuildImportExportGui(),
|
||||
}
|
||||
});
|
||||
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();
|
||||
}
|
||||
public void FillAndSaveConfig()
|
||||
{
|
||||
Program.config.DbDirectory = tbDbDirectory.Text;
|
||||
Program.config.RegularPaymentAmount = (uint) Program.StringToInt64FP(tbRegularPayment.Text);
|
||||
Program.config.RegularPaymentCurrency = cbRegularCurrency.Text;
|
||||
Program.config.LocalUser = tbLocalUser.Text;
|
||||
Program.config.KeylockCombination = tbKeylockCombination.Text;
|
||||
try
|
||||
{
|
||||
XmlData.SaveToFile(Program.ConfigFile, Program.config);
|
||||
Program.MoneyTransfers.SaveToFile();
|
||||
Console.WriteLine("Stored new configuration.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Error while storing configuration: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -485,31 +485,6 @@ namespace dezentrale.view
|
|||
parent.Controls.Add(btnOk);
|
||||
}
|
||||
|
||||
//TBD: This is an utility function and should reside in an extra class
|
||||
public static string Int64FPToString(Int64 value)
|
||||
{
|
||||
|
||||
Int64 intPart = value / 100;
|
||||
Int64 decPart = (intPart < 0 ? -1 : 1) * (value % 100);
|
||||
return $"{intPart},{decPart:D2}";
|
||||
}
|
||||
//TBD: This is an utility function and should reside in an extra class
|
||||
public static Int64 StringToInt64FP(string value)
|
||||
{
|
||||
if (value == null) return 0;
|
||||
if (!value.Contains(".") && !value.Contains(","))
|
||||
{
|
||||
return Convert.ToInt64(value);
|
||||
}
|
||||
|
||||
int i = value.IndexOf('.');
|
||||
if (i < 0) i = value.IndexOf(',');
|
||||
string intPart = value.Substring(0, i);
|
||||
string decPart = value.Substring(i + 1);
|
||||
|
||||
Int64 ip64 = Convert.ToInt64(intPart);
|
||||
return (ip64 * 100) + (ip64 > 0 ? Convert.ToInt64(decPart) : -Convert.ToInt64(decPart));
|
||||
}
|
||||
public frmEditEntry(Member m, bool newMember = false)
|
||||
{
|
||||
|
||||
|
@ -560,7 +535,7 @@ namespace dezentrale.view
|
|||
}
|
||||
try { dateSpawn.Value = member.SpawnDate; }
|
||||
catch (Exception) { if (!newMember) { MessageBox.Show("Invalid SpawnDate: " + member.SpawnDate + "!"); } }
|
||||
tbPaymentAmount.Text = Int64FPToString((Int64) member.PaymentAmount);
|
||||
tbPaymentAmount.Text = Program.Int64FPToString((Int64) member.PaymentAmount);
|
||||
chkPaymentReduced.Checked = member.PaymentClass == Member.ePaymentClass.Reduced;
|
||||
try { dateMemberForm.Value = member.MemberFormDate; }
|
||||
catch (Exception) { if (!newMember) { MessageBox.Show("Invalid MemberFormDate: " + member.MemberFormDate + "!"); } }
|
||||
|
@ -577,7 +552,7 @@ namespace dezentrale.view
|
|||
}
|
||||
|
||||
tbMvMiss.Text = $"{member.MvMissCounter}";
|
||||
tbAccountBalance.Text = Int64FPToString(member.AccountBalance);
|
||||
tbAccountBalance.Text = Program.Int64FPToString(member.AccountBalance);
|
||||
cbEvaluateAccountInCharge.Checked = member.EvaluateAccountInCharge;
|
||||
tbBankAccountInCharge.ReadOnly = !cbEvaluateAccountInCharge.Checked;
|
||||
tbBankAccountInCharge.Text = member.BankAccountInCharge;
|
||||
|
@ -622,7 +597,7 @@ namespace dezentrale.view
|
|||
member.SpawnDate = dateSpawn.Value;
|
||||
try
|
||||
{
|
||||
member.PaymentAmount = (UInt64) StringToInt64FP(tbPaymentAmount.Text);
|
||||
member.PaymentAmount = (UInt64) Program.StringToInt64FP(tbPaymentAmount.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -647,7 +622,7 @@ namespace dezentrale.view
|
|||
member.MvMissCounter = Convert.ToUInt32(tbMvMiss.Text);
|
||||
try
|
||||
{
|
||||
member.AccountBalance = StringToInt64FP(tbAccountBalance.Text);//Convert.ToInt32(tbAccountBalance.Text);
|
||||
member.AccountBalance = Program.StringToInt64FP(tbAccountBalance.Text);//Convert.ToInt32(tbAccountBalance.Text);
|
||||
} catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Cannot convert Account balance to fixed point value:\n{ex.Message}");
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace dezentrale.view
|
|||
{
|
||||
new MenuItem("File")
|
||||
{ MenuItems = {
|
||||
new MenuItem("&Configuration...", mnuMain_File_Configuration) { Enabled = false },
|
||||
new MenuItem("&Configuration...", mnuMain_File_Configuration) { Enabled = true },
|
||||
new MenuItem("-"),
|
||||
new MenuItem("&Export database", mnuMain_File_Export),
|
||||
new MenuItem("&Import database", mnuMain_File_Import),
|
||||
|
@ -63,13 +63,17 @@ namespace dezentrale.view
|
|||
new MenuItem("Members")
|
||||
{ MenuItems = {
|
||||
new MenuItem("&Add new member", mnuMain_Members_Add),
|
||||
new MenuItem("Cronjob all", lstMembers_CronjobAll),
|
||||
new MenuItem("-"),
|
||||
#if DEBUG
|
||||
new MenuItem("Generate Testdata", mnuMain_Members_Generate_Testdata),
|
||||
#endif
|
||||
new MenuItem("-"),
|
||||
#endif
|
||||
new MenuItem("Show numeric info", lstMembers_mnuMain_Members_ShowInfo),
|
||||
} },
|
||||
new MenuItem("Payments")
|
||||
{ MenuItems = {
|
||||
new MenuItem("&Add new MoneyTransfer", mnuMain_Payments_Add) { Enabled = false },
|
||||
new MenuItem("&Add new MoneyTransfer", mnuMain_Payments_Add) { Enabled = true },
|
||||
new MenuItem("Process CSV...", mnuMain_Payments_ProcessCSV),
|
||||
} },
|
||||
new MenuItem("Help")
|
||||
|
@ -83,19 +87,17 @@ namespace dezentrale.view
|
|||
|
||||
tabMembers.Controls.Add(lstMembers = new LVMembers() { Dock = DockStyle.Fill });
|
||||
//lstMembers.AddMenuItem("Add new member", lstMembers_Add);
|
||||
lstMembers.AddMenuItem("Edit selected one", lstMembers_Edit);
|
||||
lstMembers.AddMenuItem("Delete selected one", lstMembers_Delete);
|
||||
lstMembers.AddMenuItem("Edit selected member", lstMembers_Edit);
|
||||
lstMembers.AddMenuItem("Delete selected member", lstMembers_Delete);
|
||||
lstMembers.AddMenuItem("Add cash payment to member", lstMembers_AddCashTransfer);
|
||||
lstMembers.AddMenuItem("-", null);
|
||||
lstMembers.AddMenuItem("Add cash payment", lstMembers_AddCashTransfer);
|
||||
lstMembers.AddMenuItem("-", null);
|
||||
lstMembers.AddMenuItem("Cronjob selected one", lstMembers_CronjobSelected);
|
||||
lstMembers.AddMenuItem("Cronjob checked ones", lstMembers_CronjobChecked);
|
||||
lstMembers.AddMenuItem("Cronjob selected member", lstMembers_CronjobSelected);
|
||||
//lstMembers.AddMenuItem("Cronjob checked ones", lstMembers_CronjobChecked);
|
||||
lstMembers.AddMenuItem("Cronjob all", lstMembers_CronjobAll);
|
||||
lstMembers.AddMenuItem("-", null);
|
||||
//lstMembers.AddMenuItem("-", null);
|
||||
//TBD: "Selected users missed an MV"
|
||||
|
||||
lstMembers.AddMenuItem("Show numeric info", lstMembers_ShowNumericInfo);
|
||||
lstMembers.AddMenuItem("Main Settings", null);
|
||||
//lstMembers.AddMenuItem("Main Settings", null);
|
||||
lstMembers.DoubleClick += lstMembers_Edit;
|
||||
|
||||
TabPage tabMoneyTransfers = new TabPage("MoneyTransfers");
|
||||
|
@ -114,18 +116,11 @@ namespace dezentrale.view
|
|||
|
||||
private void mnuMain_File_Configuration(object sender, EventArgs e)
|
||||
{
|
||||
frmConfiguration frmConfig = new frmConfiguration(Program.config);
|
||||
frmConfiguration frmConfig = new frmConfiguration();
|
||||
frmConfig.ShowDialog();
|
||||
if (frmConfig.DialogResult == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
frmConfig.FillConfig(Program.config);
|
||||
XmlData.SaveToFile(Program.ConfigFile, Program.config); Console.WriteLine("Stored new configuration.");
|
||||
} catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Error while storing configuration: {ex.Message}");
|
||||
}
|
||||
frmConfig.FillAndSaveConfig();
|
||||
}
|
||||
}
|
||||
private void mnuMain_File_Export(object sender, EventArgs e)
|
||||
|
@ -187,16 +182,38 @@ namespace dezentrale.view
|
|||
lstMembers.LoadFromList(Program.members.Entries);
|
||||
}
|
||||
#endif
|
||||
private void mnuMain_Payments_Add(object sender, EventArgs e)
|
||||
|
||||
private void lstMembers_mnuMain_Members_ShowInfo(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
frmMoneyTransfer addMoney = new frmMoneyTransfer();
|
||||
addMoney.ShowDialog();
|
||||
DialogResult dr = addMoney.DialogResult;
|
||||
if (dr == DialogResult.OK)
|
||||
MessageBox.Show(new MemberReport().Body);
|
||||
}
|
||||
|
||||
private void mnuMain_Payments_Add(object sender, EventArgs e)
|
||||
{
|
||||
frmMoneyTransfer addMoney = new frmMoneyTransfer();
|
||||
addMoney.ShowDialog();
|
||||
DialogResult dr = addMoney.DialogResult;
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
MoneyTransfer mt = addMoney.GetMoneyTransfer();
|
||||
|
||||
if (mt.MemberNumber != 0)
|
||||
{
|
||||
Member m = Program.members.Find(mt.MemberNumber);
|
||||
m.ApplyMoneyTransfer(mt);
|
||||
mt.AssignFixed = true;
|
||||
|
||||
//m.SaveToFile(); //automaticly saved in ApplyMoneyTransfer()
|
||||
}
|
||||
Program.MoneyTransfers.AddEntry(mt);
|
||||
Program.MoneyTransfers.SaveToFile();
|
||||
} catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Error while storing MoneyTransfer: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void mnuMain_Payments_ProcessCSV(object sender, EventArgs e)
|
||||
|
@ -245,11 +262,6 @@ namespace dezentrale.view
|
|||
lstMembers.ResumeLayout(false);
|
||||
}
|
||||
|
||||
private void lstMembers_ShowNumericInfo(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show(new MemberReport().Body);
|
||||
}
|
||||
|
||||
private void lstMembers_Edit(object sender, EventArgs e)
|
||||
{
|
||||
Member m = lstMembers.GetFirstSelectedMember();
|
||||
|
@ -298,8 +310,9 @@ namespace dezentrale.view
|
|||
{
|
||||
MoneyTransfer mt = addMoney.GetMoneyTransfer();
|
||||
m.ApplyMoneyTransfer(mt);
|
||||
m.SaveToFile();
|
||||
Program.MoneyTransfers.Entries.Add(mt);
|
||||
//m.SaveToFile(); //automaticly saved in ApplyMoneyTransfer()
|
||||
mt.AssignFixed = true;
|
||||
Program.MoneyTransfers.AddEntry(mt);
|
||||
Program.MoneyTransfers.SaveToFile();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,28 +51,28 @@ namespace dezentrale.view
|
|||
private const int bm = margin; //Bottom margin
|
||||
private const int line = 20 + margin; //lineheight
|
||||
|
||||
private void AddOkCancel(TabPage page, bool writeEnabled, EventHandler okEvent, EventHandler cancelEvent)
|
||||
private void AddOkCancel(Control parent, EventHandler okEvent, EventHandler cancelEvent, bool writeEnabled)
|
||||
{
|
||||
//Console.WriteLine($"frmMoneyTransfer.AddOkCancel(writeEnabled={writeEnabled})");
|
||||
Button ok = new Button()
|
||||
{
|
||||
Text = "OK",
|
||||
Location = new Point(page.Width - 170 - rm, page.Height - 87),
|
||||
Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
|
||||
Enabled = 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 Point(page.Width - 85 - rm, page.Height - 87),
|
||||
Anchor = AnchorStyles.Right | AnchorStyles.Bottom,
|
||||
};
|
||||
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;
|
||||
|
||||
page.Controls.Add(ok);
|
||||
page.Controls.Add(cancel);
|
||||
parent.Controls.Add(ok);
|
||||
parent.Controls.Add(cancel);
|
||||
}
|
||||
private TabPage BuildBankTransferGui()
|
||||
{
|
||||
|
@ -251,7 +251,7 @@ namespace dezentrale.view
|
|||
Location = new Point(lm + 421, 5 * line + tm),
|
||||
Width = 100,
|
||||
});
|
||||
AddOkCancel(bank, writeEnabled, btnBankOK_Click, btnCancel_Click);
|
||||
AddOkCancel(bank, btnBankOK_Click, btnCancel_Click, writeEnabled);
|
||||
|
||||
if (mt != null && mt.GetType() == typeof(BankTransfer))
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ namespace dezentrale.view
|
|||
Location = new Point(lm + 113, 0 * line + tm),
|
||||
Width = 100,
|
||||
});
|
||||
AddOkCancel(cash, writeEnabled, btnCashOK_Click, btnCancel_Click);
|
||||
AddOkCancel(cash, btnCashOK_Click, btnCancel_Click, writeEnabled);
|
||||
|
||||
if (mt != null && mt.GetType() == typeof(CashTransfer))
|
||||
{
|
||||
|
@ -323,6 +323,7 @@ namespace dezentrale.view
|
|||
Width = 180,
|
||||
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
||||
Enabled = mt == null ? true : !mt.AssignFixed,
|
||||
});
|
||||
cbAssigned.AddKV("- Unassigned -", 0);
|
||||
cbAssigned.SelectedIndex = 0;
|
||||
|
@ -349,6 +350,7 @@ namespace dezentrale.view
|
|||
Width = 180,
|
||||
Anchor = AnchorStyles.Top | AnchorStyles.Left,
|
||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
||||
Enabled = mt == null ? true : !mt.AssignFixed,
|
||||
});
|
||||
|
||||
this.Controls.Add(new Label()
|
||||
|
@ -473,10 +475,13 @@ namespace dezentrale.view
|
|||
//but, friendly as we are, we handle this anyway
|
||||
if (mt == null) throw new NullReferenceException("No MoneyTransfer was created. User didn't click OK");
|
||||
|
||||
mt.MemberNumber = (uint)((KeyValue)cbAssigned.SelectedItem).Value;
|
||||
mt.TransferType = (MoneyTransfer.eTransferType)((KeyValue)cbType.SelectedItem).Value;
|
||||
if (!mt.AssignFixed)
|
||||
{
|
||||
mt.MemberNumber = (uint)((KeyValue)cbAssigned.SelectedItem).Value;
|
||||
mt.TransferType = (MoneyTransfer.eTransferType)((KeyValue)cbType.SelectedItem).Value;
|
||||
}
|
||||
mt.ValutaDate = valutaDate.Value;
|
||||
mt.Amount = frmEditEntry.StringToInt64FP(tbAmount.Text);
|
||||
mt.Amount = Program.StringToInt64FP(tbAmount.Text);
|
||||
mt.Currency = cbCurrency.Text;
|
||||
mt.TransferReason = tbTransferReason.Text;
|
||||
|
||||
|
|
Loading…
Reference in New Issue