public void populateAccounts() { List <NoteMakingApp.Models.Account> accounts = DataHandle.getInstance().GetAccounts(); switch (cbOrder.SelectedItem) { case "Created": accounts.OrderBy(a => a.created).ToList(); break; case "Username": default: accounts.OrderBy(a => a.username).ToList(); break; } accounts = accounts.FindAll(a => a.username.Contains(tbSearch.Text)); if (!increasingOrder) { accounts.Reverse(); } this.pnlList.Controls.Clear(); AccountListItem item; foreach (NoteMakingApp.Models.Account a in accounts) { item = new AccountListItem(a, accounts.IndexOf(a) + 1); item.Location = new System.Drawing.Point(0, this.pnlList.Controls.Count * item.Height); this.pnlList.Controls.Add(item); } }
private AccountListItem makeAccountListItem(Account account) { var hasMoves = repos.Move.AccountHasMoves(account); var total = repos.Summary.GetTotal(account); var item = AccountListItem.Convert(account, total, hasMoves); return(item); }
/// <summary> /// Account created event handler /// </summary> /// <param name="e">Account created event</param> public void Handle(AddedAccount e) { var accountList = this.GetAccountListForBudget(e.Budget); var account = accountList.FirstOrDefault(x => e.AccountId.Equals(x.Id)); if (account == null) { account = new AccountListItem(e.AccountId, e.Name, this.commandBus); this.accountListItemRepository.Save(account); accountList.Add(account); } account.SetName(e.Name); this.accountListRepository.Save(e.Budget, accountList); }
/// <summary> /// Account created event handler /// </summary> /// <param name="event">Account created event</param> public void Handle(AccountCreated @event) { var accountList = this.accountListRepository.Find(); var account = this.accountListItemRepository.Find(@event.AggregateId); if (account == null) { account = new AccountListItem() { Id = @event.AggregateId, Name = @event.Name }; this.accountListItemRepository.Save(account); } if (!accountList.Any(x => x.Id == @event.AggregateId)) { accountList.Add(account); this.accountListRepository.Save(accountList); } }
private void _LinkRemove_Click(object sender, EventArgs e) { TaskDialog dialog = new TaskDialog() { Caption = Program.MainForm.Text, InstructionText = Locale.Current.Preferences.Panels.Accounts.Account.RemoveConfirmation, OwnerWindowHandle = base.Handle }; TaskDialogButton buttonYes = new TaskDialogButton("yesButton", Locale.Current.Preferences.Panels.Accounts.Account.RemoveAccount); buttonYes.Default = true; buttonYes.Click += delegate(object s, EventArgs ev) { AccountListItem target = _ListAccounts.Items.Cast <AccountListItem>().Where(o => o.Account == _currentAccount).FirstOrDefault(); if (target != null) { _ListAccounts.Items.Remove(target); } Config.Current.Accounts.Remove(_currentAccount); Config.Current.Save(); _currentAccount = null; dialog.Close(); HidePanels(); _PanelAccounts.Show(); }; TaskDialogButton buttonNo = new TaskDialogButton("noButton", Locale.Current.Common.No); buttonNo.Click += delegate(object s, EventArgs ev) { dialog.Close(); }; dialog.Controls.Add(buttonYes); dialog.Controls.Add(buttonNo); dialog.Show(); }
public void DisplayAccount() { this.textBoxPhoneNumber.Mask = null; AccountItem accountItem = new AccountItem(); if (this.comboBoxAccountList.SelectedIndex > 0) { AccountListItem selectedItem = (AccountListItem)this.comboBoxAccountList.SelectedItem; accountItem = this.appManager.GetAccountItem(selectedItem.phoneNumber); } if (accountItem.number.Length > 0) { this.textBoxPhoneNumber.Text = this.appManager.FormatPhone(accountItem.number); this.textBoxAccountTitle.Text = accountItem.title; this.textBoxPassword.Text = accountItem.password; this.comboBoxCountry.SelectedValue = accountItem.countryCode; } this.comboBoxAccountList_Load(string.Empty); this.textBoxPhoneNumber.Enabled = false; this.bNewAccount = false; this.buttonDelete.Enabled = true; }
public void comboBoxAccountList_Load(string match) { List <AccountListItem> collection = new List <AccountListItem>(); List <AccountListItem> list2 = new List <AccountListItem>(); AccountListItem item = new AccountListItem { phoneNumber = "", display = match }; list2.Add(item); foreach (AccountItem item2 in this.appManager.m_lsAccountItems) { item = new AccountListItem(); string str = (this.appManager.FormatPhone(item2.number.ToString()) + " " + item2.title).Trim(); item.phoneNumber = item2.number.ToString(); item.display = str; if (string.IsNullOrEmpty(match)) { collection.Add(item); } else { string str2 = this.appManager.FormatAlphaNumeric(match); if (item.display.ToLower().Contains(match.ToLower())) { collection.Add(item); } else if ((str2 != "") && item.phoneNumber.Contains(str2)) { collection.Add(item); } } } collection = (from a in collection orderby a.display select a).ToList <AccountListItem>(); list2.AddRange(collection); this.comboBoxAccountList.DataSource = list2; }
private void _ListAccounts_DrawItem(object sender, DrawListViewItemEventArgs e) { AccountListItem item = e.Item as AccountListItem; Bitmap image = item.Account.Type == AccountTypes.Regular ? _iconStandard : _iconApps; int elementState = 1; if ((e.State & ListViewItemStates.Selected) != 0) { if ((e.State & ListViewItemStates.Focused) != 0) { elementState = 3; // Selected } else { elementState = 5; // SelectedNotFocus; } } else if ((e.State & ListViewItemStates.Hot) != 0) { elementState = 2; // Hot } if (elementState > 1) { VisualStyleElement element = VisualStyleElement.CreateElement("Explorer::ListView", 1, elementState); VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawBackground(e.Graphics, item.Bounds); } if (e.Item.Bounds != null && item.Account != null) { PaintAccountGlyph(e.Graphics, e.Item.Bounds, item.Account); } }
/// <summary> /// Save the account list item, or add it to the repository. /// </summary> /// <param name="account">Account list item to save</param> internal void Save(AccountListItem account) { this.readStore.Store(account.Id.ToGuid(), account); }
/// <summary> /// (Re)bind to new read models /// </summary> private void RebindReadModels() { // Use properties to cause raise property changed this.AccountList = this.applicationKernel.Repositories.BudgetListRepository.Find().Single(x => BudgetId.OffBudgetId.Equals(x.BudgetId)).Accounts; // TODO: non-hardcoded single budget id this.SelectedAccount = null; }
private void _ListAccounts_DrawItem(object sender, DrawListViewItemEventArgs e) { AccountListItem item = e.Item as AccountListItem; Bitmap image = item.Account.Type == AccountTypes.Regular ? _iconStandard : _iconApps; int elementState = 1; if ((e.State & ListViewItemStates.Selected) != 0) { if ((e.State & ListViewItemStates.Focused) != 0) { elementState = 3; // Selected } else { elementState = 5; // SelectedNotFocus; } } else if ((e.State & ListViewItemStates.Hot) != 0) { elementState = 2; // Hot } if (elementState > 1) { VisualStyleElement element = VisualStyleElement.CreateElement("Explorer::ListView", 1, elementState); VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawBackground(e.Graphics, item.Bounds); } PaintAccountGlyph(e.Graphics, e.Item.Bounds, item.Account); //int tileWidth = _userFrame.Width; //int tileHeight = (int)(((float)tileWidth / (float)image.Width) * image.Height); //RectangleF clipRect = new RectangleF(item.Bounds.Left + 14, item.Bounds.Top + 13, _userFrame.Width - 30, _userFrame.Height - 30); //// //e.Graphics.SetClip(clipRect); //e.Graphics.DrawImage(image, item.Bounds.Left, item.Bounds.Top + 10, tileWidth, tileHeight); //e.Graphics.ResetClip(); //e.Graphics.DrawImage(_userFrame, new Rectangle(item.Bounds.Left, item.Bounds.Top, _userFrame.Width, _userFrame.Height)); //Point addressPoint = new Point(item.Bounds.Left + _userFrame.Width, item.Bounds.Top); //Rectangle addressRect = new Rectangle(addressPoint.X, addressPoint.Y, item.Bounds.Width - _userFrame.Width, item.Bounds.Height); //Rectangle textExtent = _rendererListSmall.GetTextExtent(e.Graphics, addressRect, item.Account.FullAddress, TextFormatFlags.Left); //int center = (_userFrame.Height - textExtent.Height) / 2; //if (item.Account.Default) { // Rectangle defaultExtent = _rendererListSmall.GetTextExtent(e.Graphics, addressRect, Locale.Current.JumpList.DefaultAccount, TextFormatFlags.Left); // center -= (defaultExtent.Height / 2) + 4; // 4 is the additional padding we're adding //} //addressRect.Offset(0, center); //_rendererListSmall.DrawText(e.Graphics, addressRect, item.Account.FullAddress, false, TextFormatFlags.Left); //if (item.Account.Default) { // addressRect.Offset(0, textExtent.Height + 4); // _rendererListSmall.DrawText(e.Graphics, addressRect, Locale.Current.JumpList.DefaultAccount, true, TextFormatFlags.Left); //} }
static void Main(string[] args) { string accountNumInput; //Det input brugeren giver når denne vælger en konto string decimalStrInput; //Det input brugeren giver når denne vil indsætte eller hæve decimal decimalDecInput; //Konverteret fra string til decimal (try/catch) bool menuBool = false; //En bolsk værdi der bliver sat ved try/catch hvis brugeren vælger at prøve igen ConsoleKeyInfo menuKey; // Istancierer banken med et navn Bank myBank = new Bank("Jan's Bank"); do { Menu(); //Kalder menuen menuKey = Console.ReadKey(true); switch (menuKey.Key) { #region - Opret konto case ConsoleKey.O: Console.WriteLine(); Console.Write("Indtast navn på kontohaver: "); string accNameInput = Console.ReadLine(); //Løber alle de tilgængelige konti typer igennem, og viser dem som en "menu" foreach (string item in myBank.GetAccType()) { Console.WriteLine(item); } Console.Write("Indtast kontotype: "); string accTypeInput = Console.ReadLine(); AccountType accType = (AccountType)Enum.Parse(typeof(AccountType), accTypeInput); //Opretter given konto, og får en string retur med friendly name string accTypeOut = myBank.CreateAccount(accNameInput, accType); Console.WriteLine(); Console.Write("Du har oprettet en {0} i {1}'s navn. Tast enter for at fortsætte", accTypeOut, accNameInput); Console.ReadKey(true); break; #endregion #region - Indsæt penge case ConsoleKey.I: Console.WriteLine(); Console.WriteLine("Vælg hvilken konto du vil indsætte penge på: "); //Løber alle konti igennem og viser det som en menu brugeren kan vælge foreach (AccountListItem item in myBank.GetAccountList()) { Console.WriteLine("[{0}] - {1} - {2}", item.AccountNo, item.AccountType, item.AccountHolder); } Console.Write("Indtast kontonummer: "); accountNumInput = Console.ReadLine(); Console.Write("Indtast beløb: "); decimalStrInput = Console.ReadLine(); //Prøver at konvertere og indsætte brugerens input try { myBank.Deposit(Convert.ToDecimal(decimalStrInput), myBank.GetAccountList().Find(s => s.AccountNo == Convert.ToInt16(accountNumInput)).AccountNo); } catch (Exception ex) { Console.WriteLine("Der er desværre sket en fejl"); Console.WriteLine(ex.Message); Console.WriteLine("Prøv venligst igen."); } Console.WriteLine("Du har indsat {0}, saldoen er nu {1} - Tast enter for at fortsætte", decimalStrInput, myBank.Balance(Convert.ToInt16(accountNumInput))); Console.ReadKey(true); break; #endregion #region - Hæver penge case ConsoleKey.H: //Denne do/while kigger på menuBool som bliver sat TRUE hvis alt blev gennemført. //Hvis brugeren har lavet en fejl bliver den sat FALSE så brugeren kan prøve igen do { Console.WriteLine(); Console.WriteLine("Vælg hvilken konto du vil hæve fra:"); //Løber alle konti igennem og viser dem som en menu hvor man kan vælge hvilken konto man vil hæve fra foreach (AccountListItem item in myBank.GetAccountList()) { Console.WriteLine("[{0}] - {1} - {2}", item.AccountNo, item.AccountType, item.AccountHolder); } Console.Write("Indtast kontonummer: "); accountNumInput = Console.ReadLine(); Console.Write("Indtast beløb: "); decimalStrInput = Console.ReadLine(); //Try/catch delen hvor input bliver kontrolleret (tal værdi) try { decimalDecInput = Convert.ToDecimal(decimalStrInput); //Tester for at se om der er kredit nok på kontoen (og om kontoen eksiterer) try { //TRUE bliver returneret af withdraw() om transaktionen blev gennemført if (myBank.Withdraw(decimalDecInput, myBank.GetAccountList().Find(s => s.AccountNo == Convert.ToInt16(accountNumInput)).AccountNo) == true) { Console.WriteLine("Du har hævet -{0}, saldoen er nu {1} - Tast enter for at fortsætte", decimalStrInput, myBank.Balance(Convert.ToInt16(accountNumInput))); Console.ReadKey(true); menuBool = true; } } catch (NullReferenceException) { Console.WriteLine("Der er desværre sket en fejl"); Console.WriteLine("Den konto du prøver at hæve fra findes ikke."); Console.WriteLine("Kontroller kontonummer, og prøv igen (tast X for at afbryde)"); if (myBank.ExitError(Console.ReadKey(true))) { break; } menuBool = false; } catch (OverdraftException e) { Console.WriteLine(e.Message); if (myBank.ExitError(Console.ReadKey(true))) { break; } menuBool = false; } } catch (Exception ex) { Console.WriteLine("Der er desværre sket en fejl"); Console.WriteLine(ex.Message); Console.WriteLine("Prøv venligst igen (tast X for at afbryde)"); if (myBank.ExitError(Console.ReadKey(true))) { break; } menuBool = false; decimalDecInput = 0; } } while (!menuBool); menuBool = false; break; #endregion #region - Vis saldo case ConsoleKey.V: Console.WriteLine(); Console.WriteLine("Vælg hvilken konto du vil se saldo for:"); Console.WriteLine("[A]lle konti"); //Løber alle konti igennem foreach (AccountListItem item in myBank.GetAccountList()) { Console.WriteLine("[{0}] - {1}", item.AccountNo, item.AccountHolder); } Console.Write("Indtast kontonummer: "); accountNumInput = Console.ReadLine(); //Hvis brugeren taster A, bliver saldi vist for alle konti. if (accountNumInput == "A" | accountNumInput == "a") { foreach (AccountListItem item in myBank.GetAccountList()) { Console.WriteLine("{0} - {1} - {2} - {3}", item.AccountNo, item.AccountHolder, item.AccountType, myBank.Balance(item.AccountNo)); } } else { try { //Finder den konto brugeren søgte på AccountListItem searchAcc = myBank.GetAccountList().Find(s => s.AccountNo == Convert.ToInt16(accountNumInput)); Console.WriteLine("Saldoen på {0} ({1}) er: {2}", searchAcc.AccountHolder, searchAcc.AccountType, myBank.Balance(searchAcc.AccountNo)); } catch (Exception ex) { Console.WriteLine("Der er desværre sket en fejl"); Console.WriteLine(ex.Message); Console.WriteLine("Prøv venligst igen."); } } Console.WriteLine("Tast enter for at fortsætte"); Console.ReadKey(true); break; #endregion #region - Tilskrive rente case ConsoleKey.R: Console.WriteLine(); myBank.Interest(); Console.WriteLine("Pålægger rente på alle konti"); for (int i = 0; i < 28; i++) { Console.Write("."); Thread.Sleep(100); } Console.WriteLine(); Console.WriteLine("Rentetilskrivning fuldført"); Console.WriteLine("Tast enter for at fortsætte"); Console.ReadKey(); break; #endregion #region - Viser logfilen case ConsoleKey.L: Console.WriteLine("Loggen indeholder følgende:"); Console.WriteLine(FileLogger.ReadFromLog()); Console.Write("Tast en vilkårlig tast for at fortsætte"); Console.ReadKey(true); break; #endregion default: break; } } while (menuKey.Key != ConsoleKey.X); myBank.ExitProgram(); }