📄 sys_accessctrl1.pas
字号:
unit Sys_AccessCtrl1;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, jpeg;
Type
TFrm_Sys_AccessCtrl1 = Class(TFrm_Base_Outer)
Lstbx_Employee: TListBox;
Lstbx_Module: TListBox;
Lstbx_Dept: TListBox;
AdoQry_MainEmployeeCode: TStringField;
AdoQry_MainEmployeeName: TStringField;
AdoQry_MainSysMenuID: TFloatField;
AdoQry_MainSysMenuCode: TStringField;
AdoQry_MainSysMenuName: TStringField;
AdoQry_MainSysModuleCode: TStringField;
AdoQry_MainSysmoduleName: TStringField;
AdoQry_MainSysmoduleB: TStringField;
AdoQry_MainCANAccess: TIntegerField;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
AdoQry_tmp1: TAdoQuery;
procedure Lstbx_ModuleClick(Sender: TObject);
procedure DBGridEhDblClick(Sender: TObject);
procedure Lstbx_EmployeeClick(Sender: TObject);
procedure Lstbx_DeptClick(Sender: TObject);
procedure DBGridEhTitleClick(Column: TColumnEh);
procedure FormActivate(Sender: TObject);
procedure Act_FilterExecute(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
ModuleCondition:string; //模块条件
EmployeeCondition:string; //人员条件
Flag:boolean;
procedure ListBoxClick; //双击事件
procedure GetSysModuleAccessCtrl(EmployCode:String);
public
sDeptCode,sEmployeeCode:string;
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
procedure GetConditionAccessCtrl(EmployeeCode,SysModuleCode:string);//AdoQry_Main得到条件筛选后的内容,可能取消.
procedure ReformSysMenuAccessCtrl(operatorCode1:string);//重整权限表
procedure GetTotalRecord(operatorCode1,SysModuleCode1:string); //获得记录
procedure DeleteTmptable; //删除临时表
end;
var
Frm_Sys_AccessCtrl1: TFrm_Sys_AccessCtrl1;
implementation
uses Sys_Global,Sys_AccessCtrl1_C;
{$R *.DFM}
procedure TFrm_Sys_AccessCtrl1.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
inherited;
AdoQry_tmp1.Connection:= AdOConnection;
// Frm_Sys_Condition:=TFrm_Sys_AccessCtrl1_C.Create(Application);
// Act_Filter.Execute;
try
Frm_Sys_AccessCtrl1_C:=TFrm_Sys_AccessCtrl1_C.Create(self);
Frm_Sys_AccessCtrl1_C.ShowModal;
finally
Frm_Sys_AccessCtrl1_C.Free;
end;
end;
procedure TFrm_Sys_AccessCtrl1.GetConditionAccessCtrl(EmployeeCode,SysModuleCode:string);
var
CreateStr:string;
sSQL:string;
begin
if EmployeeCode='' then abort;
CreateStr:=' ';
CreateStr:=CreateStr+
' select EmployeeCode='+QuotedStr(EmployeeCode)+',SysMenuID,CANAccess=0 '+
' into #TMpSysMenuAccessCtrl '+
' from SysMenu '+
' select * '+
' into #tmp1'+
' from('+
' select SysMenuAccessCtrl.EmployeeCode, '+
' SysMenuAccessCtrl.SysMenuID, '+
' SysMenuAccessCtrl.CANAccess '+
' from SysMenuAccessCtrl '+
' where SysMenuAccessCtrl.EmployeeCode='+QuotedStr(EmployeeCode)+
' and SysMenuAccessCtrl.CANAccess<>0 '+
' UNION '+
' select #TMpSysMenuAccessCtrl.EmployeeCode, '+
' #TMpSysMenuAccessCtrl.SysMenuID, '+
' Isnull(0,#TMpSysMenuAccessCtrl.CANAccess) as CANAccess '+
' from #TMpSysMenuAccessCtrl '+
' where #TMpSysMenuAccessCtrl.SysMenuID not in '+
' (select SysMenuid from SysMenuAccessCtrl where EmployeeCode='+QuotedStr(EmployeeCode)+
' and CANAccess<>0) '+
' )a ';
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add(CreateStr);
Prepared;
ExecSQL;
end;
sSQL:='';
sSQL:=sSQL+
' select #tmp1.EmployeeCode, '+
' Employee.EmployeeName, '+
' #tmp1.EmployeeCode+'' ''+Employee.EmployeeName as EmployeeB, '+
' #tmp1.SysMenuid, '+
' SysMenu.SysMenuCode, '+
' SysMenu.SysMenuName, '+
' SysMenu.SysMenuCode+'' ''+SysMenu.SysMenuName as SysMenuB, '+
' Sysmodule.SysModuleCode, '+
' Sysmodule.SysmoduleName, '+
' Sysmodule.SysModuleCode+'' ''+Sysmodule.SysmoduleName as SysmoduleB, '+
' #tmp1.canAccess '+
' from #tmp1 '+
' join Employee on #tmp1.EmployeeCode=Employee.EmployeeCode '+
' join SysMenu on #tmp1.SysMenuid =SysMenu.SysMenuid '+
' join Sysmodule on SysMenu.SysModuleCode=Sysmodule.SysModuleCode ';
if SysModuleCode<>'' then
sSQL:=sSQL+' where Sysmodule.SysModuleCode= '+QuotedStr(SysModuleCode);
sSQL:=sSQL+' Order by Sysmodule.SysModuleCode,SysMenu.SysMenuCode';
with AdoQry_Main do
begin
Close;
SQL.clear;
SQL.Add(sSQL);
Open;
end;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('drop table #tMpSysMenuAccessCtrl drop table #tmp1');
Prepared;
ExecSQL;
end;
end;
procedure TFrm_Sys_AccessCtrl1.ListBoxClick;
begin
EmployeeCondition:=Lstbx_Employee.Items[Lstbx_Employee.ItemIndex];
EmployeeCondition:=getCode(EmployeeCondition);
if Lstbx_Module.Itemindex=0 then ModuleCondition:=''
else
begin
ModuleCondition:=Lstbx_Module.Items[Lstbx_Module.Itemindex];
if ModuleCondition<>'' then ModuleCondition:=getCode(ModuleCondition);
end;
ReformSysMenuAccessCtrl(EmployeeCondition);
Condition:='';
GetTotalRecord(EmployeeCondition,ModuleCondition);
DeleteTmptable;
end;
procedure TFrm_Sys_AccessCtrl1.Lstbx_ModuleClick(Sender: TObject);
var
sModule:string;
begin
inherited;
if Lstbx_Employee.ItemIndex<0 then Lstbx_Employee.ItemIndex:=0
else
EmployeeCondition:=Lstbx_Employee.Items[Lstbx_Employee.ItemIndex];
EmployeeCondition:=getCode(EmployeeCondition);
if Lstbx_Module.Itemindex=0 then ModuleCondition:=''
else
begin
ModuleCondition:=Lstbx_Module.Items[Lstbx_Module.Itemindex];
if ModuleCondition<>'' then ModuleCondition:=getCode(ModuleCondition);
end;
Condition:='';
GetTotalRecord(EmployeeCondition,ModuleCondition);
GetSysModuleAccessCtrl(EmployeeCondition);
end;
procedure TFrm_Sys_AccessCtrl1.DBGridEhDblClick(Sender: TObject);
var
sSQL:string;
Id:integer;
SCode:string;
begin
// inherited;
if AdoQry_Main.IsEmpty then exit;
Id:=AdoQry_Main.fieldbyname('SysMenuID').AsInteger;
SCode:= AdoQry_Main.fieldbyname('EmployeeCode').asstring;
if AdoQry_Main.fieldbyname('CANAccess').AsInteger=0 then
sSQL:=' update SysMenuAccessCtrl set CANAccess=1 where SysMenuID= '+
AdoQry_Main.fieldbyname('SysMenuID').AsString+
' and EmployeeCode='+Quotedstr(AdoQry_Main.fieldbyname('EmployeeCode').AsString)
else
sSQL:=' update SysMenuAccessCtrl set CANAccess=0 where SysMenuID= '+
AdoQry_Main.fieldbyname('SysMenuID').AsString+
' and EmployeeCode='+Quotedstr(AdoQry_Main.fieldbyname('EmployeeCode').AsString);
with AdoQry_tmp do
begin
Close;
SQL.clear;
SQL.Add(sSQL);
Prepared;
ExecSQL;
end;
EmployeeCondition:=Lstbx_Employee.Items[Lstbx_Employee.ItemIndex];
EmployeeCondition:=getCode(EmployeeCondition);
if Lstbx_Module.Itemindex=0 then ModuleCondition:=''
else
begin
ModuleCondition:=Lstbx_Module.Items[Lstbx_Module.Itemindex];
if ModuleCondition<>'' then ModuleCondition:=getCode(ModuleCondition);
end;
GetTotalRecord(EmployeeCondition,ModuleCondition);
AdoQry_Main.Locate('SysMenuID',id, []);
end;
procedure TFrm_Sys_AccessCtrl1.Lstbx_EmployeeClick(Sender: TObject);
var
sDept:string;
sSQL:string;
begin
inherited;
ListBoxClick;
with AdoQry_tmp do
begin
if GetCode(Lstbx_Employee.Items.Strings[Lstbx_Employee.ItemIndex])<>''then
sSQL:='select DeptCode from Employee where EmployeeCode='+Quotedstr(GetCode(Lstbx_Employee.Items.Strings[Lstbx_Employee.ItemIndex]));
Close;
SQL.clear;
SQL.Add(sSQL);
Open;
sDept:=AdoQry_tmp.fieldbyname('DeptCode').asstring;
end;
Frm_Sys_AccessCtrl1_C.GetStation(sDept,Lstbx_Dept)
end;
procedure TFrm_Sys_AccessCtrl1.Lstbx_DeptClick(Sender: TObject);
var
S1:string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -