示例#1
0
文件: Terminal.cs 项目: Dubinetski/Cs
        /// <summary>
        /// Работа с аккаунтом клиента
        /// </summary>
        /// <param name="client"></param>
        /// <param name="accaunt"></param>
        protected static void ClientAccauntMenu(Client client, Account accaunt)
        {
            Menu accauntMenu = new Menu("",
                                        new string[] { "Summ" },
                                        new string[] { "DEPOSIT", "WITHDRAW", "BACK", "EXIT" });
            decimal changeSumm;
            string  status = "";

            while (true)
            {
                accauntMenu.Title = String.Format("Client: {0}. Accaunt: {1}. ({2})", client.Login, accaunt.ToString(), status);
                accauntMenu.Show();

                switch (accauntMenu.ButtonPressedIndex())
                {
                case 0:
                    if (Decimal.TryParse(accauntMenu.FildsDict["Summ"], out changeSumm))
                    {
                        accaunt.Deposit(changeSumm);
                        status = String.Format("OK. Deposit {0} {1}", changeSumm, accaunt.GetAccountCurrency());
                    }
                    else
                    {
                        status = "EROOR. Incorrect format";
                    }
                    break;

                case 1:
                    if (Decimal.TryParse(accauntMenu.FildsDict["Summ"], out changeSumm))
                    {
                        if (accaunt.TryWithdrawal(changeSumm))
                        {
                            status = String.Format("OK. Withdraw {0} {1}", changeSumm, accaunt.GetAccountCurrency());
                        }
                        else
                        {
                            status = String.Format("EROOR. Insufficient funds.");
                        }
                    }
                    else
                    {
                        status = "EROOR. Incorrect format";
                    }
                    break;

                case 2:
                    return;

                default:
                    break;
                }
                accauntMenu.FildsDict["Summ"] = null;
            }
        }