private void Login_Click(object sender, RoutedEventArgs e) { User_Controller Controller = new User_Controller(); if (UserName.Text.Length == 0 && Password.Password.Length == 0) { UserNameErrorMessage.Text = "You must enter valid username"; PasswordErrorMessage.Text = "You must enter password"; UserName.Focus(); Password.Focus(); } else if (UserName.Text.Length == 0) { UserNameErrorMessage.Text = "You must enter valid username"; UserName.Focus(); } else if (Password.Password.Length == 0) { PasswordErrorMessage.Text = "You must enter password"; Password.Focus(); } else { string username = UserName.Text; string password = Password.Password; var status = Controller.UserLogin(username, password); if (status == true) { this.Hide(); Home home = new Home(username); home.Show(); } } }
private void Btn_Login_Click(object sender, RoutedEventArgs e) { User user = new User(); User_Controller _user = new User_Controller(); MyContext _contex = new MyContext(); if (Txt_Email.Text.Length != 0 && Txt_Password.Password.Length != 0) { string email = Txt_Email.Text; string password = Txt_Password.Password; var get = _contex.Users.Where(u => u.Email == email).FirstOrDefault <User>(); string NIK = get.Employee_Id; var status = _user.UserLogin(email, password); if (status == true) { this.Hide(); Home home = new Home(NIK); home.Show(); } } else { MessageBox.Show("Please Fill All The Requirement!"); } }