停车场系统中心收费软件代码

来源:誉澄智能 2014/4/16 13:00:11      点击:

 if conf.CenterPay then  //中心收费模式  admin
  begin
    if not imgOpen.Enabled then Exit;
    if not bCanOpen then Exit;
    //先写历史停车记录
    with qryRec do
    begin
        //////////////////
        //设备所在停车场查询
        Close;
        SQL.Clear;
        SQL.Add('SELECT * FROM JY_Park_Mech_info');
        SQL.Add('WHERE 编号=' + lbDev.Caption);
        Open;
        nPrkID := FieldByName('所属停车场编号').AsInteger;


        //查询是否已经收过费
        Close;
        SQL.Clear;
        SQL.Add('select * from JY_Park_IN_Info WHERE 卡号='''  + Edit1.Text + '''');
        Open;

       // if RecordCount>0 then
        if FieldByName('已结算').AsBoolean then
          begin  //也结算过的,必须重新采用插入新的出场记录
             sID := GetID();
             Close;
             SQL.Clear;


             aCardID:=trim(Edit1.Text);
             SQL.Add('INSERT JY_Park_Rec_Info (编号,卡号,卡类,大小停车场)');
             SQL.Add('VALUES (''' + sID + ''',''' + aCardID + ''',' + IntToStr(2) + ','
                                + inttostr(nPrkID) + ')');
             try
                ExecSQL;
             except
                    SQL.SaveToFile(AppDir+'\logs\' + FormatDateTime('YYYYMMddHHmmss',now)+'.txt');
             end;
              Close;
            SQL.Clear;
            SQL.Add('UPDATE JY_Park_IN_Info SET');
            SQL.Add('出场时间=''' + DateTimeToStr(now) + ''',');

            SQL.Add('已结算= ' + sBool[True]);
            SQL.Add(' WHERE 卡号=''' + Edit1.Text +'''');

            try
            ExecSQL;
           except
           // SQL.SaveToFile(AppDir+'\logs\' + DateTimeToStr(now)+'.txt');
             DecodeDate(now, mdt.year, mdt.month, mdt.day);
             DecodeTime(now, mdt.hour, mdt.minute, mdt.second,t);
             str1:=floattostr(mdt.year)+'Y'+floattostr(mdt.month)+'M'+floattostr(mdt.day);
             str2:='D'+floattostr(mdt.hour)+'H'+floattostr(mdt.minute)+'M'+floattostr(mdt.second)+'S';
             SQL.SaveToFile(AppDir+'\logs\' + str1+str2+'.txt');//出错了,怎么办?
           end;

           Close;                  //更新记录
           SQL.Clear;
           SQL.Add('UPDATE JY_Park_Rec_Info SET');
           SQL.Add('出场时间=''' + Edit5.Text + ''',');
           SQL.Add('停车费用=''' + Edit7.Text + ''',');
           //SQL.Add('出口编号=' + lbDev.Caption + ',');
           if czkout then
            SQL.Add('收费员=''' + spaceuser + '''')
           else
           SQL.Add('收费员=''' + LocalUser.Name + '''');

           SQL.Add('WHERE 编号=''' + sID + '''');
           try
            ExecSQL;
           except
            DecodeDate(now, mdt.year, mdt.month, mdt.day);
            DecodeTime(now, mdt.hour, mdt.minute, mdt.second,t);
            str1:=floattostr(mdt.year)+'Y'+floattostr(mdt.month)+'M'+floattostr(mdt.day);
            str2:='D'+floattostr(mdt.hour)+'H'+floattostr(mdt.minute)+'M'+floattostr(mdt.second)+'S';
            SQL.SaveToFile(AppDir+'\logs\' + str1+str2+'.txt');//出错了,怎么办?
           end;


           //end;
          //end;
          end else   //第一次来付费
           begin
           Close;
           SQL.Clear;
           SQL.Add('UPDATE JY_Park_Rec_Info SET');
           SQL.Add('出场时间=''' + Edit5.Text + ''',');
           SQL.Add('停车费用=''' + Edit7.Text + ''',');
           //SQL.Add('出口编号=' + lbDev.Caption + ',');
           if czkout then
            SQL.Add('收费员=''' + spaceuser + '''')
           else
           SQL.Add('收费员=''' + LocalUser.Name + '''');
           //SQL.Add('大小停车场=''' + );
           SQL.Add('WHERE 编号=''' + gSid + '''');
           try
            ExecSQL;
           except
           DecodeDate(now, mdt.year, mdt.month, mdt.day);
           DecodeTime(now, mdt.hour, mdt.minute, mdt.second,t);
           str1:=floattostr(mdt.year)+'Y'+floattostr(mdt.month)+'M'+floattostr(mdt.day);
           str2:='D'+floattostr(mdt.hour)+'H'+floattostr(mdt.minute)+'M'+floattostr(mdt.second)+'S';
           SQL.SaveToFile(AppDir+'\logs\' + str1+str2+'.txt');//出错了,怎么办?
           // SQL.SaveToFile(AppDir+'\logs\' + DateTimeToStr(now)+'.txt');//出错了,怎么办?
           end;


          Close;
          SQL.Clear;
          SQL.Add('UPDATE JY_Park_IN_Info SET');
          SQL.Add('出场时间=''' + DateTimeToStr(now) + ''',');
          //SQL.Add('出口编号= ''' + IntToStr(nPrkID)+ ''',');
          SQL.Add('已结算= ' + sBool[True]);
          SQL.Add(' WHERE 卡号=''' + Edit1.Text +''' AND ');
          SQL.Add('所在停车场 >= ' + IntToStr(nPrkID));

          //SQL.Add('UPDATE JY_Park_Card_Info SET');
          //SQL.Add('所在停车场=' + IntToStr(nPrkID-1) + 'WHERE 卡号=''' + Edit1.Text + '''');
          try
            ExecSQL;
          except
           // SQL.SaveToFile(AppDir+'\logs\' + DateTimeToStr(now)+'.txt');
           DecodeDate(now, mdt.year, mdt.month, mdt.day);
           DecodeTime(now, mdt.hour, mdt.minute, mdt.second,t);
           str1:=floattostr(mdt.year)+'Y'+floattostr(mdt.month)+'M'+floattostr(mdt.day);
           str2:='D'+floattostr(mdt.hour)+'H'+floattostr(mdt.minute)+'M'+floattostr(mdt.second)+'S';
           SQL.SaveToFile(AppDir+'\logs\' + str1+str2+'.txt');//出错了,怎么办?
          end;
         end;
       end;
  end else  //普通收费模式
  begin
    if not imgOpen.Enabled then Exit;
    if not bCanOpen then Exit;

    with qrypic  do
    begin
    close;
    SQL.Clear;                                                                //
    SQL.Add('UPDATE JY_Park_New_Picture SET 标识=1');
    SQL.Add('WHERE 编号=''' + gSid + '''');  //
     try
       ExecSQL;
       except
        ;//showmessage('图像标识失败');
      end;
     end;