DatosRegistroEncadenamiento.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Data;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using sage.ew.docsven;
11 using sage.ew.functions;
12 using System.Reflection;
13 using sage.ew.docventatpv;
17 using sage.ew.images.Properties;
18 using sage.ew.objetos;
21 using sage.ew.global;
22 using sage.ew.db;
26 using sage.ew.listados.Clases;
27 
28 namespace sage.addons.factucert.Visual.UserControls
29 {
33  public partial class DatosRegistroEncadenamiento : sage.ew.ewbase.UserControlConfig
34  {
35  #region PROPIEDADES PRIVADAS
36  private DatosAdicionalesBase _oDatos = null;
37  private int _TipoDocAnt = -1;
38  private int _TipoDocPost = -1;
39  private string _NumDocAnt = string.Empty;
40  private string _NumDocPost = string.Empty;
41  private string _EjerDocAnt = string.Empty;
42  private string _EjerDocPost = string.Empty;
43  #endregion PROPIEDADES PRIVADAS
44 
45  #region PROPIEDADES PUBLICAS
46  public virtual bool _ReadOnly
50  {
51  get { return _lReadOnly; }
52  set { _lReadOnly = value; }
53  }
54  private bool _lReadOnly = false;
55  #endregion PROPIEDADES PUBLICAS
56 
57  #region CONSTRUCTORES
62  {
63  InitializeComponent();
64  }
65  #endregion CONSTRUCTORES
66 
67  #region PROPIEDADES INTERFICIE IUserControlFacturarAlbaranVenta
68 
72  public string _TituloPagina
73  {
74  get { return _cTituloPagina; }
75  set { _cTituloPagina = value; }
76  }
77  private string _cTituloPagina = "";
78 
82  public dynamic _Documento
83  {
84  get { return _oDocumento; }
85  set { _oDocumento = value; }
86  }
87  private dynamic _oDocumento = null;
88 
89  #endregion PROPIEDADES INTERFICIE IUserControlFacturarAlbaranVenta
90 
91 
92  #region METODOS PROTECTED
93  protected override void OnHandleCreated(EventArgs e)
98  {
99  base.OnHandleCreated(e);
100 
101  if (DesignMode)
102  return;
103 
104  }
105  #endregion METODOS PROTECTED
106 
107  #region METODOS PUBLICOS
108  public override void _Binding()
112  {
113  _oDatos = null;
114  if (_Documento._TipoDocumento == eTipoDocumento.Factura && _oDocumento is ewDocVentaTPV)
115  _oDatos = ((dynamic)_Documento._Addons["FACTUCERT"])._DatosAdicionalesFactura;
116  else
117  _oDatos = ((dynamic)_Documento._Addons["FACTUCERT"])._DatosAdicionales;
118 
119  ObtenerDocumentos();
120  }
121 
122  #endregion METODOS PUBLICOS
123 
124  #region METODOS PRIVADOS
125 
129  private void ObtenerDocumentos()
130  {
131  DataTable ldTemp = new DataTable();
132  if (FunctionsFactuCert._ObtenerDocAnterior(_oDatos, ref ldTemp))
133  GetData(ldTemp, ref txtTipoRegistro, ref txtFactura, ref txtFechaRegistro, ref _NumDocAnt, ref _TipoDocAnt, ref _EjerDocAnt);
134 
135  if (FunctionsFactuCert._ObtenerDocPosterior(_oDatos, ref ldTemp))
136  GetData(ldTemp, ref txtTipoRegistroPost, ref txtFacturaPost, ref txtFechaRegistroPost, ref _NumDocPost, ref _TipoDocPost, ref _EjerDocPost);
137 
138  FUNCTIONS._DisposeDatatable(ldTemp);
139 
140  }
141 
153  private string GetData(DataTable ldTemp, ref ewtextbox toTipo, ref txtNumFraMultiDoc toDoc, ref ewtextbox toFecha,
154  ref string tcNumDoc, ref int tnTipoDoc, ref string tcEjerDoc)
155  {
156  tcNumDoc = string.Empty;
157  if (ldTemp != null && ldTemp.Rows.Count>0)
158  {
159 
160  tcNumDoc = Convert.ToString(ldTemp.Rows[0]["numero"]);
161  if (!string.IsNullOrWhiteSpace(tcNumDoc))
162  {
163  tcEjerDoc = Convert.ToString(ldTemp.Rows[0]["ejercicio"]);
164  tnTipoDoc = Convert.ToInt16(ldTemp.Rows[0]["tiporeg"]);
165  toTipo.Text = GetTipoRegistro(tnTipoDoc);
166  toFecha.Text = Convert.ToString(ldTemp.Rows[0]["fechareg"]) + " " + Convert.ToString(ldTemp.Rows[0]["husohora"]);
167 
168  // Si es ticket cogemos numero y letra
169  if (tnTipoDoc == 4)
170  {
171  toDoc._Letra = Convert.ToString(ldTemp.Rows[0]["letra"]);
172  toDoc._Numero = tcNumDoc;
173  tcNumDoc = toDoc._Letra + toDoc._Numero;
174  }
175  else
176  {
177  toDoc._Letra = tcNumDoc.Substring(0, 2);
178  toDoc._Numero = tcNumDoc.Substring(2);
179  }
180  }
181  else
182  tcNumDoc = string.Empty;
183  }
184 
185  return tcNumDoc;
186  }
187 
193  private string GetTipoRegistro(int pnTipoRegistro)
194  {
195  string lcTipoRegistro = string.Empty;
196  switch (pnTipoRegistro)
197  {
198  case 0:
199  lcTipoRegistro = "Factura";
200  break;
201  case 1:
202  lcTipoRegistro = "Factura modificada";
203  break;
204  case 2:
205  lcTipoRegistro = "Factura anulada";
206  break;
207  case 4:
208  lcTipoRegistro = "Ticket";
209  break;
210  }
211 
212  return lcTipoRegistro;
213  }
214 
215 
222  private void NavegarDocumento(int tnTipoDoc, string tcNumDoc, string tcEjerDoc)
223  {
224  if (tnTipoDoc == -1 || string.IsNullOrWhiteSpace(tcNumDoc))
225  return;
226 
227  switch (tnTipoDoc)
228  {
229  case 0:
230  NavegarFactura(tcNumDoc, tcEjerDoc);
231  break;
232  case 1:
233  //lcTipoRegistro = "Factura modificada";
234  break;
235  case 2:
236  //lcTipoRegistro = "Factura anulada";
237  break;
238  case 4:
239  NavegarTicket(tcNumDoc, tcEjerDoc);
240  break;
241  }
242  }
243 
249  private void NavegarFactura(string tcNumDoc, string tcEjerDoc)
250  {
251  // si està vacio el número, no mostramos la pantalla
252  if (!string.IsNullOrWhiteSpace(tcNumDoc))
253  {
254  string lcLetraFactura = tcNumDoc.Substring(0, 2);
255  string lcNumeroFactura = tcNumDoc.Substring(2).Trim().PadLeft(8);
256  using (Listados list = new Listados())
257  {
258  list._Navegar(Listados.Pantalla.Factuven, new List<string>() { _oDatos._Empresa, lcNumeroFactura, lcLetraFactura, tcEjerDoc });
259  }
260  }
261  }
262 
263 
269  private void NavegarTicket(string tcNumDoc, string tcEjerDoc)
270  {
271  // si està vacio el número, no mostramos la pantalla
272  if (!string.IsNullOrWhiteSpace(tcNumDoc))
273  {
274  string lcLetra = tcNumDoc.Substring(0, 2);
275  string lcNumero = tcNumDoc.Substring(2).Trim().PadLeft(8);
276  using (Listados list = new Listados())
277  {
278  list._Navegar(Listados.Pantalla.Ticket, new List<string>() { _oDatos._Empresa, lcNumero, lcLetra});
279  }
280  }
281  }
282 
288  private void btVerDocumento_Click(object sender, EventArgs e)
289  {
290  NavegarDocumento(_TipoDocAnt, _NumDocAnt, _EjerDocAnt);
291  }
292 
298  private void btVerDocumentoPost_Click(object sender, EventArgs e)
299  {
300  NavegarDocumento(_TipoDocPost, _NumDocPost, _EjerDocPost);
301  }
302 
303  #endregion METODOS PRIVADOS
304 
305  }
306 }
Control para números de factura. Solo operaciones de control de formato.
Clase parcial para listados, en esta definición se especificarán los métodos comunes para las demás c...
Definition: _clsListados.cs:61
Este es el espacio de nombres de su módulo. Puede encontrar más información y ayuda en el fichero rea...
Clase documento de venta TPV
Definition: DocVentaTpv.cs:47
UserControl para presentar la información de registros de encadenamiento
Clase sage.ew.objetos.ewtextbox
eTipoDocumento
Detalle los tipos de documento posibles de ventas y compras
Definition: docsvenenum.cs:32
Clase que se utilizará como base para "DatosAdicionalesFacturarAlbaran" y "DatosAdicionalesTicket" qu...
void _Navegar(Pantalla teForm, List< string > tlParamList, DataTable _DataTableNavegacion=null)
Abre la pantalla especificada