2 using System.Collections.Generic;
3 using System.ComponentModel;
18 namespace sage.ew.lote.Forms
28 private int _IndexColumnaSel = 0;
48 DataTable ldtLotes =
new DataTable();
49 if (this._oLinea.__Contiene_Lotes(ref ldtLotes))
51 this._Lotes = ldtLotes;
59 public DataTable _Lotes = null;
64 public List<Lote> _LotesSeleccionadas =
new List<Lote>();
69 public decimal _UnidadesSeleccionadas = 0;
74 public decimal _CajasSeleccionadas = 0;
79 public decimal _PesoSeleccionadas = 0;
85 public decimal _UnidadesTraspaso
89 return this._oUnidadesTraspaso;
93 this._oUnidadesTraspaso = value;
94 this._UnidadesSeleccionadas = value;
101 public decimal _CajasTraspaso
105 return this._oCajasTraspaso;
109 this._oCajasTraspaso = value;
110 this._CajasSeleccionadas = value;
117 public decimal _PesoTraspaso
121 return this._oPesoTraspaso;
125 this._oPesoTraspaso = value;
126 this._PesoSeleccionadas = value;
135 private bool llPeso = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Peso"));
136 private bool llCajas = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_Cajas"));
141 private decimal _oUnidadesTraspaso = 0;
142 private decimal _oCajasTraspaso = 0;
143 private decimal _oPesoTraspaso = 0;
150 InitializeComponent();
160 InitializeComponent();
163 this.ewgridResultados.__ReadOnly();
164 this.ewgridResultados.AutoGenerateColumns =
false;
165 this.ewgridResultados.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
166 this.ewgridResultados.CellClick +=
new DataGridViewCellEventHandler(ewgridResultados_CellClick);
167 this.ewgridResultados.DataBindingComplete +=
new DataGridViewBindingCompleteEventHandler(ewgridResultados_DataBindingComplete);
168 this.ewgridResultados.MouseDown +=
new MouseEventHandler(ewgridResultados_MouseDown);
169 this.ewgridResultados.CellContentClick +=
new DataGridViewCellEventHandler(ewgridResultados_CellContentClick);
170 this.ewgridResultados.CellValueChanged +=
new DataGridViewCellEventHandler(ewgridResultados_CellValueChanged);
171 this.ewgridResultados.CellEnter +=
new DataGridViewCellEventHandler(ewgridResultados_CellEnter);
172 this.ewgridResultados.ReadOnly =
false;
174 this._Linea = loLinea;
175 this._UnidadesTraspaso = loUnidades;
183 string lcTituloCajas = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_descajas")).Trim();
184 string lcTituloUnidades = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_desunidades")).Trim();
188 ldgtbColSeleccionada.Name =
"sel";
189 ldgtbColSeleccionada.HeaderText =
"Sel.";
190 ldgtbColSeleccionada.ValueType = typeof(
bool);
191 ldgtbColSeleccionada.Visible =
true;
192 ldgtbColSeleccionada._NoParar =
true;
193 ldgtbColSeleccionada.Width = 50;
194 ldgtbColSeleccionada.ToolTipText =
"Sirve para seleccionar los elementos con los que operar";
195 ldgtbColSeleccionada.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
196 this.ewgridResultados.Columns.Add(ldgtbColSeleccionada);
201 ldgtbColArticulo.Name =
"lote";
203 ldgtbColArticulo.HeaderText = _oLotesConfig.
_Definicion.First().ToString().ToUpper() + _oLotesConfig.
_Definicion.Substring(1).ToString().ToLower();
204 ldgtbColArticulo.ValueType = typeof(
string);
205 ldgtbColArticulo.Width = 500;
206 ldgtbColArticulo.Visible =
true;
207 ldgtbColArticulo._NoParar =
true;
208 ldgtbColArticulo.ReadOnly =
true;
209 ldgtbColArticulo.ToolTipText =
"Código de " + _oLotesConfig.
_Definicion.Trim().ToLower();
210 ldgtbColArticulo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
211 this.ewgridResultados.Columns.Add(ldgtbColArticulo);
217 ldgtbColCajas.Name =
"cajas";
218 ldgtbColCajas.HeaderText = lcTituloCajas;
219 ldgtbColCajas.ValueType = typeof(decimal);
220 ldgtbColCajas.Width = 50;
221 ldgtbColCajas.Visible = llCajas;
222 ldgtbColCajas._NoParar =
true;
223 ldgtbColCajas.ReadOnly =
true;
224 ldgtbColCajas.ToolTipText = lcTituloCajas +
" del pedido";
225 ldgtbColCajas.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
226 ldgtbColCajas.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
227 this.ewgridResultados.Columns.Add(ldgtbColCajas);
232 ldgtbColUnidades.Name =
"unidades";
233 ldgtbColUnidades.HeaderText = lcTituloUnidades;
234 ldgtbColUnidades.Width = 50;
235 ldgtbColUnidades.Visible =
true;
236 ldgtbColUnidades._NoParar =
true;
237 ldgtbColUnidades.ReadOnly =
true;
238 ldgtbColUnidades.ToolTipText = lcTituloUnidades +
" del artículo en el pedido";
239 ldgtbColUnidades.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
240 ldgtbColUnidades.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
241 ldgtbColUnidades.DefaultCellStyle.Format = this.loMascaraUnidades.
_Mascara_Net;
242 this.ewgridResultados.Columns.Add(ldgtbColUnidades);
247 ldgtbColPesoPedido.Name =
"peso";
248 ldgtbColPesoPedido.HeaderText =
"Peso";
249 ldgtbColPesoPedido.ValueType = typeof(decimal);
250 ldgtbColPesoPedido.Width = 50;
251 ldgtbColPesoPedido.Visible = llPeso;
252 ldgtbColPesoPedido._NoParar =
true;
253 ldgtbColPesoPedido.ReadOnly =
true;
254 ldgtbColPesoPedido.ToolTipText =
"Peso del pedido";
255 ldgtbColPesoPedido.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
256 ldgtbColPesoPedido.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
257 ldgtbColPesoPedido.DefaultCellStyle.Format = this.loMascaraPeso._Mascara_Net;
258 this.ewgridResultados.Columns.Add(ldgtbColPesoPedido);
262 this.ewgridResultados.DataSource = this._Lotes;
265 foreach (DataGridViewColumn ldgvCol
in this.ewgridResultados.Columns)
267 ldgvCol.DataPropertyName = ldgvCol.Name;
271 if (this._LotesSeleccionadas.Count > 0)
273 foreach (DataGridViewRow loRow
in this.ewgridResultados.Rows)
275 foreach (
Lote loLote
in this._LotesSeleccionadas)
277 if (loLote.
_Codigo.Trim() == loRow.Cells[
"lote"].Value.ToString().Trim())
279 loRow.Cells[this._IndexColumnaSel].Value =
true;
280 loRow.Cells[
"unidades"].Value = loLote.
_Unidades;
283 loRow.Cells[
"peso"].Value = loLote.
_Peso;
292 decimal lnTotalTemp = this._UnidadesTraspaso;
293 foreach (DataGridViewRow loRow
in this.ewgridResultados.Rows)
296 loRow.Cells[this._IndexColumnaSel].Value =
true;
298 lnTotalTemp = lnTotalTemp - Convert.ToDecimal(loRow.Cells[
"unidades"].Value);
303 this.actualizaTotalTraspaso();
306 this.ewgridResultados.Refresh();
307 this.ewgridResultados.RefreshEdit();
314 protected override void OnLoad(EventArgs e)
319 this.Text =
"Traspaso de " + _oLotesConfig.
_Definicion.Trim().ToLower() +
" de salida ";
321 if (this._Linea == null)
323 this._MessageBox(
"Se ha declarado el objeto sin que se le haya asignado la linea del Documento.",
324 MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
System.Windows.Forms.DialogResult.None);
327 if (llOk && (this._Lotes == null || this._Lotes.Rows.Count <= 0))
329 this._MessageBox(
"El documento de venta no contiene " + _oLotesConfig.
_Definicion.Trim().ToLower() +
".",
330 MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
System.Windows.Forms.DialogResult.None);
342 this.ewtbArticulo.Text = this._Linea._Articulo;
343 this.ewtbDefinicion.Text = this._Linea._Definicion;
349 this.ewgridResultados.ContextMenuStrip = this.ctMenuStrip;
350 this.ewgridResultados.ContextMenuStrip.ItemClicked +=
new ToolStripItemClickedEventHandler(ContextMenuStrip_ItemClicked);
353 this.actualizaTotalTraspaso();
365 void ewgridResultados_MouseDown(
object sender, MouseEventArgs e)
367 if (e.Button == MouseButtons.Right)
369 var hti = this.ewgridResultados.HitTest(e.X, e.Y);
370 if (hti.RowIndex >= 0)
372 this.ewgridResultados.ClearSelection();
373 this.ewgridResultados.Rows[hti.RowIndex].Selected =
true;
374 this.ewgridResultados.CurrentCell = this.ewgridResultados.Rows[hti.RowIndex].Cells[0];
384 void ewgridResultados_DataBindingComplete(
object sender, DataGridViewBindingCompleteEventArgs e)
386 if (this.ewgridResultados.Columns[
"OPCIONES"] == null)
388 DataGridViewButtonColumn buttonColumn =
new DataGridViewButtonColumn();
389 buttonColumn.Name =
"OPCIONES";
390 buttonColumn.HeaderText =
"Opciones";
391 buttonColumn.Text =
"...";
392 buttonColumn.ToolTipText =
"Opciones";
393 buttonColumn.DefaultCellStyle.Padding =
new Padding(20, 1, 20, 1);
394 buttonColumn.DisplayIndex = this.ewgridResultados.Columns.Count + 1;
395 buttonColumn.Visible =
true;
396 buttonColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
399 buttonColumn.UseColumnTextForButtonValue =
true;
400 buttonColumn.ContextMenuStrip = this.ctMenuStrip;
402 this.ewgridResultados.Columns.Insert(this.ewgridResultados.Columns.Count, buttonColumn);
411 void ewgridResultados_CellContentClick(
object sender, DataGridViewCellEventArgs e)
413 this.ewgridResultados.CommitEdit(DataGridViewDataErrorContexts.Commit);
421 void ewgridResultados_CellEnter(
object sender, DataGridViewCellEventArgs e)
423 this.ewgridResultados_CellClick(sender, e);
431 void ewgridResultados_CellClick(
object sender, DataGridViewCellEventArgs e)
436 this.ewgridResultados.Rows[e.RowIndex].ReadOnly =
true;
439 if (e.ColumnIndex ==
this._IndexColumnaSel)
441 this.ewgridResultados.Rows[e.RowIndex].ReadOnly =
false;
445 if (this.ewgridResultados.Columns[e.ColumnIndex].Name ==
"OPCIONES")
447 var ptLowerLeft = this.ewgridResultados.PointToClient(Cursor.Position);
448 this.ctMenuStrip.Show(this.ewgridResultados, ptLowerLeft);
458 void ewgridResultados_CellValueChanged(
object sender, DataGridViewCellEventArgs e)
462 DataGridViewRow loRow = (DataGridViewRow)this.ewgridResultados.Rows[e.RowIndex];
463 if (loRow.Cells[e.ColumnIndex].Value != null)
466 this.actualizaTotalTraspaso();
474 private void actualizaTotalTraspaso()
476 decimal lnTotalSeleccion = 0;
477 foreach (DataGridViewRow loRow
in this.ewgridResultados.Rows)
479 if (loRow.Cells[
this._IndexColumnaSel].Value != null && Convert.ToBoolean(loRow.Cells[
this._IndexColumnaSel].Value))
481 lnTotalSeleccion = lnTotalSeleccion + Convert.ToDecimal(loRow.Cells[
"unidades"].Value);
484 this.ewtbTotalTraspaso.Text = this._UnidadesTraspaso.ToString(loMascaraUnidades.
_Mascara_Net);
485 this.ewtbTotalSeleccion.Text = lnTotalSeleccion.ToString(loMascaraUnidades.
_Mascara_Net);
493 void ContextMenuStrip_ItemClicked(
object sender, ToolStripItemClickedEventArgs e)
496 this.ctMenuStrip.Close();
498 switch (e.ClickedItem.Name)
502 this.ewcbSelectAll.Checked = !this.ewcbSelectAll.Checked;
503 if (this.ewcbSelectAll.Checked)
504 e.ClickedItem.Text =
"Deseleccionar todas las líneas";
506 e.ClickedItem.Text =
"Seleccionar todas las líneas";
516 private void ewcheckbox2_CheckedChanged(
object sender, EventArgs e)
518 foreach (DataGridViewRow loRow
in this.ewgridResultados.Rows)
521 if (this.ewcbSelectAll.Checked)
524 loRow.Cells[this._IndexColumnaSel].Value =
true;
529 loRow.Cells[this._IndexColumnaSel].Value =
false;
539 private void _ResizeForm(
int tnNumRegs = 25)
542 if (this.ewgridResultados.Rows.Count < tnNumRegs)
544 int lnGridSize = this.ewgridResultados.Height;
546 foreach (DataGridViewRow row
in this.ewgridResultados.Rows)
547 lnHeight += row.Height;
548 lnHeight += this.ewgridResultados.ColumnHeadersHeight;
549 int lnWidth = this.ewgridResultados.Width;
551 this.ewgridResultados.ClientSize =
new Size(lnWidth, lnHeight + 2);
553 int lnNewFormSize = this.Height - (lnGridSize - this.ewgridResultados.ClientSize.Height);
554 this.MinimumSize =
new System.Drawing.Size(this.MinimumSize.Width, lnNewFormSize);
555 this.MaximumSize = this.MinimumSize;
556 this.Height = lnNewFormSize;
558 this.CenterToScreen();
567 private void btDocAceptar1_Click(
object sender, EventArgs e)
570 string lcError =
"No ha seleccionado ningún registro para su traspaso.";
571 foreach (DataGridViewRow ldr
in this.ewgridResultados.Rows)
573 if (ldr.Cells[
this._IndexColumnaSel].Value != null && (
bool)(ldr.Cells[
this._IndexColumnaSel].Value) ==
true)
583 this._MessageBox(lcError, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1,
System.Windows.Forms.DialogResult.None);
584 this.DialogResult = DialogResult.None;
589 List<Lote> llTemp =
new List<Lote>();
590 foreach (DataGridViewRow loRow
in this.ewgridResultados.Rows)
592 if (loRow.Cells[
this._IndexColumnaSel].Value != null && Convert.ToBoolean(loRow.Cells[
this._IndexColumnaSel].Value))
595 loLote.
_Codigo = loRow.Cells[
"lote"].Value.ToString();
596 loLote.
_Unidades = Convert.ToDecimal(loRow.Cells[
"unidades"].Value);
597 loLote.
_Peso = Convert.ToDecimal(loRow.Cells[
"peso"].Value);
604 this._LotesSeleccionadas = llTemp;
613 private void btDocCancelar1_Click(
object sender, EventArgs e)
615 this.DialogResult = DialogResult.None;
Clase para la gestión de los lotes
KeyDiccionarioMascara
Clave para diccionario de máscaras
decimal _Unidades
Unidades asignadas a la venta
String _Definicion
Definición del LOTE
Clase para cargar la configuración del módulo de LOTES
Base per a les columnes estandar
virtual string _Codigo
Valor del campo clave que
Clase linea de documento de venta TPV
Proporciona características adicionales de las máscaras de Eurowin
string _Mascara_Net
Máscara convertida en formato .Net
Presenta un datagridview con botones añadir y borrar tipo Mantegrid de Eurowin
decimal _Peso
Peso asignado a la venta
Base per a les columnes estandar