frmRegFactVerifactu.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.IO;
8 using System.Windows.Forms;
9 using sage.ew.objetos;
10 using sage.ew.global;
11 using sage.ew.ewbase;
12 using sage.ew.txtbox;
13 using sage.ew.cliente;
14 using sage.ew.formul.Forms;
16 using sage.ew.functions;
18 using sage.ew.db;
20 using sage.ew.perfiles.Forms;
21 using sage.ew.contabilidad;
22 using Sage.ES.S50.Modelos.Forms;
23 using sage.ew.docsven.Forms;
24 using System.Runtime.Remoting.Messaging;
25 using sage.ew.docsven;
26 using sage.ew.docventatpv;
28 using DocumentFormat.OpenXml.Office2010.ExcelAc;
29 using DevExpress.Xpo.DB;
30 
31 
32 namespace sage.addons.factucert.Visual.Forms
33 {
37  public partial class frmRegFactVerifactu : FormSalir
38  {
39  #region ENUMERACIONES
40 
41 
45  private enum EstadoEnvio
46  {
50  [Description("Todos")]
51  Todos = 0,
55  [Description("Enviados")]
56  Enviados,
60  [Description("Pendientes")]
62  }
63 
64 
68  private enum EstadoAdministracion
69  {
73  [Description("Pendiente")]
74  Pendiente = 0,
78  [Description("Aceptada")]
79  Aceptada,
83  [Description("Aceptada con errores")]
84  AceptadaConErrores,
88  [Description("Rechazada")]
89  Rechazada
90  }
91 
92 
93  #endregion ENUMERACIONES
94 
95 
96  #region PROPIEDADES PRIVADAS
97 
105  private string _cRutaRaizFicherosXml = string.Empty;
106 
107 
111  private ewMascara _oMascaraImporte = new ewMascara(KeyDiccionarioMascara.wc_grantotal);
112 
113 
117  private string _lcAny = Convert.ToString(EW_GLOBAL._GetVariable("wc_any"));
118 
119 
123  private string _cMonedaEmpresa = Convert.ToString(EW_GLOBAL._GetVariable("wc_moneda"));
124 
125 
129  private string _cEmpresa = Convert.ToString(EW_GLOBAL._GetVariable("wc_empresa"));
130 
131 
135  private bool _lEjerPartido = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_parti"));
136 
137 
141  private bool _llSerFact = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_serfact"));
142 
143 
147  private DateTime _dPeriodoIni = Convert.ToDateTime(EW_GLOBAL._GetVariable("wd_periodoini"));
148 
149 
153  private DateTime _dPeriodoFin = Convert.ToDateTime(EW_GLOBAL._GetVariable("wd_periodofin"));
154 
155 
159  private bool _lEmpresaNormal = Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_normal"));
160 
161 
162  #endregion PROPIEDADES PRIVADAS
163 
164 
165  #region PROPIEDADES PÚBLICAS
166 
167 
171  public bool _MostrarDatosAlEntrar { get; set; } = false;
172 
173 
174  #endregion PROPIEDADES PÚBLICAS
175 
176 
177  #region CONSTRUCTOR
178 
179 
183  public frmRegFactVerifactu() : base()
184  {
185  InitializeComponent();
186 
187  if (!this.DesignMode)
188  {
189  this.constructorVarios();
190 
191  this.programarEventos();
192  }
193 
194  return;
195  }
196 
197 
201  private void constructorVarios()
202  {
203  this._MostrarAccesoFavoritos = false;
204  this._MostrarCrearTareaProgramada = false;
205  this._MostrarGestionAccesos = true;
206  this._MostrarCrearAccesoDirecto = false;
207  this._Pantalla = "REGFACTVERIFACTU";
208 
209  this.btRefrescar.Image = sage.ew.images.Properties.Resources.refresh;
210  this.btRefrescar.ImageAlign = ContentAlignment.MiddleLeft;
211 
213  this.btImprimir.ImageAlign = ContentAlignment.MiddleLeft;
214 
215  this.dtFechaDesde.Value = this._dPeriodoIni;
216  this.dtFechaHasta.Value = this._dPeriodoFin;
217 
218  // Para que al acceder al browser no salga preseleccionado en el filtro el valor que hay declarado en el txtPeriodo
219  //
220  this.txtPeriodo._PermitirFiltradoAutomaticoTextoParcial = false;
221 
222  this.ewEmpresa.Text = Convert.ToString(EW_GLOBAL._GetVariable("wc_empnombre1"));
223  this.ewEjercicio.Text = this._lcAny;
224 
225  string lcRutaRaizFicherosXML = System.IO.Path.Combine(EW_GLOBAL._GetVariable("wc_IniServidor").ToString().Trim(), "MODULOS");
226  lcRutaRaizFicherosXML = System.IO.Path.Combine(lcRutaRaizFicherosXML, FACTUCERT._NombreAddOn);
227  lcRutaRaizFicherosXML = System.IO.Path.Combine(lcRutaRaizFicherosXML, ew.ewbase.GrupoEmpresa._CodigoGrupoActual().ToString().Trim());
228  lcRutaRaizFicherosXML = System.IO.Path.Combine(lcRutaRaizFicherosXML, EW_GLOBAL._GetVariable("wc_empresa").ToString().Trim());
229  lcRutaRaizFicherosXML = System.IO.Path.Combine(lcRutaRaizFicherosXML, EW_GLOBAL._GetVariable("wc_any").ToString().Trim());
230 
231  this._cRutaRaizFicherosXml = lcRutaRaizFicherosXML;
232 
233  // Montar combo de estados de envío y ponemos valor por defecto "Todos"
234  //
235  this.populateComboEstado(EstadoEnvio.Todos);
236 
237  return;
238  }
239 
240 
244  private void programarEventos()
245  {
246  this.btRefrescar.Click += new System.EventHandler(this.btRefrescar_Click);
247  this.btVerAsiento.Click += new System.EventHandler(this.btVerAsiento_Click);
248  this.btVerDocumento.Click += new System.EventHandler(this.btVerDocumento_Click);
249  this.btVerCliente.Click += new System.EventHandler(this.btVerCliente_Click);
250  this.btVerDatosCertif.Click += new System.EventHandler(this.btVerDatosCertif_Click);
251  this.Shown += new System.EventHandler(this.frmRegFactVerifactu_Shown);
252  this.Load += new System.EventHandler(this.frmRegFactVerifactu_Load);
253 
254  this.txtPeriodo._Codigo_Cambiado += TxtPeriodo__Codigo_Cambiado;
255  this.ewgridDatos.RowPrePaint += EwgridDatos_RowPrePaint;
256  this.ewgridDatos.CellClick += EwgridDatos_CellClick;
257  this.btImprimir._onPrintBefore += BtImprimir__onPrintBefore;
258 
259  return;
260  }
261 
262 
266  private void cancelarEventos()
267  {
268  this.btRefrescar.Click -= new System.EventHandler(this.btRefrescar_Click);
269  this.btVerAsiento.Click -= new System.EventHandler(this.btVerAsiento_Click);
270  this.btVerDocumento.Click -= new System.EventHandler(this.btVerDocumento_Click);
271  this.btVerCliente.Click -= new System.EventHandler(this.btVerCliente_Click);
272  this.btVerDatosCertif.Click -= new System.EventHandler(this.btVerDatosCertif_Click);
273  this.Load -= new System.EventHandler(this.frmRegFactVerifactu_Load);
274  this.Shown -= new System.EventHandler(this.frmRegFactVerifactu_Shown);
275 
276  this.txtPeriodo._Codigo_Cambiado -= TxtPeriodo__Codigo_Cambiado;
277  this.ewgridDatos.RowPrePaint -= EwgridDatos_RowPrePaint;
278  this.ewgridDatos.CellClick -= EwgridDatos_CellClick;
279  this.btImprimir._onPrintBefore -= BtImprimir__onPrintBefore;
280 
281  return;
282  }
283 
284 
285  #endregion CONSTRUCTOR
286 
287 
288  #region MÉTODOS PROTECTED OVERRIDE
289 
290 
295  protected override void OnClosing(CancelEventArgs e)
296  {
297  this.cancelarEventos();
298 
299  if (this.btImprimir != null && this.btImprimir._DataTable != null)
300  {
301  this.btImprimir._DataTable.Clear();
302  this.btImprimir._DataTable = null;
303  this.btImprimir = null;
304  }
305 
306  if (this.ewgridDatos != null && this.ewgridDatos.DataSource != null && this.ewgridDatos.DataSource is DataTable)
307  {
308  DataTable ldtTable = this.ewgridDatos.DataSource as DataTable;
309  ldtTable.Clear();
310  ldtTable = null;
311  }
312 
313  base.OnClosing(e);
314 
315  return;
316  }
317 
318 
319  #endregion MÉTODOS PROTECTED OVERRIDE
320 
321 
322  #region MÉTODO PRIVADOS
323 
324 
329  private void populateComboEstado(object selectedvalue = null)
330  {
331  object selvalue = null;
332  DataTable sourcedatatable = new DataTable();
333  sourcedatatable.Columns.Add("id", typeof(int));
334  sourcedatatable.Columns.Add("nombre", typeof(string));
335 
336  foreach (EstadoEnvio loEstado in Enum.GetValues(typeof(EstadoEnvio)))
337  {
338  sourcedatatable.Rows.Add((int)loEstado, FUNCTIONS._GetEnumDescription((Enum)loEstado));
339  if (loEstado.Equals(selectedvalue))
340  selvalue = loEstado;
341  }
342 
343  this.cmbMostrarRegistros.DataSource = sourcedatatable;
344  this.cmbMostrarRegistros.ValueMember = "id";
345  this.cmbMostrarRegistros.DisplayMember = "nombre";
346 
347  if (selvalue != null)
348  this.cmbMostrarRegistros.SelectedValue = selvalue;
349 
350  return;
351  }
352 
353 
359  private void btVerAsiento_Click(object sender, EventArgs e)
360  {
361  if (this.ewgridDatos.CurrentCell.RowIndex < 0)
362  return;
363 
364  DataRow loRow = ((DataRowView)ewgridDatos.Rows[this.ewgridDatos.CurrentCell.RowIndex].DataBoundItem).Row;
365 
366  int lnTipoReg = Convert.ToInt32(loRow["idtiporeg"]);
367 
368  if (lnTipoReg >= 0 && lnTipoReg <= 3)
369  {
370  string lcEmpresa = loRow["empresa"].ToString();
371  string lcFactura = loRow["numero"].ToString();
372 
373  if (string.IsNullOrWhiteSpace(lcEmpresa) || string.IsNullOrWhiteSpace(lcFactura))
374  {
375  FUNCTIONS._MessageBox("No se ha detectado el nº de la factura.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
376  return;
377  }
378 
379  using (ewDocVentaFRA loFra = new ewDocVentaFRA())
380  {
381  loFra._Load(lcEmpresa, lcFactura);
382  string lcAsi = loFra._Asi;
383 
384  if (!string.IsNullOrWhiteSpace(lcAsi))
385  {
386  using (Asientos loAsiento = new Asientos(lcAsi))
387  {
388  loAsiento._Show();
389  }
390  }
391  else
392  {
393  FUNCTIONS._MessageBox("No se ha detectado el asiento de la factura.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
394  }
395  }
396  }
397 
398  return;
399  }
400 
401 
407  private void btVerDocumento_Click(object sender, EventArgs e)
408  {
409  if (this.ewgridDatos.CurrentCell.RowIndex < 0)
410  return;
411 
412  DataRow loRow = ((DataRowView)ewgridDatos.Rows[this.ewgridDatos.CurrentCell.RowIndex].DataBoundItem).Row;
413 
414  int lnTipoReg = Convert.ToInt32(loRow["idtiporeg"]);
415 
416  if (lnTipoReg >= 0 && lnTipoReg <= 3)
417  {
418  string lcEmpresa = loRow["empresa"].ToString();
419  string lcFactura = loRow["numero"].ToString();
420  using (PrevisionCobro loFactura = new PrevisionCobro())
421  {
422  loFactura._Empresa = lcEmpresa;
423  loFactura._Factura = lcFactura;
424  loFactura._Show_Factura();
425  }
426  return;
427  }
428  else if (EW_GLOBAL._ModuloActivo("TPV") && lnTipoReg >= 4 && lnTipoReg <= 7)
429  {
430  string lcEmpresa = loRow["empresa"].ToString();
431  string lcNumero = loRow["numero"].ToString();
432  string lcLetra = loRow["letra"].ToString();
433 
434  ewDocVentaTPV loDoc = new ewDocVentaTPV();
435  loDoc._Load(lcEmpresa, lcNumero, lcLetra);
436  loDoc._Show();
437 
438  // Otra forma de hacer la llamada.
439  //
440  //frmDocVentaTpv loForm;
444  // loForm = new frmDocVentaAlbaran();
445 
446  //loForm._Mantener_Ejecucion = true;
447  //loForm._Documento._Load(lcEmpresa, lcNumero, lcLetra);
448  //loForm._ShowDialog();
449  }
450 
451  return;
452  }
453 
454 
460  private void btVerCliente_Click(object sender, EventArgs e)
461  {
462  if (this.ewgridDatos.CurrentCell.RowIndex < 0)
463  return;
464 
465  string lcCodigo = this.ewgridDatos.Rows[this.ewgridDatos.CurrentCell.RowIndex].Cells["Cliente"].Value.ToString();
466 
467  Cliente loCliente = new Cliente();
468  loCliente._Codigo = lcCodigo;
469  loCliente._Show();
470 
471  return;
472  }
473 
474 
480  private void btVerDatosCertif_Click(object sender, EventArgs e)
481  {
482  if (this.ewgridDatos.CurrentCell.RowIndex < 0)
483  return;
484 
485  DataRow loRow = ((DataRowView)ewgridDatos.Rows[this.ewgridDatos.CurrentCell.RowIndex].DataBoundItem).Row;
486 
487  int lnTipoReg = Convert.ToInt32(loRow["idtiporeg"]);
488  string lcEmpresa = Convert.ToString(loRow["empresa"]);
489 
490  if (lnTipoReg >= 0 && lnTipoReg <= 3)
491  {
492  string lcFactura = loRow["numero"].ToString();
493 
494  if (string.IsNullOrWhiteSpace(lcEmpresa) || string.IsNullOrWhiteSpace(lcFactura))
495  {
496  FUNCTIONS._MessageBox("No se ha detectado el nº de la factura.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
497  return;
498  }
499 
500  using (ewDocVentaFRA loDocFra = new ewDocVentaFRA())
501  {
502  if (loDocFra._Load(lcEmpresa, lcFactura))
503  {
504  btOpcionesFacturaTicket lobtOpcionesFacturaTicket = new btOpcionesFacturaTicket();
505  lobtOpcionesFacturaTicket._Documento = loDocFra;
506  lobtOpcionesFacturaTicket._ShowDatosCertificacion();
507  }
508  else
509  {
510  FUNCTIONS._MessageBox("No se ha podido cargar la factura.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
511  }
512  }
513  return;
514  }
515  else if (EW_GLOBAL._ModuloActivo("TPV") && lnTipoReg >= 4 && lnTipoReg <= 7)
516  {
517  using (ewDocVentaTPV loDocTicket = new ewDocVentaTPV())
518  {
519  string lcNumero = loRow["numero"].ToString();
520  string lcLetra = loRow["letra"].ToString();
521 
522  if (string.IsNullOrWhiteSpace(lcEmpresa) || string.IsNullOrWhiteSpace(lcNumero))
523  {
524  FUNCTIONS._MessageBox("No se ha detectado el nº del ticket.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
525  return;
526  }
527 
528  if (loDocTicket._Load(lcEmpresa, lcNumero, lcLetra))
529  {
530  btOpcionesFacturaTicket lobtOpcionesFacturaTicket = new btOpcionesFacturaTicket();
531  lobtOpcionesFacturaTicket._Documento = loDocTicket;
532  lobtOpcionesFacturaTicket._ShowDatosCertificacion();
533  }
534  else
535  {
536  FUNCTIONS._MessageBox("No se ha podido cargar el ticket.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
537  }
538  }
539  }
540 
541  return;
542  }
543 
544 
550  private void frmRegFactVerifactu_Load(object sender, EventArgs e)
551  {
552  this.configurarGrid();
553 
554  return;
555  }
556 
557 
563  private void frmRegFactVerifactu_Shown(object sender, EventArgs e)
564  {
565  if (this._MostrarDatosAlEntrar)
566  this.obtenerDatos();
567 
568  btRefrescar.Image = sage.ew.images.Properties.Resources.refresh;
569  btRefrescar.ImageAlign = ContentAlignment.MiddleLeft;
570 
571  btImprimir.Top = btVerAsiento.Top;
572  btImprimir.Left = ewgridDatos.Left;
573  btImprimir.Height = btVerAsiento.Height;
575 
576  btSalir1.Top = btVerAsiento.Top;
577  btSalir1.Height = btVerAsiento.Height;
578 
579  return;
580  }
581 
582 
586  private void configurarGrid()
587  {
588  this.ewgridDatos.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
589  this.ewgridDatos.ReadOnly = true;
590 
591  this.ewgridDatos.AutoGenerateColumns = false;
592  this.ewgridDatos.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
593  this.ewgridDatos.AllowUserToAddRows = false;
594  this.ewgridDatos.AllowUserToDeleteRows = false;
595  this.ewgridDatos.Columns.Clear();
596 
598  //ldgtbColSel.DataPropertyName = "_Sel";
599  //ldgtbColSel.Name = "_Sel";
600  //ldgtbColSel.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
601  //ldgtbColSel.HeaderText = "Sel";
602  //ldgtbColSel.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
603  //ldgtbColSel.ValueType = typeof(Boolean);
604  //ldgtbColSel.Visible = true;
605  //ldgtbColSel._NoParar = true;
606  //ldgtbColSel.ReadOnly = false;
607  //ldgtbColSel.DisplayIndex = 0;
608  //ldgtbColSel.Width = 51;
609  //ldgtbColSel._SelectionColumn = true;
610  //ldgtbColSel.Frozen = true;
611  //this.ewgridDatos.Columns.Add(ldgtbColSel);
612 
614  ldgtbColEstado.Name = "Estado";
615  ldgtbColEstado.DataPropertyName = "Estado";
616  ldgtbColEstado.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
617  ldgtbColEstado.HeaderText = "Estado";
618  ldgtbColEstado.ValueType = typeof(string);
619  ldgtbColEstado.Visible = true;
620  ldgtbColEstado._NoParar = false;
621  ldgtbColEstado.ReadOnly = true;
622  ldgtbColEstado.Width = 85;
623  this.ewgridDatos.Columns.Add(ldgtbColEstado);
624 
626  ldgtbColEstadoAdm.Name = "Estadoadm";
627  ldgtbColEstadoAdm.DataPropertyName = "Estadoadm";
628  ldgtbColEstadoAdm.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
629  ldgtbColEstadoAdm.HeaderText = "Estado administr.";
630  ldgtbColEstadoAdm.ValueType = typeof(string);
631  ldgtbColEstadoAdm.Visible = true;
632  ldgtbColEstadoAdm._NoParar = false;
633  ldgtbColEstadoAdm.ReadOnly = true;
634  ldgtbColEstadoAdm.Width = 140;
635  this.ewgridDatos.Columns.Add(ldgtbColEstadoAdm);
636 
638  ldgtbColIncidencia.Name = "Incidencia";
639  ldgtbColIncidencia.DataPropertyName = "Incidencia";
640  ldgtbColIncidencia.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
641  ldgtbColIncidencia.HeaderText = "Incidencia";
642  ldgtbColIncidencia.ValueType = typeof(string);
643  ldgtbColIncidencia.Visible = true;
644  ldgtbColIncidencia._NoParar = false;
645  ldgtbColIncidencia.ReadOnly = true;
646  ldgtbColIncidencia.Width = 160;
647  this.ewgridDatos.Columns.Add(ldgtbColIncidencia);
648 
650  ldgtbColTipoReg.Name = "Tiporeg";
651  ldgtbColTipoReg.DataPropertyName = "Tiporeg";
652  ldgtbColTipoReg.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
653  ldgtbColTipoReg.HeaderText = "Tipo registro";
654  ldgtbColTipoReg.ValueType = typeof(string);
655  ldgtbColTipoReg.Visible = true;
656  ldgtbColTipoReg._NoParar = false;
657  ldgtbColTipoReg.ReadOnly = true;
658  ldgtbColTipoReg.Width = 110;
659  this.ewgridDatos.Columns.Add(ldgtbColTipoReg);
660 
662  ldgtbColNumero.Name = "Numero";
663  ldgtbColNumero.DataPropertyName = "Letranumero";
664  ldgtbColNumero.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
665  ldgtbColNumero.HeaderText = "Número";
666  ldgtbColNumero.ValueType = typeof(string);
667  ldgtbColNumero.Visible = true;
668  ldgtbColNumero._NoParar = false;
669  ldgtbColNumero.ReadOnly = true;
670  ldgtbColNumero.Width = 85;
671  this.ewgridDatos.Columns.Add(ldgtbColNumero);
672 
674  ldgtbColFraExp.Name = "Numfraexp";
675  ldgtbColFraExp.DataPropertyName = "numfraexp";
676  ldgtbColFraExp.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
677  ldgtbColFraExp.HeaderText = "Nº factura exped.";
678  ldgtbColFraExp.ValueType = typeof(string);
679  ldgtbColFraExp.Visible = true;
680  ldgtbColFraExp._NoParar = false;
681  ldgtbColFraExp.ReadOnly = true;
682  ldgtbColFraExp.Width = 140;
683  this.ewgridDatos.Columns.Add(ldgtbColFraExp);
684 
686  ldgtbColTerminal.Name = "Terminal";
687  ldgtbColTerminal.DataPropertyName = "Terminal";
688  ldgtbColTerminal.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
689  ldgtbColTerminal.HeaderText = "Terminal";
690  ldgtbColTerminal.ValueType = typeof(string);
691  ldgtbColTerminal.Visible = true;
692  ldgtbColTerminal._NoParar = false;
693  ldgtbColTerminal.ReadOnly = true;
694  ldgtbColTerminal.Width = 150;
695  this.ewgridDatos.Columns.Add(ldgtbColTerminal);
696 
698  ldgtbColFechaReg.Name = "Fecha";
699  ldgtbColFechaReg.DataPropertyName = "Fecha";
700  ldgtbColFechaReg.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
701  ldgtbColFechaReg.HeaderText = "Fecha";
702  ldgtbColFechaReg.ValueType = typeof(string);
703  ldgtbColFechaReg.Visible = true;
704  ldgtbColFechaReg._NoParar = false;
705  ldgtbColFechaReg.ReadOnly = true;
706  ldgtbColFechaReg.Width = 80;
707  this.ewgridDatos.Columns.Add(ldgtbColFechaReg);
708 
710  ldgtbColHora.Name = "Hora";
711  ldgtbColHora.DataPropertyName = "Hora";
712  ldgtbColHora.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
713  ldgtbColHora.HeaderText = "Hora";
714  ldgtbColHora.ValueType = typeof(string);
715  ldgtbColHora.Visible = true;
716  ldgtbColHora._NoParar = false;
717  ldgtbColHora.ReadOnly = true;
718  ldgtbColHora.Width = 75;
719  this.ewgridDatos.Columns.Add(ldgtbColHora);
720 
722  ldgtbColCodigo.Name = "Cliente";
723  ldgtbColCodigo.DataPropertyName = "Cliente";
724  ldgtbColCodigo.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
725  ldgtbColCodigo.HeaderText = "Cliente";
726  ldgtbColCodigo.ValueType = typeof(string);
727  ldgtbColCodigo.Visible = true;
728  ldgtbColCodigo._NoParar = false;
729  ldgtbColCodigo.ReadOnly = true;
730  ldgtbColCodigo.Width = 85;
731  this.ewgridDatos.Columns.Add(ldgtbColCodigo);
732 
734  ldgtbColNombre.Name = "Nombre";
735  ldgtbColNombre.DataPropertyName = "Nombre";
736  ldgtbColNombre.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
737  ldgtbColNombre.HeaderText = "Nombre";
738  ldgtbColNombre.ValueType = typeof(string);
739  ldgtbColNombre.Visible = true;
740  ldgtbColNombre._NoParar = false;
741  ldgtbColNombre.ReadOnly = true;
742  ldgtbColNombre.Width = 300;
743  this.ewgridDatos.Columns.Add(ldgtbColNombre);
744 
746  ldgtbColImporte.Name = "Totaldoc";
747  ldgtbColImporte.DataPropertyName = "Totaldoc";
748  ldgtbColImporte.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
749  ldgtbColImporte.HeaderText = "Importe";
750  ldgtbColImporte.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
751  ldgtbColImporte.ValueType = typeof(decimal);
752  ldgtbColImporte.Visible = true;
753  ldgtbColImporte._NoParar = false;
754  ldgtbColImporte.ReadOnly = true;
755  ldgtbColImporte.Width = 100;
756  ldgtbColImporte.DefaultCellStyle.Format = this._oMascaraImporte._Mascara_Net;
757  ldgtbColImporte.DecimalPlaces = this._oMascaraImporte._Num_Decimales;
758  ldgtbColImporte.Maximum = this._oMascaraImporte._Rango_Max;
759  ldgtbColImporte.Minimum = this._oMascaraImporte._Rango_Min;
760  ldgtbColImporte.Increment = 1;
761  ldgtbColImporte.ThousandsSeparator = false;
762  this.ewgridDatos.Columns.Add(ldgtbColImporte);
763 
765  ldgtbColSimbDivisa.Name = "Divisa";
766  ldgtbColSimbDivisa.DataPropertyName = "Montexto";
767  ldgtbColSimbDivisa.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
768  ldgtbColSimbDivisa.HeaderText = "Divisa";
769  ldgtbColSimbDivisa.ValueType = typeof(string);
770  ldgtbColSimbDivisa.Visible = true;
771  ldgtbColSimbDivisa._NoParar = false;
772  ldgtbColSimbDivisa.ReadOnly = true;
773  ldgtbColSimbDivisa.Width = 70;
774  this.ewgridDatos.Columns.Add(ldgtbColSimbDivisa);
775 
777  ldgtbColImporteDiv.Name = "Totaldiv";
778  ldgtbColImporteDiv.DataPropertyName = "Totaldiv";
779  ldgtbColImporteDiv.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
780  ldgtbColImporteDiv.HeaderText = "Importe divisa";
781  ldgtbColImporteDiv.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
782  ldgtbColImporteDiv.ValueType = typeof(decimal);
783  ldgtbColImporteDiv.Visible = true;
784  ldgtbColImporteDiv._NoParar = false;
785  ldgtbColImporteDiv.ReadOnly = true;
786  ldgtbColImporteDiv.Width = 120;
787  ldgtbColImporteDiv.DefaultCellStyle.Format = this._oMascaraImporte._Mascara_Net;
788  ldgtbColImporteDiv.DecimalPlaces = this._oMascaraImporte._Num_Decimales;
789  ldgtbColImporteDiv.Maximum = this._oMascaraImporte._Rango_Max;
790  ldgtbColImporteDiv.Minimum = this._oMascaraImporte._Rango_Min;
791  ldgtbColImporteDiv.Increment = 1;
792  ldgtbColImporteDiv.ThousandsSeparator = false;
793  this.ewgridDatos.Columns.Add(ldgtbColImporteDiv);
794 
795 
797  ldgtbColXmlEnvioString.Name = "XmlEnvioString";
798  ldgtbColXmlEnvioString.DataPropertyName = "Xmlenvio";
799  ldgtbColXmlEnvioString.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
800  ldgtbColXmlEnvioString.HeaderText = "Xml envío";
801  ldgtbColXmlEnvioString.ValueType = typeof(string);
802  ldgtbColXmlEnvioString.Visible = true;
803  ldgtbColXmlEnvioString._NoParar = false;
804  ldgtbColXmlEnvioString.ReadOnly = true;
805  ldgtbColXmlEnvioString.Width = 100;
806  ldgtbColXmlEnvioString.Visible = false;
807  this.ewgridDatos.Columns.Add(ldgtbColXmlEnvioString);
808 
810  ldgtbColXmlEnvioImagen.Name = "XmlEnvioImg";
811  ldgtbColXmlEnvioImagen.HeaderText = "XML envio reg.";
812  ldgtbColXmlEnvioImagen.ValueType = typeof(ew.objetos.ewbutton);
813  ldgtbColXmlEnvioImagen.Width = 125;
814  ldgtbColXmlEnvioImagen.Visible = true;
815  ldgtbColXmlEnvioImagen._NoParar = false;
816  ldgtbColXmlEnvioImagen.ReadOnly = false;
817  ldgtbColXmlEnvioImagen.DefaultCellStyle.NullValue = null; // Si no hay imagen no debe de presentar el cuadrado de que no tenemos imagen
818  this.ewgridDatos.Columns.Add(ldgtbColXmlEnvioImagen);
819 
821  ldgtbColXmlRespString.Name = "XmlRespString";
822  ldgtbColXmlRespString.DataPropertyName = "Xmlresp";
823  ldgtbColXmlRespString.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
824  ldgtbColXmlRespString.HeaderText = "Xml resp.";
825  ldgtbColXmlRespString.ValueType = typeof(string);
826  ldgtbColXmlRespString.Visible = true;
827  ldgtbColXmlRespString._NoParar = false;
828  ldgtbColXmlRespString.ReadOnly = true;
829  ldgtbColXmlRespString.Width = 100;
830  ldgtbColXmlRespString.Visible = false;
831  this.ewgridDatos.Columns.Add(ldgtbColXmlRespString);
832 
834  ldgtbColResp.Name = "XmlRespImg";
835  ldgtbColResp.HeaderText = "Xml resp.";
836  ldgtbColResp.ValueType = typeof(ew.objetos.ewbutton);
837  ldgtbColResp.Width = 90;
838  ldgtbColResp.Visible = true;
839  ldgtbColResp._NoParar = false;
840  ldgtbColResp.ReadOnly = false;
841  ldgtbColResp.DefaultCellStyle.NullValue = null; // Si no hay imagen no debe de presentar el cuadrado de que no tenemos imagen
842  this.ewgridDatos.Columns.Add(ldgtbColResp);
843 
845  ldgtbColCsvResp.Name = "Csv";
846  ldgtbColCsvResp.DataPropertyName = "Csv";
847  ldgtbColCsvResp.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
848  ldgtbColCsvResp.HeaderText = "CSV respuesta";
849  ldgtbColCsvResp.ValueType = typeof(string);
850  ldgtbColCsvResp.Visible = true;
851  ldgtbColCsvResp._NoParar = false;
852  ldgtbColCsvResp.ReadOnly = true;
853  ldgtbColCsvResp.Width = 150;
854  this.ewgridDatos.Columns.Add(ldgtbColCsvResp);
855 
856  this.ewgridDatos._FiltrarPorColumna = true;
857 
858  return;
859  }
860 
861 
868  private void EwgridDatos_CellClick(object sender, DataGridViewCellEventArgs e)
869  {
870  string lcFicheroXml = string.Empty;
871 
872  if (this.ewgridDatos.CurrentCell.ColumnIndex == this.ewgridDatos.Columns["XmlEnvioImg"].Index ||
873  this.ewgridDatos.CurrentCell.ColumnIndex == this.ewgridDatos.Columns["XmlRespImg"].Index)
874  {
875  // El fichero no lleva ruta, solo el nombre del fichero.
876  // Si es el fichero generado se guardará en la carpeta
877  // \sage50cserv\MODULOS\factucert\Código Grupo\Código Empresa\Ejercicio\C_E
878  //
879  // Si es el fichero de respuesta se guardará en la carpeta
880  // \sage50cserv\MODULOS\factucert\Código Grupo\Código Empresa\Ejercicio\C_E\Respuesta
881  //
882  if (this.ewgridDatos.CurrentCell.ColumnIndex == this.ewgridDatos.Columns["XmlEnvioImg"].Index)
883  {
884  lcFicheroXml = this._cRutaRaizFicherosXml + @"\C_E\" + this.ewgridDatos.Rows[this.ewgridDatos.CurrentCell.RowIndex].Cells["XmlEnvioString"].Value.ToString();
885  }
886  else if (this.ewgridDatos.CurrentCell.ColumnIndex == this.ewgridDatos.Columns["XmlRespImg"].Index)
887  {
888  lcFicheroXml = this._cRutaRaizFicherosXml + @"\C_E\Respuesta\" + this.ewgridDatos.Rows[this.ewgridDatos.CurrentCell.RowIndex].Cells["XmlRespString"].Value.ToString();
889  }
890 
891  if (!string.IsNullOrWhiteSpace(lcFicheroXml))
892  {
893  if (File.Exists(lcFicheroXml))
894  {
895  string lcTitulo = string.Empty;
896  if (this.ewgridDatos.CurrentCell.ColumnIndex == this.ewgridDatos.Columns["XmlEnvioImg"].Index)
897  lcTitulo = "Fichero XML envío";
898  else if (this.ewgridDatos.CurrentCell.ColumnIndex == this.ewgridDatos.Columns["XmlRespImg"].Index)
899  lcTitulo = "Fichero XML respuesta";
900 
901  lcTitulo += " - " + lcFicheroXml;
902 
903  FormXMLRespuesta loForm = new FormXMLRespuesta();
904  loForm._TextoBotonCancelar = "&Salir";
905  loForm._Titulo = lcTitulo;
906  loForm._FicheroXML = lcFicheroXml;
907  loForm._ShowDialog();
908  }
909  else
910  {
911  FUNCTIONS._MessageBox("No se ha encontrado el fichero XML "+lcFicheroXml, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, DialogResult.None);
912  }
913  }
914  }
915 
916  return;
917  }
918 
919 
926  private bool BtImprimir__onPrintBefore(ref DataTable toDt, ew.reports.Report.ReportAction toAction)
927  {
928  string lcForeColorDefault = FUNCTIONS.Color_To_Rgb(Color.Black);
929  int lnNumColumnas = toDt.Columns.Count;
930 
931  for (int ln_i = 0; ln_i < lnNumColumnas; ln_i++)
932  {
933  DataColumn loColumn = toDt.Columns[ln_i];
934 
935  // Solo añado columnas de color a las columnas que no sean de color.
936  //
937  if (!loColumn.ColumnName.EndsWith("_forecolor"))
938  {
939  // He de verificar que la columna de color respectiva no esté ya añadida de una anterior ejecución en la misma sesión.
940  //
941  if (!toDt.Columns.Contains(loColumn.ColumnName + "_forecolor"))
942  {
943  DataColumn loColumnData = new DataColumn(loColumn.ColumnName + "_forecolor", typeof(string));
944  loColumnData.DefaultValue = lcForeColorDefault;
945  toDt.Columns.Add(loColumnData);
946  }
947  }
948  }
949 
950  foreach (DataRow loRow in toDt.Rows)
951  {
952  EstadoAdministracion eEstadoAdm = (EstadoAdministracion)Enum.Parse(typeof(EstadoAdministracion), Convert.ToString(Convert.ToInt32(loRow["idestadoadm"])));
953  switch (eEstadoAdm)
954  {
955  case EstadoAdministracion.Pendiente:
956  // Fila pintada con color negro, color por defecto.
957  break;
958  case EstadoAdministracion.Aceptada:
959  this.ponerFilaDataTableColor(loRow, ShapeLeyendaAceptadas.BackColor);
960  break;
961  case EstadoAdministracion.AceptadaConErrores:
962  this.ponerFilaDataTableColor(loRow, ShapeLeyendaAceptErrores.BackColor);
963  break;
964  case EstadoAdministracion.Rechazada:
965  this.ponerFilaDataTableColor(loRow, ShapeLeyendaRechazadas.BackColor);
966  break;
967  }
968  }
969 
970  return true;
971  }
972 
973 
979  private void ponerFilaDataTableColor(DataRow toRow, Color toColor)
980  {
981  foreach (DataColumn loColumn in toRow.Table.Columns)
982  {
983  if (loColumn.ColumnName.EndsWith("_forecolor"))
984  toRow[loColumn.ColumnName] = FUNCTIONS.Color_To_Rgb(toColor);
985  }
986 
987  return;
988  }
989 
990 
994  private void obtenerDatos()
995  {
996  DataTable ldtRegistros = new DataTable();
997  string lcSqlFacturas = string.Empty, lcSqlTickets = string.Empty, lcSql = string.Empty;
998  string lcParametroEmpresa = string.Empty, lcParametroEjercicio = string.Empty, lcParametroFechas = string.Empty, lcParametroEstado = string.Empty;
999 
1000  DateTime dFechaIni = this.dtFechaDesde.Value, dFechaFin = this.dtFechaHasta.Value;
1001  EstadoEnvio estadoEnv = (EstadoEnvio)this.cmbMostrarRegistros.SelectedIndex;
1002 
1003  // Parámetros para la consulta SQL.
1004  //
1005  List<DB.QueryParams> parametros = new List<DB.QueryParams>();
1006 
1007 
1008  // Parametrización empresa.
1009  //
1010  if (this._lEmpresaNormal)
1011  {
1012  // Empresa normal.
1013  //
1014  parametros.Add(new DB.QueryParams("@empresa", this._cEmpresa, SqlDbType.Char));
1015  lcParametroEmpresa = "ev.empresa = @empresa";
1016  }
1017  else
1018  {
1019  // Empresa consolidada.
1020  //
1021  string[] l_wa_Consolida = (string[])EW_GLOBAL._GetVariable("wa_consolid"); // Array d'empreses consolidades
1022  lcParametroEmpresa = "(";
1023  for (int ln = 0; ln < l_wa_Consolida.Length; ln++)
1024  {
1025  parametros.Add(new DB.QueryParams("@empresaparam" + ln.ToString().Trim(), l_wa_Consolida[ln], SqlDbType.Char));
1026  lcParametroEmpresa += "ev.empresa = @empresaparam" + ln.ToString().Trim()+" or ";
1027  }
1028  lcParametroEmpresa += ")";
1029  }
1030 
1031  // Parametrización ejercicio.
1032  //
1033  parametros.Add(new DB.QueryParams("@ejercicio", this._lcAny, SqlDbType.Char));
1034  lcParametroEjercicio = "ev.ejercicio = @ejercicio";
1035 
1036  // Parametrización fechas.
1037  //
1038  // Ojo con los campos DateTime por que ahora como utilizamos parámetros SQL para filtrar las consultas, hay que tener en cuenta que si en
1039  // el campo de tipo DateTime hay una hora declarada podría influir en que aparezca una fecha o no, p.e., si hacemos la consulta
1040  // así AND FECHAREG <= @fechafinal y la fecha final es 03/04/2024 por ejemplo, no nos va a traer los registros del día 03/04/2024 por que
1041  // todos los registros en la bd en el campo FECHAREG tienen hora declarada y al filtrar la fecha sin incluir la hora asumirá hora 00:00:00 por
1042  // lo que haría que no nos llegasen los registros cuya fecha sea igual a 03/04/2024. Para solucionar esto, en la consulta SQL se hace un
1043  // cast(fechareg as fecha) para que no tenga en cuenta la hora y solo filtre por la fecha.
1044  //
1045  parametros.Add(new DB.QueryParams("@fechainicial", dFechaIni.ToShortDateString(), SqlDbType.DateTime));
1046  parametros.Add(new DB.QueryParams("@fechafinal", dFechaFin.ToShortDateString(), SqlDbType.DateTime));
1047  lcParametroFechas = "cast(ev.fechareg as date) >= @fechainicial and cast(ev.fechareg as date) <= @fechafinal";
1048 
1049  // Parametrización estado envío (pendientes, enviados, todos).
1050  //
1051  if (estadoEnv != EstadoEnvio.Todos)
1052  {
1053  if (estadoEnv == EstadoEnvio.Enviados)
1054  parametros.Add(new DB.QueryParams("@estado", "1", SqlDbType.Int));
1055  else if (estadoEnv == EstadoEnvio.Pendientes)
1056  parametros.Add(new DB.QueryParams("@estado", "0", SqlDbType.Int));
1057 
1058  lcParametroEstado = " and ev.estado = @estado ";
1059  }
1060 
1061  // Revisar facturas, nos quedamos solo con los registros de facturas (TIPOREG=0,1,2,3)
1062  //
1063  // 0: Factura.
1064  // 1: Factura modificada.
1065  // 2: Factura anulada.
1066  // 3: Factura anulada modificada
1067  //
1068  lcSqlFacturas = $@"Select ev.empresa, ev.estado as idestado,
1069  {cadenaEstado("ev.estado")} as estado,
1070  ev.estadoadm as idestadoadm,
1071  {cadenaEstadoAdm("ev.estadoadm")} as estadoadm,
1072  ev.incidencia,
1073  ev.tiporeg as idtiporeg,
1074  {cadenaTipoReg("ev.tiporeg")} as tiporeg,
1075  ev.numero, ev.letra, ev.numero as letranumero, ev.siiframod as numfraexp, ev.terminal,
1076  ev.fechareg as fechahora,
1077  cast(ev.fechareg as date) as fecha,
1078  substring(cast(cast(ev.fechareg as time) as varchar),1,8) as hora,
1079  ev.codigo_cli as cliente, ev.nombre_cli as nombre,
1080  ev.totaldoc, ev.divisa, ev.totaldiv, ev.xml_ce as xmlenvio, ev.xmlresp, ev.csv, ev.tipoenvio, ev.guid_emp, ev.husohora,
1081  rtrim(ltrim(m.nombre)) + (case when m.simbolo <> '' then ' (' + rtrim(ltrim(m.simbolo)) + ')' else
1082  (case when m.abrev <> '' then ' (' + rtrim(ltrim(m.abrev)) + ')' else '' end) end) as montexto
1083  From {DB.SQLDatabase(FACTUCERT._NombreAddOn, "fcfactuven")} fc
1084  inner join {DB.SQLDatabase(FACTUCERT._NombreAddOn, "estvericer")} ev ON fc.empresa = ev.empresa and fc.ejercicio = ev.ejercicio and fc.numero = ev.numero
1085  inner join {DB.SQLDatabase("gestion", "c_factuven")} a1 ON a1.empresa = fc.empresa and a1.numero = fc.numero and fc.ejercicio = {DB.SQLString(this._lcAny)}
1086  left join {DB.SQLDatabase("gestion", "moneda")} m on ev.divisa = m.codigo
1087  where {lcParametroEmpresa} and
1088  {lcParametroEjercicio} and
1089  ev.tiporeg in (0, 1, 2, 3) and
1090  {lcParametroFechas}
1091  {lcParametroEstado} ";
1092 
1093  if (EW_GLOBAL._ModuloActivo("TPV"))
1094  {
1095  // Revisar tickets, nos quedamos solo con los registros de facturas (TIPOREG=4,5,6,7)
1096  //
1097  // 4: Ticket.
1098  // 5: Ticket modificado.
1099  // 6: Ticket anulado.
1100  // 7: Ticket anulado modificado.
1101  //
1102  lcSqlTickets = $@"Select ev.empresa, ev.estado as idestado,
1103  {cadenaEstado("ev.estado")} as estado,
1104  ev.estadoadm as idestadoadm,
1105  {cadenaEstadoAdm("ev.estadoadm")} as estadoadm,
1106  ev.incidencia,
1107  ev.tiporeg as idtiporeg,
1108  {cadenaTipoReg("ev.tiporeg")} as tiporeg,
1109  ev.numero, ev.letra, ev.letra+ev.numero as letranumero, ev.siiframod as numfraexp, ev.terminal,
1110  ev.fechareg as fechahora,
1111  cast(ev.fechareg as date) as fecha,
1112  substring(cast(cast(ev.fechareg as time) as varchar),1,8) as hora,
1113  ev.codigo_cli as cliente, ev.nombre_cli as nombre,
1114  ev.totaldoc, ev.divisa, ev.totaldiv, ev.xml_ce as xmlenvio, ev.xmlresp, ev.csv, ev.tipoenvio, ev.guid_emp, ev.husohora,
1115  rtrim(ltrim(m.nombre)) + (case when m.simbolo <> '' then ' (' + rtrim(ltrim(m.simbolo)) + ')' else
1116  (case when m.abrev <> '' then ' (' + rtrim(ltrim(m.abrev)) + ')' else '' end) end) as montexto
1117  From {DB.SQLDatabase(FACTUCERT._NombreAddOn, "fctickets")} fc
1118  inner join {DB.SQLDatabase(FACTUCERT._NombreAddOn, "estvericer")} ev ON fc.empresa = ev.empresa and fc.ejercicio = ev.ejercicio and fc.numero = ev.numero and fc.letra = ev.letra
1119  inner join {DB.SQLDatabase("gestion", "c_albven")} a1 ON a1.empresa = fc.empresa and a1.numero = fc.numero and a1.letra=fc.letra and fc.ejercicio = {DB.SQLString(this._lcAny)}
1120  inner join {DB.SQLDatabase("tpv", "c_albven")} a2 ON a2.empresa = fc.empresa and a2.numero = fc.numero and a2.letra=fc.letra and a2.ejercicio=fc.ejercicio and fc.ejercicio = {DB.SQLString(this._lcAny)}
1121  left join {DB.SQLDatabase("gestion", "moneda")} m on ev.divisa = m.codigo
1122  where {lcParametroEmpresa} and
1123  {lcParametroEjercicio} and
1124  ev.tiporeg in (4, 5, 6, 7) and
1125  {lcParametroFechas}
1126  {lcParametroEstado} ";
1127  }
1128 
1129  lcSql = lcSqlFacturas + (!string.IsNullOrWhiteSpace(lcSqlTickets) ? " Union All " + lcSqlTickets : "") +
1130  " Order by tipoenvio, terminal, guid_emp, fechahora, husohora Asc";
1131 
1132  DB.SQLExecParams(lcSql, ref ldtRegistros, parametros);
1133 
1134  this.ewgridDatos.DataSource = ldtRegistros;
1135 
1136  this.revisarIconosFilasGrid();
1137 
1138  this.configurarImpresion(ldtRegistros);
1139 
1140  return;
1141  }
1142 
1143 
1148  private void revisarIconosFilasGrid()
1149  {
1150  foreach (DataGridViewRow ldRow in this.ewgridDatos.Rows)
1151  {
1152  if (!string.IsNullOrWhiteSpace(Convert.ToString(ldRow.Cells["XmlEnvioString"].Value)))
1153  {
1154  ldRow.Cells["XmlEnvioImg"].Value = ew.images.Properties.Resources.icon_eye16;
1155  }
1156  else
1157  {
1158  ldRow.Cells["XmlEnvioImg"].Value = null;
1159  }
1160 
1161  if (!string.IsNullOrWhiteSpace(Convert.ToString(ldRow.Cells["XmlRespString"].Value)))
1162  {
1163  ldRow.Cells["XmlRespImg"].Value = ew.images.Properties.Resources.icon_eye16;
1164  }
1165  else
1166  {
1167  ldRow.Cells["XmlRespImg"].Value = null;
1168  }
1169  }
1170 
1171  return;
1172 
1173  }
1174 
1175 
1180  private void configurarImpresion(DataTable tdtRegistros)
1181  {
1182  btImprimir._Filtros.Clear();
1183  btImprimir._Filtros.Add("wc_fechas", this.dtFechaDesde.Value.ToShortDateString()+ " - " + this.dtFechaHasta.Value.ToShortDateString());
1184  btImprimir._Filtros.Add("wc_mostrarregistros", this.cmbMostrarRegistros.Text);
1185 
1186  btImprimir._DataTable = tdtRegistros;
1187 
1188  // Para que vaya a buscar el report a EUROSERV\MODULOS\FACTUCERT\REPORTS\SAGE.EW.REPORTS\BASE
1189  //
1190  btImprimir._TipoReport = ew.reports.Report.TipoReport.Modulo;
1191  btImprimir._Modulo = "FACTUCERT";
1192  return;
1193  }
1194 
1195 
1200  private void TxtPeriodo__Codigo_Cambiado()
1201  {
1202  if (string.IsNullOrWhiteSpace(this.txtPeriodo._Codigo))
1203  return;
1204 
1205  int lnPeriodoSel = Convert.ToInt32(this.txtPeriodo._Codigo);
1206 
1207  PeriodosIva loPeriodos = new PeriodosIva(this._cEmpresa);
1208  loPeriodos._Load();
1209 
1210  Periodo loPeriodo = loPeriodos._Items.Where(x => x._Periodo == lnPeriodoSel).FirstOrDefault();
1211  if (loPeriodo != null)
1212  {
1213  this.dtFechaDesde.Value = Convert.ToDateTime(loPeriodo._FechaIniReper);
1214  this.dtFechaHasta.Value = Convert.ToDateTime(loPeriodo._FechaFinalReper);
1215  }
1216  loPeriodos = null;
1217  loPeriodo = null;
1218 
1219  return;
1220  }
1221 
1222 
1228  private void EwgridDatos_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
1229  {
1230  if (e.RowIndex < 0)
1231  return;
1232 
1233  DataGridViewRow loRowDataGridViewRow = this.ewgridDatos.Rows[e.RowIndex];
1234  if (loRowDataGridViewRow == null)
1235  return;
1236 
1237  DataRow loRow = ((DataRowView)ewgridDatos.Rows[e.RowIndex].DataBoundItem).Row;
1238 
1239  EstadoAdministracion eEstadoAdm = (EstadoAdministracion)Enum.Parse(typeof(EstadoAdministracion), Convert.ToString(Convert.ToInt32(loRow["idestadoadm"])));
1240 
1241  switch (eEstadoAdm)
1242  {
1243  case EstadoAdministracion.Pendiente:
1244  // Fila pintada con color negro, color por defecto.
1245  break;
1246  case EstadoAdministracion.Aceptada:
1247  this.ewgridDatos.Rows[e.RowIndex].DefaultCellStyle.ForeColor = ShapeLeyendaAceptadas.BackColor;
1248  break;
1249  case EstadoAdministracion.AceptadaConErrores:
1250  this.ewgridDatos.Rows[e.RowIndex].DefaultCellStyle.ForeColor = ShapeLeyendaAceptErrores.BackColor;
1251  break;
1252  case EstadoAdministracion.Rechazada:
1253  this.ewgridDatos.Rows[e.RowIndex].DefaultCellStyle.ForeColor = ShapeLeyendaRechazadas.BackColor;
1254  break;
1255  }
1256 
1257  return;
1258  }
1259 
1260 
1266  private void btRefrescar_Click(object sender, EventArgs e)
1267  {
1268  this.obtenerDatos();
1269  }
1270 
1271 
1278  private string cadenaEstado(string tcCampo)
1279  {
1280  string lcCadena = DB.SQLIif(tcCampo + "=0", "'Pendiente'", "'Enviado'");
1281 
1282  return lcCadena;
1283  }
1284 
1285 
1292  private string cadenaEstadoAdm(string tcCampo)
1293  {
1294  string lcCadena = string.Empty;
1295 
1296  lcCadena = DB.SQLIif(tcCampo + "=3", "'Rechazada'", "'No contemplado'");
1297  lcCadena = DB.SQLIif(tcCampo + "=2", "'Aceptada con errores'", lcCadena);
1298  lcCadena = DB.SQLIif(tcCampo + "=1", "'Aceptada'", lcCadena);
1299  lcCadena = DB.SQLIif(tcCampo + "=0", "'Pendiente'", lcCadena);
1300 
1301  return lcCadena;
1302  }
1303 
1304 
1319  private string cadenaTipoReg(string tcCampo)
1320  {
1321  string lcCadena = string.Empty;
1322 
1323  lcCadena = DB.SQLIif(tcCampo + "=7", "'Ticket anulado modificado'", "'No contemplado'");
1324  lcCadena = DB.SQLIif(tcCampo + "=6", "'Ticket anulado'", lcCadena);
1325  lcCadena = DB.SQLIif(tcCampo + "=5", "'Ticket modificado'", lcCadena);
1326  lcCadena = DB.SQLIif(tcCampo + "=4", "'Ticket'", lcCadena);
1327  lcCadena = DB.SQLIif(tcCampo + "=3", "'Factura anulada modificada'", lcCadena);
1328  lcCadena = DB.SQLIif(tcCampo + "=2", "'Factura anulada'", lcCadena);
1329  lcCadena = DB.SQLIif(tcCampo + "=1", "'Factura modificada'", lcCadena);
1330  lcCadena = DB.SQLIif(tcCampo + "=0", "'Factura'", lcCadena);
1331 
1332  return lcCadena;
1333  }
1334 
1335 
1336  #endregion MÉTODO PRIVADOS
1337  }
1338 
1339  }
1340 
decimal _Rango_Max
Valor máximo según la máscara. Es la máscara de VFP convertida a decimal
Definition: clsEwBase.cs:6245
Clase para las previsiones de cobro
override bool _Load(string tcEmpresa, string tcNumero, string tcLetra="", string tcEjercicio="GESTION")
Carga un documento existente
override void _Load()
Overrides del _Load
string _Titulo
Título del formulario
Este es el espacio de nombres de su módulo. Puede encontrar más información y ayuda en el fichero rea...
EstadoEnvio
Enumeración para el estado
Definition: Enums.cs:131
override string _Codigo
PE-102491: override de _Codigo para que en el Set podamos convertir el número que nos llega a código ...
Clase documento de venta TPV
Definition: DocVentaTpv.cs:47
Formulario gennérico para mostrar información
static System.Drawing.Bitmap refresh
Busca un recurso adaptado de tipo System.Drawing.Bitmap.
static System.Drawing.Bitmap doc_print
Busca un recurso adaptado de tipo System.Drawing.Bitmap.
Classe documento Factura de venta
Definition: DocsVentaFra.cs:61
Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc.
Clase utilizada para realizar asientos contables.
Definition: Asientos.cs:36
KeyDiccionarioMascara
Clave para diccionario de máscaras
Consulta de una declaración existente
virtual void _Show()
Muestra el formulario asiociado
Definition: clsEwBase.cs:5021
Formulario para mostrar los registros de facturación (facturas y tickets) en sistema de certificación...
void _Show()
Muestra por pantalla el asiento
Definition: Asientos.cs:2563
virtual void _Show()
Implementación del método _Show para ver el documento relacionado (Gestión Documental) ...
Definition: DocsVen.cs:3006
Botón Aceptar para formularios
int _Num_Decimales
Número de decimales de la máscara
Definition: clsEwBase.cs:6240
Custom column type dedicated to the DataGridViewNumericUpDownCell cell type.
Definition: Mantegrid.cs:3451
bool _Load(string tcEmpresa, string tcNumero)
Sobrecarrega del load, tcNumero és la lletra + número de factura
Proporciona características adicionales de las máscaras de Eurowin
Definition: clsEwBase.cs:6212
virtual void _Show_Factura()
Nos presenta la factura de la previsión
string _Factura
Número de factura
dynamic _Documento
Referencia a la instancia de ña clase de negocio en los documentos de venta/compra y mantenimientos ...
decimal _Rango_Min
Valor mínimo según la máscara. Es la máscara de VFP convertida a decimal y en negativo ...
Definition: clsEwBase.cs:6250
string _Mascara_Net
Máscara convertida en formato .Net
Definition: clsEwBase.cs:6235
string _Empresa
Código de empresa.
Clase FormSalir basada en FormBase
Definition: FormSalir.cs:14
override void OnClosing(CancelEventArgs e)
Cancelar eventos.
string _TextoBotonCancelar
Texto del botón Cancelar
Presenta un datagridview con botones añadir y borrar tipo Mantegrid de Eurowin
Definition: Mantegrid.cs:30