コード例 #1
0
 private void LoginButtonLoginWindow_Click(object sender, RoutedEventArgs e)
 {
     if (!_repo.AreThereAnyUsers())
     {
         MessageBox.Show("No any user in system! \nPlease, register");
         return;
     }
     if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
     {
         MessageBox.Show("Please, enter email!");
         EmailTextBox.Focus();
         return;
     }
     if (string.IsNullOrWhiteSpace(PasswordTextBox.Password))
     {
         MessageBox.Show("Please, enter password!");
         PasswordTextBox.Focus();
         return;
     }
     if (_repo.AutentificateUser(EmailTextBox.Text, User.GetHash(PasswordTextBox.Password)) == null)
     {
         MessageBox.Show("No such user! \nCheck your credentials or register in the system");
     }
     else
     {
         MainWindow mainWindow = new MainWindow(_repo, _repo.AutentificateUser(EmailTextBox.Text, User.GetHash(PasswordTextBox.Password)));
         mainWindow.Show();
         this.Close();
     }
 }
コード例 #2
0
ファイル: CreateUser.cs プロジェクト: kblood/QuizMaster_WCF
 /// <summary>
 /// When enter is pressed, while the usernameTextBox is in focus, move the focus on.
 /// </summary>
 private void UsernameTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Enter)
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #3
0
 private void ButtonDangKy_Click(object sender, RoutedEventArgs e)
 {
     if (TaiKhoanTextBox.Text.Length == 0)
     {
         MessageBox.Show("Vui lòng nhập tên tài khoản", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
         TaiKhoanTextBox.Focus();
     }
     else if (PasswordTextBox.Password.Length == 0)
     {
         MessageBox.Show("Vui lòng nhập mật khẩu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
         PasswordTextBox.Focus();
     }
     else if (RepasswordTextBox.Password.Length == 0)
     {
         MessageBox.Show("Vui lòng xác nhận lại mật khẩu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
         RepasswordTextBox.Focus();
     }
     else if (PasswordTextBox.Password.ToString() != RepasswordTextBox.Password.ToString())
     {
         MessageBox.Show("Mật khẩu không trùng khớp", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
         RepasswordTextBox.Focus();
     }
     else
     {
         SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MyShop;Integrated Security=True");
         con.Open();
         SqlCommand cmd = new SqlCommand("Insert into Account(username,rolename,Matkhau,HoTen,DiaChi,SDT,Email) values ('" + TaiKhoanTextBox.Text + "','guess', '" + PasswordTextBox.Password.ToString() + "','" + HoTenTextBox.Text + "','" + DiaChiTextBox.Text + "','" + SDTTextBox.Text + "','" + EmailTextBox.Text + "')");
         cmd.CommandType = System.Data.CommandType.Text;
         cmd.ExecuteNonQuery();
         con.Close();
         MessageBox.Show("Đăng ký thành công.", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
         NhapLaiLuonNeBanOi();
     }
 }
コード例 #4
0
 private void UsernameTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13) // focus Password field when enter key pressed
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #5
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();
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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;
     }
 }
コード例 #8
0
ファイル: Form1.cs プロジェクト: NiranjanKumbhar/VisualC-
        /*
         * Event Handler for Submit Button for Password
         * -Validate password
         * -If failed, counter add 1 to the Counter
         * -If counter is equals to Allowed attempts, Application will close
         */
        private void PasswordSubmitButton_Click(object sender, EventArgs e)
        {
            if (PasswordTextBox.Text != STOREDPASSWORD)
            {
                //Increasing the count
                PasswordCounter += 1;
                if (PasswordCounter == PASSWORDATTEMPTS)
                {
                    MessageBox.Show("You have used all password attemps. Application will close now", "Invalid Passowrd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("\tInvalid Password. \n\n " + (PASSWORDATTEMPTS - PasswordCounter).ToString() + " attempt(s) remaining out of " + PASSWORDATTEMPTS, "Invalid Passowrd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    PasswordTextBox.Focus();
                    PasswordTextBox.SelectAll();
                }
            }
            else
            {
                //If Password is correct, Checking for file and enabling Summary and Search Button
                //if no records present in the file, buttons will be disabled
                if (GetSummaryDetails(true) == 0)
                {
                    SummaryButton.Enabled = false;
                    SearchButton.Enabled  = false;
                }

                //Hiding Panels and Displaying Price
                PasswordPanel.Visible   = false;
                PricingGroupBox.Visible = true;
                ButtonPanel.Visible     = true;
                TermTextBox.Focus();
            }
        }
コード例 #9
0
        private void ProfileComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ProfileComboBox.Items.Count == 0)
            {
                return;
            }

            EnsureCorrectButtonStates();

            if (ProfileComboBox.SelectedItem is ProfileInfo)
            {
                PasswordExpander.IsExpanded = true;
                PasswordTextBox.Focus();
                return;
            }

            CreateProfileForm createProfileForm = new CreateProfileForm();

            createProfileForm.ShowDialog();
            createProfileForm.Close();

            if (createProfileForm.CreatedProfile != null)
            {
                _loadedProfiles.Add(createProfileForm.CreatedProfile);
            }

            FillUI(_loadedProfiles);
        }
コード例 #10
0
 private void LoginTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key.Equals(Windows.System.VirtualKey.Enter))
     {
         PasswordTextBox.Focus(FocusState.Programmatic);
     }
 }
