MantePropiedad.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Data;
6 using System.ComponentModel;
7 
8 using sage.ew.global;
9 using sage.ew.db;
10 using sage.ew.ewbase;
11 using System.Windows.Forms;
13 using sage.ew.interficies;
14 
15 namespace sage.addons.gestdoc.Negocio.Mantes
16 {
20  public partial class MantePropiedad : ewMante
21  {
22  # region Propiedades públicas
23  public bool _EnUso = false;
27 
31 
32  public int _Tipo
33  {
34  get
35  {
36  if (_lisCampos.ContainsKey("TIPO"))
37  {
38  int lnTipo = Convert.ToInt16(_lisCampos["TIPO"]._NewVal);
39  if (lnTipo<=0)
40  lnTipo = 1;
41 
42  return lnTipo;
43  }
44  else
45  {
46  return 1;
47  }
48  }
49  set
50  {
51  if (_lisCampos.ContainsKey("TIPO"))
52  {
53  _lisCampos["TIPO"]._NewVal = value;
54  }
55  }
56  }
57 
61 
62  public string _Mascara
63  {
64  get
65  {
66  if (_lisCampos.ContainsKey("MASCARA"))
67  {
68  return Convert.ToString(_lisCampos["MASCARA"]._NewVal);
69  }
70  else
71  {
72  return String.Empty;
73  }
74  }
75  set
76  {
77  if (_lisCampos.ContainsKey("MASCARA"))
78  {
79  _lisCampos["MASCARA"]._NewVal = value;
80  }
81  }
82  }
83 
84 
85  private LineasPropiedadLista _oLineasPropiedadLista;
89  public LineasPropiedadLista _Lineas
90  {
91  get
92  {
93  this._LoadLineas();
94  return _oLineasPropiedadLista;
95  }
96  }
97 
98  # endregion Propiedades públicas
99 
100  # region Constructores
101  public MantePropiedad()
105  {
106  Inicializar();
107  }
108 
113  public MantePropiedad(string tcCodigo)
114  {
115  Inicializar();
116 
117  this._Codigo = tcCodigo;
118  this._Load();
119  }
120  # endregion Constructores
121 
122  # region Métodos privados
123  private void Inicializar()
124  {
125  // Asignamos las propiedades para el mantenimiento
126  this._Clave = "Codigo";
127  this._DataBase = "GESTDOC";
128  this._Tabla = "propiedad";
129  this._TituloMantenimiento = "Mantenimiento de propiedades";
130 
131  this._Pantalla = "propiedad";
132  this._FormManteBaseType = typeof(Visual.Forms.frmMantePropiedad);
133 
134  this._Codigo = string.Empty;
135  }
136  # endregion Métodos privados
137 
138  # region Métodos public override
139  public override bool _Delete()
144  {
145  bool llDelete = true;
146 
147  Documento loDocumento = new Documento(); // Borramos las propidades de los documentos
148  llDelete = loDocumento._DeleteMantePropiedades(this._Codigo);
149 
150  if (llDelete)
151  {
152  Carpeta loCarpeta = new Carpeta(); // Borramos las propidades de las carepetas
153  llDelete = loCarpeta._DeleteMantePropiedades(this._Codigo);
154  }
155 
156  if (llDelete)
157  llDelete = base._Delete();
158 
159  // Borrar lineas
160  if (llDelete)
161  {
162  if (_Lineas != null)
163  _Lineas._Delete();
164  }
165  else
166  {
167  this._Error_Message = String.Format("Error al borrar la línea de la propiedad {0} ({1})", _Nombre, _Codigo);
168  llDelete = false;
169  }
170  return llDelete;
171  }
172 
176  public override void _Load()
177  {
178  base._Load();
179 
180  // Cargar los datos de las lineas
181  if (_oLineasPropiedadLista != null)
182  {
183  if (_oLineasPropiedadLista._Grid != null)
184  {
185  _oLineasPropiedadLista._Claves._Codigo._Valor = this._Codigo;
186  _oLineasPropiedadLista._Load();
187  }
188  else
189  {
190  _oLineasPropiedadLista = null;
191  }
192  }
193  }
194 
198  public void _LoadLineas()
199  {
200  if (_oLineasPropiedadLista == null)
201  {
202  _oLineasPropiedadLista = new LineasPropiedadLista(_Codigo);
203  _oLineasPropiedadLista._ewMantePrincipal = this;
204  _oLineasPropiedadLista._Load();
205  }
206  }
207 
211  public override bool _Save()
212  {
213  Boolean lOk = true;
214 
215  if (base._Save())
216  {
217  // Guardar los datos de las lineas
218  if (_oLineasPropiedadLista != null)
219  {
220  // En caso de tener una propiedad tipo lista, obligamos a introducir algun valor en la lista
221  if (this._Tipo == 5 && ( (_oLineasPropiedadLista.Count() == 0) || (_oLineasPropiedadLista.Count() > 0 && string.IsNullOrWhiteSpace(_oLineasPropiedadLista._Items[0]._Texto))))
222  {
223  _Error_Message = "Es necesario indicar algún valor para las propiedades de tipo lista.";
224  return false;
225  }
226 
227  _oLineasPropiedadLista._Save();
228  }
229  }
230  else
231  {
232  lOk = false;
233  }
234 
235  return lOk;
236  }
237 
238 
239  # endregion Métodos public override
240 
241 
242 
243  #region CLASE DE LINEAS PARA PROPIEDADES TIPO LISTA
244 
248  public class LineasPropiedadLista : ewManteTRel<LineasPropiedadLista.LineaPropiedadLista, LineasPropiedadLista.Clave>
249  {
250 
255  {
256  CrearEstructura();
257  }
258 
262  public LineasPropiedadLista(string tcCodigo)
263  {
264  CrearEstructura();
265 
266  this._Claves._Codigo._Valor = tcCodigo;
267  }
268 
269  private void CrearEstructura()
270  {
271  // Definir la base
272  this._DataBase = "GESTDOC";
273  this._Tabla = "PROPI_LIS";
274  this._Condicion = "";
275  this._OrdenarPor = "LINEA";
276  this._Titulo_Browser = "Buscar Linea";
277 
278 
279  // Campos clave
280  this._AddCampoTRel("_Codigo", "Codigo", ewCampoTRel.Visible.No, ewCampoTRel.Updatable.Si, ewCampoTRel.Editable.No);
281  this._AddCampoTRel("_Linea", "Linea", ewCampoTRel.Visible.No, ewCampoTRel.Updatable.Si, ewCampoTRel.Editable.No);
282 
283  // Otros campos
284  this._AddCampoTRel("_Texto", "Texto", ewCampoTRel.Visible.Si, ewCampoTRel.Updatable.Si, ewCampoTRel.Editable.Si, "Campo", gridColumnsTypes.Texto);
285  }
286 
287 
291  public class Clave : IClaves
292  {
296  public ClaveTRel _Codigo { get; set; }
297 
301  public ClaveTRel _Linea { get; set; }
302 
306  public Clave()
307  {
308  // Definimos las propiedadess de cada una de las claves
309  _Codigo = new ClaveTRel();
310  _Codigo._EsFiltro = true;
311  _Codigo._Valor = "";
312 
313  _Linea = new ClaveTRel();
314  _Linea._EsCampoLinea = true;
315  _Linea._Valor = 0;
316  }
317  }
318 
323  {
324  #region PROPIEDADES
325 
326  private string _cCodigo = "";
330  public string _Codigo
331  {
332  get { return _cCodigo; }
333  set { _cCodigo = value; }
334  }
335 
336  private Int32 _nLinea = 0;
340  public Int32 _Linea
341  {
342  get { return _nLinea; }
343  set { _nLinea = value; }
344  }
345 
346  private string _cTexto = "";
350  public string _Texto
351  {
352  get
353  {
354  return _cTexto;
355  }
356  set
357  {
358  if (_cTexto != value)
359  {
360  _cTexto = value;
361  }
362  }
363  }
364 
365 
366  private LineasPropiedadLista loParent;
370  public object _Parent
371  {
372  get { return loParent; }
373  set { loParent = (LineasPropiedadLista)value; }
374  }
375 
376  #endregion PROPIEDADES
377 
382  {
383 
384  }
385 
390  public bool Fila_Plena()
391  {
392  bool lbFilaPlena;
393 
394  lbFilaPlena = _Codigo != "" && _Texto != "";
395 
396  return lbFilaPlena;
397  }
398  }
399 
400  }
401 
402 
403  #endregion CLASE DE LINEAS PARA PROPIEDADES TIPO LISTA
404 
405  }
406 
407 }
Clase de negocio base para mantenimientos
Definition: clsEwBase.cs:1643
MantePropiedad(string tcCodigo)
Constructor con código
Objeto base ObjetoCarpeta basado sobre el objeto base "ObjetoGestDoc" y que cumple implementa la inte...
Definition: Carpeta.cs:23
Definición de los objetos campo para las tablas relacionadas
Objeto base ObjetoDocumento basado sobre el objeto base "ObjetoGestDoc"
Definition: Documento.cs:30
Clase para las lineas de las propiedades de tipo lista. Basada a partir de un ewManteTRel ...
override bool _Save()
Guarda los datos de la propiedad y de las lineas relacionadas
LineasPropiedadLista(string tcCodigo)
Inicializa una nueva intancia de la clase mediante un código
Definición de los objetos campo para las tablas relacionadas
Updatable
Actualizable. Existe el campo en la tabla.
override void _Load()
Carga los datos de la propiedad y de las lineas relacionadas
Editable
Premitirá modificar su valor
Interfaz para objetos línea
Definition: ILinTRel.cs:11
Clase del addon de gestión documental.
Definition: SageAddons.cs:85
Interfaz para la definición de las claves para tablas relacionadas
Definition: IClaves.cs:11
Clase para el acceso a las tablas relacionadas de los mantenimientos.
gridColumnsTypes
Definición de los tipos de columnas para los grids o campos enlazados
Visible
Visible en el grid
void _LoadLineas()
Carga las lineas de la lista