private void Sure_Click(object sender, EventArgs e) { bool fname = false; foreach (UserInfo u in Program.users) { if (u.Account == Account.Text) { fname = true; if (u.Pass == Pass.Text) { MessageBox.Show("登录成功!请选择要执行的操作"); Choose chose = new Choose(); chose.SetUser(u); chose.ShowDialog(); return; } } } if (!fname) { if (Account.Text=="") { MessageBox.Show("登陆的帐号不能为空!"); } else MessageBox.Show("你输入的帐号不存在,请先注册!"); return; } MessageBox.Show("你输入的密码不正确:"); }