Ejemplo n.º 1
0
 private void TextBox_User_Id_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         TextBox_Password.Focus();
     }
 }
Ejemplo n.º 2
0
 protected void Button_Entrar_Click(object sender, EventArgs e)
 {
     if (TextBox_User.Text == " ")
     {
         TextBox_User.Focus();
     }
     else
     {
         if (TextBox_Password.Text == " ")
         {
             TextBox_Password.Focus();
         }
         else
         {
             Usuarios = Connect.Consultar1("Login", "UserName", TextBox_User.Text, "Password", TextBox_Password.Text);
             if (Usuarios)
             {
                 Session["usuario"] = Usuarios;
                 Response.Redirect("ControlColocacionMesclaz.aspx");
             }
             else
             {
                 Lable_Mensaje.Text = "Usuario o contraseña incorrectos";
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void BtEnter_Click(object sender, EventArgs e)
        {
            //Проверка на заполнение полей ввода
            switch (TextBox_Login.Text == "")
            {
            case true:
                TextBox_Login.BackColor = Color.Red;
                break;

            case false:
                switch (TextBox_Password.Text == "")
                {
                case true:
                    TextBox_Password.BackColor = Color.Red;
                    break;

                case false:
                    Function_Class function = new Function_Class();
                    //Прохождение авторизации
                    function.Authorization(TextBox_Login.Text,
                                           TextBox_Password.Text);
                    switch (Program.intID == "")
                    {
                    //Не верно введёные данные
                    case true:
                        MessageBox.Show("Введённые данные не верны! " +
                                        "Повторите ввод!",
                                        "DinoRemont", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        TextBox_Login.Clear();
                        TextBox_Password.Clear();
                        TextBox_Login.Focus();
                        break;

                    case false:
                        if (checkBox_KnowMe.Checked)
                        {
                            RegistryKey registry = Registry.CurrentUser;
                            //Создаёт папку в выбраном коревом каталоге рееста ОС
                            RegistryKey key = registry.CreateSubKey("DinoRemont");
                            //Запись в реестр зашифрованных данных
                            key.SetValue("Login", Cipher(TextBox_Login.Text, "Гамбургёр").ToString());
                            key.SetValue("Password", Cipher(TextBox_Password.Text, "Гамбургёр").ToString());
                        }
                        Employee employee = new Employee();
                        employee.Show(this);
                        this.Visible = false;
                        Hide();
                        hide = true;
                        break;
                    }
                    break;
                }
                break;
            }
        }
Ejemplo n.º 4
0
        private void BtEnter_Click(object sender, EventArgs e)
        {
            //Проверка на заполнение полей ввода
            switch (TextBox_Login.Text == "")
            {
            case true:
                TextBox_Login.BackColor = Color.Red;
                break;

            case false:
                switch (TextBox_Password.Text == "")
                {
                case true:
                    TextBox_Password.BackColor = Color.Red;
                    break;

                case false:
                    Function_Class function = new Function_Class();
                    //Прохождение авторизации
                    function.Authorization(TextBox_Login.Text,
                                           TextBox_Password.Text);
                    switch (Program.intID == "")
                    {
                    //Не верно введёные данные
                    case true:
                        MessageBox.Show("Введённые данные не верны! " +
                                        "Повторите ввод!",
                                        "Fgnbu", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        TextBox_Login.Clear();
                        TextBox_Password.Clear();
                        TextBox_Login.Focus();
                        break;

                    case false:

                        Worker worker = new Worker();
                        worker.Show(this);
                        this.Visible = false;
                        Hide();
                        hide = true;
                        break;
                    }
                    break;
                }
                break;
            }
        }
Ejemplo n.º 5
0
        private void ClientManager_OnIntroductionCompleted(object sender, IntroducerIntroductionCompletedEventArgs e)
        {
            switch (e.Result)
            {
            case Network.Messages.Nova.ResponseIntroducerIntroductionCompletedMessage.Result.Allowed:
                // Do nothing, expect OnNatTraversalSucceeded() to be raised shortly
                break;

            case Network.Messages.Nova.ResponseIntroducerIntroductionCompletedMessage.Result.Denied:
                switch (e.DenyReason)
                {
                case ResponseIntroducerIntroductionCompletedMessage.Reason.WrongPassword:
                    TextBox_Password.Set(() => TextBox_Password.Text, String.Empty);         // clear the password box for re-entry
                    MessageBox.Show("Please enter the correct password.");
                    break;

                case ResponseIntroducerIntroductionCompletedMessage.Reason.Banned:
                    MessageBox.Show("You have been banned for trying to connect too many times.");
                    break;
                }
                break;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Validate the login form credentials.
        /// </summary>
        /// <param name="user">The user who is attempting to log in.</param>
        /// <returns>True if all the fields on the form validate, else false.</returns>
        private bool ValidateLoginForm(User user, ref string validationErrors)
        {
            bool validRegistration = true;

            // Validating username field
            // Setting up the Regex for the username field
            Match usernameMatch = Regex.Match(user.Username.UserName, "^[a-zA-Z0-9-]+$", RegexOptions.IgnoreCase);

            if (user.Username.UserName == "")
            {
                validationErrors += "The <b>username</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_Username.Focus();
                validRegistration = false;
            }

            /*else if (user.Username.UserName.Length > 0 && user.Username.UserName.Length < 6)
             * {
             *  validationErrors += "The <b>username</b> entered is too short. Please try again.<br/>";
             *  TextBox_Username.Focus();
             *  validRegistration = false;
             * }*/
            else if (user.Username.UserName.Length > 30)
            {
                validationErrors += "The <b>username</b> entered is too long. Please shorten the username and try again.<br/>";
                TextBox_Username.Focus();
                validRegistration = false;
            }

            // Don't want to see this error too if we already know that the username field is blank.
            if (user.Username.UserName != "")
            {
                if (!usernameMatch.Success)
                {
                    validationErrors += "The <b>username</b> entered contains invalid characters. Please remove these characters and try again.<br/>";
                    TextBox_Username.Focus();
                    validRegistration = false;
                }
            }

            // Validate password field
            // Settings up the Regex for the password field

            /**
             * With thanks to http://stackoverflow.com/questions/9477906/password-must-be-8-characters-including-1-uppercase-letter-1-special-character
             **/
            Match passwordMatch = Regex.Match(user.Password.PassWord, "^[a-zA-Z0-9-+/*]+$", RegexOptions.IgnoreCase);

            if (user.Password.PassWord == "")
            {
                validationErrors += "The <b>password</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_Password.Focus();
                validRegistration = false;
            }
            else if (user.Password.PassWord.Length > 0 && user.Password.PassWord.Length < 8)
            {
                validationErrors += "The <b>password</b> field is too short. Please try again.<br/>";
                TextBox_Password.Focus();
                validRegistration = false;
            }
            else if (user.Password.PassWord.Length > 50)
            {
                validationErrors += "The <b>password</b> entered is too long. Please shorten the password and try again.<br/>";
                TextBox_Password.Focus();
                validRegistration = false;
            }

            if (user.Password.PassWord != null)
            {
                if (!passwordMatch.Success)
                {
                    validationErrors += "The <b>password</b> you entered contains invalid characters. Please try again.<br/>";
                    TextBox_Password.Focus();
                    validRegistration = false;
                }
            }

            // Don't want to see this error if we already know that the username or password is null.
            if (validRegistration)
            {
                // As these have the same resulting error message for security reasons, test both the username and password condition together and display the error only once.
                if (!user.CheckUsernameExistence())
                {
                    validationErrors += "The credentials you entered are not found. Please try again.<br/>";
                    TextBox_Password.Focus();
                    validRegistration = false;
                }
            }

            return(validRegistration);
        }
Ejemplo n.º 7
0
 void ClearBoxes()
 {
     TextBox_UserName.Clear();
     TextBox_Password.Clear();
     //ComboBox_SelectUser.Clear();
 }
Ejemplo n.º 8
0
        private void Button_Login_Click(object sender, EventArgs e)
        {
            // These are the Text box and combobox stuffs...

            string username = TextBox_UserName.Text;
            string password = TextBox_Password.Text;
            string usertype = ComboBox_SelectUser.Text;


            // from here databse connection starts..

            DB db = new DB();

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM users WHERE username = @usn and password = @pass and usertype = @type", db.getConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;
            command.Parameters.Add("@type", MySqlDbType.VarChar).Value = usertype;

            adapter.SelectCommand = command;

            adapter.Fill(table);
            // here ends database things.

            if (usertype == "Manager")
            {
                if (table.Rows.Count > 0)
                {
                    // MessageBox.Show("Manager Login Successful");
                    this.Hide();
                    ManagerForm managerform = new ManagerForm();
                    managerform.Show();
                    // from here we are going to manager page..
                }
                else
                {
                    MessageBox.Show("Manager Login Unsuccessful");
                    TextBox_UserName.Clear();
                    TextBox_Password.Clear();
                }
            }
            else if (usertype == "Admin")
            {
                if (table.Rows.Count > 0)
                {
                    //MessageBox.Show("Admin Login Successful");

                    this.Hide();
                    AdminForm adminform = new AdminForm();
                    adminform.Show();

                    // from here we are going to admin page..
                }
                else
                {
                    MessageBox.Show("Admin Login Unsuccessful");
                    TextBox_UserName.Clear();
                    TextBox_Password.Clear();
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Validate the fields in the registration form an issue appropriate errors if necessary.
        /// </summary>
        /// <param name="validationErrors">A string representation that will hold all validation errors for output to the screen.</param>
        /// <returns>True if the registration form validates, else false.</returns>
        private bool ValidateRegistrationForm(ref string validationErrors)
        {
            bool   validRegistration          = true;
            bool   termsAndConditionsAccepted = false;
            string confirmEmailAddress        = TextBox_ConfirmEmailAddress.Text;
            string confirmPassword            = TextBox_ConfirmPassword.Text;

            // Validating the Title field
            if (user.Title == "---")
            {
                validationErrors += "The <b>title</b> field was left blank. Please select a title and try again.<br/>";
                DropDownList_Title.Focus();
                validRegistration = false;
            }

            // Validating the Forename field
            // Setting up the Regex for detecting invalid characters in the forename field
            Match forenameMatch = Regex.Match(user.Forename, "^[A-Za-z]+$", RegexOptions.IgnoreCase);

            if (user.Forename == "")
            {
                validationErrors += "The <b>forename</b> field was left blank. Please enter your forename and try again.<br/>";
                TextBox_Forename.Focus();
                validRegistration = false;
            }
            else if (user.Forename.Length > 50)
            {
                validationErrors += "The <b>forename</b> field is too long. Please shorten your forename and try again.<br/>";
                TextBox_Forename.Focus();
                validRegistration = false;
            }

            if (user.Forename != "")
            {
                if (!forenameMatch.Success)
                {
                    validationErrors += "The <b>forename</b> field contains invalid characters. Please remove these characters and try again.<br/>";
                    TextBox_Forename.Focus();
                    validRegistration = false;
                }
            }

            // Validating the Surname field
            // Setting up the Regex for detecting invalid characters in the surname field
            Match surnameMatch = Regex.Match(user.Surname, "^[A-Za-z]+$", RegexOptions.IgnoreCase);

            if (user.Surname == "")
            {
                validationErrors += "The <b>surname</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_Surname.Focus();
                validRegistration = false;
            }
            else if (user.Surname.Length > 50)
            {
                validationErrors += "The <b>surname</b> field is too long. Please shorten your surname and try again.<br/>";
                TextBox_Surname.Focus();
                validRegistration = false;
            }

            if (user.Surname != "")
            {
                if (!surnameMatch.Success)
                {
                    validationErrors += "The <b>surname</b> field contains invalid characters. Please remove these characters and try again.<br/>";
                    TextBox_Surname.Focus();
                    validRegistration = false;
                }
            }

            // Validating the E-mail address field
            // Setting up the Regex for detecting invalid characters in the email address
            //Match emailAddressMatch = Regex.Match(user.EmailAddress, "^[a-zA-Z0-9@._]+$", RegexOptions.IgnoreCase);

            if (user.EmailAddress == "")
            {
                validationErrors += "The <b>e-mail address</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_EmailAddress.Focus();
                validRegistration = false;
            }
            else if (user.EmailAddress.Length > 150)
            {
                validationErrors += "The <b>e-mail address</b> field is too long. Please shorten your e-mail address and try again.<br/>";
                TextBox_EmailAddress.Focus();
                validRegistration = false;
            }

            /*if (user.EmailAddress != "")
             * {
             *  if (!emailAddressMatch.Success)
             *  {
             *      validationErrors += "The <b>e-mail address</b> did not contain the required characters for a valid e-mail address. Please alter your e-mail address and then try again.<br/>";
             *      TextBox_EmailAddress.Focus();
             *      validRegistration = false;
             *  }
             * }*/

            /*if (user.EmailAddress != "")
             * {
             *  if (!(user.EmailAddress.Contains(".") && user.EmailAddress.Contains("@")))
             *  {
             *      validationErrors += "The <b>e-mail address</b> did not conform to the standard e-mail address format. Please alter your e-mail address and then try again.<br/>";
             *      TextBox_EmailAddress.Focus();
             *      validRegistration = false;
             *  }
             * }*/

            if (user.CheckEmailAddressExistence())
            {
                validationErrors += "The <b>e-mail address</b> entered is already registered. Please choose a different e-mail address and try again.<br/>";
                TextBox_EmailAddress.Focus();
                validRegistration = false;
            }

            // Validating the confirm email address field
            // Setting up the Regex for detecting invalid characters in the confirm email address

            /**
             * With thanks to http://stackoverflow.com/questions/2652500/email-regular-expression-validation
             **/
            //Match confirmEmailAddressMatch = Regex.Match(confirmEmailAddress, "^[a-zA-Z0-9@._]+$", RegexOptions.IgnoreCase);

            if (confirmEmailAddress == "")
            {
                validationErrors += "The <b>confirmation e-mail address</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_ConfirmEmailAddress.Focus();
                validRegistration = false;
            }
            else if (confirmEmailAddress.Length > 150)
            {
                validationErrors += "The <b>confirmation e-mail address</b> field is too long. Please shorten this and try again.<br/>";
                TextBox_ConfirmEmailAddress.Focus();
                validRegistration = false;
            }

            /*if (user.EmailAddress != "")
             * {
             *  if (!confirmEmailAddressMatch.Success)
             *  {
             *      validationErrors += "The <b>confirmation e-mail address</b> field cdid not contain the required characters for a valid e-mail address. Please alter your e-mail address and then try again.<br/>";
             *      TextBox_ConfirmEmailAddress.Focus();
             *      validRegistration = false;
             *  }
             * }*/

            if (user.EmailAddress != confirmEmailAddress)
            {
                validationErrors                += "The <b>e-mail address</b> and <b>confirmation e-mail address</b> you entered do not match. Please re-enter these and try again.<br/>";
                TextBox_EmailAddress.Text        = "";
                TextBox_ConfirmEmailAddress.Text = "";
                TextBox_EmailAddress.Focus();
                validRegistration = false;
            }

            // Validating username field
            // Setting up the Regex for the username field
            Match usernameMatch = Regex.Match(user.Username.UserName, "^[A-Za-z0-9-]+$", RegexOptions.IgnoreCase);

            if (user.Username.UserName == "")
            {
                validationErrors += "The <b>username</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_Username.Focus();
                validRegistration = false;
            }
            else if (user.Username.UserName.Length > 30)
            {
                validationErrors += "The <b>username</b> entered is too long. Please shorten the username and try again.<br/>";
                TextBox_Username.Focus();
                validRegistration = false;
            }

            if (user.Username.UserName != "")
            {
                if (!usernameMatch.Success)
                {
                    validationErrors += "The <b>username</b> entered contains invalid characters. Please remove these characters and try again.<br/>";
                    TextBox_Username.Focus();
                    validRegistration = false;
                }
            }

            if (user.CheckUsernameExistence())
            {
                validationErrors += "The <b>username</b> entered is already taken. Please choose another username and try again.<br/>";
                TextBox_Username.Focus();
                validRegistration = false;
            }

            // Validate password field
            // Settings up the Regex for the password field

            /**
             * With thanks to http://stackoverflow.com/questions/9477906/password-must-be-8-characters-including-1-uppercase-letter-1-special-character
             **/
            Match passwordMatch = Regex.Match(user.Password.PassWord, "^[A-Za-z0-9+-/*]+$", RegexOptions.IgnoreCase);

            if (user.Password.PassWord == "")
            {
                validationErrors += "The <b>password</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_Password.Focus();
                validRegistration = false;
            }
            else if (user.Password.PassWord.Length > 0 && user.Password.PassWord.Length < 8)
            {
                validationErrors += "The <b>password</b> field is too short. Please choose a pasword of at least 8 characters.<br/>";
                TextBox_Password.Focus();
                validRegistration = false;
            }
            else if (user.Password.PassWord.Length > 50)
            {
                validationErrors += "The <b>password</b> entered is too long. Please shorten the password and try again.<br/>";
                TextBox_Password.Focus();
                validRegistration = false;
            }

            if (user.Password.PassWord != "")
            {
                if (!passwordMatch.Success)
                {
                    validationErrors += "The <b>password</b> entered contains some invalid characters. Please ensure the password contains a minimum of 8 characters of which one is an uppercase English character, a lowercase English character and a digit.<br/>";
                    TextBox_Password.Focus();
                    validRegistration = false;
                }
            }

            // Validate confirm password field
            // Settings up the Regex for the confirm password field

            /**
             * With thanks to http://stackoverflow.com/questions/9477906/password-must-be-8-characters-including-1-uppercase-letter-1-special-character
             **/
            Match confirmPasswordMatch = Regex.Match(confirmPassword, @"[A-Za-z0-9]", RegexOptions.IgnoreCase);

            if (confirmPassword == "")
            {
                validationErrors += "The <b>confirmation password</b> field was left blank. Please fill this in and try again.<br/>";
                TextBox_ConfirmPassword.Focus();
                validRegistration = false;
            }
            else if (confirmPassword.Length > 0 && confirmPassword.Length < 8)
            {
                validationErrors += "The <b>confirmation password</b> field is too short. Please choose a password of at least 8 characters.<br/>";
                TextBox_ConfirmPassword.Focus();
                validRegistration = false;
            }
            else if (confirmPassword.Length > 50)
            {
                validationErrors += "The <b>confirmation password</b> field is too long. Please shorten the password and try again.<br/>";
                TextBox_ConfirmPassword.Focus();
                validRegistration = false;
            }

            if (!confirmPasswordMatch.Success)
            {
                validationErrors += "The <b>confirmation password</b> entered contains some invalid characters. Please ensure the confirmation password contains a minimum of 8 characters of which one is an uppercase English character, a lowercase English character and a digit.<br/>";
                TextBox_ConfirmPassword.Focus();
                validRegistration = false;
            }

            // Check the password and confirm password fields match.
            if (user.Password.PassWord != confirmPassword)
            {
                validationErrors            += "The <b>password</b> and <b>confirmation password</b> you entered do not match. Please re-enter these and try again.<br/>";
                TextBox_Password.Text        = "";
                TextBox_ConfirmPassword.Text = "";
                TextBox_Password.Focus();
                validRegistration = false;
            }

            if (CheckBox_TermsAndConditions.Checked)
            {
                termsAndConditionsAccepted = true;
            }
            else
            {
                termsAndConditionsAccepted = false;
            }

            if (!termsAndConditionsAccepted)
            {
                validationErrors += "The <b>terms and conditions</b> were not accepted. Please read and accept these and then try again.<br/>";
                validRegistration = false;
            }

            return(validRegistration);
        }