Example #1
0
        protected void KontoDepositClose_ButtonClick(object sender, EventArgs e)
        {
            restartTimer();
            double money;
            String deposit = deposit1.tbDeposit.Text;
            Regex  regex   = new Regex(@"^[0-9]{2,4}(,[0-9]{2})?$");
            Match  match   = Regex.Match(deposit, @"^[0-9]{1,4}(,[0-9]{2})?$");

            if (match.Success)
            {
                try
                {
                    money = Convert.ToDouble(match.Value);
                    int moneyAccount = Convert.ToInt32(money * 100);

                    int s200 = moneyAccount / 20000;
                    moneyAccount = moneyAccount % 20000;

                    int s100 = moneyAccount / 10000;
                    moneyAccount = moneyAccount % 10000;

                    int s50 = moneyAccount / 5000;
                    moneyAccount = moneyAccount % 5000;

                    int s20 = moneyAccount / 2000;
                    moneyAccount = moneyAccount % 2000;

                    int s10 = moneyAccount / 1000;
                    moneyAccount = moneyAccount % 1000;

                    int s5 = moneyAccount / 500;
                    moneyAccount = moneyAccount % 500;

                    int s2 = moneyAccount / 200;
                    moneyAccount = moneyAccount % 200;

                    int s1 = moneyAccount / 100;
                    moneyAccount = moneyAccount % 100;

                    int s050 = moneyAccount / 50;
                    moneyAccount = moneyAccount % 50;

                    int s020 = moneyAccount / 20;
                    moneyAccount = moneyAccount % 20;

                    int s010 = moneyAccount / 10;
                    moneyAccount = moneyAccount % 10;

                    int s05 = moneyAccount / 5;
                    moneyAccount = moneyAccount % 5;

                    int s02 = moneyAccount / 2;
                    moneyAccount = moneyAccount % 2;

                    int s01 = moneyAccount / 1;
                    moneyAccount = moneyAccount % 1;

                    new Task(async() =>
                    {
                        account = await accountClient.Deposit(account, atm, new FunBankLib.Models.ATMInventory()
                        {
                            FiftyEuro      = s50,
                            FifyCents      = s050,
                            FiveEuro       = s5,
                            OneCent        = s01,
                            OneEuro        = s1,
                            OneHundredEuro = s100,
                            TenCents       = s010,
                            TwoCents       = s02,
                            FiveCents      = s05,
                            TenEuro        = s10,
                            TwentyEuro     = s20,
                            TwentyCents    = s020,
                            TwoEuro        = s2,
                            TwoHundredEuro = s200
                        });

                        if (account != null)
                        {
                            InvokeIfRequired(() =>
                            {
                                balance = account.Balance;
                                balance = balance / 100;
                                zustand = 1;
                                deposit1.Hide();
                                konto1.Show();
                                deposit1.refreshTB();
                                deposit1.Refresh();
                                Application.DoEvents();
                            });
                        }
                    }).Start();
                }
                catch (FormatException ex)
                {
                    Console.WriteLine("Withdraw FormatException", ex);
                }
            }
        }