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

📄 unit1.~pas

📁 Delphi编写的东进语音卡实现的电话挂失系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
// file unit1.pas
//description: programe main source file
//version 1.2
//copyright (c) 2002 by Oriental Communication Tech Co.,LTD (shenzhen,P.R.China) allright reserverd

//index       date        author           notes
//  0      2000-4-29        LRG        create this file
//  1      2002-11-6        LRG        modify this file
//  2      2003-1-6         LRG        modify this file
unit Unit1;

interface

uses
  tc08a32,sysstr,Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, StdCtrls, Buttons, ExtCtrls,shellapi, DBXpress, FMTBcd, DB, inifiles,
  SqlExpr;

const
  maxchannel=240;

type
  channelpara=record
               Idcount:integer;
               Pwdcount:integer;
               playing:boolean;
               Step:integer;
               Countdown:integer;
               Callerid:pchar;
               dtmfid:string;
               PhoneNo:string;
               Pwd:string;
               Select:integer;
               CardCount:integer;
               CardNo:array[0..99]of string;
               CustID:string;
//               Callerid:string;
              end;

  TMAINFORM = class(TForm)
    showgrid: TStringGrid;
    Timer1: TTimer;
    btnclose: TBitBtn;
    SQLConnection1: TSQLConnection;
    SQLQuery1: TSQLQuery;
    SQLStoredProc1: TSQLStoredProc;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btncloseClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormActivate(Sender: TObject);

  private

    channel:array [0..maxchannel-1] of channelpara;
    procedure PlayMsg(Channelno:integer);
    function convertdtmf(sVal:integer):string;
    { Private declarations }
  public
    { Public declarations }
  end;
const
        ENCRYPT_DES=0;
        DECRYPT_DES=1;
        SUCC=0;
        FAIL=-1;
        PIN_ERR=-2;
        NO_CARD=-3;
        WAIT_TIME=6000;

var
  MAINFORM: TMAINFORM;
  validchannel,
  stroffset:integer;

implementation

{$R *.DFM}
{$R mystring.res}

