/// <summary> /// Genera el excel y lo guarda /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [ecanul] 15/03/2016 Created /// </history> private async void btnToExcel_Click(object sender, RoutedEventArgs e) { StaStart("Loading assistances Excel..."); btnToExcel.IsEnabled = false; //Si tiene LeadSource se toma este de preferencia if (user.LeadSource != null) { filters.Add(Tuple.Create("Lead Sourse", user.LeadSource.lsID)); } else { filters.Add(Tuple.Create("Sales Room", user.SalesRoom.srID)); } _listAssistData = BRAssistance.GetAssistance(enumPalaceType, palaceId, dtpStartt.Value.Value, dtpEndd.Value.Value); if (_listAssistData.Count > 0) { FileInfo file = await ExportReports.RptAssitance(_listAssistData, dtpStartt.Value.Value, dtpEndd.Value.Value, filters); if (file != null) { frmDocumentViewer documentViewver = new frmDocumentViewer(file, user.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false); documentViewver.Owner = this; documentViewver.ShowDialog(); } } else { UIHelper.ShowMessage("There is no Information to generate the report", MessageBoxImage.Exclamation, "Save the data"); } StaEnd(); btnToExcel.IsEnabled = true; }
/// <summary> /// Imprime los datos que se encuentran en el DataGrid de SalesmenChanges /// </summary> /// <history> /// [jorcanche] created 03/10/2016 /// </history> private async void btnPrintSalesmenChangeslog_Click(object sender, RoutedEventArgs e) { try { if (salesmenChangesDataGrid == null) { return; } if (salesmenChangesDataGrid.Items.Count == 0) { UIHelper.ShowMessage("There is no info to make a report"); return; } Mouse.OverrideCursor = Cursors.Wait; FileInfo fileInfo = await ReportBuilder.CreateCustomExcelAsync( TableHelper.GetDataTableFromList((List <SalesmenChanges>)salesmenChangesDataGrid.ItemsSource, true, true, true), new List <Tuple <string, string> > { Tuple.Create((_movementType == "SL") ? "Sale Id" : "Guest Id", ID.ToString()) }, "Salesmen Changes", DateHelper.DateRangeFileName(DateTime.Today, DateTime.Today), EpplusHelper.OrderColumns(salesmenChangesDataGrid.Columns.ToList(), ExportReports.RptSalesmenChanges())); if (fileInfo != null) { frmDocumentViewer documentViewver = new frmDocumentViewer(fileInfo, Context.User.HasPermission(EnumPermission.RptExcel, EnumPermisionLevel.ReadOnly), false); documentViewver.Owner = this; documentViewver.ShowDialog(); } } catch (Exception ex) { UIHelper.ShowMessage(ex); } finally { Mouse.OverrideCursor = null; } }