?? rgtrolefunction.~pas
字號:
if P_Insert1=false then
if MessageDlg('是否要更新該記錄?',mtConfirmation, [mbYes,mbNo], 0)=mrNo then exit;
if trim(P_FUNCSERIALID1) ='' then
begin
MessageDlg('請選擇權限功能!',mtConfirmation, [mbYes], 0);
exit;
end;
str :=TreeViewRy.Selected.Text;
//該角色的這種功能已經存在不要再增加
if P_Insert1 then
begin
Query_Tmp.Close;
Query_Tmp.sql.text :=
'select count(*) from PRIVUSERFUNC where FUNCSERIALID='+#39
+P_FUNCSERIALID1+#39+' and USERLOGINID='
+#39+copy(str,1,pos(':',str) -1)+#39;;
Query_Tmp.open;
if Query_Tmp.Fields[0].AsInteger >0 then
begin
Application.MessageBox('該帳戶的這種功能已存在!請重新選擇對應!','提示',MB_OK+MB_ICONWARNING);
Exit;
end;
end;
//**************判斷登陸用戶是否有權限把加這個權限***********
//**************(就是說登陸用戶只能把自己有的權限給用戶)***
Query_Tmp.Close;
Query_Tmp.sql.text :=
'select count(*) from PRIVUSERFUNC where FUNCSERIALID='+#39
+P_FUNCSERIALID1+#39+' and USERLOGINID='
+#39+GH+#39;;
Query_Tmp.open;
if Query_Tmp.Fields[0].AsInteger >0 then
begin
Application.MessageBox('您沒有權限把該功能給這個用戶','提示',MB_OK+MB_ICONWARNING);
Exit;
end;
//*******************************************************
//**********************************************
if P_Insert1 then
Begin
sqlstr:='insert into PRIVUSERFUNC (SERIAL,USERLOGINID,FUNCID,USERLOGINIDNAME,FUNCNAME,FUNCSERIALID,FLAG) '
+' values(SEQ_USERFUNCSERIAL.nextval,'
+#39+copy(str,1,pos(':',str) -1)+#39
+','+#39+P_FUNCID1+#39+','
+#39+copy(str,pos(':',str) +1,length(str))+#39+','
+#39+Edit5.Text+#39+','+P_FUNCSERIALID1+','+#39+'1'+#39+')';
if AnalyzeSql(sqlstr)=1 then exit;
end
else
begin
sqlstr:='update PRIVROLEFUNC set FUNCID='+#39+P_FUNCID1+#39
+',FUNCNAME='+#39+edit5.Text+#39
+',FUNCSERIALID='+P_FUNCSERIALID1
+' where SERIAL='+query2.fieldbyname('SERIAL').asstring;
if AnalyzeSql(sqlstr)=1 then exit;
end;
//*************數據同步********************
if P_Insert1 then
Begin
P_edit1 :=true;
Query2.insert;
Query_Tmp.close;
Query_Tmp.sql.text :=
'select nvl(max(SERIAL),0) from PRIVUSERFUNC ';
Query_Tmp.open;
P_CurrentCode1 :=Query_Tmp.fields[0].asstring;
end
else
begin
P_edit1 :=true;
Query2.Edit;
end;
Query2.FieldByName('SERIAL').AsString :=P_CurrentCode1;
Query2.FieldByName('USERLOGINID').AsString :=copy(str,1,pos(':',str) -1);
Query2.FieldByName('FUNCID').AsString :=P_FUNCID1;
Query2.FieldByName('USERLOGINIDNAME').AsString :=copy(str,pos(':',str) +1,length(str));
Query2.FieldByName('FUNCNAME').AsString :=edit5.text;
Query2.FieldByName('FUNCSERIALID').AsString :=P_FUNCSERIALID1;
if Edit6.text ='看不見' then
query2.fieldbyname('CONTROLTYPE').asstring :='INVISIBLE';
if Edit6.text ='不可編輯' then
query2.fieldbyname('CONTROLTYPE').asstring :='DISABLED';
query2.fieldbyname('FLAG').asstring :='1';
P_edit1 :=false;
Query2.Post;
//*****************************************
Query2.AfterScroll(nil);
end;
end;
P_Save :=false;
BitBtnSave.Enabled :=false;
end;
procedure TRgtFrmRoleFunction.BitBtnCancelClick(Sender: TObject);
begin
inherited;
case PageControl1.ActivePageIndex of
0:begin
Query1.AfterScroll(nil);
end;
1:begin
Query2.AfterScroll(nil);
end;
end;
P_Save :=false;
end;
procedure TRgtFrmRoleFunction.BitBtnAddClick(Sender: TObject);
begin
case PageControl1.ActivePageIndex of
0:begin
if query_pub.bof and query_pub.eof then exit;
SbSysFormCtrlListEditing.Enabled :=true;
EdtFuncNameEditing.Text :='';
EdtFormCaptionEditing.Text :='';
EdtControlCaptionEditing.Text :='';
Edit1.Text :='';
P_FUNCID :='';
EdtFuncSerialIdEditing.text :='';
BitBtnSave.Enabled :=true;
P_Insert :=true;
end;
1:begin
if TreeViewRy.Selected=nil then exit;
if TreeViewRy.Selected.Level<3 then exit;
BitBtn1.Enabled :=true;
Edit3.Text :='';
Edit4.Text :='';
Edit5.Text :='';
Edit6.Text :='';
P_FUNCID1 :='';
Edit2.text :='';
BitBtnSave.Enabled :=true;
P_Insert1 :=true;
end;
end;
P_Save :=true;
end;
procedure TRgtFrmRoleFunction.FlatEdit1KeyPress(Sender: TObject; var Key: Char);
begin
If not (Key in ['0'..'9',#8,#13]) then
Key:=#0;
end;
procedure TRgtFrmRoleFunction.PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
begin
if P_Save then
begin
if MessageDlg('當前記錄已經發生改變,請您先保存!',mtConfirmation,
[mbYes],0)=mryes then
AllowChange :=false;
end;
end;
procedure TRgtFrmRoleFunction.SbSysFormCtrlListEditingClick(
Sender: TObject);
var
FormCtrlSelect :TRgtSelectFormFunctionSelect;
str,V_FORMNAME,V_CONTROLNAME :string;
i :integer;
begin
FormCtrlSelect :=nil;
Try
FormCtrlSelect:=TRgtSelectFormFunctionSelect.create(self);
FormCtrlSelect.ShowModal;
EdtFuncNameEditing.Text :=FormCtrlSelect.P_FUNCNAME;
Edit1.text :='';
if FormCtrlSelect.P_CONTROLTYPE='INVISIBLE' then
Edit1.text :='看不見';
If FormCtrlSelect.P_CONTROLTYPE='DISABLED' then
Edit1.text :='不可編輯';
str :=FormCtrlSelect.P_FUNCID;
P_FUNCID :=str;
i :=pos('.',str);
V_FORMNAME :=copy(str,1,i-1);
V_CONTROLNAME :=copy(str,i+1,length(str));
Query_Tmp.close;
Query_Tmp.sql.text :='select FORMCAPTION,CONTROLCAPTION from SYSFORMCTRLLIST'
+' where FORMNAME='+#39+V_FORMNAME+#39
+' and CONTROLNAME='+#39+V_CONTROLNAME+#39;
Query_Tmp.open;
EdtFormCaptionEditing.text :=Query_Tmp.FieldByName('FORMCAPTION').AsString;
EdtControlCaptionEditing.Text :=Query_Tmp.FieldByName('CONTROLCAPTION').AsString;
P_FUNCSERIALID :=FormCtrlSelect.P_FUNCSERIALID;
Finally
FormCtrlSelect.Free;
end;
end;
procedure TRgtFrmRoleFunction.Query_PubAfterScroll(DataSet: TDataSet);
begin
query1.close;
query1.sql.text :=
'select a.*,b.controltype from PRIVROLEFUNC a,PRIVFUNCTION b '
+' where a.funcid=b.funcid(+) and ROLEID='
+Query_Pub.fieldbyname('ROLEID').asstring;
query1.Open;
if query1.Bof and query1.eof then
begin
Query1AfterScroll(nil);
end;
end;
procedure TRgtFrmRoleFunction.Query1AfterScroll(DataSet: TDataSet);
var
str,V_FORMNAME,V_CONTROLNAME :string;
i :integer;
begin
if P_edit then exit;
str :=Query1.FieldByName('FUNCID').AsString;
P_FUNCID :=str;
i :=pos('.',str);
V_FORMNAME :=copy(str,1,i-1);
V_CONTROLNAME :=copy(str,i+1,length(str));
//
Query_Tmp.close;
Query_Tmp.sql.text :='select FORMCAPTION,CONTROLCAPTION from SYSFORMCTRLLIST'
+' where FORMNAME='+#39+V_FORMNAME+#39
+' and CONTROLNAME='+#39+V_CONTROLNAME+#39;
Query_Tmp.open;
EdtFormCaptionEditing.text :=Query_Tmp.FieldByName('FORMCAPTION').AsString;
EdtControlCaptionEditing.Text :=Query_Tmp.FieldByName('CONTROLCAPTION').AsString;
EdtFuncNameEditing.text :=Query1.FieldByName('FUNCNAME').AsString;
P_FUNCSERIALID :=Query1.FieldByName('FUNCSERIALID').AsString;
EdtFuncSerialIdEditing.text :=Query1.FieldByName('SERIAL').AsString;
P_CurrentCode :=EdtFuncSerialIdEditing.text;
Edit1.text :='';
if uppercase(query1.fieldbyname('CONTROLTYPE').asstring) ='INVISIBLE' then
Edit1.text :='看不見';
if uppercase(query1.fieldbyname('CONTROLTYPE').asstring) ='DISABLED' then
Edit1.text :='不可編輯';
SbSysFormCtrlListEditing.Enabled :=false;
if not (Query1.bof and Query1.Eof) then
begin
BitBtnAlter.Enabled :=true;
BitBtnDel.Enabled :=true;
BitBtnSave.Enabled :=false;
end
else
begin
BitBtnAlter.Enabled :=false;
BitBtnDel.Enabled :=false;
BitBtnSave.Enabled :=false;
end;
end;
procedure TRgtFrmRoleFunction.Query1CalcFields(DataSet: TDataSet);
begin
if uppercase(query1.fieldbyname('CONTROLTYPE').asstring) ='INVISIBLE' then
query1.fieldbyname('TYPE').asstring :='看不見';
if uppercase(query1.fieldbyname('CONTROLTYPE').asstring) ='DISABLED' then
query1.fieldbyname('TYPE').asstring :='不可編輯';
end;
procedure TRgtFrmRoleFunction.FreeNode(treeview: TTreeview);
var
i:integer;
pnode:pchar;
begin
FOR i:=0 to TreeView.Items.Count - 1 do
begin
if TreeView.Items[i].Data<>nil then
begin
pnode:=pchar(TreeView.Items[i].Data);
FreeMem(pnode);
end;
end;
end;
procedure TRgtFrmRoleFunction.InitTreeViewRY;
var
NewJXNode: TTreeNode;
ljx,lcityno :string;
begin
//加市
with QueryTmp1 do
begin
close;//局向
sql.clear;
//sql.add('select OFF_NO_HOME,COUNTYNAME from T_D_COUNTY');
sql.add('select CITYNO,CITYNAME from T_D_CITY');
open;
first;
while not Eof do
begin
ljx :=Fields[0].AsString;
lcityno :=Fields[1].AsString;
//先把第一層建出來
NewJXNode:=
InsertTreeNode(TreeViewRy,nil,lcityno,ljx);
//TreeViewRy.Items.Add(nil,Fields[0].AsString+':'+Fields[1].AsString);
NewJXNode.ImageIndex := 0;
NewJXNode.SelectedIndex := 1;
//***************判斷該市下有沒縣有沒有,如果速度慢去掉*****************
//QueryTmp2.close;
//QueryTmp2.sql.text :='select count(OFF_NO_HOME) from T_D_COUNTY where CITYNO='+#39+ljx+#39;
//QueryTmp2.open;
//if QueryTmp2.fields[0].asinteger >0 then
//begin
//加入臨時結點來強行加上+號
InsertTreeNode(TreeViewRy,NewJXNode,'TEMP'
,'TEMP');
//end;
//************************************************************
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -