unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
ADOQuery1: TADOQuery;
Button2: TButton;
procedure Edit3Exit(Sender: TObject);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3, Unit7;
{$R *.dfm}
procedure TForm1.Edit3Exit(Sender: TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add('select 用户名 from 用户清单 where 用户编号='''+edit3.text+'''');
adoquery1.open;
edit1.Text:=adoquery1.fieldbyname('用户名').AsString;
end;
procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.add('select 用户名 from 用户清单 where 用户编号='''+edit3.text+'''');
adoquery1.open;
edit1.Text:=adoquery1.fieldbyname('用户名').AsString;
end;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
button1.Click;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
user,pass,temp:string;
begin
user:=edit1.text;
pass:=edit2.text;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 用户名 from 用户清单 where 用户名='+user+'and 密码='+pass+'';
adoquery1.open;
temp:=adoquery1.fieldbyname('用户编号').AsString;
if temp<>'' then
begin
form2.button1.enabled:=false;
form2.button2.enabled:=false;
form2.button3.enabled:=false;
form2.button4.enabled:=false;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 权限序号 from 权限清单 where 用户编码='''+temp+''' and 权限名称=''药品买入单''';
adoquery1.Open;
if adoquery1.FieldByName('权限序号').AsString<>'' then
form2.button2.Enabled:=true;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 权限序号 from 权限清单 where 用户编码='''+temp+''' and 权限名称=''膳食查询''';
adoquery1.Open;
if adoquery1.FieldByName('权限序号').AsString<>'' then
form2.button3.Enabled:=true;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 权限序号 from 权限清单 where 用户编码='''+temp+''' and 权限名称=''权限管理''';
adoquery1.Open;
if adoquery1.FieldByName('权限序号').AsString<>'' then
form2.button4.Enabled:=true;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 权限序号 from 权限清单 where 用户编码='''+temp+''' and 权限名称=''药品储备管理''';
adoquery1.Open;
if adoquery1.FieldByName('权限序号').AsString<>'' then
begin
guanli.n2.enabled:=true;
form2.button2.Enabled:=true;
end;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 权限序号 from 权限清单 where 用户编码='''+temp+''' and 权限名称=''病人资料管理''';
adoquery1.Open;
if adoquery1.FieldByName('权限序号').AsString<>'' then
begin
guanli.n3.enabled:=true;
form2.button2.Enabled:=true;
end;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.text:='select 权限序号 from 权限清单 where 用户编码='''+temp+''' and 权限名称=''病种资料管理''';
adoquery1.Open;
if adoquery1.FieldByName('权限序号').AsString<>'' then
begin
guanli.n4.enabled:=true;
form2.button1.Enabled:=true;
end;
form2.visible:=true;
form2.statusbar1.panels[0].text:=user;
form1.hide;
end
else
begin
showmessage('用户名或密码错误,请检查后重新登录');
end
end;
procedure TForm1.FormShow(Sender: TObject);
begin
edit1.clear;
edit2.clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
zhuce.visible:=true;
end;
end.
有权限设置`