private async void EliminarButton_Click(object sender, RoutedEventArgs e)
        {
            bool eliminado = false;

            if (int.TryParse(ImportadorIdTextBox.Text, out int clienteId))
            {
                if (await ImportadorBLL.Existe(clienteId))
                {
                    MessageBoxResult opcion = MessageBox.Show("Desea eliminar este importador?.", "Confirme", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (opcion == MessageBoxResult.Yes)
                    {
                        eliminado = await ImportadorBLL.Eliminar(clienteId);

                        if (eliminado)
                        {
                            Limpiar();
                            MessageBox.Show("Eliminado.");
                        }
                        else
                        {
                            MessageBox.Show("Error al eliminar.");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Este importador no existe.");
                }
            }
            else
            {
                MessageBox.Show("Cliente Id invalido.");
            }
        }
        private async void InicializarImportador(int importadorId)
        {
            var _importador = await ImportadorBLL.Buscar(importadorId);

            if (_importador != null)
            {
                importador = _importador;
            }
            else
            {
                MessageBox.Show("Este importador fue eliminado");
            }
        }
        private async void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            bool guardado = false;

            if (CamposValidos())
            {
                guardado = await ImportadorBLL.Guardar(importador);

                if (guardado)
                {
                    Limpiar();
                    MessageBox.Show("Guardado.");
                }
                else
                {
                    MessageBox.Show("Error al guardar.");
                }
            }
        }
        async Task FiltrarImportador()
        {
            if (CriterioTextBox.Text.Trim().Length > 0)
            {
                switch (FiltroComboBox.SelectedIndex)
                {
                case 0:
                    Importadores = Task.Run(() => ImportadorBLL.GetImportadores(e => true)).Result;
                    break;


                case 1:
                    int num = 0;
                    Importadores = Task.Run(() => ImportadorBLL.GetImportadores(e => e.ImportadorId == Convert.ToInt32(CriterioTextBox.Text))).Result;
                    break;

                case 2:

                    Importadores = Task.Run(() => ImportadorBLL.GetImportadores(e => e.Nombre.Contains(CriterioTextBox.Text))).Result;
                    break;

                case 3:

                    Importadores = Task.Run(() => ImportadorBLL.GetImportadores(e => e.PaginaWeb.Contains(CriterioTextBox.Text))).Result;
                    break;

                case 4:

                    Importadores = Task.Run(() => ImportadorBLL.GetImportadores(e => e.Telefono.Contains(CriterioTextBox.Text))).Result;
                    break;
                }
            }
            else
            {
                Importadores = Task.Run(() => ImportadorBLL.GetImportadores(e => true)).Result;
            }
            ResultadosDataGrid.ItemsSource = null;
            ResultadosDataGrid.ItemsSource = Importadores;

            CargarGrid();
        }
        private async void BuscarButton_Click(object sender, RoutedEventArgs e)
        {
            if (int.TryParse(ImportadorIdTextBox.Text, out int importadorId))
            {
                if (await ImportadorBLL.Existe(importadorId))
                {
                    importador = await ImportadorBLL.Buscar(importadorId);

                    this.DataContext = importador;
                    MyPropertyChanged("importador");
                }
                else
                {
                    MessageBox.Show("Este importador no existe.");
                    Limpiar();
                }
            }
            else
            {
                MessageBox.Show("Este importador id es invalido.");
            }
        }
        private async Task InicializarImportador()
        {
            Importadores = await ImportadorBLL.GetImportadores(e => true);

            CargarGrid();
        }
Ejemplo n.º 7
0
 async public void Llenar()
 {
     //ImportadorComboBox.ItemsSource = ImportadorBLL.GetList();
     ImportadorComboBox.ItemsSource = await ImportadorBLL.GetList();
 }