frmStockSeriesBase.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Drawing;
5 using System.Linq;
6 using System.Windows.Forms;
7 using sage.ew.formul.Forms;
8 using sage.ew.global;
9 using sage.ew.docventatpv;
10 using sage.ew.stocks;
12 using sage.ew.interficies;
13 using sage.ew.botones;
14 using System.Diagnostics;
15 using sage.ew.objetos;
16 using sage.ew.db;
17 using System.Threading;
18 using System.Collections.Concurrent;
19 
20 
21 namespace sage.ew.serie.Forms
22 {
23 // /// <summary>
24 // /// Formulario para el inventario de series
25 // /// </summary>
26 // public partial class frmStockSeriesBase : FormSatelite
27 // {
28 // #region Variables
29 
30 // /// <summary>
31 // /// Browser de series
32 // /// </summary>
33 // protected btBrowser _btBrowSeries = new btBrowser();
34 // /// <summary>
35 // /// Mantenimiento de series (Información de la serie)
36 // /// </summary>
37 // protected btMante _btManteFicticio = new btMante();
38 
39 // /// <summary>
40 // /// Broker de operaciones
41 // /// </summary>
42 // private OperationBroker _OpereationBroker
43 // {
44 // get
45 // {
46 // if (_lOpereationBroker == null)
47 // _lOpereationBroker = new OperationBroker();
48 // return _lOpereationBroker;
49 // }
50 // set { _lOpereationBroker = value; }
51 // }
52 // private OperationBroker _lOpereationBroker = null;
53 
54 // //Rendimiento
55 // /// <summary>
56 // /// Objeto LinVenDetSeries en edición
57 // /// </summary>
58 // private LinVenDetSeries _oLinVenDetSerieEnEdicion;
59 
60 // //Rendimiento
61 // /// <summary>
62 // /// Variable para almacenar el índice de fila que estamos editando.
63 // /// Un valor de -1 indica que no se está editando ninguna fila
64 // /// </summary>
65 // private int _nFilaEnEdicion = -1;
66 
67 // //Rendimiento
68 // /// <summary>
69 // /// Indicamos el Commit Scope. False para nivel de celda
70 // /// </summary>
71 // private bool _lrowScopeCommit = true;
72 
73 // /// <summary>
74 // /// Guardará el estado de las series al realizar un _Load para omitir la operación si ya existe
75 // /// </summary>
76 // private ConcurrentDictionary<string, bool> _dicEstadoOriginal = new ConcurrentDictionary<string, bool>();
77 
78 // #endregion Variables
79 
80 // #region Propiedades
81 
82 // /// <summary>
83 // /// Declaro objeto de tipo LinVenDet de series para vincular con la clase.
84 // /// </summary>
85 // public LinVenDet<LinVenDetSeries> _LinVenDetSeries
86 // {
87 // get { return _oLinVenDetSeries; }
88 // set { _oLinVenDetSeries = value; }
89 // }
90 // private LinVenDet<LinVenDetSeries> _oLinVenDetSeries;
91 
92 // /// <summary>
93 // /// Código de artículo
94 // /// </summary>
95 // public string _Articulo { get; set; } = "";
96 
97 // /// <summary>
98 // /// Código de almacén
99 // /// </summary>
100 // public string _Almacen { get; set; } = "";
101 
102 // /// <summary>
103 // /// Devuelve un valor de garantía por defecto para el artículo. (Lazy)
104 // /// </summary>
105 // private DateTime _GarantiaDefecto
106 // {
107 // get
108 // {
109 // if (_dGarantiaDefecto == null)
110 // {
111 // using (articulo.Articulo loArt = new articulo.Articulo(_LinVenDetSeries._Lineas._Articulo))
112 // {
113 // _dGarantiaDefecto = ((DateTime)Convert.ToDateTime(_LinVenDetSeries._Lineas._Fecha)).AddDays(loArt._Garantia);
114 // }
115 // }
116 // return (DateTime)_dGarantiaDefecto;
117 // }
118 // }
119 // private DateTime? _dGarantiaDefecto = null;
120 
121 // #endregion Propiedades
122 
123 // #region Constructores
124 
125 // /// <summary>
126 // /// Contructor por defecto (privado)
127 // /// </summary>
128 // private frmStockSeriesBase()
129 // {
130 // InitializeComponent();
131 // }
132 
133 // /// <summary>
134 // /// Contructor por defecto
135 // /// </summary>
136 // protected frmStockSeriesBase(string pantalla) : this ()
137 // {
138 // InitializeComponent();
139 
140 // _Pantalla = pantalla;
141 // }
142 
143 // #endregion Constructores
144 
145 // #region Métodos Override
146 
147 // /// <summary>
148 // /// Override OnShow
149 // /// </summary>
150 // /// <param name="e"></param>
151 // protected override void OnShown(EventArgs e)
152 // {
153 // base.OnShown(e);
154 
155 // //Obtener datos
156 // ObtenerDatos();
157 
158 // //Hay que hacerlo en el último momento
159 // ReadOnlyControlesInformativos();
160 
161 // //Corrección size
162 // _oPanelFoto.Size = _oPictureboxArticulo.Size = new Size(200, 186);
163 
164 // //Activo los eventos de la casilla para la lectura de series
165 // txtBuscar.Leave += new EventHandler(Evento_txtBuscar_Leave);
166 // txtBuscar.MaxLength = EW_GLOBAL._GetLenCampo("wn_serie"); //Máximo de carácteres
167 // }
168 
169 // /// <summary>
170 // /// Método para escribir una traza
171 // /// </summary>
172 // /// <param name="mensaje"></param>
173 // protected void Traza(string mensaje)
174 // {
175 // Trace.WriteLineIf(Debugger.IsAttached, mensaje, Name);
176 // }
177 
178 // private void ObtenerDatos()
179 // {
180 // if (DesignMode)
181 // return;
182 
183 // DateTime dFechaDocumento = Convert.ToDateTime(_LinVenDetSeries._Lineas._Fecha);
184 
185 // //Datos resumen de serie
186 // _oGridResumen.Columns.Clear();
187 // _oGridResumen.DataSource = Serie._ResumenSeries(_otxtArticulo._Codigo, _otxtAlmacen._Codigo, dFechaDocumento);
188 
189 // _PanelResumen._Titulo = "Resumen a " + dFechaDocumento.ToString(EW_GLOBAL._CustomFormatDate);
190 
191 // //Establezco el origen de los datos
192 // _oManteGrid._Grid.DataSource = _LinVenDetSeries._lisCodigos;
193 
194 // //Bloqueo los códigos que provienen de BBDD
195 // _dicEstadoOriginal.Clear();
196 // foreach (DataGridViewRow ldrRow in _oManteGrid._Grid.Rows)
197 // {
198 // LinVenDetSeries loLinea = (LinVenDetSeries)ldrRow.DataBoundItem;
199 // ldrRow.Cells["_Codigo"].ReadOnly = ldrRow.Cells["_Garantia"].ReadOnly = loLinea._RegistroAlmacenado;
200 // //Me guardo el estado por si finalmente no cambia
201 // if(!String.IsNullOrWhiteSpace(loLinea._Codigo) && !_dicEstadoOriginal.ContainsKey(loLinea._Codigo)) //No espero duplicados pero nunca se sabe
202 // _dicEstadoOriginal.AddOrUpdate(loLinea._Codigo, loLinea._Baja, (key, oldval) => loLinea._Baja);
203 // }
204 
205 
206 
207 // _oManteGrid._DataSource_Row_New_Event += new Mantegrid._DataSource_Row_New_Event_Handler(Evento_DataSource_NewRow);
208 // _oManteGrid._DataSource_Row_Delete_Event += new Mantegrid._DataSource_Row_Delete_Event_Handler(Evento_DataSource_DeleteRow);
209 
210 // //Me suscribo a los eventos de edición
211 // _oManteGrid._Grid.CellBeginEdit += new DataGridViewCellCancelEventHandler(Evento_Grid_CellBeginEdit);
212 // _oManteGrid._Grid.CellEndEdit += new DataGridViewCellEventHandler(Evento_Grid_CellEndEdit);
213 
214 // _oManteGrid._F4_BeforeClick += new Mantegrid._F4_BeforeClick_Handler(Evento_oManteGrid__F4_BeforeClick);
215 // _oManteGrid._F5_BeforeClick += new Mantegrid._F5_BeforeClick_Handler(Evento_Grid__F5_KeyPress); //F5 sobre el grid
216 
217 // // Configurem el browser
218 // _btBrowSeries._Clave = "SERIE";
219 // _btBrowSeries._Tabla = "COMPRAS";
220 // _btBrowSeries._DataBase = "COMUNES";
221 // _btBrowSeries._Titulo = "Series";
222 // _btBrowSeries._Titulos_Campos = "Series, Baja, Fecha de compra, Garantía";
223 // _btBrowSeries._Campo_Predet = "SERIE";
224 // _btBrowSeries._Campos = "SERIE, BAJA, FECHA, GARANTIA";
225 // _oManteGrid._TeclaF4("_Codigo", _btBrowSeries);
226 // _oManteGrid._TeclaF5("_Codigo", _btManteFicticio);
227 // _btManteFicticio._Click_Before += new btMante._Click_Before_Handler(Evento_oManteGrid__F5_BeforeClick); //Click sobre el boton
228 // }
229 
230 // /// <summary>
231 // /// Evento F5 sobre el mantegrid
232 // /// </summary>
233 // /// <param name="sender"></param>
234 // /// <param name="toMante"></param>
235 // void Evento_Grid__F5_KeyPress(object sender, ref btMante toMante)
236 // {
237 // //Muestro el formulario de información de la serie
238 // MostrarInformacionSerie();
239 // }
240 
241 // /// <summary>
242 // /// Evento F5 sobre el mantegrid
243 // /// </summary>
244 // /// <param name="tlOk">False para parar la ejecución</param>
245 // void Evento_oManteGrid__F5_BeforeClick(ref bool tlOk)
246 // {
247 // //Paro la ejecución => Ya ha pasado por Evento_oManteGrid__F5_KeyPress y no ha de hacer nada más
248 // tlOk = false;
249 // }
250 
251 // /// <summary>
252 // /// Evento F4 Sobre el grid
253 // /// </summary>
254 // /// <param name="sender"></param>
255 // /// <param name="toBrowser"></param>
256 // void Evento_oManteGrid__F4_BeforeClick(object sender, ref botones.btBrowser toBrowser)
257 // {
258 // _btBrowSeries._Titulo = "Series en el almacén " + _otxtAlmacen._Codigo +
259 // " anteriores a " + ((DateTime)Convert.ToDateTime(_LinVenDetSeries._Lineas._Fecha)).ToString(EW_GLOBAL._CustomFormatDate);
260 // _btBrowSeries._Condicion = "almacen = " + DB.SQLString(_otxtAlmacen._Codigo) +
261 // " AND ARTICULO = " + DB.SQLString(_LinVenDetSeries._Lineas._Articulo) +
262 // " AND FECHA <= " + DB.SQLString(_LinVenDetSeries._Lineas._Fecha);
263 
264 // //Bug 112747 Duplicación de series por F4 => Creo una lista de exclusión de los elementos que ya tengo
265 // string lcTempCondicion = string.Empty;
266 // foreach (LinVenDetSeries loElemento in _LinVenDetSeries._lisCodigos.Where(loSerie => !string.IsNullOrEmpty(loSerie._Codigo)))
267 // {
268 // if (!string.IsNullOrEmpty(lcTempCondicion)) lcTempCondicion += ","; //Si no es el primer elemento
269 // lcTempCondicion += DB.SQLString(loElemento._Codigo.Trim());
270 // }
271 // if (!string.IsNullOrEmpty(lcTempCondicion))
272 // _btBrowSeries._Condicion += " AND SERIE NOT IN (" + lcTempCondicion + ")";
273 
274 // if (!_oManteGrid._Grid.CurrentCell.IsInEditMode)
275 // {
276 // _oManteGrid._Grid.CellValueChanged -= new DataGridViewCellEventHandler(Evento_CellValueChangedConBtBrowser); //por si han cancelado
277 // _oManteGrid._Grid.CellValueChanged += new DataGridViewCellEventHandler(Evento_CellValueChangedConBtBrowser);
278 // }
279 // }
280 
281 // void Evento_CellValueChangedConBtBrowser(object sender, DataGridViewCellEventArgs e)
282 // {
283 // if (sender != null && e.ColumnIndex == _oManteGrid._Grid.Columns["_Codigo"].Index)
284 // {
285 // ComprobarExistenciaSerie(_oManteGrid._Grid.Rows[e.RowIndex]);
286 // _oManteGrid._Grid.CellValueChanged -= new DataGridViewCellEventHandler(Evento_CellValueChangedConBtBrowser);
287 // }
288 // }
289 
290 // /// <summary>
291 // /// Respuesta al evento de inicio de edición
292 // /// </summary>
293 // /// <param name="sender"></param>
294 // /// <param name="e"></param>
295 // void Evento_Grid_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
296 // {
297 // //Si se trata de la columna del código
298 // if (e.ColumnIndex == _oManteGrid._Grid.Columns["_Codigo"].Index)
299 // {
300 // //En este momento he entrado en una celda de _codigo no informado y tengo que añadir el dígito de control
301 // ((LinVenDetSeries)_oManteGrid._Grid.Rows[e.RowIndex].DataBoundItem)._Evento_Validacion_Codigo_Before += new LinVenDetSeries._Validacion_Codigo_Handler(Evento_Validacion_Codigo_Before);
302 // }
303 // }
304 
305 // void Evento_Validacion_Codigo_Before(object sender, ValidationEventArgs e)
306 // {
307 // if (sender == null)
308 // return;
309 // //Verifico que no este en la lista
310 // e._Cancel = _oLinVenDetSeries._lisCodigos.Count(loEle => loEle._Codigo == e._Serie) == 1;
311 // if (e._Cancel)
312 // e._Mensaje = String.Format("La serie {0} ya se encuentra en la lista.", e._Serie);
313 // }
314 
315 // /// <summary>
316 // /// Respuesta al evento de finalización de edición
317 // /// </summary>
318 // /// <param name="sender"></param>
319 // /// <param name="e"></param>
320 // void Evento_Grid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
321 // {
322 // if (sender == null)
323 // return;
324 
325 // //Si se trata de la columna del código
326 // if (e.ColumnIndex == _oManteGrid._Grid.Columns["_Codigo"].Index)
327 // {
328 // //Verifico si la serie existe
329 // ComprobarExistenciaSerie(((ewgrid)sender).Rows[e.RowIndex]);
330 
331 // ((LinVenDetSeries)_oManteGrid._Grid.Rows[e.RowIndex].DataBoundItem)._Evento_Validacion_Codigo_Before -= new LinVenDetSeries._Validacion_Codigo_Handler(Evento_Validacion_Codigo_Before);
332 // }
333 // }
334 
335 // /// <summary>
336 // /// Respuesta al evento de borrado de líneas
337 // /// </summary>
338 // /// <param name="trRowDelete"></param>
339 // void Evento_DataSource_DeleteRow(DataGridViewRow trRowDelete)
340 // {
341 // //Determino si la línea proviene de BBDD
342 // if (trRowDelete.Cells["_RegistroAlmacenado"].Value != null && (bool)trRowDelete.Cells["_RegistroAlmacenado"].Value == true)
343 // {
344 // Traza("Suprimir del grid serie existente.");
345 
346 // //El registro existe en BBDD => hay que añadir la operación de anulación de la operación al broker
347 
348 // LinVenDetSeries loLinVenDet = (LinVenDetSeries)trRowDelete.DataBoundItem;
349 // SerieDocStockInventario loSerie = new SerieDocStockInventario(loLinVenDet._Codigo, _oLinVenDetSeries._Lineas);
350 
351 // if (trRowDelete.Cells["_Baja"].Value != null && (bool)trRowDelete.Cells["_Baja"].Value == true)
352 // {
353 // _OpereationBroker._AddOperacion(new CancelarBajaInventarioStockOp(loSerie));
354 // Traza($"Añadida operacion de CANCELAR BAJA al broker para la serie {loLinVenDet._Codigo}");
355 // }
356 // else
357 // {
358 // _OpereationBroker._AddOperacion(new CancelarAltaInventarioStockOp(loSerie));
359 // Traza($"Añadida operacion de CANCELAR ALTA al broker para la serie {loLinVenDet._Codigo}");
360 // }
361 // }
362 // else
363 // {
364 // Traza("Suprimir inventario serie ficticia (inexistente).");
365 // }
366 
367 // //Suprimo de la lista
368 // _oLinVenDetSeries._lisCodigos.Remove((LinVenDetSeries)trRowDelete.DataBoundItem);
369 // }
370 
371 // /// <summary>
372 // /// Respuesta al evento de añadir líneas
373 // /// </summary>
374 // /// <param name="tnInsertLinea"></param>
375 // void Evento_DataSource_NewRow(int tnInsertLinea)
376 // {
377 // //No permito añadir mas de una linea en blanco
378 // if (_LinVenDetSeries._lisCodigos.Count(ele => string.IsNullOrEmpty(ele._Codigo)) > 0)
379 // return;
380 
381 // AddLinVenDet("");
382 // }
383 
384 // /// <summary>
385 // /// Respuesta al evento de salida del textbox de insertar series
386 // /// </summary>
387 // /// <param name="sender"></param>
388 // /// <param name="e"></param>
389 // void Evento_txtBuscar_Leave(object sender, EventArgs e)
390 // {
391 // ewtextbox loTxtBox = (ewtextbox)sender;
392 // string lcMensaje = string.Empty;
393 
394 // // Código de barras tecleado ...
395 // string numeroDeSerie = loTxtBox.Text.Trim();
396 // if (!String.IsNullOrWhiteSpace(numeroDeSerie))
397 // {
398 // if (_oLinVenDetSeries._lisCodigos.Count(loEle => loEle._Codigo == numeroDeSerie) == 1)
399 // {
400 // DataGridViewRow row = _oManteGrid._Grid.Rows
401 // .Cast<DataGridViewRow>()
402 // .Where(loRow => loRow.Cells["_Codigo"].Value != null && loRow.Cells["_Codigo"].Value.ToString().Equals(numeroDeSerie))
403 // .First();
404 
405 // _oManteGrid._Grid.CurrentCell = _oManteGrid._Grid["_Codigo", row.Index];
406 // }
407 // else
408 // {
409 // using(SerieDocStockInventario loSerie = new SerieDocStockInventario())
410 // {
411 // //Realizo las validaciones para el código
412 // string lcErrorMessage = "";
413 // if (!loSerie._ComprobarValor(numeroDeSerie, false, _oLinVenDetSeries._Lineas, ref lcErrorMessage))
414 // {
415 // _MessageBox(lcErrorMessage, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DialogResult.None);
416 // }
417 // else
418 // {
419 // if (TengoHuecosEnLasLineas())
420 // {
421 // LinVenDetSeries lineaVacia = ObtenerPrimeraLineaVacia();
422 // lineaVacia._Codigo = numeroDeSerie;
423 // EstablecerGarantia(lineaVacia, numeroDeSerie);
424 // }
425 // else
426 // {
427 // LinVenDetSeries loNewItem = new LinVenDetSeries(_oLinVenDetSeries._Lineas as IDocumentLinea, numeroDeSerie, _oLinVenDetSeries.__ObtenerNuevaPosicion())
428 // {
429 // _Existe = new Serie(numeroDeSerie)._Disponible() != null
430 // };
431 // EstablecerGarantia(loNewItem, numeroDeSerie);
432 // _oLinVenDetSeries._lisCodigos.Add(loNewItem);
433 // }
434 // }
435 // }
436 
437 // }
438 // loTxtBox.Text = "";
439 // }
440 // }
441 
442 // /// <summary>
443 // /// Método privado para establecer la garantía de una serie
444 // /// </summary>
445 // /// <param name="LineaSeries"></param>
446 // /// <param name="NumeroDeSerie"></param>
447 // private void EstablecerGarantia(LinVenDetSeries LineaSeries, string NumeroDeSerie)
448 // {
449 // if (!LineaSeries._Existe) //Bug 112788
450 // LineaSeries._Garantia = _GarantiaDefecto;
451 // else
452 // LineaSeries._Garantia = Serie._ObtenerGarantia(NumeroDeSerie);
453 // }
454 
455 // private LinVenDetSeries ObtenerPrimeraLineaVacia()
456 // {
457 // return _oLinVenDetSeries._lisCodigos.Where(linea => String.IsNullOrWhiteSpace(linea._Codigo)).First();
458 // }
459 
460 // private bool TengoHuecosEnLasLineas()
461 // {
462 // return _oLinVenDetSeries._lisCodigos.Where(linea => String.IsNullOrWhiteSpace(linea._Codigo)).ToList().Any();
463 // }
464 
465 // /// <summary>
466 // /// Click al botón de Aceptar
467 // /// </summary>
468 // /// <param name="sender"></param>
469 // /// <param name="e"></param>
470 // private void Evento_btDocAceptar1_Click(object sender, EventArgs e)
471 // {
472 // Traza("Click en Aceptar.");
473 
474 // FormClosing -= new FormClosingEventHandler(Evento_FormClosing);
475 
476 // DialogResult lodialog = new DialogResult();
477 // string tcMensaje = "";
478 
479 // //Compruebo que tenga todas las series
480 // lodialog = DialogResult.Yes;
481 // if (Comprobar_FaltanSeries(ref tcMensaje))
482 // {
483 // lodialog = _MessageBox(tcMensaje + Environment.NewLine + Environment.NewLine +
484 // "¿Desea continuar de todos modos?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, DialogResult.Yes);
485 // }
486 
487 
488 // if (lodialog == DialogResult.Yes)
489 // {
490 // _GrabarSeries();
491 // }
492 // else
493 // {
494 // DialogResult = DialogResult.None;
495 
496 // //Restablezco el control de cierre por la X
497 // FormClosing += new FormClosingEventHandler(Evento_FormClosing);
498 // }
499 // }
500 
501 // /// <summary>
502 // /// Función auxiliar para comprobar la falta de series
503 // /// </summary>
504 // /// <param name="tcMensaje">Mensaje con el texto del error si corresponde</param>
505 // /// <returns>True si faltan series</returns>
506 // private bool Comprobar_FaltanSeries(ref string tcMensaje)
507 // {
508 // Traza("Comprobando si faltan series...");
509 
510 // bool llError = false;
511 
512 // DataTable ldtSeriesFaltan = new DataTable();
513 // int lnCuantasFaltan = ObtenerSeriesRestantes(ref ldtSeriesFaltan);
514 
515 // if(lnCuantasFaltan > 0)
516 // {
517 // tcMensaje = "No ha introducido todas las series correctamente. " + Environment.NewLine +
518 // String.Format("Quedan {0} series a las que definir su estado.",lnCuantasFaltan) + Environment.NewLine +
519 // "En caso de que no se defina quedarán en estado de alta.";
520 // llError = true;
521 // }
522 // return llError;
523 // }
524 
525 // /// <summary>
526 // /// Método que ordena y graba las series
527 // /// </summary>
528 // private void _GrabarSeries()
529 // {
530 // #region Grabar resultados ordenados
531 
532 // //Paso a una lista mis elemntos (descartando los nulos) ordenados por SERIE
533 // List<LinVenDetSeries> loList = _LinVenDetSeries._lisCodigos
534 // .Where(loSerie => !string.IsNullOrEmpty(loSerie._Codigo))
535 // .OrderBy(loEle => loEle._Codigo).ToList();
536 
537 // int lnPos = 1;
538 
539 // //Asigno a los elementos de la lista el nuevo orden relativo.
540 // foreach (LinVenDetSeries loElement in loList)
541 // {
542 // _LinVenDetSeries._lisCodigos[_LinVenDetSeries._lisCodigos.IndexOf(loElement)]._Posicion = lnPos;
543 // lnPos++;
544 // }
545 
546 // #endregion Grabar resultados ordenados
547 
548 // Traza($"Lista de series no vacias con {loList.Count} elementos ");
549 
550 // //Añado las operaciones al broker
551 // loList.ForEach(loEle => LoadAddOperation(loEle));
552 
553 // //Ejecutamos => Las operaciones de las líneas y las que pudiera haber de borrado de líneas existentes
554 // _OpereationBroker._EjecutarOperaciones();
555 // }
556 
557 // /// <summary>
558 // /// Método auxiliar para determinar y añadir al broker la operación necesaria en base al campo BAJA de la serie
559 // /// </summary>
560 // /// <param name="toLinVenDet"></param>
561 // private void LoadAddOperation(LinVenDetSeries toLinVenDet)
562 // {
563 // SerieDocStockInventario loSerie = new SerieDocStockInventario(toLinVenDet._Codigo, _oLinVenDetSeries._Lineas)
564 // {
565 // _Garantia = toLinVenDet._Garantia
566 // };
567 
568 // if (_dicEstadoOriginal.ContainsKey(loSerie._Codigo) && _dicEstadoOriginal[loSerie._Codigo] == toLinVenDet._Baja)
569 // {
570 // Traza($"Thread {Thread.CurrentThread.ManagedThreadId} => La serie {toLinVenDet._Codigo} no ha cambiado. No se añade ninguna operación.");
571 // return;
572 // }
573 
574 // if (toLinVenDet._Baja)
575 // {
576 // _OpereationBroker._AddOperacion(new BajaInventarioStockOp(loSerie));
577 // Traza($"Thread {Thread.CurrentThread.ManagedThreadId} => Añadida operacion de BAJA al broker para la serie {toLinVenDet._Codigo}");
578 // }
579 // else
580 // {
581 // _OpereationBroker._AddOperacion(new AltaInventarioStockOp(loSerie));
582 // Traza($"Thread {Thread.CurrentThread.ManagedThreadId} => Añadida operacion de ALTA al broker para la serie {toLinVenDet._Codigo}");
583 // }
584 // }
585 
586 // /// <summary>
587 // /// Click al botón de Cancelar
588 // /// </summary>
589 // /// <param name="sender"></param>
590 // /// <param name="e"></param>
591 // private void Evento_btDocCancelar1_Click(object sender, EventArgs e)
592 // {
593 // FormClosing -= new FormClosingEventHandler(Evento_FormClosing);
594 
595 // DialogResult lodialog = new DialogResult();
596 // lodialog = DialogResult.Yes;
597 
598 // if (lodialog == DialogResult.Yes)
599 // {
600 // _LinVenDetSeries._lisCodigos.Clear();
601 // _LinVenDetSeries._Load(); //Restablezco lo que teniamos guardado
602 // }
603 // else
604 // {
605 // DialogResult = DialogResult.None;
606 
607 // //Restablezco el control de cierre por la X
608 // FormClosing += new FormClosingEventHandler(Evento_FormClosing);
609 // }
610 // }
611 
612 
613 // /// <summary>
614 // /// Respuesta al evento de cierre de formulario
615 // /// </summary>
616 // /// <param name="sender"></param>
617 // /// <param name="e"></param>
618 // void Evento_FormClosing(object sender, FormClosingEventArgs e)
619 // {
620 // //Si esta cerrando el usuario
621 // if (e.CloseReason == CloseReason.UserClosing)
622 // {
623 // Trace.WriteLineIf(Debugger.IsAttached, "frmInventarioSeries => Cerrar formulario.");
624 
625 // //Estan saliendo por la X o Alt + F4
626 // string lcMensaje = "";
627 
628 // if (Comprobar_FaltanSeries(ref lcMensaje))
629 // {
630 // DialogResult lodialog = new DialogResult();
631 // lodialog = DialogResult.Yes;
632 
633 // lodialog = _MessageBox(lcMensaje + Environment.NewLine + Environment.NewLine +
634 // "¿Desea continuar de todos modos?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, DialogResult.Yes);
635 
636 // //Bloqueo la salida si no ha dicho que quiere continuar
637 // e.Cancel = (lodialog != DialogResult.Yes);
638 // }
639 // }
640 // }
641 
642 // /// <summary>
643 // /// Método Load
644 // /// </summary>
645 // /// <param name="e"></param>
646 // protected override void OnLoad(EventArgs e)
647 // {
648 // base.OnLoad(e);
649 
650 // PrepararFormulario();
651 // }
652 
653 // #endregion Métodos Override
654 
655 // /// <summary>
656 // /// Función que prepara el formulario
657 // /// </summary>
658 // private void PrepararFormulario()
659 // {
660 //#if ewTools //Rendimiento
661 // EwTools._WriteTrace(EwTools.eMethodStatus.Inicio);
662 //#endif
663 
664 // //Si no tengo objeto series termino.
665 // if (_oLinVenDetSeries == null) return;
666 
667 // _otxtArticulo._Codigo = _LinVenDetSeries._Lineas._Articulo;
668 // _otxtAlmacen._Codigo = ((StockInventario)_LinVenDetSeries._Lineas._StockINV)._Almacen;
669 
670 // Preparar_Grid();
671 
672 // //Monto la botonera
673 // MontarBotones();
674 
675 // //Recupero la imágen
676 // RecuperarImagen();
677 
678 // //Control de cierre por la X
679 // FormClosing += new FormClosingEventHandler(Evento_FormClosing);
680 
681 //#if ewTools //Rendimiento
682 // EwTools._WriteTrace(EwTools.eMethodStatus.Fin);
683 //#endif
684 // }
685 
686 // /// <summary>
687 // /// Función para preparar el Grid
688 // /// Crea las columnas, valida los datos
689 // /// </summary>
690 // private void Preparar_Grid()
691 // {
692 //#if ewTools //Rendimiento
693 // EwTools._WriteTrace(EwTools.eMethodStatus.Inicio);
694 //#endif
695 
696 // //PE-100009 Miro si tengo códigos... Sino hay códigos prefijaré valores de una forma que no necesite calcular los valores
697 // bool llSinSeries = (_LinVenDetSeries._lisCodigos.Where(loSerie => !string.IsNullOrEmpty(loSerie._Codigo)).Count() == 0);
698 
699 // //Llamo al método que crea las columnas
700 // Preparar_Grid_CrearColumnas(llSinSeries);
701 
702 // //Establezco el origen de los datos
703 // _oManteGrid._Grid.DataSource = _LinVenDetSeries._lisCodigos;
704 
705 //#if ewTools //Rendimiento
706 // EwTools._WriteTrace(EwTools.eMethodStatus.Fin);
707 //#endif
708 // }
709 
710 // /// <summary>
711 // /// Método auxiliar para crear las columnas
712 // /// </summary>
713 // private void Preparar_Grid_CrearColumnas(bool tlSinSeries)
714 // {
715 
716 // //Configuro el mantegrid para que no me genere las columnas automaticamente.
717 // _oManteGrid._Grid.AutoGenerateColumns = false;
718 // _oManteGrid._RecuadroVisible = false;
719 
720 // //Definimos las propiedades de las columnas que vamos a utilizar.
721 // #region DefinicionColumnasGrid
722 
723 // #region Posicion
724 
725 // using (Mantegrid.ewDataGridViewTextBoxColumn ldgtbColUnidades = new Mantegrid.ewDataGridViewTextBoxColumn())
726 // {
727 // ldgtbColUnidades.Name = "_Posicion";
728 // ldgtbColUnidades.DataPropertyName = "_Posicion";
729 // ldgtbColUnidades.HeaderText = "Número";
730 // ldgtbColUnidades.ValueType = typeof(int);
731 // ldgtbColUnidades.Visible = true;
732 // ldgtbColUnidades._NoParar = true;
733 // ldgtbColUnidades.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
734 // ldgtbColUnidades.ToolTipText = "Número de series requeridas.";
735 
736 
737 // //PE-78508 Se establece readonly para no dejar de modificar el campo
738 // ldgtbColUnidades.ReadOnly = true;
739 // this._oManteGrid._Grid.Columns.Add(ldgtbColUnidades);
740 // }
741 
742 // #endregion Posicion
743 
744 // #region Serie
745 
746 // using (Mantegrid.ewDataGridViewTextBoxColumn ldgtbColSerie = new Mantegrid.ewDataGridViewTextBoxColumn())
747 // {
748 // ldgtbColSerie.Name = "_Codigo";
749 // ldgtbColSerie.DataPropertyName = "_Codigo";
750 // ldgtbColSerie.HeaderText = "Series";
751 // ldgtbColSerie.ValueType = typeof(string);
752 // ldgtbColSerie.Visible = true;
753 // ldgtbColSerie._NoParar = false;
754 // ldgtbColSerie.ReadOnly = false; // !tlSinSeries; //PE-100009 Si no hay series ReadOnly a false
755 // ldgtbColSerie.MaxInputLength = sage.ew.global.EW_GLOBAL._GetLenCampo("wn_serie");
756 // ldgtbColSerie.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
757 // ldgtbColSerie.ToolTipText = "Código de la Serie.";
758 // this._oManteGrid._Grid.Columns.Add(ldgtbColSerie);
759 // }
760 
761 // #endregion Serie
762 
763 // #region Existe
764 
765 // using (Mantegrid.ewDataGridViewCheckBoxColumn ldgtbColExiste = new Mantegrid.ewDataGridViewCheckBoxColumn())
766 // {
767 // ldgtbColExiste.Name = "_Existe";
768 // ldgtbColExiste.HeaderText = "Existe";
769 // ldgtbColExiste.DataPropertyName = "_Existe";
770 // ldgtbColExiste.ValueType = typeof(bool);
771 // ldgtbColExiste.Visible = false;
772 // ldgtbColExiste._NoParar = true;
773 // ldgtbColExiste.ReadOnly = true;
774 
775 // //PE-100009 Prefijo valores para rendimiento
776 // ldgtbColExiste.TrueValue = true;
777 // ldgtbColExiste.IndeterminateValue = false;
778 // ldgtbColExiste.FalseValue = false;
779 
780 // ldgtbColExiste.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
781 // ldgtbColExiste.ToolTipText = "Existencia de la Serie.";
782 // this._oManteGrid._Grid.Columns.Add(ldgtbColExiste);
783 // }
784 
785 // #endregion Existe
786 
787 // #region Baja
788 
789 // using (Mantegrid.ewDataGridViewCheckBoxColumn ldgtbColBaja = new Mantegrid.ewDataGridViewCheckBoxColumn())
790 // {
791 // ldgtbColBaja.Name = "_Baja";
792 // ldgtbColBaja.HeaderText = "Baja";
793 // ldgtbColBaja.DataPropertyName = "_Baja";
794 // ldgtbColBaja.ValueType = typeof(bool);
795 // ldgtbColBaja.Visible = true;
796 // ldgtbColBaja._NoParar = true;
797 // ldgtbColBaja.ReadOnly = false;
798 
799 // //Prefijo valores para rendimiento
800 // ldgtbColBaja.TrueValue = true;
801 // ldgtbColBaja.IndeterminateValue = false;
802 // ldgtbColBaja.FalseValue = false;
803 
804 // ldgtbColBaja.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
805 // ldgtbColBaja.ToolTipText = "Estado de la serie.";
806 // this._oManteGrid._Grid.Columns.Add(ldgtbColBaja);
807 // }
808 
809 // #endregion Baja
810 
811 // #region RegistroAlmacenado
812 
813 // using (Mantegrid.ewDataGridViewCheckBoxColumn ldgtbColRegistroAlmacenado = new Mantegrid.ewDataGridViewCheckBoxColumn())
814 // {
815 // ldgtbColRegistroAlmacenado.Name = "_RegistroAlmacenado";
816 // ldgtbColRegistroAlmacenado.HeaderText = "RegistroAlmacenado";
817 // ldgtbColRegistroAlmacenado.DataPropertyName = "_RegistroAlmacenado";
818 // ldgtbColRegistroAlmacenado.ValueType = typeof(bool);
819 // ldgtbColRegistroAlmacenado.Visible = false;
820 // ldgtbColRegistroAlmacenado._NoParar = true;
821 // ldgtbColRegistroAlmacenado.ReadOnly = true;
822 
823 // //Prefijo valores para rendimiento
824 // ldgtbColRegistroAlmacenado.TrueValue = true;
825 // ldgtbColRegistroAlmacenado.IndeterminateValue = false;
826 // ldgtbColRegistroAlmacenado.FalseValue = false;
827 
828 // ldgtbColRegistroAlmacenado.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
829 // ldgtbColRegistroAlmacenado.ToolTipText = "Registro almacenado.";
830 // this._oManteGrid._Grid.Columns.Add(ldgtbColRegistroAlmacenado);
831 // }
832 
833 // #endregion RegistroAlmacenado
834 
835 // #region Garantia
836 
837 // using (Mantegrid.CalendarColumn ldgtbColGarantia = new Mantegrid.CalendarColumn())
838 // {
839 // ldgtbColGarantia.Name = "_Garantia";
840 // ldgtbColGarantia.HeaderText = "Garantía";
841 // ldgtbColGarantia.DataPropertyName = "_Garantia";
842 // ldgtbColGarantia.ValueType = typeof(DateTime);
843 // ldgtbColGarantia.Visible = true;
844 // ldgtbColGarantia._NoParar = true;
845 // ldgtbColGarantia.ReadOnly = false;
846 // ldgtbColGarantia.MinimumWidth = 80;
847 // ldgtbColGarantia.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
848 // ldgtbColGarantia.ToolTipText = "Fecha de finalización de la garantía";
849 
850 // this._oManteGrid._Grid.Columns.Add(ldgtbColGarantia);
851 // }
852 
853 // #endregion Garantia
854 
855 // #endregion DefinicionColumnasGrid
856 
857 // //Rendimiento
858 // #region VirtualMode
859 
860 // if (!tlSinSeries)
861 // {
862 
863 // _oManteGrid._Grid.VirtualMode = true;
864 // _oManteGrid._Grid.RowHeadersVisible = false;
865 // _oManteGrid._Grid.CellValueNeeded += new DataGridViewCellValueEventHandler(EventoDeGrid_CellValueNeeded);
866 // _oManteGrid._Grid.CellValuePushed += new DataGridViewCellValueEventHandler(EventoDeGrid_CellValuePushed);
867 // _oManteGrid._Grid.NewRowNeeded += new DataGridViewRowEventHandler(EventoDeGrid_NewRowNeeded);
868 // _oManteGrid._Grid.RowValidated += new DataGridViewCellEventHandler(EventoDeGrid_RowValidated);
869 // _oManteGrid._Grid.RowDirtyStateNeeded += new QuestionEventHandler(EventoDeGrid_RowDirtyStateNeeded);
870 // _oManteGrid._Grid.CancelRowEdit += new QuestionEventHandler(EventoDeGrid_CancelRowEdit);
871 // _oManteGrid._Grid.UserDeletingRow += new DataGridViewRowCancelEventHandler(EventoDeGrid_UserDeletingRow);
872 
873 // // Set the row count, including the row for new records.
874 // _oManteGrid._Grid.RowCount = _LinVenDetSeries._lisCodigos.Count;// +1;
875 // }
876 
877 // #endregion VirtualMode
878 // }
879 
880 
881 // #region Eventos VirtualMode para rendimiento
882 
883 // //Rendimiento
884 // /// <summary>
885 // /// Evento de borrado de fila por parte del usuario
886 // /// </summary>
887 // /// <param name="sender"></param>
888 // /// <param name="e"></param>
889 // void EventoDeGrid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
890 // {
891 // if (e.Row.Index < this._LinVenDetSeries._lisCodigos.Count)
892 // {
893 // // Si se borra una línea existente borramos el correspondiente objeto LinVenDetSerie de los datos
894 // this._LinVenDetSeries._lisCodigos.RemoveAt(e.Row.Index);
895 // }
896 
897 // if (e.Row.Index == this._nFilaEnEdicion)
898 // {
899 // // Si el objeto que se borra es nuevo liberamos el objeto LinVenDetSerie
900 // this._nFilaEnEdicion = -1;
901 // this._oLinVenDetSerieEnEdicion = null;
902 // }
903 // }
904 
905 // //Rendimiento
906 // /// <summary>
907 // /// Evento de cancelación de edición
908 // /// </summary>
909 // /// <param name="sender"></param>
910 // /// <param name="e"></param>
911 // void EventoDeGrid_CancelRowEdit(object sender, QuestionEventArgs e)
912 // {
913 // if (this._nFilaEnEdicion == _oManteGrid._Grid.Rows.Count - 2 &&
914 // this._nFilaEnEdicion == this._LinVenDetSeries._lisCodigos.Count)
915 // {
916 // // If the user has canceled the edit of a newly created row,
917 // // replace the corresponding Customer object with a new, empty one.
918 // this._oLinVenDetSerieEnEdicion = new LinVenDetSeries();
919 // }
920 // else
921 // {
922 // // If the user has canceled the edit of an existing row,
923 // // release the corresponding Customer object.
924 // this._oLinVenDetSerieEnEdicion = null;
925 // this._nFilaEnEdicion = -1;
926 // }
927 // }
928 
929 // //Rendimiento
930 // /// <summary>
931 // /// Evento de modificación de celda (para confimaciones a nivel de celda)
932 // /// </summary>
933 // /// <param name="sender"></param>
934 // /// <param name="e"></param>
935 // void EventoDeGrid_RowDirtyStateNeeded(object sender, QuestionEventArgs e)
936 // {
937 // if (!_lrowScopeCommit)
938 // {
939 // // In cell-level commit scope, indicate whether the value
940 // // of the current cell has been modified.
941 // e.Response = _oManteGrid._Grid.IsCurrentCellDirty;
942 // }
943 // }
944 
945 // //Rendimiento
946 // /// <summary>
947 // /// Evento de validación de fila
948 // /// </summary>
949 // /// <param name="sender"></param>
950 // /// <param name="e"></param>
951 // void EventoDeGrid_RowValidated(object sender, DataGridViewCellEventArgs e)
952 // {
953 // // Save row changes if any were made and release the edited
954 // // Customer object if there is one.
955 // if (e.RowIndex >= this._LinVenDetSeries._lisCodigos.Count &&
956 // e.RowIndex != _oManteGrid._Grid.Rows.Count - 1)
957 // {
958 // // Add the new Customer object to the data store.
959 // this._LinVenDetSeries._lisCodigos.Add(this._oLinVenDetSerieEnEdicion);
960 // this._oLinVenDetSerieEnEdicion = null;
961 // this._nFilaEnEdicion = -1;
962 // }
963 // else if (this._oLinVenDetSerieEnEdicion != null &&
964 // e.RowIndex < this._LinVenDetSeries._lisCodigos.Count)
965 // {
966 // // Save the modified Customer object in the data store.
967 // this._LinVenDetSeries._lisCodigos[e.RowIndex] = this._oLinVenDetSerieEnEdicion;
968 // this._oLinVenDetSerieEnEdicion = null;
969 // this._nFilaEnEdicion = -1;
970 // }
971 // else if (_oManteGrid._Grid.ContainsFocus)
972 // {
973 // this._oLinVenDetSerieEnEdicion = null;
974 // this._nFilaEnEdicion = -1;
975 // }
976 // }
977 
978 // //Rendimiento
979 // /// <summary>
980 // /// Evento solicitud de nueva fila
981 // /// </summary>
982 // /// <param name="sender"></param>
983 // /// <param name="e"></param>
984 // void EventoDeGrid_NewRowNeeded(object sender, DataGridViewRowEventArgs e)
985 // {
986 // // Create a new Customer object when the user edits
987 // // the row for new records.
988 // this._oLinVenDetSerieEnEdicion = new LinVenDetSeries();
989 // this._nFilaEnEdicion = _oManteGrid._Grid.Rows.Count - 1;
990 // //Asigno un valor de garantia
991 // this._oLinVenDetSerieEnEdicion._Garantia = _GarantiaDefecto;
992 // }
993 
994 // //Rendimiento
995 // /// <summary>
996 // ///
997 // /// </summary>
998 // /// <param name="sender"></param>
999 // /// <param name="e"></param>
1000 // void EventoDeGrid_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
1001 // {
1002 // LinVenDetSeries loLinVenDetSeriesTmp = null;
1003 
1004 // // Almaceno la referencia al objeto LinVenDetSerie para la fila que estamos editando
1005 // if (e.RowIndex < _LinVenDetSeries._lisCodigos.Count)
1006 // {
1007 // // Si el usuari esta editando una fila nuevo creo un nuevo objeto LinVenDetSerie
1008 // if (this._oLinVenDetSerieEnEdicion == null)
1009 // {
1010 // this._oLinVenDetSerieEnEdicion = new LinVenDetSeries(_LinVenDetSeries._Lineas,
1011 // ((LinVenDetSeries)this._LinVenDetSeries._lisCodigos[e.RowIndex])._Codigo,
1012 // ((LinVenDetSeries)this._LinVenDetSeries._lisCodigos[e.RowIndex])._Posicion);
1013 // _oLinVenDetSerieEnEdicion._Baja = ((LinVenDetSeries)this._LinVenDetSeries._lisCodigos[e.RowIndex])._Baja;
1014 // _oLinVenDetSerieEnEdicion._RegistroAlmacenado = ((LinVenDetSeries)this._LinVenDetSeries._lisCodigos[e.RowIndex])._RegistroAlmacenado;
1015 // _oLinVenDetSerieEnEdicion._Garantia = ((LinVenDetSeries)this._LinVenDetSeries._lisCodigos[e.RowIndex])._Garantia;
1016 // }
1017 // loLinVenDetSeriesTmp = this._oLinVenDetSerieEnEdicion;
1018 // this._nFilaEnEdicion = e.RowIndex;
1019 // }
1020 // else
1021 // {
1022 // loLinVenDetSeriesTmp = this._oLinVenDetSerieEnEdicion;
1023 // }
1024 
1025 // // Asignamos el valor de la propiedad desde la celda que hemos informado
1026 // String newValue = e.Value as String;
1027 // switch (_oManteGrid._Grid.Columns[e.ColumnIndex].Name)
1028 // {
1029 // case "_Codigo":
1030 // loLinVenDetSeriesTmp._Codigo = newValue;
1031 // break;
1032 
1033 // case "_Posicion":
1034 // loLinVenDetSeriesTmp._Posicion = Convert.ToInt32(newValue);
1035 // break;
1036 // case "_Baja":
1037 // loLinVenDetSeriesTmp._Baja = Convert.ToBoolean(newValue);
1038 // break;
1039 // case "_Existe":
1040 // loLinVenDetSeriesTmp._Existe = Convert.ToBoolean(newValue);
1041 // break;
1042 // case "_RegistroAlmacenado":
1043 // loLinVenDetSeriesTmp._RegistroAlmacenado = Convert.ToBoolean(newValue);
1044 // break;
1045 // case "_Garantia":
1046 // loLinVenDetSeriesTmp._Garantia = Convert.ToDateTime(newValue);
1047 // break;
1048 // }
1049 // }
1050 
1051 // //Rendimiento
1052 // /// <summary>
1053 // /// Evento de solicitud de valor
1054 // /// </summary>
1055 // /// <param name="sender"></param>
1056 // /// <param name="e"></param>
1057 // void EventoDeGrid_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
1058 // {
1059 // // Si la fila es para valores nuevos no necessito valores
1060 // if (e.RowIndex == _oManteGrid._Grid.RowCount) // - 1)
1061 // return;
1062 
1063 // LinVenDetSeries loLinVenDetSerieTmp = null;
1064 
1065 // // Almaceno la referencia al objeto LinVenDetSerie para la fila que estamos pintando
1066 // if (e.RowIndex == _nFilaEnEdicion)
1067 // {
1068 // loLinVenDetSerieTmp = this._oLinVenDetSerieEnEdicion;
1069 // }
1070 // else
1071 // {
1072 // loLinVenDetSerieTmp = (LinVenDetSeries)_LinVenDetSeries._lisCodigos[e.RowIndex];
1073 // }
1074 
1075 // // Establezco el valor en la celda a pintar usando el objeto LinVenDet recuperado
1076 // switch (_oManteGrid._Grid.Columns[e.ColumnIndex].Name)
1077 // {
1078 // case "_Codigo":
1079 // e.Value = loLinVenDetSerieTmp._Codigo;
1080 // break;
1081 
1082 // case "_Posicion":
1083 // e.Value = loLinVenDetSerieTmp._Posicion;
1084 // break;
1085 
1086 // case "_Existe":
1087 // e.Value = loLinVenDetSerieTmp._Existe;
1088 // _oManteGrid._Grid["_Garantia", e.RowIndex].ReadOnly = loLinVenDetSerieTmp._Existe; //Establezco el modo ReadOnly de la celda de garantia
1089 
1090 // break;
1091 
1092 // case "_Baja":
1093 // e.Value = loLinVenDetSerieTmp._Baja;
1094 // break;
1095 
1096 // case "_RegistroAlmacenado":
1097 // e.Value = loLinVenDetSerieTmp._RegistroAlmacenado;
1098 // break;
1099 
1100 // case "_Garantia":
1101 // if (loLinVenDetSerieTmp._Garantia == null) //Sino hay valor fabrico uno
1102 // e.Value = _GarantiaDefecto;
1103 // else
1104 // e.Value = loLinVenDetSerieTmp._Garantia;
1105 // break;
1106 // }
1107 // }
1108 
1109 // #endregion Eventos VirtualMode para rendimiento
1110 
1111 // /// <summary>
1112 // /// Evento click en el botón de añadir resto de series como BAJA
1113 // /// </summary>
1114 // /// <param name="sender"></param>
1115 // /// <param name="e"></param>
1116 // private void BtRestoBajas_Click(object sender, EventArgs e)
1117 // {
1118 // AgregarRestoSeries(tlAgregarComoBaja: true);
1119 // }
1120 
1121 // /// <summary>
1122 // /// Evento click en el botón de añadir resto de series como ALTA
1123 // /// </summary>
1124 // /// <param name="sender"></param>
1125 // /// <param name="e"></param>
1126 // private void BtRestoAltas_Click(object sender, EventArgs e)
1127 // {
1128 // AgregarRestoSeries(tlAgregarComoBaja: false);
1129 // }
1130 
1131 // /// <summary>
1132 // /// Método auxiliar para abrir la pantalla de información de series
1133 // /// </summary>
1134 // private void MostrarInformacionSerie()
1135 // {
1136 // frmSeries loForm = new frmSeries();
1137 // if (_oManteGrid._Grid.CurrentRow != null && _oManteGrid._Grid.CurrentRow.Index >= 0) //Indice -1 son títulos
1138 // {
1139 // string lcSerieGrid = ((LinVenDetSeries)_oManteGrid._Grid.CurrentRow.DataBoundItem)._Codigo;
1140 // if (!String.IsNullOrWhiteSpace(lcSerieGrid))
1141 // {
1142 // Serie loSerie = new Serie(lcSerieGrid);
1143 
1144 // if (loSerie._Disponible() != null) //Sino existia la serie explotaba
1145 // loForm._Serie = new Serie(lcSerieGrid);
1146 // }
1147 // }
1148 // loForm._ShowDialog(); //Bug 114218 Cambiar .ShowDialog() por ._ShowDialog()
1149 // }
1150 
1151 // /// <summary>
1152 // /// Método privado para determinar si una serie existe o no
1153 // /// </summary>
1154 // /// <param name="loRow"></param>
1155 // private void ComprobarExistenciaSerie(DataGridViewRow loRow)
1156 // {
1157 // string lcCodigo = ((LinVenDetSeries)loRow.DataBoundItem)._Codigo;
1158 // //Si la serie al mirar disponibilidad no devuelve null (no exite) => Será EXISTE true
1159 // if (!string.IsNullOrWhiteSpace(lcCodigo))
1160 // {
1161 // bool llExiste = (((Serie)Activator.CreateInstance(typeof(Serie)))._Disponible(lcCodigo) != null) ? true : false;
1162 // loRow.Cells["_Existe"].Value = llExiste;
1163 // if (llExiste)
1164 // loRow.Cells["_Garantia"].Value = Serie._ObtenerGarantia(lcCodigo);
1165 // else
1166 // loRow.Cells["_Garantia"].Value = _GarantiaDefecto;
1167 // _oManteGrid._Grid["_Garantia", loRow.Index].ReadOnly = llExiste;
1168 // }
1169 // else
1170 // loRow.Cells["_Existe"].Value = false;
1171 // }
1172 
1173 // /// <summary>
1174 // /// Establecemos controles de solo lectura
1175 // /// </summary>
1176 // private void ReadOnlyControlesInformativos()
1177 // {
1178 // _otxtArticulo._ReadOnly = true;
1179 // _otxtArticulo._Mostrar_Browser = false;
1180 
1181 // _otxtAlmacen._ReadOnly = true;
1182 // _otxtAlmacen._Mostrar_Browser = false;
1183 
1184 // _oGridResumen.ReadOnly = true;
1185 // }
1186 
1187 // /// <summary>
1188 // /// Método auxiliar para recuperar la imagen
1189 // /// </summary>
1190 // private void RecuperarImagen()
1191 // {
1192 // //Recuperamos la imagen del artículo
1193 // #region Imagen Articulo
1194 
1195 // //Recupero las imagenes del artículo
1196 // articulo.Articulo loArticulo = new articulo.Articulo(_LinVenDetSeries._Lineas._Articulo);
1197 
1198 // DataTable ldtImagenes = new DataTable();
1199 // ldtImagenes = loArticulo._Recuperar_Imagenes();
1200 // //Si el DataTable trae imagenes, recupero la primera.
1201 // if (ldtImagenes.Rows.Count != 0) _oPictureboxArticulo.ImageLocation = ldtImagenes.Rows[0].ItemArray[0].ToString();
1202 // else _oPictureboxArticulo.Image = images.Properties.Resources.picture_no_available;
1203 // _oPictureboxArticulo.SizeMode = PictureBoxSizeMode.StretchImage;
1204 
1205 // #endregion Imagen Articulo
1206 // }
1207 
1208 // /// <summary>
1209 // /// Método auxiliar para posicionamiento de los botones dentro del flow de botones
1210 // /// </summary>
1211 // private void MontarBotones()
1212 // {
1213 // _oFlowBotones.Controls.Add(btSalir1);
1214 // _oFlowBotones.Controls.Add(btDocCancelar1);
1215 // _oFlowBotones.Controls.Add(btDocAceptar1);
1216 // }
1217 
1218 // /// <summary>
1219 // /// Método auxiliar para añadir líneas al grid
1220 // /// </summary>
1221 // /// <param name="tcSerie"></param>
1222 // /// <param name="lnPosicion"></param>
1223 // private void AddLinVenDet(string tcSerie = "", int lnPosicion = -1)
1224 // {
1225 // if (lnPosicion < 0)
1226 // lnPosicion = _oLinVenDetSeries.__ObtenerNuevaPosicion();
1227 
1228 // LinVenDetSeries loNewItem = new LinVenDetSeries(_oLinVenDetSeries._Lineas as IDocumentLinea, tcSerie, lnPosicion)
1229 // {
1230 // _Garantia = _GarantiaDefecto //Asingo un valor de garantia por defecto
1231 // };
1232 // _oLinVenDetSeries._lisCodigos.Add(loNewItem);
1233 
1234 // }
1235 
1236 // /// <summary>
1237 // /// Método auxiliar que añade las series restantes como ALTA o BAJA en función del parámetro
1238 // /// </summary>
1239 // /// <param name="tlAgregarComoBaja"></param>
1240 // private void AgregarRestoSeries(bool tlAgregarComoBaja)
1241 // {
1242 // //Recupero todas las series de este articulo y almacén que estan de alta y no estan en la lista
1243 // DataTable ldtSeries = new DataTable();
1244 // ObtenerSeriesRestantes(ref ldtSeries);
1245 
1246 // if (ldtSeries.Rows.Count > 0) //Si tengo series
1247 // {
1248 // //Aprovecho y limpio de líneas en blanco
1249 // var lineasVacias = _oLinVenDetSeries._lisCodigos.Where(ele => string.IsNullOrEmpty(ele._Codigo)).ToList();
1250 // lineasVacias.ForEach(loEle => _oLinVenDetSeries._lisCodigos.Remove(loEle));
1251 
1252 // //Máximo + 1 o directamente 1 =>
1253 // int lnPosicion = _oLinVenDetSeries.__ObtenerNuevaPosicion();
1254 
1255 // foreach (DataRow ldr in ldtSeries.Rows)
1256 // {
1257 // LinVenDetSeries loNewItem = new LinVenDetSeries(_oLinVenDetSeries._Lineas as IDocumentLinea, ldr["SERIE"].ToString().TrimEnd(), lnPosicion)
1258 // {
1259 // _Baja = tlAgregarComoBaja,
1260 // _Existe = true
1261 // };
1262 // loNewItem._Garantia = Serie._ObtenerGarantia(loNewItem._Codigo);
1263 // _oLinVenDetSeries._lisCodigos.Add(loNewItem);
1264 // lnPosicion++;
1265 // }
1266 // }
1267 // }
1268 
1269 // /// <summary>
1270 // /// Método que carga en la tabla los datos de series que cumplan los criterios y que no estén ya usadas
1271 // /// </summary>
1272 // /// <param name="tdtDatos">Tabla donde cargar los datos</param>
1273 // /// <returns>Numero de registros de la tabla</returns>
1274 // private int ObtenerSeriesRestantes(ref DataTable tdtDatos)
1275 // {
1276 // //Recupero todas las series de este articulo y almacén que estan de alta y no estan en la lista
1277 // using (Serie loSerie = new Serie())
1278 // {
1279 // //Creo la lista de exclusiones
1280 // string lcFiltroFechas = " AND FECHA <= " + DB.SQLString(_LinVenDetSeries._Lineas._Fecha);
1281 // List<string> lisExcluidas = _oLinVenDetSeries._lisCodigos.Select(loEle => loEle._Codigo).ToList();
1282 // tdtDatos = loSerie._Obtener_Series(_otxtArticulo._Codigo, tlBaja: false, tcAlmacen: _otxtAlmacen._Codigo,
1283 // toLista: lisExcluidas, tcClausulaWhereAdicional: lcFiltroFechas);
1284 // return tdtDatos.Rows.Count;
1285 // }
1286 
1287 // }
1288 // }
1289 }