コード例 #1
0
 private void EnterButton_Click(object sender, EventArgs e)
 {
     using
     (SqlConnection connection = new SqlConnection(connectionString))
     {
         try
         {
             connection.Open();
         }
         catch
         {
             MessageBox.Show("Ошибка подключения к базе данных", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         SqlCommand requestauth = new SqlCommand("SELECT dbo.AuthUser('" +
                                                 LoginTextbox.Text + "','" + PasswordTextbox.Text + "')", connection);
         string result = requestauth.ExecuteScalar().ToString();
         connection.Close();
         if (result == "Fail")
         {
             MessageBox.Show("Неверный логин или пароль", "Ошибка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             InitiateNewForm(result);
             this.Hide();
         }
         LoginTextbox.Clear();
         PasswordTextbox.Clear();
         LoginTextbox.Focus();
     }
 }
        private void UsernameTextbox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                if (UsernameTextbox.Text.Length <= 0 && PasswordTextbox.Text.Length <= 0)
                {
                    LoginButton_Click(sender, e);
                }

                else if (UsernameTextbox.Text.Length > 0 && PasswordTextbox.Text.Length <= 0)
                {
                    PasswordTextbox.Focus();
                }

                else if (UsernameTextbox.Text.Length <= 0 && PasswordTextbox.Text.Length > 0)
                {
                    LoginButton_Click(sender, e);
                }

                else if (UsernameTextbox.Text.Length > 0 && PasswordTextbox.Text.Length > 0)
                {
                    LoginButton_Click(sender, e);
                }
            }

            else if (e.KeyData == Keys.F12)
            {
                SqlServerSettingsButton_Click(sender, e);
            }

            else if (e.KeyData == Keys.Escape)
            {
                this.Close();
            }
        }
コード例 #3
0
 private void PasswordTextbox_Leave(object sender, EventArgs e)
 {
     PasswordTextbox.AddText(PasswordPlaceholder);
     if (String.IsNullOrWhiteSpace(PasswordTextbox.Text) || PasswordTextbox.Text == PasswordPlaceholder)
     {
         PasswordTextbox.PasswordChar = '\0';
     }
 }
        private void ResetLoginFormState()
        {
            UsernameTextbox.Focus();
            UsernameTextbox.ResetText();
            PasswordTextbox.ResetText();

            LoginErrorMessage.Visible  = false;
            LoginErrorMessage.Location = new Point(141, 134);
        }
コード例 #5
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!String.Equals(PasswordTextbox.Text, ConfirmTextbox.Text))
            {
                label13.Text    = "Passwords Must Match";
                label13.Visible = true;
            }
            else
            {
                string str = Properties.Settings.Default.DefaultConnection;

                SqlConnection con = new SqlConnection
                {
                    ConnectionString = str
                };
                con.Open();
                SqlCommand cmd = new SqlCommand("Insert into Employee(SSN, FirstName, LastName, City, State, " +
                                                "ZipCode, Email, Password, Telephone, StartDate, HourlyRate, Type) " +
                                                "Values(@SSN, @FirstName, @LastName, @City, @State, @ZipCode, @Email, @Password, @Telephone, @AccountCreationDate, " +
                                                "@HourlyRate, @AccountType)", con);
                cmd.Parameters.AddWithValue("@SSN", SSNTextbox.Text);
                cmd.Parameters.AddWithValue("@FirstName", FirstNameTextbox.Text);
                cmd.Parameters.AddWithValue("@LastName", LastNameTextbox.Text);
                cmd.Parameters.AddWithValue("@City", CityTextbox.Text);
                cmd.Parameters.AddWithValue("@State", StateTextbox.Text);
                cmd.Parameters.AddWithValue("@ZipCode", ZipTextbox.Text);
                cmd.Parameters.AddWithValue("@Email", EmailTextbox.Text);
                cmd.Parameters.AddWithValue("@Password", PasswordTextbox.Text);
                cmd.Parameters.AddWithValue("@Telephone", TelephoneTextbox.Text);
                cmd.Parameters.AddWithValue("@AccountCreationDate", DateTime.Now.Date);
                cmd.Parameters.AddWithValue("@HourlyRate", HourlyWageTextBox.Text);
                cmd.Parameters.AddWithValue("@AccountType", comboBox1.Text);

                cmd.ExecuteNonQuery();
                label13.Text    = "Successfully Added " + FirstNameTextbox.Text + " " + LastNameTextbox.Text;
                label13.Visible = true;

                //Clear the textboxes
                SSNTextbox.Clear();
                FirstNameTextbox.Clear();
                FirstNameTextbox.Clear();
                LastNameTextbox.Clear();
                CityTextbox.Clear();
                StateTextbox.Clear();
                ZipTextbox.Clear();
                EmailTextbox.Clear();
                PasswordTextbox.Clear();
                ConfirmTextbox.Clear();
                TelephoneTextbox.Clear();
                HourlyWageTextBox.Clear();
                comboBox1.SelectedIndex = -1;
            }
        }
コード例 #6
0
 private void SetPassword(string Password)
 {
     try
     {
         Console.WriteLine("Is Password textbox displayed? {0}", PasswordTextbox.Displayed);
         PasswordTextbox.Clear();
         PasswordTextbox.SendKeys(Password);
     }
     catch (Exception e)
     {
         Logger.Error("Error: ", e);
         throw (e);
     }
 }
コード例 #7
0
ファイル: mainwindow.xaml.cs プロジェクト: ciker/wpf
        private void rect_window_fadein()
        {
            DoubleAnimation fadingAnimation = new DoubleAnimation();

            fadingAnimation.From     = 0;
            fadingAnimation.To       = 1;
            fadingAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));

            LoginRectangle.BeginAnimation(Rectangle.OpacityProperty, fadingAnimation);
            LoginButton.BeginAnimation(Button.OpacityProperty, fadingAnimation);
            ExitRectangle.BeginAnimation(Button.OpacityProperty, fadingAnimation);
            UsernameTextbox.BeginAnimation(TextBox.OpacityProperty, fadingAnimation);
            PasswordTextbox.BeginAnimation(TextBox.OpacityProperty, fadingAnimation);
        }
コード例 #8
0
        private void LoginPage_Loaded(object sender, RoutedEventArgs e)
        {
            // Automatically insert the user name last entered as the login, retrieved
            // from isolated storage
            UserNameTextbox.Text = ConfigurationSettings.LastUserName;

            if (string.IsNullOrEmpty(UserNameTextbox.Text))
            {
                UserNameTextbox.Focus();
            }
            else
            {
                PasswordTextbox.Focus();
            }
        }
コード例 #9
0
        //------------------------------ Private --------------------------------------
        void loginPageLoaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Browser.HtmlPage.Plugin.Focus();
            UserNameTextbox.Focus();
            //var _tbap = new TextBoxAutomationPeer(UserNameTextbox);
            //( (IValueProvider) _tbap ).SetValue("?");
            // Automatically insert the user name last entered as the login, retrieved from isolated storage
            //UserNameTextbox.Text = ConfigurationSettings.LastUserName;

            if (UserNameTextbox.Text.Length == 0)
            {
                UserNameTextbox.Focus();
            }
            else
            {
                PasswordTextbox.Focus();
            }
        }
コード例 #10
0
        private void ClearForm()
        {
            if (UserId == 0)
            {
                IdTextbox.Text = "0";
                UsernameTextbox.Clear();
                FirstnameTextbox.Clear();
                LastnameTextbox.Clear();
                PasswordTextbox.Clear();
                ConfirmTextbox.Clear();
                IsAdminCheckbox.Checked    = false;
                IsApproverCheckbox.Checked = false;
                IsVisitorCheckbox.Checked  = false;
            }
            else
            {
                LoadUserDetails();
            }

            passwordNotMatch = false;
        }
