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

📄 createdb.cpp

📁 此程序为EVC编写的MIS系统
💻 CPP
字号:
// CreateDB.cpp: implementation of the CCreateDB class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "抄表系统.h"
#include "CreateDB.h"

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

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

CCreateDB::CCreateDB()
{
	//wtableflag=0;
	//operflag=0;
	//数据库卷变量赋值
	szname=L"\\FlashDisk\\PDA抄表系统数据库.cdb";
	dwFlags=OPEN_ALWAYS;
	//
	if(!OpenMountDBVol())		//装配数据库卷
		::AfxMessageBox(L"PDA抄表系统数据库文件目前无法使用!");

}

CCreateDB::~CCreateDB()
{
	CloseMountDBVol();
}
//////////////////////////////////////////////////////
//创建或者打开PDA售后服务系统数据卷
BOOL CCreateDB::OpenMountDBVol()
{
	BOOL result;
	result=CeMountDBVol(&pguid,szname,dwFlags);     //装配数据库卷
	return result;
}
BOOL CCreateDB::CloseMountDBVol()                     //卸载数据库卷
{
	BOOL result;
	result=CeUnmountDBVol(&pguid);
	return result;
}
///////////////////////////////////////////////////////
//设置抄表记录参数
SORTORDERSPECEX CCreateDB::DfWtableInfo()
{
	CEPROPID SortProp[3];
	SortProp[0]=MAKELONG(CEVT_LPWSTR,prop_01);   //按水表编号排序(升序)
	SortProp[1]=MAKELONG(CEVT_LPWSTR,prop_02);	//按用户名称排序(降序)
	SortProp[2]=MAKELONG(CEVT_LPWSTR,prop_03);	//按用户地址排序(降序)
	SORTORDERSPECEX SortInfo[3];
	SortInfo[0].wVersion=1;
	SortInfo[0].wNumProps =1;
	SortInfo[0].wKeyFlags=CEDB_SORT_UNIQUE;  //关键字的唯一
	SortInfo[0].rgPropID[0]=SortProp[0];
	//SortInfo[0].rgdwFlags [0]=CEDB_SORT_DESCENDING;
	SortInfo[1].wVersion=1;
	SortInfo[1].wNumProps =1;
	//SortInfo[1].wKeyFlags=CEDB_SORT_UNIQUE;  
	SortInfo[1].rgPropID[0]=SortProp[1];
	SortInfo[1].rgdwFlags [0]=CEDB_SORT_DESCENDING;
	SortInfo[2].wVersion=1;
	SortInfo[2].wNumProps =1;
	//SortInfo[2].wKeyFlags=CEDB_SORT_UNIQUE;  //关键字的唯一
	SortInfo[2].rgPropID[0]=SortProp[2];
	SortInfo[2].rgdwFlags [0]=CEDB_SORT_DESCENDING;

	pWtableInfo.wVersion=1;
	pWtableInfo.dwFlags=CEDB_VALIDCREATE;
	wcscpy(pWtableInfo.szDbaseName,writetableDB);
	//::AfxMessageBox (pOperInfo.szDbaseName);
	pWtableInfo.dwDbaseType=writetable_ID;
	pWtableInfo.wNumSortOrder=3;
	pWtableInfo.rgSortSpecs[0]=SortInfo[0];
	pWtableInfo.rgSortSpecs[1]=SortInfo[1];
	pWtableInfo.rgSortSpecs[2]=SortInfo[2];
	
	return SortInfo[0];

}
BOOL CCreateDB::openWriteDB1()
{
	SORTORDERSPECEX SortInfo;
	SortInfo.wVersion=1;
	SortInfo.wNumProps =1;
	//SortInfo[1].wKeyFlags=CEDB_SORT_UNIQUE;  
	SortInfo.rgPropID[0]=MAKELONG(CEVT_LPWSTR,prop_02);
	SortInfo.rgdwFlags[0] =CEDB_SORT_DESCENDING;
	writetable=0;
	writetbhandle=CeOpenDatabaseEx2(&pguid,&writetable,writetableDB,&SortInfo,CEDB_AUTOINCREMENT,NULL);
	if(writetbhandle==INVALID_HANDLE_VALUE)
		return FALSE;
	return TRUE;
}
BOOL CCreateDB::openWriteDB2()
{
	SORTORDERSPECEX SortInfo;
	SortInfo.wVersion=1;
	SortInfo.wNumProps =1;
	//SortInfo[1].wKeyFlags=CEDB_SORT_UNIQUE;  
	SortInfo.rgPropID[0]=MAKELONG(CEVT_LPWSTR,prop_03);
	SortInfo.rgdwFlags[0] =CEDB_SORT_DESCENDING;
	writetable=0;
	writetbhandle=CeOpenDatabaseEx2(&pguid,&writetable,writetableDB,&SortInfo,CEDB_AUTOINCREMENT,NULL);
	if(writetbhandle==INVALID_HANDLE_VALUE)
		return FALSE;
	return TRUE;
}
//设置抄表人员记录参数
SORTORDERSPECEX CCreateDB::DfOperInfo()
{
	SORTORDERSPECEX SortInfo[2];
	SortInfo[0].wVersion=1;
	SortInfo[0].wNumProps =1;
	SortInfo[0].wKeyFlags=CEDB_SORT_UNIQUE;  //关键字的唯一
	SortInfo[0].rgPropID[0]=MAKELONG(CEVT_LPWSTR,prop_10);
	//SortInfo[0].rgdwFlags [0]=CEDB_SORT_DESCENDING;
	SortInfo[1].wVersion=1;
	SortInfo[1].wNumProps =1;
	//SortInfo[1].wKeyFlags=CEDB_SORT_UNIQUE;  //关键字的唯一
	SortInfo[1].rgPropID[0]=MAKELONG(CEVT_LPWSTR,prop_11);
	//
	pOperInfo.wVersion=1;
	pOperInfo.dwFlags=CEDB_VALIDCREATE;
	wcscpy(pOperInfo.szDbaseName,operatorsDB);
	//::AfxMessageBox (pOperInfo.szDbaseName);
	pOperInfo.dwDbaseType=operators_ID;
	pOperInfo.wNumSortOrder=2;
	pOperInfo.rgSortSpecs[0]=SortInfo[0];
	pOperInfo.rgSortSpecs[1]=SortInfo[1];
	//
	
	return SortInfo[0];

}
BOOL CCreateDB::openOperator()
{
	SORTORDERSPECEX SortInfo;	
	SortInfo.wVersion=1;
	SortInfo.wNumProps =1;
	//SortInfo[1].wKeyFlags=CEDB_SORT_UNIQUE;  //关键字的唯一
	SortInfo.rgPropID[0]=MAKELONG(CEVT_LPWSTR,prop_11);
	//
	operators=0;
	operhandle=CeOpenDatabaseEx2(&pguid,&operators,operatorsDB,&SortInfo,CEDB_AUTOINCREMENT,NULL);
	if(operhandle==INVALID_HANDLE_VALUE)
		return FALSE;
	return TRUE;
}
///
//创建抄表记录
BOOL CCreateDB::CreateWtableDB()
{
	writetable=0;
	SORTORDERSPECEX WritetbInfo=DfWtableInfo();
	//::AfxMessageBox(writetableDB);
	writetbhandle=CeOpenDatabaseEx2(&pguid,&writetable,writetableDB,&WritetbInfo,CEDB_AUTOINCREMENT,NULL);
	if(writetbhandle==INVALID_HANDLE_VALUE)
	{
		writetable=CeCreateDatabaseEx2(&pguid,&pWtableInfo);
		if(writetable==0)
		{
			int error;
			TCHAR text[64];
			error=GetLastError();
			wsprintf(text,L"writeDb CEOID.error=%d(%x)",error,error);
			::AfxMessageBox(text);
			return FALSE;
		}
		writetbhandle=CeOpenDatabaseEx2(&pguid,&writetable,NULL,&WritetbInfo,CEDB_AUTOINCREMENT,NULL);
		if(writetbhandle==INVALID_HANDLE_VALUE)
		{
			int error;
			TCHAR text[64];
			error=GetLastError();
			wsprintf(text,L"writeDb CEOID.error=%d(%x)",error,error);
			::AfxMessageBox(text);
			return FALSE;
		}
	}
	return TRUE;
}
//
//创建抄表人员记录
BOOL CCreateDB::CreateOperDB()
{
	operators=0;
	SORTORDERSPECEX OperatorsInfo=DfOperInfo();
	CString str;
	operhandle=CeOpenDatabaseEx2(&pguid,&operators,operatorsDB,&OperatorsInfo,CEDB_AUTOINCREMENT,NULL);
	if(operhandle==INVALID_HANDLE_VALUE)
	{
		operators=CeCreateDatabaseEx2(&pguid,&pOperInfo);
		if(operators==0)
		{
			int error;
			TCHAR text[64];
			error=GetLastError();
			wsprintf(text,L"operDb Create.error=%d(%x)",error,error);
			::AfxMessageBox(text);
			return FALSE;
		}
		operhandle=CeOpenDatabaseEx2(&pguid,&operators,NULL,&OperatorsInfo,CEDB_AUTOINCREMENT,NULL);
		if(operhandle==INVALID_HANDLE_VALUE)
		{
			int error;
			TCHAR text[64];
			error=GetLastError();
			wsprintf(text,L"operDb Open.error=%d(%x)",error,error);
			::AfxMessageBox(text);
			return FALSE;
		}
	}
	return TRUE;
}
//创建抄表管理员数据库
BOOL CCreateDB::CreateManagerDB()
{
	CEDBASEINFOEX pManagerInfo;
	SORTORDERSPECEX SortInfo;
	SortInfo.wVersion=1;
	SortInfo.wNumProps =1;
	SortInfo.wKeyFlags=CEDB_SORT_UNIQUE;  
	SortInfo.rgPropID[0]=MAKELONG(CEVT_LPWSTR,prop_20);
	SortInfo.rgdwFlags[0] =CEDB_SORT_DESCENDING;
	//
	pManagerInfo.wVersion=1;
	pManagerInfo.dwFlags=CEDB_VALIDCREATE;
	wcscpy(pManagerInfo.szDbaseName,managerDB );
	pManagerInfo.dwDbaseType=manager_ID;
	pManagerInfo.wNumSortOrder=1;
	pManagerInfo.rgSortSpecs[0]=SortInfo;
	//
	manager=0;
	managerhandle=CeOpenDatabaseEx2(&pguid,&manager,managerDB,&SortInfo,CEDB_AUTOINCREMENT,NULL);
	if(managerhandle==INVALID_HANDLE_VALUE)
	{
		manager=CeCreateDatabaseEx2(&pguid,&pManagerInfo);
		if(manager==0)
		{
			int error;
			TCHAR text[64];
			error=GetLastError();
			wsprintf(text,L"ManagerDb Create.error=%d(%x)",error,error);
			::AfxMessageBox(text);
			return FALSE;
		}
		managerhandle=CeOpenDatabaseEx2(&pguid,&manager,NULL,&SortInfo,CEDB_AUTOINCREMENT,NULL);
		if(managerhandle==INVALID_HANDLE_VALUE)
		{
			int error;
			TCHAR text[64];
			error=GetLastError();
			wsprintf(text,L"ManagerDb Open.error=%d(%x)",error,error);
			::AfxMessageBox(text);
			return FALSE;
		}
	}
	return TRUE;

}

⌨️ 快捷键说明

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