Esempio n. 1
0
        private void WithdrawBtnClick(object sender, RoutedEventArgs e)
        {
            var client = new BetServiceClient();

            try
            {
                client.Open();
                int amount;
                if (int.TryParse(withdrawTB.Text, out amount) && client.AccountWithdraw(account.Code, amount))
                {
                    account.Amount      -= amount;
                    accountAmountTB.Text = account.Amount.ToString();

                    MessageBox.Show($"Successfully withdrew  {amount}");
                    withdrawTB.Text = "";
                }
                else
                {
                    MessageBox.Show($"Cannot withdrew {amount}");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection problem");
            }
            finally
            {
                client.Close();
            }
        }
Esempio n. 2
0
 private void SimpleBetClick(object sender, RoutedEventArgs e)
 {
     if (EventsListView.SelectedItem == null)
     {
         MessageBox.Show("You should select event form the list");
     }
     else
     {
         var item    = (Event)EventsListView.SelectedItem;
         var results = new Event
         {
             Factor = item.Factor,
             Name   = item.Name
         };
         int betAmount;
         if (!int.TryParse(BetTextBox.Text, out betAmount))
         {
             MessageBox.Show("Wrong bet");
         }
         else
         {
             if (betAmount > account.Amount)
             {
                 MessageBox.Show("Not enough money");
             }
             else
             {
                 var client = new BetServiceClient();
                 try
                 {
                     client.Open();
                     client.AccountWithdraw(account.Code, betAmount);
                     client.MakeBet(account.Code, betAmount, BetType.Simple, new[] { results });
                     MessageBox.Show("Bet success");
                     BetTextBox.Text = "";
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("Connection problem");
                 }
                 finally
                 {
                     client.Close();
                 }
             }
         }
     }
 }