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

📄 yy.cpp

📁 电信语音系统源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//----------------------------------------------------------------------------
// 语音系统 - (C) Copyright 1997, 1997 by SCGT
//   Yy\Yy.cpp
//   源程序
//----------------------------------------------------------------------------
#include <owl\owlpch.h>

#include "Util.h"   // 工具
#include "Dbase.h"  // 数据库
#include "Yy.rc"    // 资源定义
#include "Yy.h"
#include "Tele.h"
//
// 系统名称、版本、标题、配置文件名、帮助
//
static char szAppName[] = "Yy";
static char szAppVersion[] = "2.0";
static char szAppTytle[] = "邮电语音系统\n(话费催缴、话费查询语音系统)";
static char szAppCfg[] = "Yy.cfg";
static char szAppHelp[] =
   "■您可以按ALT+F4或选择〔系统〕菜单下的\n"
   "  〔退出〕以退出本系统\n"
   "■窗口上部为标题栏,标题栏下为菜单条,本\n"
   "  系统的所有功能都可以通过用鼠标选择菜单\n"
   "  来完成。使用每个功能都可以获取帮助\n"
   "■窗口底部为提示栏,提示几个常用的功能键\n"
   "  还显示出当前的日期和时间";


// CJ.DBF
char
   FDCJ_TEL[]   = "TEL",
   FDCJ_CNO[]   = "CNO",
   FDCJ_TYPE[]  = "TYPE",
   FDCJ_TOTAL[] = "TOTAL",
   FDCJ_TIMES[] = "TIMES";

// CJFREE.DBF
char
   FDCJFREE_TEL[] = "TEL";

DBase *dbfCx, *dbfUser, *dbfCj, *dbfCjFree;

Config config;  // 系统配置

//
// 读入系统配置
//
void ReadConfig()
{
   FILE *fp = fopen( szAppCfg, "rb" );
   if( fp == NULL )
      ShowError( "配置丢失,需要管理员重新配置" );
   else
   {
      fread( &config, sizeof( Config ), 1, fp );
      fclose( fp );
   }
   InitPassword( config.szPassword );  // WinUtil要求知道密码存在哪

   DBase* dbfSysIni = new DBase( GetNetFile( fnSysIniDbf ) );
   config.nTelLen = dbfSysIni->GetInt( FDSYSINI_TELLEN  );
   delete dbfSysIni;
}

//
// 保存系统配置
//
void SaveConfig()
{
   FILE *fp = fopen( szAppCfg, "wb" );
   fwrite( &config, sizeof( Config ), 1, fp );
   fclose( fp );
}

//
// 系统类
//
class Yy : public MFrameWindow
{
     static void ShowStatus();  // 显示系统提示
   public:
     Yy( char* szTytle ) : MFrameWindow( szTytle ) {}
     ~Yy();

   protected:
     void SetupWindow();
     BOOL CanClose() { return CheckPassword(); }
     void EvTimer( UINT );

     //
     // 响应菜单项:
     //   设置密码(要求先输入正确的密码)
     //   系统帮助
     //   系统信息
     //
     void CmCjPause();
     void CmCxPause();

     void CmSetPassword() { if( CheckPassword() ) SetPassword(); }
     void CmSetCjTime();
     void CmSetCjFree();
     void CmResetCj();

     void CmHelp() { ShowHelp( szAppHelp ); }
     void CmAbout() { About( szAppTytle, szAppVersion ); }

   DECLARE_RESPONSE_TABLE( Yy );
};

DEFINE_RESPONSE_TABLE1( Yy, TFrameWindow )
   EV_WM_TIMER,
   EV_COMMAND( CM_CJPAUSE, CmCjPause ),
   EV_COMMAND( CM_CXPAUSE, CmCxPause ),
   EV_COMMAND( CM_SETPASS, CmSetPassword ),
   EV_COMMAND( CM_SETCJTIME, CmSetCjTime ),
   EV_COMMAND( CM_SETCJFREE, CmSetCjFree ),
   EV_COMMAND( CM_RESETCJ, CmResetCj ),
   EV_COMMAND( CM_HELP, CmHelp ),
   EV_COMMAND( CM_ABOUT, CmAbout ),
END_RESPONSE_TABLE;

void Yy::EvTimer( UINT )
{
   MMsg msg;
   GetTeleMsg( msg );
}

BOOL bCjPause = FALSE;
BOOL bCxPause = FALSE;
void Yy::CmCjPause()
{
   TMenu menu( *this );
   if( !bCjPause )
   {
      if( CheckPassword() )
      {
         menu.ModifyMenu( CM_CJPAUSE, MF_BYCOMMAND, CM_CJPAUSE, "催缴继续(&J)" );
         bCjPause = TRUE;
      }
   }
   else
   {
      menu.ModifyMenu( CM_CJPAUSE, MF_BYCOMMAND, CM_CJPAUSE, "催缴暂停(&J)..." );
      bCjPause = FALSE;
   }
}

void Yy::CmCxPause()
{
   TMenu menu( *this );
   if( !bCxPause )
   {
      if( CheckPassword() )
      {
         menu.ModifyMenu( CM_CXPAUSE, MF_BYCOMMAND, CM_CXPAUSE, "查询继续(&X)" );
         bCxPause = TRUE;
      }
   }
   else
   {
      menu.ModifyMenu( CM_CXPAUSE, MF_BYCOMMAND, CM_CXPAUSE, "查询暂停(&X)..." );
      bCxPause = FALSE;
   }
}

class CjCxDialog : public TDialog
{
     RECT rcWindow;
     char* szTytle;
   protected:
     void SetupWindow();
     HBRUSH EvCtlColor( HDC hDC, HWND hWndChild, UINT uCtlType );
     //BOOL CanClose() { return FALSE; }

   public:
     CjCxDialog( int nLeft, int nTop, int nWidth, int nHeight, char* szTytle );
     void ShowStatus( char* szStatus ) { SetDlgItemText( IDE_STATUS, szStatus ); }
     void ShowTable( char** szTable )
     {
        ::HideCaret( GetDlgItem( IDE_TABLE ) );
        ShowText( GetDlgItem( IDE_TABLE ), szTable );
     }

   DECLARE_RESPONSE_TABLE( CjCxDialog );
};

DEFINE_RESPONSE_TABLE1( CjCxDialog, TDialog )
   EV_WM_CTLCOLOR,
END_RESPONSE_TABLE;

CjCxDialog::CjCxDialog( int nLeft, int nTop, int nWidth, int nHeight, char* szTt ) :
   TDialog( GetMainWindow(), "CjCxDialog" )
{
   szTytle = szTt;

   rcWindow.left   = nLeft;
   rcWindow.top    = nTop;
   rcWindow.right  = nLeft + nWidth;
   rcWindow.bottom = nTop + nHeight;
}

void CjCxDialog::SetupWindow()
{
   MoveWindow( rcWindow, FALSE );
   RECT rc;
   ::GetWindowRect( GetDlgItem( IDS_TYTLE ), &rc );
   int nSpace       = 5,
       nWinWidth    = rcWindow.right - rcWindow.left,
       nWinHeight   = rcWindow.bottom - rcWindow.top,
       nTytleLeft   = nSpace,
       nTytleTop    = nSpace,
       nTytleWidth  = rc.right - rc.left,
       nTytleHeight = rc.bottom - rc.top - 3,

       nStatusLeft  = nTytleLeft + nTytleWidth + nSpace - 1,
       nStatusTop   = nTytleTop,
       nStatusWidth = nWinWidth - 3 * nSpace - nTytleWidth + 1,
       nStatusHeight= nTytleHeight,

       nTableLeft   = nSpace,
       nTableTop    = nTytleTop + nTytleHeight + nSpace - 1,
       nTableWidth  = nWinWidth - 2 * nSpace,
       nTableHeight = nWinHeight - 3 * nSpace - nTytleHeight + 1;
   ::MoveWindow( GetDlgItem( IDS_BORDER1 ), 0, 0, nWinWidth, nWinHeight, FALSE );
   ::MoveWindow( GetDlgItem( IDS_BORDER2 ), 1, 1, nWinWidth - 2, nWinHeight - 2, FALSE );

   ::MoveWindow( GetDlgItem( IDE_TYTLE ), nTytleLeft, nTytleTop, nTytleWidth, nTytleHeight, FALSE );
   ::MoveWindow( GetDlgItem( IDE_STATUS ), nStatusLeft, nStatusTop, nStatusWidth, nStatusHeight, FALSE );
   ::MoveWindow( GetDlgItem( IDE_TABLE ), nTableLeft, nTableTop, nTableWidth, nTableHeight, FALSE );

   ::MoveWindow( GetDlgItem( IDS_TYTLE ), nTytleLeft - 1, nTytleTop - 1, nTytleWidth + 2, nTytleHeight + 2, FALSE );
   ::MoveWindow( GetDlgItem( IDS_STATUS ), nStatusLeft - 1, nStatusTop - 1, nStatusWidth + 2, nStatusHeight + 2, FALSE );
   ::MoveWindow( GetDlgItem( IDS_TABLE ), nTableLeft - 1, nTableTop - 1, nTableWidth + 2, nTableHeight + 2, FALSE );

   SetDlgItemText( IDE_TYTLE, szTytle );
   SendDlgItemMessage( IDE_TABLE, WM_SETFONT, ( WORD )GetStockObject( SYSTEM_FIXED_FONT ), 0l );
   TDialog::SetupWindow();
}

