private void LoginSystem(object logUser) { try { string msg = ""; LibraryService.UserEntity userInfo = new LibraryService.UserEntity(); bool log_result = false; LibraryService.ILibrary _service = new LibraryService.LibraryClient(); try { log_result = _service.LoginSys(out msg, out userInfo, (logUser as LibraryService.UserEntity).LoginName, (logUser as LibraryService.UserEntity).Pwd); } catch (Exception ex) { msg = "无法连接服务器!"; } this.Dispatcher.BeginInvoke((Action) delegate() { loginBtn.Content = "登录"; if (log_result) { CommonConfig.Current.LoginUserInfo = userInfo; this.DialogResult = true; this.Close(); } else { label_msg.Content = msg; return; } }); } catch (Exception ex) { } }
private void loginBtn_Click(object sender, RoutedEventArgs e) { label_msg.Content = ""; if (string.IsNullOrEmpty(usernameBox.Text.Trim())) { label_msg.Content = "用户名不能为空!"; return; } if (string.IsNullOrEmpty(passwordBox.Password.Trim())) { label_msg.Content = "密码不能为空!"; return; } loginBtn.Content = "登录中..."; LibraryService.UserEntity logUser = new LibraryService.UserEntity(); logUser.LoginName = usernameBox.Text.Trim(); logUser.Pwd = passwordBox.Password.Trim(); Thread newThread = new Thread(new ParameterizedThreadStart(LoginSystem)); newThread.Start(logUser); }
private void InitFromConfig() { LoginUserInfo = new LibraryService.UserEntity(); }