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

📄 exportdest.cpp.svn-base

📁 股票软件源码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
			if( m_bCanceled )	return;
		}
		ExportCloseTable( );
	}

	// Begin Export Min15
	if( pOption->m_bKMin15
		&& ExportOpenTable( stock, CKData::ktypeMin15, TRUE ) )
	{
		CKData	& kdata = stock.GetKDataMin15( );
		for( int k=0; k<kdata.GetSize(); k++ )
		{
			KDATA	kd	=	kdata.ElementAt(k);
			CStringArray	astrItemText;
			if( DoExportKDATAToStringArray( kd, astrItemText, FALSE, dateMinBegin, dateMinEnd, stock.GetStockInfo().DigitBit() ) )
				ExportAddItem( astrItemText );
			nCount	++;
			SetProgress( nProgressStart + (nProgressEnd-nProgressStart)*nCount/nTotal );
			if( m_bCanceled )	return;
		}
		ExportCloseTable( );
	}

	// Begin Export Min30
	if( pOption->m_bKMin30
		&& ExportOpenTable( stock, CKData::ktypeMin30, TRUE ) )
	{
		CKData	& kdata = stock.GetKDataMin30( );
		for( int k=0; k<kdata.GetSize(); k++ )
		{
			KDATA	kd	=	kdata.ElementAt(k);
			CStringArray	astrItemText;
			if( DoExportKDATAToStringArray( kd, astrItemText, FALSE, dateMinBegin, dateMinEnd, stock.GetStockInfo().DigitBit() ) )
				ExportAddItem( astrItemText );
			nCount	++;
			SetProgress( nProgressStart + (nProgressEnd-nProgressStart)*nCount/nTotal );
			if( m_bCanceled )	return;
		}
		ExportCloseTable( );
	}

	// Begin Export Min60
	if( pOption->m_bKMin60
		&& ExportOpenTable( stock, CKData::ktypeMin60, TRUE ) )
	{
		CKData	& kdata = stock.GetKDataMin60( );
		for( int k=0; k<kdata.GetSize(); k++ )
		{
			KDATA	kd	=	kdata.ElementAt(k);
			CStringArray	astrItemText;
			if( DoExportKDATAToStringArray( kd, astrItemText, FALSE, dateMinBegin, dateMinEnd, stock.GetStockInfo().DigitBit() ) )
				ExportAddItem( astrItemText );
			nCount	++;
			SetProgress( nProgressStart + (nProgressEnd-nProgressStart)*nCount/nTotal );
			if( m_bCanceled )	return;
		}
		ExportCloseTable( );
	}
}

BOOL CExportDest::DoExportKDATAToStringArray( KDATA & kd, CStringArray & astrItemText,
											BOOL bDayOrMin, DWORD dateBegin, DWORD dateEnd, int nDigitBits )
{
	if( bDayOrMin )
	{
		if( kd.m_date < dateBegin || kd.m_date > dateEnd )
			return FALSE;
	}
	else
	{
		if( kd.m_date % 100000000 < dateBegin % 100000000
			|| kd.m_date % 100000000 > dateEnd % 100000000 )
			return FALSE;
	}

	CString	strTemp;
	
	// Date
	CSPTime	sptime;
	sptime.FromStockTime( kd.m_date, bDayOrMin );
	strTemp	=	sptime.Format( "%Y-%m-%d" );
	astrItemText.Add( strTemp );

	CString strPriceFmt;
	strPriceFmt.Format( "%%.%df", nDigitBits );

	// Open
	strTemp.Format( strPriceFmt, kd.m_fOpen );
	astrItemText.Add( strTemp );

	// High
	strTemp.Format( strPriceFmt, kd.m_fHigh );
	astrItemText.Add( strTemp );

	// Low
	strTemp.Format( strPriceFmt, kd.m_fLow );
	astrItemText.Add( strTemp );

	// Close
	strTemp.Format( strPriceFmt, kd.m_fClose );
	astrItemText.Add( strTemp );

	// Amount
	strTemp.Format( "%u", DWORD(kd.m_fAmount/1000) );
	astrItemText.Add( strTemp );

	// Volume
	strTemp.Format( "%u", DWORD(kd.m_fVolume/100) );
	astrItemText.Add( strTemp );

	return TRUE;
}

