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

📄 uform_record.pas

📁 电话防伪系统
💻 PAS
字号:
unit Uform_record;

interface

uses
  tw8a32,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, ComCtrls, ExtCtrls, StdCtrls, Buttons, Spin;

type
  Tform_record = class(TForm)
    Panel1: TPanel;
    listview: TListView;
    ImageList1: TImageList;
    BitBtn2: TBitBtn;
    StatusBar1: TStatusBar;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Label2: TLabel;
    Image3: TImage;
    Panel2: TPanel;
    Image1: TImage;
    Image2: TImage;
    Bevel3: TBevel;
    Bevel2: TBevel;
    Label3: TLabel;
    BitBtn4: TBitBtn;
    Label4: TLabel;
    ProgressBar1: TProgressBar;
    SpinEdit1: TSpinEdit;
    Label5: TLabel;
    Timer1: TTimer;
    Timer2: TTimer;
    Label7: TLabel;
    procedure BitBtn2Click(Sender: TObject);
    procedure listviewClick(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure ESitem(yn:boolean);
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    filename:string;
   phonecode:integer;
   stage:integer;
  end;

var
  form_record: Tform_record;

implementation

uses Uform_ex;

{$R *.dfm}

procedure Tform_record.BitBtn2Click(Sender: TObject);
begin
   close;
end;

procedure Tform_record.listviewClick(Sender: TObject);
begin
   //click the listview 2001-12-24
   if listview.selected=nil then exit;

   label4.Caption :=listview.Selected.Caption ;
   case listview.Selected.Index of
      0:
         label1.Caption :='欢迎您进入本系统,请输入您的产品防伪号';
      1:
         label1.Caption :='您输入的号码是';
      2:
         label1.caption :='零';
      3:
         label1.caption :='一';
      4:
         label1.caption :='二';
      5:
         label1.caption :='三';
      6:
         label1.caption :='四';
      7:
         label1.caption :='五';
      8:
         label1.caption :='六';
      9:
         label1.caption :='七';
      10:
         label1.caption :='八';
      11:
         label1.caption :='九';
      12:
         label1.caption :='您所输入的产品是';
      13:
         label1.caption :='正确请按1,重新输入请按2';
      14:
         label1.caption :='您的号码正确,此产品为真品';
      15:
         label1.caption :='您的号码正确,但此号码已经查询过,您的产品有可能是假的';
      16:
         label1.Caption :='您的号码不正确,此产品为假的';
      17:
         label1.Caption :='您的输入含有米字键或井字键';
   end;
end;

procedure Tform_record.BitBtn4Click(Sender: TObject);
begin
   //show the form_ex 2001_12_24
   form_ex.ShowModal ;
end;

procedure Tform_record.BitBtn1Click(Sender: TObject);

begin
   //record the phone 2001-12-24p

   if bitbtn1.Caption ='开始录音' then
   begin
      //know use whick phone
      if radiobutton1.Checked =true then phonecode:=0 else phonecode:=1;

      //know the file's name
      if listview.selected=nil then exit;
      filename:=inttostr(listview.Selected.Index) + 'sou.tw';

      //enabled the item
      ESitem(false);
      bitbtn1.Caption :='停止录音';
      bitbtn3.Enabled :=false;
      stage:=1;

      timer1.Enabled :=true;
   end
   else
   begin
      //enabled the item
      ESitem(true);
      bitbtn1.Caption :='开始录音';
      bitbtn3.Enabled :=true;
      stage:=1;
      tw_stoprecordfile(phonecode);
      tw_hangupctrl(phonecode);
      label7.Caption :='';
      timer1.Enabled :=false;
   end;

end;

procedure Tform_record.ESitem(yn:boolean);
begin
   //enable the item or vis the item 2001-12-14p
   listview.Enabled :=yn;
   spinedit1.Enabled :=yn;
   radiobutton1.Enabled :=yn;
   radiobutton2.Enabled :=yn;
   bitbtn2.Enabled :=yn;
end;
procedure Tform_record.Timer1Timer(Sender: TObject);
var
   temp:pchar;
   temp2:integer;
begin



   if stage=1 then
   begin
      if tw_ringdetect(phonecode) >1 then
      begin
         stage:=2;
         tw_offhookctrl(phonecode);
         temp:=pchar( ExtractFilePath(ParamStr(0)) + 'sound\' + filename);
         if fileexists(ExtractFilePath(ParamStr(0)) + 'sound\' + filename) then
         begin
            deletefile(ExtractFilePath(ParamStr(0)) + 'sound\' + filename);
         end;
         tw_startrecordfile(phonecode,temp,0,spinedit1.Value  *6448);
         label7.Caption :='开始录音';
      end;
   end;



   if stage=2 then
   begin
      temp2:=tw_recordfilerest(phonecode);
      temp2:=temp2* 100;
      temp2:= temp2 div (spinedit1.Value *6448);
      progressbar1.Position :=100 - temp2;
      if temp2=0 then
      begin
         ESitem(true);
         bitbtn1.Caption :='开始录音';
         bitbtn3.Enabled :=true;
         stage:=1;
         tw_hangupctrl(phonecode);
         label7.Caption :='';
         timer1.Enabled :=false;
      end;
   end;


end;

procedure Tform_record.BitBtn3Click(Sender: TObject);
begin
   //play the sound 2001-12-25p

   //know use whick phone
   if radiobutton1.Checked =true then phonecode:=0 else phonecode:=1;

   //know the file's name
   if listview.selected=nil then exit;
   filename:=inttostr(listview.Selected.Index) + 'sou.tw';

   if bitbtn3.Caption ='播   放' then
   begin
      ESitem(false);
      bitbtn1.Enabled :=false;
      bitbtn3.Caption :='停止放音';
      stage:=1;
      timer2.Enabled :=true;
   end
   else
   begin
      ESitem(true);
      bitbtn1.Enabled :=true ;
      bitbtn3.Caption :='播   放';
      stage:=1;
      timer2.Enabled :=false;

      if tw_playfilerest(phonecode)>0  then
      begin
         tw_stopPlayfile(phonecode);
      end;
      tw_hangupctrl(phonecode);
   end;

end;

procedure Tform_record.Timer2Timer(Sender: TObject);
var
   temp:pchar;
begin
   //the timer of play the sound 2001-12-25p

   if stage=1 then
   begin
      if tw_ringdetect(phonecode) >1 then
      begin
         tw_offhookctrl(phonecode);
         temp:=pchar( ExtractFilePath(ParamStr(0)) + 'sound\' + filename);
         //showmessage(ExtractFilePath(ParamStr(0)) + 'sound\' + filename);
         tw_startplayfile(phonecode,temp,0,0);
         //showmessage('kdjfkdf');
         stage:=2;
      end;
   end;
   if stage=2 then
   begin
      if tw_playfilerest(phonecode)=0 then
      begin
         ESitem(true);
         bitbtn1.Enabled :=true ;
         bitbtn3.Caption :='播   放';
         stage:=1;
         timer2.Enabled :=false;
         tw_hangupctrl(phonecode);
      end;
   end;   
end;

end.

⌨️ 快捷键说明

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