| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 638 人关注过本帖
标题:DELPHI 调用数据库文件 ,哪位大虾解决一下!!!!
只看楼主 加入收藏
wxy190527204
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-30
收藏
 问题点数:0 回复次数:0 
DELPHI 调用数据库文件 ,哪位大虾解决一下!!!!
我做的是一个关机彩铃的课题,就是机主可以设定自己的状态,当别人打电话给机主时,如果机主关机的话就播放机主设定的状态。。
我设定了开会,出差,休息,上课,这四个状态,,现在已经可以把机主选择的状态写进数据库里,数据库里有两张表,一张存放选定的状态对应的标识符i,和机主号码,,另一张表存放这四个状态所对应的语音文件,现在的问题就是运行主程序电话呼入时,怎样调用数据库把选定的状态读出来,
下面的是主程序,(此时主程序播放的是一个固定的语音文件)
unit CallFunc;

interface


type TRUNK_STATE =(
    TRK_IDLE,
    TRK_WAIT_CONNECT,
    TRK_PLAY_WELCOM,
    TRK_CHECK_PLAY_WELCOM,
    TRK_NOTRK
        );
const USER_CH = 2;
type TRUNK_STRUCT = record
        EnCalled:Boolean;
    lineState:Integer;
    Step:TRUNK_STATE;        //state of current channel
    UserCh:integer;

    pErrMsg:String;
    pCallerId:String;
        dwTimeOutCounter:LongWord;
end;
///////////////////////////////////////////
procedure UpDateATrunkChListCtrl();
procedure InitATrunkCh;
function InitCtiSystem():boolean;
procedure AppErrorHandler(ch:Integer);
procedure ScanATrunkCh;
procedure ExitCtiSystem;

///////////////////////////////////////////////////////////
var
  nTotUserCh:Integer;
  nTotATrkCh:Integer;
  ATrkCh:array[0..100] of TRUNK_STRUCT;

///////////////////////////////////////////////////////////
implementation
uses Shpa3api,Main,Windows, Messages, SysUtils, Classes, Graphics,
     Controls, Forms, Dialogs,ComCtrls, ExtCtrls;

////////////////////////////////////////////////////////////
function InitCtiSystem():boolean;
var
  strCurrentDir:string;
  fnIni:string;
  fnIndex:string;

  ErrMsg:PChar;
begin
  strCurrentDir:=GetCurrentDir();
  fnIni:=strCurrentDir+'\ShConfig.ini';
  fnIndex:=strCurrentDir+'\ShIndex.ini';

  if SsmStartCti( @fnIni[1], @fnIndex[1] ) <> 0 then
  begin
    GetMem(ErrMsg,200);
    SsmGetLastErrMsg(ErrMsg); //取得初始化出错信息
    Application.MessageBox(ErrMsg,'错误', MB_OK );
    FreeMem(ErrMsg);
    InitCtiSystem:=False;
    Exit;
  end;

  InitCtiSystem:=true;
end;

////////////////////////////////////////////////////////////
procedure ExitCtiSystem;
begin
  SsmCloseCti() ;
end;

/////////////////////////////////////////////////////////////
procedure ScanATrunkCh();
var
  i:Integer;
  tmp:char;
  strCurrentDir:string;
  pBuf:PChar;
begin
  for i:=0 to nTotATrkCh-1 do
  if ATrkCh[i].EnCalled then
  begin
    ATrkCh[i].lineState := SsmGetChState(i);

    case ATrkCh[i].Step of
    TRK_IDLE:
    begin
      if ATrkCh[i].lineState = S_CALL_RINGING then  //ring detected
      begin
        SsmPickup(i);
        GetMem(pBuf,100);
        if SsmGetCallerId(i,pBuf)>0 then  ATrkCh[i].pCallerId:=StrPas(pBuf)
        else ATrkCh[i].pCallerId:='';
        FreeMem(pBuf);
        ATrkCh[i].dwTimeOutCounter := 0;
        ATrkCh[i].Step := TRK_WAIT_CONNECT;
      end
      else
      begin
        ATrkCh[i].pCallerId := '';
      end;
    end;

    TRK_WAIT_CONNECT:
    begin

      if ATrkCh[i].lineState = S_CALL_TALKING then
      begin
        ATrkCh[i].Step := TRK_PLAY_WELCOM;
      end;
    end;

    TRK_PLAY_WELCOM:
    begin
      SsmClearFileList(i);
      if (SsmAddToFileList(i,'..\..\..\..\..\DemoVoc\bgmusic.wav',6,0,$FFFFFFFF)=-1)
      or (SsmAddToFileList(i,'..\..\..\..\..\DemoVoc\bgmusic.wav',6,0,$FFFFFFFF)=-1)then
        AppErrorHandler(i)
      else
      begin
        if SsmPlayFileList(i) = -1 then AppErrorHandler(i)
        else ATrkCh[i].Step := TRK_CHECK_PLAY_WELCOM;
      end;
    end;

    TRK_CHECK_PLAY_WELCOM:
    begin
        if SsmCheckPlay(i) > 0 then//end of playing "welcom"
              ATrkCh[i].Step := TRK_IDLE;
    end;


 
    end;//end of case
  end;//end of for
