📄 frmrightsmanage.pas
字号:
unit FRMRIGHTSMANAGE;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FRMBASSDIALOGS, ComCtrls, MenuBar, ToolWin, DsFancyButton,myself,
ExtCtrls, StdCtrls, TFlatCheckListBoxUnit, TFlatListBoxUnit, DB, DBTables,frmmain;
type
TFrm_rightsmanage = class(TFrm_bassDialogs)
LB_name: TFlatListBox;
CLB_rights: TFlatCheckListBox;
Image1: TImage;
Query_data: TQuery;
procedure FormCreate(Sender: TObject);
procedure LB_nameClick(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure CLB_rightsClickCheck(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
private
B_create:boolean;
P_rights: array of array of string;
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_rightsmanage: TFrm_rightsmanage;
implementation
{$R *.dfm}
procedure TFrm_rightsmanage.FormCreate(Sender: TObject);
var
I_index:integer;
begin
inherited;
self.Caption :='权限管理';
setlength(P_rights,2);
setlength(P_rights[0],7);
setlength(P_rights[1],7);
P_rights[0,0]:='管理员';
P_rights[0,1]:='一级';
P_rights[0,2]:='二级';
P_rights[0,3]:='三级';
P_rights[0,4]:='四级';
P_rights[0,5]:='五级';
P_rights[0,6]:='限制级';
query_data.DatabaseName :=HWSHOPDATA;
B_create:=false;
with query_data do
begin
close;
sql.Clear ;
sql.Text :='select * from systemrights';
try
open;
B_create:=true;
except
messagedlg(Errormsg0001+'0006',mtError,[mbok],0);
close;
B_create:=false;
end;
if (RecordCount <> 7) and (B_create) then
begin
P_rights[1,0]:='1111111111';
P_rights[1,1]:='1111011111';
P_rights[1,2]:='1111011011';
P_rights[1,3]:='1111001011';
P_rights[1,4]:='1111000011';
P_rights[1,5]:='1110000011';
P_rights[1,6]:='0000000011';
end
else if(RecordCount = 7) and (B_create) then
begin
first;
for I_index:=1 to recordcount do
begin
P_rights[1,I_index-1]:=fieldbyname('rights').AsString ;
next;
end;
end;
end;
end;
procedure TFrm_rightsmanage.LB_nameClick(Sender: TObject);
var
S_rights:string;
I_index:integer;
begin
inherited;
if (LB_name.itemindex<0) or (LB_name.itemindex>6) then
begin
CLB_rights.Enabled :=false;
exit;
end
else
CLB_rights.Enabled :=true;
S_rights:=P_rights[1,LB_name.itemindex];
if length(S_rights)<>10 then
S_rights:='0000000000';
for I_index:=1 to CLB_rights.Items.Count do
begin
if S_rights[I_index]='1' then
CLB_rights.Checked[I_index-1]:=true
else
CLB_rights.Checked[I_index-1]:=false;
end;
end;
procedure TFrm_rightsmanage.FormPaint(Sender: TObject);
begin
inherited;
if not B_create then
self.Close ;
end;
procedure TFrm_rightsmanage.CLB_rightsClickCheck(Sender: TObject);
var
I_index,I_name:integer;
S_rights:string;
begin
inherited;
I_name:=lb_name.ItemIndex ;
if I_name=0 then //系统管理员
exit;
if CLB_rights.Checked[5] then
CLB_rights.Checked[6]:=true;
S_rights:='';
for I_index:=0 to CLB_rights.Items.Count -1 do
begin
if CLB_rights.Checked[I_index] then
S_rights:=S_rights+'1'
else
S_rights:=S_rights+'0';
end;
S_rights:=S_rights+'11';
P_rights[1,I_name]:=S_rights;
end;
procedure TFrm_rightsmanage.OKBtnClick(Sender: TObject);
var
I_row :integer;
begin
inherited;
with query_data do
begin
close;
sql.Clear ;
sql.Text :='delete from systemrights';
try
execsql;
except
messagedlg(Errormsg0005+'0006',mtError,[mbok],0);
close;
self.Close ;
end;
for I_row:=0 to 6 do
begin
close;
sql.Clear ;
sql.Text :='insert into systemrights (id,name,rights)'
+' values("'+inttostr(I_row)+'","'+P_rights[0,I_row]+'","'
+P_rights[1,I_row]+'")';
try
execsql;
except
messagedlg(Errormsg0004+'0006',mtError,[mbok],0);
close;
self.Close ;
end;
end;
close;
self.Close ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -