Esempio n. 1
0
        private void RegistrarUsuario(string Usuario)
        {
            Interface = new InterfaceUsuario(this);
            int          temp        = -1;
            bool         PrimerAdmin = !Interface.HayAdministradores();
            DialogResult Resultado;

            if (!PrimerAdmin)
            {
                if (Interface.ValidarEmpleado(out temp, out Resultado))
                {
                    if (!Interface.ValidarEmpleadoRegistrado(temp))
                    {
                        Interface = new InterfaceUsuario(this);
                        Interface.DesplegarPantallaRegistrarUsuario(RegistrarNombre ? tbUsuario.Text : "", temp);
                        IntentosFallidos = 0;
                    }
                    else
                    {
                        MessageBox.Show("El número de empleado " + temp.ToString() + " ya tiene un usuario registrado", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                }
                else
                {
                    if (Resultado == DialogResult.Yes)
                    {
                        MessageBox.Show("Número de empleado no registrado, contáctese con el administrador", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        IntentosFallidos++;
                    }
                }
            }
            else
            {
                Interface = new InterfaceUsuario(this);
                Interface.DesplegarPantallaRegistrarUsuario(RegistrarNombre ? tbUsuario.Text : "", 1);
                IntentosFallidos = 0;
            }
            tbUsuario.Text = tbPassword.Text = "";
            if (IntentosFallidos == 5)
            {
                MessageBox.Show("Abuso de intentos, se cerrará el sistema", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                Application.Exit();
            }
        }
 private void btnAgregarUsuario_Click(object sender, EventArgs e)
 {
     Interface = new InterfaceUsuario(this);
     Interface.DesplegarPantallaRegistrarUsuario("", ObtenerEmpleado);
     RefrescarData();
 }