unit UPegaProduto;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  FMX.ListView.Types, FMX.ListView.Appearances, FMX.ListView.Adapters.Base,
  Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs,
  Fmx.Bind.Editors, Fmx.Bind.GenData, Data.Bind.GenData, Data.Bind.Components,
  Data.Bind.ObjectScope, FMX.ListView, Data.Bind.DBScope, Data.DB,
  Datasnap.DBClient, Data.DbxSqlite, Data.FMTBcd, Datasnap.Provider,
  Data.SqlExpr, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
  FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client, uDWConstsData, uRESTDWPoolerDB;

type
  TFPegaProduto = class(TForm)
    ListView1: TListView;
    SterlingStyleBook: TStyleBook;
    RESTDWClientSQL1: TRESTDWClientSQL;
    BindSourceDB1: TBindSourceDB;
    BindingsList1: TBindingsList;
    LinkListControlToField1: TLinkListControlToField;
    procedure ListView1ItemClick(const Sender: TObject;
      const AItem: TListViewItem);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Selecionado: String;
  end;

var
  FPegaProduto: TFPegaProduto;

implementation

{$R *.fmx}

procedure TFPegaProduto.FormActivate(Sender: TObject);
begin
  RESTDWClientSQL1.Active := False;
  RESTDWClientSQL1.Active := True;
end;

procedure TFPegaProduto.ListView1ItemClick(const Sender: TObject;
  const AItem: TListViewItem);
begin
//  Selecionado := ListView1.Items[ListView1.Selected.Index].Text;
  Selecionado := RESTDWClientSQL1.FieldByName('ID').AsString + '|' + RESTDWClientSQL1.FieldByName('NOME').AsString;
  Close;
end;

end.
