📄 unitgroupinfoframe.pas
字号:
unit UnitGroupInfoFrame;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, Grids, yhbGrid, StdCtrls, ADODB,
YHBCheckBoxCellEditor, VirtualDBEngine, mis_Right, AnyDBFactory;
type
TFrame_GroupInfo = class(TFrame)
ModuleGrid: TYHBStringGrid;
Splitter1: TSplitter;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
ScrollBox1: TScrollBox;
TabSheet2: TTabSheet;
FuncGrid: TYHBStringGrid;
YHBCheckBoxCellEditor2: TYHBCheckBoxCellEditor;
YHBCheckBoxCellEditor1: TYHBCheckBoxCellEditor;
procedure ModuleGridSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure FuncGridSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure ModuleGridClick(Sender: TObject);
private
FGroupInfo: TGroupInfo;
FDBFactory: TAnyDBFactory;
{ Private declarations }
public
{ Public declarations }
OldRow:Integer;
procedure ClearRow(const RowIndex:Integer);
procedure UnDisplayViewModule;
procedure DisplayGroupInfo;
property DBFactory:TAnyDBFactory read FDBFactory write FDBFactory;
property GroupInfo:TGroupInfo read FGroupInfo write FGroupInfo;
end;
implementation
uses
mis_AppStruct, mis_RightDBStore, StringOperations;
{$R *.dfm}
procedure TFrame_GroupInfo.ClearRow(const RowIndex: Integer);
var
i:Integer;
begin
for i:=0 to FuncGrid.ColCount-1 do
FuncGrid.Cells[i, RowIndex]:='';
end;
procedure TFrame_GroupInfo.UnDisplayViewModule;
var
AModule:TAppModule;
begin
if (OldRow>0)and(OldRow<ModuleGrid.RowCount) then
begin
AModule:=TAppModule(ModuleGrid.Objects[0, OldRow]);
if AModule<>nil then AModule.UnViewModule;
end;
end;
procedure TFrame_GroupInfo.ModuleGridSetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
var
AModuleRight:TModuleRight;
begin
if ModuleGrid.Row=-1 then Exit;
AModuleRight:=TModuleRight(ModuleGrid.Objects[1, ModuleGrid.Row]);
if AModuleRight=nil then Exit;
if ACol=0 then
begin
AModuleRight.CanEnter:=TextToBool(ModuleGrid.Cells[ACol, ARow]);
SetModuleChecked(FDBFactory, GroupInfo.GroupID,
AModuleRight.ModuleID, AModuleRight.CanEnter);
end;
end;
procedure TFrame_GroupInfo.FuncGridSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
var
AModuleRight:TModuleRight;
AFuncRight:TFuncRight;
begin
if ModuleGrid.Row=-1 then Exit;
AModuleRight:=TModuleRight(ModuleGrid.Objects[1, ModuleGrid.Row]);
if AModuleRight=nil then Exit;
if ACol=1 then
begin
AFuncRight:=AModuleRight.FuncRights.Items[ARow-1];
AFuncRight.Checked:=TextToBool(FuncGrid.Cells[ACol, ARow]);
SetFunctionChecked(FDBFactory, GroupInfo.GroupID,
AModuleRight.ModuleID, AFuncRight.FuncID,
AFuncRight.Checked);
end;
end;
procedure TFrame_GroupInfo.DisplayGroupInfo;
procedure DecRowCount;
begin
if ModuleGrid.RowCount>2 then
ModuleGrid.RowCount:=ModuleGrid.RowCount-1
else if ModuleGrid.RowCount=2 then
ClearRow(1);
end;
var
i:Integer;
AModule:TAppModule;
AModuleRight: TModuleRight;
begin
if GroupInfo.ModuleRights.ItemCount>0 then
begin
ModuleGrid.RowCount:=GroupInfo.ModuleRights.ItemCount+1;
for i:=0 to GroupInfo.ModuleRights.ItemCount-1 do
begin
AModuleRight:=GroupInfo.ModuleRights.Items[i];
AModule:=AModuleRight.ModuleObj;
ModuleGrid.Objects[0, i+1]:=AModule; //关联模块信息//
ModuleGrid.Objects[1, i+1]:=AModuleRight; //关联模块权限//
ModuleGrid.Cells[0, i+1]:=BoolToText(AModuleRight.CanEnter);
if GroupInfo.ModuleRights.Items[i].ModuleObj=nil then
DecRowCount
else begin
ModuleGrid.Cells[1, i+1]:=AModule.ModuleName;
ModuleGrid.Cells[2, i+1]:=AModule.Script;
end;
end;
end
else
begin
ModuleGrid.RowCount:=2;
ClearRow(1);
end;
ModuleGrid.OnClick(ModuleGrid);
end;
procedure TFrame_GroupInfo.ModuleGridClick(Sender: TObject);
var
i:Integer;
AModule:TAppModule;
AModuleRight: TModuleRight;
begin
if (OldRow<>ModuleGrid.Row) then UnDisplayViewModule;
try
if ModuleGrid.Row=-1 then Exit;
AModule:=TAppModule(ModuleGrid.Objects[0, ModuleGrid.Row]);
AModuleRight:=TModuleRight(ModuleGrid.Objects[1, ModuleGrid.Row]);
if (AModule=nil)or(AModuleRight=nil) then Exit;
if AModule.ViewModule=nil then
AModule.CreateViewModule(ScrollBox1)
else
AModule.ShowViewModule;
if AModule.Functions.ItemCount>0 then
begin
FuncGrid.RowCount:=AModule.Functions.ItemCount+1;
for i:=0 to AModule.Functions.ItemCount-1 do
begin
FuncGrid.Cells[1, i+1]:=BoolToText(AModuleRight.FuncRights.Items[i].Checked);
FuncGrid.Cells[2, i+1]:=AModule.Functions.Items[i].FuncName;
FuncGrid.Cells[3, i+1]:=AModule.Functions.Items[i].Script;
end;
end
else
begin
FuncGrid.RowCount:=2;
ClearRow(1);
end;
finally
OldRow:=ModuleGrid.Row;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -