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

📄 configrecordset.cpp

📁 考勤管理系统 使用VC++开发环境 ODBC数据库访问技术
💻 CPP
字号:
// ConfigRecordset.cpp : implementation file
//

#include "stdafx.h"
#include "CheckIn.h"
#include "ConfigRecordset.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CConfigRecordset

IMPLEMENT_DYNAMIC(CConfigRecordset, CRecordset)

CConfigRecordset::CConfigRecordset(CDatabase* pdb)
	: CRecordset(pdb)
{
	//{{AFX_FIELD_INIT(CConfigRecordset)
	m_ThresholdHour = 0;
	m_ThresholdMinute = 0;
	m_Delta = 0;
	m_nFields = 3;
	//}}AFX_FIELD_INIT
	m_nDefaultType = dynaset;
}


CString CConfigRecordset::GetDefaultConnect()
{
	return _T("ODBC;DSN=CheckIn");
}

CString CConfigRecordset::GetDefaultSQL()
{
	return _T("[tbConfig]");
}

void CConfigRecordset::DoFieldExchange(CFieldExchange* pFX)
{
	//{{AFX_FIELD_MAP(CConfigRecordset)
	pFX->SetFieldType(CFieldExchange::outputColumn);
	RFX_Long(pFX, _T("[ThresholdHour]"), m_ThresholdHour);
	RFX_Long(pFX, _T("[ThresholdMinute]"), m_ThresholdMinute);
	RFX_Long(pFX, _T("[Delta]"), m_Delta);
	//}}AFX_FIELD_MAP
}

/////////////////////////////////////////////////////////////////////////////
// CConfigRecordset diagnostics

#ifdef _DEBUG
void CConfigRecordset::AssertValid() const
{
	CRecordset::AssertValid();
}

void CConfigRecordset::Dump(CDumpContext& dc) const
{
	CRecordset::Dump(dc);
}
#endif //_DEBUG

BOOL CConfigRecordset::GetRegularTime(CTime &tmpTime)
/*从表tbConfig中取出上班时间*/
/*这个上班时间是规定的上班时间+浮动时间*/
{
	tmpTime = CTime::GetCurrentTime();
	try
	{
		if(!IsOpen())
			Open();
		tmpTime = CTime(tmpTime.GetYear(),tmpTime.GetMonth(),tmpTime.GetDay(),this->m_ThresholdHour,this->m_ThresholdMinute+this->m_Delta,59);
		return true;
	}
	catch(CDBException *e)
	{
		AfxMessageBox(e->m_strError );		
		return false;
	}
}

BOOL CConfigRecordset::AddConfigToTable(int hour, int minute, int delta)
{
	try
	{
		if(!IsOpen())
			Open();
		if (!this->IsBOF())//表明表中有记录,在增加新设置前,应首先删除旧设置
		{
			this->MoveFirst();
			this->Delete();
		}
		/*增加新设置*/
		this->AddNew();
		this->m_ThresholdHour = hour;
		this->m_ThresholdMinute = minute;
		this->m_Delta = delta;
		this->Update();		
	}
	catch(CDBException *e)
	{
		AfxMessageBox(e->m_strError );		
		return false;
	}
	return true;
}

⌨️ 快捷键说明

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