private void Loginbutton_Click(object sender, EventArgs e) { if (this.AccounttextBox.Text == "root" && this.PasswordtextBox.Text == "123456") { state = State.Rooted; MessageBox.Show("管理员登录成功,点击银行查看用户信息"); TextBoxFixed(); this.LogoutToolStripMenuItem.Visible = true; } else { int flag = 0;//表示账号列表中是否有当前账号 foreach (Account act in Account.BankAccounts) { if (act.BaseAccount == this.AccounttextBox.Text) { flag = 1; if (act.Password != this.PasswordtextBox.Text) { MessageBox.Show("您输入的密码有误"); } else { state = State.Logined; CurrentAccount = act; MessageBox.Show("登陆成功,请使用菜单栏中按钮"); TextBoxFixed(); this.LogoutToolStripMenuItem.Visible = true; } } } if (flag == 0) { foreach (CreditAccount CA in CreditAccount.CreditAccounts) { if (CA.BaseAccount == this.AccounttextBox.Text) { flag = 1; if (CA.Password != this.PasswordtextBox.Text) { MessageBox.Show("您输入的密码有误"); } else { state = State.Logined; CurrentCreditAccount = CA; MessageBox.Show("登陆成功,请使用菜单栏中按钮"); TextBoxFixed(); this.LogoutToolStripMenuItem.Visible = true; } } } } if (flag == 0) { MessageBox.Show("您输入的账号不存在"); } } }
private void SubmitButton_Click(object sender, EventArgs e) { if (flag == Flag.Account) { if (CredittextBox.Text != "" && CredittextBox.Text != "0") { foreach (Account account in Account.BankAccounts) { if (account.BaseAccount == NametextBox.Text) { this.BankAccount = account; CreditAccount CA = new CreditAccount(account.BaseAccount, account.Password, Int32.Parse(CredittextBox.Text)); CA.SetMoney(Int32.Parse(LefttextBox.Text)); CreditAccount.CreditAccounts.Add(CA); } } Account.BankAccounts.Remove(BankAccount); } else { foreach (Account account in Account.BankAccounts) { if (account.BaseAccount == NametextBox.Text) { this.BankAccount = account; account.SetMoney(Int32.Parse(LefttextBox.Text)); } } } } else if (flag == Flag.CreditAccount) { foreach (CreditAccount account in CreditAccount.CreditAccounts) { if (account.BaseAccount == NametextBox.Text) { this.BankCreditAccount = account; account.SetMoney(Int32.Parse(LefttextBox.Text)); account.Credit = Int32.Parse(CredittextBox.Text); } } Account.BankAccounts.Remove(BankAccount); } else { MessageBox.Show("请选中ListView中的一个项,单击即可"); } //重启本视图,将更新后的Account和CreditAccount更新到视图中 FillAccountlistView(); FillCreditAccountlistView(); this.NametextBox.Text = ""; this.LefttextBox.Text = ""; this.CredittextBox.Text = ""; }
private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) { state = State.UnLogined; CurrentAccount = null; CurrentCreditAccount = null; TextBoxThaw(); this.AccounttextBox.Clear(); this.PasswordtextBox.Clear(); this.LogoutToolStripMenuItem.Visible = false; }
public ATM(CreditAccount account) { this.CurrentCreditAccount = account; InitializeComponent(); Textlabel.Text = ($"{account.BaseAccount}用户"); LeftLabel.Text = ($"{account.GetMoney()}"); CreditLabel.Text = ($"{account.Credit}"); rd = new Random(); //注册CreditAccount的事件 CurrentCreditAccount.BigMoneyFetchedEvent += BigCreditMoneyFetched; }
//订阅器 public void BigCreditMoneyFetched(object sender, CreditAccount.BigMoneyArgs args) { CreditAccount act = (CreditAccount)sender; MessageBox.Show($"{act.BaseAccount},您的账号取走了{args.money}"); }
public BigMoneyArgs(int money, CreditAccount account) { this.account = account; this.money = money; }