コード例 #1
0
        /// <summary>
        /// Metodo encargado de validar los campos del formulario
        /// </summary>
        /// <returns></returns>
        public bool Validar()
        {
            bool paso = true;

            ErrorProvider.Clear();
            if (string.IsNullOrWhiteSpace(CodigoTextBox.Text))
            {
                ErrorProvider.SetError(CodigoTextBox, "El codigo no puede estar vacio");
                CodigoTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(PrecioTextBox.Text))
            {
                ErrorProvider.SetError(PrecioTextBox, "El codigo no puede estar vacio");
                PrecioTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(ItebisTextBox.Text))
            {
                ErrorProvider.SetError(ItebisTextBox, "El codigo no puede estar vacio");
                ItebisTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(TotalTextBox.Text))
            {
                ErrorProvider.SetError(TotalTextBox, "El codigo no puede estar vacio");
                TotalTextBox.Focus();
                paso = false;
            }
            return(paso);
        }
コード例 #2
0
 //——————————————————————————————————————————[ ITBIS ]——————————————————————————————————————————
 private void ItebisTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     try
     {
         if (ItebisTextBox.Text.Trim() != string.Empty)
         {
             double.Parse(ItebisTextBox.Text);
         }
     }
     catch
     {
         MessageBox.Show($"El valor digitado en el campo (ITBIS) no es un número.\n\nPor favor, digite un número.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
         ItebisTextBox.Text = "0";
         ItebisTextBox.Focus();
         ItebisTextBox.SelectAll();
     }
 }
コード例 #3
0
        //——————————————————————————————————————————————————————————————[ Guardar ]———————————————————————————————————————————————————————————————
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            {
                if (!Validar())
                {
                    return;
                }

                //———————————————————————————————————————————————————————[ VALIDAR SI ESTA VACIO ]———————————————————————————————————————————————————————
                //—————————————————————————————————[ Producto Id ]—————————————————————————————————
                if (ProductoIdTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Producto Id) está vacío.\n\nAsigne un Id al Libro.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    ProductoIdTextBox.Text = "0";
                    ProductoIdTextBox.Focus();
                    ProductoIdTextBox.SelectAll();
                    return;
                }

                //—————————————————————————————————[ Nombre ]—————————————————————————————————
                if (NombrePTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Nombre producto) está vacío.\n\nEscriba un Nombre.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    NombrePTextBox.Clear();
                    NombrePTextBox.Focus();
                    return;
                }

                //—————————————————————————————————[ Marca Id ]—————————————————————————————————
                if (MarcaIdComboBox.Text == string.Empty)
                {
                    MessageBox.Show("El Campo (Marca Id) está vacío.\n\nPorfavor, Seleccione una marca .", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    MarcaIdComboBox.IsDropDownOpen = true;
                    return;
                }

                //—————————————————————————————————[ Precio ]—————————————————————————————————
                if (PrecioTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Precio) está vacío.\n\nEscriba un de Precio.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    PrecioTextBox.Clear();
                    PrecioTextBox.Focus();
                    return;
                }

                //—————————————————————————————————[ ITBIS ]—————————————————————————————————
                if (ItebisTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (ITBIS) está vacío.\n\nEscriba un Itbis.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    ItebisTextBox.Focus();
                    ItebisTextBox.SelectAll();
                    return;
                }

                //—————————————————————————————————[ Fecha ]—————————————————————————————————
                if (FechaPDatePicker.Text.Trim() == string.Empty)
                {
                    MessageBox.Show($"El Campo (Fecha) está vacío.\n\nSeleccione una fecha.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    FechaPDatePicker.Focus();
                    return;
                }

                //—————————————————————————————————[ Existencia ]—————————————————————————————————
                if (DescripcionTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Descripcion) está vacío.\n\nRealice una despcricion  .", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);


                    DescripcionTextBox.Focus();
                    DescripcionTextBox.SelectAll();
                    return;
                }


                //———————————————————————————————————————————————————————[ VALIDAR SI ESTA VACIO - FIN ]———————————————————————————————————————————————————————
                var paso = ProductosBLL.Guardar(productos);
                if (paso)
                {
                    Limpiar();
                    MessageBox.Show("Transacción Exitosa", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("Transaccion Fallida", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }