?? unit4.pas
字號:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, DBCtrls, Grids, DBGrids, DB, Mask,
ADODB, ComCtrls;
type
Thistory = class(TForm)
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label3: TLabel;
DBNavigator1: TDBNavigator;
ADOQuery1: TADOQuery;
Button1: TButton;
press: TButton;
time2: TDateTimePicker;
time1: TDateTimePicker;
Edit1: TEdit;
Label4: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure pressClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
history: Thistory;
FormOldWid:Integer;
implementation
uses Unit2, Unit1, Unit10, Unit11;
{$R *.dfm}
procedure Thistory.BitBtn1Click(Sender: TObject);
begin //查詢某個時間段的停車記錄
if time1.Checked and time2.Checked then
begin
if trim(edit1.Text)='' then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select carid as 車牌 ,cardid as 停車卡號,addressid as 車位編號,entime as 進場時間,outime as 離場時間,stoptime as 停車時間,charge as 收費,opname as 操作員 from history where outime between :starttime and :stoptime');
adoquery1.Parameters.ParamByName('starttime').Value:=time2.Date;
adoquery1.Parameters.ParamByName('stoptime').Value:=time1.Date;
adoquery1.Open;
end
else
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select carid as 車牌 ,cardid as 停車卡號,addressid as 車位編號,entime as 進場時間,outime as 離場時間,stoptime as 停車時間,charge as 收費,opname as 操作員 from history where outime between :starttime and :stoptime and cardid=:cardid');
adoquery1.Parameters.ParamByName('starttime').Value:=time2.Date;
adoquery1.Parameters.ParamByName('stoptime').Value:=time1.Date;
adoquery1.Parameters.ParamByName('cardid').Value:=trim(edit1.Text);
adoquery1.Open;
end
end;
press.Enabled:=true;
end;
procedure Thistory.Button1Click(Sender: TObject);
begin //刪除歷史記錄
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('delete from history where outime<:starttime and outime>:stoptime');
adoquery1.Parameters.ParamByName('starttime').Value:=time1.Date;
adoquery1.Parameters.ParamByName('stoptime').Value:=time2.Date;
adoquery1.ExecSQL;
end;
procedure Thistory.FormShow(Sender: TObject);
begin //判斷用戶的權限,只有管理員才能刪除歷史記錄
if trim(opcase)='管理員' then
button1.Enabled:=true
else
button1.Enabled:=false;
press.Enabled:=false;
FormOldWid:=self.Width;
end;
procedure Thistory.pressClick(Sender: TObject);
begin //打印歷史記錄
form10.QRLabel14.Caption:=datetostr(time2.DateTime);
form10.QRLabel15.Caption:=datetostr(time1.DateTime);
form10.QuickRep1.Preview;
end;
procedure Thistory.FormClose(Sender: TObject; var Action: TCloseAction);
begin
history:=nil;
Action:=caFree;
end;
procedure Thistory.FormResize(Sender: TObject);
begin
if FormOldWid>0 then
begin
ScaleBy(self.Width,FormOldWid);
FormOldWid:=self.Width;
end ;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -