private void MoneyFetchbutton_Click(object sender, EventArgs e) { int money; if (Int32.TryParse(FetchMoneytextBox.Text, out money) == true) { if (CurrentCreditAccount != null) { if (CurrentCreditAccount.Fetch(money)) { this.LeftLabel.Text = CurrentCreditAccount.GetMoney().ToString(); this.CreditLabel.Text = CurrentCreditAccount.Credit.ToString(); } else { MessageBox.Show("您的余额不足"); } } else { if (CurrentAccount.Fetch(money)) { this.LeftLabel.Text = CurrentAccount.GetMoney().ToString(); } else { MessageBox.Show("您的余额不足"); } } } else { MessageBox.Show("您的输入不是正确的格式"); } }
private void MoneyFetchbutton_Click(object sender, EventArgs e) { int money; if (Int32.TryParse(FetchMoneytextBox.Text, out money) == true) { try { if (CurrentCreditAccount != null) { if (CurrentCreditAccount.Fetch(money)) { if (rd.NextDouble() >= 0.7) { throw new BadCashException("系统检测到坏钞票"); } else { this.LeftLabel.Text = CurrentCreditAccount.GetMoney().ToString(); this.CreditLabel.Text = CurrentCreditAccount.Credit.ToString(); } } else { MessageBox.Show("您的余额不足"); } } else { if (CurrentAccount.Fetch(money)) { if (rd.NextDouble() >= 0.7) { throw new BadCashException("系统检测到坏钞票"); } else { this.LeftLabel.Text = CurrentAccount.GetMoney().ToString(); } } else { MessageBox.Show("您的余额不足"); } } } catch (BadCashException Exception) { MessageBox.Show(Exception.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("您的输入不是正确的格式"); } }