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

📄 umovetogrp.pas

📁 用户权限管理系统
💻 PAS
字号:
unit uMoveToGrp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RzTabs, RzButton, StdCtrls, RzLabel, Grids, ComCtrls,
  cxControls, cxContainer, cxEdit, cxTextEdit, cxMemo, ExtCtrls,
  cxMaskEdit, cxDropDownEdit, RzPanel, cxTreeView, DB, DBClient, ImgList;

type
  TfrmMoveToGrp = class(TForm)
    RzButton1: TRzButton;
    RzButton2: TRzButton;
    cxTreeView1: TcxTreeView;
    cds_Grp: TClientDataSet;
    cds_GrpV01: TStringField;
    cds_GrpV02: TStringField;
    cds_GrpV03: TStringField;
    cds_GrpV04: TSmallintField;
    cds_GrpV05: TMemoField;
    Images: TImageList;
    procedure RzButton2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure RzButton1Click(Sender: TObject);
  private
    { Private declarations }
    function GetGrpNode(const Id: string): TTreeNode;
    procedure LoadUserGrp;

  public
    { Public declarations }
    UserId, GrpName: string;
  end;

var
  frmMoveToGrp: TfrmMoveToGrp;

implementation

uses untDM, untPublic;

{$R *.dfm}

function TfrmMoveToGrp.GetGrpNode(const Id: string): TTreeNode;
var
  i: integer;
begin
  result := nil;
  for i := 0 to cxTreeView1.Items.Count - 1 do
  begin
    if PUserGrpData(cxTreeView1.Items[i].Data)^.GrpId = Id then
    begin
      result := cxTreeView1.Items[i];
      break;
    end;
  end;
end;

procedure TfrmMoveToGrp.LoadUserGrp;
var
  Node, ParNode: TTreeNode;
  NodData: PUserGrpData;
begin
  with cds_Grp do
  begin
    if Active then
      Active := false;
    XMLData := DM.FreeQuery('select * from T_003 order by V04,V03,V01');
    Active := true;

    first;
    while not eof do
    begin
      ParNode := GetGrpNode(trim(cds_Grp.fieldbyname('V03').AsString));
      Node := cxTreeView1.Items.AddChild(ParNode,
        trim(cds_Grp.fieldbyname('V02').AsString));
      Node.ImageIndex := 1;
      Node.SelectedIndex := 0;

      new(NodData);
      NodData^.GrpId := trim(cds_Grp.fieldbyname('V01').AsString);
      NodData^.GrpName := trim(cds_Grp.fieldbyname('V02').AsString);
      NodData^.GrpMemo := trim(cds_Grp.fieldbyname('V05').AsString);
      NodData^.Nod := Node;
      Node.Data := NodData;
      next;
    end;
  end;
  cxTreeView1.FullExpand;
end;

procedure TfrmMoveToGrp.RzButton2Click(Sender: TObject);
begin
  ModalResult := mrCancel;
  close;
end;

procedure TfrmMoveToGrp.FormShow(Sender: TObject);
begin
  LoadUserGrp;
end;

procedure TfrmMoveToGrp.RzButton1Click(Sender: TObject);
begin
  if (cxTreeView1.Selected <> nil) and (trim(UserId) <> '') then
  begin
    DM.UserToGrp(PUserGrpData(cxTreeView1.Selected.Data)^.GrpId, UserId);
    GrpName:= PUserGrpData(cxTreeView1.Selected.Data)^.GrpName;
    ModalResult := mrOk;
  end;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -