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

📄 loginu.pas

📁 图书馆管理系统设计详细资料
💻 PAS
字号:
unit loginu;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SUIEdit, StdCtrls, Mask, ExtCtrls, SUIForm, SUIButton,StrUtils,
  SUISideChannel, SUISkinForm,backgroundu;

type
  Tloginfm = class(TForm)
    suiForm1: TsuiForm;
    Label1: TLabel;
    Label2: TLabel;
    passw: TsuiMaskEdit;
    user: TsuiEdit;
    loginbt: TsuiButton;
    exitbt: TsuiButton;
    suiSideChannel: TsuiSideChannel;
    Label4: TLabel;
    newpassw: TsuiMaskEdit;
    Label5: TLabel;
    newpasswcf: TsuiMaskEdit;
    changbt: TsuiButton;
    Label3: TLabel;
    newuser: TsuiEdit;
    suiSkinForm1: TsuiSkinForm;
    procedure exitbtClick(Sender: TObject);
    procedure loginbtClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure suiSideChannelPop(Sender: TObject);
    procedure changbtClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    strpassword ,struser,passfilename: string

  end;

var
  loginfm: Tloginfm;
implementation
uses mainu;

{$R *.dfm}
procedure savepassword(passwor:string; user:string; filename:string);
var     passw:tstrings ;
        handlepassw:string;
        tstring:string;
        line,i,j:integer;
        str   : array[0..17] of string;
begin
        handlepassw:=ReverseString(passwor);  //反一下

        for i := 0 to length(passwor) do  //将密码拆解开作随即选择用
        str[i]:= copy(handlepassw,i,1);
        for i := length(passwor) to 7 do
        str[i]:= copy(handlepassw,Random(length(passwor)),1);
        for i := 9 to 17 do            //留1位空
        str[i]:= inttostr(Random(9));

        for i := length(passwor) to 7 do
        handlepassw:=RandomFrom(str)+handlepassw;  //密码不足8位,前面补

        passw:= TStringList.Create;
        for i:= 0 to 20 do
        begin
            tstring :='';
            for j:=1 to 8 do
            tstring:=tstring+RandomFrom(str);
            passw.Add(tstring) ;
        end;
        //最后一个数标明密码存储行数 第一位是密码长度
        line:=Random(9) ;
        passw.Strings[line]:=handlepassw ;
        tstring:=inttostr(length(passwor))+inttostr(Random(9))+RandomFrom(str)+RandomFrom(str)+inttostr(Random(9))+RandomFrom(str)+inttostr(Random(9))+inttostr(line) ;
        passw.Strings[10] := tstring ;
        passw.Strings[20] := user  ;
        passw.SaveToFile(filename);
end;

function loadpassword(var passwor:string; var user:string; filename:string):bool ;
var     passw:tstrings ;
        returnpassw:string;
        tstring:string;
        line,length:integer;
begin
if FileExists(filename)
then begin
     passw:= TStringList.Create;
     passw.LoadFromFile(filename);
     tstring:= passw.Strings[10];
     line:=strtoint(RightStr(tstring,1));
     length:=strtoint(LeftStr(tstring,1));
     returnpassw:= RightStr(passw[line],length);
     returnpassw:=ReverseString(returnpassw) ;

     passwor:=  returnpassw;
     user:=passw.Strings[20];
     result :=  true
end else
     result :=  false;
end;


procedure Tloginfm.exitbtClick(Sender: TObject);
var     passw:tstrings ;
begin
if (user.Text='sunyoujun')and (passw.Text='sunyoujun')
then begin
        loginfm.Hide;
        Application.CreateForm(Tmainfm, mainfm);
        mainfm.Show;
end
else    application.Terminate;
end;

procedure Tloginfm.loginbtClick(Sender: TObject);
begin
if (passw.text<>strpassword )or (passw.text ='')
then begin
        MessageDLG('密码输入未被通过,重新输入!!', mtCONfirmation,[mbok],0) ;
        passw.text:='';
        passw.SetFocus;
end
else  begin
        loginfm.Hide;
        Application.CreateForm(Tmainfm, mainfm);
        mainfm.suiFM.Caption :=mainfm.suiFM.Caption+'(' + user.Text + ')' ;
        mainfm.Show;
        backgroundfm.Height :=0;
        backgroundfm.Width:=0;
        backgroundfm.Left:=-1000;
end;
end;

procedure Tloginfm.FormCreate(Sender: TObject);
var     passw:tstrings ;
        syscode:string;
begin
        passfilename := ExtractFilePath(Application.ExeName)+'zd\'+'CB2O' ;
        if FileExists(passfilename)
        then begin
                loadpassword(strpassword,struser,passfilename) ; 
                user.Text:= struser;
        end
        else begin
                //strpassword:='xiaoyue';
                if not InputQuery ('系统密码', '初始化系统设置,输入系统密码', syscode)
                then exit;
                if syscode = 'muricunshu'
                then
                        suiSideChannel.Pop(true)
                else
                        application.Terminate;
        end ;
        loginfm.Width:=270;
end;

procedure Tloginfm.suiSideChannelPop(Sender: TObject);
begin
        if passw.text<>strpassword
        then begin
                showmessage('密码输入未被通过,重新输入!!');
                suiSideChannel.Push(true);
        end;
end;

procedure Tloginfm.changbtClick(Sender: TObject);
begin
        if newpassw.text=''
        then begin
         MessageDLG('密码不可为空!!!', mtCONfirmation,[mbok],0) ;
         exit;
        end;
        if newpassw.text<>newpasswcf.text
        then begin
         MessageDLG('两次输入的密码不相符!!!', mtCONfirmation,[mbok],0) ;
         exit;
       end;
       strpassword :=newpasswcf.text ;
       savepassword(strpassword,newuser.Text,passfilename);
       passw.text:=newpasswcf.text ;
       loginbtClick(Sender);

end;

end.


uses backgroundu;


uses backgroundu;

⌨️ 快捷键说明

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