private void LogIn_Click(object sender, RoutedEventArgs e) { DB db = new DB(); string uid = this.UserNumber.Text.Trim(); string pwd = this.PassWord.Password; if (uid == null || uid.Equals("")) { this.Info.Height = 20; this.Info.Content = "用户名不能为空!"; return; } if (pwd == null || pwd.Equals("")) { this.Info.Height = 20; this.Info.Content = "密码不能为空!"; return; } /* 验证登录。* 3 无此用户* 2 密码不对 * 1 非管理员* 0 成功 */ int login = db.LogIn(this.UserNumber.Text, this.PassWord.Password); switch (login) { case 3: this.Info.Height = 20; this.Info.Content = "没有此用户!"; break; case 2: this.Info.Height = 20; this.Info.Content = "用户名或密码不正确!"; break; case 1: this.Info.Height = 20; this.Info.Content = "您没有管理权限!"; break; case 0: this.Info.Height = 20; this.Info.Content = "验证成功"; this.DialogResult = true; this.Close(); break; default: break; } }