txtPeriodoLiquidado.cs
1 # region Usings
2 using System;
3 using System.Collections.Generic;
4 using System.ComponentModel;
5 using System.Drawing;
6 using System.Data;
7 using System.Linq;
8 using System.Text;
9 using System.Windows.Forms;
10 using sage.ew.contabilidad;
11 using sage.ew.global;
12 using sage.ew.listados.Clases;
13 using sage.ew.functions;
14 #endregion Usings
15 
16 namespace sage.ew.txtbox.UserControls
17 {
21  public partial class txtPeriodoLiquidado : ewtxtcodlabel
22  {
23  #region Propiedades privadas
24  private DataTable _dtPeriodos = null;
25  private bool _lPeriodosRetenciones = false;
26  #endregion Propiedades privadas
27 
28  #region Propiedades públicas
29  [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
33  public bool _PeriodosRetenciones
34  {
35  get { return _lPeriodosRetenciones; }
36  set
37  {
38  if (_lPeriodosRetenciones != value)
39  {
40  FUNCTIONS._DisposeDatatable(ref _dtPeriodos);
41 
42  _lPeriodosRetenciones = value;
43 
44  _DataTable = null;
45 
46  CargarDataTable();
47  }
48  }
49  }
50  #endregion Propiedades públicas
51 
52  #region Constructor
53  public txtPeriodoLiquidado()
57  {
58  InitializeComponent();
59 
60  _Mostrar_Browser = true;
61  _Mostrar_Mante = false;
62  _Mostrar_Mensaje = true;
63 
64  if (!DesignMode)
65  _Codigo_Cambiado_Before += new Delegar_Codigo_Cambiado_Before(txtPeriodo__Codigo_Cambiado_Before); // Validaremos si existe el periodo entrado manualmente
66  }
67  #endregion Constructor
68 
69  #region Métodos públicos
70  public void _Periodos(DataTable tdtDatatable)
75  {
76  _dtPeriodos = tdtDatatable;
77 
78  FUNCTIONS._DisposeDatatable(_DataTable);
79 
80  _DataTable = null;
81 
82  CargarDataTable();
83  }
84  #endregion Métodos públicos
85 
86  #region Métodos protected override
87  protected virtual DataTable _Periodos()
92  {
93  if (_dtPeriodos != null)
94  return _dtPeriodos;
95  else
96  {
97  if (_lPeriodosRetenciones)
98  return CONTABILIDAD._PeriodosRetencionLiquidados(true); // Periodos de Retención
99  else
101  }
102  }
103 
107  protected override void _Cargar_Propiedades()
108  {
109  _Clave = "codigo";
110  _Len = 2;
111  _Expandir = false;
112  _Mensaje_No_Existe = "El periodo no existe";
113  _Mostrar_Mante = false;
114  _Esconder_Label = false;
115 
116  // TODO: Mirar de unificar en el siguiente modelo fiscal para que sea comptatible con el control txtPerido que utiliza otro datatable
117 
118  _Browser_Clave = "periodo";
119  _Browser_Campo_Predet = "periodo";
120  _Browser_Campos = "periodo,reper";
121  _Browser_Titulos_Campos = "Código,Fecha final";
122  _Browser_Titulo = "Listado de periodos";
123 
124  _TooltipBrowser = "Consultar periodos";
125 
126  if (Convert.ToBoolean(sage.ew.global.EW_GLOBAL._GetVariable("wl_designmode", true)) == false)
127  CargarDataTable(); //Carga un datatable personalizado
128  }
129  #endregion Métodos protected override
130 
131  #region Métodos privados
132  private void CargarDataTable()
136  {
137  if (Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_Parti")))
138  _Len = 5; // Cambiamos el ancho
139 
140  if (_DataTable == null)
141  {
142  DataTable ldtPeriodosTemp = _Periodos();
143 
144  bool llPeriodoejer = _dtPeriodos != null && Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_Parti")) && ldtPeriodosTemp.Columns.Contains("periodoejer");
145 
146  DataTable ldtPeriodos = new DataTable();
147 
148  ldtPeriodos.Columns.Add(new DataColumn("periodo", Type.GetType("System.String")));
149  ldtPeriodos.Columns.Add(new DataColumn("reper", Type.GetType("System.String")));
150 
151  foreach (DataRow ldrPeriodoTemp in ldtPeriodosTemp.Rows) // Para filtrar las fechas correctamente pasamos los campos de tipo fecha a string
152  {
153  DataRow ldrPeriodo = ldtPeriodos.NewRow();
154 
155  if (llPeriodoejer)
156  ldrPeriodo["periodo"] = Convert.ToString(ldrPeriodoTemp["periodoejer"]).Trim();
157  else
158  ldrPeriodo["periodo"] = Convert.ToString(ldrPeriodoTemp["periodo"]).Trim();
159 
160  ldrPeriodo["reper"] = Convert.ToDateTime(ldrPeriodoTemp["reper"]).ToShortDateString();
161  ldtPeriodos.Rows.Add(ldrPeriodo);
162  }
163 
164  _DataTable = ldtPeriodos;
165  _Browser_Datatable_Personalizado = _DataTable;
166 
167  _PrimeraVez = true;
168  base._Refresh();
169  }
170  }
171 
176  private string IVARetencion()
177  {
178  if (_lPeriodosRetenciones)
179  return "retenciones";
180  else
181  return Convert.ToString(EW_GLOBAL._GetVariable("wc_iva")).Trim();
182  }
183 
188  private void txtPeriodo__Codigo_Cambiado_Before(ref bool tlOk)
189  {
190  string lcPeriodo = ewtextbox.Text;
191 
192  if (!(string.IsNullOrWhiteSpace(lcPeriodo)) && (lcPeriodo != "Todos") && (this._Browser_Datatable_Personalizado != null))
193  {
194  if (this._Browser_Datatable_Personalizado != null && (this._Browser_Datatable_Personalizado.Rows.Count == 0))
195  {
196  FUNCTIONS._MessageBox("No hay periodos de " + IVARetencion() + " definidos." + Environment.NewLine +
197  "Por favor defina antes los periodos de " + IVARetencion() + Environment.NewLine +
198  "en la opción de periodos de " + IVARetencion() + " en el menú" + Environment.NewLine +
199  "archivos de contabilidad.", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, DialogResult.OK);
200 
201  tlOk = false;
202 
203  return;
204  }
205 
206  DataRow[] ldrPeriodo = this._Browser_Datatable_Personalizado.Select("periodo = '" + lcPeriodo + "'");
207 
208  if ((ldrPeriodo != null) && (ldrPeriodo.Count() == 0))
209  {
210  FUNCTIONS._MessageBox("El periodo " + lcPeriodo + " no existe.", "Validar periodo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
211  tlOk = false;
212  }
213  }
214  }
215  #endregion Métodos privados
216  }
217 }
static DataTable _PeriodosIVALiquidados(bool tlDesglosarEmpresa=false)
Devuelve un Datatable con los periodos de IVA Liquidados teniendo en cuenta si trabajamos con ejercic...
Filtro de periodo liquidado a utilizar en la generación de los modelos fiscales
override void _Cargar_Propiedades()
Redefinición del método Cargar_Propiedades()
Clase EW_GLOBAL para gestionar las variables públicas de Eurowin, variables de empresa, variables de anchuras de campo, variables de mascaras, etc.
Definition: EW_GLOBAL.cs:46
static DataTable _PeriodosRetencionLiquidados(bool tlDesglosarEmpresa=false)
Devuelve un Datatable con los periodos de Retención Liquidados teniendo en cuenta si trabajamos con e...
Clase base para controles de tipo txtcodlabelf