Example #1
0
        private async void  login_button_click(object sender, RoutedEventArgs e)
        {
            if (TxtUsername.Text == "")
            {
                _message.Message.Text = "Please Enter Username";
                TxtUsername.Focus();
                await DialogHost.Show(_message, "RootDialog");

                return;
            }
            if (TxtPassword.Password == "")
            {
                _message.Message.Text = "Please Enter Password";
                TxtPassword.Focus();
                await DialogHost.Show(_message, "RootDialog");

                return;
            }
            UserDataManager userManager = new UserDataManager();
            User            user        = userManager.AuthenticateUser(TxtUsername.Text, TxtPassword.Password);

            if (user == null)
            {
                _message.Message.Text = "Wrong username or password";
                TxtUsername.Focus();
                await DialogHost.Show(_message, "RootDialog");

                return;
            }
            MainWindow window = new MainWindow();

            window.Show();
            Close();
        }
        public static User AuthenticateUser(String LoginName, String Password)
        {
            User objUser = UserDataManager.AuthenticateUser(LoginName, Password);

            HttpContext.Current.Session.Add("User", objUser);
            if (String.IsNullOrEmpty(objUser.Remarks))
            {
                Common.CurrentUser = objUser;
            }
            else
            {
                Common.CurrentUser = null;
            }
            return(objUser);
        }