我所撰写的可以动态的控制使用者的画面。
例如主选单和任一个Form的Button或Function。
但是这个实做不是很容易的,要有几个Table。
1员工主档
2 (主选单资料文件)树状资料文件
3 Form使用权资料文件
4 Function的资料文件等
最重要的是要写在父代的Form 上 ,当要撰写一个维护或查询的程序时,就继承其父代的Form,其程序代码如下
此段写在FromCreate,就可以达到某一字段或是Button的使用权的设定
for I := ComponentCount - 1do
wnto 0do
begin
if Components is TDCOMConnection then
begin
TDCOMConnection(Components).ComputerName:=SECConnection.ComputerName;
LCComputerName:=TDCOMConnection(Components).ComputerName;
end;
{ if Components is TWebConnection then
begin
LCComputerName:=TWebConnection(Components).url;
// LCComputerName:='11111111';
// showmessage(LCComputerName);
end;
}
if Components is TDbKeyComboBox then
begin
if (not (rtEdit in RightList)) then
TDbKeyComboBox(Components).Enabled:=false;
end;
if Components is TDBMatchComboBox then
begin
if (not (rtEdit in RightList)) then
TDBMatchComboBox(Components).Enabled:=false;
end;
if Components is TDBCombBox then
begin
if (not (rtEdit in RightList)) then
TDBCombBox(Components).Enabled:=false;
end;
//增加wwDBComboBox
if Components is TwwDBComboBox then
begin
if (not (rtEdit in RightList)) then
TwwDBComboBox(Components).Enabled:=false;
end;
//wwDBCombDlg
// if Components is TwwDBCombDlg then
// begin
// if (not (rtEdit in RightList)) then
// TwwDBCombDlg(Components).Enabled:=false;
// end;
//wwDBLookupComboDlg
if Components is TwwDBLookupComboDlg then
begin
if (not (rtEdit in RightList)) then
TwwDBLookupComboDlg(Components).Enabled:=false;
end;
//wwDBLookupCombo
if Components is TwwDBLookupCombo then
begin
if (not (rtEdit in RightList)) then
TwwDBLookupCombo(Components).Enabled:=false;
end;
if Components is TDBRadioGroup then
if (not (rtEdit in RightList)) then
TDBRadioGroup(Components).Readonly:=True;
if Components is TDBCheckBox then
if (not (rtEdit in RightList)) then
TDBCheckBox(Components).Readonly:=True;
if Copy(TXTString[0],1,4)<>'CPDS' then
begin
if Components is TEDBNavigator then
//判断使用者是否有权限使用此Form上Navigator之增,修,删,查,印表(RList)
begin
RightSet:=[];
for j:=0 to TXTString.Count-1do
begin
if GetLeftStr(TXTString[j],' ')=rs_FormName+'L' then
begin
S:=GetRightStr(TXTString[j],' ');
if Pos('I',S)>0 then
Include(RightSet, nbInsert);
if Pos('D',S)>0 then
Include(RightSet, nbDelete);
if Pos('E',S)>0 then
Include(RightSet, nbEdit);
if Pos('Q',S)>0 then
Include(RightSet, nbQuery);
if Pos('P',S)>0 then
Include(RightSet, nbPrint);
TEDBNavigator(Components).VisibleButtons:=
TEDBNavigator(Components).VisibleButtons-RightSet;
Exit;
end;
end;
end else
if (Components is TButton) or (Components is TBitBtn)
or (Components is TSpeedButton) Or (Components is TfcShapeBtn)
then
//判断使用者是否有权限使用此Form上之Button(RFunc)
begin
if TXTString.Find(rs_FormName+'F '+Components.Name,index) then
TButton(Components).Enabled:=False;
end else
if (Components is TDBEdit) or (Components is TwwDBEdit) then
//判断使用者是否有权限使用此Form上之Edit(ROther)
begin
if TXTString.Find(rs_FormName+'O '+Components.Name,index) then
TDBEdit(Components).ReadOnly:=True;
end else
If (Components is TTabSheet) then
if TXTString.Find(rs_FormName+'F '+Components.Name,index) then
TTabSheet(Components).TabVisible:=False;
end;
//if Copy(TXTString[0],1,4)<>'CPDS' then
end;
//for i:=ComponentCount-1do
wnto 0do
ub_NewBillNo := False;
// rs_FormName := TForm(Sender).Caption;
ActiveDataSource.DataSet:=dsdataset;
//if WindowState<> wsMaximized then
// TForm(Sender).Height := TForm(Sender).Height+24;