📄 unitpopedominfo.~pas
字号:
unit UnitPopedomInfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, DB, ADODB, Grids, yhbGrid,
YHBCheckBoxCellEditor, mis_Instance, mis_AppStruct, mis_Right,
bsSkinData, BusinessSkinForm, Menus, ToolWin, ImgList, UnitGroupInfoFrame,
AnyDBFactory;
type
TForm_PopedomInfo = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
MainMenu1: TMainMenu;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
Splitter2: TSplitter;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
ImageList1: TImageList;
PageControl2: TPageControl;
TabSheet3: TTabSheet;
TreeView1: TTreeView;
Panel1: TPanel;
Panel2: TPanel;
Frame_GroupInfo: TFrame_GroupInfo;
N12: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
Label_GroupName: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N8Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N11Click(Sender: TObject);
procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
GroupRoot:TTreeNode;
UserRoot:TTreeNode;
GroupInfo:TGroupInfo;
FDBFactory: TAnyDBFactory;
function AddGroupNode(const GroupName:string):TTreeNode;
procedure SetDBFactory(const Value: TAnyDBFactory);
procedure LoadPopedomInfo;
public
{ Public declarations }
property DBFactory:TAnyDBFactory read FDBFactory write SetDBFactory;
end;
var
Form_PopedomInfo: TForm_PopedomInfo;
procedure ConfigPopedomInfo(ADBFactory:TAnyDBFactory);
implementation
uses StringOperations, BusinessDialogs, mis_RightDBStore, WinControl,
AnyDBTools;
procedure ConfigPopedomInfo(ADBFactory:TAnyDBFactory);
begin
with TForm_PopedomInfo.Create(nil) do
begin
try
DBFactory:=ADBFactory;
ShowModal;
finally
Free;
end;
end;
end;
{$R *.dfm}
procedure TForm_PopedomInfo.FormCreate(Sender: TObject);
begin
GroupRoot:=TreeView1.Items[0];
UserRoot:=TreeView1.Items[1];
GroupInfo:=TGroupInfo.Create;
Frame_GroupInfo.GroupInfo:=GroupInfo;
end;
procedure TForm_PopedomInfo.FormDestroy(Sender: TObject);
begin
GroupInfo.Free;
end;
procedure TForm_PopedomInfo.N7Click(Sender: TObject);
var
NewString: string;
ClickedOK: Boolean;
aNode:TTreeNode;
begin
NewString := '新用户组';
ClickedOK := InputQuery('请填写用户组名', '用户组名:', NewString);
if not ClickedOK then Exit;
if UserGroupExists(FDBFactory, NewString) then
WarningAbort('提示', '用户组已经存在!');
if not AddUserGroup(FDBFactory, NewString) then
WarningAbort('提示', '未知原因导致增加用户组失败!');
aNode:=AddGroupNode(NewString);
if aNode<>nil then TreeView1.Selected:=aNode;
end;
procedure TForm_PopedomInfo.N8Click(Sender: TObject);
var
aNode:TTreeNode;
begin
if TreeView1.Selected<>nil then
begin
DeleteUserGroup(FDBFactory, GroupInfo.GroupID);
aNode:=TreeView1.Selected.GetNext;
if aNode=nil then TreeView1.Selected.GetPrev;
TreeView1.Selected.Delete;
if aNode<>nil then TreeView1.Selected:=aNode;
end;
end;
procedure TForm_PopedomInfo.N9Click(Sender: TObject);
var
NewString: string;
ClickedOK: Boolean;
begin
if TreeView1.Selected<>nil then
begin
NewString := GroupInfo.GroupName;
ClickedOK := InputQuery('请填写用户名', '用户名:', NewString);
if not ClickedOK then Exit;
ChangeUserGroupName(FDBFactory, GroupInfo.GroupID, NewString);
GroupInfo.GroupName:=NewString;
TreeView1.Selected.Text:=NewString;
end;
end;
procedure TForm_PopedomInfo.N14Click(Sender: TObject);
begin
RetureModules(FDBFactory);
end;
procedure TForm_PopedomInfo.N11Click(Sender: TObject);
var
ANode:TTreeNode;
begin
ANode:=TreeView1.Selected;
if (ANode<>nil)and(ANode.Parent=GroupRoot) then
begin
RetrueUserGroup(FDBFactory, GroupInfo.GroupID);
TreeView1.OnChange(TreeView1, ANode);
end;
end;
procedure TForm_PopedomInfo.TreeView1Change(Sender: TObject; Node: TTreeNode);
var
PNode:TTreeNode;
begin
Label_GroupName.Caption:='';
PNode:=Node.Parent;
if PNode=GroupRoot then
begin
Frame_GroupInfo.UnDisplayViewModule;
LoadGroupInfo(FDBFactory, Node.Text, GroupInfo);
Label_GroupName.Caption:=GroupInfo.GroupName;
Frame_GroupInfo.DisplayGroupInfo;
end;
end;
function TForm_PopedomInfo.AddGroupNode(const GroupName:string):TTreeNode;
begin
Result:=TreeView1.Items.AddChild(GroupRoot, GroupName);
Result.ImageIndex:=0;
Result.SelectedIndex:=0;
end;
procedure TForm_PopedomInfo.LoadPopedomInfo;
var
i:Integer;
List:TStringList;
begin
List:=TStringList.Create;
try
LoadUserGroups(FDBFactory, List);
for i:=0 to List.Count-1 do
AddGroupNode(List.Strings[i]);
finally
List.Free;
end;
Frame_GroupInfo.OldRow:=Frame_GroupInfo.ModuleGrid.Row;
GroupRoot.Expand(True);
UserRoot.Expand(True);
if GroupRoot.Count>0 then
TreeView1.Selected:=GroupRoot.Item[0];
end;
procedure TForm_PopedomInfo.FormShow(Sender: TObject);
begin
{修正模块列表}
RetureModules(FDBFactory);
{修正所有用户组}
RetureUserGroups(FDBFactory);
{加载所有用户组}
LoadPopedomInfo;
end;
procedure TForm_PopedomInfo.SetDBFactory(const Value: TAnyDBFactory);
begin
FDBFactory := Value;
Frame_GroupInfo.DBFactory:=FDBFactory;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -