frmsecurity.pas
来自「详细说明:毕业论文中关于小型宾馆管理系统的详细设计毕 业论文中关于小型宾馆...」· PAS 代码 · 共 188 行
PAS
188 行
//
// View/modify/insert Prexim security settings
//
// NOTE: Before showing the form set the g_Framework member
//
//
unit frmSecurity;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons,
utils;
type
TfrmSecurity = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
bOk: TBitBtn;
bCancel: TBitBtn;
eMinLen: TEdit;
eMinNum: TEdit;
eMinPun: TEdit;
eMaxCon: TEdit;
ePasExp: TEdit;
Label12: TLabel;
Label16: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure FormShow(Sender: TObject);
procedure bOkClick(Sender: TObject);
public
private
g_oplock: WideString;
function UpdateDisplay: Boolean;
end;
//var
// frmSecurity: TfrmSecurity;
implementation
{$R *.DFM}
//
// Initialise
//
procedure TfrmSecurity.FormShow(Sender: TObject);
begin
// Call Application Server for security settings
// Update display
bOK.Enabled:=UpdateDisplay;
BringToTheFront(self);
end;
//
// Call the Framework and get the security settings
// Update the user display
//
// Returns TRUE on success
//
function TfrmSecurity.UpdateDisplay: Boolean;
var min_pword_len, min_pword_num, min_pword_punc: Integer;
max_consecutive, pword_expiry, store_old_pwords: Integer;
errcode: Integer;
errmsg: String;
r: Integer;
begin
try
{ r:=g_Framework.FW_GetSecurity(min_pword_len, min_pword_num, min_pword_punc,
max_consecutive, pword_expiry, store_old_pwords, g_oplock);
if r<>Integer(GE_OK) then begin
errmsg:=g_Framework.FW_LastError(errcode);
MessageDlg(errmsg+#13+#13+'There was an error retrieving the security information.',
mtError, [mbCancel], 0);
Result:=FALSE;
Exit;
end;
}
// Update display
eMinLen.text:=IntToStr(min_pword_len);
eMinNum.text:=IntToStr(min_pword_num);
eMinPun.text:=IntToStr(min_pword_punc);
eMaxCon.text:=IntToStr(max_consecutive);
ePasExp.text:=IntToStr(pword_expiry);
Result:=TRUE;
finally
end;
end;
//
// Update security settings
//
procedure TfrmSecurity.bOkClick(Sender: TObject);
var min_pword_len, min_pword_num, min_pword_punc: Integer;
max_consecutive, pword_expiry, store_old_pwords: Integer;
errcode: Integer;
errmsg: String;
old_oplock: WideString;
begin
// Validation
try
if (StrToInt(eMinLen.text) < 0) or (StrToInt(eMinLen.text) > 32) then begin
ShowMessage('Minumum password lengths must be between zero and thirty-two inclusive.');
ModalResult:=mrNone;
Exit;
end;
if (StrToInt(eMinNum.text) < 0) or (StrToInt(eMinNum.text) > StrToInt(eMinLen.text)) then begin
ShowMessage('Invalid value for minimum number of numerical characters. It cannot be longer than the minimum password length.');
ModalResult:=mrNone;
Exit;
end;
if (StrToInt(eMinPun.text) < 0) or (StrToInt(eMinPun.text) > StrToInt(eMinLen.text)) then begin
ShowMessage('Invalid value for minimum number of numerical characters. It cannot be longer than the minimum password length.');
ModalResult:=mrNone;
Exit;
end;
if StrToInt(eMinPun.text) + StrToInt(eMinNum.text) > StrToInt(eMinLen.text) then begin
ShowMessage('The minimum password length is too short for the minimum settings supplied.');
ModalResult:=mrNone;
Exit;
end;
if StrToInt(eMaxCon.text) < 0 then begin
ShowMessage('Invalid value for maximum number of consecutive characters - specify 0 to disable this feature.');
ModalResult:=mrNone;
Exit;
end;
if StrToInt(ePasExp.text) < 0 then begin
ShowMessage('Invalid value for password expiry - specify 0 to disable password expiry.');
ModalResult:=mrNone;
Exit;
end;
except
ShowMessage('There is an invalid numerical value in one of the fields.');
ModalResult:=mrNone;
Exit;
end;
// Get values from form
min_pword_len:=StrToInt(eMinLen.text);
min_pword_num:=StrToInt(eMinNum.text);
min_pword_punc:=StrToInt(eMinPun.text);
max_consecutive:=StrToInt(eMaxCon.text);
pword_expiry:=StrToInt(ePasExp.text);
old_oplock:=g_oplock;
// Update database
try
{ if g_Framework.FW_SetSecurity(min_pword_len, min_pword_num, min_pword_punc,
max_consecutive, pword_expiry, store_old_pwords, g_oplock)<>GE_OK then begin
// Failed
ModalResult:=mrNone;
// Reset display
if not UpdateDisplay then
ModalResult:=mrCancel
else if g_oplock<>old_oplock then
MessageDlg('Another user has changed the security settings.'+#13+
'The settings have been reset to their new values. Please try again.',
mtError, [mbOK], 0)
else begin
errmsg:=g_Framework.FW_LastError(errcode);
MessageDlg(errmsg+#13+#13+
'There was an error updating the security information.'+#13+
'The settings have been reset to their correct stored values.',
mtError, [mbOK], 0);
end;
end else
ModalResult:=mrOK;}
finally
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?