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

📄 tdlgdatetime.cpp

📁 联通接收发送新程序
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "tdlgdatetime.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDlgDateTime *DlgDateTime;
//---------------------------------------------------------------------------
__fastcall TDlgDateTime::TDlgDateTime(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TDlgDateTime::CANCELClick(TObject *Sender)
{
  Close() ;
}
//---------------------------------------------------------------------------
void __fastcall TDlgDateTime::getlocaltimeClick(TObject *Sender)
{
  otime.GetLocalTime();
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;
  char s[20 ] ;
  sprintf( s,"%ld",otime.AbsDay());
  ABS -> SetTextBuf( s ) ;
  Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TDlgDateTime::AddClick(TObject *Sender)
{
  char d[ 20 ],h[20],m[20],s[20] ;
  short sd,sh,sm,ss;
  day    -> GetTextBuf( d,20 ) ;
  hour   -> GetTextBuf( h,20 ) ;
  minute -> GetTextBuf( m,20 ) ;
  second -> GetTextBuf( s,20 ) ;

  sd = atoi( d ) ;
  sh = atoi( h ) ;
  sm = atoi( m ) ;
  ss = atoi( s ) ;

  otimespan.Set( sd,sh,sm,ss ) ;
  sprintf(s,"%hd - %hd - %hd - %hd",sd,sh,sm,ss ) ;
  timespan -> SetTextBuf( s ) ;
  otime += otimespan ;
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;

  sprintf( s,"%ld",otime.AbsDay());
  ABS -> SetTextBuf( s ) ;

  Refresh();

//  Invalidate() ;
}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::MinusClick(TObject *Sender)
{
  char d[ 20 ],h[20],m[20],s[20] ;
  short sd,sh,sm,ss;
  day    -> GetTextBuf( d,20 ) ;
  hour   -> GetTextBuf( h,20 ) ;
  minute -> GetTextBuf( m,20 ) ;
  second -> GetTextBuf( s,20 ) ;

  sd = atoi( d ) ;
  sh = atoi( h ) ;
  sm = atoi( m ) ;
  ss = atoi( s ) ;

  otimespan.Set( sd,sh,sm,ss ) ;
  sprintf(s,"%hd - %hd - %hd - %hd",sd,sh,sm,ss ) ;
  timespan -> SetTextBuf( s ) ;
  otime -= otimespan ;
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;

  sprintf( s,"%ld",otime.AbsDay());
  ABS -> SetTextBuf( s ) ;

  //  Refresh();
  Invalidate() ;


}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::GetDateClick(TObject *Sender)
{
  char s1[20 ],s2[20];
  Date -> GetTextBuf(s1,9 ) ;
  Time -> GetTextBuf(s2,7 ) ;
  otime.SetDateTime(s1,s2 );
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;
  char s[20 ] ;
  sprintf( s,"%ld",otime.AbsDay());
  ABS -> SetTextBuf( s ) ;
  Refresh();
}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::PrintClick(TObject *Sender)
{
  FILE *pf = fopen( "Record__.log","a+" ) ;

  if( pf )
  {
    fprintf( pf,"\n----------Begin------------" ) ;
    OTime ts("21000101","000000" ) ;
    while(  otime < ts )
    {
      if( otime.GetMonth() == 1 && otime.GetDay() == 1 )
        fprintf( pf,"\n%s             %ld  %hd",otime.GetFormatedDate(),otime.AbsDay(),
                                otime.GetDayofWeek() ) ;
      else  if(otime.GetDay() == 1)
        fprintf( pf,"\n    %s        %ld   %hd",otime.GetFormatedDate(),otime.AbsDay(),
                                otime.GetDayofWeek() ) ;
      else
        fprintf( pf,"\n           %s    %ld  %hd",otime.GetFormatedDate(),otime.AbsDay(),
             otime.GetDayofWeek() ) ;

      Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
      DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;
      Refresh() ;
      otime += otimespan ;
    }
    fprintf( pf,"\n----------End------------" ) ;
    fclose( pf ) ;
  };
}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::Button1Click(TObject *Sender)
{//addyear
  char y[ 20 ];
  short year;
  EditVar    -> GetTextBuf( y,20 ) ;

  year = atoi( y ) ;

  otime .AddYear( year ) ;
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;

  Refresh();


}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::Button2Click(TObject *Sender)
{ //minusyear
  char y[ 20 ];
  short year;
  EditVar    -> GetTextBuf( y,20 ) ;

  year = atoi( y ) ;

  otime .MinusYear( year ) ;
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;

  Refresh();

}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::Button3Click(TObject *Sender)
{ //addday
  char y[ 20 ];
  short year;
  EditVar    -> GetTextBuf( y,20 ) ;

  year = atoi( y ) ;

  otime .AddMonth( year ) ;
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;


  Refresh();

}
//---------------------------------------------------------------------------

void __fastcall TDlgDateTime::Button4Click(TObject *Sender)
{
  char y[ 20 ];
  short year;
  EditVar    -> GetTextBuf( y,20 ) ;

  year = atoi( y ) ;

  otime .MinusMonth( year ) ;
  Disp -> SetTextBuf( otime.GetFormatedDate() ) ;
  DispTime -> SetTextBuf( otime.GetFormatedTime() ) ;


  Refresh();

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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