Cargando...
Buscando...
Nada coincide
frmReportAction.cs
1using System;
2using System.ComponentModel;
3using System.Data;
4using System.Drawing;
5using System.Windows.Forms;
8using System.Drawing.Printing;
11using sage.ew.db;
12using sage.ew.ewbase;
14using sage.ew.usuario;
15using System.IO;
16using sage.ew.objetos;
19using System.Collections.Generic;
20
22{
26 public partial class frmReportAction : FormDialog
27 {
28 private enum Accion
29 {
30 Impresion = 1,
31 Exportacion = 2,
32 Edicion = 3,
33 Adicional = 4
34 }
35
36 private String _cNombre;
37 private String _cReportBase;
38 private String _cFilePath;
39 private String _cPrinter;
40 private Int16 _iTipo = 15;
41 private Int16 _iPrinterCopies;
42 private Int16 _iPrinterFromPage;
43 private Int16 _iPrinterToPage;
44 private Report.ReportAction _oAction;
45 private Boolean _bEditMode = false;
46 private Boolean _bMostrarOpcionColores = true;
47 private ImpresionNormalMultiple _oTipoImpresion = ImpresionNormalMultiple.Normal;
48 private Boolean _bCargaValoresSageReports = true;
49
50 private Accion _oAccionSeleccionada = Accion.Impresion;
51 //PE-103580
52 private Boolean _bShowEditMode = true;
53
54 private Boolean _bShowExport = true;
55 //PE-97035
56 private IFileDialog365 _oFileDialog365 = null;
57
58 private PrintDocument printDoc = new PrintDocument();
59
60 private UserControl _oUserControlAdicional = null;
61
62 private Usuario _oUsuario = sage.ew.usuario.Usuario._This;
63
68 {
69 get
70 {
71 return _oTipoImpresion;
72 }
73 set
74 {
75 _oTipoImpresion = value;
76 }
77 }
78
83 {
84 get
85 {
86 return _bCargaValoresSageReports;
87 }
88 set
89 {
90 _bCargaValoresSageReports = value;
91 }
92 }
93
97 public UserControl _UserControlAdicional
98 {
99 get
100 {
101 return _oUserControlAdicional;
102 }
103 set
104 {
105 if(value != null)
106 {
107 _oUserControlAdicional = value;
108 if(Created) _ConfiguraUserControlAdicional();
109 }
110 }
111 }
112
116 public String _Nombre
117 {
118 set
119 {
120 if (_cNombre != value)
121 {
122 _cNombre = value;
123 }
124 }
125 }
126
130 public String _ReportBase
131 {
132 set
133 {
134 if (_cReportBase != value)
135 {
136 _cReportBase = value;
137 }
138 }
139 }
140
144 public void _LoadUserParams()
145 {
146 Int16 tiTipo = 99;
147 String lcFilePath = "", lcPrinter = "";
148
149 if (!String.IsNullOrEmpty(_cReportBase) && !String.IsNullOrEmpty(_cNombre) && _bCargaValoresSageReports)
150 {
151 _oUsuario.SageReportLoad(_cReportBase, ref tiTipo, ref lcFilePath, ref lcPrinter);
152
153 _Tipo = tiTipo;
154 _FilePath = _GetPath(lcFilePath);
155 if (!String.IsNullOrEmpty(lcPrinter)) _Printer = lcPrinter;
156 }
157
158 _SetValues();
159 }
160
161 private String _GetPath(string tcFilePath)
162 {
163 String lcFilePath = tcFilePath.Trim();
164
165 if (String.IsNullOrEmpty(lcFilePath))
166 {
167 tcFilePath = Directory.Exists(EW_GLOBAL._Ruta_Exportacion_Docs()) ? EW_GLOBAL._Ruta_Exportacion_Docs() : Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
168 }
169 else if(Directory.Exists(lcFilePath))
170 {
171 tcFilePath = lcFilePath;
172 }
173 else if (Directory.Exists(Path.GetDirectoryName(lcFilePath)))
174 {
175 tcFilePath = Path.GetDirectoryName(lcFilePath);
176 }
177 else
178 {
179 tcFilePath = Directory.Exists(EW_GLOBAL._Ruta_Exportacion_Docs()) ? EW_GLOBAL._Ruta_Exportacion_Docs() : Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
180 }
181
182 if (_ImpresionNormalMultiple == ImpresionNormalMultiple.Normal && !String.IsNullOrEmpty(_cNombre))
183 {
184 tcFilePath = Path.Combine(tcFilePath, _cNombre);
185 }
186
187 return tcFilePath;
188 }
189
194 {
195 get
196 {
197 return EW_GLOBAL._lDebugMode && _bMostrarOpcionColores;
198 }
199 set
200 {
201 _bMostrarOpcionColores = value;
202 }
203 }
204
208 private IFileDialog365 _FileDialog365
209 {
210 get
211 {
212 if(_oFileDialog365 == null) _oFileDialog365 = EW_GLOBAL._FileDialog365;
213 return _oFileDialog365;
214 }
215 }
216
221 {
222 get
223 {
225
226 switch (_Action)
227 {
228 case Report.ReportAction.xls:
229 loTipoExp = DocPrint.eFormato_exportacion.Excel;
230 break;
231 case Report.ReportAction.xlsx:
232 loTipoExp = DocPrint.eFormato_exportacion.Excel_xlsx;
233 break;
234 case Report.ReportAction.html:
235 loTipoExp = DocPrint.eFormato_exportacion.Html;
236 break;
237 case Report.ReportAction.xml:
238 loTipoExp = DocPrint.eFormato_exportacion.Xml;
239 break;
240 case Report.ReportAction.txt:
241 loTipoExp = DocPrint.eFormato_exportacion.txt;
242 break;
243 case Report.ReportAction.delimited:
244 case Report.ReportAction.csv:
245 loTipoExp = DocPrint.eFormato_exportacion.CSV;
246 break;
247 }
248
249 return loTipoExp;
250 }
251 }
252
256 public Boolean _ShowEditMode
257 {
258 get
259 {
260 return _bShowEditMode;
261 }
262 set
263 {
264 _bShowEditMode = value;
265 _ShowHideOptions();
266 }
267 }
268
272 public Boolean _ShowExport
273 {
274 get
275 {
276 return _bShowExport;
277 }
278 set
279 {
280 _bShowExport = value;
281 _ShowHideOptions();
282 }
283 }
284
285
289 public Boolean _ShowVistaPreliminar
290 {
291 get
292 {
293 return ewPreivew.Visible;
294 }
295 set
296 {
297 ewPreivew.Visible = value;
298 }
299 }
300
304 [DefaultValue(Report.ReportAction.preview)]
306 {
307 get
308 {
309 return _oAction;
310 }
311 set
312 {
313 _oAction = value;
314 _iTipo = Convert.ToInt16(value);
315 }
316 }
317
321 [DefaultValue(15)]
322 public Int16 _Tipo
323 {
324 get
325 {
326 return _iTipo;
327 }
328 set
329 {
330 _oAction = (Report.ReportAction)Enum.Parse(typeof(Report.ReportAction), Convert.ToString(value));
331 _iTipo = value;
332 }
333 }
334
338 public String _FilePath
339 {
340 get
341 {
342 return _cFilePath;
343 }
344 set
345 {
346 _cFilePath = value;
347 }
348 }
349
353 public String _Printer
354 {
355 get
356 {
357 return _cPrinter?.Trim();
358 }
359 set
360 {
361 _cPrinter = value;
362 }
363 }
364
368 public Int16 _PrinterCopies
369 {
370 get
371 {
372 return _iPrinterCopies;
373 }
374 set
375 {
376 _iPrinterCopies = value;
377 }
378 }
379
383 public Boolean _EditMode
384 {
385 get
386 {
387 return _bEditMode;
388 }
389 set
390 {
391 _bEditMode = value;
392 }
393 }
394
399 {
400 get
401 {
402 return ckColores.Checked;
403 }
404 }
405
406
410 public Int16 _PrinterFromPage
411 {
412 get
413 {
414 return _iPrinterFromPage;
415 }
416 set
417 {
418 _iPrinterFromPage = value;
419 }
420 }
421
425 public Int16 _PrinterToPage
426 {
427 get
428 {
429 return _iPrinterToPage;
430 }
431 set
432 {
433 _iPrinterToPage = value;
434 }
435 }
436
440 public bool _MostrarExportacionTexto { get; set; } = true;
444 public bool _MostrarExportacionHTML { get; set; } = true;
448 public bool _MostrarExportacionCSV { get; set; } = true;
452 public bool _MostrarExportacionXML { get; set; } = true;
453
454
458 public Boolean _VistaPreliminar
459 {
460 get
461 {
462 return _Action == Report.ReportAction.preview;
463 }
464 }
465
477
478
483 public override void _ShowDialog()
484 {
485 switch(StartPosition)
486 {
487 case FormStartPosition.CenterScreen:
488 Shown += (s, e) => CenterToScreen();
489 break;
490 case FormStartPosition.CenterParent:
491 Shown += (s, e) => CenterToParent();
492 break;
493 }
494
495 base._ShowDialog();
496
497 }
498
503 {
504 InitializeComponent();
505
506 this._MenuOpcionesBoton = false; //PE91513 - el botó d'accessos, favoritos no ha de sortir
507
508 // PARTE 101488
509 if (!this.DesignMode)
510 {
511 this.btPrintOptions.FlatAppearance.BorderSize = 0;
512 this.btExportOptions.FlatAppearance.BorderSize = 0;
513 this.btEditOption.FlatAppearance.BorderSize = 0;
514 }
515 // FPARTE 101488
516 }
517
518 private void buttonFolder_Click(object sender, EventArgs e)
519 {
520 //PE-97035 Añadimos el control FileDialog para O365
521 if (Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_sage50")))
522 {
524 {
525 //PE-104439 Pasamos la carpeta/fichero a seleccionar
526 if (_FileDialog365._GetPathFile("Seleccione el fichero ", tcPath: this.ewtbFileToSave.Text) == DialogResult.OK)
527 {
528 this.ewtbFileToSave.Text = _FileDialog365._Path;
529 }
530 }
531 else
532 {
533 //PE-104439 Pasamos la carpeta/fichero a seleccionar
534 if (_FileDialog365._GetPathFolder("Seleccione el directorio ") == DialogResult.OK)
535 {
536 this.ewtbFileToSave.Text = _FileDialog365._Path;
537 }
538 }
539 }
540 else
541 {
543 {
544 if (saveFileDialog1.ShowDialog() == DialogResult.OK)
545 {
546 this.ewtbFileToSave.Text = saveFileDialog1.FileName;
547 }
548 }
549 else
550 {
551 if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
552 {
553 this.ewtbFileToSave.Text = folderBrowserDialog1.SelectedPath;
554 }
555 }
556 }
557 }
558
559 private void frmReportAction_Load(object sender, EventArgs e)
560 {
561 this.buttonFolder.Image = Resources.open_folder_review_16; //PE-103580
562 this.btExportOptions.Image = Resources.export; // PE-101097
563 this.btPrintOptions.Image = Resources.doc_print; // PE-101097
564 this.btEditOption.Image = Resources.mant_edit; // PE-101097
565
566 _SetConfigImage(this.ewrbExportarXls, Resources.exportr_xls_36);
567 _SetConfigImage(this.ewrbExportarHtml, Resources.exportr_html_36);
568 _SetConfigImage(this.ewrbExportarPdf, Resources.exportr_pdf_36);
569 _SetConfigImage(this.ewrbExportarTexto, Resources.exportr_txt_36);
570 _SetConfigImage(this.ewrbExportarXml, Resources.exportr_xml_36);
571 _SetConfigImage(this.ewrbExportarExcel, Resources.exportr_excel_36);
572 _SetConfigImage(this.ewrbExportarCSV, Resources.exportr_csv_36);
573
574 //CCR 118475 / Bug 119750 : Quitamos la opción de "Tablas dinámicas"
575 this.ewrbExportarExcel.Visible = false;
576 this.ewrbExportarCSV.Visible = _MostrarExportacionCSV;
577 this.ewrbExportarHtml.Visible = _MostrarExportacionHTML;
578 this.ewrbExportarTexto.Visible = _MostrarExportacionTexto;
579 this.ewrbExportarXml.Visible = _MostrarExportacionXML;
580
581 //PE-96061: inicialitzem
582 ewPreivew_CheckedChanged(null, null);
583
585
586 Accion loAccion = Accion.Impresion;
587
588 switch ((Report.ReportAction)_Tipo)
589 {
590 case Report.ReportAction.xls:
591 case Report.ReportAction.pdf:
592 case Report.ReportAction.xlsx:
593 loAccion = Accion.Exportacion;
594 break;
595 case Report.ReportAction.delimited:
596
597 if (_MostrarExportacionCSV) loAccion = Accion.Exportacion;
598 break;
599 case Report.ReportAction.html:
600 if (_MostrarExportacionHTML) loAccion = Accion.Exportacion;
601 break;
602 case Report.ReportAction.txt:
603 if (_MostrarExportacionTexto) loAccion = Accion.Exportacion;
604 break;
605 case Report.ReportAction.xml:
606 if (_MostrarExportacionXML) loAccion = Accion.Exportacion;
607 break;
608 }
609
610 _ShowPrint(loAccion);
611
612 ewPrinterSelector.SetDefautPrinter(new List<String>() { String.IsNullOrWhiteSpace(_Printer) ? _DefaultPrinter() : _Printer, printDoc.PrinterSettings.PrinterName });
613
614 // PE-86800. Aplicar estilos
615 if (this._AplicarEstilos)
616 {
617 if (this._BackColor != SystemColors.Window)
618 {
619 // Apliquem els colors
620 this.ewsplitcontainer1.Panel2.BackColor = this._BackColor;
621
622 // PARTE 101488: TODO: Cuando se tenga tiempo se deberá de revisar que utilice el color definido en el estilo y que se presente con el mismo estilo que en el formulario de listados.
623 // De momento en esta versión lo presentamos con el mismo color del botón que ya tiene el color definido en el estilo
624 // FormListado lfrmlis = new FormListado();
625 // this.ewsplitcontainer1.Panel1.BackColor = lfrmlis._ColorFondoListadosOpciones;
626
627 // Debe de tener el mismo color de fondo, puede que por estilos si
628 this.ewsplitcontainer1.BackColor = this.btEditOption.BackColor;
629 // FPARTE 101488
630 }
631 }
632
633 //PE-103580
634 _ShowHideOptions();
635
636 _ConfiguraUserControlAdicional();
637 }
638
639 private void _SetConfigImage(ewradiobutton toRadioButton, Bitmap toImage)
640 {
641 toRadioButton.Text = String.Format(" {0}",toRadioButton.Text);
642 toRadioButton.Image = toImage;
643 toRadioButton.TextImageRelation = TextImageRelation.ImageBeforeText;
644 toRadioButton.ImageAlign = ContentAlignment.MiddleLeft;
645 }
649 public void _SetValues()
650 {
651 if(Created)
652 {
654 {
655 this.ewtbFileToSave.Text = saveFileDialog1.FileName = _FilePath;
656 }
657 else
658 {
659 this.ewtbFileToSave.Text = folderBrowserDialog1.SelectedPath = _GetPath(_FilePath);
660 }
661
662 switch ((Report.ReportAction)_Tipo)
663 {
664 case Report.ReportAction.preview:
665 ewPreivew.Checked = _ShowVistaPreliminar;
666 break;
667 case Report.ReportAction.html:
668 if (_MostrarExportacionHTML) ewrbExportarHtml.Checked = true;
669 break;
670 case Report.ReportAction.pdf:
671 ewrbExportarPdf.Checked = true;
672 break;
673 case Report.ReportAction.txt:
674 if (_MostrarExportacionTexto) ewrbExportarTexto.Checked = true;
675 break;
676 case Report.ReportAction.xml:
677 if (_MostrarExportacionXML) ewrbExportarXml.Checked = true;
678 break;
679 case Report.ReportAction.xls:
680 case Report.ReportAction.xlsx:
681 if(ewrbExportarXls.Visible) ewrbExportarXls.Checked = true;
682 if (ewrbExportarExcel.Visible) ewrbExportarExcel.Checked = true;
683 break;
684 case Report.ReportAction.delimited:
685
686 if (_MostrarExportacionCSV) ewrbExportarCSV.Checked = true;
687 break;
688 default:
689 break;
690 }
691
692 if (ewrbExportarXls.Checked)
693 {
694 _SetExtensionValue(Report.ReportAction.xlsx);
695 }
696 else if (ewrbExportarHtml.Checked)
697 {
698 _SetExtensionValue(Report.ReportAction.html);
699 }
700 else if (ewrbExportarPdf.Checked)
701 {
702 _SetExtensionValue(Report.ReportAction.pdf);
703 }
704 else if (ewrbExportarTexto.Checked)
705 {
706 _SetExtensionValue(Report.ReportAction.txt);
707 }
708 else if (ewrbExportarXml.Checked)
709 {
710 _SetExtensionValue(Report.ReportAction.xml);
711 }
712 else if (ewrbExportarExcel.Checked)
713 {
714 _SetExtensionValue(Report.ReportAction.xlsx);
715 }
716 else if (ewrbExportarCSV.Checked)
717 {
718 _SetExtensionValue(Report.ReportAction.csv);
719 }
720
721 ewPrinterSelector.Printer = _Printer;
722 }
723 }
724
725 private void _ConfiguraUserControlAdicional()
726 {
727 if(_oUserControlAdicional is UserControl)
728 {
729 ewPanelUserControlAdicional.Controls.Clear();
730 ewPanelUserControlAdicional.Controls.Add(_oUserControlAdicional);
731
732 ewLabelTituloAdicional.Text = "Opciones";
733 if (_oUserControlAdicional is OpcionesAdicionalesImpresion)
734 {
735 OpcionesAdicionalesImpresion loControl = (OpcionesAdicionalesImpresion)_oUserControlAdicional;
736
737 loControl._Initialize();
738 if (!String.IsNullOrEmpty(loControl._Titulo)) ewLabelTituloAdicional.Text = loControl._Titulo;
739
740 ewPanelUserControlAdicional.Height = _oUserControlAdicional.Height;
741 ewPanelUserControlAdicional.AutoSize = true;
742 ewPanelUserControlAdicional.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
743 ewPanelBorder.Visible = true;
744
745 ewPanelBorder.BackColor = System.Drawing.SystemColors.Control;
746 ewpanel3.BackColor = Color.White;
747 }
748 else
749 {
750 ewPanelBorder.Visible = false;
751 this.Width = 510;
752 }
753 }
754 else
755 {
756 ewPanelBorder.Visible = false;
757 this.Width = 510;
758 }
759
760 this.Height = Math.Max(Math.Max(ewPanelUserControlAdicional.Height, ewPanelFichero.Height) + 150, 400);
761 }
762
763
768 private string _DefaultPrinter()
769 {
770 Terminal loTerm = new Terminal();
771 DataTable ldtImpresora = new DataTable();
772 String lcSql, lcPrinterName = "";
773
774 //Determinamos si realemte hay un registro para este código
775 if (loTerm._Existe_Registro())
776 {
777
778 //PE-95961
779 if (Convert.ToBoolean(loTerm._Campo("HERCONFTPV")))
780 {
781 ldtImpresora = new DataTable();
782
783 lcSql = String.Format("SELECT i.NOMBRE FROM {0} i INNER JOIN {1} c ON i.CODIGO = c.IMPRESORA2 WHERE c.CODIGO = '{2}' ", DB.SQLDatabase("TPV", "IMPRESOR"), DB.SQLDatabase("TPV", "CAJAS"), EW_GLOBAL._GetVariable("wc_cajatpv"));
784
785 DB.SQLExec(lcSql, ref ldtImpresora);
786 lcPrinterName = ldtImpresora.Rows.Count > 0 ? Convert.ToString(ldtImpresora.Rows[0][0]).TrimEnd() : ""; //PE-95961 Se añade un trim al nombre de impresora ya que viene con espacios en blanco
787
788 }
789 else
790 {
791 //PE-96827 CAmbio IMPRESORA por IMPNORM
792 if (!String.IsNullOrEmpty(loTerm._Campo("IMPNORM").ToString().Trim()))
793 {
794 ldtImpresora = new DataTable();
795 lcSql = String.Format("SELECT i.NOMBRE FROM {0} i WHERE i.CODIGO = '{1}' ", DB.SQLDatabase("TPV", "IMPRESOR"), loTerm._Campo("IMPNORM"));
796
797 DB.SQLExec(lcSql, ref ldtImpresora);
798 lcPrinterName = ldtImpresora.Rows.Count > 0 ? Convert.ToString(ldtImpresora.Rows[0][0]).TrimEnd() : ""; //PE-95961 Se añade un trim al nombre de impresora ya que viene con espacios en blanco
799 }
800 }
801 //PE-96827
802 if (String.IsNullOrEmpty(lcPrinterName)) lcPrinterName = Convert.ToString(loTerm._Campo("IMPRESORA")).TrimEnd();
803
804 }
805
806 return functions.FUNCTIONS._GetPrinterDriver(lcPrinterName);
807 }
808
812 private void _ShowHideOptions()
813 {
814 btEditOption.Visible = _bShowEditMode;
815 btExportOptions.Visible = _bShowExport;
816 }
817
818 private void btDocAceptar1_Click(object sender, EventArgs e)
819 {
820 Boolean lOk = true;
821 String tcErrorMesage = String.Empty;
822
823 try
824 {
825 if (_oUserControlAdicional is OpcionesAdicionalesImpresion)
826 {
827 lOk = ((OpcionesAdicionalesImpresion)_oUserControlAdicional)._Valida();
828 }
829
830 if (lOk)
831 {
832 if (_oAccionSeleccionada == Accion.Exportacion && !ewrbExportarCSV.Checked && !ewrbExportarXls.Checked && !ewrbExportarHtml.Checked && !ewrbExportarPdf.Checked && !ewrbExportarTexto.Checked && !ewrbExportarXml.Checked && !ewrbExportarExcel.Checked)
833 {
834 throw new Exception("Debe seleccionar un tipo de exportación");
835 }
836
837 if (_oAccionSeleccionada == Accion.Impresion && ewPreivew.Checked)
838 {
839 _Tipo = Convert.ToInt16(Report.ReportAction.preview);
840 }
841 else if (_oAccionSeleccionada == Accion.Impresion && !ewPreivew.Checked)
842 {
843 _Tipo = Convert.ToInt16(Report.ReportAction.prn);
844 }
845 else if (ewrbExportarXls.Checked)
846 {
847 _Tipo = Convert.ToInt16(Report.ReportAction.xlsx);
848 }
849 else if (ewrbExportarHtml.Checked)
850 {
851 _Tipo = Convert.ToInt16(Report.ReportAction.html);
852 }
853 else if (ewrbExportarPdf.Checked)
854 {
855 _Tipo = Convert.ToInt16(Report.ReportAction.pdf);
856 }
857 else if (ewrbExportarTexto.Checked)
858 {
859 _Tipo = Convert.ToInt16(Report.ReportAction.txt);
860 }
861 else if (ewrbExportarXml.Checked)
862 {
863 _Tipo = Convert.ToInt16(Report.ReportAction.xml);
864 }
865 else if (ewrbExportarExcel.Checked)
866 {
867 _Tipo = Convert.ToInt16(Report.ReportAction.xlsx);
868 }
869 else if (ewrbExportarCSV.Checked)
870 {
871 _Tipo = Convert.ToInt16(Report.ReportAction.delimited);
872 }
873
874 if (_oAccionSeleccionada == Accion.Exportacion)
875 {
877 {
878 if (String.IsNullOrEmpty(ewtbFileToSave.Text.Trim()))
879 {
880 throw new Exception("Introduzca el path del fichero a exportar");
881 }
882
883 FileInfo loFileInfo = new FileInfo(ewtbFileToSave.Text);
884 if (String.IsNullOrEmpty(loFileInfo.Name.Replace(loFileInfo.Extension, "").Trim()))
885 {
886 throw new Exception("Introduzca el nombre del fichero");
887 }
888
889 if (ewtbFileToSave.Text != Report._ValidaExtension((Report.ReportAction)_Tipo, ewtbFileToSave.Text))
890 {
891 throw new Exception("Introduzca una extensión correcta");
892 }
893 }
894 else
895 {
896 if (String.IsNullOrEmpty(ewtbFileToSave.Text.Trim()))
897 {
898 throw new Exception("Introduzca el path de exportación");
899 }
900
901 if (!Directory.Exists(ewtbFileToSave.Text))
902 {
903 if (!_FileDialog365._DirectoryExists(ewtbFileToSave.Text))
904 {
905 throw new Exception("Introduzca un path de exportación correcto");
906 }
907 }
908 }
909 }
910
911 _Printer = ewPrinterSelector.Printer;
912 _FilePath = ewtbFileToSave.Text;
913 _EditMode = _oAccionSeleccionada == Accion.Edicion;
914
915 if (!String.IsNullOrEmpty(_cReportBase) && _bCargaValoresSageReports)
916 {
917 _oUsuario.SageReportSave(_cReportBase, _Tipo, _FilePath, _Printer);
918 }
919 }
920 else
921 {
922 throw new Exception("");
923 }
924 }
925 catch (Exception loEx)
926 {
927 if(!String.IsNullOrEmpty(loEx.Message)) this._MessageBox(loEx.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, DialogResult.OK);
928 DialogResult = DialogResult.None;
929 }
930 }
931
932 private void _ShowPrint(Accion toTipo)
933 {
934
935 switch(toTipo)
936 {
937 case Accion.Exportacion:
938
939 ewLabelTitulo.Text = "Exportar";
940 ewPanelImpr.Visible = false;
941 ewPanelFichero.Visible = true;
942 ewPanelEditar.Visible = false;
943
944 //PE-86806
945 if (!ewrbExportarCSV.Checked && !ewrbExportarXls.Checked && !ewrbExportarHtml.Checked && !ewrbExportarExcel.Checked && !ewrbExportarXml.Checked && !ewrbExportarTexto.Checked && !ewrbExportarPdf.Checked && !ewrbExportarHtml.Checked) ewrbExportarXls.Checked = true;
946
947 break;
948 case Accion.Edicion:
949
950 ewLabelTitulo.Text = "Editar";
951 ewPanelImpr.Visible = false;
952 ewPanelFichero.Visible = false;
953 ewPanelEditar.Visible = true;
954
955 break;
956 default:
957 ewLabelTitulo.Text = "Imprimir";
958 ewPanelImpr.Visible = true;
959 ewPanelFichero.Visible = false;
960 ewPanelEditar.Visible = false;
961
962 break;
963 }
964
965 _oAccionSeleccionada = toTipo;
966
967 }
968
969 private void ewrbExportarExcel_CheckedChanged(object sender, EventArgs e)
970 {
971 if (ewrbExportarExcel.Checked) _SetExtensionValue(Report.ReportAction.xlsx);
972 }
973
974 private void ewrbExportarXml_CheckedChanged(object sender, EventArgs e)
975 {
976 if (ewrbExportarXml.Checked) _SetExtensionValue(Report.ReportAction.xml);
977 }
978
979 private void ewrbExportarTexto_CheckedChanged(object sender, EventArgs e)
980 {
981 if (ewrbExportarTexto.Checked) _SetExtensionValue(Report.ReportAction.txt);
982 }
983
984 private void ewrbExportarPdf_CheckedChanged(object sender, EventArgs e)
985 {
986 if (ewrbExportarPdf.Checked) _SetExtensionValue(Report.ReportAction.pdf);
987 }
988
989 private void ewrbExportarHtml_CheckedChanged(object sender, EventArgs e)
990 {
991 if (ewrbExportarHtml.Checked) _SetExtensionValue(Report.ReportAction.html);
992 }
993
994 private void ewrbExportarXls_CheckedChanged(object sender, EventArgs e)
995 {
996 if (ewrbExportarXls.Checked) _SetExtensionValue(Report.ReportAction.xlsx);
997 }
998
999 private void _SetExtensionValue(Report.ReportAction reportAction)
1000 {
1002 {
1003 this.ewtbFileToSave.Text = Report._ValidaExtension(reportAction, this.ewtbFileToSave.Text.Trim());
1004 }
1005 }
1006
1007 private void ewPreivew_CheckedChanged(object sender, EventArgs e)
1008 {
1009 ckColores.Visible = _MostrarOpcionColores && ewPreivew.Checked;
1010 }
1011
1012 private void ewrbExportarCSV_CheckedChanged(object sender, EventArgs e)
1013 {
1014 if (ewrbExportarCSV.Checked) _SetExtensionValue(Report.ReportAction.delimited);
1015 }
1016
1017 private void btPrintOptions_Click(object sender, EventArgs e)
1018 {
1019 _ShowPrint(Accion.Impresion);
1020 }
1021
1022 private void btExportOptions_Click(object sender, EventArgs e)
1023 {
1024 _ShowPrint(Accion.Exportacion);
1025 }
1026
1027 private void btEditOption_Click(object sender, EventArgs e)
1028 {
1029 _ShowPrint(Accion.Edicion);
1030 }
1031
1032 private void btAdicional_Click(object sender, EventArgs e)
1033 {
1034 _ShowPrint(Accion.Adicional);
1035 }
1036 }
1037}
Clase para la impresión de documentos (del tipo que sea)
Definition DocPrint.cs:35
eFormato_exportacion
Tipos de exportación soportados.
Definition DocPrint.cs:40
Color _BackColor
Obtiene o establece el color de fondo del control.
Definition clsFormul.cs:776
bool _AplicarEstilos
Aplicar estilos visuales.
Definition clsFormul.cs:841
DialogResult _MessageBox(String tcMensaje, MessageBoxButtons toBotones, MessageBoxIcon toIcono, MessageBoxDefaultButton toBotonDefecto, DialogResult toResultadoDefecte)
Messagebox propio 1.
FormDialog()
Contructor del formulario FormDialog.
Definition FormDialog.cs:56
Boolean _FieldRandomBackColor
Establece en el modo edición, si pondrá color al fondo de los campos.
bool _MostrarExportacionHTML
Indica si muestra la opción de exportar a HTML.
bool _MostrarExportacionXML
Indica si muestra la opción de exportar a XML.
ImpresionNormalMultiple _ImpresionNormalMultiple
Indica el tipo de impresión.
Boolean _ShowEditMode
PE-103580 Indica si debemos ocultar la edición del report.
DocPrint.eFormato_exportacion _FormatoExportacion
DEvuelve el tipo de exportación.
bool _MostrarExportacionCSV
Indica si muestra la opción de exportar a CSV.
Boolean _CargaValoresSageReports
Indica si guarda/carga los datos de la última impresión.
override void _ShowDialog()
PE92638 Fa el ShowDialog però abans comprova l'accès al formulari.
String _Nombre
Nombre del documento.
UserControl _UserControlAdicional
Control adicional.
Boolean _ShowExport
Indica si debemos ocultar la exportación del report.
bool _MostrarExportacionTexto
Indica si muestra la opción de exportar a Texto.
void _LoadUserParams()
Carga los datos de la ultima impresión del usuario.
Boolean _ShowVistaPreliminar
PE-103580 Indica si debemos ocultar la edición del report.
Boolean _MostrarOpcionColores
Indica si se debe mostrar la opción para poner colores a las columnas.
Report.ReportAction _Action
Acción.
Boolean _VistaPreliminar
Indica si la acción es de preview.
bool _Exportar
Indica si la acción es de exportación.
Clase base para añadir controles adicionales a la pantalla de impresión general.
virtual void _Initialize()
Se ejecuta al cargar el formulario.
ReportAction
PE-84803 enum para las acciones a realizar.
Definition Report.cs:93
@ preview
Previsualizar el documento.
Definition Report.cs:157
@ edit
Editar el documento.
Definition Report.cs:161
Interficie del gestor de ficheros o365.
DialogResult _GetPathFile(string tcTitle, string tcType="Todos los archivos (*.*)|*.*", string tcPath="")
Abre un FileDialog, con selección de ficheros.
DialogResult _GetPathFolder(string tcTitle)
Abre un FileDialog, para la selección de carpetas.
ImpresionNormalMultiple
Indica si es una impresión normal o multiple.
Definition reports.cs:13