📄 vote.cpp
字号:
// Vote.cpp: implementation of the CVote class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Office.h"
#include "Vote.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVote::CVote()
{
}
CVote::~CVote()
{
}
CString CVote::GetStaff()
{
return staff;
}
COleDateTime CVote::GetPublishDate()
{
return publishDate;
}
CString CVote::GetContent()
{
return content;
}
void CVote::SetStaff(CString vStaff)
{
staff=vStaff;
}
void CVote::SetPublishDate(COleDateTime vPublishDate)
{
publishDate=vPublishDate;
}
void CVote::SetContent(CString vContent)
{
content=vContent;
}
void CVote::sqlInsert()
{
CString strSQL;
strSQL="select * from voteRecord";
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((COfficeApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
m_pRecordset->AddNew();
CString str;
m_pRecordset->PutCollect("staff",_variant_t(staff));
m_pRecordset->PutCollect("publishDate",_variant_t(publishDate));
m_pRecordset->PutCollect("content",_variant_t(content));
m_pRecordset->Update();
}
}
void CVote::sqlDelete(CString vContent)
{
CString strSQL;
strSQL="delete from voteRecord where content='";
strSQL=strSQL+vContent+"'";
(((COfficeApp*)AfxGetApp())->m_pConn)->Execute((_bstr_t)strSQL,NULL,adCmdText);
}
void CVote::sqlUpdate(CString vContent)
{
CString strSQL;
strSQL="select * from voteRecord where content='";
strSQL=strSQL+vContent+"'";
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((COfficeApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(!(m_pRecordset->adoEOF))
{
CString str;
m_pRecordset->PutCollect("staff",_variant_t(staff));
m_pRecordset->PutCollect("publishDate",_variant_t(publishDate));
m_pRecordset->PutCollect("content",_variant_t(content));
m_pRecordset->Update();
}
}
void CVote::GetData(CString vContent)
{
CString strSQL;
strSQL="select * from voteRecord where content='";
strSQL=strSQL+vContent+"'";
_RecordsetPtr m_pRecordset;
HRESULT hTRes;
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((COfficeApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
CString str;
staff= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staff"));
content= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("content"));
publishDate= m_pRecordset->GetCollect("publishDate");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -