Unit1.pas
上传用户:szyozho
上传日期:2013-04-13
资源大小:3688k
文件大小:4k
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, Buttons, StdCtrls, DBCtrls, DB, Mask,DBTables;
- type
- Tloginform = class(TForm)
- Image1: TImage;
- Label1: TLabel;
- Label2: TLabel;
- Edit1: TEdit;
- Label3: TLabel;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Query1: TQuery;
- Query1ID: TStringField;
- Query1mi: TStringField;
- Query1qx: TStringField;
- ComboBox1: TComboBox;
- Timer1: TTimer;
- // procedure ComboBox1Change(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure Edit1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure FormShow(Sender: TObject);
- private
- { Private declarations }
- public
-
- { Public declarations }
- //username:string;
- //password:string;
- end;
- var
- loginform: Tloginform;
- t:integer;
- flash:boolean;
- //username,password:string;
- implementation
- uses Unit4, Unit3, Unit21;
- {$R *.dfm}
- procedure Tloginform.BitBtn2Click(Sender: TObject);
- begin
- if (messagedlg('确认要退出系统吗 ?',mtconfirmation,[mbyes,mbno],0))=mryes then
- application.Terminate;
- end;
- procedure Tloginform.FormCreate(Sender: TObject);
- begin
- flash:=false;
- t:=0;
- query1.Close;
- query1.SQL.Clear;
- query1.SQL.Add('select * from u');
- query1.open;
- while not query1.eof do
- begin
- ComboBox1.items.add(trim(query1.fieldbyname('ID').asstring));
- query1.next;
- end;
- end;
- procedure Tloginform.BitBtn1Click(Sender: TObject);
- begin
- query1.Close;
- query1.SQL.Clear;
- query1.SQL.Add('select * from u where ID=:p1 and mi=:p2');
- query1.Params[0].AsString:=ComboBox1.Text;
- query1.Params[1].AsString:=Edit1.Text;
- query1.Open;
- inc(t);
- if query1.RecordCount>0 then
- begin
- mainform.username:=ComboBox1.Text;
- mainform.password:=edit1.Text;
- mainform.StatusBar1.Panels[1].Text:='当前用户:'+ ComboBox1.Text;
- // query1.Close;
- // query1.SQL.Clear;
- // query1.SQL.text:='select qx from u where ID='''+ComboBox1.Text+'''';
- // query1.ExecSQL;
- if query1.fieldbyname('qx').AsString='b' then
- begin
- if rightform.CheckBox1.State=cbChecked then
- mainform.N3.Enabled:=true else mainform.N3.Enabled:=false;
- if rightform.CheckBox2.State=cbChecked then
- mainform.N18.Enabled:=true else mainform.N18.Enabled:=false;
- if rightform.CheckBox4.State=cbChecked then
- mainform.N6.Enabled:=true else mainform.N6.Enabled:=false;
- if rightform.CheckBox5.State=cbChecked then
- mainform.N7.Enabled:=true else mainform.N7.Enabled:=false;
- if rightform.CheckBox7.State=cbChecked then
- mainform.N10.Enabled:=true else mainform.N10.Enabled:=false;
-
- // mainform.N3.Enabled:=false;
- // mainform.N6.Enabled:=false;
- // mainform.N7.Enabled:=false;
- // mainform.N10.Enabled:=false;
- // mainform.N18.Enabled:=false;
- // form21.BitBtn1.Click;
- end;
- if query1.fieldbyname('qx').AsString='a' then
- begin
- mainform.N3.Enabled:=true;
- mainform.N6.Enabled:=true;
- mainform.N7.Enabled:=true;
- mainform.N10.Enabled:=true;
- mainform.N18.Enabled:=true;
- // form21.BitBtn1.Click;
- end;
- havelogin:=true;
- loginform.Close;
- end
- else
- begin
- showMessage('密码输入错误,请重新输入!');
- if t>=3 then
- begin
- MessageBox(handle,'输入密码错误超过三次,程序退出!','信息',MB_OK);
- Close;
- Application.Terminate;
- end
- else
- begin
- edit1.Text:='';
- edit1.SetFocus;
- end;
- end;
- // if query1.fieldbyname('qx').AsString='a' then
- end;
- procedure Tloginform.Timer1Timer(Sender: TObject);
- begin
- FlashWindow(loginform.Handle,flash);
- FlashWindow(Application.Handle,flash);
- flash:=not flash;
- end;
- procedure Tloginform.Edit1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if Key=13 then
- BitBtn1Click(Sender);
- end;
- procedure Tloginform.FormShow(Sender: TObject);
- begin
- Edit1.SetFocus;
- end;
- end.