コード例 #1
0
 private void DireccionTextBox_KeyPress(object sender, KeyPressEventArgs e)//De la direccion al Encargado
 {
     if ((int)e.KeyChar == (int)Keys.Enter)
     {
         EncargadoComboBox.Focus();
     }
 }
コード例 #2
0
        //--------------------------------------------------------------------------------------------------------

        //Validaciones -------------------------------------------------------------------------------------------
        private bool Validar() // Funcion que valida todo el registro
        {
            MyErrorProvider.Clear();
            bool paso = true;

            if (ClienteComboBox.Text == string.Empty) // Validando que elija un cliente
            {
                MyErrorProvider.SetError(ClienteComboBox, "Debe elegir un cliente");
                ClienteComboBox.Focus();
                paso = false;
            }
            if (TipoTrabajoComboBox.Text == string.Empty) // Validando que elija el tipo de trabajo
            {
                MyErrorProvider.SetError(TipoTrabajoComboBox, "Debe un tipo de trabajo");
                TipoTrabajoComboBox.Focus();
                paso = false;
            }
            if (DescripcionTrabajoTextBox.Text == String.Empty) // Validando que el trabajo tenga una descripcion
            {
                MyErrorProvider.SetError(DescripcionTrabajoTextBox, "Debe agregar una descripcion al trabajo");
                DescripcionTrabajoTextBox.Focus();
                paso = false;
            }
            if (PrecioNumericUpDown.Value <= 0) // Validando que el precio sea mayor a 0
            {
                MyErrorProvider.SetError(PrecioNumericUpDown, "El precio del trabajo tiene que ser mayor que 0");
                PrecioNumericUpDown.Focus();
                paso = false;
            }
            if (DireccionTextBox.Text == String.Empty)  // Validando que el trabajo tenga una direccion
            {
                MyErrorProvider.SetError(DireccionTextBox, "Debe agregar una direccion al trabajo");
                DireccionTextBox.Focus();
                paso = false;
            }
            if (EncargadoComboBox.Text == string.Empty)  // Validando que elija un encargado
            {
                MyErrorProvider.SetError(EncargadoComboBox, "Debe elegir un encargado");
                EncargadoComboBox.Focus();
                paso = false;
            }
            if (AjusteNumericUpDown.Value <= 0)
            {
                MyErrorProvider.SetError(AjusteNumericUpDown, "El ajuste debe ser mayor a 0"); // Validando que el precio sea mayor a 0
                AjusteNumericUpDown.Focus();
                paso = false;
            }
            if (AjusteNumericUpDown.Value > PrecioNumericUpDown.Value)
            {
                MyErrorProvider.SetError(AjusteNumericUpDown, "El ajuste no puede ser mayor al precio del trabajo"); // Validando que el ajuste no sea mayor al precio
                AjusteNumericUpDown.Focus();
                paso = false;
            }
            return(paso);
        }