void CExportDest::SetProgressRange( int nLower, int nUpper )
{
	if( nUpper > nLower )
	{
		m_ctrlProgress.SetWindowPos( NULL, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE );
		m_staticProgress.SetWindowPos( NULL, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE );
		m_ctrlProgress.SetRange32( nLower, nUpper );
	}
}

void CExportDest::SetProgress( int nPos )
{
	int	nLower = 0, nUpper = 100;
	m_ctrlProgress.GetRange( nLower, nUpper );

	if( nUpper > nLower )
	{
		m_ctrlProgress.SetPos( nPos );

		CString	strProgressNew;
		strProgressNew.Format( "%d%%", 100*nPos/(nUpper-nLower) );
		CString	strProgressOld;
		m_staticProgress.GetWindowText( strProgressOld );
		if( 0 != strProgressNew.Compare( strProgressOld ) )
			m_staticProgress.SetWindowText( strProgressNew );
	}
}

void CExportDest::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPageEx::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CExportDest)
	DDX_Control(pDX, IDC_ODBC_SOURCE, m_btnODBCSource);
	DDX_Control(pDX, IDC_ODBC_DEST, m_editODBCDest);
	DDX_Control(pDX, IDC_ODBC_CHECK, m_btnODBCCheck);
	DDX_Control(pDX, IDC_STATIC_PROGRESS, m_staticProgress);
	DDX_Control(pDX, IDC_PROGRESS, m_ctrlProgress);
	DDX_Control(pDX, IDC_CSV_EXPLORER, m_btnCsvExplorer);
	DDX_Control(pDX, IDC_CSV_DEST, m_editCsvDest);
	DDX_Control(pDX, IDC_CSV_CHECK, m_btnCsvCheck);
	DDX_Control(pDX, IDC_MDB_EXPLORER, m_btnMdbExplorer);
	DDX_Control(pDX, IDC_MDB_DEST, m_editMdbDest);
	DDX_Control(pDX, IDC_MDB_CHECK, m_btnMdbCheck);
	DDX_Control(pDX, IDC_TXT_EXPLORER, m_btnTxtExplorer);
	DDX_Control(pDX, IDC_TXT_DEST, m_editTxtDest);
	DDX_Control(pDX, IDC_TXT_CHECK, m_btnTxtCheck);
	DDX_Text(pDX, IDC_TXT_DEST, m_strTxtDest);
	DDX_Text(pDX, IDC_MDB_DEST, m_strMdbDest);
	DDX_Text(pDX, IDC_CSV_DEST, m_strCsvDest);
	DDX_Check(pDX, IDC_TXT_CHECK, m_bTxtCheck);
	DDX_Check(pDX, IDC_MDB_CHECK, m_bMdbCheck);
	DDX_Check(pDX, IDC_CSV_CHECK, m_bCsvCheck);
	DDX_Check(pDX, IDC_EXEONFINISH, m_bExeOnFinish);
	DDX_Check(pDX, IDC_ODBC_CHECK, m_bODBCCheck);
	DDX_Text(pDX, IDC_ODBC_DEST, m_strODBCDest);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CExportDest, CPropertyPageEx)
	//{{AFX_MSG_MAP(CExportDest)
	ON_BN_CLICKED(IDC_TXT_CHECK, OnTxtCheck)
	ON_BN_CLICKED(IDC_TXT_EXPLORER, OnTxtExplorer)
	ON_BN_CLICKED(IDC_MDB_CHECK, OnMdbCheck)
	ON_BN_CLICKED(IDC_MDB_EXPLORER, OnMdbExplorer)
	ON_BN_CLICKED(IDC_CSV_CHECK, OnCsvCheck)
	ON_BN_CLICKED(IDC_CSV_EXPLORER, OnCsvExplorer)
	ON_BN_CLICKED(IDC_ODBC_CHECK, OnODBCCheck)
	ON_BN_CLICKED(IDC_ODBC_SOURCE, OnOdbcSource)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExportDest message handlers

BOOL CExportDest::OnInitDialog() 
{
	CPropertyPageEx::OnInitDialog();
	
	// TODO: Add extra initialization here
	LoadProfile( );
	UpdateData( FALSE );

	// txt 
	m_btnTxtCheck.SetCheck( m_bTxtCheck );
	m_editTxtDest.EnableWindow( m_bTxtCheck );
	m_btnTxtExplorer.EnableWindow( m_bTxtCheck );
	int	nCheckID	=	IDC_EXPORT_OVERWRITE;
	if( !m_bOverwrite )
		nCheckID	=	IDC_EXPORT_APPEND;
	CheckRadioButton( IDC_EXPORT_OVERWRITE, IDC_EXPORT_APPEND, nCheckID );

	// mdb
	m_btnMdbCheck.SetCheck( m_bMdbCheck );
	m_editMdbDest.EnableWindow( m_bMdbCheck );
	m_btnMdbExplorer.EnableWindow( m_bMdbCheck );

	// Csv
	m_btnCsvCheck.SetCheck( m_bCsvCheck );
	m_editCsvDest.EnableWindow( m_bCsvCheck );
	m_btnCsvExplorer.EnableWindow( m_bCsvCheck );

	// ODBC
	m_btnODBCCheck.SetCheck( m_bODBCCheck );
	m_editODBCDest.EnableWindow( m_bODBCCheck );
	m_btnODBCSource.EnableWindow( m_bODBCCheck );

	// progress ctrl
	m_ctrlProgress.SetWindowPos( NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE );
	m_staticProgress.SetWindowPos( NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CExportDest::OnTxtCheck() 
{
	// TODO: Add your control notification handler code here
	int	nCheck	=	m_btnTxtCheck.GetCheck();
	m_editTxtDest.EnableWindow( nCheck );
	m_btnTxtExplorer.EnableWindow( nCheck );
}

void CExportDest::OnTxtExplorer() 
{
	// TODO: Add your control notification handler code here
	UpdateData( );

	CString	strTemp	=	AfxGetFileDirectoryExist( m_strTxtDest, (LPCTSTR)AfxGetProfile().GetExportPath() );

	if( AfxDoSelectDirectory( strTemp ) )
	{
		m_strTxtDest	=	strTemp;
		UpdateData( FALSE );
	}
}

void CExportDest::OnMdbCheck() 
{
	// TODO: Add your control notification handler code here
	int	nCheck	=	m_btnMdbCheck.GetCheck();
	m_editMdbDest.EnableWindow( nCheck );
	m_btnMdbExplorer.EnableWindow( nCheck );
}

void CExportDest::OnMdbExplorer() 
{
	// TODO: Add your control notification handler code here
	UpdateData( );

	CKSFileDialog dlg (FALSE, NULL, NULL, OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_ENABLESIZING,
		"Microsoft Access Database files (*.mdb)|*.mdb|All files (*.*)|*.*||", NULL);
	if( IDOK == dlg.DoModal() )
	{
		m_strMdbDest	=	dlg.GetPathName();
		UpdateData( FALSE );
	}
}

void CExportDest::OnCsvCheck() 
{
	// TODO: Add your control notification handler code here
	int	nCheck	=	m_btnCsvCheck.GetCheck();
	m_editCsvDest.EnableWindow( nCheck );
	m_btnCsvExplorer.EnableWindow( nCheck );
}

void CExportDest::OnODBCCheck() 
{
	// TODO: Add your control notification handler code here
	int	nCheck	=	m_btnODBCCheck.GetCheck();
	m_editODBCDest.EnableWindow( nCheck );
	m_btnODBCSource.EnableWindow( nCheck );
}

void CExportDest::OnCsvExplorer() 
{
	// TODO: Add your control notification handler code here
	UpdateData( );

	CString	strTemp	=	AfxGetFileDirectoryExist( m_strCsvDest, (LPCTSTR)AfxGetProfile().GetExportPath() );

	if( AfxDoSelectDirectory( strTemp ) )
	{
		m_strCsvDest	=	strTemp;
		UpdateData( FALSE );
	}
}

void CExportDest::OnOdbcSource() 
{
	// TODO: Add your control notification handler code here
	UpdateData( TRUE );

	if( m_exportdb.OpenODBCDB( NULL ) )
	{
		m_strODBCDest	=	m_exportdb.GetODBCConnect();
		UpdateData( FALSE );
	}
}

BOOL CExportDest::OnSetActive() 
{
	// TODO: Add your specialized code here and/or call the base class
	m_bExporting	=	FALSE;
	m_bCanceled		=	FALSE;

	CPropertySheetEx * pSheet = DYNAMIC_DOWNCAST( CPropertySheetEx, GetParent()	);
	if( pSheet )
	{
		pSheet->SetWizardButtons( m_dwButtonFlags );
		
		CWnd * pWnd = pSheet->GetDlgItem( ID_WIZNEXT );
		if( pWnd && ::IsWindow( pWnd->GetSafeHwnd() ) )
		{
			CString	strTemp;
			strTemp.LoadString( IDS_EXPORT_START );
			pWnd->SetWindowText( strTemp );
		}
	}

	// progress ctrl
	m_ctrlProgress.SetWindowPos( NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE );
	m_staticProgress.SetWindowPos( NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE );

	return CPropertyPageEx::OnSetActive();
}

LRESULT CExportDest::OnWizardBack() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CPropertyPageEx::OnWizardBack();
}

LRESULT CExportDest::OnWizardNext() 
{
	// TODO: Add your specialized code here and/or call the base class
	UpdateData( );

	CButton * pbtn		= (CButton *)GetDlgItem( IDC_EXPORT_OVERWRITE );
	if( pbtn )	m_bOverwrite	=	pbtn->GetCheck();

	if( !m_bTxtCheck && !m_bMdbCheck && !m_bCsvCheck && !m_bODBCCheck )
	{
		AfxMessageBox( IDS_EXPORTDB_NODEST, MB_OK | MB_ICONINFORMATION );
		return -1;
	}

	if( m_bTxtCheck && m_strTxtDest.GetLength() == 0 )
	{
		AfxMessageBox( IDS_EXPORTDB_NOTXTDEST, MB_OK | MB_ICONINFORMATION );
		return -1;
	}
	if( m_bMdbCheck && m_strMdbDest.GetLength() == 0 )
	{
		AfxMessageBox( IDS_EXPORTDB_NOMDBDEST, MB_OK | MB_ICONINFORMATION );
		return -1;
	}
	if( m_bCsvCheck && m_strCsvDest.GetLength() == 0 )
	{
		AfxMessageBox( IDS_EXPORTDB_NOCSVDEST, MB_OK | MB_ICONINFORMATION );
		return -1;
	}
	if( m_bODBCCheck && m_strODBCDest.GetLength() == 0 )
	{
		AfxMessageBox( IDS_EXPORTDB_NOODBCDEST, MB_OK | MB_ICONINFORMATION );
		return -1;
	}

	if( m_bTxtCheck )
	{
		CPathDialog::MakeSurePathExists( m_strTxtDest );
		m_strTxtDest	=	AfxGetFileDirectoryExist( m_strTxtDest, (LPCTSTR)AfxGetProfile().GetExportPath() );
	}
	if( m_bMdbCheck )
	{
		int nIndex = m_strMdbDest.Find( "." );
		if( -1 == nIndex )
			m_strMdbDest	+=	".mdb";
		else if( m_strMdbDest.GetLength()-1 == nIndex )
			m_strMdbDest	+=	"mdb";
	}
	if( m_bCsvCheck )
	{
		CPathDialog::MakeSurePathExists( m_strCsvDest );
		m_strCsvDest	=	AfxGetFileDirectoryExist( m_strCsvDest, (LPCTSTR)AfxGetProfile().GetExportPath() );
	}

	UpdateData( FALSE );

	// Store profile
	StoreProfile( );

	// Export
	DoExport( );

	return -1;
}

void CExportDest::OnCancel() 
{
	// TODO: Add your specialized code here and/or call the base class
	if( m_bExporting )
	{
		if( IDOK == AfxMessageBox( IDS_EXPORTDEST_CONFIRMCLOSE, MB_OKCANCEL|MB_ICONINFORMATION ) )
			m_bCanceled	=	TRUE;
		return;
	}
	CPropertyPageEx::OnCancel();
}


BOOL CExportDest::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( WM_KEYDOWN == pMsg->message && VK_RETURN == pMsg->wParam )
		return TRUE;
	return CPropertyPageEx::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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