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

📄 overtime.cpp

📁 visual c++与sql Server数据库开发考勤管理系统
💻 CPP
字号:
// Overtime.cpp: implementation of the COvertime class.
//
// 1 otDate char(10) 加班日期 Allow Null = False
// 2 EmpId int 员工编号 Allow Null = False
// 3 otHour smallint 加班时数 Allow Null = Faslse 默认值:1
// 4 otType varchar(50) 加班类型(法定节假日,周六日加班,日常加班) Allow Null = Fasle
// 5 Describes varchar(200) 描述 Allow Null = True
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CheckManage.h"
#include "Overtime.h"
#include "ADOConn.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

COvertime::COvertime()
{
	CTime CurrentTime;
	CurrentTime = CTime::GetCurrentTime();
	otDate = CurrentTime.Format("%Y-%m-%d");
	EmpId = 0;
	otHour = 1;
	otType = "";
	Describes = "";
}

COvertime::~COvertime()
{

}

// 判断是否存在此员工
bool COvertime::HaveEmp(CString paraDate, CString paraEmpId)
{
	// 连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	
	// 设置Select语句
	_bstr_t vSQL;
	vSQL = "SELECT * FROM Overtime WHERE otDate = '" + paraDate
		+ "' AND EmpId = " + paraEmpId;
	
	// 执行SQL语句
	_RecordsetPtr m_pRecordSet;
	m_pRecordSet = m_AdoConn.GetRecordSet(vSQL);
	
	// 判断是否存在此员工
	if(m_pRecordSet->adoEOF)
	{
		return FALSE;
	}
	else
	{
		return TRUE;
	}
}

// 插入操作
void COvertime::SqlInsert()
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	
	//设置INSERT语句
	CString strEmpId;
	strEmpId.Format("%ld", EmpId);
	CString strHour;
	strHour.Format("%ld", otHour);
	
	_bstr_t vSQL;
	vSQL = "INSERT INTO Overtime VALUES('"	+ otDate + "', " + strEmpId
		+ ", " + strHour + ", '" + otType + "', '" + Describes + "')";
	
	//执行INSERT语句
	m_AdoConn.ExecuteSQL(vSQL);
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}

// 得到信息
void COvertime::SqlUpdate(CString paraDate, CString paraEmpId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	
	//设置UPDATE语句
	CString strHour;
	strHour.Format("%ld", otHour);

	_bstr_t vSQL;
	vSQL = "UPDATE Overtime SET otHour = " + strHour + ", otType = '" + otType
		+ "', Describes = '" + Describes + "' WHERE otDate = '" + paraDate
		+ "' AND EmpId = " + paraEmpId;
	
	//执行UPDATE语句
	m_AdoConn.ExecuteSQL(vSQL);
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}

// 删除操作
void COvertime::SqlDelete(CString paraCheckDate, CString paraEmpId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();
	
	//设置DELETE语句
	_bstr_t vSQL;
	vSQL = "DELETE FROM Overtime WHERE CheckDate = '"+ paraCheckDate + "' AND EmpId = " + paraEmpId;
	
	//执行DELETE语句
	m_AdoConn.ExecuteSQL(vSQL);	
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
}

⌨️ 快捷键说明

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