Ejemplo n.º 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();
     }
 }
Ejemplo n.º 2
0
 private void LoginFailed()
 {
     UsernameTextBox.Focus();
     UsernameTextBox.Background    = _errorColorBrush;
     PasswordBox.Background        = _errorColorBrush;
     LoginFailedMessage.Visibility = Visibility.Visible;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 7
0
 public LoginWindow()
 {
     InitializeComponent();
     UsernameTextBox.Focus();
     _notifyIcon = UIHelper.CreateNotifyIconForTray();
     _notifyIcon.MouseDoubleClick += _notifyIcon_MouseDoubleClick;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 9
0
        private void ResetButton_Click(object sender, System.EventArgs e)
        {
            PasswordTextBox.Text = string.Empty;
            UsernameTextBox.Text = string.Empty;

            UsernameTextBox.Focus();
        }
Ejemplo n.º 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])));
             }
         }
     }
 }
Ejemplo n.º 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         UsernameTextBox.Focus();
     }
 }
Ejemplo n.º 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");
                }
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 16
0
 public void GivenILoginToAnyXeroOrganisation()
 {
     _driver.Navigate().GoToUrl(AppConfig.Url);
     UsernameTextBox.SendKeys(TestData.LoginDetails.Email);
     PasswordTextBox.SendKeys(TestData.LoginDetails.Password);
     LoginButton.Click();
 }
Ejemplo n.º 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 = "";
            }
        }
Ejemplo n.º 18
0
 private void UsernameTextBox_GotFocus(object sender, RoutedEventArgs e)
 {
     UsernameTextBox.SelectAll();
     ErrorUsernameTextBlock.Visibility = Visibility.Collapsed;
     ErrorProviderTextBlock.Visibility = Visibility.Collapsed;
     //SetTextBlockVisibilityCollapsed();
 }
Ejemplo n.º 19
0
 private void Window_Activated(object sender, EventArgs e)
 {
     if (UsernameTextBox.Text == "")
     {
         UsernameTextBox.Focus();
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
     }));
 }
Ejemplo n.º 25
0
 private void UpdateView(OperationResult operationResult)
 {
     if (!operationResult.Succeed)
     {
         UsernameTextBox.Focus();
         MessageBox.Show(operationResult.Message);
     }
 }
Ejemplo n.º 26
0
        public UserCreationView()
        {
            InitializeComponent();
            Loaded += OnLoaded;

            UsernameTextBox.GotFocus += (_, __) => UsernameTextBox.SelectAll();
            PasswordBox1.GotFocus    += (_, __) => PasswordBox1.SelectAll();
            PasswordBox2.GotFocus    += (_, __) => PasswordBox2.SelectAll();
        }
Ejemplo n.º 27
0
 public LoginWindow()
 {
     InitializeComponent();
     //if (GlobalSettings.Startuped)
     //    closeButton.Visibility = Visibility.Visible;
     //else
     //    closeButton.Visibility = Visibility.Hidden;
     UsernameTextBox.Focus();
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }