utgroup.pas
来自「是一个用delphi设计的考勤系统」· PAS 代码 · 共 269 行
PAS
269 行
unit UTGroup;
interface
uses windows, forms, SysUtils, Controls, Classes, URecord;
type
TGroup = class
public
RetVal: integer; //返回码
RetMsg: string; //返回信息
GroupName: string; //组名称
Ms: string; //描述
Stop: integer; //是否停用 0:可用 1:停用
RightCount: integer;
RecGRight: array of TRecGRight;
SourceRecGRight: array of TRecGRight;
constructor create;
public
function GetGroupInfo(sGroupName: string): boolean;
function AddGroup(): boolean;
function DeleteGroup(): boolean;
function UpdateGroupInfo(): boolean;
//
function SetRight(sRightNum: string; bRight: boolean): boolean; //设置组属有的权限
function UpdateRecGRight(): boolean;
//
function UpdateGroupRight(): boolean;
function SaveRight(): boolean;
private
procedure IniData; //初始化变量数据
end;
implementation
uses DM_DataModal;
{ TUGroup }
function TGroup.AddGroup: boolean;
begin
Result := False;
try
with winddata.pUsr_102_GroupInfo do
begin
parameters.ParamByName('@czfs').Value := 1;
parameters.ParamByName('@GroupName').Value := GroupName;
parameters.ParamByName('@Ms').Value := Ms;
parameters.ParamByName('@Stop').Value := Stop;
execproc;
retval := parameters.ParamByName('@return_value').Value;
retmsg := parameters.ParamByName('@retmsg').Value;
end;
except
retval := -1;
retmsg := '执行存储异常'
end;
end;
constructor TGroup.create;
var
i: integer;
begin
inherited Create;
RetVal := -1; //返回码
RetMsg := ''; //返回信息
with winddata.PublicQuery do
begin
sql.Clear;
sql.Add('select * from usr_RightInfo');
open;
last;
RightCount := RecordCount;
setlength(RecGRight, RightCount);
setlength(SourceRecGRight, RightCount);
i := 0;
first;
while not eof do
begin
RecGRight[i].RightNum := fieldbyname('RightNum').asstring;
RecGRight[i].RightMc := fieldbyname('RightMemo').asstring;
RecGRight[i].RightCount := fieldbyname('RightCount').asinteger;
RecGRight[i].Right := False;
RecGRight[i].SubCount := 0;
next;
inc(i);
end;
end;
IniData;
end;
function TGroup.DeleteGroup: boolean;
begin
Result := False;
try
with winddata.pUsr_102_GroupInfo do
begin
parameters.ParamByName('@czfs').Value := 2;
parameters.ParamByName('@GroupName').Value := GroupName;
execproc;
retval := parameters.ParamByName('@return_value').Value;
retmsg := parameters.ParamByName('@retmsg').Value;
end;
except
retval := -1;
retmsg := '执行存储异常'
end;
end;
function TGroup.GetGroupInfo(sGroupName: string): boolean;
var
i: integer;
begin
result := False;
try
with winddata.PublicQuery do
begin
sql.Clear;
sql.Add('select * from Usr_GroupInfo where Name=''' + sGroupName + '''');
open;
if not eof then
begin
GroupName := sGroupName;
ms := fieldbyname('ms').asstring;
stop := fieldbyname('stop').asinteger;
sql.Clear;
sql.Add('SELECT * from usr_right where groupname=''' + sGroupName + '''');
open;
while not eof do
begin
for i := 0 to RightCount - 1 do
begin
if RecGRight[i].RightNum = Fieldbyname('Rightnum').asstring then
RecGRight[i].Right := True;
end;
next;
end;
UpdateRecGRight;
for i := 0 to RightCount - 1 do SourceRecGRight[i] := RecGRight[i];
retval := 1;
result := True;
end
else
begin
retval := 1;
retmsg := '此组不存在';
end;
end;
except
retval := -1;
retmsg := '执行存储异常';
end;
end;
procedure TGroup.IniData;
begin
end;
function TGroup.SaveRight: boolean;
var
i: integer;
begin
Result := False;
try
for i := 0 to RightCount - 1 do
begin
if SourceRecGRight[i].Right = RecGRight[i].Right then continue;
with winddata.pUsr_102_GroupInfo do
begin
if SourceRecGRight[i].Right then
parameters.ParamByName('@czfs').Value := 5
else
parameters.ParamByName('@czfs').Value := 4;
parameters.ParamByName('@GroupName').Value := GroupName;
parameters.ParamByName('@RightNum').Value := RecGRight[i].RightNum;
execproc;
retval := parameters.ParamByName('@return_value').Value;
retmsg := parameters.ParamByName('@retmsg').Value;
end;
end;
except
retval := -1;
retmsg := '执行存储异常'
end;
end;
function TGroup.SetRight(sRightNum: string; bRight: boolean): boolean;
var
i, j: integer;
s1, s2: string;
begin
for i := 0 to RightCount - 1 do
begin
if RecGRight[i].RightNum = sRightNum then RecGright[i].Right := bRight;
s1 := sRightNum;
for j := 0 to RightCount - 1 do
begin
s2 := RecGRight[j].RightNum;
if (copy(s2, 1, length(s1)) = s1) then //如 '10' 在 '1001'中
begin
RecGRight[j].Right := bRight;
{ if bRight then
RecGRight[i].SubCount := RecGRight[i].SubCount + 1
else
RecGRight[i].SubCount := RecGRight[i].SubCount - 1;}
end;
end;
end;
end;
function TGroup.UpdateGroupInfo: boolean;
begin
Result := False;
try
with winddata.pUsr_102_GroupInfo do
begin
parameters.ParamByName('@czfs').Value := 3;
parameters.ParamByName('@GroupName').Value := GroupName;
parameters.ParamByName('@Ms').Value := Ms;
parameters.ParamByName('@Stop').Value := Stop;
execproc;
retval := parameters.ParamByName('@return_value').Value;
retmsg := parameters.ParamByName('@retmsg').Value;
end;
except
retval := -1;
retmsg := '执行存储异常'
end;
end;
function TGroup.UpdateGroupRight: boolean;
begin
end;
function TGroup.UpdateRecGRight: boolean;
var
i, j: integer;
s1, s2: string;
begin
for i := 0 to RightCount - 1 do
begin
RecGright[i].SubCount := 0;
end;
for i := 0 to RightCount - 1 do
begin
if RecGRight[i].Right then
begin
s1 := RecGRight[i].RightNum;
for j := 0 to RightCount - 1 do
begin
s2 := RecGRight[j].RightNum;
if (copy(s1, 1, length(s2)) = s2) and (s1 <> s2) then //如 '10' 在 '1001'中
begin
RecGRight[j].Right := True;
RecGRight[j].SubCount := RecGRight[j].SubCount + 1;
end;
end;
end;
end;
for i := 0 to RightCount - 1 do
begin
if (length(RecGRight[i].RightNum) <= 4) and
(RecGRight[i].SubCount = 0) and (RecGRight[i].RightCount <> 0) then
RecGRight[i].Right := False;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?