Ver Mensaje Individual
  #2  
Antiguo 12-06-2018
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Por lo que te entendí podrías hacer:
Código Delphi [-]
procedure TFr_Venta.InsertOrUpdate(const Producto: string);
var
  found: Boolean;
  i    : Integer;
begin
  // buscar producto en ListView
  i     := 0;
  found := False;
  while (i < ReporteVenta.Items.Count) and not found do
  begin
    found := ReporteVenta.Items[i].Caption = Producto;
    Inc(i);
  end;

  // insertar o modificar en ClientDataSet
  if not Found then // no encontrado -> insertar
  begin
    T_vta.Insert;
    T_vta.Fields[0].Value := producto;
    T_vta.Fields[1].Value := precioVta;
    T_vta.Fields[2].Value := cantidad;
    ...
    T_vta.Post;
  end
  else              // encontrado -> editar (modificar valores)
  begin
    T_vta.Locate(T_vta.Fields[0].FieldName, producto,[]);
    T_vta.Edit;
    { T_vta.Fields[0].Value := ??? }
    T_vta.Fields[1].Value := precioVta;
    T_vta.Fields[2].Value := cantidad;
    ...
    T_vta.Post;
  end;
  
  // Actualizar ListView
  ...
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita