private async void BuscarButton_Click(object sender, RoutedEventArgs e) { if (CriterioTextBox.Text.Trim().Length > 0) { switch (FiltroComboBox.SelectedIndex) { case 0: if (int.TryParse(CriterioTextBox.Text, out int PolizaId)) { poliza = (await PolizasBLL.GetPolizas()).Where(r => r.PolizaId == PolizaId).ToList(); } break; case 1: if (int.TryParse(CriterioTextBox.Text, out int VehiculoId)) { poliza = (await PolizasBLL.GetPolizas()).Where(r => r.VehiculoId == VehiculoId).ToList(); } break; case 2: //poliza = (await PolizasBLL.GetPolizas()).Where(r => r.Estado.Contains(CriterioTextBox.Text)).ToList(); break; case 3: poliza = await PolizasBLL.GetPolizas(); break; } } else { poliza = await PolizasBLL.GetPolizas(); } if (TodasRadioButton.IsChecked.Value) { poliza = poliza.Where(p => true).ToList(); } else if (VigenteRadioButton.IsChecked.Value) { poliza = poliza.Where(p => !p.EstaVencida).ToList(); } else if (VencidaRadioButton.IsChecked.Value) { poliza = poliza.Where(p => p.EstaVencida).ToList(); } ResultadosDataGrid.ItemsSource = null; ResultadosDataGrid.ItemsSource = poliza; }
private async void SetPoliza(Poliza poliza) { var _poliza = await PolizasBLL.Buscar(poliza.PolizaId); if (_poliza != null) { Poliza = _poliza; MyPropertyChanged("Poliza"); } EstadoTetBox.Text = Poliza.EstaVencida ? "Vencida" : "Vigente"; }
public async void BuscarPolizasARenovar() { //Polizas.Add(new Poliza { PolizaId = 1 , VehiculoId = 1 , MontoAsegurado = 300000, FechaFinal = new DateTime(2020 , 11 , 5) }); //Polizas.Add(new Poliza { PolizaId = 2 , VehiculoId = 2 , MontoAsegurado = 500000 , FechaFinal = new DateTime(2020 , 11 , 5) }); //Polizas.Add(new Poliza { PolizaId = 3 , VehiculoId = 3 , MontoAsegurado = 100000000 , FechaFinal = new DateTime(2020 , 11 , 5) }); //Polizas.Add(new Poliza { PolizaId = 1 , VehiculoId = 4 , MontoAsegurado = 300000 , FechaFinal = new DateTime(2020 , 11 , 5) }); //Polizas.Add(new Poliza { PolizaId = 2 , VehiculoId = 5 , MontoAsegurado = 300000 , FechaFinal = new DateTime(2020 , 11 , 5) }); Polizas = await PolizasBLL.GetPolizas(); Polizas = Polizas.Where(p => p.FechaFinal.DayOfYear - DIAS_ANTICIPACION <= DateTime.Today.DayOfYear && p.FechaFinal.Year == DateTime.Today.Year).ToList(); PolizasListBox.ItemsSource = null; PolizasListBox.ItemsSource = Polizas; }
private async void RenovarButton_Click(object sender, RoutedEventArgs e) { if (Poliza.FechaFinal.DayOfYear - 30 <= DateTime.Today.DayOfYear && Poliza.FechaFinal.Year == DateTime.Today.Year) { Poliza.FechaFinal = DateTime.Today.AddDays(365); bool renovada = await PolizasBLL.Modificar(Poliza); if (renovada) { SetPoliza(Poliza); MessageBox.Show("La poliza fue renovada", "Exito", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("Aun le queda mas de un mes de vigencia", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private async Task InicializarPoliza() { poliza = await PolizasBLL.GetPolizas(); Actualizar(); }