private void UpdateAccountInfo(int code) { var client = new BetServiceClient(); try { client.Open(); account = client.GetAccount(code); accountAmountTB.Text = account.Amount.ToString(); accountCodeTB.Text = account.Code.ToString(); accountFIOTB.Text = account.FIO; } catch (Exception ex) { MessageBox.Show("Connection problem"); } finally { client.Close(); } }
private void LoginBtnClick(object sender, RoutedEventArgs e) { loginBtn.IsEnabled = false; var accCode = -1; if (int.TryParse(accCodeTB.Text, out accCode)) { var client = new BetServiceClient(); try { client.Open(); var acc = client.GetAccount(accCode); if (acc.Code == 0) { loginStatus.Text = $"There is no account with code - {accCode}"; } else { loginStatus.Text = "Succesful login"; NavigationService?.Navigate(new AccountManager(accCode)); } } catch (Exception ex) { loginStatus.Text = "Cannot connect to server"; } finally { client.Close(); } } else { loginStatus.Text = "Incorrect code"; } loginBtn.IsEnabled = true; }