?? unit2.~pas
字號(hào):
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,DBTables,BDE;
type
TfrmLogin = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmLogin: TfrmLogin;
implementation
uses Unit1;
{$R *.dfm}
procedure TfrmLogin.Button2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TfrmLogin.FormCreate(Sender: TObject);
var
Query:TQuery;
begin
comboBox1.Clear;
try
Query:=TQuery.Create(nil);
Query.close;
Query.DatabaseName:='cc';
Query.SQL.Clear;
Query.SQL.Add('select userName from operator ');
Query.Open;
if Query.RecordCount=0 then
begin
MessageDlg('沒(méi)有可以登錄的用戶(hù)名' ,mtError,[mbok],0);
Exit;
end else
begin
Query.First;
while Query.Eof=false do
begin
comboBox1.Items.Add(Query.FieldByName('userName').asstring);
Query.next;
end;
end;
Query.Close;
Query.Free;
comboBox1.ItemIndex:=0;
except MessageDlg('連接數(shù)據(jù)庫(kù)出錯(cuò)' ,mtError,[mbok],0);
end;
end;
procedure TfrmLogin.Button1Click(Sender: TObject);
var
Query:TQuery;
begin
try
Query:=TQuery.Create(nil);
Query.DatabaseName:='cc';
Query.SQL.Add('select * from Operator where UserName=:UserName and userpwd=:userpwd');
Query.Params.ParamByName('UserName').Value:=comboBox1.Text;
Query.Params.ParamByName('userpwd').Value:=edit1.Text;
Query.Open;
if Query.RecordCount=0 then
begin
MessageDlg('請(qǐng)輸入正確的用戶(hù)名和密碼',mtError,[mbok],0);
Exit;
end;
Query.Close;
Query.Free;
frmRoom.Show;
frmLogin.close;
except
MessageDlg('連接數(shù)據(jù)庫(kù)出錯(cuò)',mtError,[mbok],0);
end;
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -