public bool Validar()
        {
            bool paso = true;
            MyErrorProvider.Clear();

            if (string.IsNullOrWhiteSpace(ArticuloTextBox.Text))
            {
                MyErrorProvider.SetError(ArticuloTextBox, "Debe insertar almenos un articulo.");
                ArticuloTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(CodigoMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(CodigoMaskedTextBox, "Debe asignarle un codigo.");
                CodigoMaskedTextBox.Focus();
                paso = false;
            }

            if (PrecioNumericUpDown.Value <= 0)
            {
                MyErrorProvider.SetError(PrecioNumericUpDown, "Debe asignarle un precio valido.");
                PrecioNumericUpDown.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(UnidadComboBox.Text))
            {
                MyErrorProvider.SetError(UnidadComboBox, "Debe agregarle una medida.");
                UnidadComboBox.Focus();
                paso = false;
            }

            return paso;
        }
Beispiel #2
0
 private void DescripcionTrabajoTextBox_KeyPress(object sender, KeyPressEventArgs e)// De la descripcion del trabajo al precio
 {
     if ((int)e.KeyChar == (int)Keys.Enter)
     {
         PrecioNumericUpDown.Focus();
     }
 }
        public bool Validar()
        {
            bool validado = true;

            if (string.IsNullOrWhiteSpace(CodigoTb.Text))
            {
                MyErrorProvider.SetError(CodigoTb, "El campo codigo no puede estar vacio");
                CodigoTb.Focus();
                validado = false;
            }
            if (string.IsNullOrWhiteSpace(DescripcionTb.Text))
            {
                MyErrorProvider.SetError(DescripcionTb, "El campo descripcion no puede estar vacio");
                DescripcionTb.Focus();
                validado = false;
            }
            if (CostoNumericUpDown.Value == 0)
            {
                MyErrorProvider.SetError(CostoNumericUpDown, "El campo costo, no puede ser 0");
                CostoNumericUpDown.Focus();
                validado = false;
            }
            if (PrecioNumericUpDown.Value == 0)
            {
                MyErrorProvider.SetError(CostoNumericUpDown, "El campo precio, no puede ser 0");
                PrecioNumericUpDown.Focus();
                validado = false;
            }
            return(validado);
        }
Beispiel #4
0
        private bool Validar()
        {
            bool paso = true;

            MyErrorProvider.Clear();

            if (DescripcionTextBox.Text == string.Empty)
            {
                MyErrorProvider.SetError(DescripcionTextBox, "Este campo no puede estar vacio");
                DescripcionTextBox.Focus();
                paso = false;
            }
            if (PrecioNumericUpDown.Text == string.Empty)
            {
                MyErrorProvider.SetError(PrecioNumericUpDown, "Este campo no puede estar vacio");
                PrecioNumericUpDown.Focus();
                paso = false;
            }
            if (CantidadNumericUpDown.Text == string.Empty)
            {
                MyErrorProvider.SetError(CantidadNumericUpDown, "Este campo no puede estar vacio");
                CantidadNumericUpDown.Focus();
                paso = false;
            }
            return(paso);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        private bool ValidaProducto() // Funcion encargada de validar que el producto este corrextamente llenado
        {
            bool Paso = true;

            Productos ProductoTemporal = BuscaProducto((int)ProductoIdNumericUpDown.Value);

            if (ProductoIdNumericUpDown.Value == 0 ||
                Convert.ToString(ProductoIdNumericUpDown.Value) == string.Empty ||
                DescripcionTextBox.Text == string.Empty ||
                DescripcionTextBox.Text != ProductoTemporal.Descripcion)// Valida que el producto este cargado
            {
                MyErrorProvider.SetError(ProductoIdNumericUpDown, "Debe cargar el producto!");
                BuscarProductoButton.Focus();
                Paso = false;
            }
            else
            {
                if (CantidadNumericUpDown.Value <= 0) //Valida que la cantidad sea mayor a 0
                {
                    MyErrorProvider.SetError(CantidadNumericUpDown, "La cantidad debe ser mayor a 0!");
                    CantidadNumericUpDown.Focus();
                    Paso = false;
                }
                else
                {
                    if (ProductoTemporal.ControlAlmacen == true)                     //Valida si el producto esta controlado en elmacen
                    {
                        if (ProductoTemporal.Cantidad < CantidadNumericUpDown.Value) //Valida que la cantidad a facturar no sea mayor a la que existe en el almacen
                        {
                            MyErrorProvider.SetError(CantidadNumericUpDown, "De este producto solo quedan \"" + ProductoTemporal.Cantidad + "\" unidades en almacen!");
                            CantidadNumericUpDown.Focus();
                            Paso = false;
                        }
                    }
                }

                if (PrecioNumericUpDown.Value <= 0)
                {
                    MyErrorProvider.SetError(PrecioNumericUpDown, "El precio del producto debe ser mayor a 0.00!");
                    PrecioNumericUpDown.Focus();
                    Paso = false;
                }
            }
            return(Paso);
        }
Beispiel #7
0
        private bool Validar()
        {
            bool paso = true;

            MyErrorProvider.Clear();

            if (string.IsNullOrWhiteSpace(NombreTextBox.Text))
            {
                MyErrorProvider.SetError(NombreTextBox, "No se puede dejar este campo en blanco");
                NombreTextBox.Focus();
                paso = false;
            }
            if (PrecioNumericUpDown.Value == 0)
            {
                MyErrorProvider.SetError(PrecioNumericUpDown, "No se puede dejar este campo en blanco");
                PrecioNumericUpDown.Focus();
                paso = false;
            }

            return(paso);
        }
Beispiel #8
0
        private bool Validar()//Funcion que valida todo el registro
        {
            bool Paso = true;

            MyErrorProvider.Clear();

            if (DescripcionTextBox.Text == string.Empty) // Condicion encargada de validar que el campo descripcion no este vacio
            {
                MyErrorProvider.SetError(DescripcionTextBox, "La descripción no puede estar vacía!");
                DescripcionTextBox.Focus();
                Paso = false;
            }
            else // Validando que la descripcion del producto no este duplicada
            {
                if (ProductoIdNumericUpDown.Value == 0 || Convert.ToString(ProductoIdNumericUpDown.Value) == string.Empty) // Validando que la descripcion no exista, en caso de registrar un producto nuevo
                {
                    if (ProductosBLL.ExisteDescripcion(DescripcionTextBox.Text) == true)
                    {
                        MyErrorProvider.SetError(DescripcionTextBox, "Ya existe un producto con esta descripción, debe ingresar una diferente!");
                        DescripcionTextBox.Focus();
                        Paso = false;
                    }
                }
                else //Valida que si al modificar un producto, la descripcion sea unica
                {
                    RepositorioBase <Productos> Repositorio = new RepositorioBase <Productos>();
                    var Listado = new List <Productos>();

                    Listado = Repositorio.GetList(p => p.Descripcion.Contains(DescripcionTextBox.Text));

                    if (Listado.Count == 1) // Confirma que solo exista un producto con esa descripcion
                    {
                        Productos ProductoTemporal = new Productos();
                        ProductoTemporal = Listado[0];
                        if (ProductoTemporal.ProductoId != ProductoIdNumericUpDown.Value) // Verifica si el producto que tiene esa descripcion en la base de datos no es al que se esta modificando!
                        {
                            MyErrorProvider.SetError(DescripcionTextBox, "Ya existe un producto con esta descripción, debe ingresar una diferente!");
                            DescripcionTextBox.Focus();
                            Paso = false;
                        }
                    }
                    else if (Listado.Count > 1)
                    {
                        MyErrorProvider.SetError(DescripcionTextBox, "Ya existe un producto con esta descripción, debe ingresar una diferente!");
                        DescripcionTextBox.Focus();
                        Paso = false;
                    }
                }
            }

            if (CategoriaComboBox.SelectedIndex < 0) // Condicion encargada de validar que haya una categoria seleccionada
            {
                MyErrorProvider.SetError(CategoriaComboBox, "Debe seleccionar una categoría!");
                CategoriaComboBox.Focus();
                Paso = false;
            }

            if (CantidadNumericUpDown.Value < 0) // Condicion encargada de validar que la cantidad no sea menor que 0
            {
                MyErrorProvider.SetError(CantidadNumericUpDown, "La cantidad disponible debe no puede ser menor que 0!");
                CantidadNumericUpDown.Focus();
                Paso = false;
            }

            if (PrecioNumericUpDown.Value <= 0) // Condicion encargada de validar que el precio sea mayor a 0
            {
                MyErrorProvider.SetError(PrecioNumericUpDown, "El precio del producto debe ser mayor a 0!");
                PrecioNumericUpDown.Focus();
                Paso = false;
            }

            return(Paso);
        }