基Form:unit Base;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, Buttons, ExtCtrls,CommDeclare,dxDBGrid;type TBase_f = class(TForm) pnl_toolbar: TPanel; btnSB_New: TSpeedButton; btnSB_Modi: TSpeedButton; btnSB_Del: TSpeedButton; btnSB_Print: TSpeedButton; btnSB_Exit: TSpeedButton; btnSB_Save: TSpeedButton; btnSB_Cancel: TSpeedButton; btnSB_Search: TSpeedButton; btnSB_Approve: TSpeedButton; btnSB_Back: TSpeedButton; btnSB_SaveNew: TSpeedButton; qry_BaseTemp: TADOQuery; procedure FormKeyPress(Sender: TObject; var Key: Char); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure btnSB_ExitClick(Sender: TObject); private { Private declarations } protected function HaveRight(ModuleID: integer;UserID: string;aRight: TRight): Boolean; public { Public declarations } end;var Base_f: TBase_f;implementationuses sys_datamoudle;{$R *.dfm}procedure TBase_f.FormKeyPress(Sender: TObject; var Key: Char); begin if key=#13 then if (ActiveControl is TdxDBGrid) then begin with TdxDBGrid(ActiveControl) do if FocusedColumn<ColumnCount-1 then FocusedColumn:=FocusedColumn+1 else if FocusedNode.IsLast=True then FocusedColumn:=0; end else begin Key:= #0; Perform(WM_NEXTDLGCTL, 0, 0); end; end;procedure TBase_f.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end;procedure TBase_f.btnSB_ExitClick(Sender: TObject); begin Close; end; function TBase_f.HaveRight(ModuleID: integer;UserID: string; aRight: TRight): Boolean; begin with qry_BaseTemp do begin Close; SQL.Clear; SQL.Add('select max(ModuleRight)as ModuleRight,max(InsertRight)as InsertRight,max(ModifyRight)as ModifyRight,'); SQL.add(' max(DeleteRight)as DeleteRight,max(PrintRight)as PrintRight,max(ApproveRight)as ApproveRight,max(BackRight)'); SQL.add(' as BackRight,max(BatchRight)as BatchRight from SYS_RIGHT_NEW a left join SYS_USERGROUP b on a.GroupID=b.GroupID'); SQL.add(' where b.Account_ID='''+UserID+''' and a.MODULEID='''+inttostr(ModuleID)+''' group by MODULEID'); Open; case aRight of rModule: Result := FieldByName('ModuleRight').AsInteger=1; rInsert: Result := FieldByName('InsertRight').AsInteger=1; rModify: Result := FieldByName('ModifyRight').AsInteger=1; rDelete: Result := FieldByName('DeleteRight').AsInteger=1; rPrint: Result := FieldByName('PrintRight').AsInteger=1; rReadAll: Result := FieldByName('ReadAll').AsInteger=1; rApprove: Result := FieldByName('ApproveRight').AsInteger=1; rBack: Result := FieldByName('BackRight').AsInteger=1; else Result := False; end; Close; end; end; end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Buttons, ExtCtrls,CommDeclare,dxDBGrid;type
TBase_f = class(TForm)
pnl_toolbar: TPanel;
btnSB_New: TSpeedButton;
btnSB_Modi: TSpeedButton;
btnSB_Del: TSpeedButton;
btnSB_Print: TSpeedButton;
btnSB_Exit: TSpeedButton;
btnSB_Save: TSpeedButton;
btnSB_Cancel: TSpeedButton;
btnSB_Search: TSpeedButton;
btnSB_Approve: TSpeedButton;
btnSB_Back: TSpeedButton;
btnSB_SaveNew: TSpeedButton;
qry_BaseTemp: TADOQuery;
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnSB_ExitClick(Sender: TObject);
private
{ Private declarations }
protected
function HaveRight(ModuleID: integer;UserID: string;aRight: TRight): Boolean;
public
{ Public declarations }
end;var
Base_f: TBase_f;implementationuses sys_datamoudle;{$R *.dfm}procedure TBase_f.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
if (ActiveControl is TdxDBGrid) then
begin
with TdxDBGrid(ActiveControl) do
if FocusedColumn<ColumnCount-1 then
FocusedColumn:=FocusedColumn+1
else
if FocusedNode.IsLast=True then FocusedColumn:=0;
end
else
begin
Key:= #0;
Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;procedure TBase_f.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;procedure TBase_f.btnSB_ExitClick(Sender: TObject);
begin
Close;
end;
function TBase_f.HaveRight(ModuleID: integer;UserID: string; aRight: TRight): Boolean;
begin
with qry_BaseTemp do
begin
Close;
SQL.Clear;
SQL.Add('select max(ModuleRight)as ModuleRight,max(InsertRight)as InsertRight,max(ModifyRight)as ModifyRight,');
SQL.add(' max(DeleteRight)as DeleteRight,max(PrintRight)as PrintRight,max(ApproveRight)as ApproveRight,max(BackRight)');
SQL.add(' as BackRight,max(BatchRight)as BatchRight from SYS_RIGHT_NEW a left join SYS_USERGROUP b on a.GroupID=b.GroupID');
SQL.add(' where b.Account_ID='''+UserID+''' and a.MODULEID='''+inttostr(ModuleID)+''' group by MODULEID');
Open;
case aRight of
rModule: Result := FieldByName('ModuleRight').AsInteger=1;
rInsert: Result := FieldByName('InsertRight').AsInteger=1;
rModify: Result := FieldByName('ModifyRight').AsInteger=1;
rDelete: Result := FieldByName('DeleteRight').AsInteger=1;
rPrint: Result := FieldByName('PrintRight').AsInteger=1;
rReadAll: Result := FieldByName('ReadAll').AsInteger=1;
rApprove: Result := FieldByName('ApproveRight').AsInteger=1;
rBack: Result := FieldByName('BackRight').AsInteger=1;
else Result := False;
end;
Close;
end;
end;
end.