Esempio n. 1
0
        private void passwordTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                if (usernameTextBox.Text.Trim().Length != 0 && passwordTextBox.Text.Trim().Length != 0)
                {
                    string username = usernameTextBox.Text.Trim();
                    string password = passwordTextBox.Text.Trim();

                    User user = new User();

                    user = Database.getUser(username);

                    try
                    {
                        if (Utils.Decrypt(user.Password) == password)
                        {
                            MessageBox.Show("Ingreso Exitoso, bienvenido " + user.Username, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Main_Windows mr = new Main_Windows();
                            mr.send_username = user.Username;
                            mr.Show();

                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Contraseña incorrecta", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Usuario incorrecto", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                else
                {
                    MessageBox.Show("Error al ingresar, rellene todos los campos", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Click event of the enterButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void enterButton_Click(object sender, EventArgs e)
        {
            if (validate_username == true && validate_password == true)
            {
                string username = usernameTextBox.Text.Trim();
                string password = passwordTextBox.Text.Trim();

                User user = new User();

                user = Database.getUser(username);

                try
                {
                    if (Utils.Decrypt(user.Password) == password)
                    {
                        MessageBox.Show("Ingreso Exitoso, bienvenido " + user.Username, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Main_Windows mr = new Main_Windows();
                        mr.send_username = user.Username;
                        mr.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Contraseña incorrecta", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch
                {
                    MessageBox.Show("Usuario incorrecto", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            else
            {
                MessageBox.Show("Error al ingresar, rellene todos los campos", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }