Cargando...
Buscando...
Nada coincide
LegalizacionLibros.cs
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.ComponentModel.DataAnnotations;
5using System.Data;
6using System.Diagnostics.CodeAnalysis;
7using System.IO;
8using System.Linq;
9using System.Windows.Forms;
10using Ionic.Zip;
12using sage.ew.ewbase;
17using sage.ew.global;
19using sage.ew.objetos;
22
24{
29 {
30 #region ENUMERACIONES INTERNAS
31
32
59
60
76
77
78 #endregion ENUMERACIONES INTERNAS
79
80
81 #region EVENTOS
82
83
88 public delegate void _Error_Message_Linea_After_Handler(string tcMissatge);
89
90
95
96
97 #endregion EVENTOS
98
99
100 #region PROPIEDADES PRIVATE
101
102
109 private ILegalizacionLibrosDA _dataAccessLegalizacionLibros
110 {
111 get
112 {
113 // Recoge el valor de la propiedad _dataAccessDocumentoBase que tiene la clase base DocumentoBase, se
114 // acaba asignando en cualquiera de las llamadas a los constructores de esta clase LegalizacionLibros
115 // cuando se llama a base(legalizacionLibrosDA)
116 //
117 return this._dataAccessDocumentoBase as ILegalizacionLibrosDA;
118 }
119 }
120
124 private int _lnAny = Convert.ToInt32(EW_GLOBAL._GetVariable("wc_any"));
125
126
130 private string _lcAny = Convert.ToString(EW_GLOBAL._GetVariable("wc_any"));
131
132
136 private string _cMonedaEmpresa = Convert.ToString(EW_GLOBAL._GetVariable("wc_moneda"));
137
138
142 private string _cEmpresa = Convert.ToString(EW_GLOBAL._GetVariable("wc_empresa"));
143
144
148 private bool _lEmpresaNormal = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_normal"));
149
150
154 private bool _llEjercicioPartido = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_parti"));
155
156
160 private DateTime _dFechaIniEjer = Convert.ToDateTime(EW_GLOBAL._GetVariable("wd_periodoini"));
161
162
166 private DateTime _dFechaFinEjer = Convert.ToDateTime(EW_GLOBAL._GetVariable("wd_periodofin"));
167
168
169 #endregion PROPIEDADES PRIVATE
170
171
172 #region PROPIEDADES PÚBLICAS
173
174
175 #region PROPIEDADES CABECERA
176
177
181 [FieldName("Empresa")]
182 [DisplayName("EMPRESA")]
183 [ReportProperty("Empresa", "", "Empresa::")]
184 [DefaultValue("")]
185 [DataType(DataType.Text)]
186 public new string _Empresa
187 {
188 get
189 {
190 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._Empresa))));
191 }
192 set
193 {
194 this._Campo(this.GetFieldName(nameof(this._Empresa)), value);
195 }
196 }
197
198
202 [FieldName("Numero")]
203 [DisplayName("Ejercicio:")]
204 [ReportProperty("Numero", "", "Número::")]
205 [DefaultValue("")]
206 [DataType(DataType.Text)]
207 public string _Numero
208 {
209 get
210 {
211 string lcValor = Convert.ToString(_Campo(GetFieldName(nameof(this._Numero)))).Trim().PadRight(8, ' ');
212 if (lcValor.Trim() == "0")
213 lcValor = "";
214
215 return lcValor;
216 }
217 set
218 {
219 // Asignar campo empresa en función de la empresa activa.
220 //
221 this.AsignarValoresClave();
222
223 value = value.PadRight(8);
224
225 this._Campo(this.GetFieldName(nameof(this._Numero)), value );
226 }
227 }
228
229
233 [FieldName("Fecha")]
234 [DisplayName("Fecha solicitud:")]
235 [ReportProperty("Fecha", "dd/MM/yyyy", "Fecha::")]
236 [DataType(DataType.DateTime)]
237 public DateTime _Fecha
238 {
239 get
240 {
241 return Convert.ToDateTime(this._Campo(this.GetFieldName(nameof(this._Fecha))));
242 }
243 set
244 {
245 string lcNombreCampo = this.GetFieldName(nameof(this._Fecha)).ToUpper();
246
247 this._Campo(lcNombreCampo, value);
248 }
249 }
250
251
255 [FieldName("Retencion")]
256 [DisplayName("Solicita retención:")]
257 [ReportProperty("Solicita retención", "", "Solicita retención::")]
258 [DefaultValue(false)]
260 {
261 get
262 {
263 return Convert.ToBoolean(this._Campo(this.GetFieldName(nameof(this._SolicitaRetencion))));
264 }
265 set
266 {
267 this._Campo(this.GetFieldName(nameof(this._SolicitaRetencion)), value);
268 }
269 }
270
271
275 [FieldName("Ruta_dest")]
276 [DefaultValue("")]
277 public string _RutaGeneracion
278 {
279 get
280 {
281 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._RutaGeneracion))));
282 }
283 set
284 {
285 this._Campo(this.GetFieldName(nameof(this._RutaGeneracion)), value);
286 }
287 }
288
289
290 #endregion PROPIEDADES CABECERA
291
292
293 #region PROPIEDADES EMPRESARIO
294
295
299 [FieldName("Emp_nom")]
300 [DisplayName("Nombre empresario:")]
301 [ReportProperty("Nombre empresario", "", "Nombre empresario::")]
302 [DefaultValue("")]
303 public string _NombreEmpresario
304 {
305 get
306 {
307 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NombreEmpresario))));
308 }
309 set
310 {
311 this._Campo(this.GetFieldName(nameof(this._NombreEmpresario)), value);
312 }
313 }
314
315
319 [FieldName("Emp_ap1")]
320 [DisplayName("Apellido 1 empresario:")]
321 [ReportProperty("Apellido 1 empresario", "", "Apellido 1 empresario::")]
322 [DefaultValue("")]
324 {
325 get
326 {
327 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._Apellido1Empresario))));
328 }
329 set
330 {
331 this._Campo(this.GetFieldName(nameof(this._Apellido1Empresario)), value);
332 }
333 }
334
335
339 [FieldName("Emp_ap2")]
340 [DisplayName("Apellido 2 empresario:")]
341 [ReportProperty("Apellido 2 empresario", "", "Apellido 2 empresario::")]
342 [DefaultValue("")]
344 {
345 get
346 {
347 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._Apellido2Empresario))));
348 }
349 set
350 {
351 this._Campo(this.GetFieldName(nameof(this._Apellido2Empresario)), value);
352 }
353 }
354
355
359 [FieldName("Emp_cif")]
360 [DisplayName("Cif empresario:")]
361 [ReportProperty("Cif empresario", "", "Cif empresario::")]
362 [DefaultValue("")]
363 public string _CifEmpresario
364 {
365 get
366 {
367 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CifEmpresario))));
368 }
369 set
370 {
371 this._Campo(this.GetFieldName(nameof(this._CifEmpresario)), value);
372 }
373 }
374
375
379 [FieldName("Emp_direc")]
380 [DisplayName("Dirección empresario:")]
381 [ReportProperty("Dirección empresario", "", "Dirección empresario::")]
382 [DefaultValue("")]
384 {
385 get
386 {
387 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._DireccionEmpresario))));
388 }
389 set
390 {
391 this._Campo(this.GetFieldName(nameof(this._DireccionEmpresario)), value);
392 }
393 }
394
395
399 [FieldName("Emp_codpos")]
400 [DisplayName("Código postal empresario:")]
401 [ReportProperty("Código postal empresario", "", "Código postal empresario::")]
402 [DefaultValue("")]
403 public string _CodposEmpresario
404 {
405 get
406 {
407 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CodposEmpresario))));
408 }
409 set
410 {
411 this._Campo(this.GetFieldName(nameof(this._CodposEmpresario)), value);
412 }
413 }
414
415
419 [FieldName("Emp_ciudad")]
420 [DisplayName("Ciudad empresario:")]
421 [ReportProperty("Ciudad empresario", "", "Ciudad empresario::")]
422 [DefaultValue("")]
423 public string _CiudadEmpresario
424 {
425 get
426 {
427 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CiudadEmpresario))));
428 }
429 set
430 {
431 this._Campo(this.GetFieldName(nameof(this._CiudadEmpresario)), value);
432 }
433 }
434
435
439 [FieldName("Emp_provin")]
440 [DisplayName("Provincia empresario:")]
441 [ReportProperty("Provincia empresario", "", "Provincia empresario::")]
442 [DefaultValue("")]
444 {
445 get
446 {
447 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._ProvinciaEmpresario))));
448 }
449 set
450 {
451 this._Campo(this.GetFieldName(nameof(this._ProvinciaEmpresario)), value);
452 }
453 }
454
455
459 [FieldName("Emp_tel")]
460 [DisplayName("Teléfono empresario:")]
461 [ReportProperty("Teléfono empresario", "", "Teléfono empresario::")]
462 [DefaultValue("")]
464 {
465 get
466 {
467 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._TelefonoEmpresario))));
468 }
469 set
470 {
471 this._Campo(this.GetFieldName(nameof(this._TelefonoEmpresario)), value);
472 }
473 }
474
475
479 [FieldName("Emp_fax")]
480 [DisplayName("Fax empresario:")]
481 [ReportProperty("Fax empresario", "", "Fax empresario::")]
482 [DefaultValue("")]
483 public string _FaxEmpresario
484 {
485 get
486 {
487 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._FaxEmpresario))));
488 }
489 set
490 {
491 this._Campo(this.GetFieldName(nameof(this._FaxEmpresario)), value);
492 }
493 }
494
495
496 #endregion PROPIEDADES EMPRESARIO
497
498
499 #region PROPIEDADES PRESENTADOR
500
501
505 [FieldName("Prs_nom")]
506 [DisplayName("Nombre presentador:")]
507 [ReportProperty("Nombre presentador", "", "Nombre presentador::")]
508 [DefaultValue("")]
509 public string _NombrePresentador
510 {
511 get
512 {
513 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NombrePresentador))));
514 }
515 set
516 {
517 this._Campo(this.GetFieldName(nameof(this._NombrePresentador)), value);
518 }
519 }
520
521
525 [FieldName("Prs_ap1")]
526 [DisplayName("Apellido 1 presentador:")]
527 [ReportProperty("Apellido 1 presentador", "", "Apellido 1 presentador::")]
528 [DefaultValue("")]
530 {
531 get
532 {
533 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._Apellido1Presentador))));
534 }
535 set
536 {
537 this._Campo(this.GetFieldName(nameof(this._Apellido1Presentador)), value);
538 }
539 }
540
541
545 [FieldName("Prs_ap2")]
546 [DisplayName("Apellido 2 presentador:")]
547 [ReportProperty("Apellido 2 presentador", "", "Apellido 2 presentador::")]
548 [DefaultValue("")]
550 {
551 get
552 {
553 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._Apellido2Presentador))));
554 }
555 set
556 {
557 this._Campo(this.GetFieldName(nameof(this._Apellido2Presentador)), value);
558 }
559 }
560
561
565 [FieldName("Prs_cif")]
566 [DisplayName("Cif presentador:")]
567 [ReportProperty("Cif presentador", "", "Cif presentador::")]
568 [DefaultValue("")]
569 public string _CifPresentador
570 {
571 get
572 {
573 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CifPresentador))));
574 }
575 set
576 {
577 this._Campo(this.GetFieldName(nameof(this._CifPresentador)), value);
578 }
579 }
580
581
585 [FieldName("Prs_direc")]
586 [DisplayName("Dirección presentador:")]
587 [ReportProperty("Dirección presentador", "", "Dirección presentador::")]
588 [DefaultValue("")]
590 {
591 get
592 {
593 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._DireccionPresentador))));
594 }
595 set
596 {
597 this._Campo(this.GetFieldName(nameof(this._DireccionPresentador)), value);
598 }
599 }
600
601
605 [FieldName("Prs_codpos")]
606 [DisplayName("Código postal presentador:")]
607 [ReportProperty("Código postal presentador", "", "Código postal presentador::")]
608 [DefaultValue("")]
609 public string _CodposPresentador
610 {
611 get
612 {
613 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CodposPresentador))));
614 }
615 set
616 {
617 this._Campo(this.GetFieldName(nameof(this._CodposPresentador)), value);
618 }
619 }
620
621
625 [FieldName("Prs_ciudad")]
626 [DisplayName("Ciudad presentador:")]
627 [ReportProperty("Ciudad presentador", "", "Ciudad presentador::")]
628 [DefaultValue("")]
629 public string _CiudadPresentador
630 {
631 get
632 {
633 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CiudadPresentador))));
634 }
635 set
636 {
637 this._Campo(this.GetFieldName(nameof(this._CiudadPresentador)), value);
638 }
639 }
640
641
645 [FieldName("Prs_provin")]
646 [DisplayName("Provincia presentador:")]
647 [ReportProperty("Provincia presentador", "", "Provincia presentador::")]
648 [DefaultValue("")]
650 {
651 get
652 {
653 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._ProvinciaPresentador))));
654 }
655 set
656 {
657 this._Campo(this.GetFieldName(nameof(this._ProvinciaPresentador)), value);
658 }
659 }
660
661
665 [FieldName("Prs_tel")]
666 [DisplayName("Teléfono presentador:")]
667 [ReportProperty("Teléfono presentador", "", "Teléfono presentador::")]
668 [DefaultValue("")]
670 {
671 get
672 {
673 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._TelefonoPresentador))));
674 }
675 set
676 {
677 this._Campo(this.GetFieldName(nameof(this._TelefonoPresentador)), value);
678 }
679 }
680
681
685 [FieldName("Prs_fax")]
686 [DisplayName("Fax presentador:")]
687 [ReportProperty("Fax presentador", "", "Fax presentador::")]
688 [DefaultValue("")]
689 public string _FaxPresentador
690 {
691 get
692 {
693 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._FaxPresentador))));
694 }
695 set
696 {
697 this._Campo(this.GetFieldName(nameof(this._FaxPresentador)), value);
698 }
699 }
700
701
705 [FieldName("Prs_email")]
706 [DisplayName("Email presentador:")]
707 [ReportProperty("Email presentador", "", "Email presentador::")]
708 [DefaultValue("")]
709 public string _EmailPresentador
710 {
711 get
712 {
713 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._EmailPresentador))));
714 }
715 set
716 {
717 this._Campo(this.GetFieldName(nameof(this._EmailPresentador)), value);
718 }
719 }
720
721
722 #endregion PROPIEDADES PRESENTADOR
723
724
725 #region PROPIEDADES REGISTRO
726
727
731 [FieldName("Rgs_codigo")]
732 [DisplayName("Código de Registro:")]
733 [ReportProperty("Código de registro", "", "Código de registro::")]
734 [DefaultValue("")]
735 public string _CodigoRegistro
736 {
737 get
738 {
739 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._CodigoRegistro))));
740 }
741 set
742 {
743 this._Campo(this.GetFieldName(nameof(this._CodigoRegistro)), value);
744 }
745 }
746
747
751 [FieldName("Rgs_tomo")]
752 [DisplayName("Número de tomo registro:")]
753 [ReportProperty("Número de tomo registro", "", "Número de tomo registro::")]
754 [DefaultValue("")]
756 {
757 get
758 {
759 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NumeroTomoRegistro))));
760 }
761 set
762 {
763 this._Campo(this.GetFieldName(nameof(this._NumeroTomoRegistro)), value);
764 }
765 }
766
767
771 [FieldName("Rgs_libro")]
772 [DisplayName("Número de libro registro:")]
773 [ReportProperty("Número de libro registro", "", "Número de libro registro::")]
774 [DefaultValue("")]
776 {
777 get
778 {
779 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NumeroLibroRegistro))));
780 }
781 set
782 {
783 this._Campo(this.GetFieldName(nameof(this._NumeroLibroRegistro)), value);
784 }
785 }
786
787
791 [FieldName("Rgs_sec")]
792 [DisplayName("Número de sección registro:")]
793 [ReportProperty("Número de sección registro", "", "Número de sección registro::")]
794 [DefaultValue("")]
796 {
797 get
798 {
799 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NumeroSeccionRegistro))));
800 }
801 set
802 {
803 this._Campo(this.GetFieldName(nameof(this._NumeroSeccionRegistro)), value);
804 }
805 }
806
807
811 [FieldName("Rgs_folio")]
812 [DisplayName("Número de folio:")]
813 [ReportProperty("Número de folio registro", "", "Número de folio registro::")]
814 [DefaultValue("")]
816 {
817 get
818 {
819 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NumeroFolioRegistro))));
820 }
821 set
822 {
823 this._Campo(this.GetFieldName(nameof(this._NumeroFolioRegistro)), value);
824 }
825 }
826
827
831 [FieldName("Rgs_hoja")]
832 [DisplayName("Número de hoja registro:")]
833 [ReportProperty("Número de hoja registro", "", "Número de hoja registro::")]
834 [DefaultValue("")]
836 {
837 get
838 {
839 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._NumeroHojaRegistro))));
840 }
841 set
842 {
843 this._Campo(this.GetFieldName(nameof(this._NumeroHojaRegistro)), value);
844 }
845 }
846
850 [FieldName("Rgs_irus")]
851 [DisplayName("Identificador registral único de la sociedad:")]
852 [ReportProperty("Identificador registral único de la sociedad", "", "Identificador registral único de la sociedad::")]
853 [DefaultValue("")]
854 public string _IRUS
855 {
856 get
857 {
858 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._IRUS))));
859 }
860 set
861 {
862 this._Campo(this.GetFieldName(nameof(this._IRUS)), value);
863 }
864 }
865
866
870 [FieldName("Rgs_trp")]
871 [DisplayName("Tipo de registro mercantil:")]
872 [ReportProperty("Tipo de registro mercantil", "", "Tipo de registro mercantil::")]
873 [DefaultValue("")]
875 {
876 get
877 {
878 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._TipoRegistroMercantil))));
879 }
880 set
881 {
882 this._Campo(this.GetFieldName(nameof(this._TipoRegistroMercantil)), value);
883 }
884 }
885
886
890 [FieldName("Rgs_otros")]
891 [DisplayName("Otros:")]
892 [ReportProperty("Otros", "", "Otros::")]
893 [DefaultValue("")]
895 {
896 get
897 {
898 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._OtrosRegistroMercantil))));
899 }
900 set
901 {
902 this._Campo(this.GetFieldName(nameof(this._OtrosRegistroMercantil)), value);
903 }
904 }
905
906
910 [FieldName("Rgs_rm")]
911 [DisplayName("Registro mercantil:")]
912 [ReportProperty("Registro mercantil", "", "Registro mercantil::")]
913 [DefaultValue("")]
914 public string _RegistroMercantil
915 {
916 get
917 {
918 return Convert.ToString(this._Campo(this.GetFieldName(nameof(this._RegistroMercantil))));
919 }
920 set
921 {
922 this._Campo(this.GetFieldName(nameof(this._RegistroMercantil)), value);
923 }
924 }
925
926
935 [FieldName("Tot_libr")]
936 [DisplayName("Nº de libros presentados:")]
937 [ReportProperty("Número libros presentados", "", "Nº libros presentados::")]
938 [DefaultValue(0)]
940 {
941 get
942 {
943 return Convert.ToInt32(this._Campo(this.GetFieldName(nameof(this._NumeroLibrosPresentados))));
944 }
945 set
946 {
947 this._Campo(this.GetFieldName(nameof(this._NumeroLibrosPresentados)), value);
948 }
949 }
950
951
952 #endregion PROPIEDADES REGISTRO
953
954
955 #region PROPIEDADES IDOCUMENTOIMPRIMIBLE SOBREESCRITAS
956
957
961 public override IDocPrint _DocPrint
962 {
963 get
964 {
965 if (_oDocPrint == null) _oDocPrint = new DocPrintLegalizacionLibros(this);
966 return _oDocPrint;
967 }
968 set
969 {
970 if (value is DocPrintLegalizacionLibros)
972 }
973 }
974
975
976 #endregion PROPIEDADES IDOCUMENTOIMPRIMIBLE SOBREESCRITAS
977
978
979 #region PROPIEDADES VARIAS
980
981
985 public int _NumeroLibros
986 {
987 get
988 {
989 return this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrWhiteSpace(x._RutaArchivo)).Count();
990 }
991 }
992
993
1003 public new string _Error_Message
1004 {
1005 get { return _cError_message; }
1006 set { _cError_message = value; }
1007 }
1008 private string _cError_message = "";
1009
1010
1014 public string _Warning_Message
1015 {
1016 get { return _cWarning_Message; }
1017 set { this._cWarning_Message = value; }
1018 }
1019 private string _cWarning_Message = "";
1020
1021
1029 {
1030 get { return _cError_Message_Linea; }
1031 set
1032 {
1033 _cError_Message_Linea = value;
1034
1035 if (!string.IsNullOrWhiteSpace(_cError_Message_Linea))
1036 {
1037 if (this._Error_Message_Linea_After != null)
1038 this._Error_Message_Linea_After(_cError_Message_Linea);
1039 }
1040 }
1041 }
1042 private string _cError_Message_Linea = "";
1043
1044
1049 {
1050 get
1051 {
1053 }
1054 }
1055
1056
1060 public override string _Nombre
1061 {
1062 get { return "LegalizaciónLibros."+this._lcAny.Trim(); }
1063 set
1064 {
1065 }
1066 }
1067
1068
1072 public TipoImpresion _TipoImpresion = TipoImpresion.SolicitudLegalizacion;
1073
1074
1075 #endregion PROPIEDADES VARIAS
1076
1077
1078 #region PROPIEDADES SOBREESCRITAS DE DOCUMENTOBASE
1079
1080
1087 public override bool _Solo_Lectura
1088 {
1089 get
1090 {
1091 // Continuo haciendo el control sobre la base por si añaden algo de código más que no tengamos aquí.
1092 //
1093 bool llLectura = base._Solo_Lectura;
1094 if (!llLectura)
1095 {
1096 // Caso de que en la base no haya restringido el acceso, aplico el código propio aquí.
1097 //
1098 formul._TiposAccesosPantalla lnSoloLectura = this._oUsuario._Acceso(this._Pantalla);
1099 llLectura = this._EnUso ||
1100 lnSoloLectura == formul._TiposAccesosPantalla.Denegado ||
1101 lnSoloLectura == formul._TiposAccesosPantalla.SoloLectura;
1102 }
1103
1104 return llLectura;
1105 }
1106 }
1107
1108
1109 #endregion PROPIEDADES SOBREESCRITAS DE DOCUMENTOBASE
1110
1111
1112 #endregion PROPIEDADES PÚBLICAS
1113
1114
1115 #region CONSTRUCTORES
1116
1117
1121 public LegalizacionLibros() : this( Convert.ToString(EW_GLOBAL._GetVariable("wc_any")),
1123 {
1124 }
1125
1130 public LegalizacionLibros(string tcEjercicio) : this(tcEjercicio, new LegalizacionLibrosDA())
1131 {
1132 }
1133
1138 public LegalizacionLibros(ILegalizacionLibrosDA legalizacionLibrosDA) :
1139 this(Convert.ToString(EW_GLOBAL._GetVariable("wc_any")), new LegalizacionLibrosDA())
1140 {
1141 }
1142
1155 public LegalizacionLibros(string tcEjercicio, ILegalizacionLibrosDA legalizacionLibrosDA) :
1156 base(legalizacionLibrosDA)
1157 {
1158 if (legalizacionLibrosDA == null)
1159 {
1160 throw new ArgumentNullException(nameof(legalizacionLibrosDA), "El parámetro de acceso a datos legalizacionLibrosDA no puede tener valor null.");
1161 }
1162
1163 // Tareas a realizar en el constructor del objeto LegalizacionLibros
1164 //
1165 this.legalizacionLibrosConstructor();
1166
1167 // Asignación del ejercicio lo cual ya acaba desenacadenando toda la carga del objeto
1168 // LegalizacionLibros entero. Si llega un "" no cargaré nada.
1169 //
1170 if (!string.IsNullOrWhiteSpace(tcEjercicio))
1171 {
1172 if (this._Comprobar_Existe_Documento(tcEjercicio))
1173 {
1174 this._Numero = tcEjercicio.Trim().PadRight(8, ' ');
1175
1176 this._LineasLegalizacionLibros._Load();
1177 }
1178 }
1179
1180 return;
1181 }
1182
1183
1187 private void legalizacionLibrosConstructor()
1188 {
1189 // No está permitido utilizar objetos de negocio de LegalizacionLibros en empresas consolidadas.
1190 //
1191 if (!this._lEmpresaNormal)
1192 return;
1193
1194 // Pensar que el método Inicializar() de la clase se ejecuta antes de llegar aquí pues lo llama la clase base
1195 // 'DocumentoBase' en su constructor lo cual ocurre antes de llegar aquí.
1196
1197
1198 // Programar evento para que al cambiar el estado del mantenimiento, cambie también el estado
1199 // del documento.
1200 //
1201 this._Mantenimiento_Estado_Change += this.legalizacionLibros_Actualizar_Estado_Documento;
1202
1203 // Declaración de la condición para impedir que mediante navegación se pueda acceder a una legalización de otra empresa.
1204 // Si bien en el formulario de legalización de libros no se permite la navegación, ponemos el control para asegurar por si algún día
1205 // se activa esta posibilidad.
1206 //
1207 this.Navegacion._Condicion = "EMPRESA=" + this._dataAccessLegalizacionLibros.SQLString(this._cEmpresa);
1208
1209 return;
1210 }
1211
1212
1213 #endregion CONSTRUCTORES
1214
1215
1216 #region MÉTODOS PROTECTED OVERRIDE SOBREESCRITOS DE CLASE BASE 'DOCUMENTOBASE'
1217
1218
1225 protected override void Inicializar()
1226 {
1227 // Asignamos las propiedades para el mantenimiento.
1228 //
1229 this._Clave = "EMPRESA,NUMERO";
1230 this._DataBase = "COMUNES";
1231 this._Tabla = "C_LEGLBR";
1232 this._TituloMantenimiento = "Legalización de libros";
1233 this._TituloCabecera = "Legalización de libros";
1234 this._TituloMenu = "Legalizacion de libros";
1235 this._Campo_Nombre = "EMP_NOM";
1236 this._Browser_Campos = "";
1237 this._Browser_Titulos_Campos = "";
1238 this._Browser_Campo_Predet = "";
1239
1240
1241 this._Pantalla = "LEGALIBR";
1242 this._FormManteBaseType = typeof(frmLegalizacionLibros);
1243
1244 this._DetalleDocumentoType = typeof(LineasLegalizacionLibros);
1245 this._TypeLinea = typeof(LineasLegalizacionLibros.LineaLegalizacionLibros);
1246
1247 this._ReportTitlePreview = this._TituloMantenimiento;
1248 this._ReportBase = "DocumentoLegalizacion";
1249
1250 return;
1251 }
1252
1253
1257 protected override void AsignarValoresClave()
1258 {
1259 if (string.IsNullOrWhiteSpace(this._Empresa))
1260 this._Empresa = this._cEmpresa;
1261
1262 return;
1263 }
1264
1265
1266 #endregion MÉTODOS PROTECTED OVERRIDE SOBREESCRITOS DE CLASE BASE 'DOCUMENTOBASE'
1267
1268
1269 #region MÉTODOS PUBLIC OVERRIDE SOBREESCRITOS DE CLASE BASE 'DOCUMENTOBASE'
1270
1271
1276 [ExcludeFromCodeCoverage]
1277 public override void _Show()
1278 {
1279 // Lo asocio a la propiedad _FormMante de negocio pues así se sabe internamente
1280 // que negocio está ligado a visual.
1281 //
1282 this._FormMante = new frmLegalizacionLibros(this);
1283 this._FormMante._Show();
1284
1285 if (!string.IsNullOrWhiteSpace(this._Codigo))
1286 {
1287 if (this._FormMante != null)
1288 this._FormMante._Cargar_Documento();
1289 }
1290
1291 return;
1292 }
1293
1294
1300 [ExcludeFromCodeCoverage]
1301 public override bool _Show_Print(int tnAbrirEn = 1)
1302 {
1303 return true;
1304 }
1305
1306
1312 public override Dictionary<string, object> _Obtener_Filtros_SageReports(Dictionary<string, object> tdicParametros = null)
1313 {
1314
1315 Dictionary<string, object> ldicFiltros = new Dictionary<string, object>();
1316
1317 switch (this._TipoImpresion)
1318 {
1319 case TipoImpresion.SolicitudLegalizacion:
1320
1321 // En este report toda la información la tenemos colocada en la banda detalle del report, con un único registro en el que se
1322 // mostrarán todos los campos. No hay banda de cabecera, por tanto, no hay filtros de cabecera.
1323 //
1324
1325 break;
1326
1327 case TipoImpresion.CertificadoFirmas:
1328
1329 // Datos cabecera report, se imprimen estos datos en cabecera y luego para cada linea de libro se imprime una serie de campos y el
1330 // código de barras de la firma en formato EAN.
1331 //
1332 ldicFiltros.Add("wc_nomape1ape2_empresario", this._NombreEmpresario.Trim() + " " + this._Apellido1Empresario.Trim() + this._Apellido2Empresario.Trim());
1333 ldicFiltros.Add("wc_cif_empresario", this._CifEmpresario.Trim());
1334 ldicFiltros.Add("wc_direccion_empresario", this._DireccionEmpresario.Trim());
1335 ldicFiltros.Add("wc_ciudad_empresario", this._CiudadEmpresario.Trim());
1336 ldicFiltros.Add("wc_codpos_empresario", this._CodposEmpresario.Trim());
1337 ldicFiltros.Add("wc_provincia_empresario", this._ProvinciaEmpresario.Trim());
1338 ldicFiltros.Add("wc_fax_empresario", this._FaxEmpresario.Trim());
1339 ldicFiltros.Add("wc_telefono_empresario", this._TelefonoEmpresario.Trim());
1340
1341 string lcFechaEnDtos = this.getDtosFecha(this._Fecha);
1342 if (!string.IsNullOrWhiteSpace(lcFechaEnDtos))
1343 lcFechaEnDtos = lcFechaEnDtos.Substring(0, 2) + " " + lcFechaEnDtos.Substring(2, 2) + " " + lcFechaEnDtos.Substring(4);
1344 else
1345 lcFechaEnDtos = "";
1346 ldicFiltros.Add("wc_fecha_socilitud", lcFechaEnDtos.Trim());
1347
1348 ldicFiltros.Add("wc_tomo_registro", this._NumeroTomoRegistro.Trim());
1349 ldicFiltros.Add("wc_folio_registro", this._NumeroFolioRegistro.Trim());
1350 ldicFiltros.Add("wc_hoja_registro", this._NumeroHojaRegistro.Trim());
1351 ldicFiltros.Add("wc_otros_registro", this._OtrosRegistroMercantil.Trim());
1352 ldicFiltros.Add("wc_tiporebpub_registro", this._TipoRegistroMercantil.Trim());
1353 ldicFiltros.Add("wc_irus_registro", this._IRUS.Trim());
1354
1355 ldicFiltros.Add("wc_numlibros", Convert.ToString(this._NumeroLibros));
1356
1357 break;
1358 }
1359
1360 return ldicFiltros;
1361 }
1362
1363
1369 public override DataTable _Obtener_Datos_SageReports(Dictionary<string, object> tdicParametros = null)
1370 {
1371 DataTable loDt = new DataTable();
1372
1373 switch (this._TipoImpresion)
1374 {
1375 case TipoImpresion.SolicitudLegalizacion:
1376
1377 // Haremos como si el report fuera de un solo registro de detalle y todo lo que colocariamos en cabecera del report lo colocamos
1378 // en detalle, siguiente consejo de Jose Sevillano.
1379 //
1380
1381 // Creamos la estructura del DataTable que alimentará el detalle del report (detalle de una única linea).
1382
1383 // Registro mercantil.
1384 //
1385 loDt.Columns.Add("registro_mercantil", typeof(String)).Caption = "Registro mercantil";
1386
1387 // Datos varios.
1388 //
1389 loDt.Columns.Add("solicita_retencion", typeof(String)).Caption = "Solicita retención";
1390 loDt.Columns.Add("fecha_solicitud", typeof(String)).Caption = "Fecha solicitud";
1391 loDt.Columns.Add("num_libros", typeof(int)).Caption = "Número libros";
1392
1393 // Empresario.
1394 //
1395 loDt.Columns.Add("nombre_empresario", typeof(String)).Caption = "Nombre empresario";
1396 loDt.Columns.Add("cif_empresario", typeof(String)).Caption = "Cif empresario";
1397 loDt.Columns.Add("direccion_empresario", typeof(String)).Caption = "Dirección empresario";
1398 loDt.Columns.Add("ciudad_empresario", typeof(String)).Caption = "Ciudad empresario";
1399 loDt.Columns.Add("codpos_empresario", typeof(String)).Caption = "Codpos empresario";
1400
1401 // Presentador
1402 //
1403 loDt.Columns.Add("nombre_presentador", typeof(String)).Caption = "Nombre presentador";
1404 loDt.Columns.Add("cif_presentador", typeof(String)).Caption = "Cif presentador";
1405 loDt.Columns.Add("direccion_presentador", typeof(String)).Caption = "Direccion presentador";
1406 loDt.Columns.Add("ciudad_presentador", typeof(String)).Caption = "Ciudad presentador";
1407 loDt.Columns.Add("codpos_presentador", typeof(String)).Caption = "C.Postal presentador";
1408 loDt.Columns.Add("provincia_presentador", typeof(String)).Caption = "Provincia presentador";
1409 loDt.Columns.Add("fax_presentador", typeof(String)).Caption = "Fax presentador";
1410 loDt.Columns.Add("telefono_presentador", typeof(String)).Caption = "Teléfono presentador";
1411 loDt.Columns.Add("email_presentador", typeof(String)).Caption = "Email presentador";
1412
1413 // Creo un registro para el report y le relleno los datos.
1414 //
1415
1416 DataRow loRow = loDt.NewRow();
1417 loRow["registro_mercantil"] = Convert.ToString(this._RegistroMercantil.Trim());
1418 loRow["solicita_retencion"] = this._SolicitaRetencion ? "SI" : "NO";
1419
1420 string lcFechaEnDtos = this.getDtosFecha(this._Fecha);
1421 if (!string.IsNullOrWhiteSpace(lcFechaEnDtos))
1422 loRow["fecha_solicitud"] = lcFechaEnDtos.Substring(0, 2) + " " + lcFechaEnDtos.Substring(2, 2) + " " + lcFechaEnDtos.Substring(4);
1423 else
1424 loRow["fecha_solicitud"] = "";
1425
1426 loRow["num_libros"] = Convert.ToInt32(this._NumeroLibros);
1427
1428 loRow["nombre_empresario"] = this._NombreEmpresario.Trim() + " " + this._Apellido1Empresario.Trim() + " " + this._Apellido2Empresario.Trim();
1429 loRow["cif_empresario"] = this._CifEmpresario.Trim();
1430 loRow["direccion_empresario"] = this._DireccionEmpresario.Trim();
1431 loRow["ciudad_empresario"] = this._CiudadEmpresario.Trim();
1432 loRow["codpos_empresario"] = this._CodposEmpresario.Trim();
1433
1434 loRow["nombre_presentador"] = this._NombrePresentador.Trim() + " " + this._Apellido1Presentador.Trim() + " " + this._Apellido2Presentador.Trim();
1435 loRow["cif_presentador"] = this._CifPresentador.Trim();
1436 loRow["direccion_presentador"] = this._DireccionPresentador.Trim();
1437 loRow["ciudad_presentador"] = this._CiudadPresentador.Trim();
1438 loRow["codpos_presentador"] = this._CodposPresentador.Trim();
1439 loRow["provincia_presentador"] = this._ProvinciaPresentador.Trim();
1440 loRow["fax_presentador"] = this._FaxPresentador.Trim();
1441 loRow["telefono_presentador"] = this._TelefonoPresentador.Trim();
1442 loRow["email_presentador"] = this._EmailPresentador.Trim();
1443
1444 loDt.Rows.Add(loRow);
1445
1446 break;
1447
1448 case TipoImpresion.CertificadoFirmas:
1449
1450 loDt.Columns.Add("tipo_libro", typeof(String)).Caption = "Tipo libro";
1451 loDt.Columns.Add("num_libro", typeof(int)).Caption = "Nº libro";
1452 loDt.Columns.Add("fec_apertura", typeof(String)).Caption = "Fecha apert.";
1453 loDt.Columns.Add("fec_cierre", typeof(String)).Caption = "Fecha cierre";
1454 loDt.Columns.Add("firma", typeof(String)).Caption = "Firma";
1455
1456 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLinea in this._LineasLegalizacionLibros._Items)
1457 {
1458 DataRow loRowLibro = loDt.NewRow();
1459
1460 loRowLibro["tipo_libro"] = loLinea._TipoLibro;
1461 loRowLibro["num_libro"] = Convert.ToInt32(loLinea._NumLibro);
1462 if (loLinea._FecApertura != null)
1463 loRowLibro["fec_apertura"] = Convert.ToDateTime(loLinea._FecApertura).ToShortDateString();
1464 else
1465 loRowLibro["fec_apertura"] = "";
1466
1467 if (loLinea._FecCierre != null)
1468 loRowLibro["fec_cierre"] = Convert.ToDateTime(loLinea._FecCierre).ToShortDateString();
1469 else
1470 loRowLibro["fec_cierre"] = "";
1471
1472 loRowLibro["firma"] = loLinea._Firma;
1473
1474 loDt.Rows.Add(loRowLibro);
1475 }
1476
1477 break;
1478 }
1479
1480 return loDt;
1481 }
1482
1483
1489 public override bool _Comprobar_Existe_Documento(string tcEjercicio)
1490 {
1491 return this._dataAccessLegalizacionLibros._Comprobar_Existe_Documento(this._DataBase, this._Tabla, this._cEmpresa, tcEjercicio);
1492 }
1493
1494
1499 [ExcludeFromCodeCoverage]
1500 public override bool _Delete()
1501 {
1502 // Como en legalización de libros siempre tendremos cargado un ejercicio y de momento no permitimos borrar, eliminamos todo el código que
1503 // pudiera implementarse aquí, para prevenir que la clase base DocumentoBase ejecute su propio código _Delete()
1504
1505 return true;
1506 }
1507
1508
1509 #endregion MÉTODOS PÚBLIC OVERRIDE SOBREESCRITOS DE CLASE BASE 'DOCUMENTOBASE'
1510
1511
1512 #region MÉTODOS PROTECTED OVERRIDE SOBREESCRITOS DE CLASE BASE 'EWMANTE'
1513
1514
1521 public override bool _Save_Before()
1522 {
1523 if (!string.IsNullOrWhiteSpace(this._Numero))
1524 {
1525 // Para que no guarde hora ni minutos en la fecha.
1526 //
1527 if (this._Fecha.Hour != 0 || this._Fecha.Minute != 0 || this._Fecha.Second != 0)
1528 {
1529 DateTime ldFecha = new DateTime(this._Fecha.Year, this._Fecha.Month, this._Fecha.Day);
1530 this._Fecha = ldFecha;
1531 }
1532
1533 // Guardo en la propiedad que hace referencia al campo físico de nº de libros presentados, el nº de libros que tenemos actualmente en la
1534 // legalización para que al hacer el _Save() guarde ese número en la base de datos.
1535 //
1536 this._NumeroLibrosPresentados = this._NumeroLibros;
1537 }
1538
1539 return true;
1540 }
1541
1542
1543 #endregion MÉTODOS PROTECTED OVERRIDE SOBREESCRITOS DE CLASE BASE 'EWMANTE'
1544
1545
1546 #region MÉTODOS PRIVADOS
1547
1548
1549 #region MÉTODOS PRIVADOS PARA IMPORTAR LEGALIZACION DE FICHERO ZIP
1550
1551
1556 private bool algunDatoDeclaradoDatosPresentacion()
1557 {
1558 // Empresario
1559 //
1560 if (!string.IsNullOrWhiteSpace(this._NombreEmpresario + this._Apellido1Empresario + this._Apellido2Empresario + this._CifEmpresario))
1561 return true;
1562
1563 if (!string.IsNullOrWhiteSpace(this._DireccionEmpresario + this._CodposEmpresario + this._CiudadEmpresario + this._ProvinciaEmpresario))
1564 return true;
1565
1566 if (!string.IsNullOrWhiteSpace(this._TelefonoEmpresario + this._FaxEmpresario))
1567 return true;
1568
1569
1570 // Presentador
1571 //
1572 if (!string.IsNullOrWhiteSpace(this._NombrePresentador + this._Apellido1Presentador + this._Apellido2Presentador + this._CifPresentador))
1573 return true;
1574
1575 if (!string.IsNullOrWhiteSpace(this._DireccionPresentador + this._CodposPresentador + this._CiudadPresentador + this._ProvinciaPresentador))
1576 return true;
1577
1578 if (!string.IsNullOrWhiteSpace(this._TelefonoPresentador + this._FaxPresentador + this._EmailPresentador))
1579 return true;
1580
1581
1582 // Datos registrales
1583 //
1584 if (!string.IsNullOrWhiteSpace(this._CodigoRegistro + this._NumeroTomoRegistro + this._Apellido2Presentador + this._CifPresentador))
1585 return true;
1586
1587 if (!string.IsNullOrWhiteSpace(this._NumeroFolioRegistro + this._NumeroHojaRegistro + this._TipoRegistroMercantil + this._OtrosRegistroMercantil))
1588 return true;
1589
1590 if (!string.IsNullOrWhiteSpace(this._RegistroMercantil))
1591 return true;
1592
1593 if (!string.IsNullOrWhiteSpace(this._IRUS))
1594 return true;
1595
1596 return false;
1597 }
1598
1599
1605 [ExcludeFromCodeCoverage]
1606 private bool seleccionarArchivoZipValido(out string tcRutaArchivoZip)
1607 {
1608 string lcCarpetaImportacion = "";
1609 tcRutaArchivoZip = "";
1610
1611 OpenFileDialog openFileDialog1 = new OpenFileDialog();
1612 openFileDialog1.Filter = "Archivos Zip (*.zip)|*.zip|Todos los archivos (*.*)|*.*";
1613 openFileDialog1.FilterIndex = 0;
1614 openFileDialog1.RestoreDirectory = true;
1615 if (!string.IsNullOrWhiteSpace(this._RutaGeneracion))
1616 openFileDialog1.InitialDirectory = this._RutaGeneracion;
1617
1618 if (openFileDialog1.ShowDialog() != DialogResult.OK)
1619 {
1620 this._Error_Message = "No ha seleccionado ningún fichero ZIP de legalizacíón para importar.";
1621 return false;
1622 }
1623
1624 if (string.IsNullOrWhiteSpace(openFileDialog1.FileName))
1625 {
1626 this._Error_Message = "No ha seleccionado ningún fichero ZIP de legalizacíón para importar.";
1627 return false;
1628 }
1629
1630 if (Path.GetExtension(openFileDialog1.FileName).Trim().ToUpper() != ".ZIP")
1631 {
1632 this._Error_Message = "El archivo de legalización a importar debe ser de tipo ZIP.";
1633 return false;
1634 }
1635
1636 // Verificar que el nombre del archivo sea correcto.
1637 if (!this.esNombreArchivoZipValido(openFileDialog1.FileName))
1638 return false;
1639
1640 // Crea la carpeta de importación si no existe. Si existe se asegura de que esté vacía, si no lo está borra todo para
1641 // asegurarse de que esté vacía. Si hay algún problema con todo lo anterior ya no se continúa. Es requesito tener esta
1642 // carpeta de importación completamente vacía pues el ZIP se copiará allá y se decomprimirá allá.
1643 //
1644 if (!this.asegurarCarpetaImportacionVacia(out lcCarpetaImportacion))
1645 return false;
1646
1647 tcRutaArchivoZip = openFileDialog1.FileName.Trim();
1648
1649 string lcNombreFicheroDestino = Path.Combine(lcCarpetaImportacion, Path.GetFileName(tcRutaArchivoZip));
1650
1651 File.Copy(tcRutaArchivoZip, lcNombreFicheroDestino);
1652
1653 if (!File.Exists(lcNombreFicheroDestino))
1654 {
1655 this._Error_Message = "No se ha podido copiar el fichero ZIP de legalización '" + tcRutaArchivoZip + "' a la carpeta de importación '" + lcCarpetaImportacion + "'.";
1656 return false;
1657 }
1658
1659 if (!this.verificarRecuperarArchivoZip(lcNombreFicheroDestino, false))
1660 {
1661 // El mensaje de error ya se generó dentro del método anterior.
1662 return false;
1663 }
1664
1665 return true;
1666 }
1667
1668
1674 private bool esNombreArchivoZipValido(string tcRutaArchivoZip)
1675 {
1676 int lnCodRegistro = -2;
1677
1678 string lcNombreArchivo = Path.GetFileNameWithoutExtension(tcRutaArchivoZip);
1679 if (lcNombreArchivo.Substring(0, 2) != "LL")
1680 {
1681 this._Error_Message = "No es un fichero de legalización válido, debe comenzar por LL";
1682 return false;
1683 }
1684
1685 if (lcNombreArchivo.Length < 7)
1686 {
1687 this._Error_Message = "No es un fichero de legalización válido, debe comenzar por LL y tener 5 dígitos numéricos a continuación con el código de registro.";
1688 return false;
1689 }
1690
1691 if (!int.TryParse(lcNombreArchivo.Substring(2, 5), out lnCodRegistro) || lnCodRegistro <= 0)
1692 {
1693 this._Error_Message = "No es un fichero de legalización válido, debe comenzar por LL y tener 5 dígitos numéricos a continuación con el código de registro.";
1694 return false;
1695 }
1696
1697 return true;
1698 }
1699
1700
1718 [ExcludeFromCodeCoverage]
1719 private bool verificarRecuperarArchivoZip(string tcArchivoZipImportar, bool tlActualizar)
1720 {
1721 bool llOk = true;
1722
1723 if (string.IsNullOrWhiteSpace(tcArchivoZipImportar))
1724 return false;
1725
1726 string lcCarpetaExtraccion = Path.GetDirectoryName(tcArchivoZipImportar);
1727
1728 try
1729 {
1730 using (ZipFile zip = new ZipFile(tcArchivoZipImportar))
1731 {
1732 zip.Comment = "";
1733 zip.Encryption = EncryptionAlgorithm.None;
1734 zip.Password = "";
1735 zip.CompressionMethod = CompressionMethod.Deflate;
1736 zip.UseZip64WhenSaving = Zip64Option.Never;
1737
1738 zip.ExtractAll(lcCarpetaExtraccion);
1739
1740 string lcArchivoNombresTxt = Path.Combine(lcCarpetaExtraccion, "NOMBRES.TXT");
1741 string lcArchivoDatosTxt = Path.Combine(lcCarpetaExtraccion, "DATOS.TXT");
1742
1743 if (!File.Exists(lcArchivoNombresTxt))
1744 {
1745 this._Error_Message = "Al descomprimir el fichero ZIP de legalización '" + tcArchivoZipImportar + "' en la carpeta '" + lcCarpetaExtraccion + "' no se ha obtenido un fichero NOMBRES.TXT." +
1746 Environment.NewLine + Environment.NewLine + "EL fichero ZIP de legalización es incorrecto."+
1747 Environment.NewLine + Environment.NewLine + "Imposible realizar importación de fichero ZIP de legalización.";
1748 return false;
1749 }
1750
1751
1752 if (!File.Exists(lcArchivoDatosTxt))
1753 {
1754 this._Error_Message = "Al descomprimir el fichero ZIP de legalización '" + tcArchivoZipImportar + "' en la carpeta '" + lcCarpetaExtraccion + "' no se ha obtenido un fichero DATOS.TXT." +
1755 Environment.NewLine + Environment.NewLine + "El fichero ZIP de legalización es incorrecto."+
1756 Environment.NewLine + Environment.NewLine + "Imposible realizar importación de fichero ZIP de legalización.";
1757 return false;
1758 }
1759
1760 // Verificar que todos los archivos que hay en NOMBRES.TXT existen.
1761 //
1762 StreamReader archivoNombresTxt = new StreamReader(lcArchivoNombresTxt);
1763 string lcNombreFichero = "";
1764 string lcRutaCompletaFichero = "";
1765
1766 while ((lcNombreFichero = archivoNombresTxt.ReadLine()) != null)
1767 {
1768 lcRutaCompletaFichero = Path.Combine(lcCarpetaExtraccion, lcNombreFichero);
1769 if (!File.Exists(lcArchivoDatosTxt))
1770 {
1771 this._Error_Message = "Al descomprimir el fichero ZIP de legalización '" + tcArchivoZipImportar + "' en la carpeta '" + lcCarpetaExtraccion + "' no se ha obtenido el fichero '"+ lcNombreFichero + "'" +
1772 "tal como consta en el archivo NOMBRES.TXT obtenido del fichero ZIP de la legalización."+Environment.NewLine + Environment.NewLine + "El fichero ZIP de legalización es incorrecto." +
1773 Environment.NewLine + Environment.NewLine + "Imposible realizar importación de fichero ZIP de legalización.";
1774 llOk = false;
1775 break;
1776 }
1777 }
1778
1779 archivoNombresTxt.Close();
1780
1781 if (!llOk)
1782 return false;
1783
1784
1785 // Volcar todos los datos hallados en el archivo ZIP a la legalización.
1786 //
1787 if (tlActualizar)
1788 {
1789 // Vaciar todos los datos del apartado de Presentacion.
1790 //
1791 if (!this.importarVaciarCamposPresentacion())
1792 return false;
1793
1794 // Cargos datos de presentación.
1795 //
1796 if (!this.importarCargarCamposPresentacion(lcArchivoDatosTxt))
1797 return false;
1798
1799 // Cargos datos de libros presentados.
1800 //
1801 if (!this.importarCargarLibrosPresentados(lcArchivoNombresTxt, lcArchivoDatosTxt))
1802 return false;
1803 }
1804 }
1805 }
1806 catch (Exception e)
1807 {
1808 this._Error_Message = "No se ha podido " + (tlActualizar ? "importar correctamente el" : "verificar el formato del") + " fichero ZIP de legalización '" + tcArchivoZipImportar + "'." +
1809 Environment.NewLine + Environment.NewLine + e.Message + Environment.NewLine + Environment.NewLine +
1810 "Imposible realizar importación de fichero ZIP de legalización.";
1811 llOk = false;
1812 }
1813
1814 return llOk;
1815 }
1816
1817
1823 [ExcludeFromCodeCoverage]
1824 private bool asegurarCarpetaImportacionVacia(out string tcCarpetaImportacion)
1825 {
1826 string lcRutaCompletaExportacion = this._RutaGeneracionCompleta();
1827
1828 tcCarpetaImportacion = Path.Combine(lcRutaCompletaExportacion, "Import");
1829
1830 if (!Directory.Exists(tcCarpetaImportacion))
1831 Directory.CreateDirectory(tcCarpetaImportacion);
1832
1833 if (!Directory.Exists(tcCarpetaImportacion))
1834 {
1835 this._Error_Message = "No se ha podido crear la carpeta de importación '" + tcCarpetaImportacion + "'." + Environment.NewLine + Environment.NewLine +
1836 "Imposible realizar importación de fichero ZIP de legalización.";
1837 return false;
1838 }
1839
1840 int lnNumFicheros = 0;
1841 if (this.algunFicheroEnRutaGeneracion(tcCarpetaImportacion, out lnNumFicheros))
1842 {
1843 if (!this.borrarTodosArchivosRuta(tcCarpetaImportacion))
1844 {
1845 this._Error_Message = "La carpeta destino de la importación ('" + tcCarpetaImportacion + "') ya contiene ficheros y no ha sido " +
1846 "posible eliminarlos todos." + Environment.NewLine + Environment.NewLine + "Imposible realizar importación de fichero ZIP " +
1847 "de legalización.";
1848 return false;
1849 }
1850 }
1851
1852 return true;
1853 }
1854
1855
1862 private bool algunFicheroEnRutaGeneracion(string tcRutaGeneracion, out int tnNumFicheros)
1863 {
1864 bool llExistenFicheros = false;
1865
1866 string[] laFicheros = Directory.GetFiles(tcRutaGeneracion);
1867 tnNumFicheros = laFicheros.Count();
1868
1869 llExistenFicheros = (tnNumFicheros > 0);
1870
1871 return llExistenFicheros;
1872 }
1873
1874
1880 [ExcludeFromCodeCoverage]
1881 private bool borrarTodosArchivosRuta(string tcRuta)
1882 {
1883 bool llTodosArchivosBorrados = true;
1884
1885 try
1886 {
1887 string[] laFicheros = Directory.GetFiles(tcRuta);
1888 foreach (string lcFichero in laFicheros)
1889 {
1890 if (File.Exists(lcFichero))
1891 {
1892 File.Delete(lcFichero);
1893 if (File.Exists(lcFichero))
1894 {
1895 llTodosArchivosBorrados = false;
1896 break;
1897 }
1898 }
1899 }
1900 }
1901 catch (Exception)
1902 {
1903 llTodosArchivosBorrados = false;
1904 }
1905
1906 return llTodosArchivosBorrados;
1907 }
1908
1909
1914 private bool importarVaciarCamposPresentacion()
1915 {
1916 bool llOk = true;
1917
1918 try
1919 {
1920 // Cabecera
1921 //
1922 this._Fecha = DateTime.Today;
1923 this._SolicitaRetencion = false;
1924
1925 // Datos empresario
1926 //
1927 this._NombreEmpresario = "";
1928 this._Apellido1Empresario = "";
1929 this._Apellido2Empresario = "";
1930 this._CifEmpresario = "";
1931 this._DireccionEmpresario = "";
1932 this._CodposEmpresario = "";
1933 this._CiudadEmpresario = "";
1934 this._ProvinciaEmpresario = "";
1935 this._TelefonoEmpresario = "";
1936 this._FaxEmpresario = "";
1937
1938 // Datos presentador
1939 //
1940 this._NombrePresentador = "";
1941 this._Apellido1Presentador = "";
1942 this._Apellido2Presentador = "";
1943 this._CifPresentador = "";
1944 this._DireccionPresentador = "";
1945 this._CodposPresentador = "";
1946 this._CiudadPresentador = "";
1947 this._ProvinciaPresentador = "";
1948 this._TelefonoPresentador = "";
1949 this._FaxPresentador = "";
1950 this._EmailPresentador = "";
1951
1952 // Datos registrales
1953 //
1954 this._CodigoRegistro = "";
1955 this._NumeroTomoRegistro = "";
1956 this._NumeroLibroRegistro = "";
1957 this._NumeroSeccionRegistro = "";
1958 this._NumeroFolioRegistro = "";
1959 this._NumeroHojaRegistro = "";
1960 this._TipoRegistroMercantil = "";
1961 this._OtrosRegistroMercantil = "";
1962 this._RegistroMercantil = "";
1963 this._IRUS = "";
1964 }
1965 catch (Exception e)
1966 {
1967 this._Error_Message = "Se ha producido un error el vaciar los campos de presentación de la legalización." + Environment.NewLine + Environment.NewLine +
1968 "Mensaje de error: " + e.Message;
1969 llOk = false;
1970 }
1971
1972 return llOk;
1973 }
1974
1975
1980 [ExcludeFromCodeCoverage]
1981 private bool importarCargarCamposPresentacion(string tcRutaFicheroDatosTxt)
1982 {
1983 bool llOk = true;
1984
1985 try
1986 {
1987 // Cargar en esta lista de string las lineas del fichero.
1988 //
1989 List<string> lstFileLines = File.ReadAllLines(tcRutaFicheroDatosTxt).ToList();
1990
1991 // Datos cabecera.
1992 //
1993 this.importarCargarCamposPresentacion_Cabecera(lstFileLines);
1994
1995 // Datos empresario.
1996 //
1997 this.importarCargarCamposPresentacion_Empresario(lstFileLines);
1998
1999 // Datos presentador.
2000 //
2001 this.importarCargarCamposPresentacion_Presentador(lstFileLines);
2002
2003 // Datos registrales.
2004 //
2005 this.importarCargarCamposPresentacion_DatosRegistrales(lstFileLines);
2006 }
2007 catch (Exception e)
2008 {
2009 this._Error_Message = "Se ha producido un error al cargar los campos de presentación de la legalización con los procedentes del archivo ZIP " +
2010 "que se está importando." + Environment.NewLine + Environment.NewLine +"Mensaje de error: " + e.Message;
2011 llOk = false;
2012 }
2013
2014 return llOk;
2015 }
2016
2017
2022 private void importarCargarCamposPresentacion_Cabecera(List<string> tlstLineas)
2023 {
2024 // Obtener fecha.
2025 //
2026 string lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "101");
2027 DateTime? ldtFecha = this.setDtosToFecha(lcValorCampo);
2028 if (ldtFecha == null)
2029 this._Fecha = DateTime.Today;
2030 else
2031 this._Fecha = Convert.ToDateTime(ldtFecha);
2032
2033 // Solicita retencion SI/NO
2034 //
2035 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "401");
2036 this._SolicitaRetencion = lcValorCampo.Trim().ToUpper() == "SI";
2037
2038 return;
2039 }
2040
2041
2046 private void importarCargarCamposPresentacion_Empresario(List<string> tlstLineas)
2047 {
2048 string lcValorCampo = "";
2049
2050 // Nombre empresario.
2051 //
2052 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "102");
2053 this._NombreEmpresario = lcValorCampo;
2054
2055 // Apellido 1 empresario.
2056 //
2057 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "103");
2058 this._Apellido1Empresario = lcValorCampo;
2059
2060 // Apellido 2 empresario.
2061 //
2062 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "104");
2063 this._Apellido2Empresario = lcValorCampo;
2064
2065 // CIF empresario.
2066 //
2067 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "105");
2068 this._CifEmpresario = lcValorCampo;
2069
2070 // Direccion empresario.
2071 //
2072 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "106");
2073 this._DireccionEmpresario = lcValorCampo;
2074
2075 // Ciudad empresario.
2076 //
2077 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "107");
2078 this._CiudadEmpresario = lcValorCampo;
2079
2080 // Codpos empresario.
2081 //
2082 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "108");
2083 this._CodposEmpresario = lcValorCampo;
2084
2085 // Código de provincia empresario (2 dígitos)
2086 //
2087 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "109");
2088 this._ProvinciaEmpresario = FUNCTIONS._GetProvinciaFromCodigoProvincia(lcValorCampo);
2089
2090 // Fax empresario.
2091 //
2092 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "110");
2093 this._FaxEmpresario = lcValorCampo;
2094
2095 // Telefono empresario.
2096 //
2097 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "111");
2098 this._TelefonoEmpresario = lcValorCampo;
2099
2100 return;
2101 }
2102
2103
2108 private void importarCargarCamposPresentacion_Presentador(List<string> tlstLineas)
2109 {
2110 string lcValorCampo = "";
2111
2112 // Nombre presentador.
2113 //
2114 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "301");
2115 this._NombrePresentador = lcValorCampo;
2116
2117 // Apellido 1 presentador.
2118 //
2119 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "302");
2120 this._Apellido1Presentador = lcValorCampo;
2121
2122 // Apellido 2 presentador.
2123 //
2124 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "303");
2125 this._Apellido2Presentador = lcValorCampo;
2126
2127 // CIF presentador.
2128 //
2129 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "304");
2130 this._CifPresentador = lcValorCampo;
2131
2132 // Direccion presentador.
2133 //
2134 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "305");
2135 this._DireccionPresentador = lcValorCampo;
2136
2137 // Ciudad presentador.
2138 //
2139 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "306");
2140 this._CiudadPresentador = lcValorCampo;
2141
2142 // Codpos presentador.
2143 //
2144 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "307");
2145 this._CodposPresentador = lcValorCampo;
2146
2147 // Provincia presentador.
2148 //
2149 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "308");
2150 this._ProvinciaPresentador = lcValorCampo;
2151
2152 // Fax presentador.
2153 //
2154 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "309");
2155 this._FaxPresentador = lcValorCampo;
2156
2157 // Telefono presentador.
2158 //
2159 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "310");
2160 this._TelefonoPresentador = lcValorCampo;
2161
2162 // Email presentador.
2163 //
2164 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "311");
2165 this._EmailPresentador = lcValorCampo;
2166
2167 return;
2168 }
2169
2170
2175 private void importarCargarCamposPresentacion_DatosRegistrales(List<string> tlstLineas)
2176 {
2177 string lcValorCampo = "";
2178
2179 // Código registro.
2180 //
2181 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "112");
2182 this._CodigoRegistro = lcValorCampo;
2183
2184 // Número tomo.
2185 //
2186 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "201");
2187 this._NumeroTomoRegistro = lcValorCampo;
2188
2189 // Número libro.
2190 //
2191 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "202");
2192 this._NumeroLibroRegistro = lcValorCampo;
2193
2194 // Número sección.
2195 //
2196 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "203");
2197 this._NumeroSeccionRegistro = lcValorCampo;
2198
2199 // Número folio.
2200 //
2201 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "204");
2202 this._NumeroFolioRegistro = lcValorCampo;
2203
2204 // Tipo registro mercantil.
2205 //
2206 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "205");
2207 this._TipoRegistroMercantil = lcValorCampo;
2208
2209 // Número hoja.
2210 //
2211 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "206");
2212 this._NumeroHojaRegistro = lcValorCampo;
2213
2214 // Otros registro mercantil.
2215 //
2216 lcValorCampo = this.importarGetCampoDatosTxt(tlstLineas, "207");
2217 this._OtrosRegistroMercantil = lcValorCampo;
2218
2219 // Registro mercantil.
2220 //
2221 // Ojo que este campo de registro mercantil ni se exporta ni se importa, no viaja nunca en el fichero ZIP de legalización.
2222
2223 return;
2224 }
2225
2226
2233 private string importarGetCampoDatosTxt(List<string> tlstLista, string codigoCampo)
2234 {
2235 string lcRegistroBuscado ="", lcValorCampo = "";
2236
2237 lcRegistroBuscado = tlstLista.Where(x => x.Length >= codigoCampo.Length && x.Substring(0, codigoCampo.Length) == codigoCampo).FirstOrDefault();
2238
2239 lcRegistroBuscado = lcRegistroBuscado.Trim();
2240
2241 if (!string.IsNullOrWhiteSpace(lcRegistroBuscado) && lcRegistroBuscado.Length > codigoCampo.Length)
2242 lcValorCampo = lcRegistroBuscado.Substring(codigoCampo.Length);
2243
2244 return lcValorCampo;
2245 }
2246
2247
2254 private int importarNumLiniasFicheroEnDatosTxt(List<string> tlstLista, string codigoCampo)
2255 {
2256 int lnNumLinias = tlstLista.Where(x => x.Length >= codigoCampo.Length && x.Substring(0, codigoCampo.Length) == codigoCampo).Count();
2257
2258 return lnNumLinias;
2259 }
2260
2261
2268 [ExcludeFromCodeCoverage]
2269 private bool importarCargarLibrosPresentados(string tcRutaFicheroNombresTxt, string tcRutaFicheroDatosTxt)
2270 {
2271 bool llOk = true;
2272
2273 int lnLiniaFichero = 1, lnNumLineasFicheroEnDatosTxt = 0;
2274 string lcCodigoCampo = "", lcValorCampo = "", lcPrefijoCodigoCampo = "", lcNombreFichero = "", lcRutaCompletaFichero = "", lcCarpetaExtraccion = "";
2275 DateTime? ldtFecha = null;
2276
2277 try
2278 {
2279 lcCarpetaExtraccion = Path.GetDirectoryName(tcRutaFicheroNombresTxt);
2280
2281 // Cargar en esta lista de string las lineas del fichero DATOS.TXT que sera sobre la que trabajaremos para extraer los campos
2282 // que nos interesan de cada libro.
2283 //
2284 List<string> lstFileLinesDatosTxt = File.ReadAllLines(tcRutaFicheroDatosTxt).ToList();
2285
2286 // Borrar todos los libros declarados y actualizo a la base de datos, antes de crear las nuevas lineas.
2287 //
2288 this._LineasLegalizacionLibros._Delete();
2289 this._LineasLegalizacionLibros._Save();
2290
2291 StreamReader archivoNombresTxt = new StreamReader(tcRutaFicheroNombresTxt);
2292 while ((lcNombreFichero = archivoNombresTxt.ReadLine()) != null)
2293 {
2294 lcRutaCompletaFichero = Path.Combine(lcCarpetaExtraccion, lcNombreFichero);
2295
2296 if (!File.Exists(lcRutaCompletaFichero))
2297 {
2298 this._Error_Message = "Al intentar actualizar los libros a la legalización no se ha detectado la existencia del fichero '" + lcNombreFichero + "' en la carpeta '" + lcCarpetaExtraccion + "' " +
2299 "tal como consta en el archivo NOMBRES.TXT obtenido del fichero ZIP de la legalización." + Environment.NewLine + Environment.NewLine + "El fichero ZIP de legalización es incorrecto." +
2300 Environment.NewLine + Environment.NewLine + "Imposible realizar importación de fichero ZIP de legalización.";
2301 llOk = false;
2302 break;
2303 }
2304
2305 // Confirmamos que en el fichero DATOS.TXT existen las 6 lineas de información para este fichero (tipo, numlibro, fecha apert., fecha cierre, fecha cierre ant., huella)
2306 lnNumLineasFicheroEnDatosTxt = this.importarNumLiniasFicheroEnDatosTxt(lstFileLinesDatosTxt, Convert.ToString(lnLiniaFichero).Trim().PadLeft(3, '0'));
2307 if (lnNumLineasFicheroEnDatosTxt!=6)
2308 {
2309 this._Error_Message = "Al intentar actualizar los libros a la legalización no se ha detectado la existencia del fichero '" + lcNombreFichero + "' en la carpeta '" + lcCarpetaExtraccion + "' " +
2310 "tal como consta en el archivo NOMBRES.TXT obtenido del fichero ZIP de la legalización." + Environment.NewLine + Environment.NewLine + "El fichero ZIP de legalización es incorrecto." +
2311 Environment.NewLine + Environment.NewLine + "Imposible realizar importación de fichero ZIP de legalización.";
2312 llOk = false;
2313 break;
2314 }
2315
2316 // Añado registro nuevo de linea de libro.
2317 //
2319
2320 lcPrefijoCodigoCampo = Convert.ToString(lnLiniaFichero).Trim().PadLeft(3, '0');
2321
2322 // Capto el tipo de fichero del fichero en curso que estoy recuperando.
2323 //
2324 lcCodigoCampo = lcPrefijoCodigoCampo + "01";
2325 lcValorCampo = this.importarGetCampoDatosTxt(lstFileLinesDatosTxt, lcCodigoCampo);
2326 loLinea._TipoLibroVisual = lcValorCampo;
2327
2328 // Capto el número de libro del fichero en curso que estoy recuperando.
2329 //
2330 lcCodigoCampo = lcPrefijoCodigoCampo + "02";
2331 lcValorCampo = this.importarGetCampoDatosTxt(lstFileLinesDatosTxt, lcCodigoCampo);
2332 loLinea._NumLibro = lcValorCampo;
2333
2334 loLinea._RutaArchivo = lcRutaCompletaFichero;
2335
2336 // Fecha de apertura del fichero en curso que estoy recuperando.
2337 //
2338 lcCodigoCampo = lcPrefijoCodigoCampo + "03";
2339 lcValorCampo = this.importarGetCampoDatosTxt(lstFileLinesDatosTxt, lcCodigoCampo);
2340 ldtFecha = this.setDtosToFecha(lcValorCampo);
2341 if (ldtFecha == null)
2342 loLinea._FecApertura = null;
2343 else
2344 loLinea._FecApertura = Convert.ToDateTime(ldtFecha);
2345
2346 // Fecha de cierre del fichero en curso que estoy recuperando.
2347 //
2348 lcCodigoCampo = lcPrefijoCodigoCampo + "04";
2349 lcValorCampo = this.importarGetCampoDatosTxt(lstFileLinesDatosTxt, lcCodigoCampo);
2350 ldtFecha = this.setDtosToFecha(lcValorCampo);
2351 if (ldtFecha == null)
2352 loLinea._FecCierre = null;
2353 else
2354 loLinea._FecCierre = Convert.ToDateTime(ldtFecha);
2355
2356 // Fecha de cierre anterior del fichero en curso que estoy recuperando.
2357 //
2358 lcCodigoCampo = lcPrefijoCodigoCampo + "05";
2359 lcValorCampo = this.importarGetCampoDatosTxt(lstFileLinesDatosTxt, lcCodigoCampo);
2360 ldtFecha = this.setDtosToFecha(lcValorCampo);
2361 if (ldtFecha == null)
2362 loLinea._FecCierreAnt = null;
2363 else
2364 loLinea._FecCierreAnt = Convert.ToDateTime(ldtFecha);
2365
2366
2367 // Firma del fichero en curso que estoy recuperando.
2368 //
2369 lcCodigoCampo = lcPrefijoCodigoCampo + "06";
2370 lcValorCampo = this.importarGetCampoDatosTxt(lstFileLinesDatosTxt, lcCodigoCampo);
2371 loLinea._Firma = lcValorCampo;
2372
2373 // Pasamos a procesar el siguiente libro.
2374 //
2375 lnLiniaFichero++;
2376 }
2377
2378 archivoNombresTxt.Close();
2379 }
2380 catch (Exception e)
2381 {
2382 this._Error_Message = "Se ha producido un error el cargar los libros procedentes del fichero ZIP de legalización." + Environment.NewLine + Environment.NewLine +
2383 "Mensaje de error: " + e.Message;
2384 llOk = false;
2385 }
2386
2387 return llOk;
2388 }
2389
2390
2391 #endregion MÉTODOS PRIVADOS PARA IMPORTAR LEGALIZACION DE FICHERO ZIP
2392
2393
2394 #region MÉTODOS PRIVADOS PARA EXPORTAR LEGALIZACION A FICHERO ZIP
2395
2396
2402 private bool datosEmpresarioOk(ref string tcFaltaCampo)
2403 {
2404 if (string.IsNullOrWhiteSpace(this._NombreEmpresario))
2405 {
2406 tcFaltaCampo = "Nombre empresario";
2407 return false;
2408 }
2409
2410
2411 if (string.IsNullOrWhiteSpace(this._CifEmpresario))
2412 {
2413 tcFaltaCampo = "CIF empresario";
2414 return false;
2415 }
2416
2417 if (string.IsNullOrWhiteSpace(this._DireccionEmpresario))
2418 {
2419 tcFaltaCampo = "Dirección empresario";
2420 return false;
2421 }
2422
2423 if (string.IsNullOrWhiteSpace(this._CodposEmpresario))
2424 {
2425 tcFaltaCampo = "Código postal empresario";
2426 return false;
2427 }
2428
2429 if (string.IsNullOrWhiteSpace(this._CiudadEmpresario))
2430 {
2431 tcFaltaCampo = "Ciudad empresario";
2432 return false;
2433 }
2434
2435 if (string.IsNullOrWhiteSpace(this._ProvinciaEmpresario))
2436 {
2437 tcFaltaCampo = "Provincia empresario";
2438 return false;
2439 }
2440
2441 return true;
2442 }
2443
2444
2450 private bool datosPresentadorOk(ref string tcFaltaCampo)
2451 {
2452 if (string.IsNullOrWhiteSpace(this._NombrePresentador))
2453 {
2454 tcFaltaCampo = "Nombre presentador";
2455 return false;
2456 }
2457
2458
2459 if (string.IsNullOrWhiteSpace(this._CifPresentador))
2460 {
2461 tcFaltaCampo = "CIF presentador";
2462 return false;
2463 }
2464
2465 return true;
2466 }
2467
2468
2474 private bool datosRegistroOk(ref string tcFaltaCampo)
2475 {
2476 if (!string.IsNullOrWhiteSpace(this._IRUS)) // Customer Change Request 222922
2477 {
2478 if (string.IsNullOrWhiteSpace(this._TipoRegistroMercantil))
2479 {
2480 tcFaltaCampo = "Tipo de registro público";
2481 return false;
2482 }
2483 return true;
2484 }
2485
2486 if (string.IsNullOrWhiteSpace(this._CodigoRegistro))
2487 {
2488 tcFaltaCampo = "Código de registro";
2489 return false;
2490 }
2491
2492 // Task 167756, no se obliga a declarar nº libro, nº sección ni nº de hoja, por tanto no controlamos aquí estos campos.
2493 //
2494 if (string.IsNullOrWhiteSpace(this._NumeroTomoRegistro))
2495 {
2496 tcFaltaCampo = "Número de tomo registro";
2497 return false;
2498 }
2499
2500 if (string.IsNullOrWhiteSpace(this._NumeroFolioRegistro))
2501 {
2502 tcFaltaCampo = "Número de folio registro";
2503 return false;
2504 }
2505
2506 if (string.IsNullOrWhiteSpace(this._TipoRegistroMercantil))
2507 {
2508 tcFaltaCampo = "Tipo de registro público";
2509 return false;
2510 }
2511
2512 if (string.IsNullOrWhiteSpace(this._RegistroMercantil))
2513 {
2514 tcFaltaCampo = "Registro mercantil de";
2515 return false;
2516 }
2517
2518 return true;
2519 }
2520
2521
2522
2528 [ExcludeFromCodeCoverage]
2529 private bool exportarCopiarFicherosARutaGeneracion()
2530 {
2531 bool llOk = true;
2532
2533 string lcRutaGeneracion = this._RutaGeneracionCompleta();
2534
2535 try
2536 {
2537
2538 string lcNombreFicheroOrigen = "", lcNombreFicheroDestino = "", lcExtensionFichero = "";
2539 string lcCheckSum = "";
2540 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLinea in this._LineasLegalizacionLibros._Items)
2541 {
2542 if (!string.IsNullOrWhiteSpace(loLinea._RutaArchivo))
2543 {
2544 lcNombreFicheroOrigen = loLinea._RutaArchivo.Trim();
2545 lcExtensionFichero = Path.GetExtension(lcNombreFicheroOrigen);
2546 lcNombreFicheroDestino = Path.Combine(lcRutaGeneracion, loLinea._TipoLibro.Trim() + "_" + loLinea._NumLibro.Trim() + lcExtensionFichero);
2547
2548 File.Copy(lcNombreFicheroOrigen, lcNombreFicheroDestino);
2549
2550 if (!File.Exists(lcNombreFicheroDestino))
2551 {
2552 this._Error_Message = "No se ha podido copiar el archivo '" + lcNombreFicheroOrigen + "' en la carpeta destino de generación '" + lcRutaGeneracion + "'.";
2553 llOk = false;
2554 break;
2555 }
2556
2557 lcCheckSum = Criptografia.GenerateSHA256ToBase64String(lcNombreFicheroDestino);
2558 if (string.IsNullOrWhiteSpace(lcCheckSum))
2559 {
2560 this._Error_Message = "No se ha podido obtener la firma SHA256 del archivo '" + lcNombreFicheroDestino + "'.";
2561 llOk = false;
2562 break;
2563
2564 }
2565 loLinea._Firma = lcCheckSum;
2566 }
2567 }
2568 }
2569 catch (Exception e)
2570 {
2571 this._Error_Message = "No se han podido copiar los archivos de los libros a la ruta de generación '" + lcRutaGeneracion + "'." +
2572 Environment.NewLine + Environment.NewLine + e.Message;
2573
2574 llOk = false;
2575 }
2576
2577 return llOk;
2578 }
2579
2580
2585 [ExcludeFromCodeCoverage]
2586 private bool exportarPrepararFicheroNombresTxt()
2587 {
2588 bool llOk = true;
2589 string lcRutaGeneracion = this._RutaGeneracionCompleta();
2590
2591 try
2592 {
2593 string lcFicheroNombres = Path.Combine(lcRutaGeneracion, "NOMBRES.TXT");
2594
2595 using (StreamWriter sw = File.CreateText(lcFicheroNombres))
2596 {
2597 string lcExtensionFichero = "", lcNombreFicheroDestino = "";
2598 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLinea in this._LineasLegalizacionLibros._Items)
2599 {
2600 if (!string.IsNullOrWhiteSpace(loLinea._RutaArchivo))
2601 {
2602 lcExtensionFichero = Path.GetExtension(loLinea._RutaArchivo.Trim());
2603 lcNombreFicheroDestino = loLinea._TipoLibro.Trim() + "_" + loLinea._NumLibro.Trim() + lcExtensionFichero;
2604 sw.WriteLine(lcNombreFicheroDestino);
2605 }
2606 }
2607 }
2608 }
2609 catch (Exception e)
2610 {
2611 this._Error_Message = "No se ha podido preparar el fichero NOMBRES.TXT en la carpeta '" + lcRutaGeneracion + "'." +
2612 Environment.NewLine + Environment.NewLine + e.Message;
2613 llOk = false;
2614 }
2615
2616 return llOk;
2617 }
2618
2619
2624 [ExcludeFromCodeCoverage]
2625 private bool exportarPrepararFicheroDatosTxt()
2626 {
2627 bool llOk = true;
2628 string lcRutaGeneracion = this._RutaGeneracionCompleta();
2629
2630 try
2631 {
2632 string lcFicheroDatos = Path.Combine(lcRutaGeneracion, "DATOS.TXT");
2633
2634 using (StreamWriter sw = File.CreateText(lcFicheroDatos))
2635 {
2636 this.exportarPrepararFicheroDatosTxt_DatosEmpresario(sw);
2637
2638 this.exportarPrepararFicheroDatosTxt_DatosRegistrales(sw);
2639
2640 this.exportarPrepararFicheroDatosTxt_DatosPresentador(sw);
2641
2642 this.exportarPrepararFicheroDatosTxt_DatosOtros(sw);
2643
2644 this.exportarPrepararFicheroDatosTxt_DatosLibros(sw);
2645 }
2646 }
2647 catch (Exception e)
2648 {
2649 this._Error_Message = "No se ha podido preparar el fichero DATOS.TXT en la carpeta '" + lcRutaGeneracion + "'." +
2650 Environment.NewLine + Environment.NewLine + e.Message;
2651 llOk = false;
2652 }
2653
2654 return llOk;
2655 }
2656
2657
2662 private void exportarPrepararFicheroDatosTxt_DatosEmpresario(StreamWriter sw)
2663 {
2664
2665 // CCR198381, he mirado en FOX y alli SÍ se generaba registro 100 con el registro mercantil. He mirado en el
2666 // documento de análisis en el que nos basamos cuando pasamos de FOX a .NET esta pantalla y en el análisis
2667 // tampoco aparece el registro "100" pero por lo que dice la incidencia Spira relacionada con el CCR en
2668 // la web de LEGALIA está pidiendo este registro por lo que si además tenemos en cuenta que en FOX ya
2669 // se generaba este registro "100" todo parece apuntar a que es un descuido de análisis. Añado pues el
2670 // registro "100" que se omitió por error al pasar a .NET.
2671 //
2672 // Registro mercantil
2673 //
2674 string lcCadena = "100" + this.getCadenaLongitud(this._RegistroMercantil, 32);
2675 sw.WriteLine(lcCadena);
2676
2677 // Fecha de solicitud.
2678 //
2679 lcCadena = "101" + this.getDtosFecha(this._Fecha);
2680 sw.WriteLine(lcCadena);
2681
2682 // Nombre empresario.
2683 //
2684 lcCadena = "102" + this.getCadenaLongitud(this._NombreEmpresario, 100);
2685 sw.WriteLine(lcCadena);
2686
2687 // Apellido 1 empresario.
2688 //
2689 lcCadena = "103" + this.getCadenaLongitud(this._Apellido1Empresario, 32);
2690 sw.WriteLine(lcCadena);
2691
2692 // Apellido 2 empresario.
2693 //
2694 lcCadena = "104" + this.getCadenaLongitud(this._Apellido2Empresario, 32);
2695 sw.WriteLine(lcCadena);
2696
2697 // CIF empresario.
2698 //
2699 lcCadena = "105" + this.getCadenaLongitud(this._CifEmpresario, 9);
2700 sw.WriteLine(lcCadena);
2701
2702 // Dirección empresario.
2703 //
2704 lcCadena = "106" + this.getCadenaLongitud(this._DireccionEmpresario, 32);
2705 sw.WriteLine(lcCadena);
2706
2707 // Ciudad empresario.
2708 //
2709 lcCadena = "107" + this.getCadenaLongitud(this._CiudadEmpresario, 32);
2710 sw.WriteLine(lcCadena);
2711
2712 // Código postal empresario.
2713 //
2714 lcCadena = "108" + this.getCadenaLongitud(this._CodposEmpresario, 5);
2715 sw.WriteLine(lcCadena);
2716
2717 // Código de la provincia empresario.
2718 //
2719 lcCadena = "109" + this.getCadenaLongitud(this._CodposEmpresario, 2);
2720 sw.WriteLine(lcCadena);
2721
2722 // Fax empresario.
2723 //
2724 lcCadena = "110" + this.getCadenaLongitud(this._FaxEmpresario, 10);
2725 sw.WriteLine(lcCadena);
2726
2727 // Teléfono empresario.
2728 //
2729 lcCadena = "111" + this.getCadenaLongitud(this._TelefonoEmpresario, 10);
2730 sw.WriteLine(lcCadena);
2731
2732 // Código de registro.
2733 //
2734 lcCadena = "112" + this.getCadenaLongitud(this._CodigoRegistro, 5);
2735 sw.WriteLine(lcCadena);
2736
2737 return;
2738 }
2739
2740
2745 private void exportarPrepararFicheroDatosTxt_DatosRegistrales(StreamWriter sw)
2746 {
2747 // Tomo
2748 //
2749 string lcCadena = "201" + this.getCadenaLongitud(this._NumeroTomoRegistro, 6);
2750 sw.WriteLine(lcCadena);
2751
2752 // Libro.
2753 //
2754 if (!string.IsNullOrWhiteSpace(this._NumeroLibroRegistro))
2755 {
2756 // Task 167756, si no está declarado no lo adjuntamos al fichero.
2757 //
2758 lcCadena = "202" + this.getCadenaLongitud(this._NumeroLibroRegistro, 6);
2759 sw.WriteLine(lcCadena);
2760 }
2761
2762 // Sección.
2763 //
2764 if (!string.IsNullOrWhiteSpace(this._NumeroSeccionRegistro))
2765 {
2766 // Task 167756, si no está declarado no lo adjuntamos al fichero.
2767 //
2768 lcCadena = "203" + this.getCadenaLongitud(this._NumeroSeccionRegistro, 6);
2769 sw.WriteLine(lcCadena);
2770 }
2771
2772 // Folio.
2773 //
2774 lcCadena = "204" + this.getCadenaLongitud(this._NumeroFolioRegistro, 6);
2775 sw.WriteLine(lcCadena);
2776
2777 // Tipo de registro público.
2778 //
2779 lcCadena = "205" + this.getCadenaLongitud(this._TipoRegistroMercantil, 32);
2780 sw.WriteLine(lcCadena);
2781
2782 // Hoja.
2783 //
2784 if (!string.IsNullOrWhiteSpace(this._NumeroHojaRegistro))
2785 {
2786 // Task 167756, si no está declarado no lo adjuntamos al fichero.
2787 //
2788 lcCadena = "206" + this.getCadenaLongitud(this._NumeroHojaRegistro, 10);
2789 sw.WriteLine(lcCadena);
2790 }
2791
2792 // Otros.
2793 //
2794 lcCadena = "207" + this.getCadenaLongitud(this._OtrosRegistroMercantil, 32);
2795 sw.WriteLine(lcCadena);
2796
2797 return;
2798 }
2799
2800
2805 private void exportarPrepararFicheroDatosTxt_DatosPresentador(StreamWriter sw)
2806 {
2807 // Nombre presentador.
2808 //
2809 string lcCadena = "301" + this.getCadenaLongitud(this._NombrePresentador, 100);
2810 sw.WriteLine(lcCadena);
2811
2812 // Apellido 1 presentador
2813 //
2814 lcCadena = "302" + this.getCadenaLongitud(this._Apellido1Presentador, 32);
2815 sw.WriteLine(lcCadena);
2816
2817 // Apellido 2 presentador.
2818 //
2819 lcCadena = "303" + this.getCadenaLongitud(this._Apellido2Presentador, 32);
2820 sw.WriteLine(lcCadena);
2821
2822 // CIF presentador.
2823 //
2824 lcCadena = "304" + this.getCadenaLongitud(this._CifPresentador, 9);
2825 sw.WriteLine(lcCadena);
2826
2827 // Dirección presentador.
2828 //
2829 lcCadena = "305" + this.getCadenaLongitud(this._DireccionPresentador, 32);
2830 sw.WriteLine(lcCadena);
2831
2832 // Ciudad presentador.
2833 //
2834 lcCadena = "306" + this.getCadenaLongitud(this._CiudadPresentador, 32);
2835 sw.WriteLine(lcCadena);
2836
2837 // Código postal presentador.
2838 //
2839 lcCadena = "307" + this.getCadenaLongitud(this._CodposPresentador, 5);
2840 sw.WriteLine(lcCadena);
2841
2842 // Provincia presentador.
2843 //
2844 lcCadena = "308" + this.getCadenaLongitud(this._ProvinciaPresentador, 32);
2845 sw.WriteLine(lcCadena);
2846
2847 // Fax presentador.
2848 //
2849 lcCadena = "309" + this.getCadenaLongitud(this._FaxPresentador, 10);
2850 sw.WriteLine(lcCadena);
2851
2852 // Teléfono presentador.
2853 //
2854 lcCadena = "310" + this.getCadenaLongitud(this._TelefonoPresentador, 10);
2855 sw.WriteLine(lcCadena);
2856
2857 // Correo electrónico.
2858 //
2859 lcCadena = "311" + this.getCadenaLongitud(this._EmailPresentador, 60);
2860 sw.WriteLine(lcCadena);
2861
2862 return;
2863 }
2864
2865
2870 private void exportarPrepararFicheroDatosTxt_DatosOtros(StreamWriter sw)
2871 {
2872 // Solicita retención.
2873 //
2874 string lcCadena = "401" + (this._SolicitaRetencion ? "SI" : "NO");
2875 sw.WriteLine(lcCadena);
2876
2877 // Número total de libros presentados.
2878 //
2879 lcCadena = "501" + Convert.ToString(this._NumeroLibros).Trim().PadLeft(3,'0');
2880 sw.WriteLine(lcCadena);
2881
2882 return;
2883 }
2884
2885
2890 [ExcludeFromCodeCoverage]
2891 private void exportarPrepararFicheroDatosTxt_DatosLibros(StreamWriter sw)
2892 {
2893 int lnContadorReg = 1;
2894 string lcCadena = "";
2895
2896 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLineaLibro in this._LineasLegalizacionLibros._Items)
2897 {
2898 if (!string.IsNullOrWhiteSpace(loLineaLibro._RutaArchivo))
2899 {
2900 // Descripción del tipo de libro.
2901 //
2902 lcCadena = Convert.ToString(lnContadorReg).Trim().PadLeft(3, '0') + "01" + this.getCadenaLongitud(loLineaLibro._TipoLibroVisual, 100);
2903 sw.WriteLine(lcCadena);
2904
2905 // Nº de libro.
2906 //
2907 lcCadena = Convert.ToString(lnContadorReg).Trim().PadLeft(3, '0') + "02" + this.getCadenaLongitud(loLineaLibro._NumLibro, 3);
2908 sw.WriteLine(lcCadena);
2909
2910 // Fecha de apertura del libro.
2911 //
2912 lcCadena = Convert.ToString(lnContadorReg).Trim().PadLeft(3, '0') + "03" + this.getDtosFecha(loLineaLibro._FecApertura);
2913 sw.WriteLine(lcCadena);
2914
2915 // Fecha de cierre del libro.
2916 //
2917 lcCadena = Convert.ToString(lnContadorReg).Trim().PadLeft(3, '0') + "04" + this.getDtosFecha(loLineaLibro._FecCierre);
2918 sw.WriteLine(lcCadena);
2919
2920 // Fecha de último cierre del libro.
2921 //
2922 lcCadena = Convert.ToString(lnContadorReg).Trim().PadLeft(3, '0') + "05" + this.getDtosFecha(loLineaLibro._FecCierreAnt);
2923 sw.WriteLine(lcCadena);
2924
2925 // Huella digital del libro.
2926 //
2927 lcCadena = Convert.ToString(lnContadorReg).Trim().PadLeft(3, '0') + "06" + this.getCadenaLongitud(loLineaLibro._Firma, 64);
2928 sw.WriteLine(lcCadena);
2929
2930 lnContadorReg++;
2931 }
2932 }
2933 return;
2934 }
2935
2936
2941 [ExcludeFromCodeCoverage]
2942 private bool exportarPrepararFicheroZip()
2943 {
2944 bool llOk = true;
2945
2946 string lcRutaGeneracion = this._RutaGeneracionCompleta();
2947
2948 try
2949 {
2950 using (ZipFile zip = new ZipFile())
2951 {
2952 List<string> lstFicherosAnadir = new List<string>();
2953
2954 // Propietats del zip
2955 zip.Comment = "";
2956 zip.Encryption = EncryptionAlgorithm.None;
2957 //zip.Password = "";
2958 zip.CompressionMethod = CompressionMethod.Deflate;
2959 zip.UseZip64WhenSaving = Zip64Option.Never;
2960
2961 this.obtenerListaFicherosAnadirAZip(ref lstFicherosAnadir, lcRutaGeneracion);
2962 zip.AddFiles(lstFicherosAnadir, false, "");
2963
2964 string lcNombreFicheroZip = Path.Combine(lcRutaGeneracion, "LL" + this._CodigoRegistro.Trim() + this._CifEmpresario.Trim() + ".ZIP");
2965 zip.Save(lcNombreFicheroZip);
2966
2967 if (!File.Exists(lcNombreFicheroZip))
2968 {
2969 llOk = false;
2970 this._Error_Message = "No se ha podido generar correctamente el fichero ZIP de legalización en la carpeta '" + lcRutaGeneracion + "'";
2971 }
2972 }
2973 }
2974 catch (Exception e)
2975 {
2976 llOk = false;
2977 this._Error_Message = "No se ha podido generar correctamente el fichero ZIP de legalización en la carpeta '" + lcRutaGeneracion + "'." +
2978 Environment.NewLine + Environment.NewLine + e.Message;
2979 }
2980
2981 return llOk;
2982 }
2983
2984
2990 private void obtenerListaFicherosAnadirAZip(ref List<string> tlstFicheros, string tcRutaExportacion)
2991 {
2992 tlstFicheros.Add(Path.Combine(tcRutaExportacion, "NOMBRES.TXT"));
2993 tlstFicheros.Add(Path.Combine(tcRutaExportacion, "DATOS.TXT"));
2994
2995 string lcNombreFicheroOrigen = "", lcExtensionFichero = "", lcNombreFicheroDestino = "";
2996
2997 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLinea in this._LineasLegalizacionLibros._Items)
2998 {
2999 if (!string.IsNullOrWhiteSpace(loLinea._RutaArchivo))
3000 {
3001 lcNombreFicheroOrigen = loLinea._RutaArchivo.Trim();
3002 lcExtensionFichero = Path.GetExtension(lcNombreFicheroOrigen);
3003 lcNombreFicheroDestino = Path.Combine(tcRutaExportacion, loLinea._TipoLibro.Trim() + "_" + loLinea._NumLibro.Trim() + lcExtensionFichero);
3004
3005 tlstFicheros.Add(lcNombreFicheroDestino);
3006 }
3007 }
3008
3009 return;
3010 }
3011
3012
3013 #endregion MÉTODOS PRIVADOS PARA EXPORTAR LEGALIZACION A FICHERO ZIP
3014
3015
3016 #region MÉTODOS PRIVADOS VARIOS
3017
3018
3026 private string getCadenaLongitud(string tcCadena, int lnLongitud)
3027 {
3028 string lcCadenaRetorno = (tcCadena.Length >= lnLongitud ? tcCadena.Substring(0, lnLongitud) : tcCadena.Trim().PadRight(lnLongitud, ' '));
3029
3030 return lcCadenaRetorno;
3031 }
3032
3033
3039 private string getDtosFecha(DateTime? dtFecha)
3040 {
3041 string fechaRetorno = "";
3042
3043 if (dtFecha == null)
3044 fechaRetorno = new string(' ', 8);
3045 else
3046 {
3047 DateTime dtFecha2 = Convert.ToDateTime(dtFecha);
3048 fechaRetorno = Convert.ToString(dtFecha2.Day).Trim().PadLeft(2, '0') +
3049 Convert.ToString(dtFecha2.Month).Trim().PadLeft(2, '0') +
3050 Convert.ToString(dtFecha2.Year).Trim();
3051 }
3052 return fechaRetorno;
3053 }
3054
3055
3062 private DateTime? setDtosToFecha(string tcFecha)
3063 {
3064 DateTime? fechaRetorno = null;
3065
3066 if (tcFecha.Trim().Length != 8)
3067 return null;
3068
3069 try
3070 {
3071 fechaRetorno = new DateTime(Convert.ToInt32(tcFecha.Substring(4, 4)), Convert.ToInt32(tcFecha.Substring(2, 2)) , Convert.ToInt32(tcFecha.Substring(0, 2)));
3072 }
3073 catch (Exception)
3074 {
3075 fechaRetorno = null;
3076 }
3077
3078 return fechaRetorno;
3079 }
3080
3081
3086 [ExcludeFromCodeCoverage]
3087 private void ajustesVisualesGrid(ewgrid toGrid)
3088 {
3089 if (toGrid.Columns.Contains("_TipoLibro"))
3090 {
3091 toGrid.Columns["_TipoLibro"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
3092 toGrid.Columns["_TipoLibro"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
3093 }
3094
3095 if (toGrid.Columns.Contains("_RutaArchivo"))
3096 {
3097 toGrid.Columns["_RutaArchivo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
3098 toGrid.Columns["_RutaArchivo"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
3099 }
3100
3101 if (toGrid.Columns.Contains("_NumLibro"))
3102 {
3103 toGrid.Columns["_NumLibro"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
3104 toGrid.Columns["_NumLibro"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
3105 }
3106
3107 if (toGrid.Columns.Contains("_FecApertura"))
3108 {
3109 toGrid.Columns["_FecApertura"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
3110 toGrid.Columns["_FecApertura"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
3111 }
3112
3113 if (toGrid.Columns.Contains("_FecCierre"))
3114 {
3115 toGrid.Columns["_FecCierre"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
3116 toGrid.Columns["_FecCierre"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
3117 }
3118
3119 if (toGrid.Columns.Contains("_FecCierreAnt"))
3120 {
3121 toGrid.Columns["_FecCierreAnt"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
3122 toGrid.Columns["_FecCierreAnt"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
3123 }
3124
3125 if (toGrid.Columns.Contains("_FicheroFirmado"))
3126 {
3127 toGrid.Columns["_FicheroFirmado"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
3128 toGrid.Columns["_FicheroFirmado"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
3129 }
3130
3131 if (toGrid.Columns.Contains("_VerFichero"))
3132 {
3133 toGrid.Columns["_VerFichero"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
3134 toGrid.Columns["_VerFichero"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
3135 }
3136
3137 return;
3138 }
3139
3140
3146 private void legalizacionLibros_Actualizar_Estado_Documento(_EstadosMantenimiento teEstado)
3147 {
3148 if (this._FormMante == null)
3149 return;
3150
3151 formul.EstadosDocumento estadosDocumento = formul.EstadosDocumento.NoHayDocumento;
3152
3153 switch (teEstado)
3154 {
3155 case _EstadosMantenimiento.EsperandoCodigo:
3156 estadosDocumento = formul.EstadosDocumento.NoHayDocumento;
3157 break;
3158
3159 case _EstadosMantenimiento.MostrandoRegistro:
3160 estadosDocumento = formul.EstadosDocumento.HayDocumento;
3161 break;
3162
3163 case _EstadosMantenimiento.EntrandoNuevo:
3164 estadosDocumento = formul.EstadosDocumento.EntrandoNuevo;
3165 break;
3166
3167 case _EstadosMantenimiento.EditandoRegistro:
3168 estadosDocumento = formul.EstadosDocumento.HayDocumento;
3169 break;
3170
3171 case _EstadosMantenimiento.SinRegistro:
3172 estadosDocumento = formul.EstadosDocumento.NoHayDocumento;
3173 break;
3174
3175 default:
3176 break;
3177 }
3178
3179 ((frmLegalizacionLibros)_FormMante)._EstadoDocumento = estadosDocumento;
3180
3181 return;
3182 }
3183
3184
3185 #endregion MÉTODOS PRIVADOS VARIOS
3186
3187
3188 #endregion MÉTODOS PRIVADOS
3189
3190
3191 #region MÉTODOS PÚBLICOS
3192
3193
3197 [ExcludeFromCodeCoverage]
3198 public override void _Print()
3199 {
3200 this._oDocPrint = null;
3201
3202 this._ReportBase = this._TipoImpresion == LegalizacionLibros.TipoImpresion.SolicitudLegalizacion ? "LEGASOLI" : "LEGAFIRM";
3203
3204 this._DocPrint._Print();
3205
3206 return;
3207 }
3208
3209
3217 [ExcludeFromCodeCoverage]
3218 public string _RutaGeneracionCompleta(bool tlNoCrearCarpeta=false)
3219 {
3220 string lcRutaGeneracion = "";
3221 string lcGrupoEmp = this._dataAccessLegalizacionLibros.ObtenerDbComunes.Trim().Substring(4, 4);
3222
3223 lcRutaGeneracion = Path.Combine(this._RutaGeneracion.Trim(), "Grupo" + lcGrupoEmp.Trim());
3224 lcRutaGeneracion = Path.Combine(lcRutaGeneracion, this._cEmpresa);
3225 lcRutaGeneracion = Path.Combine(lcRutaGeneracion, this._lcAny);
3226
3227 if (!tlNoCrearCarpeta)
3228 {
3229 try
3230 {
3231 if (!Directory.Exists(lcRutaGeneracion))
3232 Directory.CreateDirectory(lcRutaGeneracion);
3233 }
3234 catch (Exception)
3235 {
3236 }
3237 }
3238
3239 return lcRutaGeneracion;
3240 }
3241
3242
3252 {
3253 this._dataAccessLegalizacionLibros._AgruparLineasPorTipoLibro(this, this._cEmpresa);
3254
3255 return;
3256 }
3257
3258
3266 public bool _EsPrimerLibroTipo(string tcTipoLibro, string tcNumLibro)
3267 {
3268 bool llEsPrimerLibro = false;
3269
3270 if (string.IsNullOrWhiteSpace(tcTipoLibro))
3271 return false;
3272
3273 if (string.IsNullOrWhiteSpace(tcNumLibro))
3274 return false;
3275
3276 int lnNumLibro = 0;
3277 if (!Int32.TryParse(tcNumLibro.Trim(), out lnNumLibro))
3278 return false;
3279
3280 llEsPrimerLibro = this._LineasLegalizacionLibros._Items.Where(x => x._TipoLibro.Trim() == tcTipoLibro.Trim() &&
3281 !string.IsNullOrWhiteSpace(x._RutaArchivo) && !string.IsNullOrWhiteSpace(x._NumLibro)
3282 && Convert.ToInt32(x._NumLibro) < lnNumLibro).Count() == 0;
3283
3284 return llEsPrimerLibro;
3285 }
3286
3287
3295 public bool _HayMasLibrosTipo(string tcTipoLibro, string tcNumLibro)
3296 {
3297 bool llHayMasLibros = false;
3298
3299 if (string.IsNullOrWhiteSpace(tcTipoLibro))
3300 return false;
3301
3302 if (string.IsNullOrWhiteSpace(tcNumLibro))
3303 return false;
3304
3305 int lnNumLibro = 0;
3306 if (!Int32.TryParse(tcNumLibro.Trim(), out lnNumLibro))
3307 return false;
3308
3309 llHayMasLibros = this._LineasLegalizacionLibros._Items.Where(x => x._TipoLibro.Trim() == tcTipoLibro.Trim() && !string.IsNullOrWhiteSpace(x._RutaArchivo) && Convert.ToInt32(x._NumLibro) > lnNumLibro).Count() > 0;
3310
3311 return llHayMasLibros;
3312 }
3313
3314
3321 public DateTime? _GetFechaFinLibroAnterior(string tcTipoLibro, string tcNumLibro)
3322 {
3323 DateTime? ldtFechaFinAnterior = null;
3324
3325 LineasLegalizacionLibros.LineaLegalizacionLibros loLineaAnterior = this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrWhiteSpace(x._TipoLibro) && x._TipoLibro.Trim() == tcTipoLibro.Trim() && Convert.ToInt32(x._NumLibro) < Convert.ToInt32(tcNumLibro)).OrderBy(x => x._NumLibro).LastOrDefault();
3326 if (loLineaAnterior != null)
3327 {
3328 if (loLineaAnterior._FecCierre != null)
3329 ldtFechaFinAnterior = loLineaAnterior._FecCierre;
3330 }
3331
3332 return ldtFechaFinAnterior;
3333 }
3334
3335
3340 public void _RenumerarLibrosTipoLibro(string tcTipoLibro)
3341 {
3342 if (string.IsNullOrWhiteSpace(tcTipoLibro))
3343 return;
3344
3345 List<LineasLegalizacionLibros.LineaLegalizacionLibros> lstLineas = this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrWhiteSpace(x._TipoLibro) && x._TipoLibro.Trim() == tcTipoLibro.Trim()).ToList();
3346
3347 int lnNumLibro = 0;
3348 //if (lstLineas.Count > 0)
3349 //{
3350 // lnNumLibro = Convert.ToInt32(lstLineas[0]._NumLibro);
3351 // lnNumLibro--;
3352 //}
3353
3354 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLinea in lstLineas)
3355 {
3356 lnNumLibro++;
3357 loLinea._NumLibro = Convert.ToString(lnNumLibro).Trim().PadLeft(3, '0');
3358 }
3359
3360 return;
3361 }
3362
3363
3370 public string _NumNuevoDocumento(string tcTipoLibro)
3371 {
3372 string lcNumeroNuevoDocumento = "";
3373
3374 var lineasDeclaradas = this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrEmpty(x._TipoLibro) &&
3375 x._TipoLibro.Trim() == tcTipoLibro);
3376 if (lineasDeclaradas.Count() == 0)
3377 {
3378 lcNumeroNuevoDocumento = "001";
3379 }
3380 else
3381 {
3382 lcNumeroNuevoDocumento = lineasDeclaradas.Max(x => x._NumLibro);
3383 if (string.IsNullOrWhiteSpace(lcNumeroNuevoDocumento))
3384 lcNumeroNuevoDocumento = "000";
3385
3386 lcNumeroNuevoDocumento = Convert.ToString(Convert.ToInt32(lcNumeroNuevoDocumento) + 1).Trim().PadLeft(3,'0');
3387 }
3388
3389 if (string.IsNullOrWhiteSpace(lcNumeroNuevoDocumento))
3390 lcNumeroNuevoDocumento = "001";
3391
3392 return lcNumeroNuevoDocumento;
3393 }
3394
3395
3401 {
3402 EstadoFirmasLibros loEstadoFirmas = EstadoFirmasLibros.NoEvaluado;
3403
3404 int liniasConArchivo = this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrWhiteSpace(x._RutaArchivo)).Count();
3405
3406 if (liniasConArchivo == 0)
3407 {
3408 loEstadoFirmas = EstadoFirmasLibros.NoEvaluado;
3409 }
3410 else
3411 {
3412 int liniasConArchivoSinFirma = this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrWhiteSpace(x._RutaArchivo) && string.IsNullOrWhiteSpace(x._Firma)).Count();
3413
3414 if (liniasConArchivoSinFirma == 0)
3415 {
3416 // No hay ningún archivo sin firmar, están todos firmados.
3417 //
3418 loEstadoFirmas = EstadoFirmasLibros.TodasFirmasGeneradas;
3419 }
3420 else
3421 {
3422 // Hay algún archivo sin firmar.
3423 //
3424 if (liniasConArchivoSinFirma == liniasConArchivo)
3425 {
3426 // No hay ningún archivo firmado.
3427 //
3428 loEstadoFirmas = EstadoFirmasLibros.NingunaFirmaGenerada;
3429 }
3430 else if (liniasConArchivoSinFirma < liniasConArchivo)
3431 {
3432 // Hay algún archivo sin firma y algún archivo con firma.
3433 //
3434 loEstadoFirmas = EstadoFirmasLibros.AlgunaFirmaGenerada;
3435 }
3436 }
3437 }
3438
3439 return loEstadoFirmas;
3440 }
3441
3442
3448 {
3449 // Dejo esta comprobación libre de código pues hoy por hoy no está implementada la eliminación de documento Legalización y de esta forma
3450 // también evitamos que la clase base haga código en su propio método que pueda afectar.
3451
3452 return true;
3453 }
3454
3455
3465 {
3466 // Si no tenemos documento no hacemos nada y salimos.
3467 // Esto en teoria no pasará nunca pues en _Numero siempre tendremos el ejercicio activo.
3468 //
3469 if (string.IsNullOrWhiteSpace(this._Numero))
3470 {
3471 this._Error_Message = "No tiene cargada ninguna legalización de libros en pantalla.";
3472 return false;
3473 }
3474
3475 // Legalización de libros en uso.
3476 //
3477 if (this._EnUso)
3478 {
3479 this._Error_Message = "La legalización de libros se encuenta en uso desde otro terminal." + Environment.NewLine + Environment.NewLine +
3480 "Imposible cargar datos de empresario, presentador y registro mercantil.";
3481 return false;
3482 }
3483
3484 return true;
3485 }
3486
3487
3498 {
3499 if (this.algunDatoDeclaradoDatosPresentacion())
3500 {
3501 this._Warning_Message = "Atención, existen datos ya declarados en la pestaña 'Datos de presentación'."+Environment.NewLine+Environment.NewLine+
3502 "Si continua con la acción de carga, los datos existentes en dicha pestaña se perderán pues serán sobreescritos por los procedentes de la carga.";
3503 return false;
3504 }
3505
3506 return true;
3507 }
3508
3509
3515 public bool _Comprobaciones_ImportarFichero(ref string tcArchivoZipLegalizacion)
3516 {
3517 // Si no tenemos documento no hacemos nada y salimos.
3518 // Esto en teoria no pasará nunca pues en _Numero siempre tendremos el ejercicio activo.
3519 //
3520 if (string.IsNullOrWhiteSpace(this._Numero))
3521 {
3522 this._Error_Message = "No tiene cargada ninguna legalización de libros en pantalla.";
3523 return false;
3524 }
3525
3526 // Legalización de libros en uso.
3527 //
3528 if (this._EnUso)
3529 {
3530 this._Error_Message = "La legalización de libros se encuenta en uso desde otro terminal." + Environment.NewLine + Environment.NewLine +
3531 "Imposible importar fichero de legalización en el formulario.";
3532 return false;
3533 }
3534
3535 // No está declarada la ruta de generación.
3536 //
3537 if (string.IsNullOrWhiteSpace(this._RutaGeneracion))
3538 {
3539 this._Error_Message = "La ruta de generación no puede estar vacía pues se utiliza para volcar el resultado de la importación." + Environment.NewLine + Environment.NewLine +
3540 "Imposible importar fichero de legalización en el formulario.";
3541 return false;
3542 }
3543
3544 tcArchivoZipLegalizacion = "";
3545 if (!this.seleccionarArchivoZipValido(out tcArchivoZipLegalizacion))
3546 {
3547 // El mensaje de error ya se ha obtenido dentro del método.
3548 //
3549 return false;
3550 }
3551
3552 return true;
3553 }
3554
3555
3562 {
3563 int lnNumLibros = this._NumeroLibros;
3564 bool llWarning = false;
3565
3566 if (lnNumLibros>0)
3567 {
3568 this._Warning_Message = "Atención, actualmente tiene declarados ya " + Convert.ToString(lnNumLibros).Trim() + " " + (lnNumLibros > 1 ? "libros" : "libro") + " en la legalización." +
3569 Environment.NewLine+Environment.NewLine+"Si continúa con la importación de datos a partir de fichero ZIP, perderá estos datos.";
3570 llWarning = true;
3571 }
3572
3573 if (this.algunDatoDeclaradoDatosPresentacion())
3574 {
3575 if (!string.IsNullOrWhiteSpace(this._Warning_Message))
3576 this._Warning_Message += Environment.NewLine + Environment.NewLine;
3577
3578 this._Warning_Message += "Atención, existen datos ya declarados en la pestaña 'Datos de presentación'." + Environment.NewLine + Environment.NewLine +
3579 "Si continua con la importación de datos a partir de fichero ZIP, los datos existentes en dicha pestaña se perderán pues serán sobreescritos por los procedentes de la importación.";
3580 llWarning = true;
3581 }
3582
3583 if (llWarning)
3584 return false;
3585
3586 // La ruta de generación tendrá el formato EUROSERV\LIBROS\GRP0001\01\2020\ donde EUROSERV\LIBROS es la ruta que hay declarada como
3587 // ruta de generación.
3588 //
3589 string lcRutaGeneracion = this._RutaGeneracionCompleta();
3590
3591 int lnNumFicheros = 0;
3592 if (this.algunFicheroEnRutaGeneracion(lcRutaGeneracion, out lnNumFicheros))
3593 {
3594 this._Warning_Message = "Atención, se ha detectado la existencia de " + Convert.ToString(lnNumFicheros).Trim() + " " + (lnNumFicheros > 1 ? "archivos" : "archivo") + " " +
3595 "en la ruta donde debe generarse el fichero ZIP de la legalización." + Environment.NewLine + Environment.NewLine + lcRutaGeneracion + Environment.NewLine + Environment.NewLine +
3596 "Antes de realizar la creación del fichero ZIP de la legalización se eliminarán todos los archivos existentes en dicha carpeta.";
3597 return false;
3598 }
3599
3600 return true;
3601 }
3602
3603
3611 {
3612 this._Error_Message = "";
3613
3614 if (string.IsNullOrWhiteSpace(this._Numero))
3615 {
3616 this._Error_Message = "No se ha cargado todavía ninguna legalización.";
3617 return false;
3618 }
3619
3620 if (this._LineasLegalizacionLibros._Items.Count == 0)
3621 {
3622 this._Error_Message = "No se ha declarado todavía ningún libro en el apartado 'Relación de libros'.";
3623 return false;
3624 }
3625
3626 // Si está en uso no permitimos imprimir ficheros.
3627 //
3628 if (this._EnUso)
3629 {
3630 this._Error_Message = "La legalización de libros se encuenta en uso desde otro terminal." + Environment.NewLine + Environment.NewLine +
3631 "Imposible imprimir solicitud de legalización en este momento.";
3632 return false;
3633 }
3634
3635
3636 int liniasSinArchivo = this._LineasLegalizacionLibros._Items.Where(x => string.IsNullOrWhiteSpace(x._RutaArchivo)).Count();
3637 if (liniasSinArchivo > 0)
3638 {
3639 this._Error_Message = "Se ha detectado algún libro en el apartado 'Relación de libros' sin ruta de archivo declarada." + Environment.NewLine + Environment.NewLine +
3640 "Para poder realizar la impresión de la solicitud de legalización es necesario declarar los archivos de todos los libros, y generar ficheros y firmas de todos los libros.";
3641 return false;
3642 }
3643
3644 int liniasArchivoSinFirma = this._LineasLegalizacionLibros._Items.Where(x => !string.IsNullOrWhiteSpace(x._RutaArchivo) && string.IsNullOrWhiteSpace(x._Firma)).Count();
3645 if (liniasArchivoSinFirma > 0)
3646 {
3647 this._Error_Message = "Se ha detectado algún libro en el apartado 'Relación de libros' sin firma realizada." + Environment.NewLine + Environment.NewLine +
3648 "Para poder realizar la impresión de la solicitud de legalización es necesario generar ficheros y firmas de todos los libros.";
3649 return false;
3650 }
3651
3652 return true;
3653 }
3654
3655
3664 {
3665 this._Error_Message = "";
3666
3667 // No se ha cargado ninguna legalización.
3668 //
3669 if (string.IsNullOrWhiteSpace(this._Numero))
3670 {
3671 this._Error_Message = "No se ha cargado todavía ninguna legalización.";
3672 return false;
3673 }
3674
3675 // No hay ningún libro declarado en la legalización.
3676 //
3677 if (this._LineasLegalizacionLibros._Items.Count == 0)
3678 {
3679 this._Error_Message = "No se ha declarado todavía ningún libro en el apartado 'Relación de libros'.";
3680 return false;
3681 }
3682
3683 // Si está en uso no permitimos crear ficheros.
3684 //
3685 if (this._EnUso)
3686 {
3687 this._Error_Message = "La legalización de libros se encuenta en uso desde otro terminal." + Environment.NewLine + Environment.NewLine +
3688 "Imposible generar fichero ZIP de legalización en este momento.";
3689 return false;
3690 }
3691
3692 // No está declarada la ruta de generación.
3693 //
3694 if (string.IsNullOrWhiteSpace(this._RutaGeneracion))
3695 {
3696 this._Error_Message = "La ruta de generación no puede estar vacía." + Environment.NewLine + Environment.NewLine +
3697 "Imposible generar fichero ZIP de legalización.";
3698 return false;
3699 }
3700
3701 // Libros con ruta de fichero declarada.
3702 //
3703 int liniasSinArchivo = this._LineasLegalizacionLibros._Items.Where(x => string.IsNullOrWhiteSpace(x._RutaArchivo)).Count();
3704 if (liniasSinArchivo > 0)
3705 {
3706 this._Error_Message = "Se ha detectado algún libro en el apartado 'Relación de libros' sin ruta de archivo declarada." + Environment.NewLine + Environment.NewLine +
3707 "Para poder realizar la creación de ficheros y firmas todos los libros deben tener ruta de archivo declarada.";
3708 return false;
3709 }
3710
3711 // Deben existir todos los ficheros declarados en las rutas.
3712 //
3713 string lcFichero = "";
3714 string lcFicherosFaltan = "";
3715 int lnFicherosInexistentes = 0;
3716 foreach (LineasLegalizacionLibros.LineaLegalizacionLibros loLinea in this._LineasLegalizacionLibros._Items)
3717 {
3718 lcFichero = loLinea._RutaArchivo.Trim();
3719 if (!File.Exists(lcFichero))
3720 {
3721 lnFicherosInexistentes++;
3722 lcFicherosFaltan += lcFichero + Environment.NewLine;
3723 }
3724 }
3725 if (lnFicherosInexistentes>0)
3726 {
3727 this._Error_Message = "No se ha detectado la existencia de " + (lnFicherosInexistentes == 1 ? "el fichero" : "los ficheros siguientes") + ":" +
3728 Environment.NewLine + Environment.NewLine + lcFicherosFaltan + Environment.NewLine + Environment.NewLine +
3729 "Para poder realizar la creación de ficheros de la legalización, todos los libros deben tener como ruta un archivo existente.";
3730 return false;
3731 }
3732
3733 // Ruta de generación declarada.
3734 //
3735 if (string.IsNullOrWhiteSpace(this._RutaGeneracion))
3736 {
3737 this._Error_Message = "Falta declarar la ruta donde generar los ficheros.";
3738 return false;
3739 }
3740
3741 // La ruta de generación tendrá el formato EUROSERV\LIBROS\GRP0001\01\2020\ donde EUROSERV\LIBROS es la ruta que hay declarada como
3742 // ruta de generación.
3743 //
3744 string lcRutaGeneracion = this._RutaGeneracionCompleta();
3745 if (!Directory.Exists(lcRutaGeneracion))
3746 {
3747 try
3748 {
3749 Directory.CreateDirectory(lcRutaGeneracion);
3750 }
3751 catch (Exception)
3752 {
3753 }
3754 if (!Directory.Exists(lcRutaGeneracion))
3755 {
3756 this._Error_Message = "No ha sido posible crear el directorio de exportación '"+ lcRutaGeneracion.Trim()+ "'.";
3757 return false;
3758 }
3759 }
3760
3761
3762 // Verificación de que estén los datos obligatorios en la pestaña de "Datos de presentación".
3763 //
3764 string lcFaltaCampo = "";
3765 if (!this.datosEmpresarioOk(ref lcFaltaCampo))
3766 {
3767 this._Error_Message = "Falta declarar el campo '"+lcFaltaCampo+"' en el apartado 'Datos del empresario' de la pestaña 'Datos de presentación'.";
3768 return false;
3769 }
3770
3771 if (!this.datosPresentadorOk(ref lcFaltaCampo))
3772 {
3773 this._Error_Message = "Falta declarar el campo '" + lcFaltaCampo + "' en el apartado 'Datos del presentador' de la pestaña 'Datos de presentación'.";
3774 return false;
3775 }
3776
3777 if (!this.datosRegistroOk(ref lcFaltaCampo))
3778 {
3779 this._Error_Message = "Falta declarar el campo '" + lcFaltaCampo + "' en el apartado 'Datos registrales' de la pestaña 'Datos de presentación'.";
3780 return false;
3781 }
3782
3783 return true;
3784 }
3785
3786
3794 {
3795 // La ruta de generación tendrá el formato EUROSERV\LIBROS\GRP0001\01\2020\ donde EUROSERV\LIBROS es la ruta que hay declarada como
3796 // ruta de generación.
3797 //
3798 string lcRutaGeneracion = this._RutaGeneracionCompleta();
3799
3800 int lnNumFicheros = 0;
3801 if (this.algunFicheroEnRutaGeneracion(lcRutaGeneracion, out lnNumFicheros))
3802 {
3803 this._Warning_Message = "Atención, se ha detectado la existencia de "+Convert.ToString(lnNumFicheros).Trim() + " "+(lnNumFicheros > 1 ? "archivos" : "archivo") + " " +
3804 "en la ruta donde debe generarse el fichero ZIP de la legalización."+Environment.NewLine+Environment.NewLine+lcRutaGeneracion + Environment.NewLine + Environment.NewLine +
3805 "Antes de realizar la creación del fichero ZIP de la legalización se eliminarán todos los archivos existentes en dicha carpeta.";
3806 return false;
3807 }
3808
3809 return true;
3810 }
3811
3812
3816 [ExcludeFromCodeCoverage]
3817 public new void _ShowDialog()
3818 {
3819 // Crear la instancia del formulario.
3820 //
3821 this._FormMante = new frmLegalizacionLibros(this);
3822
3823 // Primero cargamos el documento, y luego lo mostramos modal.
3824 //
3825 if (!string.IsNullOrWhiteSpace(this._Codigo))
3826 {
3827 if (this._FormMante != null)
3828 this._FormMante._CargarDocumento();
3829 }
3830
3831 // Mostrar el formulario.
3832 //
3833 ((formul.FormBaseDocumento)_FormMante).ShowDialog();
3834 }
3835
3836
3841 [ExcludeFromCodeCoverage]
3843 {
3844 this._LineasLegalizacionLibros._Grid = mantegrid;
3845
3847
3848 this.ajustesVisualesGrid(loGrid);
3849
3850 return;
3851 }
3852
3853
3858 [ExcludeFromCodeCoverage]
3859 public void _Set_FormMante(dynamic formMante)
3860 {
3861 this._FormMante = formMante;
3862 }
3863
3864
3869 [ExcludeFromCodeCoverage]
3871 {
3872 // DATOS EMPRESARIO (CIF, NOMBRE, APELLIDO1, APELLIDO2 se sacan del mismo sitio en territorio Común y en territorio Canarias).
3873 //
3874 if (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._NombreTC))
3875 {
3876 this._NombreEmpresario = EW_GLOBAL._Empresa._NombreTC;
3877 }
3878 else
3879 {
3880 // Si el nombre empresa está vacío, ponemos el campo apellidos (según análisis).
3881 //
3882 this._NombreEmpresario = EW_GLOBAL._Empresa._ApellidosTC;
3883 }
3884
3885 if (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._NombreTC))
3886 {
3887 // Solo guardo en apellidos lo que toca en caso de que el nombre se haya recuperado correctamente
3888 // en el paso anterior, pues caso contrario los apellidos ya se han puesto en el campo nombre y
3889 // no es necesario volver a repertirlos en el propio campo apellidos.
3890 //
3891 string lcApellidos = EW_GLOBAL._Empresa._ApellidosTC.Trim();
3892 int lnPosEspacio = lcApellidos.IndexOf(' ');
3893 if (lnPosEspacio > 0)
3894 {
3895 // Si en apellidos de empresa hay al menos un espacio, interpretamos hasta el primer espacio como primer apellido
3896 // y todo lo que venga a partir de alli como el segundo.
3897 //
3898 this._Apellido1Empresario = lcApellidos.Substring(0, lnPosEspacio);
3899 this._Apellido2Empresario = lcApellidos.Substring(lnPosEspacio + 1);
3900 }
3901 else
3902 {
3903 // Si en apellidos de empresa no hay espacio, va todo al primer apellido.
3904 this._Apellido1Empresario = lcApellidos;
3905 this._Apellido2Empresario = "";
3906 }
3907 }
3908
3909 this._CifEmpresario = EW_GLOBAL._Empresa._CifTC;
3910
3911
3912 // DATOS REGISTRO
3913 //
3914 this._CodigoRegistro = EW_GLOBAL._Empresa._CodigoAdministracion;
3915 this._NumeroTomoRegistro = EW_GLOBAL._Empresa._NumeroTomoRegistro;
3916 this._NumeroLibroRegistro = EW_GLOBAL._Empresa._NumeroLibroRegistro;
3917 this._NumeroSeccionRegistro = EW_GLOBAL._Empresa._NumeroSeccionRegistro;
3918 this._NumeroFolioRegistro = EW_GLOBAL._Empresa._NumeroFolioRegistro;
3919 this._NumeroHojaRegistro = EW_GLOBAL._Empresa._NumeroHojaRegistro;
3920 this._TipoRegistroMercantil = EW_GLOBAL._Empresa._TipoRegistroPublico;
3921 this._OtrosRegistroMercantil = EW_GLOBAL._Empresa._OtrosRegistro;
3922 this._RegistroMercantil = EW_GLOBAL._Empresa._RegistroMercantil;
3923 this._IRUS = EW_GLOBAL._Empresa._IRUS;
3924
3925 return;
3926 }
3927
3928
3932 [ExcludeFromCodeCoverage]
3934 {
3935 string lcDireccion = EW_GLOBAL._Empresa._SiglaTC.Trim() + " " +
3936 EW_GLOBAL._Empresa._NombreViaTC.Trim() +
3937 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._NumeroTC) ? " " + EW_GLOBAL._Empresa._NumeroTC.Trim() : "") +
3938 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._EscaleraTC) ? " " + EW_GLOBAL._Empresa._EscaleraTC.Trim() : "") +
3939 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._PisoTC) ? " " + EW_GLOBAL._Empresa._PisoTC.Trim() : "") +
3940 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._PuertaTC) ? " " + EW_GLOBAL._Empresa._PuertaTC.Trim() : "");
3941
3942 lcDireccion = lcDireccion.Trim();
3943 if (lcDireccion.Length > 32)
3944 lcDireccion = lcDireccion.Substring(0, 32);
3945
3946 this._DireccionEmpresario = lcDireccion;
3947 this._CodposEmpresario = EW_GLOBAL._Empresa._CodigoPostalTC;
3948 this._CiudadEmpresario = EW_GLOBAL._Empresa._MunicipioTC;
3949 this._ProvinciaEmpresario = EW_GLOBAL._Empresa._ProvinciaTC;
3950 this._TelefonoEmpresario = EW_GLOBAL._Empresa._TelefonoTC;
3951 this._FaxEmpresario = EW_GLOBAL._Empresa._FaxTC;
3952
3953 // DATOS PRESENTADOR
3954 //
3955 this._NombrePresentador = EW_GLOBAL._Empresa._NombreContactoTC;
3956
3957 string lcApellidos = EW_GLOBAL._Empresa._ApellidosContactoTC.Trim();
3958 int lnPosEspacio = lcApellidos.IndexOf(' ');
3959 if (lnPosEspacio > 0)
3960 {
3961 // Si en apellidos hay al menos un espacio, interpretamos hasta el primer espacio como primer apellido
3962 // y todo lo que venga a partir de alli como el segundo.
3963 //
3964 this._Apellido1Presentador = lcApellidos.Substring(0, lnPosEspacio);
3965 this._Apellido2Presentador = lcApellidos.Substring(lnPosEspacio + 1);
3966 }
3967 else
3968 {
3969 // Si en apellidos de empresa no hay espacio, va todo al primer apellido.
3970 //
3971 this._Apellido1Presentador = lcApellidos;
3972 this._Apellido2Presentador = "";
3973 }
3974 this._CifPresentador = EW_GLOBAL._Empresa._CifContactoTC;
3975
3976 this._DireccionPresentador = EW_GLOBAL._Empresa._NombreViaContactoTC;
3977 this._CodposPresentador = EW_GLOBAL._Empresa._CodigoPostalContactoTC;
3978 this._CiudadPresentador = EW_GLOBAL._Empresa._MunicipioContactoTC;
3979 this._ProvinciaPresentador = EW_GLOBAL._Empresa._ProvinciaContactoTC;
3980 this._TelefonoPresentador = EW_GLOBAL._Empresa._TelefonoContactoTC;
3981 this._FaxPresentador = EW_GLOBAL._Empresa._FaxContactoTC;
3982 this._EmailPresentador = EW_GLOBAL._Empresa._C_emailTC;
3983
3984 return;
3985 }
3986
3987
3991 [ExcludeFromCodeCoverage]
3993 {
3994 string lcDireccion = EW_GLOBAL._Empresa._SiglaCanarias.Trim() + " " +
3995 EW_GLOBAL._Empresa._NombreViaCanarias.Trim() +
3996 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._NumeroCanarias) ? " " + EW_GLOBAL._Empresa._NumeroCanarias.Trim() : "") +
3997 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._EscaleraCanarias) ? " " + EW_GLOBAL._Empresa._EscaleraCanarias.Trim() : "") +
3998 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._PisoCanarias) ? " " + EW_GLOBAL._Empresa._PisoCanarias.Trim() : "") +
3999 (!string.IsNullOrWhiteSpace(EW_GLOBAL._Empresa._PuertaCanarias) ? " " + EW_GLOBAL._Empresa._PuertaCanarias.Trim() : "");
4000
4001 lcDireccion = lcDireccion.Trim();
4002 if (lcDireccion.Length > 32)
4003 lcDireccion = lcDireccion.Substring(0, 32);
4004
4005 this._DireccionEmpresario = lcDireccion;
4006 this._CodposEmpresario = EW_GLOBAL._Empresa._CodigoPostalCanarias;
4007 this._CiudadEmpresario = EW_GLOBAL._Empresa._MunicipioCanarias;
4008 this._ProvinciaEmpresario = EW_GLOBAL._Empresa._ProvinciaCanarias;
4009 this._TelefonoEmpresario = EW_GLOBAL._Empresa._TelefonoCanarias;
4010 this._FaxEmpresario = EW_GLOBAL._Empresa._FaxCanarias;
4011
4012 // DATOS PRESENTADOR
4013 //
4014 this._NombrePresentador = EW_GLOBAL._Empresa._NombreContactoCanarias;
4015
4016 string lcApellidos = EW_GLOBAL._Empresa._ApellidosContactoCanarias.Trim();
4017 int lnPosEspacio = lcApellidos.IndexOf(' ');
4018 if (lnPosEspacio > 0)
4019 {
4020 // Si en apellidos hay al menos un espacio, interpretamos hasta el primer espacio como primer apellido
4021 // y todo lo que venga a partir de alli como el segundo.
4022 //
4023 this._Apellido1Presentador = lcApellidos.Substring(0, lnPosEspacio);
4024 this._Apellido2Presentador = lcApellidos.Substring(lnPosEspacio + 1);
4025 }
4026 else
4027 {
4028 // Si en apellidos de empresa no hay espacio, va todo al primer apellido.
4029 //
4030 this._Apellido1Presentador = lcApellidos;
4031 this._Apellido2Presentador = "";
4032 }
4033 this._CifPresentador = EW_GLOBAL._Empresa._CifContactoCanarias;
4034
4035 this._DireccionPresentador = EW_GLOBAL._Empresa._NombreViaContactoCanarias;
4036 this._CodposPresentador = EW_GLOBAL._Empresa._CodigoPostalContactoCanarias;
4037 this._CiudadPresentador = EW_GLOBAL._Empresa._MunicipioContactoCanarias;
4038 this._ProvinciaPresentador = EW_GLOBAL._Empresa._ProvinciaContactoCanarias;
4039 this._TelefonoPresentador = EW_GLOBAL._Empresa._TelefonoContactoCanarias;
4040 this._FaxPresentador = EW_GLOBAL._Empresa._FaxContactoCanarias;
4041 this._EmailPresentador = EW_GLOBAL._Empresa._EmailContactoCanarias;
4042
4043 return;
4044 }
4045
4046
4055 [ExcludeFromCodeCoverage]
4056 public bool _ImportarFicheroLegalizacion(string tcFicheroZipLegalizacion)
4057 {
4058 this._Error_Message = "";
4059
4060 // Crea la carpeta de importación si no existe. Si existe se asegura de que esté vacía, si no lo está borra todo para
4061 // asegurarse de que esté vacía. Si hay algún problema con todo lo anterior ya no se continúa. Es requesito tener esta
4062 // carpeta de importación completamente vacía pues el ZIP se copiará allá y se decomprimirá allá.
4063 //
4064 string lcCarpetaImportacion = "";
4065 if (!this.asegurarCarpetaImportacionVacia(out lcCarpetaImportacion))
4066 return false;
4067
4068 string lcNombreFicheroDestino = Path.Combine(lcCarpetaImportacion, Path.GetFileName(tcFicheroZipLegalizacion));
4069
4070 File.Copy(tcFicheroZipLegalizacion, lcNombreFicheroDestino);
4071
4072 if (!File.Exists(lcNombreFicheroDestino))
4073 {
4074 this._Error_Message = "No se ha podido copiar el fichero ZIP de legalización '" + tcFicheroZipLegalizacion + "' a la carpeta de importación '" + lcCarpetaImportacion + "'.";
4075 return false;
4076 }
4077
4078 if (!this.verificarRecuperarArchivoZip(lcNombreFicheroDestino, true))
4079 {
4080 // El mensaje de error ya se generó dentro del método anterior.
4081 return false;
4082 }
4083
4084 return true;
4085 }
4086
4087
4092 [ExcludeFromCodeCoverage]
4094 {
4095 this._Error_Message = "";
4096 bool llRetorno = true;
4097
4098 string lcRutaGeneracion = this._RutaGeneracionCompleta();
4099
4100 // Borrar ficheros que puedan haber en la ruta de generación. Préviamente ya se avisó al usuario.
4101 //
4102 bool llTodosArchivosBorrados = this.borrarTodosArchivosRuta(lcRutaGeneracion);
4103 if (!llTodosArchivosBorrados)
4104 {
4105 this._Error_Message = "No se han podido borrar todos los archivos existentes en la carpeta '" + lcRutaGeneracion + "'." + Environment.NewLine + Environment.NewLine +
4106 "Imposible realizar la creación de fichero ZIP de la legalización.";
4107 return false;
4108 }
4109
4110
4111 // Copiar ficheros de libros a ruta de generación adaptando nombres, y generar y guardar firmas.
4112 //
4113 bool llOk = this.exportarCopiarFicherosARutaGeneracion();
4114 if (!llOk)
4115 return false;
4116
4117
4118 // Preparar fichero NOMBRES.TXT
4119 //
4120 llOk = this.exportarPrepararFicheroNombresTxt();
4121 if (!llOk)
4122 return false;
4123
4124
4125 // Preparar fichero DATOS.TXT
4126 //
4127 llOk = this.exportarPrepararFicheroDatosTxt();
4128 if (!llOk)
4129 return false;
4130
4131
4132 // Crear fichero ZIP de legalización con los ficheros: NOMBRES.TXT, DATOS.TXT y todos los ficheros de libros incorporados.
4133 //
4134 llOk = this.exportarPrepararFicheroZip();
4135 if (!llOk)
4136 return false;
4137
4138
4139 return llRetorno;
4140 }
4141
4142
4143 #endregion MÉTODOS PÚBLICOS
4144
4145
4146 #region CLASE DE LINEAS DE LIBROS PRESENTADOS EN LA LEGALIZACION
4147
4148
4152 public class LineasLegalizacionLibros : ewManteTRel<LineasLegalizacionLibros.LineaLegalizacionLibros, LineasLegalizacionLibros.Clave>
4153 {
4154 #region PROPIEDADES PRIVADAS
4155
4156
4160 private string _lcEmpresa = Convert.ToString(EW_GLOBAL._GetVariable("wc_empresa"));
4161
4162
4166 public List<object> _lstTiposLibro = new List<object>();
4167
4168
4169 #endregion PROPIEDADES PRIVADAS
4170
4171
4172 #region PROPIEDADES PUBLICAS
4173
4174
4179 public Dictionary<string, string> _dicTiposLibro = new Dictionary<string, string>();
4180
4181
4186 {
4187 get
4188 {
4189 return (LegalizacionLibros)_ewMantePrincipal;
4190 }
4191 }
4192
4193
4194 #endregion PROPIEDADES PUBLICAS
4195
4196
4197 #region CONSTRUCTOR
4198
4199
4204 {
4205 }
4206
4207
4212 public LineasLegalizacionLibros(string tcEjercicio) : this(tcEjercicio, new LegalizacionLibrosDA())
4213 {
4214 }
4215
4216
4221 public LineasLegalizacionLibros(ILegalizacionLibrosDA legalizacionLibrosDA) :
4222 this(null, legalizacionLibrosDA)
4223 {
4224 }
4225
4240 public LineasLegalizacionLibros(string tcEjercicio, ILegalizacionLibrosDA legalizacionLibrosDA) :
4241 base(legalizacionLibrosDA)
4242 {
4243 // No hace falta establecer la propiedad _dataAccess aquí pues esta propiedad esta definida en la
4244 // clase base ewManteTRel (es de tipo protected, visible aquí en esta clase) por que al llamar al
4245 // constructor base(legalizacionLibrosDA) con el interfaz de acceso a datos como parámetro ya se
4246 // establece dicha propiedad en la clase base ewManteTRel y por tanto queda definida también para
4247 // la clase LineasLegalizacionLibros en la que estamos pues hereda de ewManteTRel.
4248 //
4249 // _dataAccess = legalizacionLibrosDA;
4250
4251 this.cargarDicLstTiposLibro();
4252
4253 this.crearEstructura();
4254
4255 if (!string.IsNullOrEmpty(tcEjercicio))
4256 {
4257 this._Claves._Empresa._Valor = this._lcEmpresa;
4258 this._Claves._Numero._Valor = tcEjercicio;
4259 }
4260
4261 return;
4262 }
4263
4264
4268 private void crearEstructura()
4269 {
4270 this._DataBase = "COMUNES";
4271 this._Tabla = "D_LEGLBR";
4272 this._OrdenarPor = "LINEA";
4273 this._Condicion = "";
4274
4275 // Código de empresa.
4276 //
4277 ewCampoTRel def_Empresa = this._AddCampoTRel("_Empresa", "Empresa");
4278 def_Empresa._AnchoColumna = 7;
4279 def_Empresa._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4280 def_Empresa._Editable = false;
4281 def_Empresa._Error_Duplicados = "";
4282 def_Empresa._Error_Validar_Dato = "";
4283 def_Empresa._ExpandirPunto = false;
4284 def_Empresa._FormatString = "";
4285 def_Empresa._PermiteDuplicados = true;
4286 def_Empresa._TipoColumna = gridColumnsTypes.Texto;
4287 def_Empresa._Titulo = "Empresa";
4288 def_Empresa._Updatable = true;
4289 def_Empresa._Validar_Asignar_Cargando = false;
4290 def_Empresa._Validar_Dato_BaseDatos = "";
4291 def_Empresa._Validar_Dato_Campos = "";
4292 def_Empresa._Validar_Dato_CampoTRel_Asignar = "";
4293 def_Empresa._Validar_Dato_Clave = "";
4294 def_Empresa._Validar_Dato_Tabla = "";
4295 def_Empresa._Visible = false;
4296
4297
4298 // Ejercicio
4299 //
4300 ewCampoTRel def_Numero = this._AddCampoTRel("_Numero", "Numero");
4301 def_Numero._AnchoColumna = 7;
4302 def_Numero._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4303 def_Numero._Editable = false;
4304 def_Numero._Error_Duplicados = "Ha introducido un valor que ya está asignado a otro registro. No se permiten valores duplicados en este campo.";
4305 def_Numero._Error_Validar_Dato = "Ha introducido un valor que no se ha encontrado en su mantenimiento origen.";
4306 def_Numero._ExpandirPunto = false;
4307 def_Numero._FormatString = "";
4308 def_Numero._PermiteDuplicados = true;
4309 def_Numero._TipoColumna = gridColumnsTypes.Texto;
4310 def_Numero._Titulo = "Ejercicio";
4311 def_Numero._Updatable = true;
4312 def_Numero._Validar_Asignar_Cargando = false;
4313 def_Numero._Validar_Dato_BaseDatos = "";
4314 def_Numero._Validar_Dato_Campos = "";
4315 def_Numero._Validar_Dato_CampoTRel_Asignar = "";
4316 def_Numero._Validar_Dato_Clave = "";
4317 def_Numero._Validar_Dato_Tabla = "";
4318 def_Numero._Visible = false;
4319
4320
4321 // Linea
4322 //
4323 this._AddCampoTRel("_Linia", "Linea", ewCampoTRel.Visible.No, ewCampoTRel.Updatable.Si, ewCampoTRel.Editable.No, "", gridColumnsTypes.Número);
4324
4325 // Tipo de libro.
4326 // Campo real de la tabla que ocultamos pero actualizamos
4327 //
4328 this._AddCampoTRel("_TipoLibro", "Tipo", false, true, false);
4329
4330
4331 // Campo visible solamente. Como tal no se actualiza, pero el Set de la propiedad actualiza el valor de la propiedad _Tipo
4332 // Dejo la lista de elementos de cuentas bancarias vacía a la espera de que se haga el _Load(), es allí donde las carga.
4333 //
4334 ewCampoTRel def_TipoLibro = this._AddCampoTRel("_TipoLibroVisual", "", true, false, true, "Tipo de libro", gridColumnsTypes.Combo, toComboValues: this._lstTiposLibro, tnAnchoColumna : 24);
4335 def_TipoLibro._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4336 def_TipoLibro._Error_Duplicados = "";
4337 def_TipoLibro._Error_Validar_Dato = "";
4338 def_TipoLibro._ExpandirPunto = false;
4339 def_TipoLibro._FormatString = "";
4340 def_TipoLibro._PermiteDuplicados = false;
4341
4342
4343 // Ruta al archivo del libro
4344 //
4345 ewCampoTRel def_RutaArchivo = this._AddCampoTRel("_RutaArchivo", "Ruta_fich");
4346 def_RutaArchivo._AnchoColumna = 0;
4347 def_RutaArchivo._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.Fill;
4348 def_RutaArchivo._Editable = true;
4349 def_RutaArchivo._Error_Duplicados = "";
4350 def_RutaArchivo._Error_Validar_Dato = "";
4351 def_RutaArchivo._ExpandirPunto = false;
4352 def_RutaArchivo._FormatString = "";
4353 def_RutaArchivo._PermiteDuplicados = true;
4354 def_RutaArchivo._TipoColumna = gridColumnsTypes.Texto;
4355 def_RutaArchivo._Titulo = "Fichero";
4356 def_RutaArchivo._Updatable = true;
4357 def_RutaArchivo._Validar_Asignar_Cargando = false;
4358 def_RutaArchivo._Validar_Dato_BaseDatos = "";
4359 def_RutaArchivo._Validar_Dato_Campos = "";
4360 def_RutaArchivo._Validar_Dato_CampoTRel_Asignar = "";
4361 def_RutaArchivo._Validar_Dato_Clave = "";
4362 def_RutaArchivo._Validar_Dato_Tabla = "";
4363 def_RutaArchivo._Visible = true;
4364
4365
4366 // Columna de tipo botón para seleccionar un archivo.
4367 //
4368 this._AddCampoTRel("", "", ewCampoTRel.Visible.Si, ewCampoTRel.Updatable.No, ewCampoTRel.Editable.No, "", gridColumnsTypes.Boton, null, 2, null, "...");
4369
4370
4371 // Número de libro.
4372 //
4373 ewCampoTRel def_NumLibro = this._AddCampoTRel("_NumLibro", "Num_libro");
4374 def_NumLibro._AnchoColumna = 5;
4375 def_NumLibro._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4376 def_NumLibro._Editable = true;
4377 def_NumLibro._Error_Duplicados = "";
4378 def_NumLibro._Error_Validar_Dato = "";
4379 def_NumLibro._ExpandirPunto = false;
4380 def_NumLibro._FormatString = "";
4381 def_NumLibro._PermiteDuplicados = true;
4382 def_NumLibro._TipoColumna = gridColumnsTypes.Texto;
4383 def_NumLibro._Titulo = "Número";
4384 def_NumLibro._Updatable = true;
4385 def_NumLibro._Validar_Asignar_Cargando = false;
4386 def_NumLibro._Validar_Dato_BaseDatos = "";
4387 def_NumLibro._Validar_Dato_Campos = "";
4388 def_NumLibro._Validar_Dato_CampoTRel_Asignar = "";
4389 def_NumLibro._Validar_Dato_Clave = "";
4390 def_NumLibro._Validar_Dato_Tabla = "";
4391 def_NumLibro._Visible = true;
4392
4393
4394 // Fecha apertura
4395 //
4396 ewCampoTRel def_FechaApertura = this._AddCampoTRel("_FecApertura", "Fec_aper");
4397 def_FechaApertura._AnchoColumna = 7;
4398 def_FechaApertura._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4399 def_FechaApertura._Editable = true;
4400 def_FechaApertura._Error_Duplicados = "";
4401 def_FechaApertura._Error_Validar_Dato = "";
4402 def_FechaApertura._ExpandirPunto = false;
4403 def_FechaApertura._FormatString = "";
4404 def_FechaApertura._PermiteDuplicados = true;
4405 def_FechaApertura._TipoColumna = gridColumnsTypes.Fecha;
4406 def_FechaApertura._Titulo = "Fecha apertura";
4407 def_FechaApertura._Updatable = true;
4408 def_FechaApertura._Validar_Asignar_Cargando = false;
4409 def_FechaApertura._Validar_Dato_BaseDatos = "";
4410 def_FechaApertura._Validar_Dato_Campos = "";
4411 def_FechaApertura._Validar_Dato_CampoTRel_Asignar = "";
4412 def_FechaApertura._Validar_Dato_Clave = "";
4413 def_FechaApertura._Validar_Dato_Tabla = "";
4414 def_FechaApertura._Visible = true;
4415
4416
4417 // Fecha cierre
4418 //
4419 ewCampoTRel def_FechaCierre = this._AddCampoTRel("_FecCierre", "Fec_cierre");
4420 def_FechaCierre._AnchoColumna = 6;
4421 def_FechaCierre._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4422 def_FechaCierre._Editable = true;
4423 def_FechaCierre._Error_Duplicados = "";
4424 def_FechaCierre._Error_Validar_Dato = "";
4425 def_FechaCierre._ExpandirPunto = false;
4426 def_FechaCierre._FormatString = "";
4427 def_FechaCierre._PermiteDuplicados = true;
4428 def_FechaCierre._TipoColumna = gridColumnsTypes.Fecha;
4429 def_FechaCierre._Titulo = "Fecha cierre";
4430 def_FechaCierre._Updatable = true;
4431 def_FechaCierre._Validar_Asignar_Cargando = false;
4432 def_FechaCierre._Validar_Dato_BaseDatos = "";
4433 def_FechaCierre._Validar_Dato_Campos = "";
4434 def_FechaCierre._Validar_Dato_CampoTRel_Asignar = "";
4435 def_FechaCierre._Validar_Dato_Clave = "";
4436 def_FechaCierre._Validar_Dato_Tabla = "";
4437 def_FechaCierre._Visible = true;
4438
4439
4440 // Fecha cierre anterior
4441 //
4442 ewCampoTRel def_FechaCierreAnt = this._AddCampoTRel("_FecCierreAnt", "Fec_cie_an");
4443 def_FechaCierreAnt._AnchoColumna = 7;
4444 def_FechaCierreAnt._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4445 def_FechaCierreAnt._Editable = true;
4446 def_FechaCierreAnt._Error_Duplicados = "";
4447 def_FechaCierreAnt._Error_Validar_Dato = "";
4448 def_FechaCierreAnt._ExpandirPunto = false;
4449 def_FechaCierreAnt._FormatString = "";
4450 def_FechaCierreAnt._PermiteDuplicados = true;
4451 def_FechaCierreAnt._TipoColumna = gridColumnsTypes.Fecha;
4452 def_FechaCierreAnt._Titulo = "F.Cierre Lib.Ant.";
4453 def_FechaCierreAnt._Updatable = true;
4454 def_FechaCierreAnt._Validar_Asignar_Cargando = false;
4455 def_FechaCierreAnt._Validar_Dato_BaseDatos = "";
4456 def_FechaCierreAnt._Validar_Dato_Campos = "";
4457 def_FechaCierreAnt._Validar_Dato_CampoTRel_Asignar = "";
4458 def_FechaCierreAnt._Validar_Dato_Clave = "";
4459 def_FechaCierreAnt._Validar_Dato_Tabla = "";
4460 def_FechaCierreAnt._Visible = true;
4461
4462 // Firma digital.
4463 //
4464 ewCampoTRel def_Firma = this._AddCampoTRel("_Firma", "Firma");
4465 def_Firma._AnchoColumna = 0;
4466 def_Firma._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4467 def_Firma._Editable = false;
4468 def_Firma._Error_Duplicados = "";
4469 def_Firma._Error_Validar_Dato = "";
4470 def_Firma._ExpandirPunto = false;
4471 def_Firma._FormatString = "";
4472 def_Firma._PermiteDuplicados = true;
4473 def_Firma._TipoColumna = gridColumnsTypes.Texto;
4474 def_Firma._Titulo = "Firma";
4475 def_Firma._Updatable = true;
4476 def_Firma._Validar_Asignar_Cargando = false;
4477 def_Firma._Validar_Dato_BaseDatos = "";
4478 def_Firma._Validar_Dato_Campos = "";
4479 def_Firma._Validar_Dato_CampoTRel_Asignar = "";
4480 def_Firma._Validar_Dato_Clave = "";
4481 def_Firma._Validar_Dato_Tabla = "";
4482 def_Firma._Visible = false;
4483
4484 // Columna de tipo botón para ver el archivo.
4485 //
4486 //this._AddCampoTRel("_VerFichero", "", ewCampoTRel.Visible.Si, ewCampoTRel.Updatable.No, ewCampoTRel.Editable.No, "Ver fichero", gridColumnsTypes.Imagen, tnAnchoColumna: 3);
4487
4488 ewCampoTRel def_Verfichero = this._AddCampoTRel("_VerFichero", "", ewCampoTRel.Visible.Si, ewCampoTRel.Updatable.No, ewCampoTRel.Editable.No, "", gridColumnsTypes.Imagen);
4489 def_Verfichero._AnchoColumna = 3;
4490 def_Verfichero._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4491 def_Verfichero._Titulo = "Ver";
4492
4493 // Columna de tipo imagén para mostrar aspa rojo o visto bueno en función de si se ha generado fichero y firma para una fichero.
4494 //
4495 //this._AddCampoTRel("_FicheroFirmado", "", ewCampoTRel.Visible.Si, ewCampoTRel.Updatable.No, ewCampoTRel.Editable.No, "Firmado", gridColumnsTypes.Imagen, tnAnchoColumna: 3);
4496 ewCampoTRel def_Firmado = this._AddCampoTRel("_FicheroFirmado", "", ewCampoTRel.Visible.Si, ewCampoTRel.Updatable.No, ewCampoTRel.Editable.No, "", gridColumnsTypes.Imagen);
4497 def_Firmado._AnchoColumna = 5;
4498 def_Firmado._AutoModeSizeColumna = DataGridViewAutoSizeColumnMode.None;
4499 def_Firmado._Titulo = "Firmado";
4500
4501 return;
4502 }
4503
4504
4508 private void cargarDicLstTiposLibro()
4509 {
4510 this._dicTiposLibro.Clear();
4511
4512 // Rellenar el diccionar con los tiposde libro.
4513 //
4514 this._dicTiposLibro.Add("Diario","DIARIO");
4515 this._dicTiposLibro.Add("Inventario y cuentas anuales" ,"INV_CUEN");
4516 this._dicTiposLibro.Add("Balances de comprobación (sumas y saldos)","BAL_SUMS");
4517 this._dicTiposLibro.Add("Inventario", "INVENTAR");
4518 this._dicTiposLibro.Add("Balances", "BALANCES");
4519 this._dicTiposLibro.Add("Memoria","MEMORIA");
4520 this._dicTiposLibro.Add("Mayor","MAYOR");
4521 this._dicTiposLibro.Add("Libro de Pérdidas y Ganancias","PER_GAN");
4522 this._dicTiposLibro.Add("IVA", "IVA");
4523 this._dicTiposLibro.Add("Facturas emitidas","FAC_EMIT");
4524 this._dicTiposLibro.Add("Facturas recibidas","FAC_RECI");
4525 this._dicTiposLibro.Add("Detalle del Diario","DET_DIA");
4526 this._dicTiposLibro.Add("Registro de Acciones Nominativas","ACCIONES");
4527 this._dicTiposLibro.Add("Registro de Socios", "SOCIOS");
4528 this._dicTiposLibro.Add("Libro de Actas" ,"ACTASCON");
4529 this._dicTiposLibro.Add("Libro de Detalle de Actas", "ACTASDET");
4530 this._dicTiposLibro.Add("Libro de Actas del Consejo", "ACTALCON");
4531 this._dicTiposLibro.Add("Libro de Detalle de Actas del Consejo","ACTACODE");
4532 this._dicTiposLibro.Add("Libro de Contratos del Socio Único con la Sociedad Unipersonal","SOCUNICO");
4533 this._dicTiposLibro.Add("Otros","OTROS");
4534
4535 this._lstTiposLibro.Clear();
4536 foreach (KeyValuePair<string, string> loKeyValuePair in this._dicTiposLibro)
4537 this._lstTiposLibro.Add(loKeyValuePair.Key);
4538
4539 return;
4540 }
4541
4542
4543 #endregion CONSTRUCTOR
4544
4545
4546 #region MÉTODOS PUBLIC OVERRIDE SOBREESCRITOS DE EWMANTTREL
4547
4548
4552 public override void _Load()
4553 {
4554 // Nos aseguramos de que la clave esté bien informada.
4555 //
4556 this._Claves._Empresa._Valor = this._oLegalizacion._Empresa;
4557 this._Claves._Numero._Valor = this._oLegalizacion._Numero;
4558
4559 this._bIsLoading = true;
4560
4561 base._Load();
4562
4563 this._bIsLoading = false;
4564
4565 return;
4566 }
4567
4568
4572 [ExcludeFromCodeCoverage]
4573 public override bool _Save()
4574 {
4575 // Nos aseguramos de que la clave esté bien informada.
4576 //
4577 this._Claves._Empresa._Valor = this._oLegalizacion._Empresa;
4578 this._Claves._Numero._Valor = this._oLegalizacion._Numero;
4579
4580 bool llOk = base._Save();
4581
4582 return llOk;
4583 }
4584
4585
4586 #endregion MÉTODOS PUBLIC OVERRIDE SOBREESCRITOS DE EWMANTTREL
4587
4588
4592 public class Clave : IClaves
4593 {
4597 public ClaveTRel _Empresa { get; set; }
4598
4599
4603 public ClaveTRel _Numero { get; set; }
4604
4605
4609 public ClaveTRel _Linia { get; set; }
4610
4611
4615 public Clave()
4616 {
4617 // Definición de las propiedades de cada una de las claves.
4618
4619 // Empresa de la legalización de libros.
4620 //
4621 this._Empresa = new ClaveTRel();
4622 this._Empresa._EsFiltro = true;
4623 this._Empresa._EsCampoLinea = false;
4624
4625
4626 // Ejercicio de la legalización de libros.
4627 //
4628 this._Numero = new ClaveTRel();
4629 this._Numero._EsFiltro = true;
4630 this._Numero._EsCampoLinea = false;
4631
4632
4633 // Linea del registdro de la legalización de libros.
4634 //
4635 this._Linia = new ClaveTRel();
4636 this._Linia._EsCampoLinea = true;
4637 this._Linia._Valor = 0;
4638 }
4639 }
4640
4641
4646 {
4647 #region PROPIEDADES PRIVADAS
4648
4649
4653 private LineasLegalizacionLibros _oLineasLegalizacion
4654 {
4655 get
4656 {
4657 return (LineasLegalizacionLibros)loParent;
4658 }
4659 }
4660
4661
4662 #endregion PROPIEDADES PRIVADAS
4663
4664
4665 #region PROPIEDADES PUBLICAS
4666
4667
4671 [ReportProperty("Empresa", "", "Empresa:")]
4672 public string _Empresa
4673 {
4674 get
4675 {
4676 return this._cEmpresa;
4677 }
4678 set
4679 {
4680 this._cEmpresa = value;
4681 }
4682 }
4683
4686 private string _cEmpresa = "";
4687
4688
4692 [ReportProperty("Ejercicio", "", "Ejercicio:")]
4693 public string _Numero
4694 {
4695 get
4696 {
4697 return this._cNumero;
4698 }
4699 set
4700 {
4701 this._cNumero = value;
4702 }
4703 }
4704
4707 private string _cNumero = "";
4708
4709
4713 public int _Linia
4714 {
4715 get { return _nLinia; }
4716 set { _nLinia = value; }
4717 }
4718 private int _nLinia = 0;
4719
4720
4724 public string _TipoLibro
4725 {
4726 get
4727 {
4728 if (_cTipoLibro == null)
4729 _cTipoLibro = "";
4730
4731 return _cTipoLibro;
4732 }
4733 set
4734 {
4735 _cTipoLibro = value;
4736 }
4737 }
4738 private string _cTipoLibro = "";
4739
4740
4744 public string _TipoLibroVisual
4745 {
4746 get
4747 {
4748 string lcTipoLibroVisual = this._oLineasLegalizacion._dicTiposLibro.FirstOrDefault(x => x.Value == this._TipoLibro.Trim()).Key;
4749
4750 return lcTipoLibroVisual;
4751 }
4752 set
4753 {
4754 if (value == null)
4755 return;
4756
4757 string lcTipoLibro = "";
4758
4759 this._oLineasLegalizacion._dicTiposLibro.TryGetValue(value.Trim(), out lcTipoLibro);
4760
4761 this._TipoLibro = lcTipoLibro;
4762 }
4763 }
4764
4765
4769 public string _RutaArchivo
4770 {
4771 get
4772 {
4773 return _cRutaArchivo;
4774 }
4775 set
4776 {
4777 _cRutaArchivo = value;
4778 }
4779 }
4780 private string _cRutaArchivo = "";
4781
4782
4786 public string _NumLibro
4787 {
4788 get
4789 {
4790 return _cNumLibro;
4791 }
4792 set
4793 {
4794 _cNumLibro = value;
4795 }
4796 }
4797 private string _cNumLibro = "";
4798
4799
4803 [ReportProperty("FecApertura", "dd/MM/yyyy", "Fecha apertura:")]
4804 public DateTime? _FecApertura
4805 {
4806 get
4807 {
4808 return this._dFecApertura;
4809 }
4810 set
4811 {
4812 if (loParent != null && !loParent._bIsLoading)
4813 {
4814 bool llCambio = (this._dFecApertura != value);
4815
4816 if (llCambio)
4817 {
4818 if (value !=null && this._dFecCierre != null && value >= this._dFecCierre)
4819 {
4820 this._oLineasLegalizacion._oLegalizacion._Error_Message_Linea = "La fecha de apertura (" + Convert.ToDateTime(value).ToShortDateString() + ") debe ser inferior a la fecha de cierre (" + Convert.ToDateTime(this._dFecCierre).ToShortDateString() + ").";
4821 return;
4822 }
4823 }
4824 }
4825
4826 this._dFecApertura = value;
4827 }
4828 }
4829
4832 private DateTime? _dFecApertura = null;
4833
4834
4838 [ReportProperty("FecCierre", "dd/MM/yyyy", "Fecha cierre:")]
4839 public DateTime? _FecCierre
4840 {
4841 get
4842 {
4843 return this._dFecCierre;
4844 }
4845 set
4846 {
4847 if (loParent != null && !loParent._bIsLoading)
4848 {
4849 bool llCambio = (this._dFecCierre != value);
4850
4851 if (llCambio)
4852 {
4853 if (value != null && this._dFecApertura != null && this._dFecApertura >= value)
4854 {
4855 this._oLineasLegalizacion._oLegalizacion._Error_Message_Linea = "La fecha de cierre (" + Convert.ToDateTime(value).ToShortDateString() + ") debe ser superior a la fecha de apertura (" + Convert.ToDateTime(this._dFecApertura).ToShortDateString() + ").";
4856 return;
4857 }
4858 }
4859 }
4860
4861 this._dFecCierre = value;
4862 }
4863 }
4864
4867 private DateTime? _dFecCierre = null;
4868
4869
4873 [ReportProperty("FecCierreAnt", "dd/MM/yyyy", "Fecha cierre libro anterior:")]
4874 public DateTime? _FecCierreAnt
4875 {
4876 get
4877 {
4878 return this._dFecCierreAnt;
4879 }
4880 set
4881 {
4882 if (loParent != null && !loParent._bIsLoading && value != null)
4883 {
4884 bool llCambio = (this._dFecCierreAnt != value);
4885
4886 if (llCambio)
4887 {
4888 if (value != null && this._dFecApertura != null && value >= this._dFecApertura)
4889 {
4890 this._oLineasLegalizacion._oLegalizacion._Error_Message_Linea = "La fecha de cierre anterior (" + Convert.ToDateTime(value).ToShortDateString() + ") debe ser inferior a la fecha de apertura (" + Convert.ToDateTime(this._dFecApertura).ToShortDateString() + ").";
4891 return;
4892 }
4893 }
4894 }
4895
4896 this._dFecCierreAnt = value;
4897 }
4898 }
4899
4902 private DateTime? _dFecCierreAnt = null;
4903
4904
4908 public string _Firma
4909 {
4910 get
4911 {
4912 return _cFirma;
4913 }
4914 set
4915 {
4916 _cFirma = value;
4917 }
4918 }
4919 private string _cFirma = "";
4920
4921
4925 public object _Parent
4926 {
4927 get { return loParent; }
4928 set { loParent = (LineasLegalizacionLibros)value; }
4929 }
4930 private LineasLegalizacionLibros loParent;
4931
4932
4933 #endregion PROPIEDADES PUBLICAS
4934
4935
4936 #region CONSTRUCTOR
4937
4938
4943 {
4944 }
4945
4946
4947 #endregion CONSTRUCTOR
4948
4949
4950 #region MÉTODOS PÚBLICOS.
4951
4952
4957 public bool Fila_Plena()
4958 {
4959 bool lbFilaPlena;
4960
4961 lbFilaPlena = _TipoLibro != "" && _RutaArchivo != "" ;
4962
4963 return lbFilaPlena;
4964 }
4965
4966
4967 #endregion MÉTODOS PÚBLICOS.
4968 }
4969 }
4970
4971
4972 #endregion CLASE DE LINEAS DE LIBROS PRESENTADOS EN LA LEGALIZACION
4973 }
4974
4975
4980 {
4985 [ExcludeFromCodeCoverage]
4986 public override bool _Print()
4987 {
4988 if (_Show_Print())
4989 {
4990 return _PrintNET();
4991 }
4992 return true;
4993 }
4994
4995
5002 [ExcludeFromCodeCoverage]
5003 public override bool _Show_Print(int tnAbrirEn = 1)
5004 {
5005 frmReportAction loForm;
5006
5007 loForm = new frmReportAction();
5008 loForm._ReportBase = _Documento._ReportBase;
5009 loForm._Nombre = _Documento._Nombre;
5010 loForm._Printer = _Printer;
5011 loForm._ImpresionNormalMultiple = _ImpresionNormalMultiple;
5012 loForm._UserControlAdicional = _UserControlAdicional;
5013 loForm._PrinterCopies = Convert.ToInt16(_Numero_Copias);
5014 loForm._MostrarExportacionCSV = false;
5015 loForm._MostrarOpcionColores = false;
5016 loForm._ShowEditMode = true;
5017 loForm._ShowDialog();
5018
5019 if (loForm.DialogResult == DialogResult.OK)
5020 {
5022 _Ruta_Fichero = loForm._FilePath;
5023 _Printer = loForm._Printer;
5024 _Exportar = loForm._Exportar;
5025 _EditMode = loForm._EditMode;
5028
5029 return true;
5030 }
5031
5032 return false;
5033 }
5034
5035
5040 public DocPrintLegalizacionLibros(IDocumentoImprimible toLegalizacion) : base()
5041 {
5042 _Documento = toLegalizacion;
5043 }
5044 }
5045
5046}
Clase de acceso datos para la clase LegalizacionLibros.
Clase para la impresión de los dos reports de legalización de libros.
override bool _Show_Print(int tnAbrirEn=1)
Método que imprementa la visualización de opciones de impresión. Se debe implementar en la clase espe...
DocPrintLegalizacionLibros(IDocumentoImprimible toLegalizacion)
Constructor.
override bool _Print()
Método que imprementa la impresión.
Clase formulario para legalización de libros en el registro mercantil.
ClaveTRel _Linia
Linia de registro de la legalización de libros.
string _NumLibro
Nº de libro en el formato 001, 002, etc., caso de tener más de un libro del mismo tipo.
Clase para las lineas de la relación de libros de la legalización.
LegalizacionLibros _oLegalizacion
Objeto de negocio LegalizacionLibros padre del cual cuelga el ManteTRel de lineas de libros de la leg...
LineasLegalizacionLibros(ILegalizacionLibrosDA legalizacionLibrosDA)
Constructor con objeto de acceso a datos.
Dictionary< string, string > _dicTiposLibro
Diccionario donde guardaremos la codificación de los diferentes tipos de libros, su descripción larga...
LineasLegalizacionLibros(string tcEjercicio, ILegalizacionLibrosDA legalizacionLibrosDA)
Constructor con parámetros código de ejercicio y objeto de acceso a datos.
LineasLegalizacionLibros()
Constructor de la clase de LineasLegalizacionLibros sin parámetros.
override void _Load()
Carga del ManteTRel de lineas de libros de la legalización.
LineasLegalizacionLibros(string tcEjercicio)
Constructor con parámetro ejercicio.
override bool _Save()
Save del ManteTRel de lineas de libros de la legalización.
List< object > _lstTiposLibro
Lista de valores de la combo de tipos de libro.
string _CiudadPresentador
Ciudad del presentador.
bool _Comprobaciones_ExportarFichero()
Comprobaciones varias antes de permitir la creación del fichero ZIP de la legalización.
new string _Error_Message
Mensaje de error durante el procesamiento de datos generales de la remesa.
string _Error_Message_Linea
Mensaje de error durante el procesamiento de una linea de la remesa. Contrariamente a la propiedad _E...
string _NumeroHojaRegistro
Número de hoja datos registrales.
bool _EsPrimerLibroTipo(string tcTipoLibro, string tcNumLibro)
Devuelve true si el libro es el primero de todos los libros declarados del tipo recibido....
string _TelefonoPresentador
Teléfono del presentador.
bool _Comprobaciones_ExportarFichero_Warning()
Comprobaciones de tipo Warning a realizar antes de permitir crear ficheros, se verifica que en la rut...
override bool _Delete()
Elimina el documento de legalización de libros cargado.
TipoImpresion
Diferentes opciones impresión de legalización de libros.
@ SolicitudLegalizacion
Impresión de documento de solicitud de legalización.
@ CertificadoFirmas
Impresión de documento de firmas de los ficheros que se legalizan.
new void _ShowDialog()
Visualización del formulario de legalización de libros en modo Modal.
override bool _Solo_Lectura
Si el documento esta en uso o el usuario no tiene acceso a esta pantalla o tiene acceso de solo lectu...
void _Set_GridDetalleRelacionLibros(objetos.UserControls.Mantegrid mantegrid)
Asignar el grid al mantetrel de detalle de relación de libros presentados.
override bool _Comprobar_Existe_Documento(string tcEjercicio)
Comprobar si el documento legalizacion de libos existe o no.
void _CargarDatosTerritorioComun()
Cargar datos de empresario y presentador caso territorio Común.
bool _Comprobaciones_ImportarFichero(ref string tcArchivoZipLegalizacion)
Comprobaciones a realizar antes de permitir importar fichero externo ZIP de legalización en el formul...
void _RenumerarLibrosTipoLibro(string tcTipoLibro)
Dado un tipo de libro renumera el campo Número Documento de los registros con ese tipo de libro.
string _NombrePresentador
Nombre del representante.
override void _Print()
Imprimir solicitud de legalización de libros o certificacion de libros.
EstadoFirmasLibros
Diferentes estados de generación de firmas en los libros declarados en la legalización.
@ TodasFirmasGeneradas
Se ha generado firma para todos los libros declarados en la legalización.
@ AlgunaFirmaGenerada
Se ha generado firma para alguno de los libros declarados en la legalización pero existe todavía algú...
@ NingunaFirmaGenerada
No se ha generado firma para ninguno de los libros declarados en la legalización.
@ NoEvaluado
No se ha evaluado todavía el estado de las firmas de los libros declarados en la legalización.
bool _Comprobaciones_CargarDatos()
Comprobaciones a realizar antes de permitir cargar datos de empresario, presentador y registro mercan...
override bool _Save_Before()
Sobreescribir el método _Save_Before() para que no realice las validaciones de propiedades de la base...
bool _ImportarFicheroLegalizacion(string tcFicheroZipLegalizacion)
Importar fichero ZIP de legalización.
void _CargarDatosTerritorioCanarias()
Cargar datos de empresario y presentador caso territorio Canarias.
string _Apellido1Empresario
Apellido 1 del empresario.
void _AgruparLineasPorTipoLibro()
Renumerar el campo LINEA de la tabla D_LEGLBR de la legalización en curso para que todos los registro...
override DataTable _Obtener_Datos_SageReports(Dictionary< string, object > tdicParametros=null)
Crea las lineas para la impresión.
LegalizacionLibros(ILegalizacionLibrosDA legalizacionLibrosDA)
Constructor con parámetro de objeto de acceso a datos para la clase LegalizacionLibros.
string _Apellido2Presentador
Apellido 2 del presentador.
string _NumNuevoDocumento(string tcTipoLibro)
Obtiene el nuevo nº de documento a asignar en una nueva linea de libro de la relación de libros,...
bool _SolicitaRetencion
Solicita retención IRPF.
string _CodposEmpresario
Código postal del empresario.
string _RutaGeneracion
Ruta de generación de los ficheros en el momento de la generación.
string _RutaGeneracionCompleta(bool tlNoCrearCarpeta=false)
Devuelve la ruta de generación completa a partir de la ruta base + grupo + empresa + ejercicio.
DateTime _Fecha
Fecha de solicitud de la legalización de libros.
override void AsignarValoresClave()
Asigna los valores de la clave que son fijos.
string _Warning_Message
Mensaje de warning que se ofrecerá al usuario al realizar algún proceso que implique su intervención ...
int _NumeroLibrosPresentados
Número libros presentados en la legalización, hace referencia al campo físico de la base de datos en ...
delegate void _Error_Message_Linea_After_Handler(string tcMissatge)
Delegado del evento que se dispara despues de establecer un valor en _Error_Message_Linea.
bool _Comprobaciones_Imprimir()
Comprobaciones a realizar antes de permitir imprimir documentos de solicitud y firmas.
string _CodposPresentador
Código postal del presentador.
string _IRUS
Número de hoja datos registrales.
override Dictionary< string, object > _Obtener_Filtros_SageReports(Dictionary< string, object > tdicParametros=null)
Crea las variables para la impresión.
LegalizacionLibros(string tcEjercicio, ILegalizacionLibrosDA legalizacionLibrosDA)
Constructor con parámetro de ejercicio y parámetro de interfaz de acceso a datos a la clase Legalizac...
override string _Nombre
Nombre, por compatibilidad con clase base.
string _CiudadEmpresario
Ciudad del empresario.
string _ProvinciaPresentador
Provincia del presentador.
void _Set_FormMante(dynamic formMante)
Permitir asignar el fomulario a la clase para cuando se crea primero el formulario.
LineasLegalizacionLibros _LineasLegalizacionLibros
Propiedad con las lineas de los libros incluidos en la legalización.
void _CargarDatosComunesTerritorios()
Cargar datos comunes a territorio común y Canarias, básicamente son Nompre empresario,...
string _NumeroLibroRegistro
Número de libro registros.
override void Inicializar()
Método para inicializar el documento.
string _Apellido2Empresario
Apellido 2 del empresario.
LegalizacionLibros(string tcEjercicio)
Constructor con parámetro de ejercicio.
override bool _Show_Print(int tnAbrirEn=1)
_Show_Print
string _NombreEmpresario
Nombre del empresario.
bool _ExportarFicheroLegalizacion()
Generar fichero ZIP de legalización.
new string _Empresa
Empresa sobre la que se presentan los libros.
string _TipoRegistroMercantil
Tipo de registro mercantil.
string _ProvinciaEmpresario
Provincia del empresario.
bool _Comprobaciones_Borrar()
Comprobaciones a realizar antes de borrar una legalización de libros.
string _NumeroTomoRegistro
Número de tomo registro.
DateTime? _GetFechaFinLibroAnterior(string tcTipoLibro, string tcNumLibro)
Datos un tipo de libro y un número de libro, devuelve la fecha de cierre del registro anterior para e...
string _TelefonoEmpresario
Teléfono del empresario.
bool _HayMasLibrosTipo(string tcTipoLibro, string tcNumLibro)
Devuelve true si hay declarados libros del tipo de libro recibido como parámetro, con número de libro...
bool _Comprobaciones_CargarDatos_Warning()
Comprobaciones de tipo Warning a realizar antes de permitir cargar datos de empresario,...
int _NumeroLibros
Número de libros declarados en la relación de libros.
TipoImpresion _TipoImpresion
Tipo de impresión para la legalización.
bool _Comprobaciones_ImportarFichero_Warning()
Comprobaciones de tipo Warning a realizar antes de permitir importar datos a partir de un fichero ZIP...
EstadoFirmasLibros _ObtenerEstadoFirmasLibros()
Verificar en que estado de firma se encuentran los ficheros de que consta la legalización.
string _NumeroSeccionRegistro
Número de sección de registro.
string _OtrosRegistroMercantil
Apartado Otros de registro mercantil.
string _Apellido1Presentador
Apellido 1 del presentador.
LegalizacionLibros()
Constructor sin parámetros.
string _Numero
Ejercicio al que corresponde la presentación de los libros.
string _DireccionEmpresario
Dirección del empresario.
string _NumeroFolioRegistro
Número de folio datos registrales.
string _DireccionPresentador
Dirección del presentador.
override void _Show()
Mostrar el formulario de legalización de libros con los datos del objeto de negocio LegalizacionLibro...
string _EmailPresentador
Email del presentador.
_Error_Message_Linea_After_Handler _Error_Message_Linea_After
Evento que se dispara despues de establecer un valor en _Error_Message_Linea.
int _Numero_Copias
Nos indicará el número de copias a imprimir.
Definition DocPrint.cs:652
eFormato_exportacion _Formato_exportacion
Formato de exportación.
Definition DocPrint.cs:713
virtual bool _Vista_Preliminar
Nos indicará si se realizará una vista preliminar del documento.
Definition DocPrint.cs:620
bool _Exportar
Determina si el documento.
Definition DocPrint.cs:728
virtual String _Printer
C106325 Devuelve la impresora configurada.
Definition DocPrint.cs:531
bool _EditMode
Modo de edición.
Definition DocPrint.cs:683
ImpresionNormalMultiple _ImpresionNormalMultiple
Indica el tipo de impresión.
Definition DocPrint.cs:498
virtual bool _PrintNET()
PE-86889 Método para realizar la impresión de un documento mediante Sage Reports.
Definition DocPrint.cs:982
IDocumentoImprimible _Documento
Referéncia al documento.
Definition DocPrint.cs:417
DocPrint()
Constructor.
Definition DocPrint.cs:2019
string _Ruta_Fichero
Nos indicará la ruta donde nos guardará el fichero del documento en formato PDF.
Definition DocPrint.cs:667
bool _FieldRandomBackColor
Propiedad _FieldRandomBackColor.
Definition DocPrint.cs:698
virtual UserControl _UserControlAdicional
Opiones de impresión.
Definition DocPrint.cs:575
Definición de atributos para el report.
dynamic detalleDocumento
Detalle del documneto.
bool _EnUso
Si el documento esta en uso.
IDocPrint _oDocPrint
IDocPrint.
DocumentoBase()
Constructor vacío.
Formulario base de documentos de stock y de asientos contables.
Boolean _FieldRandomBackColor
Establece en el modo edición, si pondrá color al fondo de los campos.
DocPrint.eFormato_exportacion _FormatoExportacion
DEvuelve el tipo de exportación.
override void _ShowDialog()
PE92638 Fa el ShowDialog però abans comprova l'accès al formulari.
Boolean _VistaPreliminar
Indica si la acción es de preview.
bool _Exportar
Indica si la acción es de exportación.
Presenta un datagridview con botones añadir y borrar tipo Mantegrid de Eurowin.
Definition Mantegrid.cs:31
Clase del objeto grid para Sage50.
Definition grid.cs:34
Interfaz de acceso datos para la clase LegalizacionLibros.
string SQLString(object txValor, int tnLongitud=0, char tcRelleno=' ', bool tlIzquierda=false)
Devuelve string para consulta.
Interfaz para la definición de las claves para tablas relacionadas.
Definition IClaves.cs:12
Definición de la interfície necesaria para las páginas(tabPage) a utilizar en formularios de tipo For...
Definition IDocPrint.cs:17
Definición de la interficie que deben cumplir los documentos de cualquier tipo para poder interactuar...
Definition IDocPrint.cs:377
Interfaz para objetos línea.
Definition ILinTRel.cs:12
string _Codigo
Campo de la tabla que representa el "Código" del mantenimiento. Por defecto siempre es CODIGO.
Definition IMantes.cs:24
string _Tabla
Nombre de la tabla que navegamos.
Definition IMantes.cs:64
string _Pantalla
Nombre clave del formulario.
Definition IMantes.cs:59
_TiposAccesosPantalla
Tipos de accesos a las pantallas.
Definition clsFormul.cs:341
@ Denegado
No se permite el acceso.
Definition clsFormul.cs:345