📄 unitwarninfosearch.~pas
字号:
unit UnitWarnInfoSearch;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Mask, DBCtrls, Buttons, ToolWin,
ComCtrls;
type
Tfrm_WarnInfoSearch = class(TForm)
GroupBox1: TGroupBox;
Cb_Equipment_NO: TCheckBox;
Cb_Equipment_Name: TCheckBox;
Cob_Equipment_NO: TComboBox;
Cob_Equipment_Name: TComboBox;
Cb_Warn_Time: TCheckBox;
Cob_Warn_Time: TComboBox;
ToolBar2: TToolBar;
Cmd_Search: TSpeedButton;
Cmd_Pweview: TSpeedButton;
Cmd_Print: TSpeedButton;
Cmd_Exit: TSpeedButton;
Cmd_Cancel: TSpeedButton;
Cob_StopWarn_Time: TComboBox;
Cb_StopWarn_Time: TCheckBox;
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBGrid1: TDBGrid;
CheckBox1: TCheckBox;
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
MaskEdit3: TMaskEdit;
CheckBox2: TCheckBox;
MaskEdit4: TMaskEdit;
procedure Cb_Equipment_NOClick(Sender: TObject);
procedure Cb_Equipment_NameClick(Sender: TObject);
procedure Cb_Warn_TimeClick(Sender: TObject);
procedure Cb_StopWarn_TimeClick(Sender: TObject);
procedure Cmd_SearchClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure Cmd_CancelClick(Sender: TObject);
procedure Cmd_PweviewClick(Sender: TObject);
procedure Cmd_PrintClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_WarnInfoSearch: Tfrm_WarnInfoSearch;
implementation
uses UnitDataModule, UnitReport, UnitPublic, Preview;
{$R *.dfm}
procedure Tfrm_WarnInfoSearch.Cb_Equipment_NOClick(Sender: TObject);
begin
if Cb_Equipment_NO.Checked=true then
begin
Cob_Equipment_NO.Clear;
Cob_Equipment_NO.Visible:=True;
with frm_DataModule.ADO_QueryItem do
begin
Close;
Sql.Clear;
Sql.Add('Select distinct Equipment_NO from [WarnInfo]');
prepared;
Open;
while not eof do
begin
Cob_Equipment_NO.Items.Add(FieldByName('Equipment_NO').AsString);
Next;
end;
end;
end
else
begin
Cob_Equipment_NO.Visible:=False;
Cob_Equipment_NO.Clear;
end;
end;
procedure Tfrm_WarnInfoSearch.Cb_Equipment_NameClick(Sender: TObject);
begin
if Cb_Equipment_Name.Checked=true then
begin
Cob_Equipment_Name.Clear;
Cob_Equipment_Name.Visible:=True;
with frm_DataModule.ADO_QueryItem do
begin
Close;
Sql.Clear;
Sql.Add('Select distinct Equipment_Name from [WarnInfo]');
prepared;
Open;
while not eof do
begin
Cob_Equipment_Name.Items.Add(FieldByName('Equipment_Name').AsString);
Next;
end;
end;
end
else
begin
Cob_Equipment_Name.Visible:=False;
Cob_Equipment_Name.Clear;
end;
end;
procedure Tfrm_WarnInfoSearch.Cb_Warn_TimeClick(Sender: TObject);
begin
if Cb_Warn_Time.Checked=true then
begin
Cob_Warn_Time.Clear;
Cob_Warn_Time.Visible:=True;
with frm_DataModule.ADO_QueryItem do
begin
Close;
Sql.Clear;
Sql.Add('Select distinct Warn_Time from [WarnInfo]');
prepared;
Open;
while not eof do
begin
Cob_Warn_Time.Items.Add(FieldByName('Warn_Time').AsString);
Next;
end;
end;
end
else
begin
Cob_Warn_Time.Visible:=False;
Cob_Warn_Time.Clear;
end;
end;
procedure Tfrm_WarnInfoSearch.Cb_StopWarn_TimeClick(Sender: TObject);
begin
if Cb_StopWarn_Time.Checked=true then
begin
Cob_StopWarn_Time.Clear;
Cob_StopWarn_Time.Visible:=True;
with frm_DataModule.ADO_QueryItem do
begin
Close;
Sql.Clear;
Sql.Add('Select distinct StopWarn_Time from [WarnInfo]');
prepared;
Open;
while not eof do
begin
Cob_StopWarn_Time.Items.Add(FieldByName('StopWarn_Time').AsString);
Next;
end;
end;
end
else
begin
Cob_StopWarn_Time.Visible:=False;
Cob_StopWarn_Time.Clear;
end;
end;
procedure Tfrm_WarnInfoSearch.Cmd_SearchClick(Sender: TObject);
var
SqlStr:String;
begin
SqlStr:=' Select ID,Equipment_NO,Equipment_Name,Warn_Time,StopWarn_Time From [WarnInfo] where ';
if Cb_Equipment_NO.Checked=True then
begin
SqlStr:=SqlStr+' Equipment_NO like '+''''+'%'+ Trim(Cob_Equipment_NO.Text)+'%'+''''+' and ';
end;
if Cb_Equipment_Name.Checked=True then
begin
SqlStr:=SqlStr+' Equipment_Name like '+''''+'%'+ Trim(Cob_Equipment_Name.Text)+'%'+''''+' and ';
end;
if Cb_Warn_Time.Checked=True then
begin
//SqlStr:=SqlStr+' Warn_Time like '+''''+'%'+ Trim(Cob_Warn_Time.Text)+'%'+''''+' and ';
SqlStr:=SqlStr+' Warn_Time = '+''''+ Trim(Cob_Warn_Time.Text)+''''+' and ';
end;
if Cb_StopWarn_Time.Checked=True then
begin
//SqlStr:=SqlStr+' StopWarn_Time like '+''''+'%'+ Trim(Cob_StopWarn_Time.Text)+'%'+''''+' and ';
SqlStr:=SqlStr+' StopWarn_Time = '+''''+ Trim(Cob_StopWarn_Time.Text)+''''+' and ';
end;
if CheckBox1.Checked=True then
begin
if (trim(MaskEdit1.Text)<>'- - : :') and (trim(MaskEdit2.Text)<>'- - : :')then
begin
//SqlStr:=SqlStr+' Warn_Time between '+''''+Trim(MaskEdit1.Text)+''''+' and '+''''+Trim(MaskEdit2.Text)+''''+' and ';//
//SqlStr:=SqlStr+' Warn_Time between '''+Trim(MaskEdit1.Text)+''' and '''+Trim(MaskEdit3.Text)+''''+' and ';
SqlStr:=SqlStr+' Warn_Time between '''+Trim(MaskEdit1.Text)+''' and '''+Trim(MaskEdit2.Text)+''''+' and ';
end;
end;
if CheckBox2.Checked=True then
begin
if (trim(MaskEdit3.Text)<>'- - : :') and (trim(MaskEdit4.Text)<>'- - : :')then
begin
//SqlStr:=SqlStr+' StopWarn_Time between '+''''+Trim(MaskEdit3.Text)+''''+' and '+''''+Trim(MaskEdit4.Text)+''''+' and ';//
//SqlStr:=SqlStr+' StopWarn_Time between '''+Trim(MaskEdit3.Text)+''' and '''+Trim(MaskEdit4.Text)+''''+' and ';
SqlStr:=SqlStr+' StopWarn_Time between '''+Trim(MaskEdit3.Text)+''' and '''+Trim(MaskEdit4.Text)+''''+' and ';
end;
end;
SqlStr:=Copy(SqlStr,0,length(SqlStr)-4);
with frm_DataModule.ADO_QuerySearch do
begin
Close;
Sql.Clear;
Sql.Add(SqlStr);
try
Open;
Prepared;
if frm_DataModule.ADO_QuerySearch.RecordCount<>0 then
begin
Cmd_Print.Enabled:=True;
Cmd_Pweview.Enabled:=True;
frm_DataModule.DataSourceSearch.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_DataModule.DataSourceSearch.Enabled:=True;
DBGrid1.DataSource:=frm_DataModule.DataSourceSearch;
DBGrid1.Columns[0].Title.Caption:='自动编号';
DBGrid1.Columns[1].Title.Caption:='设备编号';
DBGrid1.Columns[2].Title.Caption:='设备名称';
DBGrid1.Columns[3].Title.Caption:='报警时间';
DBGrid1.Columns[4].Title.Caption:='撤防时间';
end;
except
end;
end;
end;
procedure Tfrm_WarnInfoSearch.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked=true then
begin
MaskEdit1.Visible:=True;
MaskEdit2.Visible:=True;
MaskEdit1.Clear;
MaskEdit2.Clear;
end
else
begin
MaskEdit1.Visible:=False;
MaskEdit2.Visible:=False;
MaskEdit1.Clear;
MaskEdit2.Clear;
end;
end;
procedure Tfrm_WarnInfoSearch.CheckBox2Click(Sender: TObject);
begin
if CheckBox2.Checked=true then
begin
MaskEdit3.Visible:=True;
MaskEdit4.Visible:=True;
MaskEdit3.Clear;
MaskEdit4.Clear;
end
else
begin
MaskEdit3.Visible:=False;
MaskEdit4.Visible:=False;
MaskEdit3.Clear;
MaskEdit4.Clear;
end;
end;
procedure Tfrm_WarnInfoSearch.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frm_DataModule.ADO_QueryItem.Close;
frm_DataModule.ADO_QuerySearch.Close;
frm_DataModule.ADO_QuerySearch.Close;
Action:=Cafree;
end;
procedure Tfrm_WarnInfoSearch.FormDestroy(Sender: TObject);
begin
frm_DataModule.ADO_QueryItem.Close;
frm_DataModule.ADO_QuerySearch.Close;
end;
procedure Tfrm_WarnInfoSearch.Cmd_CancelClick(Sender: TObject);
begin
Close;
end;
procedure Tfrm_WarnInfoSearch.Cmd_PweviewClick(Sender: TObject);
var
SqlStr:String;
begin
SqlStr:=' Select ID,Equipment_NO,Equipment_Name,Warn_Time,StopWarn_Time From [WarnInfo] where ';
if Cb_Equipment_NO.Checked=True then
begin
SqlStr:=SqlStr+' Equipment_NO like '+''''+'%'+ Trim(Cob_Equipment_NO.Text)+'%'+''''+' and ';
end;
if Cb_Equipment_Name.Checked=True then
begin
SqlStr:=SqlStr+' Equipment_Name like '+''''+'%'+ Trim(Cob_Equipment_Name.Text)+'%'+''''+' and ';
end;
if Cb_Warn_Time.Checked=True then
begin
SqlStr:=SqlStr+' Warn_Time = '+''''+ Trim(Cob_Warn_Time.Text)+''''+' and ';
end;
if Cb_StopWarn_Time.Checked=True then
begin
SqlStr:=SqlStr+' StopWarn_Time = '+''''+ Trim(Cob_StopWarn_Time.Text)+''''+' and ';
end;
if CheckBox1.Checked=True then
begin
if (trim(MaskEdit1.Text)<>'- - : :') and (trim(MaskEdit2.Text)<>'- - : :')then
begin
SqlStr:=SqlStr+' Warn_Time between '''+Trim(MaskEdit1.Text)+''' and '''+Trim(MaskEdit2.Text)+''''+' and ';
end;
end;
if CheckBox2.Checked=True then
begin
if (trim(MaskEdit3.Text)<>'- - : :') and (trim(MaskEdit4.Text)<>'- - : :')then
begin
SqlStr:=SqlStr+' StopWarn_Time between '''+Trim(MaskEdit3.Text)+''' and '''+Trim(MaskEdit4.Text)+''''+' and ';
end;
end;
SqlStr:=Copy(SqlStr,0,length(SqlStr)-4);
with frm_DataModule.ADO_QuerySearch do
begin
Close;
Sql.Clear;
Sql.Add(SqlStr);
try
Open;
Prepared;
if frm_DataModule.ADO_QuerySearch.RecordCount<>0 then
begin
frm_Preview:=Tfrm_Preview.Create(self);
frm_Report:=Tfrm_Report.Create(self);
frm_Report.WarnLogtitle.Caption:=SoftUserName+frm_Report.WarnLogtitle.Caption;
frm_Report.Lab_WarnRecord.Caption:='总共有 '+IntToStr(RecordCount)+' 条记录';
frm_Report.Lab_WarnLogin.Caption:='制表人员:'+Longname;
frm_Report.Lab_WarnTime.Caption:='制表时间:'+DateTimeToStr(now);
frm_Report.Rep_WarnLog.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_Equipment_NO.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_Equipment_Name.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_Warn_Time.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_StopWarn_Time.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Rep_WarnLog.Prepare;
frm_Preview.ShowModal(frm_Report.Rep_WarnLog,'【红外报警信息】');
frm_Report.Free;
frm_Preview.Free;
end;
except
end;
end;
end;
procedure Tfrm_WarnInfoSearch.Cmd_PrintClick(Sender: TObject);
var
SqlStr:String;
begin
SqlStr:=' Select ID,Equipment_NO,Equipment_Name,Warn_Time,StopWarn_Time From [WarnInfo] where ';
if Cb_Equipment_NO.Checked=True then
begin
SqlStr:=SqlStr+' Equipment_NO like '+''''+'%'+ Trim(Cob_Equipment_NO.Text)+'%'+''''+' and ';
end;
if Cb_Equipment_Name.Checked=True then
begin
SqlStr:=SqlStr+' Equipment_Name like '+''''+'%'+ Trim(Cob_Equipment_Name.Text)+'%'+''''+' and ';
end;
if Cb_Warn_Time.Checked=True then
begin
SqlStr:=SqlStr+' Warn_Time = '+''''+ Trim(Cob_Warn_Time.Text)+''''+' and ';
end;
if Cb_StopWarn_Time.Checked=True then
begin
SqlStr:=SqlStr+' StopWarn_Time = '+''''+ Trim(Cob_StopWarn_Time.Text)+''''+' and ';
end;
if CheckBox1.Checked=True then
begin
if (trim(MaskEdit1.Text)<>'- - : :') and (trim(MaskEdit2.Text)<>'- - : :')then
begin
SqlStr:=SqlStr+' Warn_Time between '''+Trim(MaskEdit1.Text)+''' and '''+Trim(MaskEdit2.Text)+''''+' and ';
end;
end;
if CheckBox2.Checked=True then
begin
if (trim(MaskEdit3.Text)<>'- - : :') and (trim(MaskEdit4.Text)<>'- - : :')then
begin
SqlStr:=SqlStr+' StopWarn_Time between '''+Trim(MaskEdit3.Text)+''' and '''+Trim(MaskEdit4.Text)+''''+' and ';
end;
end;
SqlStr:=Copy(SqlStr,0,length(SqlStr)-4);
with frm_DataModule.ADO_QuerySearch do
begin
Close;
Sql.Clear;
Sql.Add(SqlStr);
try
Open;
Prepared;
if frm_DataModule.ADO_QuerySearch.RecordCount<>0 then
begin
frm_Report:=Tfrm_Report.Create(self);
frm_Report.WarnLogtitle.Caption:=SoftUserName+frm_Report.WarnLogtitle.Caption;
frm_Report.Lab_WarnRecord.Caption:='总共有 '+IntToStr(RecordCount)+' 条记录';
frm_Report.Lab_WarnLogin.Caption:='制表人员:'+Longname;
frm_Report.Lab_WarnTime.Caption:='制表时间:'+DateTimeToStr(now);
frm_Report.Rep_WarnLog.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_Equipment_NO.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_Equipment_Name.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_Warn_Time.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Text_StopWarn_Time.DataSet:=frm_DataModule.ADO_QuerySearch;
frm_Report.Rep_WarnLog.Print;
frm_Report.Free;
end;
except
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -