?? unit1.pas
字號(hào):
function tform1.xq_mima():string;
var
aboutf:tmimasl; //公用密碼輸入
begin
aboutf:=tmimasl.Create(self);
aboutf.ShowModal;
Result :=mimasla1;
end;
function tform1.FindComputer(ComputerName: string):Boolean;
//在局域網(wǎng)上以計(jì)算機(jī)名查找是否存在 TRUE 在 FALSE 不在
var
WSAData: TWSAData;
HostEnt: PHostEnt;
begin
WSAStartup(2, WSAData);
HostEnt := gethostbyname(PChar(ComputerName));
if HostEnt = nil then Result := False
else Result :=True;
WSACleanup;
end;
procedure tform1.hydl(kjIP,zh,xm,zjh:string;yj,bz:real);
//參數(shù):KJDL 客戶機(jī)IP ZH 帳號(hào) XM 姓名 ZJH 證件號(hào)
// yj 押金 bz 計(jì)費(fèi)準(zhǔn)
label jlsk; //標(biāo)簽
var
jlsk1:string;
jlsk2:integer;
//在表控件table1中查找記錄
begin
jlsk2:=234123;
form1.Table1.First;
while not (form1.Table1.Eof) do
begin
if form1.Table1ip.Value=kjip then goto jlsk;
form1.Table1.Next;
end;
jlsk2:=0;
jlsk: //標(biāo)簽
if jlsk2<>0 then
//找到
begin
form1.table1.edit;
form1.table1a5.Value:=zh;
form1.table1a3.Value:=DATe;
form1.table1a4.Value:=now;
form1.table1a12.Value:=xm;
form1.table1a13.Value:=zjh;
form1.table1a7.Value:=yj;
form1.table1a6.Value:=bz;
form1.table1a15.Value:='√';
jlsk1:=form1.Table1a1.Value;
form1.table1.post;
table1.Refresh;
form1.jlsx(0);
end;
end;
procedure Tform1.lv1_create_date;
//列表視圖lv1與數(shù)據(jù)庫(kù)建立關(guān)聯(lián)
var
item:tlistitem;
gb2,gb3:string; //用于改變時(shí)間顯示去掉秒
begin
lv1.Clear;
tb1.First;
while not tb1.Eof do
begin
if tb1a11.Value<3 then zdxs1:=1 else zdxs1:=0;
item:=lv1.Items.Add;
item.Caption:=tb1a2.Value; //電腦項(xiàng)
item.SubItems.Add(inttostr(tb1a18.Value));
item.SubItems.Add(tb1a1.Value); //狀態(tài)
//上機(jī)時(shí)間項(xiàng)
if tb1a4.Value<>strtotime('0:0:0') then item.SubItems.Add(timetostr(tb1a4.Value)) else item.SubItems.Add('');
item.SubItems.Add(tb1a6.Value); //卡號(hào)項(xiàng)
if tb1a8.Value<>0 then item.SubItems.Add(tb1a8.AsString) //押金項(xiàng)
else item.SubItems.Add('');
//計(jì)費(fèi)標(biāo)準(zhǔn)項(xiàng)
gb2:=tb1a6.Value;
delete(gb2,3,12);
if gb2='L-' then if tb1a7.Value<>0 then item.SubItems.Add('臨時(shí)上機(jī)') else item.SubItems.Add('')
else if tb1a7.Value<>0 then item.SubItems.Add('會(huì)員上機(jī)') else item.SubItems.Add('');
gb2:=tb1a15.Value;
if gb2='T' then item.SubItems[5]:='托管上機(jī)'; // 有全脫標(biāo)志
//已用時(shí)項(xiàng)
gb2:=floattostr(trunc(tb1a9.Value/60))+':'+floattostr(tb1a9.AsInteger mod 60);
if gb2<>'0:0' then item.SubItems.Add(gb2) else item.SubItems.Add('');
// 費(fèi)用項(xiàng)
if tb1a10.Value<>0 then item.SubItems.Add(tb1a10.AsString) else item.SubItems.Add('');
// 應(yīng)退項(xiàng)
if tb1a11.Value<>0 then item.SubItems.Add(tb1a11.AsString) else item.SubItems.Add('');
//剩余時(shí)間項(xiàng)
gb3:=floattostr(trunc(tb1a12.Value/60))+':'+floattostr(tb1a12.AsInteger mod 60);
if gb3<>'0:0' then item.SubItems.Add(gb3) else item.SubItems.Add('');
item.SubItems.Add(tb1a13.Value);
item.SubItems.Add(tb1a14.Value);
item.SubItems.Add(tb1IP.Value);
item.SubItems.Add(tb1a15.Value);
item.SubItems.Add(tb1a16.Value);
tb1.Next;
end;
end;
procedure TForm1.FXX(xxly:string;IP:string); //發(fā)控制碼
//參數(shù):XXLY 消息內(nèi)容 最多250個(gè)字符 IP 客戶機(jī)的IP地址
var
ReqCode:array[0..250] of char;
ReqCodeStr:string;
begin
if IP<>'' then
begin
ReqCodeStr:=xxly;
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
CUDP.RemoteHost:=IP;
CUDP.SendBuffer(ReqCode,250);
end;
end;
procedure tform1.jlsx(cs:integer);
//刷新數(shù)據(jù)庫(kù) cs: 是否測(cè)試開機(jī) 0 不測(cè) 1 測(cè)
begin
with table1 do
begin
disablecontrols;
table1.First;
while not eof do
begin //循環(huán)
if (table1a6.Value>0) and (table1ip.Value<>'') then //對(duì)一條記錄處理 有計(jì)費(fèi)標(biāo)準(zhǔn)說(shuō)明在計(jì)費(fèi)
//if-1 開始
begin //-----11
table1.Edit;
//datetimetofiledate(a:datetime) 把日期和時(shí)間換成數(shù)字
table1a8.Value:=round((now-table1a4.Value)*60*24); //已用時(shí)
table1a9.Value:=round((table1a8.AsFloat*(table1a6.Value/60))*10)/10;//費(fèi)用
table1a11.Value:=(table1a7.AsFloat/table1a6.Value)*60-table1a8.AsFloat;
//剩余時(shí)間
table1a10.Value:=table1a7.Value-table1a9.Value;
//應(yīng)退款
fxx('sfnw1'+NMDayTime1.LocalIP,table1ip.Value); //查是否聯(lián)網(wǎng)
table1a0.Value:='×';
table1.Post;
//已到時(shí)間鎖定機(jī)器 如押金=0則不執(zhí)行
if (table1a7.Value<>0) and (table1a10.Value<=0) then lkjz(table1ip.Value)
// 快到時(shí)間提醒 如押金=0則不執(zhí)行 上行執(zhí)行則下行不執(zhí)行
// 以免鎖定了還在提醒
else
if (table1a7.Value<>0) and (table1a11.Value<=3) then fxx('ccompu'+floattostr(table1a11.AsInteger),table1ip.Value);
end //-------11
else
begin
fxx('sfnw2'+NMDayTime1.LocalIP,table1ip.Value); //查是否聯(lián)網(wǎng)
table1.Edit;
table1a0.Value:='×'; // 沒有計(jì)費(fèi)則標(biāo)志設(shè)為鎖定
end; //對(duì)一條記錄處理
//if-1 完
//// 以計(jì)算機(jī)名查找此機(jī)是否脫網(wǎng) 是則狀態(tài)設(shè)為 "?"
table1.Edit;
if cs=1 then if findcomputer(table1a1.Text) then table1a0.Value:='?';
//下一記錄
table1.Next;
enablecontrols;
end; //循環(huán)完
table1.First;
//刷新listvice (lv1)
tb1.Close;
tb1.Prepared;
tb1.Open;
lv1_create_date;
end; //刷新數(shù)據(jù)庫(kù)
end; //刷新函數(shù)完
procedure TForm1.lv2sx(dl,jr,fs:string);
//加錢記錄顯示 di 電腦名 jr 加錢金額 fs 方式(即上機(jī):加錢)
var
itema1:tlistitem;
begin
itema1:=lv2.Items.Add;
itema1.Caption:=dl;
itema1.SubItems.Add(timetostr(now));
itema1.SubItems.Add(jr);
itema1.SubItems.add(fs);
end;
//會(huì)員結(jié)帳
procedure TForm1.hyjz(kjip:string);
label bh1; //標(biāo)簽
var
str1,str2,str3:string;
itemlv4:tlistitem;
begin
timer2.Enabled:=false; // 關(guān)閉timer2 時(shí)鐘 因?yàn)樗谡{(diào)用tb1
str1:=tb1.SQL.Text; //保存上次SQL的操作
str2:='select * from temp where IP="'+kjip+'"';
tb1.Close;
tb1.SQL.Clear;
tb1.SQL.Add(str2);
tb1.Prepared;
tb1.Open;
if tb1.RecordCount=0 then goto bh1; // 沒有查到該IP 出錯(cuò)退出
if tb1a6.Value='' then goto bh1; //沒有上機(jī)
tb1.First;
str3:=tb1a6.Value;
delete(str3,3,12);
if str3='L-' then
begin fxx('xx'+'你不是會(huì)員,下機(jī)找網(wǎng)管。',kjip);
goto bh1;
end;
fxx('hdesk',kjip); // 鎖定客機(jī)
//在結(jié)帳記錄上顯示
itemlv4:=lv4.Items.Add;
itemlv4.Caption:=tb1a2.Value; //電腦
str3:=timetostr(tb1a4.Value); //上機(jī)時(shí)間
itemlv4.SubItems.Add(str3);
str3:=timetostr(now); //下機(jī)時(shí)間
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a8.Value); //押金
itemlv4.SubItems.Add(str3);
str3:=timetostr(tb1a9.Value); //用時(shí)
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a10.Value); //費(fèi)用
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a11.Value); //應(yīng)退
itemlv4.SubItems.Add(str3);
str3:=tb1a6.Value; //卡號(hào)
itemlv4.SubItems.Add(str3);
// 顯示完
//添加到歷史記錄中
table2.Active:=true; //打開歷史庫(kù)
table2.Insert;
table2a1.Value:=tb1a2.Value; //電腦
table2a2.Value:=date;
table2a3.Value:=tb1a4.Value; //上機(jī)時(shí)間
table2a4.Value:=now; //下機(jī)時(shí)間
table2a6.Value:=tb1a8.Value; //押金
table2a7.Value:=tb1a9.Value; //用時(shí)
table2a8.Value:=tb1a10.Value; //費(fèi)用
table2a9.Value:=0; //應(yīng)退
table2a5.Value:=tb1a6.Value; //卡號(hào)
table2a10.Value:=tb1a13.Value; //姓名
table2a11.Value:=tb1a14.Value; //證件
table2.Post;
table2.Active:=false; //操作完關(guān)庫(kù)
//添加歷史庫(kù)完
//已用費(fèi)用沖會(huì)員押金
table3.Active:=true;
table3.Filtered:=false;
table3.Filter:='帳號(hào)='+''''+tb1a6.Value+'''';
table3.Filtered:=true;
if table3.RecordCount<>0 then
begin //過(guò)慮出錯(cuò) 沒找到記錄
table3.First;
table3.Edit;
table3a5.Value:=table3a5.Value-tb1a10.Value;
table3.Post;
end;
table3.Filtered:=false;
table3.Active:=false;
//------
//清空l(shuí)v1顯示
str2:='update temp set 備注="",剩余時(shí)間=0,已用時(shí)=0, 上機(jī)時(shí)間="0:0:0",押金=0,狀態(tài)="×",卡號(hào)="",計(jì)費(fèi)標(biāo)準(zhǔn)=0,費(fèi)用=0, 應(yīng)退=0,姓名="",證件號(hào)碼="",標(biāo)志="×" where ip="'+kjip+'"';
tb1.Close;
tb1.SQL.Clear;
tb1.SQL.Add(str2);
tb1.Prepared;
tb1.ExecSQL;
bh1:
//刷新listvice(lv1)
tb1.SQL.Clear; //lv1還原上次狀態(tài)
tb1.SQL.Add(str1);
tb1.Prepared;
tb1.Open;
lv1_create_date;
timer2.Enabled:=false; // 開時(shí)鐘
end;
//臨卡和會(huì)員結(jié)帳函數(shù)
procedure TForm1.lkjz(kjip:string);
label bh1; //標(biāo)簽
var
str1,str2,str3:string;
itemlv4:tlistitem;
begin
timer2.Enabled:=false; // 關(guān)閉timer2 時(shí)鐘 因?yàn)樗谡{(diào)用tb1
str1:=tb1.SQL.Text; //保存上次SQL的操作
str2:='select * from temp where IP="'+kjip+'"';
tb1.Close;
tb1.SQL.Clear;
tb1.SQL.Add(str2);
tb1.Prepared;
tb1.Open;
if tb1.RecordCount=0 then goto bh1; // 沒有查到該IP 出錯(cuò)退出
if tb1a6.Value='' then goto bh1; //沒有上機(jī)
tb1.First;
str3:=tb1a6.Value;
delete(str3,3,12);
//是會(huì)員調(diào)會(huì)員結(jié)帳函數(shù)
if str3<>'L-' then begin hyjz(kjip); goto bh1 end;
fxx('hdesk',kjip); // 鎖定客機(jī)
//在結(jié)帳記錄上顯示
itemlv4:=lv4.Items.Add;
itemlv4.Caption:=tb1a2.Value; //電腦
str3:=timetostr(tb1a4.Value); //上機(jī)時(shí)間
itemlv4.SubItems.Add(str3);
str3:=timetostr(now); //下機(jī)時(shí)間
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a8.Value); //押金
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a9.Value); //用時(shí)
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a10.Value); //費(fèi)用
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a11.Value); //應(yīng)退
itemlv4.SubItems.Add(str3);
str3:=tb1a6.Value; //卡號(hào)
itemlv4.SubItems.Add(str3);
// 顯示完
//添加到歷史記錄中
table2.Active:=true; //打開歷史庫(kù)
table2.Insert;
table2a1.Value:=tb1a2.Value; //電腦
table2a2.Value:=date;
table2a3.Value:=tb1a4.Value; //上機(jī)時(shí)間
table2a4.Value:=now; //下機(jī)時(shí)間
table2a6.Value:=tb1a8.Value; //押金
table2a7.Value:=tb1a9.Value; //用時(shí)
table2a8.Value:=tb1a10.Value; //費(fèi)用
table2a9.Value:=tb1a11.Value; //應(yīng)退
table2a5.Value:=tb1a6.Value; //卡號(hào)
table2a10.Value:=tb1a13.Value; //姓名
table2a11.Value:=tb1a14.Value; //證件
table2.Post;
table2.Active:=false; //操作完關(guān)庫(kù)
//添加歷史庫(kù)完
//清空l(shuí)v1顯示
str2:='update temp set 備注="",剩余時(shí)間=0,已用時(shí)=0, 上機(jī)時(shí)間="0:0:0",押金=0,狀態(tài)="×",卡號(hào)="",計(jì)費(fèi)標(biāo)準(zhǔn)=0,費(fèi)用=0, 應(yīng)退=0,姓名="",證件號(hào)碼="",標(biāo)志="×" where ip="'+kjip+'"';
tb1.Close;
tb1.SQL.Clear;
tb1.SQL.Add(str2);
tb1.Prepared;
tb1.ExecSQL;
bh1:
//刷新listvice(lv1)
tb1.SQL.Clear; //lv1還原上次狀態(tài)
tb1.SQL.Add(str1);
tb1.Prepared;
tb1.Open;
lv1_create_date;
timer2.Enabled:=false; // 開時(shí)鐘
end;
procedure TForm1.wmicb(var msg:TMessage);
//圖標(biāo)與菜單聯(lián)系
var tcwz:TPoint;
begin
case msg.LParam of
wm_lbuttonup: //左鍵
begin
getcursorpos(tcwz);
tccd.Popup(tcwz.x,tcwz.y);
end;
wm_rbuttonup: //右鍵
begin
getcursorpos(tcwz);
tccd.Popup(tcwz.x,tcwz.y);
end;
end;
end;
procedure TForm1.ycck;
begin //隱藏窗口
form1.visible:=false;
application.ShowMainForm:=form1.visible;
setforegroundwindow(application.handle);
end;
procedure TForm1.WMSysCommand(var Msg: TWMSysCommand);
begin
//截獲系統(tǒng)窗體消息函數(shù)
if (Msg.CmdType = SC_close)or (Msg.CmdType = SC_MINIMIZE) then
//窗口右上角按鈕
//SC_MINIMIZE 最小化 SC_CLOSE 關(guān)閉 SC_MAXIMIZE 最大化
//SC_size 大小 SC_MOVE 移動(dòng) SC_restore 恢復(fù)
ycck //調(diào)用隱藏
else
Inherited;//調(diào)用原處理函數(shù)
end;
//自定義子程序區(qū)完
procedure TForm1.FormCreate(Sender: TObject);
var
Year, Month, Day: Word;
devmode:tDevicemode;
Reg_id: TDateTime;
Reg_ic:integer;
reg:TRegistry;
mypath:string;
RegisterTemp: TRegistry;
InputStr, Get_id: string;
Reg_tag, ClickDok: Boolean;
Allow: Integer;
A1,A2,A3: Integer;
B1,B2,B3: Integer;
Temp:pchar;
Name:string;
pass:integer;
c:char;
I,Long:integer;
hLib : HMODULE;
GetHardDiskId : function (lpOutBuffer:PChar; lpRegisterCode:PChar): Boolean; stdcall;
DiskID: array [0..31] of char;
begin
RsltStream:=TMemoryStream.Create;
TmpStream:=TMemoryStream.Create;
//動(dòng)態(tài)設(shè)置當(dāng)前路徑為數(shù)據(jù)庫(kù)目錄
adocon1.Connected:=false;
adocon1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=xzxq;Data Source='+extractfiledir(application.ExeName)+'\jfsj.mdb;Persist Security Info=False';
adocon1.Connected:=true;
tb1.Active:=true;
table1.Active:=true;
table4.Active:=true;
//用數(shù)據(jù)庫(kù)刷新listvice控件
lv1_create_date;
lv1.Height:=form1.Height-140; //控制lv1高度
FillChar(DiskID, SizeOf(DiskID), #0);
hLib := LoadLibrary('reg.dll');
if hLib <> 0 then
begin
@GetHardDiskId := GetProcAddress(hLib, 'GetHardDiskId');
if @GetHardDiskId <> nil then
begin
if GetHardDiskId(DiskID, '周萬(wàn)能-E134DED951C388698415A4750D12C3D7C22FD4A126B21DA4') then
label2.caption := DiskID;
Name:=label2.Caption+GetMAC(0);
label3.Caption:=label2.Caption+GetMAC(0);
long:=length(Name);
for I:=1 to Long do
begin
temp:=pchar(copy(Name,I,2));
c:=temp^;
Pass:=pass+ord(c);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -