?? unit1.pas
字號(hào):
unit Unit1;
//login
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls, Buttons;
type
Tfrm_login = class(TForm)
Image1: TImage;
Edit1: TEdit;
Edit2: TEdit;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure plogin;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_login: Tfrm_login;
m:integer = 0;
s:boolean = False;
yonghu: string;
implementation
uses Unit2, Unit13, Unit5;
{$R *.dfm}
//-------------------------退出-----------------------------//
procedure Tfrm_login.SpeedButton2Click(Sender: TObject);
begin
if s=false then
application.Terminate
else
close;
end;
//-------------------------登陸---------------------------//
procedure Tfrm_login.SpeedButton1Click(Sender: TObject);
begin
m := m+1; //記錄輸入字?jǐn)?shù),如果大于3次。則失敗
if edit1.Text='' then
application.MessageBox('請(qǐng)輸入用戶(hù)名','提示',64)
else
if edit2.Text='' then
application.MessageBox('請(qǐng)輸入密碼','提示',64)
else
plogin;
end;
//-----------------------登陸涵數(shù)-------------------//
procedure Tfrm_login.plogin;
begin
with Data1.ADOlogin do
begin
close;
sql.Clear;
sql.Add('select * from admin where admin = :a and pass = :b');
parameters.ParamByName('a').Value:=trim(edit1.Text);
parameters.ParamByName('b').Value:=trim(edit2.Text);
open;
end;
if Data1.ADOlogin.RecordCount>0 then
begin
yonghu := data1.ADOlogin.fieldByName('admin').Value;
s := True;
frm_main.StatusBar1.Panels[1].Text := yonghu; //MAIN窗口中狀態(tài)條設(shè)置顯示用戶(hù)名
frm_main.StatusBar1.Panels[3].Text := datetostr(date()); //日期
close;
end
else
if m<3 then //輸入錯(cuò)誤次數(shù)小于3
begin
application.MessageBox('用戶(hù)名或密碼錯(cuò)誤,請(qǐng)重新輸入','提示',64);
edit1.Clear;
edit2.Clear;
edit1.SetFocus; //設(shè)焦點(diǎn)
end
else
begin
application.MessageBox('你無(wú)權(quán)使用本系統(tǒng)','提示',64);
application.Terminate;
end;
end;
//----------------------關(guān)閉--------------------------------//
procedure Tfrm_login.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if s=false then
application.Terminate;
end;
//--------------------密碼DEYDOWN事件------------------//
procedure Tfrm_login.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if((Key = vk_Return) or (Key = vk_Down)) then
SpeedButton1Click(sender) //當(dāng)按下回車(chē)或向下鍵時(shí),執(zhí)行登陸
else
Edit2.SetFocus;
if Key = vk_Up then
Edit1.SetFocus; //使EDIT1焦點(diǎn)
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -