D10DJkaimengwenshang/项目代码/wenshangkm/机台检验主程序可配置20201/机台检验主程序可配置2020/logon.pas

348 lines
8.8 KiB
ObjectPascal
Raw Normal View History

2025-09-27 14:24:10 +08:00
unit logon;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, MovePanel,ADODB, DB, ComCtrls,
ToolWin,IniFiles, cxContainer, cxEdit, cxTextEdit, cxGraphics, cxControls,
cxLookAndFeels, cxLabel, cxLookAndFeelPainters;
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;
ADOQueryFiles: TADOQuery;
cxLabel1: TcxLabel;
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
fCanDesign:boolean;
public
{ Public declarations }
end;
var
FormLogon: TFormLogon;
IniFile:TIniFile;
implementation
uses
Spmain,JDAESExtend,U_upPassword,U_iniParam,U_FileAutoUpdate;
{$R *.dfm}
procedure TFormLogon.FormCreate(Sender: TObject);
begin
Edit1.Text := gLastUserName;
end;
procedure TFormLogon.FormShow(Sender: TObject);
var
fsj:string;
begin
try
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'FileKPZ.INI');
fsj := IniFile.ReadString('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', <><D4B1><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD>Χ','');
finally
IniFile.Free;
end;
if Trim(fsj)<>'' then
begin
fsj:=StringReplace(fsj,'delete','',[]);
fsj:=StringReplace(fsj,'update','',[]);
fsj:=StringReplace(fsj,'drop','',[]);
fsj:=StringReplace(fsj,'truncate','',[]);
end;
with ADQ_Tmp do
begin
Close;
sql.Clear;
SQL.Add('select * from SY_user');
sql.Add('where 1=1 and userId<>''admin''');
SQL.Add(fsj);
sql.Add('and valid=''Y''');
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;
application.ProcessMessages;
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: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar;
Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar;
Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar;
Parameters9:PChar;Parameters10:PChar;DataBaseStr:PChar):hwnd;stdcall;
var
Tf: TMyFunc;
Tp: TFarProc;
Th:Thandle;
newh:hwnd;
bm,mm,mz,mm2:string;
begin
if (Edit1.Text='') then
begin
Application.MessageBox('<27>ʺ<EFBFBD>û<EFBFBD><C3BB>¼<EFBFBD><C2BC>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>롣', '<27><>Ϣ<EFBFBD><CFA2>ʾ', MB_OK or MB_ICONinformation);
Edit1.SetFocus;
exit;
end;
with ADQ_Tmp do
begin
sql.Clear;
sql.add('SELECT userid,username,password,canDesign FROM SY_User WHERE userid='+''''+trim(Edit1.Text)+''' and valid=''Y''');
Open;
bm:=Fields[0].AsString;
mz:=Fields[1].AsString;
mm:=Trim(Fields[2].AsString);
fCanDesign:=fieldByName('canDesign').AsBoolean;
if Trim(mm)<>'' then
mm2:=Trim(DecryptString(Trim(mm),keys,kb128)) //'ljb^0122!@#*&^%$'
else
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EBB2BB>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
close;
end;
////////////////////////
try
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'SYSTEMSET.INI');
IniFile.WriteBool('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'design',fCanDesign);
finally
IniFile.Free;
end;
if (mm2=trim(edit2.text)) and (bm<>'') then
begin
FormMain.StatusBar1.Panels[1].Text:='<27><><EFBFBD><EFBFBD>Ա:'+mz;
FormMain.StatusBar1.Panels[2].Text:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޹<EFBFBD>˾';
User_Name:=trim(mz);
User_Id:=trim(bm);
gLastUserName:=User_Id ;
// ExportFtErpFile('FileUpdate.dll',ADQ_Tmp);
with ADOQueryFiles do
begin
close;
sql.Clear;
sql.Add('select * from SY_UpdateExeFile');
SQL.Add('where exeName=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>''');
SQL.Add('and valid=1');
Open;
first;
cxLabel1.Visible:=true;
cxLabel1.Refresh;
while not eof do
begin
ExportFtErpFile(Trim(FieldByName('fileName').AsString),ADQ_Tmp);
if lowercase(Trim(FieldByName('fileName').AsString))=lowercase(gDllName1) then
FormMain.threadLoadDll(gDllName1);
// FormMain.Panel1.OnClick(FormMain.Panel1);
application.ProcessMessages;
next;
end;
close;
end;
cxLabel1.Visible:=false;
FormLogon.close;
FormMain.Show;
end
else
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>Ϣ<EFBFBD><CFA2>ʾ', 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 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
if trim(Edit1.Text)='' then
Edit1.SetFocus
else
Edit2.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('<27>ʺŲ<CABA><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',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.