unit uEditText;

interface

uses
  System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
  FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async,
  FireDAC.DApt, FireDAC.UI.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Phys,
  FireDAC.VCLUI.Wait, FireDAC.Phys.MySQLDef, FireDAC.Phys.MySQL, Data.DB, FireDAC.Comp.Client,
  FireDAC.Comp.DataSet,
  Vcl.ComCtrls, // Äëÿ TTreeView
  Contnrs,vcl.dialogs,
  syncobjs,vcl.Forms,vcl.Controls, uSelectionOptions,uSelectedOrChecked,uDBConnectionBPL,
  uTreeView,uSQLQueries;


type TEditNodeText=class(TComponent)

  private

  FDBTreeView:TDBTreeView;

  public

  Constructor Create(Aowner:TComponent);
  Destructor Destroy;

  property DBTreeView:TDBTreeView read FDBTreeView write FDBTreeView;

  procedure UpdateNodeText(Name:string);


end;


implementation


                                    { TEditText }

constructor TEditNodeText.Create(Aowner: TComponent);
begin
//
end;

destructor TEditNodeText.Destroy;
begin
//
end;

procedure TEditNodeText.UpdateNodeText(Name: string);

var qEdit:TFDQuery; DBConnectionLocal:TDBConnectionBPL;
    id:integer;
    SQLQueries:TSQLQueries;

begin

SQLQueries:=TSQLQueries.Create(Self);

if not Assigned(FDBTreeView.Selected) then exit;

id:=integer(FDBTreeView.Selected.Data^);

qEdit:=TFDQuery.Create(Self);
DBConnectionLocal:=TDBConnectionBPL.Create(Self);
qEdit.Connection:=DBConnectionLocal.FDConnection;



qEdit.SQL.Text:=SQLQueries.Edit.Text;
//'UPDATE `treeview_db`.`tree` SET `Name`=:Name WHERE `id`=:id';

with qEdit.Params do
 begin

  ParamValues['Name']:=Name;
  ParamValues['id']:=id;

 end;

qEdit.ExecSQL;

FDBTreeView.Selected.Text:=Name;

FreeAndNil(qEdit);
FreeAndNil(DBConnectionLocal);
FreeAndNil(SQLQueries);

end;

end.
