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

📄 records.cpp

📁 类似于股市K线技术分析的系统源码
💻 CPP
字号:
// Records.cpp: implementation of the CRecords class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "LastProject.h"
#include "Records.h"
#include "maindlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRecords::CRecords(CString tablename,CString excode)
{
	int year = 1900,month = 1,day = 1,hour = 0,minute = 0,second = 0; 

	TableName = tablename;
	ExCode = excode;
	CDBVariant var;
	CDatabase db;
	CRecordset	rs;
	CString VAL,SQL;
	
//	char buf[20];
	SQL.Format("SELECT TOP %d * FROM %s WHERE ETypeCode='%s' ORDER BY UpDateTime DESC",MAXCOUNT,tablename,excode);
	SRecord node;



	try
	{
		db.OpenEx(DEFAULTDSN,CDatabase::noOdbcDialog);
		rs.m_pDatabase = &db;
		rs.Open(AFX_DB_USE_DEFAULT_TYPE,SQL);
		m_max = 0;
		m_min = 9999;
		//读取分析数据
		while(!rs.IsEOF())
		{
			rs.GetFieldValue("UpDateTime",var);
			//sprintf(buf,"%d-%d-%d",var.m_pdate->year,var.m_pDate->month,var.m_pDate->day);
			//sprintf(buf,"%d-%d-%d %d:%d:%d",var.m_pdate->year,var.m_pdate->month,var.m_pdate->day,var.m_pdate->hour,var.m_pdate->minute,var.m_pdate->second);
			//sscanf(buf,"%d-%d-%d %d:%d-%d",&year,&month,&day,&hour,&minute,&second);
			node.DateTime.SetDateTime(var.m_pdate->year,var.m_pdate->month,var.m_pdate->day,var.m_pdate->hour,var.m_pdate->minute,var.m_pdate->second);
			//rs.GetFieldValue("ChineseName",VAL);
			//node.CHNName  = VAL;
			rs.GetFieldValue("OpenPrice",VAL);
			node.open = atof(VAL);
			rs.GetFieldValue("ClosePrice",VAL);
			node.close = atof(VAL);
			rs.GetFieldValue("MaxPrice",VAL);
			node.max = atof(VAL);
			rs.GetFieldValue("MinPrice",VAL);
			node.min = atof(VAL);
			if(node.max>m_max) m_max = node.max;
			if(node.min<m_min) m_min = node.min; 
			m_records.push_front(node);
			rs.MoveNext();
		}
	}catch(CDBException *e)
	{
		e->ReportError();
	}
	if(rs.IsOpen())	rs.Close();
	if(db.IsOpen()) db.Close();


}

CRecords::~CRecords()
{
	if(m_records.size()>0) m_records.clear();
}

CString CRecords::GetCHNName()
{
	return "";
}

⌨️ 快捷键说明

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