ewDateDoc.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Windows.Forms;
6 
7 using sage.ew.global;
8 using sage.ew.interficies;
9 using sage.ew.docsven;
10 
11 namespace sage.ew.objetos
12 {
13 
18  {
19  private string _cCampoBinding = "_Fecha";
20  private dynamic _oForm = null;
21  private dynamic _oDocumento;
25  public dynamic _Documento
26  {
27  get { return this._oDocumento; }
28  set {
29  this._oDocumento = value;
30 
31  if (this._oDocumento != null && eTipoDocumento.FacturaCompra == this._oDocumento._TipoDocumento)
32  _cCampoBinding = "_FechaFac";
33  }
34  }
35 
36  private bool _bReadOnly = false;
37 
41  public bool _ReadOnly
42  {
43  get { return _bReadOnly; }
44  set
45  {
46  if (_bReadOnly != value)
47  {
48  _bReadOnly = value;
49  }
50  //PE-96764 : JOAN: S'ha de bloquejar l'objecte si es de solo lectura.
51  this.Enabled = !_bReadOnly;
52  }
53  }
54 
59  protected override void OnLeave(EventArgs e)
60  {
61  if (this._ReadOnly)
62  Value = this._OldValue;
63  base.OnLeave(e);
64  }
65 
71  private void ewDateDoc_KeyPress(object sender, KeyPressEventArgs e)
72  {
73  if (this._ReadOnly)
74  {
75  if (char.IsDigit(e.KeyChar))
76  {
77  e.Handled = true;
78  }
79  }
80  }
81 
87  private void ewDateDoc_KeyDown(object sender, KeyEventArgs e)
88  {
89  if (this._ReadOnly)
90  {
91  if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
92  {
93  e.Handled = true;
94  }
95  }
96  }
97 
101  public void _Refresh()
102  {
103  this.DataBindings.Clear();
104  this.DataBindings.Add("Value", _oDocumento._Cabecera, _cCampoBinding, true);
105 
106  // PE-74827
107  // dynamic por que este control puede estar en formulario de mas de un tipo (formbase, formsatellite, formdialog, frmgestionperfil, ...) y aqui no sabemos
108  // en qué tipo de formulario estamos, por tanto, para que funcione para todos hacemos ésto.
109  if (_oForm == null)
110  _oForm = this.FindForm();
111 
112  if (_oForm != null)
113  {
114  // Aqui dentro del método se hace todo, se revisa el _ReadOnly del formulario, y si es un frmgestionperfil además también se mira el _Documento,
115  // si está vacío, si está en uso, etc.
116  this._ReadOnly = _oForm._Controles_En_Formulario_De_Solo_Lectura();
117  }
118  }
119 
123  public ewDateDoc()
124  {
125 
126  _Intervalo_Ejercicio = true;
127  _FechaIniIntervalo = (DateTime)EW_GLOBAL._GetVariable("wd_periodoini");
128  _FechaFinIntervalo = (DateTime)EW_GLOBAL._GetVariable("wd_periodofin");
129 
130  // Unicamente para control que no me puedan variar el valor de la fecha si el control es de solo lectura.
131  this.KeyDown += new KeyEventHandler(ewDateDoc_KeyDown);
132  this.KeyPress += new KeyPressEventHandler(ewDateDoc_KeyPress);
133 
134  }
135  }
136 
137 }
Campo fecha cabecera de documentos
Definition: ewDateDoc.cs:17
override void OnLeave(EventArgs e)
Unicamente es para impedir que nos puedan cambiar el valor de la fecha cuando el control está en Read...
Definition: ewDateDoc.cs:59
Interfaz utilizada en los controles que se añaden en los perfiles
eTipoDocumento
Detalle los tipos de documento posibles de ventas y compras
Definition: docsvenenum.cs:32
ewDateDoc()
Constructor
Definition: ewDateDoc.cs:123
void _Refresh()
Refrescar objeto para que actualize su contenido en funcion del objeto documento de venta no visual...
Definition: ewDateDoc.cs:101
Interfaz para refrescar los controles de los perfiles
Clase sage.ew.objetos.ewdate