unit Unit26;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, frxClass,
  frxDBSet, Vcl.ExtCtrls, Data.DB, Data.Win.ADODB;

type
  TfReport = class(TForm)
    kassaReport: TfrxDBDataset;
    frxKassaReport: TfrxReport;
    GroupBox1: TGroupBox;
    Panel1: TPanel;
    Button1: TButton;
    dtpFrom: TDateTimePicker;
    Label1: TLabel;
    dtpTo: TDateTimePicker;
    Label2: TLabel;
    qKassa: TADOQuery;
    qKassaid: TIntegerField;
    qKassadate_end: TDateTimeField;
    qKassabrand: TWideStringField;
    qKassamodel: TWideStringField;
    qKassaw_total: TFloatField;
    qKassasm_buyTotal: TFloatField;
    qKassasm_total: TFloatField;
    RadioGroup1: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure frxKassaReportGetValue(const VarName: string; var Value: Variant);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fReport: TfReport;

implementation

{$R *.dfm}

uses Unit2;

procedure TfReport.Button1Click(Sender: TObject);
begin
  if RadioGroup1.ItemIndex = 0 then begin
     if qKassa.Active then
        qKassa.Close;
     qKassa.Parameters[0].Value := FormatDateTime('yyyy-mm-dd', dtpFrom.Date)+' 00:00:00';
     qKassa.Parameters[1].Value := FormatDateTime('yyyy-mm-dd', dtpTo.Date)+' 23:59:59';
     qKassa.Open;
     frxKassaReport.ShowReport;
  end;
  if RadioGroup1.ItemIndex = 1 then begin
     ShowMessage('Этот отчет еще в разработке');
  end;
end;

procedure TfReport.FormCreate(Sender: TObject);
begin
   dtpFrom.Date := now();
   dtpTo.Date := now();
end;

procedure TfReport.frxKassaReportGetValue(const VarName: string;
  var Value: Variant);
begin
  if CompareText(VarName, 'dateFrom') = 0 then
     Value := FormatDateTime('yyyy-mm-dd', dtpFrom.Date);
  if CompareText(VarName, 'dateTo') = 0 then
     Value := FormatDateTime('yyyy-mm-dd', dtpTo.Date);
end;

end.
