コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            FacadeController f = FacadeController.GetFacade(); //TODO: create user using facade controller

            if (nameTxtBox.Text != string.Empty && usernameTxtBox.Text != string.Empty && pswdBox.Password != string.Empty && typeCombo.SelectedItem != null)
            {
                LogicLayer.Objects.User user = new LogicLayer.Objects.User(nameTxtBox.Text, usernameTxtBox.Text, pswdBox.Password.ToString(), typeCombo.SelectedItem.ToString());
                if (user.AddUser() > 0)
                {
                    MessageBox.Show("User Added.");
                }
                else
                {
                    MessageBox.Show("Error adding user. Contact sysadmin");
                }
                this.Close();
            }
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (nameTextBox.Text != string.Empty && passTextBox.Password != string.Empty) //Empty Field Check
            {
                FacadeController f = FacadeController.GetFacade();

                User loginResult = f.Authenticate(nameTextBox.Text, passTextBox.Password.ToString());
                nameTextBox.Text     = "";
                passTextBox.Password = string.Empty;
                if (loginResult != null)
                {
                    if (loginResult.type == "Salesman")
                    {
                        MessageBox.Show(loginResult.type);
                    }
                    else if (loginResult.type == "Admin")
                    {
                        signedIn = true;
                        StockWindow stockWindow = new StockWindow(false);
                        this.Hide();
                        stockWindow.ShowDialog();
                        if (!signedIn)
                        {
                            this.Show();
                        }
                    }
                    else if (loginResult.type == "Root")
                    {
                        signedIn = true;
                        RootMenu rm = new RootMenu();
                        this.Hide();
                        rm.ShowDialog();
                        if (!signedIn)
                        {
                            this.Show();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Login failed");
                }
            }
        }