Ejemplo n.º 1
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            Proveedores proveedores;
            bool        paso = false;


            proveedores = LlenaClases();

            if (string.IsNullOrWhiteSpace(IDProveedorTextBox.Text) || IDProveedorTextBox.Text == "0")
            {
                paso = ProveedorBll.Guardar(proveedores);
            }
            else
            {
                if (!ExisteBD())
                {
                    System.Windows.MessageBox.Show("No Se puede Modificar porque no existe", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                paso = ProveedorBll.Modificar(proveedores);
            }

            if (paso)
            {
                Limpiar();
                System.Windows.MessageBox.Show("Guardado!!", "Exito", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                System.Windows.MessageBox.Show("No fue posible guardar!!", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void EliminarButton_Click(object sender, RoutedEventArgs e)
        {
            int id;

            id = Convert.ToInt32(IDProveedorTextBox.Text);

            Limpiar();

            if (ProveedorBll.Eliminar(id))
            {
                System.Windows.MessageBox.Show("Eliminado", "Exito", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                System.Windows.MessageBox.Show(IDProveedorTextBox.Text, "No se puede eliminar porque no existe");
            }
        }
Ejemplo n.º 3
0
        private void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            int         id;
            Proveedores proveedores = new Proveedores();

            int.TryParse(IDProveedorTextBox.Text, out id);

            Limpiar();

            proveedores = ProveedorBll.Buscar(id);

            if (proveedores != null)
            {
                LlenaCampos(proveedores);
            }
            else
            {
                System.Windows.MessageBox.Show("No Encontrada");
            }
        }
Ejemplo n.º 4
0
        private void ConsultarButton_Click(object sender, RoutedEventArgs e)
        {
            var listado = new List <Proveedores>();

            if (CriterioTextBox.Text.Trim().Length > 0)
            {
                switch (FiltroComboBox.SelectedIndex)
                {
                case 0:    //todo
                    listado = ProveedorBll.GetList(p => true);
                    break;

                case 1:    //ID
                    int id = Convert.ToInt32(CriterioTextBox.Text);
                    listado = ProveedorBll.GetList(p => p.IdProveedor == id);
                    break;

                case 2:    //Proveedor
                    listado = ProveedorBll.GetList(p => p.Proveëdor.Contains(CriterioTextBox.Text));
                    break;

                case 3:    //Direccion
                    listado = ProveedorBll.GetList(p => p.Direccion.Contains(CriterioTextBox.Text));
                    break;

                case 4:    //Ciudad
                    listado = ProveedorBll.GetList(p => p.Ciudad.Contains(CriterioTextBox.Text));
                    break;
                }
            }
            else
            {
                listado = ProveedorBll.GetList(p => true);
            }

            ConsultaDataGrip.ItemsSource = null;
            ConsultaDataGrip.ItemsSource = listado;
        }
Ejemplo n.º 5
0
        private bool ExisteBD()
        {
            Proveedores proveedores = ProveedorBll.Buscar(Convert.ToInt32(IDProveedorTextBox.Text));

            return(proveedores != null);
        }