//创建窗体
procedure TFMW_JSGL.FormCreate(Sender: TObject);
begin
Left := 0;
Top := 0;
Height := gChildHeight;
Width := gChildWidth;
//构造系统功能树
MakeSysFuncTree;
DQ_JS.Open;
end;
//关闭前置处理
procedure TFMW_JSGL.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := True;
end;
//关闭窗口
procedure TFMW_JSGL.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := CaFree;
end;
//构造系统功能目录
Procedure TFMW_JSGL.MakeSysFuncTree;
Var Node_MK,Node_ZMK,Node_GN: TTreeNode;
s:String;
Begin
TV_XTGN.Items.Clear;
//打开数据集
if DQ_MK.Active then DQ_MK.Close; DQ_MK.Open;
if DQ_ZMK.Active then DQ_ZMK.Close; DQ_ZMK.Open;
if DQ_GN.Active then DQ_GN.Close; DQ_GN.Open;
//装载根目录(模块)
While Not DQ_MK.Eof Do
Begin
Node_MK := TV_XTGN.Items.AddObject(nil
,DQ_MKMKMC.Value,DQ_MK.GetBookmark) ;
Node_MK.ImageIndex := 0 ;
Node_MK.SelectedIndex := 3 ;
With DQ_ZMK Do
Begin
Filtered := False ;
Filter := 'MKBM_PK='''+DQ_MKMKBM_PK.Value+'''' ;
Filtered := True ;
First ;
End;
//装载一级目录(子模块)
While Not DQ_ZMK.Eof Do
Begin
Node_ZMK := TV_XTGN.Items.AddChildObject(Node_MK
,DQ_ZMKZMKMC.Value,DQ_ZMK.GetBookmark) ;
Node_ZMK.ImageIndex := 1 ;
Node_ZMK.SelectedIndex := 3 ;
With DQ_GN Do
Begin
Filtered := False ;
Filter := 'ZMKBM_PK='''+DQ_ZMKZMKBM_PK.Value+'''' ;
Filtered := True ;
First ;
End;
//装载二级目录(功能)
While Not DQ_GN.Eof Do
Begin
s := DQ_GNGNMC.Value;
if DQ_GNBZ.Value<>'' then s := s+'('+DQ_GNBZ.Value+')';
Node_GN := TV_XTGN.Items.AddChildObject(Node_ZMK
,s,DQ_GN.GetBookmark) ;
Node_GN.ImageIndex := 2 ;
Node_GN.SelectedIndex := 4 ;
DQ_GN.Next;
End;
DQ_ZMK.Next;
End;
DQ_MK.Next;
End;
DQ_ZMK.Filtered := False ;
DQ_GN.Filtered := False ;
End;
//系统功能目录当前节点变化
procedure TFMW_JSGL.TV_XTGNChange(Sender: TObject; Node: TTreeNode);
begin
Case Node.Level of
0
Q_MK.GotoBookmark(Node.Data);
1
Q_ZMK.GotoBookmark(Node.Data);
2
Q_GN.GotoBookmark(Node.Data);
End;
end;
//数据状态发生变化处理:改变Action的状态
procedure TFMW_JSGL.DS_JSDataChange(Sender: TObject; Field: TField);
begin
Act_Add.Enabled := DQ_JS.Active;
Act_Del.Enabled := Not DQ_JS.IsEmpty;
Act_Clone.Enabled := Act_Del.Enabled;
Act_Valid.Enabled := Act_Del.Enabled;
if Act_Valid.Enabled then
Act_Valid.Enabled := Act_Valid.Enabled And (DQ_JSYXBZ.Value='0');
Act_InValid.Enabled := Act_Del.Enabled;
if Act_InValid.Enabled then Act_InValid.Enabled := not Act_Valid.Enabled;
end;
//添加角色
procedure TFMW_JSGL.Act_AddExecute(Sender: TObject);
Var sID ,sErrMsg: String;
begin
if Not PubGetNextSqNum('SYS_S_JSBM',sID,sErrMsg) then
Begin
PubMsgDlg('读取序列号时发生错误'+Chr(10)+sErrMsg);
Exit;
End;
DQ_JS.Append;
DQ_JSJSBM_PK.Value := sID;
DQ_JSJSMC.Value := '新建角色';
DQ_JSYXBZ.Value := '1';
DQ_JSCJR.Value := gUser.SUserID;
DQ_JS.Post;
DBGrid_JS.Col := 2;
end;
//删除角色
procedure TFMW_JSGL.Act_DelExecute(Sender: TObject);
begin
if PubMsgDlg('删除角色『'+DQ_JSJSBM_PK.Value+'』吗?') then
try
With DMW_Public.DC_Pub do if Not InTransaction then BeginTrans;
With DQ_Edit Do
Begin
SQL.Clear;
SQL.Add('Delete From SYS_JSGNFPB');
SQL.Add(' Where JSBM_PK='''+DQ_JSJSBM_PK.Value+'''');
ExecSQL;
End;
DMW_Public.DC_Pub.CommitTrans;
DQ_JS.Delete;
Except
DMW_Public.DC_Pub.RollbackTrans;
PubMsgDlg('删除角色的功能分配时出现错误');
End;
end;
//克隆角色
procedure TFMW_JSGL.Act_CloneExecute(Sender: TObject);
Var sID ,sErrMsg: String;
CurP : TDataSetNotifyEvent;
sJSBM,sJSMC : String;
bOK : Boolean;
begin
//读取新的角色编号
if Not PubGetNextSqNum('SYS_S_JSBM',sID,sErrMsg) then
Begin
PubMsgDlg('读取序列号时发生错误'+Chr(10)+sErrMsg);
Exit;
End;
//取消AfterScroll事件
bOk := False;
CurP := DQ_JS.AfterScroll;
DQ_JS.AfterScroll := Nil;
Try
//添加角色
sJSBM := DQ_JSJSBM_PK.Value;
sJSMC := DQ_JSJSMC.Value;
DQ_JS.Append;
DQ_JSJSBM_PK.Value := sID;
DQ_JSJSMC.Value := sJSMC+'(克隆'+sID+')';
DQ_JSYXBZ.Value := '1';
DQ_JSCJR.Value := gUser.SUserID;
DQ_JS.Post;
DBGrid_JS.Col := 2;
//克隆功能
Try
With DMW_Public.DC_Pub do if Not InTransaction then BeginTrans;
With DQ_Edit Do
Begin
SQL.Clear;
SQL.Add('Insert Into SYS_JSGNFPB (JSBM_PK,GNBM_PK,CJR,YXBZ)');
SQL.Add('Select :sp_JSBMNew,GNBM_PK,:sp_CJR,''1''');
SQL.Add(' From SYS_JSGNFPB Where JSBM_PK=:sp_JSBMOld');
Parameters.Items[0].Value := sID;
Parameters.Items[1].Value := gUser.sUserID;
Parameters.Items[2].Value := sJSBM;
ExecSQL;
End;
DMW_Public.DC_Pub.CommitTrans;
bOk := True;
Except
DMW_Public.DC_Pub.RollbackTrans;
PubMsgDlg('克隆角色的功能时出现错误');
End;
Finally
//AfterScroll事件复位
if bOk then DQ_JS.Prior;
DQ_JS.AfterScroll := CurP;
if bOK then DQ_JS.Next;
End;
end;
//修改为有效
procedure TFMW_JSGL.Act_ValidExecute(Sender: TObject);
begin
if Not (DQ_JS.State = dsEdit) then DQ_JS.Edit;
DQ_JSYXBZ.Value := '1';
DQ_JS.Post;
end;
//修改为无效
procedure TFMW_JSGL.Act_InValidExecute(Sender: TObject);
begin
if Not (DQ_JS.State = dsEdit) then DQ_JS.Edit;
DQ_JSYXBZ.Value := '0';
DQ_JS.Post;
end;
//显式返回
procedure TFMW_JSGL.Act_ReturnExecute(Sender: TObject);
begin
Close;
end;
//构建角色功能目录
Procedure TFMW_JSGL.MakeRoleFuncTree;
Var Node_MK,Node_ZMK,Node_GN: TTreeNode;
s:String;
Begin
TV_JSGN.Items.Clear;
//打开数据集
if DQ_JSMK.Active then DQ_JSMK.Close; DQ_JSMK.Open;
if DQ_JSZMK.Active then DQ_JSZMK.Close; DQ_JSZMK.Open;
if DQ_JSGN.Active then DQ_JSGN.Close;
DQ_JSGN.Parameters.Items[0].Value := DQ_JSJSBM_PK.Value;
DQ_JSGN.Open;
//装载根目录(模块)
While Not DQ_JSMK.Eof Do
Begin
Node_MK := TV_JSGN.Items.AddObject(nil
,DQ_JSMKMKMC.Value,DQ_JSMK.GetBookmark) ;
Node_MK.ImageIndex := 0 ;
Node_MK.SelectedIndex := 3 ;
With DQ_JSZMK Do
Begin
Filtered := False ;
Filter := 'MKBM_PK='''+DQ_JSMKMKBM_PK.Value+'''' ;
Filtered := True ;
First ;
End;
//装载一级目录(子模块)
While Not DQ_JSZMK.Eof Do
Begin
Node_ZMK := TV_JSGN.Items.AddChildObject(Node_MK
,DQ_JSZMKZMKMC.Value,DQ_JSZMK.GetBookmark) ;
Node_ZMK.ImageIndex := 1 ;
Node_ZMK.SelectedIndex := 3 ;
With DQ_JSGN Do
Begin
Filtered := False ;
Filter := 'ZMKBM_PK='''+DQ_JSZMKZMKBM_PK.Value+'''' ;
Filtered := True ;
First ;
End;
//装载二级目录(功能)
While Not DQ_JSGN.Eof Do
Begin
s := DQ_JSGNGNMC.Value;
if DQ_JSGNBZ.Value<>'' then s := s+'('+DQ_JSGNBZ.Value+')';
Node_GN := TV_XTGN.Items.AddChildObject(Node_ZMK
,s,DQ_JSGN.GetBookmark) ;
Node_GN.ImageIndex := 2 ;
Node_GN.SelectedIndex := 4 ;
DQ_JSGN.Next;
End;
DQ_JSZMK.Next;
End;
DQ_JSMK.Next;
End;
DQ_JSZMK.Filtered := False ; DQ_JSZMK.Filter := '';
DQ_JSGN.Filtered := False ; DQ_JSGN.Filter := '';
End;
//重载角色功能目录:重新刷新角色功能分配表并刷新目录树
Procedure TFMW_JSGL.ReLoadRoleFuncTree;
Var Node_MK,Node_ZMK,Node_GN: TTreeNode;
s : String;
Begin
//打开数据集
if DQ_JSGN.Active then DQ_JSGN.Close;
DQ_JSGN.Parameters.Items[0].Value := DQ_JSJSBM_PK.Value;
DQ_JSGN.Open;
Try
TV_JSGN.Items.BeginUpdate;
Node_MK := TV_JSGN.Items[0];
While Assigned(Node_MK) Do //一级节点循环
Begin
Node_ZMK := Node_MK.getFirstChild;
While Assigned(Node_ZMK) do //二级节点循环
Begin
DQ_JSZMK.GotoBookmark(Node_ZMK.Data); //定位子模块
Node_ZMK.DeleteChildren; //删除字节点
With DQ_JSGN Do
Begin
Filtered := False ;
Filter := 'ZMKBM_PK='''+DQ_JSZMKZMKBM_PK.Value+'''' ;
Filtered := True ;
First ;
End;
//装载二级目录(功能)
While Not DQ_JSGN.Eof Do
Begin
s := DQ_JSGNGNMC.Value;
if DQ_JSGNBZ.Value<>'' then s := s+'('+DQ_JSGNBZ.Value+')';
Node_GN := TV_XTGN.Items.AddChildObject(Node_ZMK
,s,DQ_JSGN.GetBookmark) ;
Node_GN.ImageIndex := 2 ;
Node_GN.SelectedIndex := 4 ;
DQ_JSGN.Next;
End;
Node_ZMK :=Node_ZMK.getNextSibling;
End; //结束:二级节点循环
Node_MK := Node_MK.getNextSibling;
End; //结束:一级节点循环
DQ_JSZMK.Filtered := False ; DQ_JSZMK.Filter := '';
DQ_JSGN.Filtered := False ; DQ_JSGN.Filter := '';
Finally
TV_JSGN.Items.EndUpdate;
End;
End;
//角色变化处理:显示相应功能分配
procedure TFMW_JSGL.DQ_JSAfterScroll(DataSet: TDataSet);
begin
if TV_JSGN.Items.Count=0 then
MakeRoleFuncTree
else
ReLoadRoleFuncTree;
end;
//角色功能目录当前节点变化
procedure TFMW_JSGL.TV_JSGNChange(Sender: TObject; Node: TTreeNode);
begin
Case Node.Level of
0:if DQ_JSMK.BookmarkValid(Node.Data) then DQ_JSMK.GotoBookmark(Node.Data);
1:if DQ_JSZMK.BookmarkValid(Node.Data) then DQ_JSZMK.GotoBookmark(Node.Data);
2:if DQ_JSGN.BookmarkValid(Node.Data) then DQ_JSGN.GotoBookmark(Node.Data);
End;
end;
//拖动:开始拖动(改变拖动鼠标)
procedure TFMW_JSGL.TV_XTGNStartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
if TTreeView(Sender).Selected.Level=2 then
TTreeView(Sender).DragCursor := crDrag
else
TTreeView(Sender).DragCursor := crMultiDrag;
end;
//拖动:拖过
procedure TFMW_JSGL.TV_JSGNDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
Var Node_Draged,Node_DragTo : TTreeNode;
CurAddr:TBookMark;
begin
Accept := Source=TV_XTGN;
if Not Accept then Exit;
Node_Draged := TV_XTGN.Selected;
Node_DragTo := TV_JSGN.GetNodeAt(X,Y);
if Assigned(Node_DragTo) then
Case Node_Draged.Level of
0: //拖动模块:相应模块之间拖动
Accept := (Node_DragTo.Level=0) And (Node_DragTo.Index=Node_Draged.Index);
1: //拖动子模块:拖到相应模块或子模块
Case Node_DragTo.Level of
0:Begin //拖到相应模块下
CurAddr := DQ_JSMK.GetBookMark;
DQ_JSMK.GotoBookmark(Node_DragTo.Data);
Accept := (DQ_JSMKMKBM_PK.Value=DQ_ZMKMKBM_PK.Value);
DQ_JSMK.GotoBookMark(CurAddr);
DQ_JSMK.FreeBookmark(CurAddr);
End;
1:Begin //拖到相应子模块下
CurAddr := DQ_JSZMK.GetBookMark;
DQ_JSZMK.GotoBookmark(Node_DragTo.Data);
Accept := (DQ_JSZMKZMKBM_PK.Value = DQ_ZMKZMKBM_PK.Value);
DQ_JSZMK.GotoBookmark(CurAddr);
DQ_JSZMK.FreeBookMark(CurAddr);
End;
2:Accept := False;
End;
2://拖动功能
Begin
Accept := Node_DragTo.Level = 1; //只能拖到子目录下
if Accept then
Begin //只能拖到相应子目录下
CurAddr := DQ_JSZMK.GetBookMark;
DQ_JSZMK.GotoBookmark(Node_DragTo.Data);
Accept := (DQ_JSZMKZMKBM_PK.Value = DQ_GNZMKBM_PK.Value);
DQ_JSZMK.GotoBookmark(CurAddr);
DQ_JSZMK.FreeBookMark(CurAddr);
if Accept then
Begin
CurAddr := DQ_JSGN.GetBookmark;
Accept := Not DQ_JSGN.Locate('GNBM_PK',DQ_GNGNBM_PK.Value,[loCaseInsensitive]);
DQ_JSGN.GotoBookMark(CurAddr);
DQ_JSGN.FreeBookMark(CurAddr);
End;
End;
End;
End;
end;
//拖动:放下
procedure TFMW_JSGL.TV_JSGNDragDrop(Sender, Source: TObject; X, Y: Integer);
Var Node_Draged,Node_DragTo : TTreeNode;
begin
Node_Draged := TV_XTGN.Selected;
Node_DragTo := TV_JSGN.GetNodeAt(X,Y);
if Assigned(Node_DragTo) then
Case Node_Draged.Level of
0: //拖动模块,添加模块功能
if AddRoleMK(DQ_JSJSBM_PK.Value,DQ_MKMKBM_PK.Value) then
Begin
ReLoadRoleFuncTree;
Node_DragTo.Selected := True;
Node_DragTo.Expand(False);
End;
1: //拖动子模块:拖到相应模块或子模块
if AddRoleZMK(DQ_JSJSBM_PK.Value,DQ_ZMKZMKBM_PK.Value) then
Begin
ReLoadRoleFuncTree;
Node_DragTo.Selected := True;
Node_DragTo.Expand(True);
End;
2://拖动功能
if AddRoleFunc then //添加记录
Begin
ReLoadRoleFuncTree;
Node_DragTo.Selected := True;
Node_DragTo.Expand(false);
End;
End;
end;
//添加角色功能
Function TFMW_JSGL.AddRoleFunc:Boolean;
Begin
//添加角色功能>>提交
With DQ_Edit do
Try
SQL.Clear;
SQL.Add('Insert SYS_JSGNFPB(JSBM_PK,GNBM_PK,CJR,YXBZ) ');
SQL.Add(' Values
sp_JSBM,:sp_GNBM,:sp_CJR,''1'')');
Parameters.Items[0].Value := DQ_JSJSBM_PK.Value;
Parameters.Items[1].Value := DQ_GNGNBM_PK.Value;
Parameters.Items[2].Value := gUser.sUserID;
ExecSQL;
Result := True;
Except
PubMsgDlg('添加角色功能时,保存数据出错!');
Result := False;
End;
End;
//删除角色功能
Function TFMW_JSGL.DelRoleFunc:Boolean;
Begin
With DQ_Edit Do
Try
SQL.Clear;
SQL.Add('Delete From SYS_JSGNFPB ');
SQL.Add(' Where JSBM_PK=:sp_JSBM ');
SQL.Add(' And GNBM_PK=:sp_GNBM ');
Parameters.Items[0].Value := DQ_JSJSBM_PK.Value;
Parameters.Items[1].Value := DQ_JSGNGNBM_PK.Value;
ExecSQL;
Result := True;
Except
PubMsgDlg('删除角色功能时,保存数据出错!');
Result := False;
End;
End;
//添加模块功能(数据)
Function TFMW_JSGL.AddRoleMK(sJSBM,sMKBM:String):Boolean;
Begin
Try
With DMW_Public.DC_Pub do if Not InTransaction then BeginTrans;
With DQ_Edit do
Begin
//删除原功能
SQL.Clear;
SQL.Add('Delete From SYS_JSGNFPB');
SQL.Add(' Where JSBM_PK='''+sJSBM+'''');
SQL.Add(' And GNBM_PK In ( Select GN.GNBM_PK');
SQL.Add(' From SYS_GNBMB GN');
SQL.Add(' ,SYS_ZMKBMB ZMK');
SQL.Add(' ,SYS_MKBMB MK');
SQL.Add(' Where GN.ZMKBM_PK=ZMK.ZMKBM_PK');
SQL.Add(' And ZMK.MKBM_PK=MK.MKBM_PK');
SQL.Add(' And MK.MKBM_PK='''+sMKBM+'''');
SQL.Add(' )' );
ExecSQL;
//添加模块
SQL.Clear;
SQL.Add('Insert Into SYS_JSGNFPB(JSBM_PK,GNBM_PK,CJR,YXBZ)');
SQL.Add('Select :sp_JSBM,GN.GNBM_PK,:sp_CJR,''1''');
SQL.Add(' From SYS_GNBMB GN');
SQL.Add(' ,SYS_ZMKBMB ZMK');
SQL.Add(' ,SYS_MKBMB MK');
SQL.Add(' Where GN.ZMKBM_PK=ZMK.ZMKBM_PK');
SQL.Add(' And ZMK.MKBM_PK=MK.MKBM_PK');
SQL.Add(' And GN.YXBZ=''1''');
SQL.Add(' And ZMK.YXBZ=''1''');
SQL.Add(' And MK.YXBZ=''1''');
SQL.Add(' And MK.MKBM_PK=:sp_MKBM');
Parameters.Items[0].Value := sJSBM;
Parameters.Items[1].Value := gUser.sUserID;
Parameters.Items[2].Value := sMKBM;
ExecSQL;
End;
DMW_Public.DC_Pub.CommitTrans;
Result := True;
Except
DMW_Public.DC_Pub.RollbackTrans;
Result := False;
PubMsgDlg('添加模块功能时出现错误!');
End;
End;
//添加子模块功能(数据)
Function TFMW_JSGL.AddRoleZMK(sJSBM,sZMKBM:String):Boolean;
Begin
Try
With DMW_Public.DC_Pub do if Not InTransaction then BeginTrans;
With DQ_Edit do
Begin
//删除原功能
SQL.Clear;
SQL.Add('Delete From SYS_JSGNFPB');
SQL.Add(' Where JSBM_PK='''+sJSBM+'''');
SQL.Add(' And GNBM_PK In ( Select GNBM_PK');
SQL.Add(' From SYS_GNBMB');
SQL.Add(' Where ZMKBM_PK='''+sZMKBM+'''');
SQL.Add(' )' );
ExecSQL;
//添加模块
SQL.Clear;
SQL.Add('Insert Into SYS_JSGNFPB(JSBM_PK,GNBM_PK,CJR,YXBZ)');
SQL.Add('Select :sp_JSBM,GN.GNBM_PK,:sp_CJR,''1''');
SQL.Add(' From SYS_GNBMB GN');
SQL.Add(' ,SYS_ZMKBMB ZMK');
SQL.Add(' Where GN.ZMKBM_PK=ZMK.ZMKBM_PK');
SQL.Add(' And GN.YXBZ=''1''');
SQL.Add(' And ZMK.YXBZ=''1''');
SQL.Add(' And ZMK.ZMKBM_PK=:sp_ZMKBM');
Parameters.Items[0].Value := sJSBM;
Parameters.Items[1].Value := gUser.sUserID;
Parameters.Items[2].Value := sZMKBM;
ExecSQL;
End;
DMW_Public.DC_Pub.CommitTrans;
Result := True;
Except
DMW_Public.DC_Pub.RollbackTrans;
Result := False;
PubMsgDlg('添加子模块功能时出现错误!');
End;
End;
//取消功能分配
procedure TFMW_JSGL.Act_CancelJSGNExecute(Sender: TObject);
Var CurNode:TTreeNode;
begin
CurNode := TV_JSGN.Selected;
if Assigned(CurNode) then
if (CurNode.Level=2) then
if DelRoleFunc then
Try
TV_JSGN.Items.BeginUpdate;
CurNode := CurNode.Parent;
ReLoadRoleFuncTree;
CurNode.Expand(False);
finally
TV_JSGN.Items.EndUpdate;
End;
end;
//取消模块分配
procedure TFMW_JSGL.Act_CancelJSMKExecute(Sender: TObject);
Var CurNode:TTreeNode;
sJSBM,sMKBM:String;
begin
CurNode := TV_JSGN.Selected;
if Assigned(CurNode) then
if CurNode.Level = 0 then
Begin
//删除原功能
sJSBM := DQ_JSJSBM_PK.Value;
sMKBM := DQ_JSMKMKBM_PK.Value;
With DQ_Edit Do
Try
With DMW_Public.DC_Pub do if Not InTransaction then BeginTrans;
SQL.Clear;
SQL.Add('Delete From SYS_JSGNFPB');
SQL.Add(' Where JSBM_PK='''+sJSBM+'''');
SQL.Add(' And GNBM_PK In ( Select GN.GNBM_PK');
SQL.Add(' From SYS_GNBMB GN');
SQL.Add(' ,SYS_ZMKBMB ZMK');
SQL.Add(' ,SYS_MKBMB MK');
SQL.Add(' Where GN.ZMKBM_PK=ZMK.ZMKBM_PK');
SQL.Add(' And ZMK.MKBM_PK=MK.MKBM_PK');
SQL.Add(' And MK.MKBM_PK='''+sMKBM+'''');
SQL.Add(' )' );
ExecSQL;
DMW_Public.DC_Pub.CommitTrans;
Except
DMW_Public.DC_Pub.RollbackTrans;
PubMsgDlg('删除角色的模块时出现错误');
Exit;
End;
//刷新
ReLoadRoleFuncTree;
CurNode.Selected := True;
CurNode.Expand(True);
End;
end;
//取消子模块分配
procedure TFMW_JSGL.Act_CancelJSZMKExecute(Sender: TObject);
Var CurNode:TTreeNode;
sJSBM,sZMKBM:String;
begin
CurNode := TV_JSGN.Selected;
if Assigned(CurNode) then
if CurNode.Level = 1 then
Begin
//删除原功能
sJSBM := DQ_JSJSBM_PK.Value;
sZMKBM := DQ_JSZMKZMKBM_PK.Value;
With DQ_Edit Do
Try
With DMW_Public.DC_Pub do if Not InTransaction then BeginTrans;
SQL.Clear;
SQL.Add('Delete From SYS_JSGNFPB');
SQL.Add(' Where JSBM_PK='''+sJSBM+'''');
SQL.Add(' And GNBM_PK In ( Select GNBM_PK');
SQL.Add(' From SYS_GNBMB');
SQL.Add(' Where ZMKBM_PK='''+sZMKBM+'''');
SQL.Add(' )' );
ExecSQL;
DMW_Public.DC_Pub.CommitTrans;
Except
DMW_Public.DC_Pub.RollbackTrans;
PubMsgDlg('删除角色的子模块时出现错误');
Exit;
End;
//刷新
ReLoadRoleFuncTree;
CurNode.Selected := True;
CurNode.Expand(True);
End;
end;
//操作角色功能时弹出菜单弹出:检验事件的有效性
procedure TFMW_JSGL.PMN_JSGNPopup(Sender: TObject);
Var CurNode:TTreeNode;
begin
CurNode := TV_JSGN.Selected;
Act_CancelJSGN.Enabled := Assigned(CurNode);
Act_CancelJSZMK.Enabled := Assigned(CurNode);
Act_CancelJSMK.Enabled := Assigned(CurNode);
if Assigned(CurNode) then
Begin
Act_CancelJSGN.Enabled := CurNode.Level=2;
Act_CancelJSZMK.Enabled := CurNode.Level=1;
Act_CancelJSMK.Enabled := CurNode.Level=0;
End;
end;
end.