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

📄 filllist.cpp

📁 本人为出租屋编写的电费管理程序,应用了MFC DAO链接了ACCESS数据库,利用可编辑的listctrl控件,综合考虑了多房间线损耗电的业务细节 和 界面皮肤美观,灵活方便的将物业电费管理轻松掌控.
💻 CPP
字号:
// FillList.cpp: implementation of the CFillList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "tempListCanEdited.h"

#include "FillList.h"

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

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

CFillList::CFillList()
{

}

CFillList::~CFillList()
{

}
//初始化数据库
bool CFillList::InitDB()
{
	if(m_database.IsOpen())
	{
		m_database.Close();
	}
	//CString str = "DRIVER={Microsoft.Jet.OLEDB.4.0};SERVER=.;Database=guanli;UID=;PWD=;";
    //CString str ="ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};UID=;PWD=;DBQ=guanli.mdb";
	CString str="DSN=guanli;DBQ=guanli.mdb;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=;";
	TRY 
	{
		m_database.OpenEx(str);
	}
	CATCH (CMemoryException, e)
	{
		AfxMessageBox(e->ReportError());
		return false;
	}
	END_CATCH
	
	 return true;	
}
//关闭数据库
 bool CFillList::CloseDB()
 {
 	if(m_database.IsOpen())
 	{
 		m_database.Close();
 		return true;
 	}
 	return false;
 }

CFillList::CFillListOnLastMonth()
{	
	
	lastMonthRD *record;
	lastMonthRDList.RemoveAll();
	CString str; 
    str.Format("Select houseNum,dianbiaoNum,dianFei,fentanFei from dianfeiGuanli where yuefen =%d",200806-1);
	
    CRecordset m_set(&m_database);
	
	m_set.Open(CRecordset::snapshot,str,CRecordset::none);
	
    
	
	CString house,dianbiao,fei,fentan;
	
	m_set.MoveFirst();
	while(!m_set.IsEOF())
	{
		record=new lastMonthRD;
		m_set.GetFieldValue("houseNum",house);
		//time.TrimRight();
		record->HouseNum=house;
		
		m_set.GetFieldValue("dianbiaoNum",dianbiao);
		//oprice.TrimRight();
		record->LMdianbiaoNum=atoi(dianbiao);
		
		m_set.GetFieldValue("dianFei",fei);
		//max.TrimRight();
		record->LMdianFei=(float)atof(fei);
		
		m_set.GetFieldValue("fentanFei",fentan);
		//min.TrimRight();
		record->LMfentanFei=(float)atof(fentan);
		
		lastMonthRDList.AddTail(*record);
		m_set.MoveNext();
	}
	m_set.Close();
//	CloseDB();
}

bool CFillList::Kongzhi(int yuefen,CString houseNum)
{
		CString kongzhi;
		kongzhi.Format(("select * from dianfeiGuanli where yuefen = %d and houseNum =%s") ,yuefen,houseNum) ;
	
		CRecordset m_set(&m_database);
		m_set.Open(CRecordset::snapshot,kongzhi,CRecordset::none);
		//	m_set.MoveFirst();
		//m_database.ExecuteSQL(kongzhi);
		
		
		return m_set.IsEOF();
		
		
}

CString CFillList::GetTotalNumOnLM(int yuefen)
{
	CString str;
	str.Format(("select * from zongbiao where 月份 = %d"),yuefen);

	CRecordset m_set(&m_database);
	m_set.Open(CRecordset::snapshot,str,CRecordset::none);

	CString TotalNumOnLM;
	m_set.GetFieldValue("总电表",TotalNumOnLM);
	
	return TotalNumOnLM;
}

⌨️ 快捷键说明

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