?? u_login.pas
字號:
unit U_login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBTables, DB, Grids, DBGrids, StdCtrls;
type
TForm_login = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
edit_user: TEdit;
edit_passwd: TEdit;
Btn_login: TButton;
btn_cancel: TButton;
Query1: TQuery;
Database1: TDatabase;
procedure Btn_loginClick(Sender: TObject);
procedure btn_cancelClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_login: TForm_login;
implementation
uses U_main;
{$R *.dfm}
procedure TForm_login.Btn_loginClick(Sender: TObject);
begin
try
database1.Connected:=True; //打開數據庫連接
query1.close;
query1.ParamByName('id').Value:=edit_user.Text; //給query組件參數賦值
query1.Open; //用 query組件查詢記錄
Except
Application.MessageBox('請與系統管理員聯系。','數據庫連接錯誤!',mb_ok);
Application.Terminate; //數據庫連接錯誤,中斷程序
end;
if query1.Fields[0].value=null then //沒有檢索出密碼
begin
Application.MessageBox('請確認用戶名是否正確!','用戶名錯誤!',mb_ok);
exit;
end;
if query1.Fields[0].value=edit_passwd.Text then
begin
if query1.Fields[1].value='1' then
begin
Form_login.hide;
form_main.show;
end
else
Application.MessageBox('請選擇合適的登錄軟件!','用戶權限錯誤!',mb_ok);
end
else
Application.MessageBox('密碼不正確,注意大小寫!','密碼錯誤!',mb_ok);
end ;
procedure TForm_login.btn_cancelClick(Sender: TObject);
begin
close;
end;
procedure TForm_login.FormCreate(Sender: TObject);
begin
edit_user.Text:='';
edit_passwd.Text:='';
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -