Пример #1
0
        void TryLogin()
        {
            string username = usernameTxt.Text;
            //string hash of plaintext password
            string password = UserAccount.stringToHashString(passwordBox.Password);

            var user = UICreatePage.GetUserFromUsernamePassword(username, password);

            if (user == null)
            {
                this.errorBlock.Text = "That username or password is invalid";
                DefaultInputFields();
            }
            else
            {
                //stores this current user
                //store ui window, with user menu page
                LoginService.getFirstInstance(user);
                UIWindow ui = LoginService.Instance.currentUIWindow;
                ui.Show();

                //close all windows
                this.Close();
                if (CreateNewAccountService.Instance != null)
                {
                    CreateNewAccountService.Instance.Window.Close();
                }
            }
        }
Пример #2
0
        private void SignupBtn_Click(object sender, RoutedEventArgs e)
        {
            string username        = UsernameTxt.Text;
            string password        = passwordBox.Password;
            string confirmPassword = ConfirmPasswordBox.Password;
            var    naV             = new NewAccountValidation(username, password, confirmPassword);

            //validation passed
            if (naV.isNewAccountValid)
            {
                //stores username and hashed password
                CreateNewAccountService.Instance.username = username;
                CreateNewAccountService.Instance.password = UserAccount.stringToHashString(password);

                //show next window
                var ui = UICreatePage.GetAdminDetailsPage();
                CreateNewAccountService.Instance.Window.Content = ui;
            }
            else
            {
                ErrorTxt.Text = naV.ErrorMessage;
            }

            /*
             * string errorMessage = ValidateInputs(username, password, confirmPassword);
             *
             * //Take action depending on validation from above
             * IsInputValid(errorMessage, username, password);*/
        }
Пример #3
0
        public static UIWindow GetUIWindow(dynamic user)
        {
            UIWindow pageHolder = new UIWindow();

            var menuPage = UICreatePage.GetUserMenu(user);

            pageHolder.pageHolder.Content = menuPage;

            return(pageHolder);
        }
Пример #4
0
        private void loginBtn_Click(object sender, RoutedEventArgs e)
        {
            //Get inputted details
            string username = usernameTxt.Text;
            string password = UserAccount.stringToHashString(passwordBox.Password);
            var    aV       = new AdminValidation(username, password);

            if (aV.isAccountAdmin)
            {
                //Allow admin to pick access levels
                var ui = UICreatePage.CreateNewSetAccessPage();
                CreateNewAccountService.Instance.Window.Content = ui;
            }
            else
            {
                errorBlock.Text = aV.ErrorMessage;
            }

            /*
             * //Validate if details match existing admin account
             * using(var dbContext = new InventoryContext())
             * {
             *  AdminAccount admin = AdminAccountValidation.ValidateAdminAccount(username, password, dbContext);
             *
             *  //Validation failed
             *  if( admin == null)
             *  {
             *      errorBlock.Text = "Enter valid admin account details";
             *
             *  }
             *  else
             *  {
             *      //Allow admin to pick access levels
             *      var ui = UICreatePage.CreateNewSetAccessPage();
             *      CreateNewAccountService.Instance.Window.Content = ui;
             *  }
             * }*/
        }
Пример #5
0
 private void MainMenuBtn_Click(object sender, RoutedEventArgs e)
 {
     LoginService.Instance.currentUIWindow.pageHolder.Content =
         UICreatePage.GetUserMenu(LoginService.Instance.currentUser);
 }
Пример #6
0
 private CreateNewAccountService(CreateNewAccountWindow _Window)
 {
     Window = UICreatePage.GetNewAccountWindow();
 }
Пример #7
0
        private void lowStockBtn_Click(object sender, RoutedEventArgs e)
        {
            var ui = UICreatePage.GetNewLowStockPage();

            LoginService.Instance.currentUIWindow.pageHolder.Content = ui;
        }
Пример #8
0
        private void viewPastDelBtn_Click(object sender, RoutedEventArgs e)
        {
            var ui = UICreatePage.GetNewPastDeliveriesPage();

            LoginService.Instance.currentUIWindow.pageHolder.Content = ui;
        }
Пример #9
0
        private void analyticsBtn_Click(object sender, RoutedEventArgs e)
        {
            var ui = UICreatePage.GetAnalyticsPage();

            LoginService.Instance.currentUIWindow.pageHolder.Content = ui;
        }
Пример #10
0
        private void tillModeBtn_Click(object sender, RoutedEventArgs e)
        {
            TillModePage tillModePage = UICreatePage.GetTillModePage();

            LoginService.Instance.currentUIWindow.pageHolder.Content = tillModePage;
        }
Пример #11
0
        private void viewTransactionsBtn_Click(object sender, RoutedEventArgs e)
        {
            ViewTransactionsPage viewTransactions = UICreatePage.GetViewTransactionsPage();

            LoginService.Instance.currentUIWindow.pageHolder.Content = viewTransactions;
        }
Пример #12
0
        //Displaying pages on currently open UIWindow
        private void viewTblsBtn_Click(object sender, RoutedEventArgs e)
        {
            var viewTblsPage = UICreatePage.GetViewTblPage();

            LoginService.Instance.currentUIWindow.pageHolder.Content = viewTblsPage;
        }
Пример #13
0
 private LoginService(dynamic _currentUser)
 {
     this.currentUser     = _currentUser;
     this.currentUIWindow = UICreatePage.GetUIWindow(this.currentUser);
 }