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

📄 property.cpp

📁 企业办公管理系统, 企业办公管理系统
💻 CPP
字号:
// Property.cpp: implementation of the CProperty class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Office.h"
#include "Property.h"

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

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

CProperty::CProperty()
{

}

CProperty::~CProperty()
{

}

CString CProperty::GetPropertyType()
{
	return propertyType;
}
CString CProperty::GetPropertyID()
{
	return propertyID;
}
CString CProperty::GetPropertyName()
{
	return propertyName;
}
CString CProperty::GetUsers()
{
	return users;
}
CString CProperty::GetInsured()
{
	return insured;
}
CString CProperty::GetRemark()
{
	return remark;
}
COleDateTime CProperty::GetHoldDate()
{
	return holdDate;
}
int CProperty::GetNum()
{
	return num;
}
float CProperty::GetTotal()
{
	return total;
}

void CProperty::SetPropertyType(CString vPropertyType)
{
	propertyType=vPropertyType;
}
void CProperty::SetPropertyID(CString vPropertyID)
{
	propertyID=vPropertyID;
}
void CProperty::SetPropertyName(CString vPropertyName)
{
	propertyName=vPropertyName;
}
void CProperty::SetUsers(CString vUsers)
{
	users=vUsers;
}
void CProperty::SetInsured(CString vInsured)
{
	insured=vInsured;
}
void CProperty::SetRemark(CString vRemark)
{
	remark=vRemark;
}
void CProperty::SetHoldDate(COleDateTime vHoldDate)
{
	holdDate=vHoldDate;
}
void CProperty::SetNum(int vNum)
{
	num=vNum;
}
void CProperty::SetTotal(float vTotal)
{
	total=vTotal;
}
	
void CProperty::sqlInsert()
{
	CString strSQL;

	strSQL="select * from propertyRecord"; //构造sql查询语句
	_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("insured",_variant_t(insured));//投保情况
		m_pRecordset->PutCollect("holdDate",_variant_t(holdDate));//拥有日期
		str.Format("%d",num);//数量
		m_pRecordset->PutCollect("num",_variant_t(str));
		m_pRecordset->PutCollect("propertyID",_variant_t(propertyID));//财产编号
		m_pRecordset->PutCollect("propertyName",_variant_t(propertyName));//财产名称
		m_pRecordset->PutCollect("propertyType",_variant_t(propertyType));//财产类型
		m_pRecordset->PutCollect("remark",_variant_t(remark));//备注
		str.Format("%f",total);//金额
		m_pRecordset->PutCollect("total",_variant_t(str));
		m_pRecordset->PutCollect("users",_variant_t(users));//使用者

		m_pRecordset->Update();//将记录写入数据库
	}
}
void CProperty::sqlDelete(CString vPropertyID)
{
	CString strSQL;
	strSQL="delete from propertyRecord where propertyID='";
	strSQL=strSQL+vPropertyID+"'"; //构造删除指定财产编号的sql语句
	(((COfficeApp*)AfxGetApp())->m_pConn)->Execute((_bstr_t)strSQL,NULL,adCmdText);//执行sql语句
}
void CProperty::sqlUpdate(CString vPropertyID)
{
	CString strSQL;

	strSQL="select * from propertyRecord where propertyID='";
	strSQL=strSQL+vPropertyID+"'";//查询指定财产编号的财产信息的sql语句
	_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("insured",_variant_t(insured));//投保情况
		m_pRecordset->PutCollect("holdDate",_variant_t(holdDate));//拥有日期
		str.Format("%d",num);//数量
		m_pRecordset->PutCollect("num",_variant_t(str));
		m_pRecordset->PutCollect("propertyID",_variant_t(propertyID));//财产编号
		m_pRecordset->PutCollect("propertyName",_variant_t(propertyName));//财产名称
		m_pRecordset->PutCollect("propertyType",_variant_t(propertyType));	//财产类型
		m_pRecordset->PutCollect("remark",_variant_t(remark));//备注
		str.Format("%f",total);
		m_pRecordset->PutCollect("total",_variant_t(str));//金额
		m_pRecordset->PutCollect("users",_variant_t(users));//使用者
		m_pRecordset->Update();//更新到数据库
	}
}
void CProperty::GetData(CString vPropertyID)
{
	CString strSQL;

	strSQL="select * from propertyRecord where propertyID='";
	strSQL=strSQL+vPropertyID+"'";//构造查询指定财产编号的财产信息的sql语句
	_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;
		insured= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("insured"));//投保情况
		num= m_pRecordset->GetCollect("num").intVal;//数量
		holdDate= m_pRecordset->GetCollect("holdDate");//拥有日期
		propertyID= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("propertyID"));//财产编号	
		propertyName= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("propertyName"));//财产名称	
		propertyType= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("propertyType"));//财产类别
		remark= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("remark"));//备注
		total= m_pRecordset->GetCollect("total").dblVal;//金额
		users= ((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("users"));//使用者
	}
}

⌨️ 快捷键说明

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