public async Task ExportToExcel() { IsExporting = true; var saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = "C:"; saveFileDialog.Title = "Guardar"; saveFileDialog.FileName = "reporte"; saveFileDialog.DefaultExt = "xls"; saveFileDialog.Filter = "Excel Files|*.xls"; if (saveFileDialog.ShowDialog().Value) { try { await RequestService.Execute(() => { Export(saveFileDialog.FileName); }); } catch (Exception e) { MessageBoxUtils.Error(e.Message); } finally { IsExporting = false; } } }
/// <summary> /// Runs the submit function in background catching common exceptions. /// </summary> /// <param name="submitFunction"></param> /// <returns></returns> public async Task<bool> Submit() { var error = Errors.FirstOrDefault(); if (error != null) { MessageBoxUtils.Error((string)error.ErrorContent); return false; } if (!SubmitValidation()) { MessageBoxUtils.FormIncompleteError(); return false; } try { Loading = true; var result = await RequestService.Execute(() => SubmitFunction()); Loading = false; return result; } catch (Exception e) { MessageBox.Show(e.Message); Loading = false; } return true; }
private void ButtonLocate_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(ViewModel.Organizacion.Latitud) || string.IsNullOrEmpty(ViewModel.Organizacion.Longitud)) { MessageBoxUtils.Error("Debe ingresar las coordenadas de la organizacion para localizarla"); } var header = new OrganizacionHeaderData() { Direccion = ViewModel.Organizacion.Direccion, Latitud = ViewModel.Organizacion.Latitud, Longitud = ViewModel.Organizacion.Longitud, Email = ViewModel.Organizacion.Email, UsuarioInti = ViewModel.Organizacion.UsuarioInti, Telefono = ViewModel.Organizacion.Telefono, Nombre = ViewModel.Organizacion.Nombre, ContactoCargo = ViewModel.Organizacion.ContactoCargo }; var window = new MapWindow(header); window.ShowDialog(); }