入库程序部分代码
procedure TForm1.lst1DrawItem(Control: TWinControl; Index: Integer; //对TListBox 添加的内容判断 并分别在前面加上图标;
Rect: TRect; State: TOwnerDrawState);
begin
if Copy(lst1.Items.Strings[index],1,4)='PASS' then
begin
ImageList1.Draw(lst1.Canvas,Rect.Left+7,Rect.Top,1,True);
lst1.Canvas.TextOut(Rect.Left+7+22,Rect.Top,Copy(lst1.Items.Strings[index],5,Length(lst1.Items.Strings[index])-4));
end
else
begin
ImageList1.Draw(lst1.Canvas,Rect.Left+7,Rect.Top,0,True);
lst1.Canvas.Font.Color:=clRed;
lst1.Canvas.TextOut(Rect.Left+7+22,Rect.Top,lst1.Items.Strings[index]);
end;
end;
procedure TForm1.FormShow(Sender: TObject);
var
n: string;
begin
FGridWndProc := DBGrid1.WindowProc;
DBGrid1.WindowProc := GridWndProc;
n := Form1.Caption;
if copy(application.ExeName, length(getcurrentdir) + 2, length(application.exename) - length(getcurrentdir) - 5) <> n then
begin
showmessage('请将程序命名为:' + n + #13 + '然后重新打开程序!');
application.Terminate;
end;
{if not Check_Version(Database1, n, 'POWER', '', true) then
Application.Terminate;
Password.Caption := n + GetProgramVersion;
form1.Caption := n + '- -' + GetProgramVersion;
try
if not (Database1.Connected) then
Database1.Connected := true;
except
ShowMessage('Disconnect to database,call ITS');
Close;
end; }
password.ShowModal; //打开密码框
end;
//--------密码框单元
unit formpassword; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, DBTables; type TPassword = class(TForm) Editempno: TEdit; Label1: TLabel; Label2: TLabel; Editpassword: TEdit; procedure EditempnoKeyPress(Sender: TObject; var Key: Char); procedure EditpasswordKeyPress(Sender: TObject; var Key: Char); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Password: TPassword; flag: integer; implementation uses Soft; {$R *.dfm} procedure TPassword.EditempnoKeyPress(Sender: TObject; var Key: Char); begin if (editempno.Text <> '') and (key = #13) then begin editpassword.SetFocus; editpassword.SelectAll; end; end; procedure TPassword.EditpasswordKeyPress(Sender: TObject; var Key: Char); var Qryemp: TQuery; begin if (key = #13) and (editpassword.Text <> '') then begin {Qryemp := TQuery.Create(nil); Qryemp.DatabaseName := Soft.Form1.Database1.DatabaseName; Qryemp.Close; Qryemp.SQL.Clear; Qryemp.SQL.Add('select * from sfis1.c_emp_desc_t where emp_no=:empno and emp_bc=:empbc'); Qryemp.ParamByName('empno').AsString := editempno.Text; Qryemp.ParamByName('empbc').AsString := editpassword.Text; Qryemp.Open; if Qryemp.RecordCount <> 0 then begin Qryemp.Close; Qryemp.SQL.Clear; Qryemp.SQL.Add('select * from sfis1.c_privilege where prg_name=''SFIS_Soft'' ' + ' and fun=''SFIS_Soft_INUP'' and emp=:empno '); Qryemp.ParamByName('empno').AsString := editempno.Text; Qryemp.Open; if Qryemp.RecordCount <> 0 then begin Soft.emp_no := editempno.Text; formpassword.Password.Close; flag := 1; end else begin showmessage('眀腹⊿舦'); Editempno.Text := ''; Editpassword.Text := ''; Editempno.SetFocus; exit; end; Form1.lbl_EmpName.Caption:='User:'+Qryemp.FieldByName('EMP_NAME').AsString+' '; Soft.emp_no := editempno.Text; //steven formpassword.Password.Close; // flag := 1; // end else showmessage('No EMP'); } if (editpassword.Text='123')and(editempno.Text='123') then begin Form1.lbl_EmpName.Caption:='My Love '; formpassword.Password.Close; // flag := 1; end else showmessage('No EMP'); Editempno.Text := ''; Editpassword.Text := ''; Editempno.SetFocus; Exit; end; end; procedure TPassword.FormClose(Sender: TObject; var Action: TCloseAction); begin if flag = 0 then Soft.Form1.Close; end; procedure TPassword.FormShow(Sender: TObject); begin flag := 0; Editempno.SetFocus; end; end.
1 object Password: TPassword 2 Left = 386 3 Top = 325 4 Width = 362 5 Height = 178 6 Caption = 'Password' 7 Color = 14465464 8 Font.Charset = DEFAULT_CHARSET 9 Font.Color = clWindowText 10 Font.Height = -11 11 Font.Name = 'MS Sans Serif' 12 Font.Style = [] 13 OldCreateOrder = False 14 OnClose = FormClose 15 OnShow = FormShow 16 PixelsPerInch = 96 17 TextHeight = 13 18 object Label1: TLabel 19 Left = 32 20 Top = 24 21 Width = 90 22 Height = 26 23 Caption = 'EMP_NO:' 24 Font.Charset = ANSI_CHARSET 25 Font.Color = clWindowText 26 Font.Height = -19 27 Font.Name = 'Palatino Linotype' 28 Font.Style = [fsBold] 29 ParentFont = False 30 end 31 object Label2: TLabel 32 Left = 32 33 Top = 80 34 Width = 89 35 Height = 26 36 Caption = 'Password:' 37 Font.Charset = ANSI_CHARSET 38 Font.Color = clWindowText 39 Font.Height = -19 40 Font.Name = 'Palatino Linotype' 41 Font.Style = [fsBold, fsUnderline] 42 ParentFont = False 43 end 44 object Editempno: TEdit 45 Left = 144 46 Top = 24 47 Width = 129 48 Height = 24 49 Font.Charset = DEFAULT_CHARSET 50 Font.Color = clWindowText 51 Font.Height = -13 52 Font.Name = 'MS Sans Serif' 53 Font.Style = [] 54 ImeName = '中文 (简体) - 搜狗拼音输入法' 55 ParentFont = False 56 TabOrder = 0 57 OnKeyPress = EditempnoKeyPress 58 end 59 object Editpassword: TEdit 60 Left = 144 61 Top = 80 62 Width = 129 63 Height = 24 64 Font.Charset = DEFAULT_CHARSET 65 Font.Color = clWindowText 66 Font.Height = -13 67 Font.Name = 'MS Sans Serif' 68 Font.Style = [] 69 ImeName = '中文 (简体) - 搜狗拼音输入法' 70 ParentFont = False 71 PasswordChar = '*' 72 TabOrder = 1 73 OnKeyPress = EditpasswordKeyPress 74 end 75 end