コード例 #11
0
ファイル: frmLogin.cs プロジェクト: JiaquanLi/F001716
 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();
     }
 }
コード例 #12
0
ファイル: LoginForm.cs プロジェクト: zebaoth666/BarcodeVigano
 private bool IsValidated()
 {
     try {
         if ((_LoginType != LoginType.AdminLogin) && (OrganizationComboBox.SelectedIndex == -1))
         {
             MessageBox.Show(this, "Please select the Organization.", _ApplicationName.Length > 0 ? _ApplicationName : DefaultApplicationInfo.FullApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             OrganizationComboBox.Focus();
             OrganizationComboBox.DroppedDown = true;
             return(false);
         }
         if (UserNameTextBox.Text.Length == 0)
         {
             MessageBox.Show(this, "Please enter the user name.", _ApplicationName.Length > 0 ? _ApplicationName : DefaultApplicationInfo.FullApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             UserNameTextBox.Focus();
             return(false);
         }
         if (PasswordTextBox.Text.Length == 0)
         {
             MessageBox.Show(this, "Please enter the password.", _ApplicationName.Length > 0 ? _ApplicationName : DefaultApplicationInfo.FullApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             PasswordTextBox.Focus();
             return(false);
         }
         return(true);
     } catch {
         throw;
     }
 }
コード例 #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
ファイル: Login.cs プロジェクト: jaymaxz/Press_Wiz
 private void UserNameTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if ((e.KeyCode == Keys.Enter))
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #15
0
 private void AccountTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #16
0
 private void RegisterButtonRegistrationWindow_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
     {
         MessageBox.Show("Email is not entered!");
         EmailTextBox.Focus();
     }
     else if (!_repo.IsEmailUnique(EmailTextBox.Text))
     {
         MessageBox.Show("User with such email already exists. \nEmail should be unique!");
         return;
     }
     else if (string.IsNullOrWhiteSpace(NameTextBox.Text))
     {
         MessageBox.Show("Full name is not entered!");
         NameTextBox.Focus();
     }
     else if (string.IsNullOrWhiteSpace(PasswordTextBox.Password))
     {
         MessageBox.Show("Password is not entered");
         PasswordTextBox.Focus();
     }
     else
     {
         _repo.CreateNewUser(NameTextBox.Text, EmailTextBox.Text, PasswordTextBox.Password);
         DialogResult = true;
     }
 }
コード例 #17
0
ファイル: LoginForm.cs プロジェクト: OutofSkills/Agenda
 private void UsernameTextBox_Enter(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #18
0
        private void YesButton_Click(object sender, RoutedEventArgs e)
        {
            var user     = UserComboBox.Text.Trim();
            var password = PasswordTextBox.Password.Trim();

            ErrorTextBlock.Text = string.Empty;
            if (string.IsNullOrEmpty(user))
            {
                ErrorTextBlock.Text = "用户不能为空";
                UserComboBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(password))
            {
                ErrorTextBlock.Text = "密码不能为空";
                PasswordTextBox.Focus();
                return;
            }

            if (!PermissionService.Login(user, password))
            {
                ErrorTextBlock.Text = "用户或密码错误";
                UserComboBox.Focus();
                return;
            }

            var loginUsers = Activator.ConfigurationService.Get(Activator.Bundle, "LoginUsers", string.Empty);

            if (string.IsNullOrEmpty(loginUsers)) // 如果为空,则直接存储
            {
                loginUsers = user;
                // 保存
                Activator.ConfigurationService.Set(Activator.Bundle, "LoginUsers", loginUsers);
            }
            else
            {
                // 如果当前用户与登录用户不相同或者当前用户的最后一个用户与登录用户不同
                // 则需要将当前登录用户放在最后
                if (!loginUsers.Equals(user) && !loginUsers.EndsWith(";" + user))
                {
                    if (loginUsers.Contains(user + ";")) // 当前登录用户是否在中间
                    {
                        loginUsers = loginUsers.Replace(user + ";", "");
                    }

                    loginUsers += ";" + user; // 放在最后
                    // 保存登录用户
                    Activator.ConfigurationService.Set(Activator.Bundle, "LoginUsers", loginUsers);
                }
            }

            var mainWindow = new MainWindow();

            Application.Current.MainWindow = mainWindow;
            Application.Current.MainWindow.Show();

            Window.GetWindow(this).Close();
        }
コード例 #19
0
        private void EnterButton_Click(object sender, EventArgs e)
        {
            string password = "";

            if (LoginTextBox.Text == " " || PasswordTextBox.Text == " ")
            {
                MessageBox.Show("Не все поля заполнены");
                LoginTextBox.Focus();
            }
            int          count   = 0;
            string       command = "Select Пароль from Пользователи Where Имя_Пользователя = @login";
            SqlParameter p1      = new SqlParameter("login", LoginTextBox.Text);
            var          reader  = StaticProcesser.GetReader(command, p1);

            while (reader.Read())
            {
                count++;
                try
                {
                    password = reader.GetString(0);
                    password = password.Replace(Environment.NewLine, "");
                }
                catch (Exception ex)
                {
                    StaticHelper.ErrorNotifier(ex);
                }
            }
            if (count == 0)
            {
                MessageBox.Show("Такого пользователя не существует");
                LoginTextBox.Clear();
                LoginTextBox.Focus();
                PasswordTextBox.Clear();
                reader.Close();
                StaticProcesser.CloseConnection();
            }
            else if (count == 1)
            {
                reader.Close();
                StaticProcesser.CloseConnection();
                string inputedPass = StaticProcesser.ComputeHash(PasswordTextBox.Text, new MD5CryptoServiceProvider());
                if (password == inputedPass)
                {
                    User.Login  = LoginTextBox.Text;
                    User.Access = 1;
                    if (User.Login == "admin")
                    {
                        User.Access = 2;
                    }
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Пароль введён не верно");
                    PasswordTextBox.Clear();
                    PasswordTextBox.Focus();
                }
            }
        }
コード例 #20
0
 public MainWindow()
 {
     InitializeComponent();
     _view        = (CollectionView)CollectionViewSource.GetDefaultView(Entries);
     _view.Filter = ItemFilter;
     _encrypter   = new OneTimePad();
     PasswordTextBox.Focus();
 }
コード例 #21
0
 private void LoginTextBox_KeyUp(object sender,
                                 KeyEventArgs e)
 {
     if (e.Key == Key.Enter || e.Key == Key.Down)
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #22
0
 private void PseudoTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         e.Handled = true;
         PasswordTextBox.Focus(FocusState.Keyboard);
     }
 }
コード例 #23
0
 protected void Page_Load(object sender, EventArgs e)
 {
     PasswordTextBox.Attributes.Add("value", PasswordTextBox.Text);
     PasswordNuevaTextBox.Attributes.Add("value", PasswordNuevaTextBox.Text);
     ConfirmacionPasswordNuevaTextBox.Attributes.Add("value", ConfirmacionPasswordNuevaTextBox.Text);
     if (!IsPostBack)
     {
         PasswordTextBox.Focus();
     }
 }
コード例 #24
0
 private void ViewModelOnFocusRequested(object sender, FocusRequestedEventArgs e)
 {
     switch (e.PropertyName)
     {
     case "Password":
         PasswordTextBox.Focus();
         PasswordTextBox.SelectAll();
         break;
     }
 }
コード例 #25
0
        public ChangePasswordView(User user)
        {
            InitializeComponent();

            DataContext = new ChangePasswordViewModel(user)
            {
                Close = () => Close()
            };

            PasswordTextBox.Focus();
        }
コード例 #26
0
        public LockScreenForm()
        {
            InitializeComponent();
            Taskbar.Hide();
            Console.WriteLine(welcome);
            FormBorderStyle = FormBorderStyle.None;
            WindowState     = FormWindowState.Normal;
            StartPosition   = FormStartPosition.Manual;
            Location        = new Point(0, 0);
            Size            = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

            Image myimage = new Bitmap(getSpotlightImage());

            BackgroundImage = myimage;

            BackgroundImageLayout = ImageLayout.Stretch;
            TopMost = true;

            string userName = Environment.UserName;

            UserNameLabel.Text      = userName;
            UserNameLabel.BackColor = Color.Transparent;

            int usernameloch = (Convert.ToInt32(Screen.PrimaryScreen.Bounds.Height) / 100) * 64;
            int usericonh    = (Convert.ToInt32(Screen.PrimaryScreen.Bounds.Height) / 100) * 29;
            int buttonh      = (Convert.ToInt32(Screen.PrimaryScreen.Bounds.Height) / 100) * 64;
            int usernameh    = (Convert.ToInt32(Screen.PrimaryScreen.Bounds.Height) / 100) * 50;
            int locked       = (Convert.ToInt32(Screen.PrimaryScreen.Bounds.Height) / 100) * 57;

            if (!PasswordTextBox.Focus())
            {
                PasswordTextBox.Focus();
            }

            ActiveControl = PasswordTextBox;

            if (CanFocus)
            {
                Focus();
            }

            PasswordTextBox.Top = usernameloch;
            PasswordTextBox.UseSystemPasswordChar = true;
            ProfileIcon.Top          = usericonh;
            SubmitPasswordButton.Top = buttonh;
            UserNameLabel.Top        = usernameh;
            LockedLabel.Top          = locked;

            foreach (var screen in Screen.AllScreens)
            {
                Thread thread = new Thread(() => WorkThreadFunction(screen));
                thread.Start();
            }
        }
コード例 #27
0
 public TextInputDialog()
 {
     InitializeComponent();
     PasswordTextBox.KeyDown += (s, e) => { if (e.Key == Key.Enter)
                                            {
                                                Close();
                                            }
     };
     SubmitButton.Click += (s, e) => Close();
     PasswordTextBox.Focus();
 }
コード例 #28
0
        private void ValidateButton_Click(object sender, RoutedEventArgs e)
        {
            // Only adds if the label is unique and required fields are filled
            if (MyGlobals.Lista.Exists(x => x.DirectKey == LabelTextBox.Text))
            {
                Thread thread = new Thread(ShowRectangleLabelExists);
                thread.Start();

                LabelTextBox.Focus();
            }
            else
            {
                if (LoginTextBox.Text == String.Empty || LoginTextBox.Text == (String)LoginTextBox.Tag)
                {
                    Thread thread = new Thread(ShowRequiredFieldWarning);
                    thread.Start(ErrorFieldEmpty2);

                    LoginTextBox.Focus();
                }
                else
                {
                    if (LabelTextBox.Text == String.Empty || LabelTextBox.Text == (String)LabelTextBox.Tag)
                    {
                        Thread thread = new Thread(ShowRequiredFieldWarning);
                        thread.Start(ErrorFieldEmpty);

                        LabelTextBox.Focus();
                    }
                    else
                    {
                        if (PasswordTextBox.Text == String.Empty || PasswordTextBox.Text == (String)PasswordTextBox.Tag)
                        {
                            Thread thread = new Thread(ShowRequiredFieldWarning);
                            thread.Start(ErrorFieldEmpty3);

                            PasswordTextBox.Focus();
                        }
                        else
                        {
                            // Add entry to local list and database
                            AddEntry();

                            // Checks if temporary Item exists, if so clears it
                            if (MyGlobals.TemporaryItem.DirectKey != String.Empty)
                            {
                                MyGlobals.TemporaryItem = Items.Empty();
                            }

                            nav.Navigate(new System.Uri("InitialPage.xaml", UriKind.RelativeOrAbsolute));
                        }
                    }
                }
            }
        }
コード例 #29
0
        private void OnFocusRequested(object sender, FocusRequestedEventArgs e)
        {
            var viewModel = (MainWindowViewModel)DataContext;

            switch (e.PropertyName)
            {
            case nameof(viewModel.Password):
                PasswordTextBox.Focus();
                PasswordTextBox.SelectAll();
                break;
            }
        }
コード例 #30
0
 private void PasswordCueText_Click(object sender, EventArgs e)
 {
     if (PasswordTextBox.Text.Trim() == "")
     {
         PasswordCueText.Hide();
     }
     else if (PasswordTextBox.Text.Trim() != "" && PasswordCueText.Visible == false)
     {
         PasswordCueText.Hide();
     }
     PasswordTextBox.Focus();
 }