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
  strLibCard_id:=edtName.Text;
  strPassword:=edtPass.Text;
  if (strLibCard_id<>'')and(strPassword<>'') then
    begin
      with ClientDataSet1 do
      begin
        Close;
        CommandText:='select * from readers where libcard_id='+quotedstr(strLibCard_id)+' and password='+quotedstr(strPassword);
        open;
        if isempty then
          showmessage('借书证号或密码错。')
        else
          begin
            strName:=fieldvalues['reader_name'];
            frmService.Enabled:=true;
            self.close;
            edtName.Text:='';
            edtPass.Text:='';
          end;
        close;
      end;
    end
  else
     showmessage('姓名、密码不能为空。');
end;

end.
