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

📄 unit1.pas

📁 关于DELPHI下面使用ODBC 连接FIREBIRD数据库 采用C/S结构,此程序运用于CLIENT端,连接主机数据库,需要安装FIREBIRD ODBC连接程序
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit Unit1;

interface


uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids, MPlayer, OleCtrls,
  PLAYCLIENTLib_TLB, ComCtrls, ExtCtrls, WMPLib_TLB,inifiles, Mask, DBCtrls,
  Menus, Buttons,Winsock, ActnList,StrUtils, MONITORCLIENTLib_TLB;
const
  CM_RESTORE=WM_USER + $1000; {自定义的“恢复”消息}
  MYAPPNAME='VLAN录音记录监督台';
  ScreenWidth:   LongInt   =   800;   {I   designed   my   form   in   800x600   mode.}
  ScreenHeight:   LongInt   =   600;
    

type
   TFooClass   =   class(TControl);   {   needed   to   get   at   protected   }   
                                                                {   font   property   }   

  TForm1 = class(TForm)
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    GroupBox2: TGroupBox;
    DBGrid1: TDBGrid;
    GroupBox3: TGroupBox;
    PlayClient1: TPlayClient;
    DBEdit1: TDBEdit;
    StatusBar1: TStatusBar;
    PopupMenu1: TPopupMenu;
    DBEdit2: TDBEdit;
    N1: TMenuItem;
    DBEdit3: TDBEdit;
    GroupBox4: TGroupBox;
    Lb_StartTime: TLabel;
    Lb_EndTime: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    CB_Agent: TCheckBox;
    CB_CallerID: TCheckBox;
    CB_DTMF: TCheckBox;
    CB_PhoneNum: TCheckBox;
    CB_TimeArea: TCheckBox;
    GroupBox5: TGroupBox;
    Btn_Close: TBitBtn;
    Btn_Query: TBitBtn;
    Edit4: TEdit;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    PopupMenu2: TPopupMenu;
    N2: TMenuItem;
    PopupMenu3: TPopupMenu;
    N3: TMenuItem;
    DBEdit4: TDBEdit;
    DateTimePicker3: TDateTimePicker;
    DateTimePicker4: TDateTimePicker;
    ADOQuery2: TADOQuery;
    N4: TMenuItem;
    N5: TMenuItem;
    ActionList1: TActionList;
    saveas: TAction;
    SaveDialog1: TSaveDialog;
    RBAccess: TRadioButton;
    RBFireBird: TRadioButton;
    CB_RecordLength: TCheckBox;
    RBB: TRadioButton;
    RBE: TRadioButton;
    RBS: TRadioButton;
    Edit5: TEdit;
    CB_Channel: TCheckBox;
    Edit6: TEdit;
    WindowsMediaPlayer1: TWindowsMediaPlayer;
    MonitorClient1: TMonitorClient;
    ComboBox1: TComboBox;
    CheckBox1: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
    procedure PlayClient1ConnectHost(Sender: TObject; Success: Integer);
    procedure PlayClient1LoadFileComplete(Sender: TObject;
      const WaveFileName: WideString);

    procedure WindowsMediaPlayer1PlayStateChange(Sender: TObject;
      NewState: Integer);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure N1Click(Sender: TObject);
    procedure Btn_CloseClick(Sender: TObject);
    procedure CB_AgentClick(Sender: TObject);
    procedure CB_CallerIDClick(Sender: TObject);
    procedure CB_DTMFClick(Sender: TObject);
    procedure CB_PhoneNumClick(Sender: TObject);
    procedure CB_TimeAreaClick(Sender: TObject);
    procedure Btn_QueryClick(Sender: TObject);
    procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure N2Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure DBGrid1CellClick(Column: TColumn);
    procedure DBGrid1TitleClick(Column: TColumn);
    procedure saveasExecute(Sender: TObject);
    procedure PlayClient1QueryRecordCount(Sender: TObject; RecordCount,
      StartDate, EndDate, StartID: Integer);
    procedure CB_RecordLengthClick(Sender: TObject);
    procedure CB_ChannelClick(Sender: TObject);
    procedure PlayClient1VocFileLength(Sender: TObject;
      const VocFileName: WideString; VocFileLength: Integer);
    procedure FormResize(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure MonitorClient1MonitorPlay(Sender: TObject;
      const HostName: WideString; ChannelNO: Smallint;
      PlayKBytes: Integer);
    procedure ComboBox1Change(Sender: TObject);




  private
    { Private declarations }
    FSort,FSortField:String;//控制grid排序
    Procedure SearchData(sid,sType:string);
    Procedure ApplicationEvents1Message(var   Msg:   tagMSG;
          var   Handled:   boolean);
    Function GetIP(Name:string):String;
    Function SQLStrComb(dbtype:string):String;
    Procedure iniRead;
    Procedure iniLanguage;
    Procedure getsourceCtrl;
  public
    { Public declarations }
    procedure CreateParams(var Params: TCreateParams); override;
    Procedure RestoreRequest(var message: TMessage); message CM_RESTORE;
    Procedure showParam(sStr:string);
  end;

var
  Form1: TForm1;

implementation

uses Splash, Save2;

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WinClassName := MYAPPNAME;

end;

procedure TForm1.RestoreRequest(var message: TMessage);

//var
   // P:Array [0..255] of char;
   // i:integer;
   // s:string;

begin
  {GlobalGetAtomName(message.LParam, P,sizeof(P));
  for i:=0 to 255 do
  begin
    if P[i]=#0 then break;
    s :=s+P[i];
  end;
  }
if IsIconic(Application.Handle)  then
   Application.Restore
else
  Application.BringToFront;
 // showParam(s);

end;

{$R *.dfm}
 var
  sConnect:string;
  sSql:string;
  sSqlUpI:string;
  sSqlUpU:string;  
  sVlanDsn:string;
  sHostFileName:string;
  sLocalFileName:string;
  sIP:string;
  sSqlType:string;
  sPos:integer;
  sRewind:string;
  iniFileName:string;
  myinifile:TInifile;
//  sDateTimeType:string;
  sSaveAs,sSaveFileName:String;
  sDefaultDB:string;
  sLanguage:String;
  x1,y1,iControlcount:integer;
  cl,ct,cw,ch:array   [0..43]   of   real;//数组上限由可视控件数目而定   

//语言参数
sNoData,        // =没有查到数据!
sNoRecord,      // =无记录
sRecords,       // =记录数:
sTryToConnect,  // =尝试连接编号:
sCannotConect,  // =无法获得主机IP,无法收听录音
sStartConnect,  // =开始连接主机:
sConnectFail,   // =连接主机s%失败
sGettingFile,   // =获取录音文件中...
sSaveFileSuccess, // =文件保存成功
sGetFileSuccess, // =文件获取成功
sCurrentPlayID,  // =当前播放编号:
sGettingIP,      // =获取IP中...
sInputChannelNo,  // =请输入轨道编号!
sInputRecordLength, // =请输入录音时长!
sEndTimeBiggerStarttime,      //        =结束时间不能小于开始时间!
sPleaseSelectQueryParm,//=请选择条件!
sMoreThen1k,//=查询的记录超过1000条,是否细化条件后继续查询?
sinfo,//=提示
sFileCopy,//=文件复制
sFileNotExist,
sPlayOnebyOne,sBtn_OK, sQuerying:string;//=文件不存在
//
procedure TForm1.showParam(sStr:string);
begin
//  label1.Caption := sStr;
//SearchData(sStr,sSqlType);
end;

procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin

  Application.OnMessage:=ApplicationEvents1Message;
  //getsourceCtrl;
  self.Caption := MYAPPNAME;
  sSaveAs:='0';
  sLocalFileName:= ExtractFilePath(Application.ExeName)+'temp.wav';
  //ini文件读取
  iniRead;
  //初始化空间语言类型
  iniLanguage;
  //打开数据库
  ADOConnection1.ConnectionString :=sConnect;
  Try
//  ADOConnection1.Connected := true;
  except
//   Showmessage('aa'); 
  end;
  //设置mediaplayer位置
//  WindowsMediaPlayer1.Width :=781;
//  WindowsMediaPlayer1.Top  :=8;
//  WindowsMediaPlayer1.Height :=65;
///界面大小
{scaled:=true;
  if   (screen.width<>orignwidth)   then
  begin
  height:=longint(height)*longint
  (screen.height)   div   orignheight;
  width:=longint(width)*longint
  (screen.width)   div   orignwidth;
  scaleby(screen.width   ,   orignwidth);
//  scaleby(screen.height   ,   orignheight);
Form1.Height := height-50;
Form1.Width := Width-10;
Form1.Top := 1;
Form1.Left := 1;

  end;
}
scaled   :=   true;   
      if   (screen.width   <>   ScreenWidth)   then   
      begin   
          height   :=   longint(height)   *   longint(screen.height)   div   ScreenHeight;
          width   :=   longint(width)   *   longint(screen.width)   div   ScreenWidth;
          scaleBy(screen.width,   ScreenWidth);
      end;   

 for i:=ControlCount-1 downto   0   do
  TFooClass(Controls[i]).Font.Size:=(screen.width div 800)* TFooClass(Controls[i]).Font.Size;
End;

Procedure  TForm1.SearchData(sid,sType:string);
var
    StrLen:integer;
    snewSql:String;

begin

  StrLen:=Length(sSql);
  Adoquery1.SQL.Clear ;
  sNewSql:=sSql;

   //判断配置文件中是否有#号,如果有,则代表sql中需要引号隔离变量
  if sSqlType = '1' then
  begin
    Delete(snewSql,sPos,StrLen);
    sNewSql:=sNewSql +''''+ sid + '''';
  end
  else
    sNewSql:=sSql+Sid;
  try
  Adoquery1.SQL.Add(sNewSql );
  Adoquery1.Active := true;
  if Adoquery1.RecordCount <= 0 then
    begin
        Form2.Hide;
        Form2.Update;

      Showmessage(sNoData);
      StatusBar1.Panels[2].Text :=sNoRecord;
      dbgrid1.Enabled := false;
      StatusBar1.Panels[1].Text :=' ';

      exit;
    end
  else
    begin

      DbGrid1.Enabled :=True;
      //DBGrid1.Columns[0].Title.Caption   :=  '编号';
      //DBGrid1.Columns[1].Title.Caption   :=  '轨道号';
      //DBGrid1.Columns[2].Title.Caption   :=  '来电号码';
      //DBGrid1.Columns[3].Title.Caption   :=  '坐席名称';
      //DBGrid1.Columns[4].Title.Caption   :=  '分机号码';
      //DBGrid1.Columns[5].Title.Caption   :=  '电话按键';
      //DBGrid1.Columns[6].Title.Caption   :=  '开始时间';
      //DBGrid1.Columns[7].Title.Caption   :=  '结束时间';
      //DBGrid1.Columns[8].Title.Caption   :=  '录音总长';
      //DBGrid1.Columns[9].Title.Caption   :=  '文件名';//DBGrid1.Columns[6].Title.Caption   ;
      adoquery1.First ;
      StatusBar1.Panels[2].Text :=sRecords+inttostr(adoquery1.RecNo)+'/' +inttostr(Adoquery1.RecordCount);

    end;
    except
      Form2.Hide;
      Form2.Update;
      Form2.Free;
      Btn_Query.Enabled := true;
      exit;
    end;

end;

procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
//双击直接播放
  if ( Adoquery1.Active = false ) or ( Adoquery1.RecordCount <=0 ) then exit;
  WindowsMediaPlayer1.URL :='';
  StatusBar1.Panels[2].Text :=sRecords+inttostr(adoquery1.RecNo)+'/' +inttostr(Adoquery1.RecordCount);
  StatusBar1.Panels[0].Text :=sTryToConnect+dbedit2.text;
  //sIP:=GetIP(DBedit3.Text );  //host ip

  if trim(sIP) = '' then
  begin
    StatusBar1.Panels[1].Text :=sCannotConect;
    exit;
  end;
  StatusBar1.Panels[1].Text :=sStartConnect+sIP;
  playclient1.ConnectHost(sIP,sVlanDsn);

end;


procedure TForm1.PlayClient1ConnectHost(Sender: TObject; Success: Integer);
begin
  if Success = 0 then
  begin
//    PlayClient1.DisconnectHost ;
//    Playclient1.Handle  ;
    Dbgrid1.Cursor :=crDefault;
    if sSaveAs='1' then
    begin
      Form3.Label1.Caption  :=Format(sConnectFail,[sIP]);
      //Form3.Show;
      Form3.Update;
      Form3.BitBtn1.Caption :=sBtn_OK;
      Form3.BitBtn1.Visible := true;
    end;
    StatusBar1.Panels[1].Text :=Format(sConnectFail,[sIP]);
    exit;
  end;
  StatusBar1.Panels[1].Text :=sGettingFile;
  sHostFileName := trim( dbedit1.Text );

  if sSaveAs = '1' then
  begin
     Form3.Label1.Caption  :=sGettingFile;
     //Form3.Show;
     Form3.Update;
     if (VarToStr(playclient1.GetVoiceFile(sHostFileName,sSaveFileName))) = '-1' then
       StatusBar1.Panels[1].Text :=sGettingFile;
  end
  else
  begin
     if (VarToStr(playclient1.GetVoiceFile(sHostFileName,sLocalFileName))) = '-1' then
    StatusBar1.Panels[1].Text :=sGettingFile;
  end;


end;

procedure TForm1.PlayClient1LoadFileComplete(Sender: TObject;
  const WaveFileName: WideString);
begin
  if sSaveAs='1' then
  begin
    Form3.Label1.Caption  :=sSaveFileSuccess;
    //Form3.ShowModal;
    Form3.Update;
    Form3.Free ;
    Dbgrid1.Cursor :=crDefault;
    StatusBar1.Panels[1].Text :=sSaveFileSuccess;
    sSaveAs:='0';
  end
  else
  begin
    StatusBar1.Panels[1].Text :=sGetFileSuccess;
    windowsMediaplayer1.URL :=sLocalFileName;
    StatusBar1.Panels[0].Text :=sCurrentPlayID+DbEdit2.Text ;
    WindowsMediaplayer1.controls.play ;
  end;

end;



procedure TForm1.WindowsMediaPlayer1PlayStateChange(Sender: TObject;
  NewState: Integer);
begin

  if NewState = 1 then
  begin
  if sRewind = '1' then
  begin
    adoquery1.Next;
    while not adoquery1.Eof do

⌨️ 快捷键说明

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