コード例 #11
0
ファイル: mainwindow.xaml.cs プロジェクト: ciker/wpf
        private void PasswordTextbox_TextChanged(object sender, TextChangedEventArgs e)
        {
            //if textbox contains characters
            if ((PasswordTextbox.Text.Length > 0) && (!PasswordTextbox.Text.Equals("Password")) && (!IsStringAllAsterisk(PasswordTextbox.Text)))
            {
                //append last character in textbox to variable
                Password += PasswordTextbox.Text[PasswordTextbox.Text.Length - 1].ToString();
                //Password.Insert((PasswordTextbox.Text.Length - 1), PasswordTextbox.Text[PasswordTextbox.Text.Length - 1].ToString());

                //change all textbox' characters to asterisks
                int tempNumAsterisks = PasswordTextbox.Text.Length;
                PasswordTextbox.Text = "";
                for (int i = 0; i < tempNumAsterisks; i++)
                {
                    PasswordTextbox.Text += "*";
                }

                PasswordTextbox.Focus();
                PasswordTextbox.SelectionStart = 9;
                PasswordTextbox.SelectionLength++;
            }
        }
コード例 #12
0
 private void PasswordTextbox_Enter(object sender, EventArgs e)
 {
     PasswordTextbox.RemoveText(PasswordPlaceholder);
     PasswordTextbox.PasswordChar = '●';
 }
コード例 #13
0
 private void ClearForm()
 {
     NameTextBox.Clear();
     PasswordTextbox.Clear();
 }
コード例 #14
0
ファイル: LoginPage.cs プロジェクト: VuPhamCongMinh/DoAn_TMDT
 public void NhapThongTinVaoPasswordTextBox(string VanBanDeNhapVao) => PasswordTextbox.SendKeys(VanBanDeNhapVao);
コード例 #15
0
 public void Login(string username, string password)
 {
     EmailTextbox.SendKeys(username);
     PasswordTextbox.SendKeys(password);
     SubmitButton.Click();
 }
コード例 #16
0
        void ReleaseDesignerOutlets()
        {
            if (CreateUserButton != null)
            {
                CreateUserButton.Dispose();
                CreateUserButton = null;
            }

            if (EmailAddress != null)
            {
                EmailAddress.Dispose();
                EmailAddress = null;
            }

            if (EmailTextbox != null)
            {
                EmailTextbox.Dispose();
                EmailTextbox = null;
            }

            if (LastnameLabel != null)
            {
                LastnameLabel.Dispose();
                LastnameLabel = null;
            }

            if (LastnameTextbox != null)
            {
                LastnameTextbox.Dispose();
                LastnameTextbox = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (NameTextbox != null)
            {
                NameTextbox.Dispose();
                NameTextbox = null;
            }

            if (PasswordLabel != null)
            {
                PasswordLabel.Dispose();
                PasswordLabel = null;
            }

            if (PasswordTextbox != null)
            {
                PasswordTextbox.Dispose();
                PasswordTextbox = null;
            }

            if (PhoneNumberLabel != null)
            {
                PhoneNumberLabel.Dispose();
                PhoneNumberLabel = null;
            }

            if (PhoneTextbox != null)
            {
                PhoneTextbox.Dispose();
                PhoneTextbox = null;
            }

            if (UserNameLabel != null)
            {
                UserNameLabel.Dispose();
                UserNameLabel = null;
            }

            if (UserNameTextbox != null)
            {
                UserNameTextbox.Dispose();
                UserNameTextbox = null;
            }
        }
コード例 #17
0
 private void buttonClear_Click(object sender, EventArgs e)
 {
     PasswordTextbox.Clear();
 }
コード例 #18
0
 private void ClearText()
 {
     UserTextbox.Clear();
     PasswordTextbox.Clear();
 }
コード例 #19
0
ファイル: LoginPage.cs プロジェクト: mmachidon/UITest_MM
 private void SetPassword(string Password)
 {
     Logger.InfoFormat("Is username box displayed? {0}", PasswordTextbox.Displayed);
     PasswordTextbox.Clear();
     PasswordTextbox.SendKeys(Password);
 }