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

📄 databaseoperat.pas

📁 SPServer.rar一个基于TCP/IP监听发送代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    if FailRecord>0 then Dec(FailRecord);
     PostMess(2,1,psSrcNo,pChargeNo,pSvcType,Now,pContent,SPNumber);
     SingleSend:=True;
   end;
end;

//===========================接收数据分析=====================================//
procedure StatemAssay(pSrcNo, pSvcType:string);
var
 i:Integer;
 aSvcType:string;
 str:string;
 str1:string;
 str2:string;
begin
if ResultCharegNo=1 then p_ChargeNo:=pSrcNo;   //被叫号码付费
if ResultCharegNo=0 then p_ChargeNo:='0';      //SP付费
aSvcType := UpperCase(Trim(pSvcType));         //转换服务类型大小写

if (Copy(aSvcType,1,2)='ZC')or(Copy(aSvcType,1,2)='ZJ')
  then begin
   str:=Copy(aSvcType,3,Length(aSvcType)-2);
   aSvcType:=Copy(aSvcType,1,2);
   end;

if (Length(aSvcType)>0)and(aSvcType<>'') then
 begin
   if SearchSvcType(aSvcType,0)>=0
    then begin
//=============H帮助信息====================//
     if aSvcType='H'
       then begin
        p_SvcType:=SP_SvcType;
        p_Content:=ResultMsg(101);
       end;
//==============取消定制用户=================//
     if aSvcType='193' then
       begin
        p_SvcType:=SP_SvcType;
        p_Content:=ResultMsg(103);
       end;
     if aSvctype='193QX' then
       begin
        p_SvcType:=SP_SvcType;
        p_Content:=ResultMsg(108);
       end;
//////////////////////////////////
     if  aSvcType='Z' then
       begin
         with frmServerDB.qrytemp do
          begin
           Close;
           Parameters.ParamByName('pproNo').Value:=str;
           Open;
          end;
          if frmServerDB.qrytemp.RecordCount>0 then
           begin
            if frmServerDB.qrytemp.Fields[4].Text='1' then
             begin
              str1:= DateTimeToStr(frmServerDB.qrytemp.Fields[2].Value);
              str2:= frmServerDB.qrytemp.Fields[3].Value;
              p_Content:='你的产品已在'+str1+'被'+str2+'注册过!';
              p_SvcType:=SP_SvcType;
             end else
            if frmServerDB.qrytemp.Fields[4].Text='0' then
             begin
              str1:= frmServerDB.qrytemp.Fields[1].Value;
              p_Content:='产品生产批号为:'+str1+'已被您注册成功!';
                with frmServerDB.uptemp do
                 begin
                  close;
                  Parameters.ParamByName('pzcdate').Value:=now;
                  parameters.ParamByName('pzcnumb').Value:=pSrcNo;
                  Parameters.ParamByName('pprono').Value:=str;
                  execsql;
                 end;
              p_SvcType:=SP_SvcType;
             end;
            end else
             begin
              p_Content:='您请求的信息没找到!';
              p_SvcType:=SP_SvcType;
             end;
           frmServerDB.qrytemp.Close;  
       end;
//===============取消天气定制用户===============//
     if aSvcType='D'
       then begin
        with frmServerDB.aqrRegister do
         begin
          Close;
          Parameters.ParamByName('p_SrcNo').Value:=pSrcNo;
          Open;
         end;
         if frmServerDB.aqrRegister.RecordCount=0
          then p_Content := ResultMsg(107) else
          //使用存储过程删除记录
          with frmServerDB.adeleteRegister do
           begin
            Parameters.ParamByName('@p_SrcNo').Value:=pSrcNo;
            Prepared;
            ExecProc;
            p_Content := ResultMsg(108);
           end;
           p_SvcType := SP_SvcType;
           frmServerDB.aqrRegister.Close;
         end;
//================用户查询服务===============//
       if aSvcType='C' then
        begin
         with frmServerDB.aSvcContent do
          begin
           Close;
           Parameters.ParamByName('p_SvcTypeName').Value:=pSvcType;
           Open;
          end;
          if frmServerDB.aSvcContent.RecordCount>0 then
           begin
            p_SvcType := Trim(frmServerDB.aSvcContent.Fields[1].Value);
            p_Content := Trim(frmServerDB.aSvcContent.Fields[2].Value);
            p_ChargeNo := pSrcNo;
            WriteCXRecord(ReadCXRecord+1);
            frm_smServer.lCXCount.Caption:=IntToStr(ReadCXRecord);
           end else
           begin
            p_Content:=ResultMsg(104);
            p_SvcType:=SP_SvcType;
           end;
           frmServerDB.aSvcContent.Close;
        end;
//===============用户定制信息的资料==================//
     if aSvcType='S' then
      begin
       with frmServerDB.aqrRegister do
        begin
         Close;
         Parameters.ParamByName('p_SrcNo').Value:=pSrcNo;
         Open;
        end;
        if frmServerDB.aqrRegister.RecordCount>0 then
          begin
           p_Content:=ResultMsg(106);
           p_SvcType:=SP_SvcType;
           frmServerDB.aqrRegister.Close;
          end else
          //使用存储过程Insert新的记录
           with frmServerDB.aInsertRegister do
            begin
             Parameters.ParamByName('@p_SrcNo').Value:=pSrcNo;
             Parameters.ParamByName('@p_ChargeNo').Value:=pSrcNo;
             Parameters.ParamByName('@p_SvcType').Value:=pSvcType;
             Parameters.ParamByName('@p_regDate').Value:=FormatDateTime('yyyymmddhhmmss',Now);
             Prepared;
             ExecProc;
             p_Content:=ResultMsg(105);
             p_SvcType:=SP_SvcType;
            end;
            frmServerDB.aqrRegister.Close;
          end;

/////////////////////////////////////////////////////////
       end else
     begin
      //输入错误的代码时
      p_Content:=ResultMsg(100);
      p_SvcType:=SP_SvcType;
     end;
     CurLogMsg(1,'==========收到服务器数据========');
     CurLogMsg(1,'主叫号码:'+pSrcNo);
     CurLogMsg(1,'请求代码:'+pSvcType);
     WriteSNDRecord(ReadSNDRecord+1);
     p_SrcNo:=pSrcNo;
     PostMess(2,1,p_SrcNo,p_ChargeNo,p_SvcType,Now,p_Content,SPNumber);
   end;
end;

procedure SockAddressLink(pHandle:DWord;pHand:byte;pIPAddress,pSPNumber:string;Falg:Integer);
var
 i:Integer;
begin
case Falg of
 0:begin
    with frmServerDB.tblConnAddress do
     begin
      Open;
      Insert;
      Fields[0].Value:=pHandle;
      Post;
      Close;
     end;
   end;
 1:
  with frmServerDB.updConnAddress do
     begin
      Close;
      Parameters.ParamByName('pHand').Value:=pHand;
      Parameters.ParamByName('pIPAddress').Value:=pIPAddress;
      Parameters.ParamByName('pDateTime').Value:=Now;
      Parameters.ParamByName('pSPNumber').Value:=pSPNumber;
      Parameters.ParamByName('pHandle').Value:=pHandle;
      ExecSQL;
     end;
 2:
  with frmServerDB.delConnAddress do
   begin
    Close;
    Parameters.ParamByName('pHandle').Value:=pHandle;
    ExecSQL;
   end;
 4:
   begin
     for i:=1 to frm_smServer.sgr3.RowCount do
     frm_smServer.sgr3.Rows[i].Clear;
     frm_smServer.sgr3.RowCount:=2;
     I:=1;
     frmServerDB.tblConnAddress.Close;
     frmServerDB.tblConnAddress.Open;
     frmServerDB.tblConnAddress.First;
      while not frmServerDB.tblConnAddress.Eof do
        begin
          with frm_smServer.sgr3 do
             with frmServerDB do
              begin
                Cells[0,i]:=tblConnAddressNetHandle.Text;
                Cells[1,i]:=tblConnAddressHand.Text;
                Cells[2,i]:=tblConnAddressIPAddress.Text;
                Cells[3,i]:=tblConnAddressUnitName.Text;
                Cells[4,i]:=tblConnAddressDateTime.Text;
              end;
             frmServerDB.tblConnAddress.Next;
             Inc(I);
             frm_smServer.sgr3.RowCount:=I;
          end;
        end;
     end;
end;

//写信息日志//
procedure  WriteMessageLog(pHandle:DWord;pHand:byte;pIPAddress,pUser,pCommandID,
                          pDestNo,pChargeNo,pSvcType,pContent,pSPNumber:string);
begin
with frmServerDB.tblMessageLog do
 begin
  Open;
  Insert;
  Fields[0].Value:=pHandle;
  Fields[1].Value:=pHand;
  Fields[2].Value:=pIPAddress;
  Fields[3].Value:=pSPNumber;
  Fields[4].Value:=pUser;
  Fields[5].Value:=pCommandID;
  Fields[6].Value:=pDestNo;
  Fields[7].Value:=pChargeNo;
  Fields[8].Value:=pSvcType;
  Fields[9].Value:=pContent;
  Fields[10].Value:=Now;
  Post;
  Close;
 end;
 with frm_smServer.sgr2 do
  begin
   if Trim(Cells[0,RowCount-1])<>'' then
    RowCount:=RowCount+1;
   Row:=RowCount-1; 
   Cells[0,RowCount-1]:=IntToStr(pHandle);
   Cells[1,RowCount-1]:=IntToStr(pHand);
   Cells[2,RowCount-1]:=pIPAddress;
   Cells[3,RowCount-1]:=pSPNumber;
   Cells[4,RowCount-1]:=pUser;
   Cells[5,RowCount-1]:=pCommandID;
   Cells[6,RowCount-1]:=pDestNo;
   Cells[7,RowCount-1]:=pChargeNo;
   Cells[8,RowCount-1]:=pSvcType;
   Cells[9,RowCount-1]:=pContent;
   Cells[10,RowCount-1]:=DateTimeToStr(Now);
  end;
end;

procedure ClearLink;
begin
 frmServerDB.delAllConnAddress.Close;
 frmServerDB.delAllConnAddress.ExecSQL;
end;

end.

⌨️ 快捷键说明

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