⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rgtrolefunction.pas

📁 一个不错的源程序DELPHI开发的,功能比较好的客户管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      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 + -