Configuracion.cs
1 using System;
2 using System.Data;
3 using System.Linq;
4 using System.Windows.Forms;
6 using sage.ew.functions;
8 
9 namespace sage.addons.factucert.Visual.UserControls
10 {
11  public partial class Configuracion
12  : sage.ew.ewbase.UserControlConfig
13  {
14  private ConfigFactuCert _oFactuCerConfig;
15 
16  public ConfigFactuCert _FactuCerConfig
17  {
18  get
19  {
20  return _oFactuCerConfig;
21  }
22  set
23  {
24  _oFactuCerConfig = value;
25  }
26  }
27 
28  private ConfigFactuCert.ConfigFactuCertModelo _ConfigFactuCertModelo
29  {
30  get
31  {
32  return _oFactuCerConfig._ConfigFactuCertModelo;
33  }
34  }
35 
36  public Configuracion()
37  {
38  InitializeComponent();
39  }
40 
45  public override void _BloquearControles(bool tlReadOnly)
46  {
47  mtgAcuerdosFacturacion._ReadOnly = tlReadOnly;
48  mtgAcuerdosSistemaInformatico._ReadOnly = tlReadOnly;
49  }
50 
54  public override void _Binding()
55  {
56  this.SubscripcionEventos(false);
57 
58  ConfigFactuCert.ConfigFactuCertModelo.Acuerdos loAcuerdosFacturacion = _ConfigFactuCertModelo._AcuerdosFacturacion;
59  loAcuerdosFacturacion._Grid = mtgAcuerdosFacturacion;
60 
61  ConfigFactuCert.ConfigFactuCertModelo.Acuerdos loAcuerdosSistemaInformatico = _ConfigFactuCertModelo._AcuerdosSistemaInformatico;
62  loAcuerdosSistemaInformatico._Grid = mtgAcuerdosSistemaInformatico;
63 
64  this.SubscripcionEventos(true);
65  }
66 
67  private void Configuracion_Load(object sender, EventArgs e)
68  {
69  return;
70  }
71 
72  private void SubscripcionEventos(bool tlSubscribir)
73  {
74  if (tlSubscribir)
75  {
76  this.mtgAcuerdosFacturacion._Grid.CellClick += MtgAcuerdos_CellClick;
77  this.mtgAcuerdosFacturacion._Grid.CellValueChanged += MtgAcuerdos_CellValueChanged;
78  this.mtgAcuerdosFacturacion._Grid.CurrentCellDirtyStateChanged += _Grid_CurrentCellDirtyStateChanged;
79  this.mtgAcuerdosFacturacion._Row_New_After += new Mantegrid._Row_New_After_Handler(MtgAcuerdos__Row_New_After);
80 
81  this.mtgAcuerdosSistemaInformatico._Grid.CellClick += MtgAcuerdos_CellClick;
82  this.mtgAcuerdosSistemaInformatico._Grid.CellValueChanged += MtgAcuerdos_CellValueChanged;
83  this.mtgAcuerdosSistemaInformatico._Grid.CurrentCellDirtyStateChanged += _Grid_CurrentCellDirtyStateChanged;
84  this.mtgAcuerdosSistemaInformatico._Row_New_After += new Mantegrid._Row_New_After_Handler(MtgAcuerdos__Row_New_After);
85  }
86  else
87  {
88  this.mtgAcuerdosFacturacion._Grid.CellClick -= MtgAcuerdos_CellClick;
89  this.mtgAcuerdosFacturacion._Grid.CellValueChanged -= MtgAcuerdos_CellValueChanged;
90  this.mtgAcuerdosFacturacion._Grid.CurrentCellDirtyStateChanged -= _Grid_CurrentCellDirtyStateChanged;
91  this.mtgAcuerdosFacturacion._Row_New_After -= new Mantegrid._Row_New_After_Handler(MtgAcuerdos__Row_New_After);
92 
93  this.mtgAcuerdosSistemaInformatico._Grid.CellClick -= MtgAcuerdos_CellClick;
94  this.mtgAcuerdosSistemaInformatico._Grid.CellValueChanged -= MtgAcuerdos_CellValueChanged;
95  this.mtgAcuerdosSistemaInformatico._Grid.CurrentCellDirtyStateChanged -= _Grid_CurrentCellDirtyStateChanged;
96  this.mtgAcuerdosSistemaInformatico._Row_New_After -= new Mantegrid._Row_New_After_Handler(MtgAcuerdos__Row_New_After);
97  }
98  }
99 
100  private void _Grid_CurrentCellDirtyStateChanged(object sender, EventArgs e)
101  {
102  if (sender == this.mtgAcuerdosFacturacion._Grid)
103  {
104  if (this.mtgAcuerdosFacturacion._Grid.CurrentCell.ColumnIndex == this.mtgAcuerdosFacturacion._Grid.Columns["_Predet"].Index)
105  {
106  this.mtgAcuerdosFacturacion._Grid.CommitEdit(DataGridViewDataErrorContexts.Commit);
107  }
108  }
109  else
110  {
111  if (this.mtgAcuerdosSistemaInformatico._Grid.CurrentCell.ColumnIndex == this.mtgAcuerdosSistemaInformatico._Grid.Columns["_Predet"].Index)
112  {
113  this.mtgAcuerdosSistemaInformatico._Grid.CommitEdit(DataGridViewDataErrorContexts.Commit);
114  }
115  }
116  }
117 
118  private void MtgAcuerdos__Row_New_After(DataGridViewRow tdgvRowLastInsert, bool tlInsert)
119  {
122 
123  //loCod._Predet = loCods._Items.Count == 1 && !loCod._Predet;
124  }
125 
131  private void MtgAcuerdos_CellClick(object sender, DataGridViewCellEventArgs e)
132  {
133  if (e.RowIndex >= 0)
134  {
135  DataGridViewCell loCell = ((sage.ew.objetos.ewgrid)sender).CurrentCell;
137 
138  if (loCell.OwningColumn.Name == "_Predet")
139  {
140  if (sender == this.mtgAcuerdosFacturacion._Grid)
141  {
142  loCod = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos.Acuerdo)this.mtgAcuerdosFacturacion._Grid.Rows[e.RowIndex].DataBoundItem;
143  }
144  else
145  {
146  loCod = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos.Acuerdo)this.mtgAcuerdosSistemaInformatico._Grid.Rows[e.RowIndex].DataBoundItem;
147  }
148 
150 
151  loCods._RevisarPredeterminado(loCod._Codigo);
152  }
153  }
154  }
155 
162  private void MtgAcuerdos_CellValueChanged(object sender, DataGridViewCellEventArgs e)
163  {
164  if (e.RowIndex >= 0)
165  {
168  DataGridViewCell loCell = ((sage.ew.objetos.ewgrid)sender).CurrentCell;
169 
170  switch (loCell.OwningColumn.Name)
171  {
172  case "_Predet":
173  if (sender == this.mtgAcuerdosFacturacion._Grid)
174  {
175  loCod = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos.Acuerdo)this.mtgAcuerdosFacturacion._Grid.Rows[e.RowIndex].DataBoundItem;
176  }
177  else
178  {
179  loCod = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos.Acuerdo)this.mtgAcuerdosSistemaInformatico._Grid.Rows[e.RowIndex].DataBoundItem;
180  }
181 
183 
184  /*
185  bool exist = (from item in loCods._Items
186  where item._Predet
187  select item).Count() > 0;
188 
189  if(!exist)
190  {
191  FUNCTIONS._MessageBox("Debe haber un registro predeterminado.", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
192  loCell.Value = true;
193  }
194  */
195 
196  break;
197 
198  case "_Codigo":
199  string lcCodigo = string.Empty, lcCodigoAnt = string.Empty;
200 
201  if (loCell.Value != null)
202  lcCodigo = loCell.Value.ToString();
203 
204  if (loCell.Tag != null)
205  lcCodigoAnt = loCell.Tag.ToString();
206 
207  if (lcCodigo != lcCodigoAnt)
208  {
209  string mensaje;
210  if (sender == this.mtgAcuerdosFacturacion._Grid)
211  {
212  loCod = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos.Acuerdo)this.mtgAcuerdosFacturacion._Grid.Rows[e.RowIndex].DataBoundItem;
213  mensaje = "El código de acuerdo de facturación se ha entrado previamente";
214  }
215  else
216  {
217  loCod = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos.Acuerdo)this.mtgAcuerdosSistemaInformatico._Grid.Rows[e.RowIndex].DataBoundItem;
218  mensaje = "El código acuerdo de sistema informático se ha entrado previamente";
219  }
220 
221  loCods = (ConfigFactuCert.ConfigFactuCertModelo.Acuerdos)loCod._Parent;
222 
223  if (loCods._ExisteCodigoAcuerdo(lcCodigo))
224  {
225  FUNCTIONS._MessageBox(mensaje, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, DialogResult.OK);
226 
227  // Restauramos el valor anterior
228  loCell.Value = lcCodigoAnt;
229  }
230  }
231  break;
232  }
233  }
234  }
235  }
236 }
Object _Grid
ewgrid o Mantegrid enlazado a Items
Este es el espacio de nombres de su módulo. Puede encontrar más información y ayuda en el fichero rea...
override void _Binding()
Método para el enlace de controles y datos
void _RevisarPredeterminado(string tcCodigo)
Controlamos que únicamente tengamos un registro predeterminado
override void _BloquearControles(bool tlReadOnly)
Método para bloquear los controles del UserControl
Clase del objeto grid para Sage50
Definition: grid.cs:31
Configuración del módulo FACTUCERT
Definition: classConfig.cs:29
delegate void _Row_New_After_Handler(DataGridViewRow tdgvRowLastInsert, bool tlInsert)
Se dispara despues de insertar una nueva fila
Clase para gestionar los acuerdos de facturación/sistema informático para VERI*FACTU ...
Presenta un datagridview con botones añadir y borrar tipo Mantegrid de Eurowin
Definition: Mantegrid.cs:30