private void loginB_Click(object sender, RoutedEventArgs e) { if (userIDTB.Text.Length == 0 || passwordPB.Password.Length == 0) { MessageBox.Show("用户ID和密码不能为空"); return; } loginB.IsEnabled = false; loginB.Content = "登录中..."; if (!(connector.connect() && connector.Login(userIDTB.Text, StaticStuff.GetMD5(passwordPB.Password)))) { MessageBox.Show(this, "登录失败,无法连接服务器!"); loginB.IsEnabled = true; loginB.Content = "登录"; } }
private void signUpB_Click(object sender, RoutedEventArgs e) { if (nickNameTB.Text.Length == 0 || passwordPB.Password.Length == 0) { MessageBox.Show(this, "昵称或密码不可为空!"); return; } char[] c = { ';', '\0' }; if (nickNameTB.Text.IndexOfAny(c) >= 0 || passwordPB.Password.IndexOfAny(c) >= 0) { MessageBox.Show(this, "昵称或密码中不可含有';'和'\0'!"); return; } if (nickNameTB.Text.Length > 20 || passwordPB.Password.Length > 20) { MessageBox.Show(this, "昵称或密码不得超过20字符长!"); return; } NickName = nickNameTB.Text; Password = StaticStuff.GetMD5(passwordPB.Password); DialogResult = true; Close(); }