private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                if (UsernameInput.IsFocused)
                {
                    PasswordInput.Focus();
                }
                else if (PasswordInput.IsFocused)
                {
                    LoginButton.Focus();
                    SendKeys.SendWait("{Enter}");
                }
            }

            else
            {
                if (System.Windows.Forms.Control.IsKeyLocked(Keys.CapsLock))
                {
                    CapsCheck.Visibility = Visibility.Visible;
                    Jim.Background       = Brushes.Red;
                    Bob.Background       = Brushes.Green;
                }
                else
                {
                    // System.Windows.MessageBox.Show("The Caps Lock key is OFF.");
                    CapsCheck.Visibility = Visibility.Collapsed;
                    Jim.Background       = Brushes.DarkTurquoise;
                    Bob.Background       = Brushes.PaleVioletRed;
                }
            }
        }
 /// <summary>
 /// Handle the focus between elements when Enter is pressed
 /// </summary>
 private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (UserInput.IsFocused && UserInput.Text.Length != 0 && PasswordInput.Password.Length == 0)
         {
             PasswordInput.Focus();
         }
         else
         {
             LoginButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
         }
     }
 }
 //View 1 items
 protected void Nextv1_Click(object sender, EventArgs e)
 {
     //Must have a username and password entered
     if (UsernameInput.Text == "")
     {
         Status.Text = "Must input a username.";
         UsernameInput.Focus();
         return;
     }
     else if (PasswordInput.Text == "")
     {
         Status.Text = "Must input a password.";
         PasswordInput.Focus();
         return;
     }
     //"Login" and move to next view
     Status.Text         = "Successfully logged in.";
     Session["username"] = UsernameInput.Text;
     MultiView.ActiveViewIndex++;
 }
Exemple #4
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Connect to Data Base
                SQLiteDatabase db = new SQLiteDatabase();

                //Data Table login that Have All Queries From DB
                DataTable Login;

                //Query to Get Username & Password and Compare them In Db if Found!
                String query = "select * from Login where username='******' and password='******'";

                //Put this information from DB to DataTable = login;
                Login = db.GetDataTable(query);

                //select grade,  username, password
                string grade = "select grade from Login where username='******' ";
                string user  = "******" + this.UsernameInput.Text + "' ";
                string pass  = "******" + this.PasswordInput.Password + "' ";

                //Assign (grade, username, password) to local variables (g, u, p)
                string g = db.ExecuteScalar(grade);
                string u = db.ExecuteScalar(user);
                string p = db.ExecuteScalar(pass);



                //Test if the inputs informations NOT Match to Database Informations ( mdified )

                if (this.UsernameInput.Text == u)
                {
                    if (this.PasswordInput.Password == p)
                    {
                        foreach (DataRow r in Login.Rows)
                        {
                            MessageBox.Show("WELCOME " + g + " " + UsernameInput.Text, "successful", MessageBoxButton.OK, MessageBoxImage.Information);
                            MainWindow admin = new MainWindow();
                            admin.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("invalid Password ");


                        PasswordInput.Clear();
                        PasswordInput.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("F**k you TryCatch Invalid Password or Username");
                    UsernameInput.Clear();
                    PasswordInput.Clear();
                    UsernameInput.Focus();
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
        }
Exemple #5
0
 public PasswordWindow()
 {
     InitializeComponent();
     PasswordInput.Focus();
 }
Exemple #6
0
 private void ImgShowHide_PreviewMouseUp(object sender, MouseEventArgs e)
 {
     HidePassword();
     PasswordInput.Focus();
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     PasswordInput.Focus();
 }