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

📄 unit1.pas

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

  if CB_PhoneNum.Checked then
    begin
      if Trim(Edit4.Text ) <> '' then
      begin
         sExtID := '( PhoneNumber like ''%' + Trim(Edit4.Text ) + '%'' )';
         if sReturnSql <> '' then
           sReturnSql:=sReturnSql+ ' And ' + sExtID
         else
           sReturnSql:=sExtID;
      end;
    end
  else
    sExtID := '';
  if CB_TimeArea.Checked then
    begin
         sBDateTime := FormatDateTime('YYYY-MM-DD',(DateTimePicker1.Date ))+' '+FormatDateTime('HH:mm:ss',(DateTimePicker3.Time ));
         sEDateTime := FormatDateTime('YYYY-MM-DD',(DateTimePicker2.Date ))+' '+FormatDateTime('HH:mm:ss',(DateTimePicker4.Time ));
         //sTime := '( StartTime  between To_Date('+ sBDateTime +',yyyy-mm-dd hh:mm:ss) and To_Date('+ sEDateTime+',yyyy-mm-dd hh:mm:ss) )';
         sTime:=' (to_char(StartTime,''YYYY-MM-DD HH24:MI:SS'') Between  '''+sBDateTime + ''' and ''' +sEDateTime +''')';
         if sReturnSql <> '' then
           sReturnSql:=sReturnSql+ ' And '+ sTime
         else
           sReturnSql:=sTime;

    end
  else
    sTime := '';
  if (sReturnSql <> '') then
     sReturnSql := ' Where ' + sReturnSql
  else
     sReturnSql:= '';
 end;    ///orcale8i end of combine sql
   Result:=sReturnSql;

end;

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
 if   VARTOSTR(DBGrid1.DataSource.DataSet.FieldByName('keep').Value)  = '1'   then
      begin
      DBGrid1.Canvas.Font.Color   :=   clRed;
      DBGrid1.Canvas.Brush.Color:=clCream;
      end
    else
      begin
      DBGrid1.Canvas.Font.Color   :=   clNavy;
      DBGrid1.Canvas.Brush.Color:=clWhite;
      end;

    if ((State = [gdSelected]) or (State=[gdSelected,gdFocused]))     then
    begin
          DBGrid1.Canvas.Font.Color   :=   clWhite;
          DBGrid1.Canvas.Brush.Color:=clSkyBlue;
    end
    else
      begin
        //DBGrid1.Canvas.Brush.Color:=clWhite;
      end;

    DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);

end;

procedure TForm1.N2Click(Sender: TObject);
//var snewSql :string;

begin
  try
    if dbedit2.Text ='' then exit;
    Adoquery1.Edit;// := dsEdit;
    DbGrid1.DataSource.DataSet.FieldByName('keep').AsInteger  := 1;
    Adoquery1.Post ;
    Dbgrid1.Repaint ;
  except
    showmessage('标注失败!');
  end;

end;

procedure TForm1.N3Click(Sender: TObject);
var snewSql :string;
StrLen,sPos1:integer;
begin
  sPos1:=pos('#',sSqlUpU);
  StrLen:=Length(sSqlUpU);
  sNewSql:=sSqlUpI;
  if sPos1 > 1 then
  begin
    Delete(sNewSql,sPos1,StrLen);
    sNewSql:=sNewSql +''''+ trim(dbEdit2.Text ) + '''';
  end
  else
    sNewSql:=sSqlUpU+trim(dbEdit2.Text );
  try
    Adoquery1.Edit;// := dsEdit;
    DbGrid1.DataSource.DataSet.FieldByName('keep').AsInteger := 0;
    Adoquery1.Post ;
//    Adoquery1.ExecuteAction()
    Dbgrid1.Repaint ;
  except
    showmessage('标注失败!');
  end;


end;

procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin

if dbedit4.Text = '1' then
   dbgrid1.PopupMenu := PopupMenu3
else
   dbgrid1.PopupMenu := PopupMenu2;

end;




procedure TForm1.DBGrid1TitleClick(Column: TColumn);
  var
        iFieldCount:Integer;
  begin
      //进行点击Title排序
      if (adoquery1.Active = False) or (Adoquery1.RecordCount <= 0) then exit;
      for   iFieldCount   :=   0   to   DBGrid1.Columns.Count   -   1   do
      begin
            if   (Copy(DBGrid1.Columns[iFieldCount].Title.Caption,Length(DBGrid1.Columns[iFieldCount].Title.Caption)-1,2)   =   '▼')   or   (Copy(DBGrid1.Columns[iFieldCount].Title.Caption,Length(DBGrid1.Columns[iFieldCount].Title.Caption)-1,2)   =   '▲')   then
            begin
                  DBGrid1.Columns[iFieldCount].Title.Caption   :=   Copy(DBGrid1.Columns[iFieldCount].Title.Caption,1,Length(DBGrid1.Columns[iFieldCount].Title.Caption)-3);
                  break;
            end;
      end;
      if   Column.FieldName   =   FSortField   then
      begin
            if   FSort   =   'DESC'   then
                  FSort   :=   'ASC'
            else
                  FSort   :=   'DESC';
      end
      else   begin
          FSortField   :=   Column.FieldName;
          FSort   :=   'ASC';
      end;
      if   FSort   =   'ASC'   then
            Column.Title.Caption   :=   Column.Title.Caption   +   ' ▲'
      else
            Column.Title.Caption   :=   Column.Title.Caption   +   ' ▼';
      Adoquery1.Sort:=   Column.FieldName   +   '   '   +   FSort;
  end;

procedure TForm1.saveasExecute(Sender: TObject);
//var i:integer;
begin
if ( Adoquery1.Active = false ) or ( Adoquery1.RecordCount <=0 ) then exit;
 sHostFileName:= trim(dbedit1.Text); //
 sSaveFileName:=ReverseString(Copy((ReverseString(sHostFileName)),0,pos('\',(ReverseString(sHostFileName)))-1));
 //sSaveFileName:=((ReverseString(Trim(DBedit1.text)))

 SaveDialog1.FileName :=sSaveFileName;
 if  SaveDialog1.Execute then
 begin
    sSaveAs:='1';
    Dbgrid1.Cursor :=crHourGlass;
    Form3:=TForm3.Create(Application);
    Form3.Caption :=sFileCopy;
    Application.Title := MYAPPNAME;
    sSaveFileName:=SaveDialog1.FileName ;


    StatusBar1.Panels[2].Text :=sRecords+inttostr(adoquery1.RecNo)+'/' +inttostr(Adoquery1.RecordCount);
    StatusBar1.Panels[0].Text :=sTryToConnect+dbedit2.text;
    Form3.Label1.Caption  :=sGettingIP;
    Form3.Show;
    Form3.Update;

    //sIP:=GetIP(DBedit3.Text ); //host ip

    if trim(sIP) = '' then
    begin
      StatusBar1.Panels[1].Text :=sCannotConect;
      Form3.Label1.Caption  :=sCannotConect;
      //Form3.Show;
      Form3.Update;
      Form3.BitBtn1.Caption :=sBtn_OK;
      Form3.BitBtn1.Visible := true;
      Dbgrid1.Cursor :=crDefault;
      exit;
    end;
    Form3.Label1.Caption  :=sStartConnect+sIP;
    //Form3.Show;
    Form3.Update;

    StatusBar1.Panels[1].Text :=sStartConnect+sIP;
    playclient1.ConnectHost(sIP,sVlanDsn);

 end
 else
   sSaveAs:='0';

end;

procedure TForm1.PlayClient1QueryRecordCount(Sender: TObject; RecordCount,
  StartDate, EndDate, StartID: Integer);
begin
  showmessage(inttostr(RecordCount));
end;

procedure TForm1.iniRead;
begin
  iniFileName :=ExtractFilePath(paramstr(0))+'vlanplay.ini';
  myinifile:=TInifile.Create(iniFileName);
  sIP:= myinifile.readstring('HOST','IP','');
  //sConnect:=myinifile.readstring('ODBCString','String','');
  sDefaultDB:=myinifile.readstring('DataBase','Default','');
  sLanguage:=myinifile.readstring('Language','Default','');
  if  sDefaultDB  = '1' then //Access
     begin
       RBAccess.Checked := true;
       // sAccessIP:=myinifile.readstring('Access','HOSTIP','');
     end
  else if  sDefaultDB ='2' then //'2'://FireBird
     begin
       RBFireBird.Checked := True;
       sConnect:=Format(myinifile.readstring('FireBird','String',''),[sIP]);
     end;
  sSql:=myinifile.readstring('SQLCommand','String','');
  sRewind:=myinifile.readstring('ReWind','String','1');


  sPos:=pos('#',sSql);
  if sPos > 0 then
     sSqlType:='1'
  else
     sSqlType:='0';
  sVlanDsn:='VLanServer';

end;

procedure TForm1.CB_RecordLengthClick(Sender: TObject);
begin
if CB_RecordLength.checked then
   begin
     edit5.Enabled := true;
     RBB.Enabled := True;
     RBE.Enabled := True;
     RBS.Enabled := True;

     edit5.SetFocus ;
   end
else
   begin
     RBB.Enabled := False;
     RBE.Enabled := False;
     RBS.Enabled := False;
     edit5.Enabled := false;
   end;
end;

procedure TForm1.CB_ChannelClick(Sender: TObject);
begin
if CB_Channel.checked then
   begin
    edit6.Enabled := true;
    edit6.SetFocus ;
   end
else
   edit6.Enabled := false;
end;

procedure TForm1.PlayClient1VocFileLength(Sender: TObject;
  const VocFileName: WideString; VocFileLength: Integer);
begin
  if VocFileLength <= 0 then
     begin
     if sSaveAs = '1' then
        begin
         Form3.Label1.Caption := sFileNotExist;
         Form3.BitBtn1.Caption :=sBtn_OK;
         Form3.BitBtn1.Visible := true;
         DBgrid1.Cursor :=crDefault;
        end;
        StatusBar1.Panels[1].Text :=sFileNotExist;
     end;
end;

procedure TForm1.iniLanguage;
var LanguageINI:string;
    IniLanguageFile:TIniFile;
begin
  LanguageINI :=ExtractFilePath(paramstr(0))+sLanguage+'.ini';
  IniLanguageFile:=TInifile.Create(LanguageINI);
  //控件部分
  CB_Agent.Caption :=IniLanguageFile.ReadString('Translate','TAgent','Agent');
  CB_CallerID.Caption :=IniLanguageFile.ReadString('Translate','TCallerID','CallerID');
  CB_DTMF.Caption :=IniLanguageFile.ReadString('Translate','TDTMF','DTMF');
  CB_Channel.Caption :=IniLanguageFile.ReadString('Translate','TChannel','Channel');
  CB_PhoneNum.Caption :=IniLanguageFile.ReadString('Translate','TPhoneNum','PhoneNum');
  CB_TimeArea.Caption :=IniLanguageFile.ReadString('Translate','TTimeArea','DateTime');
  CB_RecordLength.Caption :=IniLanguageFile.ReadString('Translate','TRecordLength','RecordLength');
  Lb_StartTime.Caption := IniLanguageFile.ReadString('Translate','TStartTime','StartTime');
  Lb_EndTime.Caption := IniLanguageFile.ReadString('Translate','TEndTime','EndTime');
  RBB.Caption := IniLanguageFile.ReadString('Translate','TBig','>');
  RBE.Caption := IniLanguageFile.ReadString('Translate','TEqual','=');
  RBS.Caption := IniLanguageFile.ReadString('Translate','TSmall','<');
  Btn_Query.Caption :=IniLanguageFile.ReadString('Translate','TQuery','Query(&Q)');
  Btn_Close.Caption :=IniLanguageFile.ReadString('Translate','TClose','Close(&C)');
  DBGrid1.Columns[0].Title.Caption:=IniLanguageFile.ReadString('Translate','TID','ID');
  DBGrid1.Columns[1].Title.Caption:=IniLanguageFile.ReadString('Translate','TChannel','Channel');
  DBGrid1.Columns[2].Title.Caption:=IniLanguageFile.ReadString('Translate','TCallerID','CallerID');
  DBGrid1.Columns[3].Title.Caption:=IniLanguageFile.ReadString('Translate','TAgent','Agent');
  DBGrid1.Columns[4].Title.Caption:=IniLanguageFile.ReadString('Translate','TPhoneNum','PhoneNum');
  DBGrid1.Columns[5].Title.Caption:=IniLanguageFile.ReadString('Translate','TDTMF','DTMF');
  DBGrid1.Columns[6].Title.Caption:=IniLanguageFile.ReadString('Translate','TStartTime','StartTime');
  DBGrid1.Columns[7].Title.Caption:=IniLanguageFile.ReadString('Translate','TEndTime','EndTime');
  DBGrid1.Columns[8].Title.Caption:=IniLanguageFile.ReadString('Translate','TRecordLength','RecordLength');
  DBGrid1.Columns[9].Title.Caption:=IniLanguageFile.ReadString('Translate','TFileName','FileName');
  N2.Caption :=IniLanguageFile.ReadString('Translate','TN2','Mark As Important');
  N3.Caption :=IniLanguageFile.ReadString('Translate','TN3','Mark As unImportant');
  GroupBox4.Caption :=IniLanguageFile.ReadString('Translate','TGroupBox4','Query Parameter');
  N4.Caption :=IniLanguageFile.ReadString('Translate','TN4','Save As...');
  N5.Caption :=IniLanguageFile.ReadString('Translate','TN4','Save As...');
  sBtn_OK  :=IniLanguageFile.ReadString('Translate','TBtn_Ok','OK');
  sQuerying:=IniLanguageFile.ReadString('Translate','TLb_Querying','Querying ,Please Wait...');
  //消息部分
  sNoData := IniLanguageFile.ReadString('Message','MNoData','No Data!');      // =没有查到数据!
  sNoRecord := IniLanguageFile.ReadString('Message','MNoRecord','No Record!');     // =无记录
  sRecords  := IniLanguageFile.ReadString('Message','MRecords','Records:');     // =记录数:
  sTryToConnect := IniLanguageFile.ReadString('Message','MTryToConnect','Try To Connect:');  // =尝试连接编号:
  sCannotConect := IniLanguageFile.ReadString('Message','MCannotConect','Can not Connect Host'); // =无法获得主机IP,无法收听录音
  sStartConnect := IniLanguageFile.ReadString('Message','MStartConnect','Start Connect Host'); // =开始连接主机:
  sConnectFail  := IniLanguageFile.ReadString('Message','MConnectFail','Connect Host %s Fail'); // =连接主机s%失败
  sGettingFile  := IniLanguageFile.ReadString('Message','MGettingFile','Getting File...'); // =获取录音文件中...
  sSaveFileSuccess:= IniLanguageFile.ReadString('Message','MSaveFileSuccess','Save File Successed'); // =文件保存成功
  sGetFileSuccess := IniLanguageFile.ReadString('Message','MGetFileSuccess','Get File Successed');// =文件获取成功
  sCurrentPlayID := IniLanguageFile.ReadString('Message','MCurrentPlayID','Current Play ID:'); // =当前播放编号:
  sGettingIP   := IniLanguageFile.ReadString('Message','MGettingIP','Getting IP...');   // =获取IP中...
  sInputChannelNo := IniLanguageFile.ReadString('Message','MInputChannelNo','Please Input Channel!'); // =请输入轨道编号!
  sInputRecordLength := IniLanguageFile.ReadString('Message','MInputRecordLength','Please Input RecordLength!');// =请输入录音时长!
  sEndTimeBiggerStarttime := IniLanguageFile.ReadString('Message','MEndTimeBiggerStarttime','EndTime Must Later Than StartTime!');     //        =结束时间不能小于开始时间!
  sPleaseSelectQueryParm:= IniLanguageFile.ReadString('Message','MPleaseSelectQueryParm','Please Input Query Parameter');//=请选择条件!
  sMoreThen1k:= IniLanguageFile.ReadString('Message','MMoreThen1k','Records is More than 1000,go on this operate?');//=查询的记录超过1000条,是否细化条件后继续查询?
  sinfo:= IniLanguageFile.ReadString('Message','Minfo','Information');//=提示
  sFileCopy:= IniLanguageFile.ReadString('Message','MFileCopy','Copying File');//=文件复制
  sFileNotExist:= IniLanguageFile.ReadString('Message','MFileNotExist','File Not Exist');//=文件不存在
  sPlayOnebyOne:=IniLanguageFile.ReadString('Translate','TN1','Play One by One');
  if sRewind='1' then
    begin
      N1.Caption :='√'+sPlayOnebyOne
    end
  else
    begin
      N1.Caption := sPlayOnebyOne;
    end;
end;

procedure TForm1.FormResize(Sender: TObject);
var   x,y,i:integer;
  begin
  {x:=form1.ClientWidth;
  y:=form1.ClientHeight;

  for   i:=0   to   iControlcount - 1   do
  begin
        cl[i]:=cl[i]*x/x1;
        ct[i]:=ct[i]*y/y1;
        form1.Controls[i].Left:=round(cl[i]);
        form1.Controls[i].Top:=round(ct[i]);
        cw[i]:=cw[i]*x/x1;
        form1.Controls[i].Width:=round(cw[i]);
        ch[i]:=ch[i]*y/y1;
        form1.Controls[i].Height:=round(ch[i]);
  end;
  x1:=x;
  y1:=y;
  WindowsMediaPlayer1.Width :=Groupbox3.Width -8 ;
  WindowsMediaPlayer1.Left :=3;
  WindowsMediaPlayer1.Top  :=18;//Groupbox3.Top ;
  WindowsMediaPlayer1.Height :=Groupbox3.Height -8  ;
  WindowsMediaPlayer1.Repaint ;
  Groupbox3.Refresh ;
  }
end;

procedure TForm1.getsourceCtrl;

var   i:integer;
  begin
  //取窗体的原始大小
  iControlcount:=form1.ControlCount ;
  x1:=form1.ClientWidth;
  y1:=form1.ClientHeight;
  //取各控件的原始大小和位置
  for   i:=0   to   iControlcount -1   do
  begin
      cw[i]:=form1.Controls[i].Width;
      cl[i]:=form1.Controls[i].Left;
      ch[i]:=form1.Controls[i].Height;
      ct[i]:=form1.Controls[i].Top;
  end;

end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if checkbox1.Checked then
   MonitorClient1.Monitor(sIP,strtoint(Combobox1.Text ))
else
   MonitorClient1.StopMonitor ;
end;

procedure TForm1.MonitorClient1MonitorPlay(Sender: TObject;
  const HostName: WideString; ChannelNO: Smallint; PlayKBytes: Integer);
begin
showmessage('监听中,有声音吗?');
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
 // if MonitorClient1.
// PlayClient1.Monitor()
end;

end.

⌨️ 快捷键说明

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