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

📄 oplog.pas

📁 计量功能 事件记录 购电提醒 欠费报警 负荷控制 自检功能 显示功能 用户插卡错误信息显示
💻 PAS
字号:
unit OpLog;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, DBClient, MConnect, ConstDef;

type
  TFrmOpLog = class(TForm)
    BtnOK: TButton;
    BtnCancel: TButton;
    LabAccount: TLabel;
    LabPsw1: TLabel;
    EdtPsw1: TEdit;
    LabPsw2: TLabel;
    EdtPsw2: TEdit;
    DCOMOpLog: TDCOMConnection;
    EdtAccount: TEdit;
    procedure FormShow(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
    procedure BtnCancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
    EnterMode: EnterModeType;
  end;

var
  FrmOpLog: TFrmOpLog;
  LogResult: CntResultType;
implementation

uses ClntMain;

{$R *.DFM}

procedure TFrmOpLog.FormCreate(Sender: TObject);
begin
  with DCOMOpLog do begin
    ComputerName:=RecNImsInfo.SrvHost.sHostName;
    ServerGUID:=DefSrvGUID;
    LoginPrompt:=False;  Connected:=False;
   end;
end;

procedure TFrmOpLog.FormShow(Sender: TObject);
begin
  EdtAccount.Text:='';
  EdtAccount.Enabled:=True;  EdtAccount.Visible:=True;
  EdtPsw1.Text:='';          EdtPsw2.Text:='';

  if EnterMode = OpLogInMode then
   begin //远程登录模式
    EdtPsw1.Enabled:=True;   EdtPsw1.Visible:=True;
    EdtPsw2.Enabled:=False;  EdtPsw2.Visible:=False;
    LabPsw2.Enabled:=False;  LabPsw2.Visible:=False;
   end
  else if EnterMode = OpChgPswMode then
   begin //更改登录口令模式
    EdtAccount.Text:= RecOpInfo.sAccount;
    EdtAccount.Enabled:=False;
    EdtPsw2.Enabled:=True;  EdtPsw2.Visible:=True;
    LabPsw2.Enabled:=True;  LabPsw2.Visible:=True;
   end;

end;

procedure TFrmOpLog.BtnOKClick(Sender: TObject);
var
  wsT1,wsT2: WideString;
  btClass: Byte;
begin
  RecOpInfo.sAccount:=EdtAccount.Text;
  RecOpInfo.sOpPsw:=EdtPsw1.Text;
  if EnterMode = OpLogInMode then begin
    RecOpInfo.cOpClass:=DefSysOpChar;//Client只能由系统操作员登录
    try  //远程登录
      with RecOpInfo do begin
        btClass:=Byte(cOpClass);
        with DCOMOpLog do begin
          Connected:=True;
          LogResult:=AppServer.btFunRmtLogIn(sAccount,sOpPsw,
                     btClass,wsT1,wsT2); //返回登录帐号的系统操作级别
          Connected:=False;
          cOpClass:=Char(btClass); sOpName:=wsT1; sOpMark:=wsT2;
          if (LogResult=CntLogOK) and (cOpClass<>DefSysOpChar) then
              LogResult:=CntNotExist;
         end;//end DCOMOpLog
       end; //end RecOpInfo
    except
      LogResult:=CntLogFail;
     end;
   end
  else if EnterMode = OpChgPswMode then begin
    try  //更改口令
      with RecOpInfo do begin
        wsT1:=sOpPsw;  wsT2:=EdtPsw2.Text;
        with DCOMOpLog do begin
          Connected:=True;
          LogResult:=AppServer.btFunRmtChgPsw(sAccount,wsT1,wsT2);
          Connected:=False;
         end;//end DCOMOpLog
        if LogResult=CntChgPswOK then sOpPsw:=wsT2;
       end;//end RecOpInfo
    except
       LogResult:=CntLogFail;
     end;
   end;//end if
  if LogResult = CntLogOK then ModalResult:=mrOK
  else if LogResult = CntChgPswOK then begin
    wFunShowOK('登录口令更改成功!',[mbOK]);
    ModalResult:=mrOK; Exit;
   end
  else begin
    if LogResult=CntLogFail  then wFunShowError('登录NIms失败!',[mbOK])
    else if LogResult=CntNotExist then
      wFunShowError('登录帐号不存在!',[mbOK])
    else if LogResult=CntLogged   then
      wFunShowError('操作员已登录!',[mbOK])
    else if LogResult=CntPswError then
      wFunShowError('登录口令错误!',[mbOK]);
    ModalResult:=mrCancel; Exit;
   end;
end;

procedure TFrmOpLog.BtnCancelClick(Sender: TObject);
begin
  ModalResult:=mrCancel;
end;

procedure TFrmOpLog.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  //ModalResult:=mrCancel;
end;

end.

⌨️ 快捷键说明

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