unit logon; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, MovePanel, ADODB, DB, ComCtrls, ToolWin, IniFiles; type TFormLogon = class(TForm) Timer1: TTimer; MovePanel1: TMovePanel; Label1: TLabel; Label2: TLabel; Edit2: TEdit; Label3: TLabel; ToolBar1: TToolBar; BtnOk: TToolButton; BtnQuit: TToolButton; ToolButton12: TToolButton; ToolBar2: TToolBar; ToolButton6: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; ToolButton9: TToolButton; ToolButton10: TToolButton; ToolButton11: TToolButton; ToolButton19: TToolButton; ToolButton20: TToolButton; ToolButton21: TToolButton; ToolButton25: TToolButton; ToolBar3: TToolBar; ToolButton2: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton13: TToolButton; ToolButton14: TToolButton; ToolButton15: TToolButton; ToolButton16: TToolButton; ToolButton17: TToolButton; ToolButton18: TToolButton; ADQ_Tmp: TADOQuery; ToolButton22: TToolButton; ToolButton24: TToolButton; Edit1: TComboBox; ToolButton1: TToolButton; ToolButton23: TToolButton; procedure btnoClick(Sender: TObject); procedure Form(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormShow(Sender: TObject); procedure BtnOkClick(Sender: TObject); procedure FormKeyPress(Sender: TObject; var Key: Char); procedure Timer1Timer(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure BtnQuitClick(Sender: TObject); procedure Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); procedure Edit1Exit(Sender: TObject); procedure ToolButton13Click(Sender: TObject); procedure ToolButton23Click(Sender: TObject); procedure ComboBox1Exit(Sender: TObject); procedure ToolButton12Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormLogon: TFormLogon; IniFile: TIniFile; implementation uses Spmain, JDAESExtend, U_upPassword, U_iniParam; {$R *.dfm} procedure TFormLogon.FormCreate(Sender: TObject); begin Edit1.Text := ''; end; procedure TFormLogon.FormShow(Sender: TObject); var fsj: string; begin try IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'KnitInspFile.INI'); fsj := IniFile.ReadString('生产车间配置', '员工编号', ''); finally IniFile.Free; end; with ADQ_Tmp do begin Close; sql.Clear; SQL.Add(fsj); Open; end; Edit1.Items.Clear; with ADQ_Tmp do begin First; while not Eof do begin Edit1.Items.Add(Trim(fieldbyname('UserId').AsString)); Next; end; end; Edit1.SetFocus; end; procedure TFormLogon.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := CaFree; end; procedure TFormLogon.Form(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = 13 then begin PostMessage(Handle, WM_KEYDOWN, VK_TAB, 0); Key := 0; end; end; procedure TFormLogon.btnoClick(Sender: TObject); begin application.Terminate; end; procedure TFormLogon.BtnOkClick(Sender: TObject); type TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer; Language: integer; WinStyle: integer; GCode: PAnsiChar; GName: PAnsiChar; DataBase: PAnsiChar; Title: PAnsiChar; Parameters1: PAnsiChar; Parameters2: PAnsiChar; Parameters3: PAnsiChar; Parameters4: PAnsiChar; Parameters5: PAnsiChar; Parameters6: PAnsiChar; Parameters7: PAnsiChar; Parameters8: PAnsiChar; Parameters9: PAnsiChar; Parameters10: PAnsiChar; DataBaseStr: PAnsiChar): hwnd; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; newh: hwnd; bm, mm, mz, mm2, mm3: string; conString: string; begin // if (Edit1.Text = '') then // begin // Application.MessageBox('帐号没有录入,请继续录入。', '信息提示', MB_OK or MB_ICONinformation); // Edit1.SetFocus; // exit; // end; with ADQ_Tmp do begin sql.Clear; sql.add('SELECT userid,username,password,pw FROM SY_User WHERE userid=' + '''' + trim(Edit1.Text) + ''''); Open; bm := Fields[0].AsString; mz := Fields[1].AsString; mm := Trim(Fields[2].AsString); mm3 := Fields[3].AsString; if Trim(mm) <> '' then mm2 := Trim(DecryptString(Trim(mm), 'ljb^0122!@#*&^%$', kb128)); { if Trim(mm) <> '' then mm2 := Trim(DecryptString(Trim(mm), 'ljb^0122!@#*&^%$', kb128)) else begin Application.MessageBox('密码不能为空!', '提示', 0); Exit; end; } close; end; if (mm2 = trim(edit2.text)) and (bm <> '') then // if (mm3 = trim(edit2.text)) and (bm <> '') then begin FormMain.StatusBar1.Panels[1].Text := '操作员:' + mz; FormMain.StatusBar1.Panels[2].Text := '绍兴睿特信息技术有限公司'; FormMain.User_Name := trim(mz); FormMain.User_Id := trim(bm); // fuserName:=trim(ADOQueryTmp.fieldbyname('userName').AsString); Th := LoadLibrary('FileUpdate.dll'); if Th > 0 then begin try Tp := GetProcAddress(Th, 'GetDllForm'); if Tp <> nil then begin Tf := TMyFunc(Tp); newh := Tf(Application, 0, 2, 0, 0, PAnsiChar(FormMain.User_Id), PAnsiChar(FormMain.User_Name), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(''), PAnsiChar(FormMain.ConDateBaseString)); end else begin //ShowMessage('打印执行错误'); end; finally //FreeLibrary(Th); end; end else begin ShowMessage('找不到FileUpdate.dll'); end; FormLogon.close; FormMain.Show; end else Application.MessageBox('密码错误!', '信息提示', MB_OK or MB_ICONinformation); {FormLogon.close; FormMain.Show;} end; procedure TFormLogon.FormKeyPress(Sender: TObject; var Key: Char); begin {key:=UpCase(key); if (Key in ['''']) then Key := #0; if FormLogon.Visible then begin if key=#13 then begin key:=#0; FormLogon.perform(WM_NEXTDLGCTL,0,0); end; end;} end; procedure TFormLogon.Timer1Timer(Sender: TObject); begin Edit1.Text := ''; Edit2.Text := ''; end; procedure TFormLogon.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin if FormMain.User_ID = '' then application.Terminate; end; procedure TFormLogon.BtnQuitClick(Sender: TObject); begin application.Terminate; end; procedure TFormLogon.Edit2KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_Return then BtnokClick(Sender); end; procedure TFormLogon.FormActivate(Sender: TObject); begin Edit1.SetFocus; end; procedure TFormLogon.Edit1Exit(Sender: TObject); begin edit1.Text := upperCase(trim(edit1.text)) end; procedure TFormLogon.ToolButton13Click(Sender: TObject); begin Edit2.Text := Trim(Edit2.Text) + Trim(TToolButton(Sender).Caption); Edit2.SelectAll; end; procedure TFormLogon.ToolButton23Click(Sender: TObject); begin if Length(Trim(Edit2.Text)) = 0 then Exit; Edit2.Text := Copy(Trim(Edit2.Text), 1, Length(Trim(Edit2.Text)) - 1); Edit2.SelectAll; end; procedure TFormLogon.ComboBox1Exit(Sender: TObject); begin edit1.Text := upperCase(trim(edit1.text)) end; procedure TFormLogon.ToolButton12Click(Sender: TObject); begin if Trim(Edit1.Text) = '' then begin Application.MessageBox('帐号不能为空!', '提示', 0); Exit; end; try frmupPassword := TfrmupPassword.Create(Application); with frmupPassword do begin fuserID := Trim(Self.Edit1.Text); if ShowModal = 1 then begin end; end; finally frmupPassword.Free; end; end; procedure TFormLogon.ToolButton1Click(Sender: TObject); begin if Length(Trim(Edit2.Text)) = 0 then Exit; Edit2.Text := Copy(Trim(Edit2.Text), 1, Length(Trim(Edit2.Text)) - 1); Edit2.SelectAll; end; end.