private void loginBtn_Click(object sender, RoutedEventArgs e) { if (username.Text == "") { loginResult.Text = "Please input username"; return; } if (password.Text == "") { loginResult.Text = "Please input password"; return; } loginResult.Text = "Authenticating..."; user.Username = username.Text; user.Password = password.Text; //BLL.Login login = new BLL.Login(user); CommClient.Login login = new CommClient.Login(user.Username, user.Password); if (login.Authenticate()) { loginResult.Text = "Login success!"; user.Status = DTO.LoginUser.LoginStatus.login; loginBtn.IsEnabled = false; logoutBtn.IsEnabled = true; } else { loginResult.Text = "Login failed!"; } }
private void logoutBtn_Click(object sender, RoutedEventArgs e) { if (user.Status == DTO.LoginUser.LoginStatus.login) { //BLL.Login login = new BLL.Login(user); CommClient.Login login = new CommClient.Login(user.Username, user.Password); if (login.Logout()) { loginResult.Text = user.Username + " logout success!"; user.Status = DTO.LoginUser.LoginStatus.logout; user.Username = "******"; loginBtn.IsEnabled = true; logoutBtn.IsEnabled = false; username.Clear(); password.Clear(); } else { loginResult.Text = "Logout failed!"; } } }