/// <summary> /// Determines if a charge should be reduced based on registration date /// </summary> /// <param name="fechaAfiliacion">Registration date</param> /// <returns>True if price should be reduced</returns> private bool IncompleteCharge(DateTime?fechaAfiliacion) { if (!fechaAfiliacion.HasValue) { throw (new Exception("Error, variable nula")); } return(fechaAfiliacion.Value.Month == DateManager.GetMonthNumber() && fechaAfiliacion.Value.Year == DateManager.GetToday().Year); }
/// <summary> /// Searches for relevant information /// </summary> private void Consultar() { Clean(); List <Cargo> cargos = null; if (this.YearsBox.SelectedItem is null || this.Meses.SelectedItem is null || this.Nodos.SelectedItem is null) { SystemSounds.Beep.Play(); MessageBox.Show("Seleccione un valor valido!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); return; } string year = this.YearsBox.SelectedItem.ToString(); string month = this.Meses.SelectedItem.ToString(); string nodo = this.Nodos.SelectedItem.ToString(); int yearInt, mesInt = DateManager.GetMonthNumber(month), nodoInt; if (String.IsNullOrEmpty(nodo) || String.IsNullOrEmpty(month) || String.IsNullOrEmpty(year)) { SystemSounds.Beep.Play(); MessageBox.Show("Busqueda no valida!", Messages.Titles.Warninig, MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (!(Int32.TryParse(year, out yearInt))) { SystemSounds.Beep.Play(); MessageBox.Show("Error!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); return; } try { if (month == "TODOS") { if (nodo == "TODOS") { new Thread(() => { Thread.CurrentThread.IsBackground = true; cargos = BDManager.GetCargosBasedOn(yearInt); Calcular(cargos); }).Start(); } else { if (Int32.TryParse(nodo, out nodoInt)) { new Thread(() => { Thread.CurrentThread.IsBackground = true; cargos = BDManager.GetCargosBasedOn(yearInt, 0, nodoInt); Calcular(cargos); }).Start(); } else { SystemSounds.Beep.Play(); MessageBox.Show("Error!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); return; } } } else if (nodo == "TODOS") { new Thread(() => { Thread.CurrentThread.IsBackground = true; cargos = BDManager.GetCargosBasedOn(yearInt, mesInt); Calcular(cargos); }).Start(); } else { if (Int32.TryParse(nodo, out nodoInt)) { new Thread(() => { Thread.CurrentThread.IsBackground = true; cargos = BDManager.GetCargosBasedOn(yearInt, mesInt, nodoInt); Calcular(cargos); }).Start(); } else { SystemSounds.Beep.Play(); MessageBox.Show("Error!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); return; } } } catch (Exception) { SystemSounds.Beep.Play(); MessageBox.Show("Error", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); } }