示例#1
0
 private void OK_Click(System.Object sender, System.EventArgs e)
 {
     if (UsernameTextBox.Text == "" | PasswordTextBox.Text == "")
     {
         MessageBox.Show("Enter your Username and password!", "Fields Empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return;
     }
     sql.addprams("@name", UsernameTextBox.Text);
     sql.addprams("@pass", PasswordTextBox.Text);
     sql.ExecSql("Select * from users where username = @name and pass = @pass");
     if (sql.count == 0)
     {
         MessageBox.Show("Invalid Username or Password", "Wrong info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         UsernameTextBox.Clear();
         PasswordTextBox.Clear();
         UsernameTextBox.Focus();
         return;
     }
     else
     {
         this.Hide();
         MainInterface mainInterface = new MainInterface();
         mainInterface.FormClosed += (s, args) => this.Close();
         mainInterface.Show();
     }
 }
示例#2
0
 private void LoginFailed()
 {
     UsernameTextBox.Focus();
     UsernameTextBox.Background    = _errorColorBrush;
     PasswordBox.Background        = _errorColorBrush;
     LoginFailedMessage.Visibility = Visibility.Visible;
 }
示例#3
0
        private async Task SignIn()
        {
            var username = UsernameTextBox.Text;
            var password = PasswordTextBox.Text;

            var user = await Services.UserManager.FindByNameAsync(username).ConfigureAwait(true);

            if (user is null)
            {
                UiUtils.ErrorMessageBox("Your username and/or password is incorrect", "Invalid Credentials");
                return;
            }

            var signInResult = await Services.SignInManager.CheckPasswordSignInAsync(user, password, false).ConfigureAwait(true);

            if (!signInResult.Succeeded)
            {
                UiUtils.ErrorMessageBox("Your username and/or password is incorrect", "Invalid Credentials");
                return;
            }

            Services.UserContext.SignIn(user);

            UsernameTextBox.ResetText();
            PasswordTextBox.ResetText();

            Hide();

            var dashboardForm = new DashboardForm(Services);

            dashboardForm.ShowDialog();

            Show();
        }
示例#4
0
        private bool ValidateRequiredFields()
        {
            bool passwordIsBad = String.IsNullOrEmpty(PasswordBox.Password);
            bool emailIsBad    = !ValidateEmail(UsernameTextBox.Text);

            if (emailIsBad)
            {
                UsernameTextBox.Focus();
            }
            else if (passwordIsBad)
            {
                PasswordBox.Focus();
            }

            if (passwordIsBad)
            {
                PasswordBox.Background = _errorColorBrush;
            }

            if (emailIsBad)
            {
                UsernameTextBox.Background         = _errorColorBrush;
                EmailFormatErrorMessage.Visibility = Visibility.Visible;
            }

            return(!(passwordIsBad || emailIsBad));
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            UserController CallUser = new UserController();

            if (UsernameTextBox.Text.Length == 0 && PasswordTextBox.Password.Length == 0)
            {
                UsernameErrorMessage.Text = "You Must Enter Valid Username!";
                PasswordErrorMessage.Text = "You Must Enter Password!";
                PasswordTextBox.Focus();
                UsernameTextBox.Focus();
            }
            else if (UsernameTextBox.Text.Length == 0)
            {
                UsernameErrorMessage.Text = "You Must Enter Valid Username!";
                UsernameTextBox.Focus();
            }
            else if (PasswordTextBox.Password.Length == 0)
            {
                PasswordErrorMessage.Text = "You Must Enter Password!";
                PasswordTextBox.Focus();
            }
            else
            {
                string username = UsernameTextBox.Text;
                string password = PasswordTextBox.Password;

                CallUser.ChangePass(username, password);
            }
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            bool isPasswordDiff = OldPasswordBox.Password != PasswordBox.Password &&
                                  OldPasswordBox.Password != RepeatPasswordBox.Password;
            bool isOldPassCorrect = _user.Password == OldPasswordBox.Password;

            bool isPasswordSame = PasswordBox.Password == RepeatPasswordBox.Password;

            if (isOldPassCorrect && isPasswordDiff && isPasswordSame)
            {
                using (var context = new ExpansesManagerContext())
                {
                    _user.Password = PasswordBox.Password;

                    context.Users.AddOrUpdate(_user);
                    context.SaveChanges();
                }

                UsernameTextBox.Clear();
                PasswordBox.Clear();
                RepeatPasswordBox.Clear();
                OldPasswordBox.Clear();
                ErrorLabel.Content = "Successfully Changed Password !";
            }
            else
            {
                ErrorLabel.Content = Checks.PasswordsDoNotMatch;
            }
        }
 public LoginWindow()
 {
     InitializeComponent();
     UsernameTextBox.Focus();
     _notifyIcon = UIHelper.CreateNotifyIconForTray();
     _notifyIcon.MouseDoubleClick += _notifyIcon_MouseDoubleClick;
 }
示例#8
0
 private void SaveUser()
 {
     if (isEditing)
     {
         var currentUser = userBindingSource.Current as User;
         if (currentUser != null)
         {
             currentUser.Username = UsernameTextBox.Text;
             currentUser.Password = encryptor.GetEncrypted(PasswordTextBox.Text);
             currentUser.Role     = (Role)RoleComboBox.SelectedItem;
         }
     }
     else
     {
         var user = new User
         {
             Username = UsernameTextBox.Text,
             Password = encryptor.GetEncrypted(PasswordTextBox.Text),
             Role     = (Role)RoleComboBox.SelectedItem
         };
         context.Users.Add(user);
     }
     context.SaveChanges();
     EditUser(false);
     UsernameTextBox.Clear();
     PasswordTextBox.Clear();
 }
示例#9
0
        private void ResetButton_Click(object sender, System.EventArgs e)
        {
            PasswordTextBox.Text = string.Empty;
            UsernameTextBox.Text = string.Empty;

            UsernameTextBox.Focus();
        }
示例#10
0
 private void LoginScreen_Load(object sender, EventArgs e)
 {
     UsernameTextBox.Select();
     //If the file exists, and there are users in the file
     if (File.Exists(path) && new FileInfo(path).Length > 0)
     {
         //Every line is split using the $. Each part is stored to userInfo and corresponds to a user;s username, level, etc.
         foreach (var line in File.ReadLines(path))
         {
             char[]   seperator = { '$' };
             string[] userInfo  = line.Split(seperator, 5);
             bool     exists    = false;
             //The following loads the users from the text file to the List.
             //It searches the whole List. If the user is not found there, it adds the user found in the specific line of file to the List. Then goes to the next line etc.
             foreach (user u in users)
             {
                 if (userInfo[0] == u.Username)
                 {
                     exists = true;
                 }
             }
             if (!exists)
             {
                 users.Add(new user(userInfo[0], int.Parse(userInfo[1]), int.Parse(userInfo[2]), DateTime.Parse(userInfo[3]), int.Parse(userInfo[4])));
             }
         }
     }
 }
示例#11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         UsernameTextBox.Focus();
     }
 }
