Hola buenas tardes desde México, con gusto coloco un procedimiento que uso en una aplicación para enviar a un StringGrid (que esta en el FormVentas) el producto seleccionado desde otro form llamado ListProducts.
Código Delphi
[-]procedure TFormVtas.AddProduct(Cve, Cant, NotaFact:String);
var x,Fila:Word; Incide:Boolean; ImpIVA,PUnitIVA:Currency;
begin
if Cve<>'' then Datos.Query3.SQL.Text:='SELECT Id,Producto,'+TipoPcio+' AS PUnit,Exist,Observ,Foto,SAT FROM productos WHERE IdOficina='''+Datos.IdOficina+''' AND Codigo='''+Cve+''''
else Datos.Query3.SQL.Text:='SELECT Id,Producto,'+TipoPcio+' AS PUnit,Exist,Observ,Foto,SAT FROM productos WHERE IdOficina='''+Datos.IdOficina+''' AND Id='+Datos.ClientData3.FieldByName('Id').AsString;
Datos.Query3.Open;
if not Datos.Query3.IsEmpty then
if (Datos.Query3.FieldByName('Exist').AsInteger>=1) or (Datos.ProdZero=True) then begin
Incide:=False;
Fila:=Grid1.RowCount;
for x:=0 to Grid1.RowCount-1 do
if Datos.Query3.FieldByName('Id').AsString=Grid1.Cells[6,x] then begin
Incide:=True;
Break;
end;
if Incide then begin
if (Datos.Query3.FieldByName('Exist').AsInteger>StrToInt(Grid1.Cells[1,x])) or (Datos.ProdZero=True) then
if Cant='' then Grid1.Cells[1,x]:=IntToStr(StrToInt(Grid1.Cells[1,x])+1)
else Grid1.Cells[1,x]:=CurrToStr(StrToInt(Grid1.Cells[1,x])+StrToCurr(Cant))
else ShowMessage('La cantidad solicitada no puede ser cubierta, no hay suficiente producto');
end else
begin
if Grid1.Cells[1,0]<>'' then
begin
Inc(Fila);
Grid1.RowCount:=Fila;
end;
CalcPcioUnit(Datos.Query3.FieldByName('PUnit').AsCurrency,ImpIVA,PUnitIVA);
if Cant='' then Grid1.Cells[1,Fila-1]:='1'
else Grid1.Cells[1,Fila-1]:=Cant;
Grid1.Cells[2,Fila-1]:=Datos.Query3.FieldByName('Producto').AsString; Grid1.Cells[5,Fila-1]:=''; Grid1.Cells[6,Fila-1]:=Datos.Query3.FieldByName('Id').AsString;
Grid1.Cells[7,Fila-1]:=Datos.Query3.FieldByName('PUnit').AsString;
Grid1.Cells[8,Fila-1]:=CurrToStr(ImpIVA);
Grid1.Cells[9,Fila-1]:=CurrToStr(PUnitIVA);
Grid1.Cells[10,Fila-1]:=Datos.Query3.FieldByName('Foto').AsString;
Grid1.Cells[11,Fila-1]:=TipoPcio;
Grid1.Cells[13,Fila-1]:=NotaFact;
try
if Grid1.Cells[10,Grid1.Row]<>'.' then Image1.Picture.LoadFromFile(Datos.PathProdImg+'\'+Grid1.Cells[10,Grid1.Row]+'.jpg') else Image1.Picture:=nil; except
Image1.Picture:=nil;
end;
end;
CalcTotal; Edit3.Clear;
Edit3.SetFocus;
end else ShowMessage('La cantidad solicitada no puede ser cubierta, no hay suficiente producto')
else ShowMessage('Producto no registrado, pida asesoría con el administrador');
Datos.Connection1.Close; end;
He tratado de documentarlo lo mejor que me ha sido posible, espero que te sea de ayuda. Saludos.