function CheckPin(var channelData:channelpara):integer;
begin
    result :=FAIL;
    try
    try
        MAINFORM.SQLQuery1.Active:=false;
        MAINFORM.SQLQuery1.SQL.Text:='select CUST_ID  from T_CUST where MOBILE_NO='''+channelData.PhoneNo+''' and CUST_PWD=MD5('''+channelData.Pwd+''')';
        MAINFORM.SQLQuery1.Active:=true;
        if MAINFORM.SQLQuery1.RecordCount>0 then
        begin
            channelData.CustID:=trim(MAINFORM.SQLQuery1.FieldByName('CUST_ID').AsString);
            result:=SUCC;
        end
        else
            result:=PIN_ERR;
    except
        result :=FAIL;
    end;
    finally
        MAINFORM.SQLQuery1.Close;
    end;
end;
function QueryCard(var channelData:channelpara):integer;
var
i:integer;
begin
    result :=FAIL;
    try
    try
        MAINFORM.SQLQuery1.Active:=false;
        MAINFORM.SQLQuery1.SQL.Text:='SELECT IC_LNO from  V_QUERY_CARD where CUST_ID='''+trim(channelData.CustID)+'''';
        MAINFORM.SQLQuery1.Active:=true;
         channelData.CardCount:=MAINFORM.SQLQuery1.RecordCount;
        if  channelData.CardCount<=0 then
            result:=NO_CARD
        else
        begin
            channelData.CardCount:=MAINFORM.SQLQuery1.RecordCount;
            for i:=0 to channelData.CardCount-1 do
            begin
                channelData.CardNo[i]:=MAINFORM.SQLQuery1.FieldByName('IC_LNO').AsString;
                MAINFORM.SQLQuery1.Next;
            end;
            result:=SUCC;
        end;
    except
        result :=FAIL;
    end;
    finally
        MAINFORM.SQLQuery1.Close;
    end;
end;
function CancelCard(var channelData:channelpara):integer;
var
i:integer;
V_RET:string;
begin
    result:=FAIL;
    try
    try
        MAINFORM.SQLStoredProc1.Active:=false;
        MAINFORM.SQLStoredProc1.StoredProcName:='P_PAUSECARD';
        MAINFORM.SQLStoredProc1.ParamByName('V_MOBILE_NO').AsString:=pchar(channelData.PhoneNo);
        MAINFORM.SQLStoredProc1.ParamByName('V_IC_LNO').AsString:='51000001'+channelData.CardNo[channelData.select-1];
        MAINFORM.SQLStoredProc1.ExecProc;
        V_RET:=MAINFORM.SQLStoredProc1.ParamByName('V_RET').AsString;
        if V_RET<>'00'  then
            result:=FAIL
        else
            result:=SUCC;
    except
        result :=FAIL;
    end;
    finally
        MAINFORM.SQLStoredProc1.Close;
    end;
end;



function initConn():integer;
var
inifile:Tinifile;
Ret:integer;
begin
    try
        inifile:=Tinifile.Create('.\DATABASE.ini');
        MAINFORM.SQLConnection1.Close;
        MAINFORM.SQLConnection1.KeepConnection:=true;
        MAINFORM.SQLConnection1.ConnectionName:='Oracle';
        MAINFORM.SQLConnection1.DriverName:= 'Oracle' ;
        MAINFORM.SQLConnection1.GetDriverFunc := 'getSQLDriverORACLE';
        MAINFORM.SQLConnection1.LibraryName := 'dbexpora.dll';
        MAINFORM.SQLConnection1.VendorLib:='OCI.DLL';
        MAINFORM.SQLConnection1.LoginPrompt := False ;
        MAINFORM.SQLConnection1.Params.Clear;
        MAINFORM.SQLConnection1.Params.Add('BlobSize=-1');
        MAINFORM.SQLConnection1.Params.Add('DataBase='+inifile.ReadString('DATABASE','DBNAME','oc'));
        MAINFORM.SQLConnection1.Params.Add('DriverName=Oracle');
        MAINFORM.SQLConnection1.Params.Add('ErrorResourceFile=');
        MAINFORM.SQLConnection1.Params.Add('LocaleCode=0000');
        MAINFORM.SQLConnection1.Params.Add('Oracle TransIsolation=ReadCommited');
        MAINFORM.SQLConnection1.Params.Add('Password='+inifile.ReadString('DATABASE','PASSWORD','octestman'));
        MAINFORM.SQLConnection1.Params.Add('User_Name='+inifile.ReadString('DATABASE','USER','bcc'));
        MAINFORM.SQLConnection1.Connected:=true;
    except
        result:=FAIL;
        exit;
    end;
    if not MAINFORM.SQLConnection1.Connected then
    begin
        result:=FAIL;
        exit;
    end;
    MAINFORM.SQLQuery1.SQLConnection:= MAINFORM.SQLConnection1;
    MAINFORM.SQLStoredProc1.SQLConnection:=MAINFORM.SQLConnection1;
    result:=SUCC;
end;



procedure TMAINFORM.FormCreate(Sender: TObject);
var
   i:integer;
   s:string;

begin
   //detect the language of SYSTEM and initialize stroffset parameter
       
   if GetSystemDefaultLangID=$804 then
   stroffset:=0
   else stroffset:=100;
   //stroffset 0:simply chinese
    //        100: ENGLIST
   //init layout of mainform
  // MAINFORM.Caption:=loadstr(IDC_SYS_TITLE+stroffset) ;
   btnclose.Caption:=loadstr(IDC_SYS_EXIT+stroffset)   ;
   //initialize analog board
   loaddrv();
   validchannel:=checkvalidch();
   enablecard(validchannel,1024*59);
   setpackrate(0);
   sig_init(0);
   //initialize layout of showgrid
   showgrid.RowCount:=validchannel+1;
   showgrid.ColWidths[0]:=80;
   showgrid.ColWidths[1]:=95;
   showgrid.ColWidths[2]:=130;
   showgrid.ColWidths[3]:=520;
   showgrid.Cells[0,0]:=loadstr(IDC_SYS_CHANNELNUM+stroffset);
   showgrid.cells[1,0]:=loadstr(IDC_SYS_CHANNELTYPE+stroffset);;
   showgrid.cells[2,0]:=loadstr(IDC_SYS_CHANNELCALLERID+stroffset);;
   showgrid.cells[3,0]:=loadstr(IDC_SYS_MESSAGE+stroffset);
   for i:=1 to validchannel do
      begin
         startsigcheck(i-1);
         channel[i-1].Countdown:=0;
         channel[i-1].Step:=0;

         initdtmfbuf(i-1);
         str(i-1,s);
        case checkchtypenew(i-1) of
        CHTYPE_USER:showgrid.cells[1,i]:=loadstr(IDC_SYS_USER+stroffset);
        CHTYPE_TRUNK:showgrid.cells[1,i]:=loadstr(IDC_SYS_TRUNK+stroffset);
        CHTYPE_EMPTY:showgrid.cells[1,i]:=loadstr(IDC_SYS_EMPTY+stroffset);
        CHTYPE_RECORD:showgrid.cells[1,i]:=loadstr(IDC_SYS_RECORD+stroffset);
        end;
         showgrid.cells[0,i]:=s;
      end;

end;

procedure TMAINFORM.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    //release analog board
    disablecard();
    freedrv;
end;

procedure TMAINFORM.btncloseClick(Sender: TObject);
begin
   close;
end;

procedure TMAINFORM.Timer1Timer(Sender: TObject);
var
   i:integer;
begin
   push_play;
   feedsigfunc;
   for i:=0 to validchannel-1 do
       begin
          if channel[i].playing then
            begin

                if (checkchtypenew(i)=CHTYPE_TRUNK) and (sig_checkbusy(i)=1) then         // if detect the busy tone , reset the trunk
                begin
                   //reset trunk
                   channel[i].Step:=0;
                   channel[i].Idcount:=0;
                   channel[i].Pwdcount:=0;
                   showgrid.cells[3,i+1]:='';
                   showgrid.cells[2,i+1]:='';

                   hangup(i);
                   startsigcheck(i);
                   Sig_ResetCheck(i);
                   initdtmfbuf(i);
                   channel[i].Playing:=false;
                   exit;
                end;

               if (ringdetect(i)=false) and (checkchtypenew(i)=CHTYPE_USER) then//IF USER HOOK IS ON THEN RESET USER
                begin
                   //reset trunk
                   channel[i].Step:=0;
                   channel[i].Idcount:=0;
                   channel[i].Pwdcount:=0;
                   showgrid.cells[3,i+1]:='';
                   showgrid.cells[2,i+1]:='';
                   startsigcheck(i);
                   StartPlaySignal(i, SIG_STOP);
                   initdtmfbuf(i);
                   channel[i].Playing:=false;
                   exit;
                end;

                //EXECUTE IVR
                playmsg(i);

            end
            else begin
               if ringdetect(i) then //first ring detected and execute playmsg()
                  begin
                     startsigcheck(i);
                     resetcalleridbuffer(i);
                     channel[i].playing:=true;
                     channel[i].step:=0;
                     showgrid.cells[3,i+1]:=loadstr(IDC_CALLERID_RING+stroffset);
                     starttimer(i,4);
                     if checkchtypenew(i)=CHTYPE_USER then// if  channel is user then exeute ivr directly
                        channel[i].step:=5;

                     playmsg(i);
                  end;
            end;
      end;
end;

procedure PlayNumber(a:string;channelno:integer);
var
i:integer;
begin
    for i:=0 to length(a)-1 do
    begin
        case byte(pchar(a)[i]) of
            $30:addindexplayfile(channelno,'.\voc\D0');
            $31:addindexplayfile(channelno,'.\voc\D1');
            $32:addindexplayfile(channelno,'.\voc\D2');
            $33:addindexplayfile(channelno,'.\voc\D3');
            $34:addindexplayfile(channelno,'.\voc\D4');

⌨️ 快捷键说明

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