public void loadAll() { if (SavGremlin.Properties.Settings.Default.Categories != null) { foreach (String cat in SavGremlin.Properties.Settings.Default.Categories) { SavingsCategoryControl tmp = new SavingsCategoryControl(); tmp.newTransactionButton.Click += new EventHandler(this.onNewTransaction); tmp.savData = SavingsCategory.inflateFromString(cat); tmp.refreshViews(); tmp.Dock = DockStyle.Left; savingsCategoryPanel.Controls.Add(tmp); } } if (SavGremlin.Properties.Settings.Default.Accounts != null) { foreach (String cat in SavGremlin.Properties.Settings.Default.Accounts) { SavingsAccountControl tmp = new SavingsAccountControl(); tmp.addButton.Click += new EventHandler(this.onNewAccountAddition); tmp.data = SavingsAccount.inflateFromString(cat); tmp.refreshViews(); tmp.Dock = DockStyle.Left; accountsPanel.Controls.Add(tmp); } } }
private void newAccountToolStripMenuItem_Click(object sender, EventArgs e) { NewAccountForm form = new NewAccountForm(); if (form.ShowDialog() == DialogResult.OK) { SavingsAccountControl tmp = new SavingsAccountControl(); tmp.data = form.newAccount; tmp.Dock = DockStyle.Left; tmp.refreshViews(); accountsPanel.Controls.Add(tmp); saveAll(); } }
public void saveAll() { System.Collections.Specialized.StringCollection data = new System.Collections.Specialized.StringCollection(); foreach (Control c in savingsCategoryPanel.Controls) { SavingsCategoryControl tmp = (SavingsCategoryControl)c; data.Add(tmp.savData.collapseToString()); } System.Collections.Specialized.StringCollection accounts = new System.Collections.Specialized.StringCollection(); foreach (Control c in accountsPanel.Controls) { SavingsAccountControl tmp = (SavingsAccountControl)c; accounts.Add(tmp.data.collapseToString()); } SavGremlin.Properties.Settings.Default.Categories = data; SavGremlin.Properties.Settings.Default.Accounts = accounts; SavGremlin.Properties.Settings.Default.Save(); }