コード例 #1
0
        /// <summary>
        /// Limpia los campos dónde se van a introducir datos.
        /// </summary>
        private void LimpiarCampos()
        {
            TxtNombre.Clear();
            TxtApellidos.Clear();
            TxtNif.Clear();
            TxtDireccion.Clear();;
            TxtTelefono.Clear();
            TxtObservaciones.Clear();

            TxtMarca.Clear();
            TxtModelo.Clear();
            TxtMatricula.Clear();
            TxtLlave.Clear();
            TxtPlaza.Clear();

            TxtBaseImponible.Clear();
            TxtIva.Clear();
            TxtTotal.Clear();
        }
コード例 #2
0
        /// <summary>
        /// Comprueba que los datos introducidos por el usuario sean correctos.
        /// </summary>
        /// <returns>Indica si los datos introducidos son correctos.</returns>
        private bool ComprobarDatosIntroducidos()
        {
            bool  hayNombre        = false;
            bool  hayDireccion     = false;
            bool  hayPlaza         = false;
            bool  hayBaseImponible = false;
            bool  hayIva           = false;
            bool  hayTotal         = false;
            Regex exprRegTelefono  = new Regex(@"^[0-9]{9}$|^[0-9]{9} \/ [0-9]{9} \/ [0-9]{9}$");
            Regex exprRegNif       = new Regex(@"[0-9]{8}[A-Z]{1}$|^X[0-9]{7}[A-Z]{1}$");
            Regex exprRegMatricula = new Regex("^[0-9]{4} [A-Z]{3}$|^[A-Z]{1,2} [0-9]{4} [A-Z]{1,2}$|^[A-Z]{1} [0-9]{4} [A-Z]{1,3}$");

            if (TxtNombre.Text.Length == 0)
            {
                MessageBox.Show("Tiene que introducir un nombre", "Nombre Vacío", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                hayNombre = true;
            }

            if (TxtDireccion.Text.Length == 0)
            {
                MessageBox.Show("Tiene que introducir una dirección", "Dirección Vacía", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                hayDireccion = true;
            }

            if (CbConceptos.SelectedIndex == 0)
            {
                if (TxtMatricula.Text.Length == 0 && CbConceptos.SelectedIndex == 0 && Convert.ToInt32(BtnAddCliente.Tag) == 1)
                {
                    MessageBox.Show("Tiene que introducir una matrícula", "Matrícula Vacía", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (!exprRegMatricula.IsMatch(TxtMatricula.Text))
                {
                    MessageBox.Show("Formato de matrícula incorrecto", "Formato Incorrecto", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TxtMatricula.Clear();
                    TxtMatricula.Focus();
                }
            }

            if (TxtPlaza.Text.Length == 0)
            {
                MessageBox.Show("Tiene que introducir una plaza", "Plaza Vacía", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                hayPlaza = true;
            }

            if (TxtBaseImponible.Text.Length == 0)
            {
                MessageBox.Show("Tiene que introducir una base imponible", "Base Imponible Vacía", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                hayBaseImponible = true;
            }

            if (TxtIva.Text.Length == 0)
            {
                MessageBox.Show("Tiene que introducir un I.V.A.", "I.V.A. Vacío", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                hayIva = true;
            }

            if (TxtTotal.Text.Length == 0)
            {
                MessageBox.Show("Tiene que introducir un total", "Total Vacío", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                hayTotal = true;
            }

            return(hayNombre && hayDireccion && hayPlaza && hayBaseImponible && hayIva && hayTotal);
        }