示例#12
0
        public MainWindow()
        {
            InitializeComponent();
            UsernameTextBox.Focus();
            _userLogic = new UserLogic();
            KeyDown   += OnEnterDownHandler;
            if (File.Exists("MyConfig.xml"))
            {
                string        username = "", password = "";
                XmlTextReader reader = new XmlTextReader("MyConfig.xml");
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        switch (reader.Name)
                        {
                        case "UserName":
                            reader.Read();
                            username = reader.Value;
                            break;

                        case "Password":
                            reader.Read();
                            password = reader.Value;
                            break;
                        }
                    }
                }
                reader.Close();
                if (!_userLogic.LoginButton_ClickLogic(username, password, this))
                {
                    File.Delete("MyConfig.xml");
                }
            }
        }
示例#13
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            if (Username.Length == 0)
            {
                UsernameTextBox.Focus();
                return;
            }
            if (Password.Length == 0)
            {
                PasswordTextBox.Focus();
                return;
            }

            string macAddress = MacAddress;

            if (macAddress != null && macAddress != HardwareHash.Empty && !macAddressRegex.IsMatch(macAddress))
            {
                MacAddressTextBox.Focus();
                return;
            }

            if (HasProxy)
            {
                int port;
                if (int.TryParse(ProxyPortTextBox.Text.Trim(), out port) && port >= 0 && port <= 65535)
                {
                    ProxyPort    = port;
                    DialogResult = true;
                }
            }
            else
            {
                DialogResult = true;
            }
        }
示例#14
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new ExpansesManagerContext())
            {
                if (context.Users.Any(u => u.Username == UsernameTextBox.Text && u.Password == PasswordBox.Password))
                {
                    MessageBox.Show("Successfully logged in!");
                }
                else
                {
                    ErrorLabel.Content = ("Username or password is invalid.");
                    return;
                }

                AuthenticationManager.Login(UsernameTextBox.Text, PasswordBox.Password);

                UsernameTextBox.Clear();
                PasswordBox.Clear();
            }

            MainApp mainApp = new MainApp();

            this.Close();
            mainApp.ShowDialog();
        }
示例#15
0
 private void OK_Click(object sender, EventArgs e)
 {
     // Make sure the user entered something.
     if (UsernameTextBox.Text.Length == 0)
     {
         MessageBox.Show("You must enter a user name");
         UsernameTextBox.Focus();
     }
     else if (PasswordTextBox.Text.Length == 0)
     {
         MessageBox.Show("You must enter a password");
         PasswordTextBox.Focus();
     }
     else if (!PasswordValid(UsernameTextBox.Text, PasswordTextBox.Text))
     {
         // The user name/password is invalid.
         MessageBox.Show("User name/password invalid");
         UsernameTextBox.Focus();
     }
     else
     {
         // The user name/password is valid.
         DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
 }
示例#16
0
 public void GivenILoginToAnyXeroOrganisation()
 {
     _driver.Navigate().GoToUrl(AppConfig.Url);
     UsernameTextBox.SendKeys(TestData.LoginDetails.Email);
     PasswordTextBox.SendKeys(TestData.LoginDetails.Password);
     LoginButton.Click();
 }
示例#17
0
        private void LoginUser()
        {
            List <Account> accounts = Admin.GetCurrentDatabase();

            Account loggedInAccount = null;

            foreach (Account account in accounts)
            {
                if (account.Username == UsernameTextBox.Text && account.Password == PasswordTextBox.Text)
                {
                    loggedInAccount = account;
                    break;
                }
            }

            if (loggedInAccount != null)
            {
                MessageBox.Show("Welcome", "Login Succesful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                UsernameTextBox.Text = "";
                PasswordTextBox.Text = "";
                UsernameTextBox.Focus();

                //Hide the login screen, open the text editor and send the account object to the next login screen.
                Hide();
                TextEditor textEditor = new TextEditor();
                textEditor.MyAccount = loggedInAccount;
                textEditor.Show(this);
            }
            else
            {
                MessageBox.Show("Incorrect Username/Password or Account does not exist.", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PasswordTextBox.Text = "";
            }
        }
示例#18
0
 private void UsernameTextBox_GotFocus(object sender, RoutedEventArgs e)
 {
     UsernameTextBox.SelectAll();
     ErrorUsernameTextBlock.Visibility = Visibility.Collapsed;
     ErrorProviderTextBlock.Visibility = Visibility.Collapsed;
     //SetTextBlockVisibilityCollapsed();
 }
示例#19
0
 private void Window_Activated(object sender, EventArgs e)
 {
     if (UsernameTextBox.Text == "")
     {
         UsernameTextBox.Focus();
     }
 }
示例#20
0
 private void LoginButton_Click(object sender, RoutedEventArgs e)
 {
     if (Username.Length == 0)
     {
         UsernameTextBox.Focus();
         return;
     }
     if (Password.Length == 0)
     {
         PasswordTextBox.Focus();
         return;
     }
     if (HasProxy)
     {
         int port;
         if (int.TryParse(ProxyPortTextBox.Text.Trim(), out port) && port >= 0 && port <= 65535)
         {
             ProxyPort    = port;
             DialogResult = true;
         }
     }
     else
     {
         DialogResult = true;
     }
 }
示例#21
0
        private void SignIn_Click(object sender, RoutedEventArgs e)
        {
            UserController CallUser = new UserController();

            if (UsernameTextBox.Text.Length == 0 && PasswordTextBox.Password.Length == 0)
            {
                UsernameErrorMessage.Text = "You Must Enter Valid Username!";
                PasswordErrorMessage.Text = "You Must Enter Password!";
                PasswordTextBox.Focus();
                UsernameTextBox.Focus();
            }
            else if (UsernameTextBox.Text.Length == 0)
            {
                UsernameErrorMessage.Text = "You Must Enter Valid Username!";
                UsernameTextBox.Focus();
            }
            else if (PasswordTextBox.Password.Length == 0)
            {
                PasswordErrorMessage.Text = "You Must Enter Password!";
                PasswordTextBox.Focus();
            }
            else
            {
                string username = UsernameTextBox.Text;
                string password = PasswordTextBox.Password;

                CallUser.UserLogin(username, password);
                this.Hide();
                Home home = new Home(username);
                home.Show();
            }
        }
示例#22
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.viewModel = (MainViewModel)this.DataContext;

            UsernameTextBox.Text = "Wizard " + new Random().Next(0, 100);
            UsernameTextBox.Focus();
            UsernameTextBox.SelectAll();
        }
示例#23
0
        public HomePage SignIn(string username, string password)
        {
            UsernameTextBox.SetText(username);
            PasswordTextBox.SetText(password);
            LoginButton.Click();

            return(Navigate(this).PostBack <HomePage>(WebDriver));
        }
 private void PlaceCursorInLoginTextBox()
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input,
                            new Action(delegate() {
         UsernameTextBox.Focus();
         Keyboard.Focus(UsernameTextBox);
     }));
 }
示例#25
0
 private void UpdateView(OperationResult operationResult)
 {
     if (!operationResult.Succeed)
     {
         UsernameTextBox.Focus();
         MessageBox.Show(operationResult.Message);
     }
 }
示例#26
0
        public UserCreationView()
        {
            InitializeComponent();
            Loaded += OnLoaded;

            UsernameTextBox.GotFocus += (_, __) => UsernameTextBox.SelectAll();
            PasswordBox1.GotFocus    += (_, __) => PasswordBox1.SelectAll();
            PasswordBox2.GotFocus    += (_, __) => PasswordBox2.SelectAll();
        }
 public LoginWindow()
 {
     InitializeComponent();
     //if (GlobalSettings.Startuped)
     //    closeButton.Visibility = Visibility.Visible;
     //else
     //    closeButton.Visibility = Visibility.Hidden;
     UsernameTextBox.Focus();
 }
示例#28
0
 public WalletWindow()
 {
     InitializeComponent();
     UsernameTextBox.Focus();
     _notifyIcon              = UIHelper.CreateNotifyIconForTray();
     _notifyIcon.DoubleClick += _notifyIcon_DoubleClick;
     _statusBarOperationMessageStoryBoard = Resources["operationStatusStoryboard"] as Storyboard;
     Messenger.Default.Register <BalanceChangedMessage>(this, BalanceChanged_Handler);
 }
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            UsernameTextBox.Focus();
            UsernameTextBox.SelectAll();

            IRequestFocus focus = (IRequestFocus)DataContext;

            focus.FocusRequested += OnFocusRequested;
        }
示例#30
0
        /**
         * login button - check username and password
         */
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string username = UsernameTextBox.Text;
            string password = PasswordBox.Password;

            UsernameTextBox.Text = "";
            PasswordBox.Password = "";
            UsernameTextBox.Focus();
            _userLogic.LoginButton_ClickLogic(username, password, this);
        }