⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 有关密码为: 服务端:为 “1”。 客户端:为机器的月份+日期。 如“2005/08/05”
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        //已用费用冲会员押金
    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);
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高度

   //以下是建立任务栏图标
 myicon.cbSize:=sizeof(TNotifyicondata);
 myicon.Wnd:=handle;
 myicon.uID:=1;
 myicon.uFlags:=nif_message or nif_tip or nif_icon;
 myicon.uCallbackMessage:=wm_icb;
 myicon.hIcon:=application.Icon.Handle;
 myicon.szTip:='超前电脑计费服务端 V1.0';
 shell_notifyicon(nim_add,@myicon);
   //以上是建立任务栏图标

  //运行就隐藏窗口
  application.CreateHandle;
  showwindow(application.Handle,SW_HIDE);
  application.ShowMainForm:=false;


end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
BmpStream.Free;
RsltStream.Free;
TmpStream.Free;
shell_notifyicon(nim_delete,@myicon);
end;

procedure TForm1.N4Click(Sender: TObject);
begin
close;  //退出
end;

procedure TForm1.N9Click(Sender: TObject);
 var
 supi1,supi2:string;
begin
        if lv1.SelCount=0 then exit; //没有焦点退出
        fxx('sdesk',lv1.Selected.SubItems[11]);//解锁电脑

        supi1:='update temp set 标志="√" where IP="'+lv1.Selected.SubItems[11]+'"';
        supi2:=tb1.SQL.Text;
        tb1.Close;
        tb1.SQL.Clear;
        tb1.SQL.Add(supi1);
        tb1.Prepared;
        tb1.ExecSQL;

        tb1.Close;
        tb1.SQL.Clear;
        tb1.SQL.Add(supi2);
        tb1.Prepared;
        tb1.Open;
        lv1_create_date;



end;

procedure TForm1.N10Click(Sender: TObject);
  var
  supi1,supi2:string;
begin
        if lv1.SelCount=0 then exit; //没有焦点退出
        fxx('hdesk',lv1.Selected.SubItems[11]); //锁定电脑

        supi1:='update temp set 标志="×" where IP="'+lv1.Selected.SubItems[11]+'"';
        supi2:=tb1.SQL.Text;
        tb1.Close;
        tb1.SQL.Clear;
        tb1.SQL.Add(supi1);
        tb1.Prepared;
        tb1.ExecSQL;

        tb1.Close;
        tb1.SQL.Clear;
        tb1.SQL.Add(supi2);
        tb1.Prepared;
        tb1.Open;
        lv1_create_date;

end;

procedure TForm1.N12Click(Sender: TObject);
begin
if lv1.SelCount=0 then exit; //没有焦点退出
 fxx('close',lv1.Selected.SubItems[11]);    //关机
end;

//侦消息函数
procedure TForm1.CUDPDataReceived(Sender: TComponent; NumberBytes: Integer;
  FromIP: String; Port: Integer);
var
  CtrlCode:array[0..250] of char;
  ipdz,sfnj1,sfnj2:string;
  js :integer;
  cudp1,cudp2,cudp3,cudp4,cudp5,cudp6:string;//本函数的公用变量
begin
  ipdz:='';
  js:=0;
  CUDP.ReadBuffer(CtrlCode,NumberBytes);
  // 读取控制码
if CtrlCode[0]+CtrlCode[1]='mz' then //客机发来客机的计算机名
  jsjm:=CtrlCode[2]+CtrlCode[3]+CtrlCode[4]+CtrlCode[5]+CtrlCode[6]+CtrlCode[7]+CtrlCode[8]+CtrlCode[9];
if CtrlCode[0]+CtrlCode[1]='ip' then  //客机发来客机的IP
  begin //  取IP地址时登录数据库
    ipdz:=CtrlCode;
    delete(ipdz,1,2);
    with table1 do
    begin //修改库
       first;
       edit;
       while not eof do
       begin
        if table1ip.Value=ipdz then
         begin
         cudp4:=table1a15.Value;
         js:=1;
         end;
        next;
       end;
    if js=0 then
      begin    //js=0            //在库中没有添加
        table1.Append;
        table1a1.Value:=jsjm;
        table1a0.Value:='⊙';  //状态为联机
        table1ip.Value:=ipdz;
        table1a15.Value:='×'; //标志为锁屏
        cudp4:=table1a15.Value;
        post;
        tb1.Close;
        tb1.Open;
        lv1_create_date;
      end;     //js=0
    end;   //修改库
    fxx('zjip'+NMDayTime1.LocalIP,ipdz); //把主机IP发过去
    if cudp4='√' then fxx('sdesk',ipdz);   //如果标志是正在使用中则解锁

  end;   //取IP地址时登录数据库

  if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]='sfnj' then
      //是否还在线上  联机
        begin
        sfnj2:=CtrlCode;
        delete(sfnj2,1,5);
        if CtrlCode[4]='1' then
        sfnj2:='update temp set 状态="●" where IP="'+sfnj2+'"'
        else
        sfnj2:='update temp set 状态="⊙" where IP="'+sfnj2+'"';

        sfnj1:=tb1.SQL.Text;
        tb1.Close;
        tb1.SQL.Clear;
        tb1.SQL.Add(sfnj2);
        tb1.Prepared;
        tb1.ExecSQL;

        tb1.Close;
        tb1.SQL.Clear;
        tb1.SQL.Add(sfnj1);
        tb1.Prepared;
        tb1.Open;
        lv1_create_date;
        end;
  if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]='wyys' then
    begin   //客机查时间
    ipdz:=CtrlCode;
    delete(ipdz,1,4);

    sfnj1:=tb1.SQL.Text;  //保存上次SQL的操作
    sfnj2:='select * from temp  where ip="'+ipdz+'"';
    tb1.Close;
    tb1.SQL.Clear;
    tb1.SQL.Add(sfnj2);
    tb1.Prepared;
    tb1.Open;
    tb1.First;
    cudp1:=timetostr(tb1a4.Value);
    cudp1:=datetostr(tb1a3.Value)+' 日 '+cudp1;


    cudp2:=floattostr(trunc(tb1a9.Value/60))+' 小时 '+floattostr(tb1a9.AsInteger mod 60)+' 分钟';
//    delete(cudp2,5,3);
    cudp3:=timetostr(now);
    cudp5:=floattostr(trunc(tb1a12.Value/60))+' 小时 '+floattostr(tb1a12.AsInteger mod 60)+' 分钟';
    cudp6:=floattostr(tb1a11.Value);
    tb1.SQL.Clear;     //还原上次状态
    tb1.SQL.Add(sfnj1);
    tb1.Prepared;
    tb1.Open;

    sfnj2:='上机时间:'+cudp1+#10#13#10#13+'当前时间:'+datetostr(date)+' 日 '+cudp3+#10#13#10#13+'已用时间:'+cudp2+#10#13#10#13+'剩余时间:'+cudp5+#10#13#10#13+'余    额:'+cudp6+' 元';

    fxx('xx'+sfnj2,ipdz);
    end;

  if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]='yhdl' then
    begin  //00   收到会员登录
    cudp1:=CtrlCode;
    delete(cudp1,1,4); //去掉控制码
    cudp2:=cudp1;
    delete(cudp2,18,250);  //分离客户机IP
    delete(cudp1,1,18);    //分离客户机发来的帐号+密码
    cudp1:=trimleft(cudp1); //去掉前部空格 IP 与帐号密码是用空格划开的
    cudp2:=trimright(cudp2); //去掉尾部空格
    table3.Active:=true;
    table3.First;
      while not table3.Eof do
        begin   //11111
         if cudp1=table3a1.Value+table3a2.Value then
            begin  //22

                 // 有无重复登录
                  table1.Filtered:=false;
                  table1.Filter:='卡号='+''''+table3a1.Value+'''';
                  table1.Filtered:=true;
                   if table1.RecordCount>0 then begin fxx('chjd',cudp2);exit; end;
                  table1.Filtered:=false;
                 //----无重登录
             fxx('sdesk',cudp2);   //帐号和密码正确 则开锁
             hydl(cudp2,table3a1.Value,table3a3.Value,table3a6.Value,table3a5.Value,table3a9.Value);


             table1.Last; //找到指针移到最后一条记录,即退出查找
             table3.Next;
            end     //22
         else
          table3.Next;
        end; //111111

    table3.Active:=false;
    end;   //00
  if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]='hyxj' then
     begin
     //会员下机
      cudp5:=CtrlCode;
      delete(cudp5,1,4);
      hyjz(cudp5);
     end;
if CtrlCode[0]+CtrlCode[1]='xx' then
  //收到发来的信息
  begin
  cudp5:=CtrlCode;
    delete(cudp5,1,2); //去掉控制码
 Application.MessageBox(Pchar(cudp5),'信息',MB_OK);
  end;

  if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]='proc' then
//发来进程数据
begin
    cudp6:=CtrlCode;
    delete(cudp6,1,4);
    proc.listbox1.Items.Add(cudp6);
    proc.ListBox1.Refresh;

   end;


 end;    //侦消息函数

procedure TForm1.N13Click(Sender: TObject);
//删除本行
var
 dele1,str,str1:string;
begin
  if lv1.SelCount=0 then exit; //没有焦点退出
  //防止在无选择空记录上
  dele1:=lv1.Selected.Caption; //取关健字
  //删除SQL语句
  str:='delete from temp where 电脑="'+dele1+'"';
  str1:=tb1.SQL.Text;
  tb1.Close;
  tb1.SQL.Clear;
  tb1.SQL.Add(str);
  tb1.Prepared;
  tb1.ExecSQL;
  //刷新listvice(lv1)
  tb1.SQL.Clear;
  tb1.SQL.Add(str1);
  tb1.Prepared;
  tb1.Open;
  lv1_create_date;
end;

procedure TForm1.N7Click(Sender: TObject);
var
 aboutf:tkahao;      //添加临时卡
begin
if lv1.SelCount<>0 then
 begin
  if lv1.Selected.SubItems[2]<>'' then
//已上机 转到结帐
  begin
  Form1.N11Click(Sender);
  exit;
  end;
 aboutf:=tkahao.Create(self);
 aboutf.ShowModal;
 table1.Refresh;
 end;
end;

procedure TForm1.N15Click(Sender: TObject);
var
  xinxi:string;
begin
 if lv1.SelCount=0 then exit; //没有焦点退出
 xinxi:=inputbox('请输入要发送的信息','信息','');
 if xinxi<>'' then
  begin
  fxx('xx'+xinxi,lv1.Selected.SubItems[11]);
  end;
end;

procedure TForm1.N8Click(Sender: TObject);
var

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -