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

📄 login_u.pas

📁 从盒子上面转过来的一个很小的软件
💻 PAS
字号:
unit Login_U;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, DB, Grids, DBGrids;

type
  TLogin = class(TForm)
    BitBtn1: TBitBtn;
    Image1: TImage;
    DateTimePicker1: TDateTimePicker;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    ComboBox1: TComboBox;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
    protected
    procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
         message WM_GETMINMAXINFO;
  public
    { Public declarations }
  end;

var
  Login: TLogin;
  inputtimes:integer;

implementation

uses DB_U;

{$R *.dfm}
procedure TLogin.WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
begin
  with Message.MinMaxInfo^ do
  begin
    ptMinTrackSize := Point(304, 169);
   //限定窗口最小尺寸为100*100
    ptMaxTrackSize := Point(304, 169);
   //限定窗口最大尺寸为200*200
  end;
end;

procedure TLogin.BitBtn1Click(Sender: TObject);
var
s:String;
begin

 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('delete from Login_temp');
 customerdata.adoquery1.Execsql;
 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('Insert into Login_temp (rq,name) values(:rq,:name)');
 customerdata.adoquery1.Parameters.ParamByName('rq').Value:=datetostr(datetimepicker1.date);
 customerdata.adoquery1.Parameters.ParamByName('name').Value:=combobox1.text;
 customerdata.adoquery1.Execsql;

 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('select * from users where name='''+combobox1.text+'''');
 customerdata.adoquery1.Open;
 s:=customerdata.adoquery1.fieldbyname('password').AsString;
  customerdata.adoquery1.close;
 inputtimes:=inputtimes+1;
 if inputtimes<=3 then
 begin
   if Edit1.text=s then
    modalresult:=mrok
   else
    Application.MessageBox(' 口令错误! 请重新输入! ','注意',MB_Iconexclamation+MB_oK);
    Edit1.setfocus;
   end
  else
   application.terminate;
end;



procedure TLogin.BitBtn2Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TLogin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//application.Terminate;
end;

procedure TLogin.FormCreate(Sender: TObject);
begin
// customerdata.ADOConnection1.Connected:=False;
// FileSetAttr('data\main.mdb',0);//去掉数据库文件只读属性
// customerdata.ADOConnection1.Connected:=True;
 datetimepicker1.date:=date();
 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('select * from users');
 customerdata.adoquery1.Open;
 customerdata.adoquery1.first;
 while not customerdata.adoquery1.Eof do
 begin
 combobox1.Items.add(customerdata.adoquery1.fieldbyname('name').asstring);
 customerdata.adoquery1.next;
 end;
 combobox1.ItemIndex:=0;
 close;
end;

procedure TLogin.FormActivate(Sender: TObject);
begin
inputtimes:=0;
end;

procedure TLogin.ComboBox1Change(Sender: TObject);
begin
{if combobox1.Text='' then
  bitbtn1.Enabled:=false
 else
  bitbtn1.Enabled:=true; }
edit1.setfocus;
end;

procedure TLogin.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
s:string;
begin
 if Key=$0D then  begin
 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('delete from Login_temp');
 customerdata.adoquery1.Execsql;
 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('Insert into Login_temp (rq,name) values(:rq,:name)');
 customerdata.adoquery1.Parameters.ParamByName('rq').Value:=datetostr(datetimepicker1.date);
 customerdata.adoquery1.Parameters.ParamByName('name').Value:=combobox1.text;
 customerdata.adoquery1.Execsql;

 customerdata.adoquery1.close;
 customerdata.adoquery1.sql.clear;
 customerdata.adoquery1.sql.add('select * from users where name='''+combobox1.text+'''');
 customerdata.adoquery1.Open;
 s:=customerdata.adoquery1.fieldbyname('password').asstring;
 customerdata.adoquery1.close;
 inputtimes:=inputtimes+1;
 if inputtimes<=3 then
 begin
   if Edit1.text=s then
    modalresult:=mrok
   else
    Application.MessageBox(' 口令错误! 请重新输入! ','注意',MB_Iconexclamation+MB_oK);
    Edit1.text:='';
    Edit1.setfocus;
   end
  else
  begin
   application.terminate;
  end;
end;
end;

procedure TLogin.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=VK_ESCAPE then begin
 Key:=Word(Nil);
 Close;
end;
end;

end.

⌨️ 快捷键说明

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