EntidadInfo.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Data;
6 using sage.ew.db;
8 using System.Diagnostics;
9 
10 namespace sage.addons.rgpd.Negocio.Clases
11 {
12  internal class EntidadInfo
13  {
14  #region Propiedades
15 
19  public string _Codigo
20  {
21  get { return _cCodigo; }
22  private set { _cCodigo = value; }
23  }
24  private string _cCodigo = "";
25 
29  public string _Nombre
30  {
31  get { return _cNombre; }
32  private set { _cNombre = value; }
33  }
34  private string _cNombre = "";
35 
39  public string _Pantalla
40  {
41  get { return _cPantalla; }
42  private set { _cPantalla = value; }
43  }
44  private string _cPantalla = "";
45 
49  public string _TxtCodlabel
50  {
51  get { return _cTxtCodlabel; }
52  private set { _cTxtCodlabel = value; }
53  }
54  private string _cTxtCodlabel = "";
55 
59  public string _Formulario
60  {
61  get { return _cFormulario; }
62  private set { _cFormulario = value; }
63  }
64  private string _cFormulario = "";
65 
66  #endregion Propiedades
67 
68  #region Constructores
69 
73  private EntidadInfo() { } //No permito instaciamiento sin valores
74 
79  public EntidadInfo(DataRow tdrDatos)
80  {
81  //CODIGO, CLASE, TXTCODLABEL, FORMULARIO
82  _cCodigo = Convert.ToString(tdrDatos["CODIGO"]).Trim();
83  _cPantalla = Convert.ToString(tdrDatos["PANTALLA"]).Trim();
84  _cTxtCodlabel = Convert.ToString(tdrDatos["TXTCODLABEL"]).Trim();
85  _cFormulario = Convert.ToString(tdrDatos["FORMULARIO"]).Trim();
86  _cNombre = Convert.ToString(tdrDatos["NOMBRE"]).Trim();
87  }
88 
89  #endregion Constructores
90 
96  internal static EntidadInfo ExisteFiltroAsociadoAlFormulario(string tcNombreFormulario)
97  {
98  Trace.WriteLineIf(Debugger.IsAttached, "EntidadInfo => buscando datos de la entidad asociada al formulario " + tcNombreFormulario);
99 
100  return EntidadesInfo.BuscarPorFormulario(tcNombreFormulario);
101  }
102 
108  internal static EntidadInfo ExisteEntidadAsociadaParaLaPantalla(string tcNombreClase)
109  {
110  Trace.WriteLineIf(Debugger.IsAttached, "EntidadInfo => buscando datos de la entidad asociada a la pantalla " + tcNombreClase);
111 
112  return EntidadesInfo.BuscarPorPantalla(tcNombreClase);
113  }
114 
120  public static EntidadInfo ObtenerEntidad(String tcCodigo)
121  {
122  return String.IsNullOrEmpty(tcCodigo) ? null : EntidadesInfo._EntidadesInstanciables.Where(loEle => loEle._Codigo == tcCodigo).FirstOrDefault();
123  }
124 
129  internal ewtxtcodlabel InstanciarFiltro()
130  {
131  Type loType = sage.ew.functions.FUNCTIONS._GetType(_cTxtCodlabel);
132  if (loType != null)
133  {
134  return Activator.CreateInstance(loType) as ewtxtcodlabel;
135  }
136 
137  return null;
138  }
139 
143  internal static class EntidadesInfo
144  {
148  internal static List<EntidadInfo> _EntidadesInstanciables
149  {
150  get
151  {
152  if (_lisInstanciables == null)
153  {
154  _lisInstanciables = new List<EntidadInfo>();
155  obtenerDatosInstanciamientoEntidadC();
156  }
157  return _lisInstanciables;
158  }
159  private set { _lisInstanciables = value; }
160  }
161  private static List<EntidadInfo> _lisInstanciables = null;
162 
166  internal static bool _ClientesPorContabilidad
167  {
168  get
169  {
170  if (llClientesPorContabilidad == null)
171  llClientesPorContabilidad = Mantes.ExtensionMantenimientoEmpresa._UsarContabilidadParaGestionarClientes();
172  return (bool)llClientesPorContabilidad;
173  }
174  }
175  private static bool? llClientesPorContabilidad = null;
176 
180  internal static bool _ProveedoresPorContabilidad
181  {
182  get
183  {
184  if (llProveedoresPorContabilidad == null)
185  llProveedoresPorContabilidad = Mantes.ExtensionMantenimientoEmpresa._UsarContabilidadParaGestionarProveedores();
186  return (bool)llProveedoresPorContabilidad;
187  }
188  }
189  private static bool? llProveedoresPorContabilidad = null;
190 
194  private static void obtenerDatosInstanciamientoEntidadC()
195  {
196  DataTable ldtResultados = new DataTable();
197  string lcSQL = "SELECT CODIGO, NOMBRE, PANTALLA, TXTCODLABEL, FORMULARIO FROM " +
198  DB.SQLDatabase("RGPD", "ENTIDAD_C");
199 
200  if (DB.SQLExec(lcSQL, ref ldtResultados) && ldtResultados.Rows.Count > 0)
201  {
202  _EntidadesInstanciables.Clear();
203  ldtResultados.AsEnumerable().Cast<DataRow>().ToList().ForEach(loRow => _EntidadesInstanciables.Add(new EntidadInfo(loRow)));
204  }
205  }
206 
212  public static EntidadInfo BuscarPorPantalla(string tcNombreBusqueda)
213  {
214  tcNombreBusqueda = tcNombreBusqueda.Trim().ToUpper();
215  var informacionEntidades = _EntidadesInstanciables.Where(loEntidad => loEntidad._Pantalla.Trim().ToUpper() == tcNombreBusqueda).ToList();
216  return filtrarPorGestionDesdeContabilidad(informacionEntidades);
217  }
218 
224  public static EntidadInfo BuscarPorFormulario(string tcNombreBusqueda)
225  {
226  tcNombreBusqueda = tcNombreBusqueda.Trim().ToUpper();
227  var informacionEntidades = _EntidadesInstanciables.Where(loEntidad => loEntidad._Formulario.Trim().ToUpper() == tcNombreBusqueda).ToList();
228  return filtrarPorGestionDesdeContabilidad(informacionEntidades);
229  }
230 
231  private static EntidadInfo filtrarPorGestionDesdeContabilidad(IEnumerable<EntidadInfo> tlisEntidades)
232  {
233  if (tlisEntidades.Any())
234  {
235  if (_ClientesPorContabilidad || _ProveedoresPorContabilidad)
236  {
237  if (_ClientesPorContabilidad) //Suprimo clientes si corresponde
238  tlisEntidades = tlisEntidades.Where(loEle => loEle._Codigo != "00000001").ToList();
239 
240  if (tlisEntidades.Any())
241  {
242  if (_ProveedoresPorContabilidad) //Suprimo proveedores si corresponde
243  tlisEntidades = tlisEntidades.Where(loEle => loEle._Codigo != "00000007").ToList();
244  if (tlisEntidades.Any())
245  return tlisEntidades.First();
246  else
247  return null;
248  }
249  else
250  return null;
251  }
252  else
253  {
254  tlisEntidades = tlisEntidades.Where(loEle => loEle._Codigo != "00000003").ToList();
255  return tlisEntidades.FirstOrDefault();
256  }
257  }
258  else
259  return null;
260  }
261  }
262  }
263 }
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
Clase para uso de funciones genéricas
Definition: functions.cs:146
Clase base para controles de tipo txtcodlabelf