📄 unit1.~pas
字号:
function tform1.xq_mima():string;
var
aboutf:tmimasl; //公用密码输入
begin
aboutf:=tmimasl.Create(self);
aboutf.ShowModal;
Result :=mimasla1;
end;
function tform1.FindComputer(ComputerName: string):Boolean;
//在局域网上以计算机名查找是否存在 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);
//参数:KJDL 客户机IP ZH 帐号 XM 姓名 ZJH 证件号
// yj 押金 bz 计费准
label jlsk; //标签
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: //标签
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与数据库建立关联
var
item:tlistitem;
gb2,gb3:string; //用于改变时间显示去掉秒
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; //电脑项
item.SubItems.Add(inttostr(tb1a18.Value));
item.SubItems.Add(tb1a1.Value); //状态
//上机时间项
if tb1a4.Value<>strtotime('0:0:0') then item.SubItems.Add(timetostr(tb1a4.Value)) else item.SubItems.Add('');
item.SubItems.Add(tb1a6.Value); //卡号项
if tb1a8.Value<>0 then item.SubItems.Add(tb1a8.AsString) //押金项
else item.SubItems.Add('');
//计费标准项
gb2:=tb1a6.Value;
delete(gb2,3,12);
if gb2='L-' then if tb1a7.Value<>0 then item.SubItems.Add('临时上机') else item.SubItems.Add('')
else if tb1a7.Value<>0 then item.SubItems.Add('会员上机') else item.SubItems.Add('');
gb2:=tb1a15.Value;
if gb2='T' then item.SubItems[5]:='托管上机'; // 有全脱标志
//已用时项
gb2:=floattostr(trunc(tb1a9.Value/60))+':'+floattostr(tb1a9.AsInteger mod 60);
if gb2<>'0:0' then item.SubItems.Add(gb2) else item.SubItems.Add('');
// 费用项
if tb1a10.Value<>0 then item.SubItems.Add(tb1a10.AsString) else item.SubItems.Add('');
// 应退项
if tb1a11.Value<>0 then item.SubItems.Add(tb1a11.AsString) else item.SubItems.Add('');
//剩余时间项
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); //发控制码
//参数:XXLY 消息内容 最多250个字符 IP 客户机的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);
//刷新数据库 cs: 是否测试开机 0 不测 1 测
begin
with table1 do
begin
disablecontrols;
table1.First;
while not eof do
begin //循环
if (table1a6.Value>0) and (table1ip.Value<>'') then //对一条记录处理 有计费标准说明在计费
//if-1 开始
begin //-----11
table1.Edit;
//datetimetofiledate(a:datetime) 把日期和时间换成数字
table1a8.Value:=round((now-table1a4.Value)*60*24); //已用时
table1a9.Value:=round((table1a8.AsFloat*(table1a6.Value/60))*10)/10;//费用
table1a11.Value:=(table1a7.AsFloat/table1a6.Value)*60-table1a8.AsFloat;
//剩余时间
table1a10.Value:=table1a7.Value-table1a9.Value;
//应退款
fxx('sfnw1'+NMDayTime1.LocalIP,table1ip.Value); //查是否联网
table1a0.Value:='×';
table1.Post;
//已到时间锁定机器 如押金=0则不执行
if (table1a7.Value<>0) and (table1a10.Value<=0) then lkjz(table1ip.Value)
// 快到时间提醒 如押金=0则不执行 上行执行则下行不执行
// 以免锁定了还在提醒
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); //查是否联网
table1.Edit;
table1a0.Value:='×'; // 没有计费则标志设为锁定
end; //对一条记录处理
//if-1 完
//// 以计算机名查找此机是否脱网 是则状态设为 "?"
table1.Edit;
if cs=1 then if findcomputer(table1a1.Text) then table1a0.Value:='?';
//下一记录
table1.Next;
enablecontrols;
end; //循环完
table1.First;
//刷新listvice (lv1)
tb1.Close;
tb1.Prepared;
tb1.Open;
lv1_create_date;
end; //刷新数据库
end; //刷新函数完
procedure TForm1.lv2sx(dl,jr,fs:string);
//加钱记录显示 di 电脑名 jr 加钱金额 fs 方式(即上机:加钱)
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;
//会员结帐
procedure TForm1.hyjz(kjip:string);
label bh1; //标签
var
str1,str2,str3:string;
itemlv4:tlistitem;
begin
timer2.Enabled:=false; // 关闭timer2 时钟 因为它在调用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 出错退出
if tb1a6.Value='' then goto bh1; //没有上机
tb1.First;
str3:=tb1a6.Value;
delete(str3,3,12);
if str3='L-' then
begin fxx('xx'+'你不是会员,下机找网管。',kjip);
goto bh1;
end;
fxx('hdesk',kjip); // 锁定客机
//在结帐记录上显示
itemlv4:=lv4.Items.Add;
itemlv4.Caption:=tb1a2.Value; //电脑
str3:=timetostr(tb1a4.Value); //上机时间
itemlv4.SubItems.Add(str3);
str3:=timetostr(now); //下机时间
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a8.Value); //押金
itemlv4.SubItems.Add(str3);
str3:=timetostr(tb1a9.Value); //用时
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a10.Value); //费用
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a11.Value); //应退
itemlv4.SubItems.Add(str3);
str3:=tb1a6.Value; //卡号
itemlv4.SubItems.Add(str3);
// 显示完
//添加到历史记录中
table2.Active:=true; //打开历史库
table2.Insert;
table2a1.Value:=tb1a2.Value; //电脑
table2a2.Value:=date;
table2a3.Value:=tb1a4.Value; //上机时间
table2a4.Value:=now; //下机时间
table2a6.Value:=tb1a8.Value; //押金
table2a7.Value:=tb1a9.Value; //用时
table2a8.Value:=tb1a10.Value; //费用
table2a9.Value:=0; //应退
table2a5.Value:=tb1a6.Value; //卡号
table2a10.Value:=tb1a13.Value; //姓名
table2a11.Value:=tb1a14.Value; //证件
table2.Post;
table2.Active:=false; //操作完关库
//添加历史库完
//已用费用冲会员押金
table3.Active:=true;
table3.Filtered:=false;
table3.Filter:='帐号='+''''+tb1a6.Value+'''';
table3.Filtered:=true;
if table3.RecordCount<>0 then
begin //过虑出错 没找到记录
table3.First;
table3.Edit;
table3a5.Value:=table3a5.Value-tb1a10.Value;
table3.Post;
end;
table3.Filtered:=false;
table3.Active:=false;
//------
//清空lv1显示
str2:='update temp set 备注="",剩余时间=0,已用时=0, 上机时间="0:0:0",押金=0,状态="×",卡号="",计费标准=0,费用=0, 应退=0,姓名="",证件号码="",标志="×" where ip="'+kjip+'"';
tb1.Close;
tb1.SQL.Clear;
tb1.SQL.Add(str2);
tb1.Prepared;
tb1.ExecSQL;
bh1:
//刷新listvice(lv1)
tb1.SQL.Clear; //lv1还原上次状态
tb1.SQL.Add(str1);
tb1.Prepared;
tb1.Open;
lv1_create_date;
timer2.Enabled:=false; // 开时钟
end;
//临卡和会员结帐函数
procedure TForm1.lkjz(kjip:string);
label bh1; //标签
var
str1,str2,str3:string;
itemlv4:tlistitem;
begin
timer2.Enabled:=false; // 关闭timer2 时钟 因为它在调用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 出错退出
if tb1a6.Value='' then goto bh1; //没有上机
tb1.First;
str3:=tb1a6.Value;
delete(str3,3,12);
//是会员调会员结帐函数
if str3<>'L-' then begin hyjz(kjip); goto bh1 end;
fxx('hdesk',kjip); // 锁定客机
//在结帐记录上显示
itemlv4:=lv4.Items.Add;
itemlv4.Caption:=tb1a2.Value; //电脑
str3:=timetostr(tb1a4.Value); //上机时间
itemlv4.SubItems.Add(str3);
str3:=timetostr(now); //下机时间
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a8.Value); //押金
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a9.Value); //用时
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a10.Value); //费用
itemlv4.SubItems.Add(str3);
str3:=floattostr(tb1a11.Value); //应退
itemlv4.SubItems.Add(str3);
str3:=tb1a6.Value; //卡号
itemlv4.SubItems.Add(str3);
// 显示完
//添加到历史记录中
table2.Active:=true; //打开历史库
table2.Insert;
table2a1.Value:=tb1a2.Value; //电脑
table2a2.Value:=date;
table2a3.Value:=tb1a4.Value; //上机时间
table2a4.Value:=now; //下机时间
table2a6.Value:=tb1a8.Value; //押金
table2a7.Value:=tb1a9.Value; //用时
table2a8.Value:=tb1a10.Value; //费用
table2a9.Value:=tb1a11.Value; //应退
table2a5.Value:=tb1a6.Value; //卡号
table2a10.Value:=tb1a13.Value; //姓名
table2a11.Value:=tb1a14.Value; //证件
table2.Post;
table2.Active:=false; //操作完关库
//添加历史库完
//清空lv1显示
str2:='update temp set 备注="",剩余时间=0,已用时=0, 上机时间="0:0:0",押金=0,状态="×",卡号="",计费标准=0,费用=0, 应退=0,姓名="",证件号码="",标志="×" where ip="'+kjip+'"';
tb1.Close;
tb1.SQL.Clear;
tb1.SQL.Add(str2);
tb1.Prepared;
tb1.ExecSQL;
bh1:
//刷新listvice(lv1)
tb1.SQL.Clear; //lv1还原上次状态
tb1.SQL.Add(str1);
tb1.Prepared;
tb1.Open;
lv1_create_date;
timer2.Enabled:=false; // 开时钟
end;
procedure TForm1.wmicb(var msg:TMessage);
//图标与菜单联系
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
//截获系统窗体消息函数
if (Msg.CmdType = SC_close)or (Msg.CmdType = SC_MINIMIZE) then
//窗口右上角按钮
//SC_MINIMIZE 最小化 SC_CLOSE 关闭 SC_MAXIMIZE 最大化
//SC_size 大小 SC_MOVE 移动 SC_restore 恢复
ycck //调用隐藏
else
Inherited;//调用原处理函数
end;
//自定义子程序区完
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;
//动态设置当前路径为数据库目录
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;
//用数据库刷新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, '周万能-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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -