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

📄 frmpjguser.pas

📁 ProviceSystem-公积金监管系统中心端
💻 PAS
字号:
unit frmPJgUser;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids, ComCtrls, ToolWin,
  ImgList, uNodeUtils;

type
  TJgUser = class(TForm)
    ImageList1: TImageList;
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ImageList2: TImageList;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    DBGrid1: TDBGrid;
    TabSheet2: TTabSheet;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit2: TEdit;
    Edit1: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Panel2: TPanel;
    CheckBox17: TCheckBox;
    CheckBox18: TCheckBox;
    CheckBox19: TCheckBox;
    CheckBox20: TCheckBox;
    CheckBox21: TCheckBox;
    CheckBox22: TCheckBox;
    CheckBox23: TCheckBox;
    CheckBox24: TCheckBox;
    CheckBox25: TCheckBox;
    CheckBox26: TCheckBox;
    CheckBox27: TCheckBox;
    CheckBox28: TCheckBox;
    CheckBox29: TCheckBox;
    CheckBox30: TCheckBox;
    CheckBox31: TCheckBox;
    CheckBox32: TCheckBox;
    CheckBox33: TCheckBox;
    CheckBox34: TCheckBox;
    CheckBox35: TCheckBox;
    CheckBox36: TCheckBox;
    CheckBox1: TCheckBox;
    ScrollBox1: TScrollBox;
    ToolButton7: TToolButton;
    ToolButton10: TToolButton;
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
  private
    { Private declarations }
    aNode: TCheckBoxView;
    bWzSet: Boolean;
  public
    { Public declarations }
  end;

var
  JgUser: TJgUser;

implementation

{$R *.dfm}
uses uDMFunc, uUserFunc, uConstUtils, uVarUtils;

procedure TJgUser.ToolButton1Click(Sender: TObject);
var
  i: Longint;
begin
  i:= RecordNo;
  PageControl1.ActivePageIndex :=0;
  UserInfo(DBGrid1);
  if bWzSet then
    RecordNo(i);
  ToolButton1.Enabled := True;
  ToolButton3.Enabled := True;
  if RecordCount=0 then
  begin
    ToolButton4.Enabled := False;
    ToolButton5.Enabled := False;
  end
  else
  begin
    ToolButton4.Enabled := True;
    ToolButton5.Enabled := True;
  end;
  ToolButton7.Enabled := False;
  ToolButton10.Enabled := False;
end;

procedure TJgUser.ToolButton3Click(Sender: TObject);
var
  i: smallint;
begin
  PageControl1.ActivePageIndex :=1;
  Edit1.Enabled := True;
  Edit2.Enabled := True;
  Edit1.Text := '';
  Edit2.Text := '';
  Edit3.Text := '';
  Edit4.Text := '';
  CheckBox1.Checked := False;
  for i:=0 to Panel2.ControlCount-1 do
    (Panel2.Controls[i] as TCheckBox).Checked := False;
{  for i:=0 to Panel3.ControlCount-1 do
    (Panel3.Controls[i] as TCheckBox).Checked := False;
}
  aNode.SetCheckedAll(False);
//  aNode.EnabledAll := True;
  ToolButton1.Enabled := False;
  ToolButton3.Enabled := False;
  ToolButton4.Enabled := False;
  ToolButton5.Enabled := False;
  ToolButton7.Enabled := true;
  ToolButton10.Enabled := true;
end;

procedure TJgUser.ToolButton4Click(Sender: TObject);
var
  sUid, sPwd, sName, sQx, sSsds: String;
  i: smallint;
  lSys: Boolean;
begin
  UserInfoRec(sUid, sPwd, sName, sQx, sSsds, lSys);
  if (not lSys) and (uppercase(pubLoginUserId) = uppercase(sUid)) then
  begin
    Application.MessageBox('不能修改自已的权限!',PMsgCaption,64);
    exit;
  end;

  PageControl1.ActivePageIndex :=1;
  Edit1.Enabled := False;
  ToolButton1.Enabled := False;
  ToolButton3.Enabled := False;
  ToolButton4.Enabled := False;
  ToolButton5.Enabled := False;
  ToolButton7.Enabled := True;
  ToolButton10.Enabled := True;
  if lSys then
    Edit2.Enabled := True
  else
    Edit2.Enabled := False;
  Edit1.Text := sUid;
  Edit2.Text := sName;
  Edit3.Text := sPwd;
  Edit4.Text := sPwd;
  CheckBox1.Checked := lSys;
  for i:=0 to Panel2.ControlCount-1 do
    (Panel2.Controls[i] as TCheckBox).Checked := IIF(copy(sQx,i+1,1)='1',True,False);
  aNode.SetCheckedAll(sSsds);
//  aNode.EnabledAll := True;
{  for i:=0 to Panel3.ControlCount-1 do
    (Panel3.Controls[i] as TCheckBox).Checked := IIF(copy(sSsds,i,1)='1',True,False);
}
end;

procedure TJgUser.ToolButton9Click(Sender: TObject);
begin
  close;
end;

procedure TJgUser.FormCreate(Sender: TObject);
begin
  bWzSet := False;
  aNode := TCheckBoxView.Create;
  aNode.Columns := 1;
  aNode.LeftSpace := 10;
  aNode.TopSpace :=10;
  aNode.HSpace := 20;
  aNode.VSpace := 10;
  DsInfo(aNode);
  aNode.AdjustWidth;
//  aNode.EnabledAll := False;
  aNode.SetParent(ScrollBox1);
  ToolButton1.Click;
  bWzSet := True;
  Resize;
end;

procedure TJgUser.FormResize(Sender: TObject);
begin
  if ScrollBox1.Width > aNode.Width then
    aNode.Columns := trunc((ScrollBox1.Width-aNode.LeftSpace) / (aNode.Width+aNode.HSpace) )
  else
    aNode.Columns := 1;
  aNode.AdjustWidth;
end;

procedure TJgUser.ToolButton5Click(Sender: TObject);
var
  sUid, sPwd, sName, sQx, sSsds: String;
  lSys: Boolean;
  iRec: Longint;
begin
  PageControl1.ActivePageIndex :=0;
  UserInfoRec(sUid, sPwd, sName, sQx, sSsds, lSys);
  if lSys then
  begin
    Application.MessageBox(Pchar('用户“'+sName+'”是系统管理员不允许删除!'),
      PMsgCaption,64);
    exit;
  end;
  if pubLoginUserId = sUid then
  begin
    Application.MessageBox('不能删除自已!',PMsgCaption,64);
    exit;
  end;
  if Application.MessageBox(Pchar('是否要删除用户“'+sName+'”?'),
    PMsgCaption,36)=6 then
  begin
    iRec := RecordNo;
    if iRec > 0 then
      Dec(iRec);
    if UserDelete(sUid)= 0 then
    begin
      UserInfo(DBGrid1);
      Application.MessageBox('删除成功!', PMsgCaption,64);
      if RecordCount>=iRec then
        RecordNo(iRec);
{      if RecordCount=0 then
      begin
        ToolButton4.Enabled := False;
        ToolButton5.Enabled := False;
      end
      else
        RecordNo(0);
}
    end
    else
      Application.MessageBox('删除失败!', PMsgCaption,64);
  end;
end;

procedure TJgUser.FormDestroy(Sender: TObject);
begin
  FreeAndNil(aNode);
end;

procedure TJgUser.ToolButton7Click(Sender: TObject);
var
  sUid, sPwd, sName, sQx, sSsds: String;
  i, iRet: smallint;
  lSys: Boolean;
begin
  sUid := trim(Edit1.Text);
  if Edit1.Enabled then
    if UserExists(sUid) then
    begin
      application.MessageBox('用户已存在,请重新输入!',PMsgCaption,64);
      Edit1.SetFocus;
      exit;
    end;
  sName := trim(Edit2.Text);
  sPwd := trim(Edit3.Text);
  if trim(Edit4.Text) <> sPwd then
  begin
    application.MessageBox('用户操作密码输入不一致,请重新输入!',PMsgCaption,64);
    Edit3.SetFocus;
    exit;
  end;
  lSys := CheckBox1.Checked;
  sQx := '';
  for i:=0 to Panel2.ControlCount -1 do
    sQx := sQx+IIF((Panel2.Controls[i] as TCheckBox).Checked,'1','0');
  sSsds := '';
//  for i:=0 to Panel3.ControlCount -1 do
//    sSsds := sSsds+IIF((Panel3.Controls[i] as TCheckBox).Checked,'1','0');
  sSsds := aNode.GetCheckedAll();
  iRet := UserSave(sUid,sPwd,sName,sQx,sSsds,lSys);
  if Edit1.Enabled then
  begin
    if iRet=0 then
    begin
      Application.MessageBox('增加成功',PMsgCaption,64);
      Toolbutton1.Click;
    end
    else
      Application.MessageBox('增加失败',PMsgCaption,16);
  end
  else
  begin
    if iRet=0 then
    begin
      Application.MessageBox('修改成功',PMsgCaption,64);
      Toolbutton1.Click;
    end
    else
      Application.MessageBox('修改失败',PMsgCaption,16);
  end;
end;

procedure TJgUser.ToolButton10Click(Sender: TObject);
begin
  ToolButton1.Click;
end;

end.

⌨️ 快捷键说明

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