?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Label3: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
UserType: string;
UserName: string;
DataFile: string;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ADOQuery1: TADOQuery;
begin
{數據庫操作:判斷用戶和密碼是否正確}
if (edit1.Text<>'') and (edit2.Text<>'') then
begin
ADOQuery1:= TADOQuery.Create(self);
ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\zhang\data\zl.mdb;Persist Security Info=False';
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from master where mname="'+edit1.Text+'" and password="'+edit2.Text+'" ');
ADOQuery1.Open;
if (edit1.Text=ADOQuery1.FieldByName('mname').AsString) and (edit2.Text=ADOQuery1.FieldByName('password').AsString) then
begin
{用戶和密碼正確,登錄成功,并獲取用戶的權限類型}
UserType := ADOQuery1.FieldByName('type').AsString;
UserName := ADOQuery1.FieldByName('mname').AsString;
ADOQuery1.Free;
Form1.Hide;
form2.ShowModal;
end
else
application.MessageBox('用戶名或者密碼錯誤,登錄失敗!','提示');
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -