Esempio n. 1
0
        private void loginVoid()
        {
            if (txtUser.Text == "")
            {
                MessageBox.Show("No ha ingresado un usuario", "Sercor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtUser.Focus();
            }
            else if (txtPsw.Text == "")
            {
                MessageBox.Show("No ha ingresado su contraseña", "Sercor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPsw.Focus();
            }
            else
            {
                UsuarioSeleccionado = UsuarioDBM.ObtenerUsuarioPorUsuario(txtUser.Text);
                if (UsuarioSeleccionado != null)
                {
                    string passHashed = UsuarioSeleccionado.CONTRASENA;

                    string passUnhash = Hash.sha256(txtPsw.Text);
                    //crear temporalmente una app aparte, para al momento de presentar registrar usuario con Hash
                    if (passHashed == passUnhash)
                    {
                        bool[] privilegio1 = Privilegio(UsuarioSeleccionado.PRIVILEGIO1);
                        bool[] privilegio2 = Privilegio(UsuarioSeleccionado.PRIVILEGIO2);

                        FormInstance.mainWindow(UsuarioSeleccionado, this, privilegio1, privilegio2);
                        this.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("Credenciales erróneas", "Sercor", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            string consulta;

            consulta = UsuarioDBM.ObtenerUsuarioPorUsuario(txtUser.Text).USUARIO;
            if (txtUser.Text == "admin")
            {
                MessageBox.Show("Nombre no permitido", "Sercor", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else if (consulta == txtUser.Text)
            {
                MessageBox.Show("Usuario existente", "Sercor", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else
            {
                if (txtUser.Text == "" || txtContrasenia.Text == "")
                {
                    MessageBox.Show("No ha ingresado un usuario o contraseña");
                    txtUser.Select();
                }
                else
                {
                    int pri1, pri2;

                    if (admin1.Checked == true && admin2.Checked == true && admin3.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 15;
                    }
                    else if (admin2.Checked == true && admin3.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 14;
                    }
                    else if (admin1.Checked == true && admin3.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 13;
                    }
                    else if (admin1.Checked == true && admin2.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 12;
                    }
                    else if (admin1.Checked == true && admin2.Checked == true && admin3.Checked == true)
                    {
                        pri1 = 11;
                    }
                    else if (admin3.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 10;
                    }
                    else if (admin2.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 9;
                    }
                    else if (admin2.Checked == true && admin3.Checked == true)
                    {
                        pri1 = 8;
                    }
                    else if (admin1.Checked == true && admin4.Checked == true)
                    {
                        pri1 = 7;
                    }
                    else if (admin1.Checked == true && admin3.Checked == true)
                    {
                        pri1 = 6;
                    }
                    else if (admin1.Checked == true && admin2.Checked == true)
                    {
                        pri1 = 5;
                    }
                    else if (admin4.Checked == true)
                    {
                        pri1 = 4;
                    }
                    else if (admin3.Checked == true)
                    {
                        pri1 = 3;
                    }
                    else if (admin2.Checked == true)
                    {
                        pri1 = 2;
                    }
                    else if (admin1.Checked == true)
                    {
                        pri1 = 1;
                    }
                    else
                    {
                        pri1 = 0;
                    }


                    if (user1.Checked == true && user2.Checked == true && user3.Checked == true && user4.Checked == true)
                    {
                        pri2 = 15;
                    }
                    else if (user2.Checked == true && user3.Checked == true && user4.Checked == true)
                    {
                        pri2 = 14;
                    }
                    else if (user1.Checked == true && user3.Checked == true && user4.Checked == true)
                    {
                        pri2 = 13;
                    }
                    else if (user1.Checked == true && user2.Checked == true && user4.Checked == true)
                    {
                        pri2 = 12;
                    }
                    else if (user1.Checked == true && user2.Checked == true && user3.Checked == true)
                    {
                        pri2 = 11;
                    }
                    else if (user3.Checked == true && user4.Checked == true)
                    {
                        pri2 = 10;
                    }
                    else if (user2.Checked == true && user4.Checked == true)
                    {
                        pri2 = 9;
                    }
                    else if (user2.Checked == true && user3.Checked == true)
                    {
                        pri2 = 8;
                    }
                    else if (user1.Checked == true && user4.Checked == true)
                    {
                        pri2 = 7;
                    }
                    else if (user1.Checked == true && user3.Checked == true)
                    {
                        pri2 = 6;
                    }
                    else if (user1.Checked == true && user2.Checked == true)
                    {
                        pri2 = 5;
                    }
                    else if (user4.Checked == true)
                    {
                        pri2 = 4;
                    }
                    else if (user3.Checked == true)
                    {
                        pri2 = 3;
                    }
                    else if (user2.Checked == true)
                    {
                        pri2 = 2;
                    }
                    else if (user1.Checked == true)
                    {
                        pri2 = 1;
                    }
                    else
                    {
                        pri2 = 0;
                    }

                    Usuario nuevoUser = new Usuario();
                    Usuario lastUser  = new Usuario();
                    lastUser              = UsuarioDBM.UltimoUsuario();
                    nuevoUser.ID_USUARIO  = lastUser.ID_USUARIO + 1;
                    nuevoUser.TIPO        = 1;
                    nuevoUser.USUARIO     = txtUser.Text;
                    nuevoUser.CONTRASENA  = Hash.sha256(txtContrasenia.Text);
                    nuevoUser.NOMBRE      = txtName.Text;
                    nuevoUser.APELLIDO    = txtLastName.Text;
                    nuevoUser.CEDULA      = txtCi.Text;
                    nuevoUser.DIRECCION   = txtDireccion.Text;
                    nuevoUser.TELEFONO    = txtTelefono.Text;
                    nuevoUser.PRIVILEGIO1 = pri1;
                    nuevoUser.PRIVILEGIO2 = pri2;

                    UsuarioDBM.Agregar(nuevoUser);

                    this.Close();
                }
            }
        }
Esempio n. 3
0
        private void cbmUsuario_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedUser        = UsuarioDBM.ObtenerUsuarioPorUsuario(cbmUsuario.SelectedItem.ToString());
            txtCi.Text          = selectedUser.CEDULA;
            txtName.Text        = selectedUser.NOMBRE;
            txtLastName.Text    = selectedUser.APELLIDO;
            txtTelefono.Text    = selectedUser.TELEFONO;
            txtDireccion.Text   = selectedUser.DIRECCION;
            txtContrasenia.Text = selectedUser.CONTRASENA;
            uncheck();

            if (cbmUsuario.SelectedItem.ToString() == "admin")
            {
                btnDelete.Enabled = false;
                btnEdit.Enabled   = false;
            }
            else
            {
                btnEdit.Enabled   = true;
                btnDelete.Enabled = true;
            }

            switch (selectedUser.PRIVILEGIO1)
            {
            case 0:
                uncheck();
                break;

            case 1:
                admin1.Checked = true;
                break;

            case 2:
                admin2.Checked = true;
                break;

            case 3:
                admin3.Checked = true;
                break;

            case 4:
                admin4.Checked = true;
                break;

            case 5:
                admin1.Checked = true;
                admin2.Checked = true;
                break;

            case 6:
                admin1.Checked = true;
                admin3.Checked = true;
                break;

            case 7:
                admin1.Checked = true;
                admin4.Checked = true;
                break;

            case 8:
                admin2.Checked = true;
                admin3.Checked = true;
                break;

            case 9:
                admin2.Checked = true;
                admin4.Checked = true;
                break;

            case 10:
                admin3.Checked = true;
                admin4.Checked = true;
                break;

            case 11:    //
                admin1.Checked = true;
                admin2.Checked = true;
                admin3.Checked = true;
                break;

            case 12:    //
                admin1.Checked = true;
                admin2.Checked = true;
                admin4.Checked = true;
                break;

            case 13:    //
                admin1.Checked = true;
                admin3.Checked = true;
                admin4.Checked = true;
                break;

            case 14:    //
                admin2.Checked = true;
                admin3.Checked = true;
                admin4.Checked = true;
                break;

            case 15:    //
                admin1.Checked = true;
                admin2.Checked = true;
                admin3.Checked = true;
                admin4.Checked = true;
                break;

            default:
                uncheck();
                break;
            }

            switch (selectedUser.PRIVILEGIO2)
            {
            case 0:
                uncheck();
                break;

            case 1:
                user1.Checked = true;
                break;

            case 2:
                user2.Checked = true;
                break;

            case 3:
                user3.Checked = true;
                break;

            case 4:
                user4.Checked = true;
                break;

            case 5:
                user1.Checked = true;
                user2.Checked = true;
                break;

            case 6:
                user1.Checked = true;
                user3.Checked = true;
                break;

            case 7:
                user1.Checked = true;
                user4.Checked = true;
                break;

            case 8:
                user2.Checked = true;
                user3.Checked = true;
                break;

            case 9:
                user2.Checked = true;
                user4.Checked = true;
                break;

            case 10:
                user3.Checked = true;
                user4.Checked = true;
                break;

            case 11:
                user1.Checked = true;
                user2.Checked = true;
                user3.Checked = true;
                break;

            case 12:
                user1.Checked = true;
                user2.Checked = true;
                user4.Checked = true;
                break;

            case 13:
                user1.Checked = true;
                user3.Checked = true;
                user4.Checked = true;
                break;

            case 14:
                user2.Checked = true;
                user3.Checked = true;
                user4.Checked = true;
                break;

            case 15:
                user1.Checked = true;
                user2.Checked = true;
                user3.Checked = true;
                user4.Checked = true;
                break;

            default:
                uncheck();
                break;
            }
        }