unit login;

interface

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

type
  TfrmLogin = class(TForm)
    Label1: TLabel;
    edtName: TEdit;
    Label2: TLabel;
    edtPass: TEdit;
    Button1: TButton;
    Button2: TButton;
    Panel1: TPanel;
    ClientDataSet1: TClientDataSet;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmLogin: TfrmLogin;
implementation

uses service;


{$R *.dfm}

procedure TfrmLogin.Button2Click(Sender: TObject);
begin
close;
frmService.Close;
end;

procedure TfrmLogin.Button1Click(Sender: TObject);
begin
  strName:=edtName.Text;
  strPassword:=edtPass.Text;
  if (strName<>'')and(strPassword<>'') then
    begin
      with ClientDataSet1 do
      begin
        Close;
        CommandText:='select * from readers where libcard_id='+quotedstr(strName)+' and password='+quotedstr(strPassword);
        open;
        if isempty then
          showmessage('借书证号或密码错。')
        else
          begin
            frmService.Enabled:=true;
            self.close;
            edtName.Text:='';
            edtPass.Text:='';
          end;
        close;
      end;
    end
  else
     showmessage('姓名、密码不能为空。');
end;

end.
