Exemple #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;
            string role     = "System Customer";

            ;

            Users aUser    = UsersDA.RetrieveUser(username);
            Users userRole = UsersDA.RetrieveRole(username);

            if (aUser.Password.Equals(password))
            {
                MessageBox.Show("Login Success");
                if (userRole.Role.Equals(role))
                {
                    View_Layer.MainMenu m = new View_Layer.MainMenu();
                    m.Show();
                }
                else
                {
                    View_Layer.AdminMainMenu n = new View_Layer.AdminMainMenu();
                    n.Show();
                }

                //                View_Layer.MainMenu m = new View_Layer.MainMenu();
                //               m.Show();
            }
            else
            {
                MessageBox.Show("Login Failed. Please try again");
                txtUsername.Text = "";
                txtPassword.Text = "";
            }
        }
Exemple #2
0
        /// <summary>
        /// Проверка пароля и логина с БД по методу RetrieveUser.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TbOk_Click(object sender, RoutedEventArgs e)
        {
            string username = tb_Login.Text;
            string password = tb_Password.Password;

            Users aUser = UsersDA.RetrieveUser(username);

            try
            {
                if (aUser.Password.Equals(password))
                {
                    MessageBox.Show("login Success");
                    View.MainWindow mw = new MainWindow();
                    mw.Show();
                }
                else
                {
                    lb_message.Content   = "Неверный пароль.";
                    tb_Password.Password = "";
                }
            }
            catch (Exception)
            {
                lb_message.Content = "Неверный логин:";
                tb_Login.Text      = "";
            }
        }
Exemple #3
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            string username = txtname.Text;
            string password = txtpass.Password;

            if (username.Length < 1 || password.Length < 1)
            {
                MessageBox.Show("Fill all fields!");
            }
            else
            {
                try
                {
                    Users aUser = UsersDA.RetrieveUser(username);

                    DBhelper.credsUnits   = aUser.LoggedUnit;
                    DBhelper.credsInitial = aUser.LoggedInitial;
                    DBhelper.credsUser    = aUser.UserName;

                    if (aUser.Password.Equals(password))
                    {
                        MessageBox.Show("Login Success");
                        MainWindow dashboard = new MainWindow();
                        dashboard.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Login Failed. Please try again");
                        txtname.Text     = "";
                        txtpass.Password = "";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Username not found " + ex.Message);
                }
            }
        }