📄 qry.pas
字号:
unit qry;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, DB, ADODB, Grids, DBGrids, jpeg, ExtCtrls,
AppEvnts;
type
TfrmQry = class(TForm)
lbl1: TLabel;
pgcqry: TPageControl;
tsACData: TTabSheet;
ts1: TTabSheet;
dbgrdacdata: TDBGrid;
dsacdata: TDataSource;
qryacdata: TADOQuery;
lbl2: TLabel;
lbl3: TLabel;
chksj: TCheckBox;
dtpstart: TDateTimePicker;
dtpstop: TDateTimePicker;
chkid: TCheckBox;
cbbid: TComboBox;
chkadd: TCheckBox;
cbbadd: TComboBox;
btnqryacdata: TButton;
qryRunState: TADOQuery;
dsRunState: TDataSource;
dbgrdRunState: TDBGrid;
chksjr: TCheckBox;
dtpstartr: TDateTimePicker;
dtpstopr: TDateTimePicker;
lbl4: TLabel;
lbl5: TLabel;
chkidr: TCheckBox;
chkaddr: TCheckBox;
cbbidr: TComboBox;
cbbaddr: TComboBox;
btnqryr: TButton;
tsIDFInfo: TTabSheet;
dsIDFInfo: TDataSource;
qryIDFInfo: TADOQuery;
dbgrdIDFInfo: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure chksjMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure chkidMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure chkaddMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure btnqryacdataClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnqryrClick(Sender: TObject);
procedure chksjrMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure chkidrMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure chkaddrMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmQry: TfrmQry;
implementation
{$R *.dfm}
uses
Main;
procedure TfrmQry.FormCreate(Sender: TObject);
begin
dtpstart.Enabled := False;
dtpstop.Enabled := False;
cbbid.Enabled := False;
cbbadd.Enabled := False;
dtpstartr.Enabled := False;
dtpstopr.Enabled := False;
cbbidr.Enabled := False;
cbbaddr.Enabled := False;
//frmain.tmrTC.Enabled := False;
end;
procedure TfrmQry.chksjMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if chksj.Checked = True then
begin
dtpstart.Enabled := True;
dtpstop.Enabled := True;
end
else
begin
dtpstart.Enabled := False ;
dtpstop.Enabled := False;
end;
end;
procedure TfrmQry.chkidMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if chkid.Checked = True then
cbbid.Enabled := True
else
if chkid.Checked = False then
cbbid.Enabled := False ;
end;
procedure TfrmQry.chkaddMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if chkadd.Checked = True then
cbbadd.Enabled := True
else
if chkadd.Checked = False then
cbbadd.Enabled := False;
end;
procedure TfrmQry.btnqryacdataClick(Sender: TObject);
begin
if (chkid.Checked = False) and (chkadd.Checked = False) and (chksj.Checked = False) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata');
Open;
end;
end;
if (chkid.Checked = True ) and (chkadd.Checked = False) and (chksj.Checked = False) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where id =:id_val');
Parameters.ParamByName('id_val').Value := cbbid.Text;
Open;
end;
end;
if (chkid.Checked = False ) and (chkadd.Checked = True) and (chksj.Checked = False) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where ACAddress =:add_val');
Parameters.ParamByName('add_val').Value := cbbadd.Text;
Open;
end;
end;
if (chkid.Checked = False ) and (chkadd.Checked = False) and (chksj.Checked = True) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('start_val').Value := dtpstart.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstop.DateTime;
Open;
end;
end;
if (chkid.Checked = True ) and (chkadd.Checked = True) and (chksj.Checked = False) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where ACAddress =:add_val and id =:id_val');
Parameters.ParamByName('add_val').Value := cbbadd.Text;
Parameters.ParamByName('id_val').Value := cbbid.Text;
Open;
end;
end;
if (chkid.Checked = False ) and (chkadd.Checked = True) and (chksj.Checked = True) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where ACAddress =:add_val and 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('add_val').Value := cbbadd.Text;
Parameters.ParamByName('start_val').Value := dtpstart.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstop.DateTime;
Open;
end;
end;
if (chkid.Checked = True ) and (chkadd.Checked = False) and (chksj.Checked = True) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where id =:id_val and 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('id_val').Value := cbbid.Text;
Parameters.ParamByName('start_val').Value := dtpstart.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstop.DateTime;
Open;
end;
end;
if (chkid.Checked = True ) and (chkadd.Checked = True) and (chksj.Checked = True) then
begin
with qryacdata do
begin
Close;
SQL.Clear;
SQL.Add('select * from acdata where ACAddress =:add_val and id =:id_val and 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('add_val').Value := cbbadd.Text;
Parameters.ParamByName('id_val').Value := cbbid.Text;
Parameters.ParamByName('start_val').Value := dtpstart.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstop.DateTime;
Open;
end;
end;
end;
procedure TfrmQry.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//frmain.tmrTC.Enabled := True;
end;
procedure TfrmQry.btnqryrClick(Sender: TObject);
begin
if (chkidr.Checked = False) and (chkaddr.Checked = False) and (chksjr.Checked = False) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState');
Open;
end;
end;
if (chkidr.Checked = True ) and (chkaddr.Checked = False) and (chksjr.Checked = False) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where id =:id_val');
Parameters.ParamByName('id_val').Value := cbbidr.Text;
Open;
end;
end;
if (chkidr.Checked = False ) and (chkaddr.Checked = True) and (chksjr.Checked = False) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where 空调地址 =:add_val');
Parameters.ParamByName('add_val').Value := cbbaddr.Text;
Open;
end;
end;
if (chkidr.Checked = False ) and (chkaddr.Checked = False) and (chksjr.Checked = True) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('start_val').Value := dtpstartr.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstopr.DateTime;
Open;
end;
end;
if (chkidr.Checked = True ) and (chkaddr.Checked = True) and (chksjr.Checked = False) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where 空调地址 =:add_val and id =:id_val');
Parameters.ParamByName('add_val').Value := cbbaddr.Text;
Parameters.ParamByName('id_val').Value := cbbidr.Text;
Open;
end;
end;
if (chkidr.Checked = False ) and (chkaddr.Checked = True) and (chksjr.Checked = True) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where 空调地址 =:add_val and 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('add_val').Value := cbbaddr.Text;
Parameters.ParamByName('start_val').Value := dtpstartr.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstopr.DateTime;
Open;
end;
end;
if (chkidr.Checked = True ) and (chkaddr.Checked = False) and (chksjr.Checked = True) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where id =:id_val and 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('id_val').Value := cbbidr.Text;
Parameters.ParamByName('start_val').Value := dtpstartr.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstopr.DateTime;
Open;
end;
end;
if (chkidr.Checked = True ) and (chkaddr.Checked = True) and (chksjr.Checked = True) then
begin
with qryRunState do
begin
Close;
SQL.Clear;
SQL.Add('select * from RunState where 空调地址 =:add_val and id =:id_val and 时间 >=:start_val and 时间 <=:stop_val');
Parameters.ParamByName('add_val').Value := cbbaddr.Text;
Parameters.ParamByName('id_val').Value := cbbidr.Text;
Parameters.ParamByName('start_val').Value := dtpstartr.DateTime;
Parameters.ParamByName('stop_val').Value := dtpstopr.DateTime;
Open;
end;
end;
end;
procedure TfrmQry.chksjrMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if chksjr.Checked = True then
begin
dtpstartr.Enabled := True;
dtpstopr.Enabled := True;
end
else
begin
dtpstartr.Enabled := False ;
dtpstopr.Enabled := False;
end;
end;
procedure TfrmQry.chkidrMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if chkidr.Checked = True then
cbbidr.Enabled := True
else
if chkidr.Checked = False then
cbbidr.Enabled := False ;
end;
procedure TfrmQry.chkaddrMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if chkaddr.Checked = True then
cbbaddr.Enabled := True
else
if chkaddr.Checked = False then
cbbaddr.Enabled := False ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -