Skip to main navigation Skip to main content Skip to page footer
unit MutatiesForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls,
  Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.Grids, Vcl.DBGrids, DataModule, Vcl.StdCtrls, Vcl.DBCtrls, Vcl.WinXCtrls,
  Vcl.ExtCtrls, Vcl.ComCtrls, TL.Components;

type
  TfrmMutaties = class(TLForm)
    GridMutaties: TLDBGrid;
    Panel2: TPanel;
    Panel3: TPanel;
    DBLookupListBoxCategories: TDBLookupListBox;
    DBLookupListBoxSubcategories: TDBLookupListBox;
    Panel1: TPanel;
    Label1: TLabel;
    ToggleSwitchNotAssigned: TToggleSwitch;
    Panel4: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure ToggleSwitchNotAssignedClick(Sender: TObject);
    procedure GridMutatiesDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMutaties: TfrmMutaties;

implementation

{$R *.dfm}

procedure TfrmMutaties.FormCreate(Sender: TObject);
begin
  if dm.Connection.Connected then
    begin
      Self.GridMutaties.SetColumnAttr;
      Self.RegVars.Values['ToggleSwitchNotAssigned']:= '0';
      Self.LoadConfig;
      Self.ToggleSwitchNotAssigned.State:= TToggleSwitchState(StrToInt(Self.RegVars.Values['ToggleSwitchNotAssigned']));
    end;
end;

procedure TfrmMutaties.GridMutatiesDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
var
  Grid: TLDBGrid;
begin
    // Locale variables for coding convinience ;)
  Grid:= (Sender as TLDBGrid);
  Grid.SetStyle(
    DataCol,
    Grid,
    Column,
    State,
    -2,
    -2);

end;

procedure TfrmMutaties.ToggleSwitchNotAssignedClick(Sender: TObject);
begin
  if Self.ToggleSwitchNotAssigned.State = tssOn then
    dm.DataSetMutaties.Filtered:= True
  else
    dm.DataSetMutaties.Filtered:= False;
  Self.RegVars.Values['ToggleSwitchNotAssigned']:= IntToStr(Ord(Self.ToggleSwitchNotAssigned.State));
  Self.SaveConfig;
end;

end.