end;

////////////////////////////////////////////////////////////////////////
procedure UpDateATrunkChListCtrl;
var
  state:Pchar ;
  tmpstr:String;
  i:Integer;
  nIndex : Integer;

begin
  nIndex:=0;
  for i:=0 to nTotATrkCh-1 do
  if ATrkCh[i].EnCalled = true  then
  begin
    case ATrkCh[i].Step of
    TRK_IDLE:            state := '空闲';
    TRK_WAIT_CONNECT:        state := '等待连接';
    TRK_PLAY_WELCOM:            state := '正在播放欢迎词';
    TRK_CHECK_PLAY_WELCOM:    state := '播放欢迎词';
    TRK_NOTRK:                  state := '非模拟外线通道';
    else            state := '未定义';
    end;
    tmpstr:=MainForm.StateListView.Items[nIndex].SubItems[0];
    if  state <> tmpstr then
      MainForm.StateListView.Items[nIndex].SubItems[0]:=state;

    tmpstr:=MainForm.StateListView.Items[nIndex].SubItems[1];
    if tmpstr <> ATrkCh[i].pCallerId then
      MainForm.StateListView.Items[nIndex].SubItems[1]:=ATrkCh[i].pCallerId;


    if ATrkCh[i].Step = TRK_IDLE then
    begin
      state := '';
      tmpstr:=MainForm.StateListView.Items[nIndex].SubItems[2];
        if state <> tmpstr then
          MainForm.StateListView.Items[nIndex].SubItems[2]:=StrPas(state);
    end
    else
    begin
      GetMem(state,100);
      if SsmGetDtmfStr(i, state) > 0 then //receive and display DTMF keys
      begin
        tmpstr:=MainForm.StateListView.Items[nIndex].SubItems[2];
        if state <> tmpstr then
          MainForm.StateListView.Items[nIndex].SubItems[2]:=StrPas(state);
      end;
      FreeMem(state);
    end;

    tmpstr:=MainForm.StateListView.Items[nIndex].SubItems[3];//display error messages occured
    if ATrkCh[i].pErrMsg <> tmpstr then
      MainForm.StateListView.Items[nIndex].SubItems[3]:=ATrkCh[i].pErrMsg;
    nIndex:=nIndex+1;

  end;
end;


///////////////////////////////////////////////////////////////////////
procedure InitATrunkCh;
var
  i:Integer;
  nDirection:Integer;
begin
  nTotATrkCh := SsmGetMaxCh();
  for i:=0 to nTotATrkCh-1 do
  begin
    ATrkCh[i].EnCalled := false;

    if SsmGetAutoCallDirection(i,@nDirection) = 1  then //允许自动接续
    begin
      if ( nDirection = 0) or (nDirection = 2) then //enable call in
      begin
        ATrkCh[i].Step := TRK_IDLE;
        ATrkCh[i].EnCalled := true;
      end;
    end;
  end;
end;

///////////////////////////////////////////////////////////////////////
procedure AppErrorHandler(ch:Integer);
var
  ErrMsg:PChar;
begin
  SsmHangup(ch);
  GetMem(ErrMsg,200);
  SsmGetLastErrMsg(ErrMsg);
  ATrkCh[ch].pErrMsg:=StrPas(ErrMsg);
  FreeMem(ErrMsg);
  ATrkCh[ch].Step := TRK_IDLE;
end;

end.
在哪里进行数据库文件的调用,请各位大虾帮个忙啊,,,急!!!


搜索更多相关主题的帖子: 数据库 DELPHI 文件 
2010-05-30 14:19
快速回复:DELPHI 调用数据库文件 ,哪位大虾解决一下!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023496 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved