190520PX read/write member data to GUI, changed storage to "one file per member", added logging, fiddling around with gui bugs

This commit is contained in:
phantomix 2019-05-20 18:19:30 +02:00
parent bfe24d3704
commit 2e857444a2
16 changed files with 687 additions and 418 deletions

View File

@ -10,14 +10,13 @@ namespace dezentrale
{
public class Program
{
public static uint VersionNumber { get; private set; } = 0x19051700;
public static uint VersionNumber { get; private set; } = 0x19052000;
public static string VersionString { get; private set; } = $"{VersionNumber:x}";
public static string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
public static string DmDirectory = Path.Combine(AppData, "dezentrale-members");
public static string ConfigFile = Path.Combine(DmDirectory, "configuration.xml");
public static string MemberFile = Path.Combine(DmDirectory, "members.xml");
public static Configuration config = new Configuration();
public static MemberList members = new MemberList();
@ -93,31 +92,35 @@ namespace dezentrale
try
{
try { config = (Configuration)XmlData.LoadFromFile(ConfigFile); }
catch (FileNotFoundException) { XmlData.SaveToFile(ConfigFile, config); Console.WriteLine("Created new configuration file."); }
try
{
members = MemberList.LoadFromFile(MemberFile);
}
catch (FileNotFoundException)
{
MemberList.SaveToFile(MemberFile, members);
Console.WriteLine("Created new member file.");
}
members.Entries.Sort();
members.Deleted.Sort();
} catch (Exception ex)
config = (Configuration)XmlData.LoadFromFile(ConfigFile);
}
catch (FileNotFoundException)
{
config.MemberDirectory = Path.Combine(DmDirectory, "member-data");
XmlData.SaveToFile(ConfigFile, config); Console.WriteLine("Created new configuration file.");
}
catch (Exception ex)
{
Console.WriteLine("Error while accessing program data:");
Console.WriteLine(ex.Message);
return 1;
}
//Member m = members.CreateMember();
//MemberList.SaveToFile(MemberFile, members);
try { Directory.CreateDirectory(config.MemberDirectory); }
catch (Exception ex) { Console.WriteLine($"Error while creating member data directory:\n{ex.Message}"); return 1; }
try
{
string[] memberFiles = Directory.GetFiles(config.MemberDirectory, "member-*.xml");
members = MemberList.LoadFromFiles(memberFiles);
Console.WriteLine($"Loaded {members.Entries.Count} member entries");
}
catch (Exception ex)
{
Console.WriteLine("Error while loading member files:");
Console.WriteLine(ex.Message);
return 1;
}
switch (ProgramMode)
{

View File

@ -60,8 +60,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="model\Address.cs" />
<Compile Include="model\Country.cs" />
<Compile Include="model\LogSubEvent.cs" />
<Compile Include="view\ComboBoxKV.cs">
<SubType>Component</SubType>
</Compile>
@ -76,7 +76,7 @@
<Compile Include="model\ConfigVSMail.cs" />
<Compile Include="model\FormMail.cs" />
<Compile Include="model\Member.cs" />
<Compile Include="model\LogEntry.cs" />
<Compile Include="model\LogEvent.cs" />
<Compile Include="model\MemberList.cs" />
<Compile Include="model\MemberPayment.cs" />
<Compile Include="model\XmlData.cs" />

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace dezentrale.model
{
public class Address : XmlData
{
[XmlElement] public string Street { get; set; } = "";
[XmlElement] public string HouseNumber { get; set; } = "";
[XmlElement] public string Zipcode { get; set; } = "";
[XmlElement] public string City { get; set; } = "";
[XmlElement] public string State { get; set; } = "";
[XmlElement("Country")] public Country.eCountry CountryCode { get; set; } = Country.eCountry.Germany;
}
}

View File

@ -8,6 +8,7 @@ namespace dezentrale.model
{
public class ConfigSmtp : XmlData
{
[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;

View File

@ -8,8 +8,11 @@ namespace dezentrale.model
{
public class Configuration : XmlData
{
[XmlElement] public ConfigSmtp Smtp { get; set; } = new ConfigSmtp();
[XmlElement] public ConfigVSMail VS { get; set; } = new ConfigVSMail();
[XmlElement] public ConfigSmtp Smtp { get; set; } = new ConfigSmtp();
[XmlElement] public ConfigVSMail VS { get; set; } = new ConfigVSMail();
[XmlElement] public string MemberDirectory { get; set; } = "member-data";
[XmlElement] public uint RegularPaymentAmount { get; set; } = 32;
[XmlElement] public string LocalUser { get; set; } = "";
}
}

View File

@ -106,7 +106,7 @@ namespace dezentrale.model
Ghana = 288,
Gibraltar = 292,
Greece = 300,
Greenland = 292,
Greenland = 304,
Grenada = 308,
Guadeloupe = 312,
Guam = 316,

View File

@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace dezentrale.model
{
public class LogEntry : XmlData
{
}
}

26
model/LogEvent.cs Normal file
View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace dezentrale.model
{
public class LogEvent : LogSubEvent
{
public enum eEventType
{
Generic = 0,
AddUser,
EditUser,
DelUser,
DataChange,
ActionFinished,
}
[XmlElement] public DateTime Timestamp { get; set; } = DateTime.Now;
[XmlElement] public string LocalUser { get; set; } = Program.config.LocalUser;
[XmlElement("SubEvent")] public List<LogSubEvent> SubEvents { get; set; } = new List<LogSubEvent>();
}
}

15
model/LogSubEvent.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace dezentrale.model
{
public class LogSubEvent
{
[XmlElement] public string Topic { get; set; } = "";
[XmlElement] public LogEvent.eEventType Type { get; set; } = LogEvent.eEventType.Generic;
}
}

View File

@ -30,6 +30,7 @@ namespace dezentrale.model
Active,
Bannend,
Disabled,
Deleted,
}
public enum ePaymentClass
@ -37,49 +38,128 @@ namespace dezentrale.model
Reduced = 0,
Normal,
}
//tbd for edit form:
//Role, Status, OpenPayments
private uint number = 0;
private eRole role = eRole.Normal;
private eType type = eType.Regulaer;
private eStatus status = eStatus.Uninitialized;
private string remarks = "";
private uint mvMiss = 0;
private string nickname = "";
private string firstName = "";
private string lastName = "";
private string street = "";
private string houseNo = "";
private string zipcode = "";
private string city = "";
private Country.eCountry countryCode = Country.eCountry.Germany;
private DateTime birthday;
private string email = "";
private string pgpFingerprint = "";
private bool mvInvitationByPost = false;
private DateTime spawnDate;
private uint paymentAmount = Program.config.RegularPaymentAmount;
private ePaymentClass paymentClass = ePaymentClass.Normal;
private DateTime memberFormDate;
//This is a bit ugly but I didn't have a good idea how to solve it better.
//The main goal is to track every change to every property.
//Therefore, private variables are defined and the get/set methods are handled manually.
//A property change is then tracked using LogPropertyChange()
[XmlElement] public uint Number { get { return number; } set { LogPropertyChange("Number", number, value); number = value; } }
[XmlElement] public eRole Role { get { return role; } set { LogPropertyChange("Role", role, value); role = value; } }
[XmlElement] public eType Type { get { return type; } set { LogPropertyChange("Type", type, value); type = value; } }
[XmlElement] public eStatus Status { get { return status; } set { LogPropertyChange("Status", status, value); status = value; } }
[XmlElement] public string Remarks { get { return remarks; } set { LogPropertyChange("Remarks", remarks, value); remarks = value; } }
[XmlElement] public uint MvMissCounter { get { return mvMiss; } set { LogPropertyChange("MvMissCounter", mvMiss, value); mvMiss = value; } }
//metadata
[XmlElement] public uint Number { get; set; } = 0;
[XmlElement] public eRole Role { get; set; } = eRole.Normal;
[XmlElement] public eType Type { get; set; } = eType.Regulaer;
[XmlElement] public eStatus Status { get; set; } = eStatus.Uninitialized;
[XmlElement] public List<string> OpenPayments { get; set; } = new List<string>(); //todo: data type
[XmlElement] public List<LogEntry> Log { get; set; } = new List<LogEntry>();
[XmlElement] public string Remarks { get; set; } = "";
[XmlElement] public uint MvMissCounter { get; set; }
//personal data
[XmlElement] public string Nickname { get; set; } = "";
[XmlElement] public string FirstName { get; set; } = "";
[XmlElement] public string LastName { get; set; } = "";
[XmlElement] public Address Address { get; set; } = new Address() { CountryCode = Country.eCountry.Germany };
[XmlElement] public DateTime Birthday { get; set; }
[XmlElement] public string EMail { get; set; } = "";
[XmlElement] public string PgpFingerprint { get; set; } = "";
[XmlElement] public string Nickname { get { return nickname; } set { LogPropertyChange("NickName", nickname, value); nickname = value; } }
[XmlElement] public string FirstName { get { return firstName; } set { LogPropertyChange("FirstName", firstName, value); firstName = value; } }
[XmlElement] public string LastName { get { return lastName; } set { LogPropertyChange("LastName", lastName, value); lastName = value; } }
[XmlElement] public string Street { get { return street; } set { LogPropertyChange("Street", street, value); street = value; } }
[XmlElement] public string HouseNumber { get { return houseNo; } set { LogPropertyChange("HouseNumber", houseNo, value); houseNo = value; } }
[XmlElement] public string Zipcode { get { return zipcode; } set { LogPropertyChange("Zipcode", zipcode, value); zipcode = value; } }
[XmlElement] public string City { get { return city; } set { LogPropertyChange("City", city, value); city = value; } }
[XmlIgnore] public Country.eCountry CountryCode
{ get {return countryCode;} set { LogPropertyChange("CountryCode", countryCode,value); countryCode = value; } }
[XmlElement("Country")] public uint CountryUInt32{ get { return (uint)CountryCode; } set { CountryCode = (Country.eCountry)value; }}
[XmlElement] public DateTime Birthday { get { return birthday; } set { LogPropertyChange("Birthday", birthday, value); birthday = value; } }
[XmlElement] public string EMail { get { return email; } set { LogPropertyChange("EMail", email, value); email = value; } }
[XmlElement] public string PgpFingerprint { get{return pgpFingerprint;}set{ LogPropertyChange("PgpFingerprint",pgpFingerprint,value); pgpFingerprint = value; } }
//membership organizational data
[XmlElement] public bool MvInvitationByPost { get; set; } = false;
[XmlElement] public DateTime SpawnDate { get; set; }
[XmlElement] public uint PaymentAmount { get; set; } = 32;
[XmlElement] public ePaymentClass PaymentClass { get; set; } = ePaymentClass.Normal;
[XmlElement] public DateTime MemberFormDate { get; set; }
[XmlElement] public bool MvInvitationByPost { get { return mvInvitationByPost; } set { LogPropertyChange("MvInvitationByPost", mvInvitationByPost, value); mvInvitationByPost = value; } }
[XmlElement] public DateTime SpawnDate { get { return spawnDate; } set { LogPropertyChange("SpawnDate", spawnDate, value); spawnDate = value; } }
[XmlElement] public uint PaymentAmount { get { return paymentAmount;} set { LogPropertyChange("PaymentAmount", paymentAmount, value); paymentAmount = value; } }
[XmlElement] public ePaymentClass PaymentClass { get { return paymentClass; } set { LogPropertyChange("PaymentClass", paymentClass, value); paymentClass = value; } }
[XmlElement] public DateTime MemberFormDate { get { return memberFormDate; } set { LogPropertyChange("MemberFormDate", memberFormDate, value); memberFormDate = value;} }
[XmlIgnore] public LogEvent CurrentLog { get; set; } = null;
[XmlElement("LogEvent")] public List<LogEvent> Log { get; set; } = new List<LogEvent>();
public Member() { }
public Member(uint number)
{
Number = number;
this.number = number;
}
public bool Equals(Member other)
{
return this.Number == other.Number;
return number == other.Number;
}
public int CompareTo(Member other)
{
if (other == null) return 1;
else return this.Number.CompareTo(other.Number);
else return number.CompareTo(other.Number);
}
public LogEvent StartLogEvent(string topic, LogEvent.eEventType type)
{
if(CurrentLog != null) throw new Exception("Member.StartLogEvent(): Cannot open a second log event, while first one is still open");
CurrentLog = new LogEvent()
{
Topic = topic,
Type = type,
};
Log.Add(CurrentLog);
return CurrentLog;
}
private void LogPropertyChange(string propertyName, object oldValue, object newValue)
{
if (CurrentLog != null)
{
string ov = oldValue.ToString();
string nv = newValue.ToString();
if(!ov.Equals(nv))
CurrentLog.SubEvents.Add(new LogSubEvent()
{
Topic = $"{propertyName} changes from \"{oldValue.ToString()}\" to \"{newValue.ToString()}\"",
Type = LogEvent.eEventType.DataChange,
});
}
}
public void CancelLogEvent()
{
if (CurrentLog == null) throw new Exception("Member.CancelLogEvent(): There is no log event open!");
Log.Remove(CurrentLog);
CurrentLog = null;
}
public void FinishLogEvent()
{
if(CurrentLog == null) throw new Exception("Member.FinishLogEvent(): There is no log event open!");
CurrentLog.SubEvents.Add(new LogSubEvent() { Type = LogEvent.eEventType.ActionFinished, Topic = "Member.FinishLogEvent()" });
CurrentLog = null;
}
public string GetFileName() { return $"member-{Number:D3}.xml"; }
}
}

View File

@ -4,19 +4,17 @@ using System.Xml.Serialization;
namespace dezentrale.model
{
public class MemberList : XmlData
public class MemberList
{
[XmlElement("Member")] public List<Member> Entries { get; set; } = new List<Member>();
[XmlElement("Deleted")] public List<Member> Deleted { get; set; } = new List<Member>();
public List<Member> Entries { get; set; } = new List<Member>();
public uint GetFreeNumber()
{
//Note: This assumes a sorted list in Entries.
if (Entries.Count < 1) return 1;
uint ret = Entries[Entries.Count - 1].Number + 1;
if (Deleted.Count < 1) return ret;
uint ret2 = Deleted[Deleted.Count - 1].Number + 1;
return ret > ret2 ? ret : ret2;
//uint ret =
return Entries[Entries.Count - 1].Number + 1;
//return ret > ret2 ? ret : ret2;
}
public Member CreateMember(bool addToList = false)
{
@ -33,27 +31,8 @@ namespace dezentrale.model
if (m == null) return false;
if (m.Role != Member.eRole.Normal)
return false; //throw new Exception("Role is Vorstand!");
bool ret = Entries.Remove(m);
Deleted.Add(m);
Deleted.Sort();
return ret;
}
public bool SaveToFile(string memberFile)
{
return SaveToFile(memberFile, this);
}
public static new MemberList LoadFromFile(string memberFile)
{
MemberList ml = (MemberList)XmlData.LoadFromFile(memberFile);
ml.Entries.Sort();
return ml;
}
public static bool SaveToFile(string memberFile, MemberList ml)
{
ml.Entries.Sort();
ml.Deleted.Sort();
return XmlData.SaveToFile(memberFile, ml);
m.Status = Member.eStatus.Deleted;
return true;
}
public void Cronjob(Member m)
@ -69,11 +48,33 @@ namespace dezentrale.model
if (partialList == null) partialList = Entries;
foreach(Member m in partialList) Cronjob(m);
}
public static MemberList LoadFromFiles(string[] memberFiles)
{
MemberList ml = new MemberList();
foreach (string file in memberFiles)
{
ml.Entries.Add((Member)XmlData.LoadFromFile(file));
}
ml.Entries.Sort();
return ml;
}
public static bool SaveToFiles(List<Member> entries = null, bool changedOnly = false)
{
if (entries == null) entries = Program.members.Entries;
foreach (Member m in entries)
{
string completePath = System.IO.Path.Combine(Program.config.MemberDirectory, m.GetFileName());
if (XmlData.SaveToFile(completePath, m) != true)
return false;
}
return true;
}
#if DEBUG
public void GenerateTestData()
{
Entries.Clear();
Deleted.Clear();
Member m;
//the brackets are unnecessary but keep everything tidy.
@ -89,7 +90,11 @@ namespace dezentrale.model
m.Nickname = "DoeJohnz";
m.FirstName = "John";
m.LastName = "Doe";
m.Address = new Address() { Street = "Homestreet", HouseNumber = "123", Zipcode = "12345", City = "Musterstadt", CountryCode = Country.eCountry.Germany };
m.Street = "Homestreet";
m.HouseNumber = "123";
m.Zipcode = "12345";
m.City = "Musterstadt";
m.CountryCode = Country.eCountry.Germany;
m.Birthday = new DateTime(1980, 1, 1);
m.EMail = "John Doe <john.doe@example.com>";
m.PgpFingerprint = "";
@ -109,7 +114,11 @@ namespace dezentrale.model
m.Nickname = "putin";
m.FirstName = "Vladimir";
m.LastName = "Putin";
m.Address = new Address() { Street = "Am Kreml", HouseNumber = "1a", Zipcode = "12345", City = "Moskau", CountryCode = Country.eCountry.RussianFederation };
m.Street = "Am Kreml";
m.HouseNumber = "1a";
m.Zipcode = "12345";
m.City = "Moskau";
m.CountryCode = Country.eCountry.RussianFederation;
m.Birthday = new DateTime(1960, 12, 24);
m.EMail = "putin <h4x0r@kgb.ru@example.com>";
m.PgpFingerprint = "encrypted ;-)";
@ -129,7 +138,11 @@ namespace dezentrale.model
m.Nickname = "AW23";
m.FirstName = "Adam";
m.LastName = "Weishaupt";
m.Address = new Address() { Street = "Parkallee", HouseNumber = "13", Zipcode = "99867", City = "Gotha", CountryCode = Country.eCountry.Germany };
m.Street = "Parkallee";
m.HouseNumber = "13";
m.Zipcode = "99867";
m.City = "Gotha";
m.CountryCode = Country.eCountry.Germany;
m.Birthday = new DateTime(1748, 2, 6);
m.EMail = "";
m.PgpFingerprint = "";
@ -149,7 +162,11 @@ namespace dezentrale.model
m.Nickname = "HeinzQuetschab";
m.FirstName = "Heinz";
m.LastName = "Ketchup";
m.Address = new Address() { Street = "", HouseNumber = "", Zipcode = "", City = "Pittsburgh", CountryCode = Country.eCountry.UnitedStatesOfAmerica, State = "Pennsylvania" };
m.Street = "";
m.HouseNumber = "";
m.Zipcode = "";
m.City = "Pittsburgh";
m.CountryCode = Country.eCountry.UnitedStatesOfAmerica;
m.Birthday = new DateTime(1876, 12, 31);
m.EMail = "heinz <quetschab@example.com>";
m.PgpFingerprint = "";
@ -168,7 +185,11 @@ namespace dezentrale.model
m.Nickname = "Joshua";
m.FirstName = "Keiner";
m.LastName = "Niemand";
m.Address = new Address() { Street = "str.", HouseNumber = "1", Zipcode = "1", City = "Musterstadt", CountryCode = Country.eCountry.Germany };
m.Street = "str.";
m.HouseNumber = "1";
m.Zipcode = "1";
m.City = "Musterstadt";
m.CountryCode = Country.eCountry.Germany;
m.Birthday = new DateTime(1980, 1, 1);
m.EMail = "joshua <joshua@wopr.gov@example.com>";
m.PgpFingerprint = "";

View File

@ -20,18 +20,8 @@ namespace dezentrale.model
typeof(string),
typeof(DateTime),
typeof(Configuration),
typeof(MemberList),
//typeof(ConfigSmtp),
//typeof(ConfigVSMail),
//typeof(FormMail),
//typeof(LogEntry),
//typeof(Member),
//typeof(Member.ePaymentClass),
//typeof(Member.eRole),
//typeof(Member.eStatus),
//typeof(Member.eType),
//typeof(MemberPayment),
typeof(Member),
//typeof(MemberList),
};
public static XmlData LoadFromFile(string fileName)
@ -59,7 +49,7 @@ namespace dezentrale.model
{
if (File.Exists(fileName))
{
string backupName = $"{fileName}_{DateTime.Now.ToString("yyyy-MM-dd_HHmmss")}.bak";
string backupName = $"{fileName}.bak";
if (File.Exists(backupName)) File.Delete(backupName);
File.Move(fileName, backupName);
}

View File

@ -8,12 +8,19 @@ namespace dezentrale.view
{
public class ComboBoxKV : ComboBox
{
public ComboKeyValue AddKV(string key, object value, object tag = null)
{
ComboKeyValue kv = new ComboKeyValue() { Key = key, Value = value, Tag = tag };
this.Items.Add(kv);
return kv;
}
}
public class ComboKeyValue
{
public string Key { get; set; }
public object Value { get; set; }
public object Tag { get; set; }
public override string ToString() { return Key.ToString(); }
}
}

View File

@ -10,6 +10,7 @@ namespace dezentrale.view
public class LVMembers : ListView
{
private ContextMenu cm = new ContextMenu();
private List<Member.eStatus> StatusFilter = null;
public LVMembers() : base()
{
@ -24,6 +25,15 @@ namespace dezentrale.view
this.Columns.Add(new ColumnHeader() { Text = "status", Width = 100 });
this.Columns.Add(new ColumnHeader() { Text = "mail", Width = 40 });
this.ContextMenu = cm;
StatusFilter = new List<Member.eStatus>()
{
Member.eStatus.Uninitialized,
Member.eStatus.Greeted,
Member.eStatus.Active,
Member.eStatus.Bannend,
Member.eStatus.Disabled,
//Member.eStatus.Deleted,
};
}
public MenuItem AddMenuItem(string text, EventHandler handler = null, MenuItem parent = null, bool enabled = true)
@ -61,7 +71,7 @@ namespace dezentrale.view
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{m.Nickname}" });
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{(m.Type == Member.eType.Foerdermitglied ? "F" : "R")}" });
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{m.Status}" });
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{(m.EMail.Length < 1 ? "" : "x")}{(m.PgpFingerprint.Length < 1 ? "" : "y")}" }); //U+1F4E7, U+1F511
lvi.SubItems.Add(new ListViewItem.ListViewSubItem() { Text = $"{(m.EMail.Length < 1 ? "" : "ja")}" }); //U+1F4E7, U+1F511
if (m.Status == Member.eStatus.Disabled)
lvi.ForeColor = System.Drawing.Color.DarkGray;
else
@ -91,9 +101,11 @@ namespace dezentrale.view
foreach (Member m in entries)
{
if(StatusFilter != null)
{
if (!StatusFilter.Contains(m.Status)) continue;
}
this.Items.Add(UpdateLvi(new ListViewItem(), m));
//this.Refresh();
//break;
}
this.ResumeLayout(false);
}

View File

@ -1,334 +1,473 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dezentrale.model;
namespace dezentrale.view
{
public class frmEditEntry : Form
{
private Member member;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dezentrale.model;
namespace dezentrale.view
{
public class frmEditEntry : Form
{
private Member member;
private bool newMember = false;
private TextBox tbFirstName;
private TextBox tbLastName;
private DateTimePicker dateBirthday;
private TextBox tbNickname;
private TextBox tbStreet;
private TextBox tbNumber;
private TextBox tbZipcode;
private TextBox tbCity;
protected ComboBoxKV cbCountry;
private TextBox tbEMail;
private TextBox tbPgpFingerprint;
private ComboBoxKV cbType;
private DateTimePicker dateSpawn;
private TextBox tbPaymentAmount;
private CheckBox chkPaymentReduced;
private TextBox tbRemarks;
private DateTimePicker dateMemberForm;
private const int margin = 5;
private const int lm = margin; //Left margin
private const int tm = margin; //Top margin
private const int rm = margin; //Right margin
private const int bm = margin; //Bottom margin
private const int line = 20 + margin; //lineheight
private void BuildMemberForm(Control parent)
{
int w = parent.ClientSize.Width - lm - rm;
int h = parent.ClientSize.Height - tm - bm;
//Form elements
//Vorname Straße Hausnr
//Name PLZ Ort
//Geburtstag Länderkürzel
//Pseudonym E-Mail-Adresse
// PGP Fingerprint
//Art der Mitgliedschaft
//Beitrittsdatum
//Beitragshöhe
//Datum des Mitgliedsantrages
private void BuildGui()
{
const int margin = 5;
const int lm = margin; //Left margin
const int tm = margin; //Top margin
const int rm = margin; //Right margin
const int bm = margin; //Bottom margin
const int line = 20 + margin; //lineheight
this.SuspendLayout();
this.StartPosition = FormStartPosition.CenterParent;
this.Size = new Size(640, 480);
this.MinimumSize = new Size(580, 360);
int w = this.ClientSize.Width - lm - rm;
int h = this.ClientSize.Height - tm - bm;
SplitContainer sc = new SplitContainer()
{
Location = new Point(lm, tm),
Size = new Size(w, 100),
Location = new Point(lm, tm),
Size = new Size(w, 100),
SplitterDistance = w / 2,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
Margin = new Padding(margin),
};
parent.Controls.Add(sc);
sc.Refresh();
Label lblFirstName = new Label()
{
Text = "First name:",
Location = new Point(0, 0 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbFirstName = new TextBox()
{
Location = new Point(118, 0 * line),
{
Text = "First name:",
Location = new Point(0, 0 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbFirstName = new TextBox()
{
Location = new Point(118, 0 * line),
Width = sc.Panel1.Width - 118,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
};
Label lblLastName = new Label()
{
{
Text = "Last name:",
Location = new Point(0, 1 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbLastName = new TextBox()
{
Location = new Point(0, 1 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbLastName = new TextBox()
{
Location = new Point(118, 1 * line),
Width = sc.Panel1.Width - 118,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblBirthday = new Label()
{
Label lblBirthday = new Label()
{
Text = "Birthday:",
Location = new Point(0, 2 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
DateTimePicker dateBirthday = new DateTimePicker()
Location = new Point(0, 2 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
dateBirthday = new DateTimePicker()
{
Location = new Point(118, 2 * line),
Width = 100,
Format = DateTimePickerFormat.Short
};
Label lblNickname = new Label()
{
Text = "Nickname:",
Location = new Point(0, 3 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbNickname = new TextBox()
Format = DateTimePickerFormat.Short,
MinDate = new DateTime(1900, 01, 01, 00, 00, 00),
MaxDate = DateTime.Today,
};
Label lblNickname = new Label()
{
Location = new Point(118, 3 * line),
Width = sc.Panel1.Width - 118,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblStreetNumber = new Label()
{
Text = "Street, Number:",
Location = new Point(0, 0 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbStreet = new TextBox()
{
Location = new Point(118, 0 * line),
Width = sc.Panel2.Width - 118 - 90,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
TextBox tbNumber = new TextBox()
{
Location = new Point(118 + tbStreet.Width + 5, 0 * line),
Width = 80,
Anchor = AnchorStyles.Top | AnchorStyles.Right,
};
Label lblZipcodeCity = new Label()
{
Text = "Zipcode,City:",
Location = new Point(0, 1 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbZipcode = new TextBox()
{
Location = new Point(118, 1 * line),
Width = 80,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
};
TextBox tbCity = new TextBox()
{
Location = new Point(118 + tbZipcode.Width + 5, 1 * line),
Width = sc.Panel2.Width - 118 - tbZipcode.Width - 10,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblCountry = new Label()
{
Text = "Country:",
Location = new Point(0, 2 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
ComboBox cbCountry = new ComboBox()
{
Location = new Point(118, 2 * line),
Width = sc.Panel2.Width - 118 - 5,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
DropDownStyle = ComboBoxStyle.DropDownList,
};
Label lblEMail = new Label()
{
Text = "EMail:",
Location = new Point(0, 3 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbEMail = new TextBox()
{
Location = new Point(118, 3 * line),
Width = sc.Panel2.Width - 118 - 5,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblPgpFingerprint = new Label()
{
Text = "PGP Fingerprint:",
Location = new Point(lm, 4 * line + tm + 5),
Size = new Size(110, 12),
Text = "Nickname:",
Location = new Point(0, 3 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbPgpFingerprint = new TextBox()
tbNickname = new TextBox()
{
Location = new Point(118, 3 * line),
Width = sc.Panel1.Width - 118,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblStreetNumber = new Label()
{
Text = "Street, Number:",
Location = new Point(0, 0 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbStreet = new TextBox()
{
Location = new Point(86, 0 * line),
Width = sc.Panel2.Width - 86 - 50,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
tbNumber = new TextBox()
{
Location = new Point(86 + tbStreet.Width + 5, 0 * line),
Width = 40,
Anchor = AnchorStyles.Top | AnchorStyles.Right,
};
Label lblZipcodeCity = new Label()
{
Text = "Zipcode,City:",
Location = new Point(0, 1 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbZipcode = new TextBox()
{
Location = new Point(86, 1 * line),
Width = 40,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
};
tbCity = new TextBox()
{
Location = new Point(86 + tbZipcode.Width + 5, 1 * line),
Width = sc.Panel2.Width - 86 - tbZipcode.Width - 10,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblCountry = new Label()
{
Text = "Country:",
Location = new Point(0, 2 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
cbCountry = new ComboBoxKV()
{
Location = new Point(86, 2 * line),
Width = sc.Panel2.Width - 86 - 5,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
DropDownStyle = ComboBoxStyle.DropDownList,
};
Label lblEMail = new Label()
{
Text = "EMail:",
Location = new Point(0, 3 * line + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbEMail = new TextBox()
{
Location = new Point(118, 3 * line),
Width = sc.Panel2.Width - 118 - 5,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblPgpFingerprint = new Label()
{
Text = "PGP Fingerprint:",
Location = new Point(lm, 4 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbPgpFingerprint = new TextBox()
{
Location = new Point(lm + 118, 4 * line + tm),
Width = w - (lm + 118),
Width = w - (lm + 118),
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
};
Label lblType = new Label()
{
Text = "Membership type:",
Location = new Point(lm, 5 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
ComboBox cbType = new ComboBox()
{
Location = new Point(lm + 118, 5 * line + tm),
Width = 200,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
DropDownStyle = ComboBoxStyle.DropDownList,
{
Text = "Membership type:",
Location = new Point(lm, 5 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
cbType = new ComboBoxKV()
{
Location = new Point(lm + 118, 5 * line + tm),
Width = 200,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
DropDownStyle = ComboBoxStyle.DropDownList,
};
Label lblSpawn = new Label()
{
Text = "Spawn Date:",
Location = new Point(lm, 6 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
{
Text = "Spawn Date:",
Location = new Point(lm, 6 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
DateTimePicker dateSpawn = new DateTimePicker()
dateSpawn = new DateTimePicker()
{
Location = new Point(lm + 118, 6 * line + tm),
Width = 100,
Format = DateTimePickerFormat.Short
Format = DateTimePickerFormat.Short,
MinDate = new DateTime(1900, 01, 01, 00, 00, 00),
MaxDate = DateTime.Today.AddYears(2),
};
Label lblPaymentClass = new Label()
{
Text = "Payment Amount:",
Location = new Point(lm, 7 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
TextBox tbPaymentAmount = new TextBox()
{
Location = new Point(lm + 118, 7 * line + tm),
Width = 100,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
};
CheckBox chkPaymentReduced = new CheckBox()
{
Text = "Reduced fee (document needed)",
Location = new Point(lm + 118 + 100 + 15, 7 * line + tm),
Width = w - (lm + 118 + 100 + 15),
{
Text = "Payment Amount:",
Location = new Point(lm, 7 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
tbPaymentAmount = new TextBox()
{
Location = new Point(lm + 118, 7 * line + tm),
Width = 100,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
TextAlign = HorizontalAlignment.Right,
};
chkPaymentReduced = new CheckBox()
{
Text = "Reduced fee (document needed)",
Location = new Point(lm + 118 + 100 + 15, 7 * line + tm),
Width = w - (lm + 118 + 100 + 15),
Anchor = AnchorStyles.Top | AnchorStyles.Left,
};
Label lblMemberForm = new Label()
{
Text = "Signed Date:",
Location = new Point(lm, 8 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
{
Text = "Signed Date:",
Location = new Point(lm, 8 * line + tm + 5),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomRight,
};
DateTimePicker dateMemberForm = new DateTimePicker()
dateMemberForm = new DateTimePicker()
{
Location = new Point(lm + 118, 8 * line + tm),
Width = 100,
Format = DateTimePickerFormat.Short
};
Label lblRemarks = new Label()
{
Text = "Remarks:",
Location = new Point(lm, 9 * line + tm),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomLeft,
};
TextBox tbRemarks = new TextBox()
{
Location = new Point(lm, 10 * line + tm),
Size = new Size(this.ClientSize.Width - 22, this.ClientSize.Height - (10 * line + tm) - 32),
Multiline = true,
ScrollBars = ScrollBars.Both,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
Format = DateTimePickerFormat.Short,
MinDate = new DateTime(1900, 01, 01, 00, 00, 00),
MaxDate = DateTime.Today,
};
sc.Panel1.Controls.Add(lblFirstName);
sc.Panel1.Controls.Add(tbFirstName);
sc.Panel1.Controls.Add(lblLastName);
sc.Panel1.Controls.Add(tbLastName);
sc.Panel1.Controls.Add(lblBirthday);
sc.Panel1.Controls.Add(dateBirthday);
sc.Panel1.Controls.Add(lblNickname);
sc.Panel1.Controls.Add(tbNickname);
sc.Panel2.Controls.Add(lblStreetNumber);
sc.Panel2.Controls.Add(tbStreet);
sc.Panel2.Controls.Add(tbNumber);
sc.Panel2.Controls.Add(lblZipcodeCity);
sc.Panel2.Controls.Add(tbZipcode);
sc.Panel2.Controls.Add(tbCity);
sc.Panel2.Controls.Add(lblCountry);
sc.Panel2.Controls.Add(cbCountry);
sc.Panel2.Controls.Add(lblEMail);
sc.Panel2.Controls.Add(tbEMail);
this.Controls.Add(sc);
this.Controls.Add(lblPgpFingerprint);
this.Controls.Add(tbPgpFingerprint);
this.Controls.Add(lblType);
this.Controls.Add(cbType);
this.Controls.Add(lblSpawn);
this.Controls.Add(dateSpawn);
this.Controls.Add(lblPaymentClass);
this.Controls.Add(tbPaymentAmount);
this.Controls.Add(chkPaymentReduced);
this.Controls.Add(lblMemberForm);
this.Controls.Add(dateMemberForm);
this.Controls.Add(lblRemarks);
this.Controls.Add(tbRemarks);
btnCancel.Location = new Point(this.ClientSize.Width - btnCancel.Width - 10, this.ClientSize.Height - btnCancel.Height - 10);
btnCancel.Click += BtnCancel_Click;
btnOk.Location = new Point(this.ClientSize.Width - btnOk.Width - btnCancel.Width - 16, this.ClientSize.Height - btnOk.Height - 10);
btnOk.Click += BtnOK_Click;
this.Controls.Add(btnCancel);
this.Controls.Add(btnOk);
this.ResumeLayout(false);
}
private Button btnCancel = new Button() { Text = "Cancel", Size = new Size(80, 20), Anchor = AnchorStyles.Bottom | AnchorStyles.Right };
private Button btnOk = new Button() { Text = "OK", Size = new Size(80, 20), Anchor = AnchorStyles.Bottom | AnchorStyles.Right };
public frmEditEntry(Member m, bool newMember = false)
{
member = m;
this.BuildGui();
this.Text = newMember ? $"New member {m.Number:D3}" : $"Edit member {m.Number:D3} ({m.Nickname})";
}
private void BtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnOK_Click(object sender, EventArgs e)
{
//Sanity check
//copy over to object
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}
//Form elements
//Vorname Straße Hausnr
//Name PLZ Ort
//Geburtstag Länderkürzel
//Pseudonym E-Mail-Adresse
// PGP Fingerprint
//Art der Mitgliedschaft
//Beitrittsdatum
//Beitragshöhe
//Datum des Mitgliedsantrages
sc.Panel1.Controls.Add(lblFirstName); sc.Panel2.Controls.Add(lblStreetNumber);
sc.Panel1.Controls.Add(tbFirstName); sc.Panel2.Controls.Add(tbStreet); sc.Panel2.Controls.Add(tbNumber);
sc.Panel1.Controls.Add(lblLastName); sc.Panel2.Controls.Add(lblZipcodeCity);
sc.Panel1.Controls.Add(tbLastName); sc.Panel2.Controls.Add(tbZipcode); sc.Panel2.Controls.Add(tbCity);
sc.Panel1.Controls.Add(lblBirthday); sc.Panel2.Controls.Add(lblCountry);
sc.Panel1.Controls.Add(dateBirthday); sc.Panel2.Controls.Add(cbCountry);
sc.Panel1.Controls.Add(lblNickname); sc.Panel2.Controls.Add(lblEMail);
sc.Panel1.Controls.Add(tbNickname); sc.Panel2.Controls.Add(tbEMail);
parent.Controls.Add(lblPgpFingerprint);
parent.Controls.Add(tbPgpFingerprint);
parent.Controls.Add(lblType);
parent.Controls.Add(cbType);
parent.Controls.Add(lblSpawn);
parent.Controls.Add(dateSpawn);
parent.Controls.Add(lblPaymentClass);
parent.Controls.Add(tbPaymentAmount);
parent.Controls.Add(chkPaymentReduced);
parent.Controls.Add(lblMemberForm);
parent.Controls.Add(dateMemberForm);
}
private void BuildMetadata(Control parent)
{
int w = parent.ClientSize.Width - lm - rm;
int h = parent.ClientSize.Height - tm - bm;
Label lblRemarks = new Label()
{
Text = "Remarks:",
Location = new Point(lm, 9 * line + tm),
Size = new Size(110, 12),
TextAlign = ContentAlignment.BottomLeft,
};
tbRemarks = new TextBox()
{
Location = new Point(lm + lm, 10 * line + tm),
Size = new Size(w - lm - rm, this.ClientSize.Height - (10 * line + tm) - 32),
Multiline = true,
ScrollBars = ScrollBars.Both,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
};
parent.Controls.Add(lblRemarks);
parent.Controls.Add(tbRemarks);
}
private void BuildLog(Control parent)
{
parent.Controls.Add(new Label() { Text = "(Todo)" });
}
private void BuildGui()
{
TabControl tc = new TabControl()
{
Size = new Size(this.ClientSize.Width, this.ClientSize.Height - 35),
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
TabPages =
{
new TabPage()
{
Text = "Member form"
},
new TabPage()
{
Text = "Metadata"
},
new TabPage()
{
Text = "Log"
}
}
};
BuildMemberForm(tc.TabPages[0]);
BuildMetadata(tc.TabPages[1]);
BuildLog(tc.TabPages[2]);
Button btnCancel = new Button() { Text = "Cancel", Size = new Size(80, 20), Anchor = AnchorStyles.Bottom | AnchorStyles.Right };
Button btnOk = new Button() { Text = "OK", Size = new Size(80, 20), Anchor = AnchorStyles.Bottom | AnchorStyles.Right };
btnCancel.Location = new Point(this.ClientSize.Width - btnCancel.Width - 10, this.ClientSize.Height - btnCancel.Height - 10);
btnCancel.Click += BtnCancel_Click;
btnOk.Location = new Point(this.ClientSize.Width - btnOk.Width - btnCancel.Width - 16, this.ClientSize.Height - btnOk.Height - 10);
btnOk.Click += BtnOK_Click;
this.Controls.Add(tc);
this.Controls.Add(btnCancel);
this.Controls.Add(btnOk);
}
public frmEditEntry(Member m, bool newMember = false)
{
member = m;
this.newMember = newMember;
this.SuspendLayout();
this.StartPosition = FormStartPosition.CenterParent;
this.Size = new Size(640, 480);
this.MinimumSize = new Size(580, 360);
//this.ResumeLayout(false);
//this.Refresh();
//this.SuspendLayout();
BuildGui();
//Fill form with data from m
this.Text = newMember ? $"New member {member.Number:D3}" : $"Edit member {member.Number:D3} ({member.Nickname})";
tbFirstName.Text = member.FirstName;
tbLastName.Text = member.LastName;
try { dateBirthday.Value = member.Birthday; } catch (Exception)
{
if (!newMember)
{
MessageBox.Show("Invalid birthday, " + member.Birthday + ", will be set to 1900-01-01");
dateBirthday.Value = new DateTime(1900, 01, 01);
}
else
dateBirthday.Value = DateTime.Today.AddYears(-30);
}
tbNickname.Text = member.Nickname;
tbStreet.Text = member.Street;
tbNumber.Text = member.HouseNumber;
tbZipcode.Text = member.Zipcode;
tbCity.Text = member.City;
List<Country> cl = Country.GetList();
foreach (Country c in cl)
{
string display = $"{c.A3} ({c.Code:d}) - {c.Name}";
ComboKeyValue kv = cbCountry.AddKV(display, c);
if (c.Code == member.CountryCode) cbCountry.SelectedItem = kv;
}
tbEMail.Text = member.EMail;
tbPgpFingerprint.Text = member.PgpFingerprint;
foreach (Member.eType type in Enum.GetValues(typeof(Member.eType)))
{
ComboKeyValue kv = cbType.AddKV($"{type}", type);
if (type == member.Type) cbType.SelectedItem = kv;
}
try { dateSpawn.Value = member.SpawnDate; }
catch (Exception) { if (!newMember) { MessageBox.Show("Invalid SpawnDate: " + member.SpawnDate + "!"); } }
tbPaymentAmount.Text = $"{member.PaymentAmount}";
chkPaymentReduced.Checked = member.PaymentClass == Member.ePaymentClass.Reduced;
try { dateMemberForm.Value = member.MemberFormDate; }
catch (Exception) { if (!newMember) { MessageBox.Show("Invalid MemberFormDate: " + member.MemberFormDate + "!"); } }
tbRemarks.Text = member.Remarks;
this.ResumeLayout(false);
}
private void BtnOK_Click(object sender, EventArgs e)
{
//Sanity check
//Generate log && copy over to object
LogEvent evt = member.StartLogEvent(
newMember ? $"Add user {member.Number}" : $"Edit user {member.Number}",
newMember ? LogEvent.eEventType.AddUser : LogEvent.eEventType.EditUser);
member.FirstName = tbFirstName.Text;
member.FirstName = tbFirstName.Text;
member.LastName = tbLastName.Text;
member.Birthday = dateBirthday.Value;
member.Nickname = tbNickname.Text;
member.Street = tbStreet.Text;
member.HouseNumber = tbNumber.Text;
member.Zipcode = tbZipcode.Text;
member.City = tbCity.Text;
if (cbCountry.SelectedItem != null)
{
ComboKeyValue kv = (ComboKeyValue)cbCountry.SelectedItem;
Country c = (Country)kv.Value;
member.CountryCode = c.Code;
}
member.EMail = tbEMail.Text;
member.PgpFingerprint = tbPgpFingerprint.Text;
if(cbType.SelectedItem != null)
{
ComboKeyValue kv = (ComboKeyValue)cbType.SelectedItem;
member.Type = (Member.eType)kv.Value;
}
member.SpawnDate = dateSpawn.Value;
member.PaymentAmount = Convert.ToUInt32(tbPaymentAmount.Text);
member.PaymentClass = chkPaymentReduced.Checked ? Member.ePaymentClass.Reduced : Member.ePaymentClass.Normal;
member.MemberFormDate = dateMemberForm.Value;
member.Remarks = tbRemarks.Text;
if (member.CurrentLog.SubEvents.Count > 0)
{
member.FinishLogEvent();
this.DialogResult = DialogResult.OK;
}
else
member.CancelLogEvent();
this.Close();
}
private void BtnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View File

@ -93,7 +93,7 @@ namespace dezentrale.view
if (edit.DialogResult == DialogResult.OK)
{
//the edit window already updated the data in the member object
MemberList.SaveToFile(Program.MemberFile, Program.members);
MemberList.SaveToFiles(Program.members.Entries);
lstMembers.UpdateEntry(m);
}
}
@ -114,7 +114,7 @@ namespace dezentrale.view
MessageBox.Show($"Cannot remove member:\n{ex.Message}");
return;
}
Program.members.SaveToFile(Program.MemberFile);
MemberList.SaveToFiles();
lstMembers.RemoveEntry(m);
}
}
@ -130,7 +130,9 @@ namespace dezentrale.view
//the edit window already updated the data in the member object
//but it is not added to the data list yet.
Program.members.Entries.Add(m);
MemberList.SaveToFile(Program.MemberFile, Program.members);
List<Member> toSave = new List<Member>();
toSave.Add(m);
MemberList.SaveToFiles(toSave);
lstMembers.AddEntry(m);
}
}