Exemplo n.º 1
0
        public void habilitar()
        {
            txtNombre.Visible       = true;
            txtApellido.Visible     = true;
            txtDni.Visible          = true;
            txtMail.Visible         = true;
            cbxActivo.Visible       = true;
            rbtnHombre.Enabled      = true;
            rbtnHombre.Checked      = true;
            rbtnMujer.Enabled       = true;
            btnGuardar.Visible      = true;
            dtpFechaNac.Visible     = true;
            cboTipoTelefono.Visible = true;
            cboRol.Visible          = true;
            txtNumero.Visible       = true;
            txtContacto.Visible     = true;

            btnAnterior.Visible              = true;
            btnSiguiente.Visible             = true;
            btnPrimero.Visible               = true;
            btnUltimo.Visible                = true;
            usuarioToolStripMenuItem.Visible = true;

            ErrorNombre.Clear();
            ErrorApellido.Clear();
            ErrorDNI.Clear();
            ErrorFecha.Clear();
            ErrorMail.Clear();
            ErrorTipo.Clear();
            ErrorTE.Clear();

            TipoTelefonoBusiness TipoTelefonoBusiness = new TipoTelefonoBusiness();

            try
            {
                cboTipoTelefono.DataSource = TipoTelefonoBusiness.listar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            RolBusinness rolBusinness = new RolBusinness();

            try
            {
                cboRol.DataSource = rolBusinness.listar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        public bool Validar()
        {
            bool ok = true;

            if (txtNombre.Text == "")
            {
                ErrorNombre.SetError(txtNombre, "Ingrese Nombre");
                ok = false;
            }
            else
            {
                ErrorNombre.Clear();
            }

            if (txtApellido.Text == "")
            {
                ErrorApellido.SetError(txtApellido, "Ingrese Apellido");
                ok = false;
            }
            else
            {
                ErrorApellido.Clear();
            }

            if (txtDni.Text == "")
            {
                ErrorDNI.SetError(txtDni, "Ingrese DNI");
                ok = false;
            }
            else
            {
                ErrorDNI.Clear();
            }

            if (dtpFechaNac.Value >= DateTime.Today)
            {
                ErrorFecha.SetError(dtpFechaNac, "Ingrese Fecha Nacimento menor a Hoy");
                ok = false;
            }
            else
            {
                ErrorFecha.Clear();
            }

            // [email protected]
            Regex RX = new Regex("^[a-zA-Z0-9]{1,20}@[a-zA-Z0-9]{1,20}.[a-zA-Z]{2,3}$");

            if (!RX.IsMatch(txtMail.Text))
            {
                ErrorMail.SetError(txtMail, "Ingrese Mail con formato correcto([email protected])");
                ok = false;
            }
            else
            {
                ErrorMail.Clear();
            }

            if (txtNumero.Text != "" && cboTipoTelefono.SelectedIndex == -1)
            {
                ErrorTipo.SetError(cboTipoTelefono, "Ingrese Tipo de Telefono");
                ok = false;
            }
            else
            {
                ErrorTipo.Clear();
            }

            return(ok);
        }