login.pas

来自「这是一个DELPHI7应用案例开发篇有配套程序种子光盘」· PAS 代码 · 共 69 行

PAS
69
字号
unit Login;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, IWControl, IWCompEdit, IWCompLabel, IWCompButton, IWInit,
  IWAppForm;

type
  TfrmLogin = class(TFrame)
    edUserName: TIWEdit;
    IWLabel1: TIWLabel;
    IWLabel2: TIWLabel;
    edPassword: TIWEdit;
    btnLogin: TIWButton;
    btnRegister: TIWButton;
    procedure btnRegisterClick(Sender: TObject);
    procedure btnLoginClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses LoginForm, DatamoduleUnit, ServerController, IWUnit1;

{$R *.dfm}

procedure TfrmLogin.btnRegisterClick(Sender: TObject);
begin
    TIWAppForm(RWebApplication.ActiveForm).Release;
    //显示新页面
    TfrmUserLogin.Create(RWebApplication).Show;
end;

procedure TfrmLogin.btnLoginClick(Sender: TObject);
var
    res : Variant;
begin
    with DataModule1.cdsCustomer do
    begin
        res := Lookup('ID',edUserName.Text,'Passwd');
        if (res<>NULL) then
            if (not (VarType(res) in [varNULL])) then
                if res=edPassword.Text then
                begin
                    UserSession.UserName := edUserName.Text;
                    UserSession.Password := edPassword.Text;
                    UserSession.LoginTime := Now;

                    TIWAppForm(RWebApplication.ActiveForm).Release;
                    //显示新页面
                    TformMain.Create(RWebApplication).Show;

                    Exit;
                end;

        RWebApplication.ShowMessage('用户名或密码错误!');
    end;
end;

end.



⌨️ 快捷键说明

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