HBRUSH CjCxDialog::EvCtlColor( HDC hDC, HWND hWndChild, UINT uCtlType )
{
   if( uCtlType != CTLCOLOR_STATIC )
      return TDialog::EvCtlColor( hDC, hWndChild, uCtlType );
   SetBkColor( hDC, COLOR7 );
   if( hWndChild == GetDlgItem( IDE_TYTLE ) )
      SetTextColor( hDC, COLORD );
   else if( hWndChild == GetDlgItem( IDE_STATUS ) )
      SetTextColor( hDC, COLORE );
   else if( hWndChild == GetDlgItem( IDE_TABLE ) )
      SetTextColor( hDC, COLOR9 );
   return ( HBRUSH )GetStockObject( LTGRAY_BRUSH );
}

const
  cjWinWidth  = 20 * 8 + 20,
  cxWinWidth  = 48 * 8 + 20,

  cjWinHeight = 12 * 16 + 20 + 12 + 3,
  winSpace    = ( 640 - cjWinWidth - cxWinWidth ) / 3,
  cjWinLeft   = winSpace,
  cjWinTop    = ( 480 - 70 - cjWinHeight ) / 2 + 5,

  cxWinHeight = cjWinHeight,
  cxWinLeft   = cjWinLeft + cjWinWidth + winSpace,
  cxWinTop    = cjWinTop;

static CjCxDialog* cjWin;
static CjCxDialog* cxWin;
void ShowCjStatus( char* szStatus ) { cjWin->ShowStatus( szStatus ); }
void ShowCxStatus( char* szStatus ) { cxWin->ShowStatus( szStatus ); }
void ShowCjTable( char** szTable ) { cjWin->ShowTable( szTable ); }
void ShowCxTable( char** szTable ) { cxWin->ShowTable( szTable ); }

//
// 系统初始化
//
void Yy::SetupWindow()
{
   if( !InitTele() ) ShowError ( "语音卡驱动程序未安装" );

   dbfCx = new DBase( GetNetFile( fnSjDbf ), FDCX_CNO );
   dbfUser = new DBase( GetNetFile( fnUserDbf ), FDUSER_TEL, FDUSER_CNO );
   dbfUser->TagSelect( FDUSER_CNO );
   dbfUser->GoBottom();
   config.nCNoLen = strlen( RightTrim( dbfUser->GetStr( FDUSER_CNO ) ) );
   dbfCj = new DBase( GetNetFile( "Cj.dbf" ) );
   dbfCjFree = new DBase( "CJFREE.DBF", FDCJFREE_TEL );

   MFrameWindow::SetupWindow();
   InitStatus();  // 初始化状态条
   ShowStatus();  // 显示系统提示

   cjWin = new CjCxDialog( cjWinLeft, cjWinTop, cjWinWidth, cjWinHeight, "催缴系统" );
   cxWin = new CjCxDialog( cxWinLeft, cxWinTop, cxWinWidth, cxWinHeight, "查询系统" );
   cjWin->Create();
   cxWin->Create();

   InitCj();
   InitCx();
   SetTimer( 100, 50 );
}

//
// 系统退出
//
Yy::~Yy()
{
   KillTimer( 100 );
   CloseCj();
   CloseCx();
   delete cjWin;
   delete cxWin;

   delete dbfCx;
   delete dbfUser;
   delete dbfCj;
   delete dbfCjFree;
   SaveConfig();  // 保存系统配置
}

//
// 显示系统提示
//
void Yy::ShowStatus()
{
   ::ShowStatus( "~CF1~0帮助 ~CALT+F4~0退出" );
}

class SetCjTimeDialog : public MDialog
{
     void ResetFocus() { ::SetFocus( GetDlgItem( IDE_SEG1 ) ); }
   protected:
     void SetupWindow();

     void CmOk();

⌨️ 快捷键说明

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