?? unit1.pas
字號:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB,unit2,unit3;
type
TForm1 = class(TForm)
Label1: TLabel;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
ADOQuery3: TADOQuery;
Label2: TLabel;
ComboBox1: TComboBox;
Label3: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
adoquery1.Open ;
adoquery1.First;
combobox1.Items.Clear;
combobox1.Text:=' ';
while not adoquery1.Eof do
begin
combobox1.Items.Add(adoquery1.Fields[0].AsString);
adoquery1.Next;
end;
adoquery1.Close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.sql.add('select 密碼 from 登入表1 where 帳號='+''''+combobox1.Text+'''');
adoquery2.Open;
adoquery3.Close;
adoquery3.SQL.Clear;
adoquery3.sql.add('select 用戶類型 from 登入表1 where 帳號='+''''+combobox1.Text+'''');
adoquery3.Open;
if(edit1.Text=adoquery2.Fields[0].AsString) and (adoquery3.Fields[0].AsString='管理員')then
begin
form2.Show ;//密碼正確,關閉登錄窗口,進入主窗口
form1.Hide;
end
else if(edit1.Text=adoquery2.Fields[0].AsString) and (adoquery3.Fields[0].AsString='普通用戶')then
begin
form3.Show;
form1.Hide;
end
else
begin
messagedlg('密碼錯誤,請重新輸入!!!',mterror,[mbcancel],0);//密碼錯誤,重新輸入
edit1.Text:='';
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -