private void btnLogin_Click(object sender, RoutedEventArgs e) { //数据验证 if (txtLogId.Text.Trim().Length == 0) { MessageBox.Show("请输入登录账号!", "登录提示"); txtLogId.Focus(); return; } if (DataValidata.IsInteger(txtLogId.Text.Trim()) == false) { MessageBox.Show("请输入正确账号!(纯数字格式)", "登录提示"); txtLogId.Focus(); return; } if (txtLogPwd.Password.Length == 0) { MessageBox.Show("请输入登录密码!", "登录提示"); txtLogPwd.Focus(); return; } //输入的账号密码 Admins admin = new Admins() { Aid = Convert.ToInt32(txtLogId.Text.Trim()), //LoginPwd = txtLogPwd.Password }; //和后台交互查询,判断登录信息是否正确 try { Admins mainuse = new AdminsManager().GetAdmins(admin); if (mainuse == null) { MessageBox.Show("用户账号不存在!", "提示信息"); txtLogId.Focus(); } else { if (mainuse.Apwd == txtLogPwd.Password) { //保存登录信息 App.CurrentAdmin = mainuse; this.DialogResult = true; this.Close(); } else { MessageBox.Show("用户密码错误!", "提示信息"); txtLogPwd.Focus(); } } } catch (Exception ex) { MessageBox.Show("服务器连接异常,登录失败!请检查您的网络!"); } }
/// <summary> /// 输入的数据检测 /// </summary> /// <returns></returns> bool CheckInfor() { if (string.IsNullOrEmpty(txtName.Text)) { System.Windows.MessageBox.Show("姓名不能为空!"); txtName.Focus(); return(false); } if (string.IsNullOrEmpty(txtAge.Content.ToString())) { System.Windows.MessageBox.Show("年龄不能为空!"); txtAge.Focus(); return(false); } else if (!DataValidata.IsInteger(txtAge.Content.ToString())) { System.Windows.MessageBox.Show("年龄必须是纯数字!"); txtAge.Focus(); return(false); } if (string.IsNullOrEmpty(txtCardNo.Text)) { System.Windows.MessageBox.Show("打卡号不能为空!"); txtCardNo.Focus(); return(false); } if (string.IsNullOrEmpty(txtStuNoId.Text)) { System.Windows.MessageBox.Show("身份证号不能为空!"); txtStuNoId.Focus(); return(false); } if (string.IsNullOrEmpty(txtPhoneNumber.Text)) { System.Windows.MessageBox.Show("联系方式不能为空!"); txtPhoneNumber.Focus(); return(false); } else if (DataValidata.IsPhone(txtPhoneNumber.Text)) { System.Windows.MessageBox.Show("电话号输入错误!"); txtPhoneNumber.Focus(); return(false); } if (DataValidata.Data(Convert.ToInt32(datePkBirthday.Content))) { System.Windows.MessageBox.Show("日期格式错误!"); datePkBirthday.Focus(); return(false); } return(true); }
/// <summary> /// 年龄判断 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtAge_LostFocus(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtAge.Content.ToString())) { System.Windows.MessageBox.Show("年龄不能为空!"); txtAge.Focus(); } else if (!DataValidata.IsInteger(txtAge.Content.ToString())) { System.Windows.MessageBox.Show("年龄必须是纯数字!"); txtAge.Focus(); } }