unit1.pas

来自「DELPHI7编程百例 DELPHI7编程百例 DELPHI7编程百例」· PAS 代码 · 共 63 行

PAS
63
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBClient, MConnect, Grids, DBGrids, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    ClientDataSet1: TClientDataSet;
    DCOMConnection1: TDCOMConnection;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    FLogin:Boolean;
    User:string;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Unit2;
procedure TForm1.FormCreate(Sender: TObject);
begin
  FLogin:=False;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Password:WideString;
begin
  if not(FLogin)then
  begin
    if LoginDlg.ShowModal=mrOK then
    begin
      FLogin:=True;
      User:=LoginDlg.Edit1.Text;
      Password:=LoginDlg.Edit2.Text;
      DCOMConnection1.AppServer.Login(User,Password);
    end;
  end;
  ClientDataSet1.Open;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DCOMConnection1.AppServer.Logout(User);
end;

end.

⌨️ 快捷键说明

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