?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Menus, ExtCtrls;
type
Tf_login = class(TForm)
Label1: TLabel;
txtpassword: TEdit;
ComboBox1: TComboBox;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Timer1: TTimer;
Label4: TLabel;
Button1: TButton;
StaticText1: TStaticText;
Edit1: TEdit;
Label3: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure txtpasswordKeyPress(Sender: TObject; var Key: Char);
procedure Timer1Timer(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox1Select(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
f_login: Tf_login;
s_gb:string;
s_name:string;
s_mima:string;
s_bh:string;
implementation
uses f_main, ado_query;
{$R *.dfm}
procedure Tf_login.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure Tf_login.BitBtn1Click(Sender: TObject);
begin
if trim(combobox1.Text)='' then
begin
showmessage('請輸入用戶名');
combobox1.SetFocus;
exit;
end;
if trim(edit1.Text)='' then
begin
showmessage('請輸入編號');
edit1.SetFocus ;
exit;
end;
if trim(txtpassword.Text)='' then
begin
showmessage('請輸入密碼');
txtpassword.SetFocus;
exit;
end
else
data_1.adoquery1.close;
data_1.adoquery1.SQL.Clear;
data_1.adoquery1.SQL.Add('select * from username where username = '+char(39)+trim(combobox1.Text)+ char(39)
+'and password ='+char(39)+trim(txtpassword.Text)+char(39)+'and bh='+char(39)+trim(edit1.Text)+char(39));
data_1.adoquery1.Open;
if data_1.adoquery1.RecordCount > 0 then begin
s_name:=trim(data_1.adoquery1.fieldbyname('username').AsString );
s_mima:=trim(data_1.adoquery1.fieldbyname('password').AsString );
s_bh:=trim(data_1.adoquery1.fieldbyname('bh').AsString );
s_gb:='yes';
f_main.Form3.Show;
f_login.Hide ;
end
else begin
application.MessageBox ('你輸入的密碼不正確',char(48));
txtpassword.SetFocus ;
txtpassword.Text:='';
exit;
end;
end;
procedure Tf_login.FormShow(Sender: TObject);
var
i:integer;
begin
combobox1.Text:='';
txtpassword.Text:='';
combobox1.Clear;
data_1.adoquery1.Close;
data_1.adoquery1.SQL.Clear;
data_1.adoquery1.SQL.Add('select distinct username from username');
data_1.adoquery1.Open;
if data_1.adoquery1.RecordCount-1>0 then begin
combobox1.Clear;
data_1.adoquery1.First;
for i:=0 to data_1.adoquery1.RecordCount-1 do begin
combobox1.Items.Add(trim(data_1.adoquery1.fieldbyname('username').AsString )) ;
data_1.adoquery1.Next;
end;
end;
end;
procedure Tf_login.txtpasswordKeyPress(Sender: TObject; var Key: Char);
begin
if ord(key)=13 then
BitBtn1Click(Sender);
end;
procedure Tf_login.Timer1Timer(Sender: TObject);
begin
if (StaticText1.Left +StaticText1.Width)>self.Left then
StaticText1.Left :=0
else
StaticText1.Left :=StaticText1.Left +1;
end;
procedure Tf_login.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key=chr(13) then
if trim(combobox1.Text )<>'' then
begin
txtpassword.SetFocus;
end
else
begin
showmessage('請選擇用戶名');
combobox1.SetFocus ;
end;
end;
procedure Tf_login.ComboBox1Select(Sender: TObject);
begin
if trim(combobox1.Text )<>'' then
begin
txtpassword.SetFocus;
end
else
begin
showmessage('請選擇用戶名');
combobox1.SetFocus ;
end;
end;
procedure Tf_login.FormCreate(Sender: TObject);
begin
timer1.Enabled :=true;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -