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

📄 inputqf.cpp

📁 DOS下一个完整的大型程序源代码
💻 CPP
字号:
#if !defined( __STRING_H )
#include <String.h>
#endif  // __STRING_H

#if !defined( __GRAPHICS_H )
#include <Graphics.h>
#endif  // __GRAPHICS_H

#if !defined( __STDLIB_H )
#include <StdLib.h>
#endif  // __STDLIB_H

#define Uses_DBase
#define Uses_Window
#define Uses_Field
#define Uses_Button
#include <ly.h>

#include "sj.h"
#include "sjdbf.h"
#include "sjcfg.h"

const
   winWidth     = 250,
   winHeight    = 233 - 30,
   winLeft      = 195,
   winTop       = 240 - winHeight / 2 + 5,

   tytleWidth   = 66 + 16,
   fieldWidth   = 159 - 16,

   ttTelLeft    = winLeft + 12,
   ttTelTop     = winTop + 38,
   fdTelLeft    = ttTelLeft + tytleWidth,
   fdTelTop     = ttTelTop - 4,
   fdTelWidth   = fieldWidth,

   ttQfLeft     = ttTelLeft,
   ttQfTop      = fdTelTop + 40,
   fdQfLeft     = ttQfLeft + tytleWidth,
   fdQfTop      = ttQfTop - 4,
   fdQfWidth    = fieldWidth,

   buttonSpace  = 12,
   buttonWidth  = 70,
   buttonHeight = 36,
   buttonTop    = fdQfTop + 37,

   btnAddLeft   = winLeft + buttonSpace,
   btnAddTop    = buttonTop,
   btnDelLeft   = 320 - buttonWidth / 2,
   btnDelTop    = buttonTop,
   btnPrintLeft = winLeft + winWidth - buttonWidth - buttonSpace,
   btnPrintTop  = buttonTop,

   btnExitLeft  = btnAddLeft,
   btnExitTop   = btnAddTop + buttonHeight + buttonSpace,
   btnHelpLeft  = btnPrintLeft,
   btnHelpTop   = btnExitTop;

static char *szHelp[] =
{
   "■电话号码最多为8位数              ",
   "■电话号码可以逐个添加或删除,按Enter",
   "  或选择〔添加〕添加,按<F2>或选择  ",
   "  〔删除〕删除                      ",
   "■按<F3>或选择〔打印〕打印电话号码与",
   "  欠费对照表                      ",
   "■按Esc或选择〔退出〕退出         ",
   NULL
};

static BOOL CheckTel( char *szTel )
{
   while( *szTel )
   {
      char ch = *szTel ++;
      if( ( ch < '0' || ch > '9' ) && ch != ' ' )
      {
         ShowError( "电话号码不正确" );
         return FALSE;
      }
   }
   return TRUE;
}

static BOOL CheckQf( char *szQf )
{
   double dQf = atof( szQf );
   if( dQf < 0 || dQf > 999999.99 )
   {
      ShowError( "欠费不正确" );
      return FALSE;
   }
   FormatMoney( dQf, szQf, flRChg );
   return TRUE;
}

static FILE* fpQfLlLog;
static void InitQfLlLog()
{
   fpQfLlLog = fopen( "Y:\\QfLl.dbf", "a" );
   if( fpQfLlLog == NULL )
     fpQfLlLog = fopen( "QfLl.dbf", "a" );
}

static void CloseQfLlLog()
{
   fclose( fpQfLlLog );
}

//工号   操作日期 操作时间 电话号码 项目       金额
//123456 97/12/12 12:12:12 12345678 1234 1234567.12
static void AddQfLlLog( char* szDutyNum, char* szTel, char* szItem, double dMoney )
{
   if( fpQfLlLog == NULL ) return;
   char szDate[ 9 ], szTime[ 9 ];
   GetDate( szDate );
   GetTime( szTime );
   fprintf( fpQfLlLog, "%s %s %s %s %s %10.2lf\n",
            szDutyNum, szDate, szTime, szTel, szItem, dMoney );
}

void SJ::InputQf()
{
   ShowError( "正式使用后不允许再录入欠费数据" );
   return;
}

/*
void SJ::InputQf()
{

   if( strlen( szDutyNum ) == 0 ) return;
   InitQfLlLog();
   dbfQf->Close();

   DBase::SetMaxRecAdd( 1000 );
   DBase *dbf = new DBase( szQfDbf );
   DBase::ResetMaxRecAdd();
   char szDate[ flQfDate + 1 ];
   struct date d;
   getdate( &d );
   d.da_year -= 1900;
   d.da_mon --;
   if( d.da_mon == 0 )
   {
      d.da_mon = 12;
      d.da_year --;
   }
   sprintf( szDate, "%02u/%02u", d.da_year, d.da_mon );

   Window *win = new Window( winTop, winWidth, winHeight, "欠费录入" );

   win->DrawTytle( ttTelLeft, ttTelTop, "电话号码", 'T' );
   char szTel[ flTel + 1 ];
   memset( szTel, ' ', flTel );
   szTel[ flTel ] = 0;
   Field *fdTelNum = new Field( fdTelLeft, fdTelTop, fdTelWidth, szTel, flTel );

   win->DrawTytle( ttQfLeft, ttQfTop, "    欠费", 'Q' );
   char szQf[ flRChg + 1 ];
   memset( szQf, ' ', flRChg );
   szQf[ flRChg ] = 0;
   Field *fdQf = new Field( fdQfLeft, fdQfTop, fdQfWidth, szQf, flRChg );

   enum
   {
      cmAdd = 0x1111,
      cmDel,
   };

   Button *btnAdd = new Button( btnAddLeft, btnAddTop, "添加", cmAdd, buttonWidth, buttonHeight );
   Button *btnDel = new Button( btnDelLeft, btnDelTop, "删除", cmDel, buttonWidth, buttonHeight );
   Button *btnPrint = new Button( btnPrintLeft, btnPrintTop, szBtnPrint, cmPrint, buttonWidth, buttonHeight );

   Button *btnExit = new Button( btnExitLeft, btnExitTop, szBtnExit, cmExit, buttonWidth, buttonHeight );
   Button *btnHelp = new Button( btnHelpLeft, btnHelpTop, tpHelpButton );

   win->Insert( fdTelNum, fdQf, btnAdd, btnDel, btnPrint,
                btnExit, btnHelp, NULL );

   ::ShowStatus( "~CF1~0帮助 ~CF2~0删除 ~CF3~0打印 ~CESC~0退出" );
   BOOL bChanged = FALSE;
   for(;;)
   {
      Event event;
      while( !GetEvent( event ) );
      win->HandleEvent( event );
      if( event.what == evKeyboard && event.key == kbF2 )
      {
         event.what = evCommand;
         event.command = cmDel;
      }
      else if( event.what == evKeyboard && event.key == kbF3 )
      {
         event.what = evCommand;
         event.command = cmPrint;
      }

      if( event.what == evCommand )
      {
         if( event.command == cmAdd || event.command == cmOk )
         {
            if( *szTel == ' ' ) { win->Reselect( fdTelNum ); continue; }
            if( *szQf == ' ' ) { win->Reselect( fdQf ); continue; }

            if( CheckTel( szTel ) && CheckQf( szQf ) )
            {
               int nRec = dbf->Seek( szTel );
               double dQf = atof( szQf );
               if( nRec >= 0 )
               {
                  AddQfLlLog( szDutyNum, szTel, "累加", dQf );

                  dQf += dbf->GetDouble( nRec, fdQfRChg );
                  dbf->Replace( nRec, fdQfRChg, dQf );
                  bChanged = TRUE;
                  ShowMessage( "电话号码存在, 原来的欠费被累加并替换" );
               }
               else
               {
                  AddQfLlLog( szDutyNum, szTel, "添加", dQf );

                  dbf->AppendRecord();
                  nRec = dbf->GetRecordNum() - 1;
                  dbf->Replace( nRec, fdQfTel, szTel );
                  dbf->Replace( nRec, fdQfDate, szDate );
                  dbf->Replace( nRec, fdQfRChg, szQf );
                  dbf->SortData();
                  bChanged = TRUE;
               }
            }
            fdTelNum->Clear();
            fdQf->Clear();
            win->Reselect( fdTelNum );
         }
         else if( event.command == cmDel )
         {
            if( *szTel == ' ' ) { win->Reselect( fdTelNum ); continue; }

            int nRec = dbf->Seek( szTel );
            if( nRec >= 0 )
            {
               AddQfLlLog( szDutyNum, szTel, "删除", dbf->GetDouble( nRec, fdQfRChg ) );

               dbf->DeleteRecord( nRec );
               bChanged = TRUE;
            }
            else ShowError( "没有这个电话号码" );
            fdTelNum->Clear();
            fdQf->Clear();
            win->Reselect( fdTelNum );
         }
         else if( event.command == cmPrint )
         {
            dbf->PrintAll( fdQfTel, fdQfRChg, -1 );
            win->Reselect( fdTelNum );
         }
         else if( event.command == cmExit ||
                  event.command == cmCancel ||
                  event.command == cmClose ) break;
         else if( event.command == cmHelp )
         {
            ShowHelp( szHelp );
            win->Reselect( fdTelNum );
         }
      }
   }
   delete win;
   delete dbf;
   dbfQf->Open();
   if( bChanged )
   {
      MakeCjDbf();
      SendYyDbf();
   }
   CloseQfLlLog;
}
*/

⌨️ 快捷键说明

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