Welcome to tiger's blog!

What lead to success, what we are seeking...
posts - 47, comments - 23, trackbacks - 0, articles - 8
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

WinCE数据库操作之CeCreateDatabaseEx

Posted on 2007-01-09 12:17 tiger 阅读(1551) 评论(0)  编辑 收藏 引用

        与CCeDBDatabase类数据库相比,CeCreateDatabaseEx具有独特的优势,其创建路径可以指定的特性决定了其数据可以永久保存的固有优势,但相比CCeDBDatabase类数据库而言,CeCreateDatabaseEx完全应用api函数操作,其操作也相对复杂一些。
Records允许的9种数据类型:
                

                      数据类型                             描述

IVal

2-byte signed integer

UiVal

2-byte unsigned integer

LVal

4-byte signed integer

UlVal

4-byte unsigned integer

FILETIME

A time and date structure

LPWSTR

0-terminated Unicode string

CEBLOB

A collection of bytes

BOOL

Boolean

Double

8-byte signed value


虽然CeCreateDatabaseEx由于直接操作api函数而使得其相对复杂,但将其封装后最终的用户就不会觉察,其下是我在使用过程中封装的几个类,仅供参考:
// InfoIndexYCBase.h: interface for the CInfoIndexYCBase class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_INFOINDEXYCBASE_H__4AC91339_5B2C_4BF0_A721_5E97AD849B2C__INCLUDED_)
#define AFX_INFOINDEXYCBASE_H__4AC91339_5B2C_4BF0_A721_5E97AD849B2C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CInfoIndexYCBase 
{
public:
 CInfoIndexYCBase();
 virtual ~CInfoIndexYCBase();

public:
 CString ViewParam(void); //查看结构体内容

protected:
 enum{YCCOUNT = 13, STANDBYCOUNT = 10}; //YCCOUNT代表遥测量个数、STANDBYCOUNT代表备用参数个数

public:
 //设置、获取No
 void SetNo(const CString &strNo);
 const CString GetNo(void)const;

 //设置、获取SNo
 void SetSNo(const CString &strSNo);
 const CString GetSNo(void)const;

 //设置、获取一次、二次标志
 //TRUE为一次、FALSE为二次
 void SetTransFlag(const BOOL &bTransFlag);
 const BOOL GetTransFlag(void)const;

 //设置、获取PT一次(不取float类型是因为含有单位)
 void SetPT1(const CString &strPT1);
 const CString GetPT1(void)const;

 //设置、获取PT二次
 void SetPT2(const CString &strPT2);
 const CString GetPT2(void)const;

 //设置、获取CT一次
 void SetCT1(const CString &strCT1);
 const CString GetCT1(void)const;

 //设置、获取CT二次
 void SetCT2(const CString &strCT2);
 const CString GetCT2(void)const;

 //设置、获取遥测量选择标志
 void SetYCSelectFlag(const BOOL *pbYCSelect, const int &nYCCount = YCCOUNT);
 void GetYCSelectFlag(BOOL *pbYCSelect, const int &nYCCount = YCCOUNT);

 //设置、获取协议类型
 void SetProtocolID(const int &nProtocolID);
 const int GetProtocolID(void)const;

 //设置、获取点表配置步骤索引
 void SetIndexConfigStep(const int &nIndexConfigStep);
 const int GetIndexConfigStep(void)const;

 //设置、获取遥测量标识码有效标志
 void SetMarkEffectFlag(const BOOL *pbMarkEffectFlag, const int &nStandbyCount = STANDBYCOUNT);
 void GetMarkEffectFlag(BOOL *pbMarkEffectFlag, const int &nStandbyCount = STANDBYCOUNT);

 //设置、获取是否已配置详细信息标志
 void SetHaveDetailInfoFlag(const BOOL &bHaveDetailInfoFlag);
 BOOL GetHaveDetailInfoFlag(void);

 //设置、获取遥测量索引有效标志
 void SetYCIndexEffectFlag(const BOOL *pbYCIndexEffectFlag, const int &nYCCount = YCCOUNT);
 void GetYCIndexEffectFlag(BOOL *pbYCIndexEffectFlag, const int &nYCCount = YCCOUNT);

 //设置、获取遥测量算法
 void SetYCArith(const int *pnYCArith, const int &nYCCount = YCCOUNT);
 void GetYCArith(int *pnYCArith, const int &nYCCount = YCCOUNT);

 //设置、获取系数K
 void SetCoefficientK(const float *pfCoefficientK, const int &nYCCount = YCCOUNT);
 void GetCoefficientK(float *pfCoefficientK, const int &nYCCount = YCCOUNT);

 //设置、获取系数B
 void SetCoefficientB(const float *pfCoefficientB, const int &nYCCount = YCCOUNT);
 void GetCoefficientB(float *pfCoefficientB, const int &nYCCount = YCCOUNT);

protected:
 void NewPropVal(CEPROPVAL *prgPropVal,
     const int &nStartIndex,
     int &nIndex);
 void PropValToRecord(CEPROPVAL *prgPropVal, int &nIndex);
 void DeletePropVal(void);

protected:
 //将数组转换为指定格式(Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F)
 CString FormatDataToSpecialStr(const int *pnData, const int &nYCCount = YCCOUNT);
 CString FormatDataToSpecialStr(const float *pfData, const int &nYCCount = YCCOUNT);

 //将指定格式的字符串分离成数组
 void DetachDataFromSpecialStr(const CString &strData, int *pnData, const int &nYCCount = YCCOUNT);
 void DetachDataFromSpecialStr(const CString &strData, float *pfData, const int &nYCCount = YCCOUNT);

 //赋值,为子类重载 = 做准备
 void Evaluate(const CInfoIndexYCBase &infoIndexBase);

protected:
 CString m_strNo;     //No
 CString m_strSNo;     //SNo

 CString m_strTransFlag;    //一次、二次标志。0为二次、1为一次
 CString m_strPT1;     //PT一次
 CString m_strPT2;     //PT二次
 CString m_strCT1;     //CT一次
 CString m_strCT2;     //CT二次

 //遥测量选择标志
 //其格式为:Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F
 //选中为1、否则为0
 CString m_strYCSelectFlag;

 CString m_strProtocolID;   //协议类型:-1代表未配、0代表Finally、1代表Other、2代表CDT、3代表101、4代表103、5代表104
 CString m_strIndexConfigStep;  //点表信息配置步骤索引:-1代表未配、0代表已配置基本信息、1代表已配置详细信息

 CString m_strMarkEffectFlag;  //遥测标识码有效标志,0为无效、1为有效
 CString m_strHaveDetailInfoFlag; //是否已配置详细信息标志
 CString m_strYCIndexEffectFlag;  //遥测索引有效标志,针对每一个遥测量是否配置索引。0为无效、1为有效

 CString m_strYCArith;    //遥测量算法,其格式为:Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F,未配置为-1
 CString m_strCoefficientK;   //系数K,其格式为:Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F
 CString m_strCoefficientB;   //系数B,其格式为:Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F
 
};

#endif // !defined(AFX_INFOINDEXYCBASE_H__4AC91339_5B2C_4BF0_A721_5E97AD849B2C__INCLUDED_)

// InfoIndexYCBase.cpp: implementation of the CInfoIndexYCBase class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "InfoIndexYCBase.h"

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

CInfoIndexYCBase::CInfoIndexYCBase()
{
 m_strNo = _T("");     //No
 m_strSNo = _T("");     //SNo

 m_strTransFlag = _T("");   //一次、二次标志。0为二次、1为一次
 m_strPT1 = _T("");     //PT一次
 m_strPT2 = _T("");     //PT二次
 m_strCT1 = _T("");     //CT一次
 m_strCT2 = _T("");     //CT二次
 m_strYCSelectFlag = _T("-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1"); //遥测量选择标志

 m_strProtocolID = _T("-1");    //协议类型:-1代表未配、0代表Finally、1代表Other、2代表CDT、3代表101、4代表103、5代表104
 m_strIndexConfigStep = _T("-1");  //点表信息配置步骤索引:-1代表未配、0代表已配置基本信息、1代表已配置详细信息

 m_strMarkEffectFlag = _T("0|0|0|0|0|0|0|0|0|0");     //遥测量标识码有效位
 m_strHaveDetailInfoFlag = _T("0");         //是否已配置详细信息标志
 m_strYCIndexEffectFlag = _T("0|0|0|0|0|0|0|0|0|0|0|0|0");;   //遥测索引有效标志,0为无效、1为有效

 m_strYCArith = _T("-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1");  //遥测量算法,格式如上
 m_strCoefficientK = _T("0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0");
 m_strCoefficientB = _T("0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0|0.0");
}

CInfoIndexYCBase::~CInfoIndexYCBase()
{

}

//查看结构体内容
CString CInfoIndexYCBase::ViewParam()
{
 CString str;
 str = _T("No: ") + m_strNo + _T("\n");
 str += _T("SNo: ") + m_strSNo + _T("\n");
 str += _T("一次、二次标志: ") + m_strTransFlag + _T("\n");
 str += _T("PT一次: ") + m_strPT1 + _T("\t");
 str += _T("PT二次: ") + m_strPT2 + _T("\n");
 str += _T("CT一次: ") + m_strCT1 + _T("\t");
 str += _T("CT二次: ") + m_strCT2 + _T("\n");
 str += _T("遥测量选择标志: ") + m_strYCSelectFlag + _T("\n");
 str += _T("协议类型: ") + m_strProtocolID + _T("\n");
 str += _T("点表信息配置步骤索引: ") + m_strIndexConfigStep + _T("\n");
 str += _T("遥测标识码有效标志: ") + m_strMarkEffectFlag + _T("\n");
 str += _T("是否已配置详细信息标志: ") + m_strHaveDetailInfoFlag + _T("\n");
 str += _T("遥测索引有效标志: ") + m_strYCIndexEffectFlag + _T("\n");
 str += _T("遥测量算法: ") + m_strYCArith + _T("\n");
 str += _T("系数K: ") + m_strCoefficientK + _T("\n");
 str += _T("系数B: ") + m_strCoefficientB + _T("\n\n");

 return str;
}

//将数组转换为指定格式(Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F)
CString CInfoIndexYCBase::FormatDataToSpecialStr(const int *pnData, const int &nYCCount)
{
 ASSERT(nYCCount > 0);

 CString str(_T("")), str1(_T(""));
 str.Format(_T("%d"), pnData[0]);
 for(register int i = 1; i < nYCCount; i++)
 {
  str1.Format(_T("|%d"), pnData[i]);
  str += str1;
 }

 return str;
}

CString CInfoIndexYCBase::FormatDataToSpecialStr(const float *pfData, const int &nYCCount)
{
 ASSERT(nYCCount > 0);

 CString str(_T("")), str1(_T(""));
 str.Format(_T("%f"), pfData[0]);
 for(register int i = 1; i < nYCCount; i++)
 {
  str1.Format(_T("|%f"), pfData[i]);
  str += str1;
 }

 return str;
}

//将指定格式的字符串分离成数组
void CInfoIndexYCBase::DetachDataFromSpecialStr(const CString &strData, int *pnData, const int &nYCCount)
{
 ASSERT(nYCCount > 0);

 CString strTemp(strData), str;
 for(register int i = 0; i < nYCCount; i++)
 {
  str = strTemp;

  if(str.Find(_T("|"), 0) != -1)
  {
   str.Delete(strTemp.Find(_T("|"), 0), strTemp.GetLength() - strTemp.Find(_T("|"), 0));

   strTemp.Delete(0, strTemp.Find(_T("|"), 0) + 1);
  }

  swscanf(str, _T("%d"), &pnData[i]);
 }
}

void CInfoIndexYCBase::DetachDataFromSpecialStr(const CString &strData, float *pfData, const int &nYCCount)
{
 ASSERT(nYCCount > 0);

 CString strTemp(strData), str;
 for(register int i = 0; i < nYCCount; i++)
 {
  str = strTemp;

  if(str.Find(_T("|"), 0) != -1)
  {
   str.Delete(strTemp.Find(_T("|"), 0), strTemp.GetLength() - strTemp.Find(_T("|"), 0));

   strTemp.Delete(0, strTemp.Find(_T("|"), 0) + 1);
  }

  swscanf(str, _T("%f"), &pfData[i]);
 }
}

//设置、获取No
void CInfoIndexYCBase::SetNo(const CString &strNo)
{
 m_strNo = strNo;
}

const CString CInfoIndexYCBase::GetNo()const
{
 return m_strNo;
}

//设置、获取SNo
void CInfoIndexYCBase::SetSNo(const CString &strSNo)
{
 m_strSNo = strSNo;
}

const CString CInfoIndexYCBase::GetSNo()const
{
 return m_strSNo;
}

//设置、获取一次、二次标志
//TRUE为一次、FALSE为二次
void CInfoIndexYCBase::SetTransFlag(const BOOL &bTransFlag)
{
 m_strTransFlag = bTransFlag ? _T("1") : _T("0");
}

const BOOL CInfoIndexYCBase::GetTransFlag()const
{
 if(m_strTransFlag == _T("1"))
  return TRUE;
  
 return FALSE;
}

//设置、获取PT一次(不取float类型是因为含有单位)
void CInfoIndexYCBase::SetPT1(const CString &strPT1)
{
 m_strPT1 = strPT1;
}

const CString CInfoIndexYCBase::GetPT1()const
{
 return m_strPT1;
}

//设置、获取PT二次
void CInfoIndexYCBase::SetPT2(const CString &strPT2)
{
 m_strPT2 = strPT2;
}

const CString CInfoIndexYCBase::GetPT2()const
{
 return m_strPT2;
}

//设置、获取CT一次
void CInfoIndexYCBase::SetCT1(const CString &strCT1)
{
 m_strCT1 = strCT1;
}

const CString CInfoIndexYCBase::GetCT1()const
{
 return m_strCT1;
}

//设置、获取CT二次
void CInfoIndexYCBase::SetCT2(const CString &strCT2)
{
 m_strCT2 = strCT2;
}

const CString CInfoIndexYCBase::GetCT2()const
{
 return m_strCT2;
}

//设置、获取遥测量选择标志
void CInfoIndexYCBase::SetYCSelectFlag(const BOOL *pbYCSelect, const int &nYCCount)
{
 m_strYCSelectFlag = FormatDataToSpecialStr(pbYCSelect, nYCCount);
}

void CInfoIndexYCBase::GetYCSelectFlag(BOOL *pbYCSelect, const int &nYCCount)
{
 DetachDataFromSpecialStr(m_strYCSelectFlag, pbYCSelect, nYCCount);
}

//设置、获取协议类型
void CInfoIndexYCBase::SetProtocolID(const int &nProtocolID)
{
 m_strProtocolID.Format(_T("%d"), nProtocolID);
}

const int CInfoIndexYCBase::GetProtocolID()const
{
 int nRet;
 swscanf(m_strProtocolID, _T("%d"), &nRet);
 return nRet;
}

//设置、获取点表配置步骤索引
void CInfoIndexYCBase::SetIndexConfigStep(const int &nIndexConfigStep)
{
 m_strIndexConfigStep.Format(_T("%d"), nIndexConfigStep);
}

const int CInfoIndexYCBase::GetIndexConfigStep()const
{
 int nRet;
 swscanf(m_strIndexConfigStep, _T("%d"), &nRet);
 return nRet;
}

//设置、获取遥测量标识码有效标志
void CInfoIndexYCBase::SetMarkEffectFlag(const BOOL *pbMarkEffectFlag, const int &nStandbyCount)
{
 m_strMarkEffectFlag = FormatDataToSpecialStr(pbMarkEffectFlag, nStandbyCount);
}

void CInfoIndexYCBase::GetMarkEffectFlag(BOOL *pbMarkEffectFlag, const int &nStandbyCount)
{
 DetachDataFromSpecialStr(m_strMarkEffectFlag, pbMarkEffectFlag, nStandbyCount);
}

//设置、获取是否已配置详细信息标志
void CInfoIndexYCBase::SetHaveDetailInfoFlag(const BOOL &bHaveDetailInfoFlag)
{
 m_strHaveDetailInfoFlag = bHaveDetailInfoFlag ? _T("1") : _T("0");
}

BOOL CInfoIndexYCBase::GetHaveDetailInfoFlag()
{
 BOOL bRet = (m_strHaveDetailInfoFlag == _T("0")) ? FALSE : TRUE;
 return bRet;
}

//设置、获取遥测量索引有效标志
void CInfoIndexYCBase::SetYCIndexEffectFlag(const BOOL *pbYCIndexEffectFlag, const int &nYCCount)
{
 m_strYCIndexEffectFlag = FormatDataToSpecialStr(pbYCIndexEffectFlag, nYCCount);
}

void CInfoIndexYCBase::GetYCIndexEffectFlag(BOOL *pbYCIndexEffectFlag, const int &nYCCount)
{
 DetachDataFromSpecialStr(m_strYCIndexEffectFlag, pbYCIndexEffectFlag, nYCCount);
}

//设置、获取遥测量算法
void CInfoIndexYCBase::SetYCArith(const int *pnYCArith, const int &nYCCount)
{
 m_strYCArith = FormatDataToSpecialStr(pnYCArith, nYCCount);
}

void CInfoIndexYCBase::GetYCArith(int *pnYCArith, const int &nYCCount)
{
 DetachDataFromSpecialStr(m_strYCArith, pnYCArith, nYCCount);
}

//设置、获取系数K
void CInfoIndexYCBase::SetCoefficientK(const float *pfCoefficientK, const int &nYCCount)
{
 m_strCoefficientK = FormatDataToSpecialStr(pfCoefficientK, nYCCount);
}

void CInfoIndexYCBase::GetCoefficientK(float *pfCoefficientK, const int &nYCCount)
{
 DetachDataFromSpecialStr(m_strCoefficientK, pfCoefficientK, nYCCount);
}

//设置、获取系数B
void CInfoIndexYCBase::SetCoefficientB(const float *pfCoefficientB, const int &nYCCount)
{
 m_strCoefficientB = FormatDataToSpecialStr(pfCoefficientB, nYCCount);
}

void CInfoIndexYCBase::GetCoefficientB(float *pfCoefficientB, const int &nYCCount)
{
 DetachDataFromSpecialStr(m_strCoefficientB, pfCoefficientB, nYCCount);
}

void CInfoIndexYCBase::NewPropVal( CEPROPVAL *prgPropVal,
         const int &nStartIndex,
         int &nIndex)
{
 //No
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strNo.LockBuffer();

 //SNo
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strSNo.LockBuffer();

 //一次、二次标志
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strTransFlag.LockBuffer();

 //PT一次
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strPT1.LockBuffer();

 //PT二次
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strPT2.LockBuffer();

 //CT一次
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strCT1.LockBuffer();

 //CT二次
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strCT2.LockBuffer();

 //遥测量选择标志
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strYCSelectFlag.LockBuffer();

 //协议类型
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strProtocolID.LockBuffer();

 //点表配置步骤索引
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strIndexConfigStep.LockBuffer();

 //遥测量标识码有效标志
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strMarkEffectFlag.LockBuffer();

 //是否已配置详细信息标志
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strHaveDetailInfoFlag.LockBuffer();

 //遥测量索引有效标志
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strYCIndexEffectFlag.LockBuffer();

 //遥测量算法
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strYCArith.LockBuffer();

 //系数K
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strCoefficientK.LockBuffer();

 //系数B
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, nStartIndex + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strCoefficientB.LockBuffer();
}

void CInfoIndexYCBase::PropValToRecord(CEPROPVAL *prgPropVal, int &nIndex)
{
 wcscpy(m_strNo.GetBuffer(255),     prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strSNo.GetBuffer(255),     prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strTransFlag.GetBuffer(255),   prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strPT1.GetBuffer(255),     prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strPT2.GetBuffer(255),     prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strCT1.GetBuffer(255),     prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strCT2.GetBuffer(255),     prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strYCSelectFlag.GetBuffer(255),  prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strProtocolID.GetBuffer(255),   prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strIndexConfigStep.GetBuffer(255),  prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strMarkEffectFlag.GetBuffer(255),  prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strHaveDetailInfoFlag.GetBuffer(255), prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strYCIndexEffectFlag.GetBuffer(255), prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strYCArith.GetBuffer(255),    prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strCoefficientK.GetBuffer(255),  prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strCoefficientB.GetBuffer(255),  prgPropVal[nIndex++].val.lpwstr);

 m_strNo.ReleaseBuffer();
 m_strSNo.ReleaseBuffer();
 m_strTransFlag.ReleaseBuffer();
 m_strPT1.ReleaseBuffer();
 m_strPT2.ReleaseBuffer();
 m_strCT1.ReleaseBuffer();
 m_strCT2.ReleaseBuffer();
 m_strYCSelectFlag.ReleaseBuffer();
 m_strProtocolID.ReleaseBuffer();
 m_strIndexConfigStep.ReleaseBuffer();
 m_strMarkEffectFlag.ReleaseBuffer();
 m_strHaveDetailInfoFlag.ReleaseBuffer();
 m_strYCIndexEffectFlag.ReleaseBuffer();
 m_strYCArith.ReleaseBuffer();
 m_strCoefficientK.ReleaseBuffer();
 m_strCoefficientB.ReleaseBuffer();
}

void CInfoIndexYCBase::DeletePropVal()
{
 m_strNo.UnlockBuffer();
 m_strSNo.UnlockBuffer();
 m_strTransFlag.UnlockBuffer();
 m_strPT1.UnlockBuffer();
 m_strPT2.UnlockBuffer();
 m_strCT1.UnlockBuffer();
 m_strCT2.UnlockBuffer();
 m_strYCSelectFlag.UnlockBuffer();
 m_strProtocolID.UnlockBuffer();
 m_strIndexConfigStep.UnlockBuffer();
 m_strMarkEffectFlag.UnlockBuffer();
 m_strHaveDetailInfoFlag.UnlockBuffer();
 m_strYCIndexEffectFlag.UnlockBuffer();
 m_strYCArith.UnlockBuffer();
 m_strCoefficientK.UnlockBuffer();
 m_strCoefficientB.UnlockBuffer();
}

//赋值,为子类重载 = 做准备
void CInfoIndexYCBase::Evaluate(const CInfoIndexYCBase &infoIndexBase)
{
 m_strNo = infoIndexBase.m_strNo;
 m_strSNo = infoIndexBase.m_strSNo;
 m_strTransFlag = infoIndexBase.m_strTransFlag;
 m_strPT1 = infoIndexBase.m_strPT1;
 m_strPT2 = infoIndexBase.m_strPT2;
 m_strCT1 = infoIndexBase.m_strCT1;
 m_strCT2 = infoIndexBase.m_strCT2;
 m_strYCSelectFlag = infoIndexBase.m_strYCSelectFlag;
 m_strProtocolID = infoIndexBase.m_strProtocolID;
 m_strIndexConfigStep = infoIndexBase.m_strIndexConfigStep;
 m_strMarkEffectFlag = infoIndexBase.m_strMarkEffectFlag;
 m_strHaveDetailInfoFlag = infoIndexBase.m_strHaveDetailInfoFlag;
 m_strYCIndexEffectFlag = infoIndexBase.m_strYCIndexEffectFlag;
 m_strYCArith = infoIndexBase.m_strYCArith;
 m_strCoefficientK = infoIndexBase.m_strCoefficientK;
 m_strCoefficientB = infoIndexBase.m_strCoefficientB;
}

// InfoIndexYCCDT.h: interface for the CInfoIndexYCCDT class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_INFOINDEXYCCDT_H__A127D99D_91CD_4B38_A98B_12A8FD3C731F__INCLUDED_)
#define AFX_INFOINDEXYCCDT_H__A127D99D_91CD_4B38_A98B_12A8FD3C731F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "InfoIndexYCBase.h"

class CInfoIndexYCCDT : public CInfoIndexYCBase 
{
public:
 CInfoIndexYCCDT();
 virtual ~CInfoIndexYCCDT();

public:
 void ViewParam(void); //查看结构体内容

private:
 enum{PROPERTYCOUNT = 19, STARTINDEX = 1300};

public:
 static int GetPropertyCount(void);

 CInfoIndexYCCDT& operator =(const CInfoIndexYCCDT &infoIndexYCCDT);

public:
 //设置、获取功能码
 void SetFuncCode(const int *pnFuncCode, const int &nStandbyCount = STANDBYCOUNT);
 void GetFuncCode(int *pnFuncCode, const int &nStandbyCount = STANDBYCOUNT);

 //设置、获取功能码位置
 void SetFuncCodeAddr(const int &nFuncCodeAddr);
 const int GetFuncCodeAddr(void)const;

 //设置、获取点号
 void SetDotNo(const int *pnDotNo, const int &nYCCount = YCCOUNT);
 void GetDotNo(int *pnDotNo, const int &nYCCount = YCCOUNT);

public:
 CEPROPVAL* NewPropVal(void);
 void PropValToRecord(CEPROPVAL *prgPropVal);
 void DeletePropVal(CEPROPVAL *prgPropVal);

private:
 CString m_strFuncCode;   //功能码,其格式为:功能码1|功能码2|功能码3|功能码4|功能码5|功能码6|功能码7|功能码8|功能码9|功能码10
 CString m_strFuncCodeAddr;  //功能码位置 
 CString m_strDotNo;    //点号,其格式为:Ua|Ub|Uc|Uab|Ucb|Uca|Ia|Ib|Ic|P|Q|Cos|F

};

#endif // !defined(AFX_INFOINDEXYCCDT_H__A127D99D_91CD_4B38_A98B_12A8FD3C731F__INCLUDED_)

// InfoIndexYCCDT.cpp: implementation of the CInfoIndexYCCDT class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "InfoIndexYCCDT.h"

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

CInfoIndexYCCDT::CInfoIndexYCCDT()
{
 m_strFuncCode = _T("-1|-1|-1|-1|-1|-1|-1|-1|-1|-1");
 m_strFuncCodeAddr = _T("-1");
 m_strDotNo = _T("-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1|-1");
}

CInfoIndexYCCDT::~CInfoIndexYCCDT()
{

}

//查看结构体内容
void CInfoIndexYCCDT::ViewParam()
{
 CString str;
 str = _T("功能码: ") + m_strFuncCode + _T("\n");
 str += _T("功能码位置: ") + m_strFuncCodeAddr + _T("\n");
 str += _T("点号: ") + m_strDotNo;
 str = CInfoIndexYCBase::ViewParam() + str;
 AfxMessageBox(str);
}

int CInfoIndexYCCDT::GetPropertyCount()
{
 return PROPERTYCOUNT;
}

CInfoIndexYCCDT& CInfoIndexYCCDT::operator =(const CInfoIndexYCCDT &infoIndexYCCDT)
{
 if(this == &infoIndexYCCDT)
  return *this;

 CInfoIndexYCBase::Evaluate(infoIndexYCCDT);

 m_strFuncCode = infoIndexYCCDT.m_strFuncCode;
 m_strFuncCodeAddr = infoIndexYCCDT.m_strFuncCodeAddr;
 m_strDotNo = infoIndexYCCDT.m_strDotNo;

 return *this;
}

//设置、获取功能码
void CInfoIndexYCCDT::SetFuncCode(const int *pnFuncCode, const int &nStandbyCount)
{
 m_strFuncCode = FormatDataToSpecialStr(pnFuncCode, nStandbyCount);
}

void CInfoIndexYCCDT::GetFuncCode(int *pnFuncCode, const int &nStandbyCount)
{
 DetachDataFromSpecialStr(m_strFuncCode, pnFuncCode, nStandbyCount);
}

//设置、获取功能码位置
void CInfoIndexYCCDT::SetFuncCodeAddr(const int &nFuncCodeAddr)
{
 m_strFuncCodeAddr.Format(_T("%d"), nFuncCodeAddr);
}

const int CInfoIndexYCCDT::GetFuncCodeAddr()const
{
 int nRet = 0;
 swscanf(m_strFuncCodeAddr, _T("%d"), &nRet);
 return nRet;
}

//设置、获取点号
void CInfoIndexYCCDT::SetDotNo(const int *pnDotNo, const int &nYCCount)
{
 m_strDotNo = FormatDataToSpecialStr(pnDotNo, nYCCount);
}

void CInfoIndexYCCDT::GetDotNo(int *pnDotNo, const int &nYCCount)
{
 DetachDataFromSpecialStr(m_strDotNo, pnDotNo, nYCCount);
}

CEPROPVAL* CInfoIndexYCCDT::NewPropVal()
{
 CEPROPVAL *prgPropVal = new CEPROPVAL[PROPERTYCOUNT];
 ZeroMemory(prgPropVal, sizeof(CEPROPVAL[PROPERTYCOUNT]));

 int nIndex = 0;

 //基类函数
 CInfoIndexYCBase::NewPropVal(prgPropVal, STARTINDEX, nIndex);

 //功能码
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, STARTINDEX + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strFuncCode.LockBuffer();

 //功能码位置
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, STARTINDEX + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strFuncCodeAddr.LockBuffer();

 //点号
 prgPropVal[nIndex].propid = MAKELONG(CEVT_LPWSTR, STARTINDEX + nIndex);
 prgPropVal[nIndex++].val.lpwstr = m_strDotNo.LockBuffer();

 return prgPropVal;
}

void CInfoIndexYCCDT::PropValToRecord(CEPROPVAL *prgPropVal)
{
 int nIndex = 0;

 //基类函数
 CInfoIndexYCBase::PropValToRecord(prgPropVal, nIndex);

 wcscpy(m_strFuncCode.GetBuffer(255),   prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strFuncCodeAddr.GetBuffer(255),  prgPropVal[nIndex++].val.lpwstr);
 wcscpy(m_strDotNo.GetBuffer(255),    prgPropVal[nIndex++].val.lpwstr);

 m_strFuncCode.ReleaseBuffer();
 m_strFuncCodeAddr.ReleaseBuffer();
 m_strDotNo.ReleaseBuffer();
}

void CInfoIndexYCCDT::DeletePropVal(CEPROPVAL *prgPropVal)
{
 //基类函数
 CInfoIndexYCBase::DeletePropVal();

 m_strFuncCode.UnlockBuffer();
 m_strFuncCodeAddr.UnlockBuffer();
 m_strDotNo.UnlockBuffer();
 
 delete prgPropVal;
}

.....

// ProtocolDB.h: interface for the CProtocolDB class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PROTOCOLDB_H__060DFC2F_EDF2_417C_A5CC_850BBD2AEF47__INCLUDED_)
#define AFX_PROTOCOLDB_H__060DFC2F_EDF2_417C_A5CC_850BBD2AEF47__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Afxtempl.h"

#include "ProtocolVer.h"
#include "InfoManufactory.h"
#include "InfoProtocolName.h"
#include "InfoDeviceType.h"
#include "InfoProtocol.h"
#include "InfoIndexYCFinally.h"
#include "InfoRTUProtocol.h"

class CProtocolDB 
{
public:
 CProtocolDB();
 virtual ~CProtocolDB();

public:
 BOOL Open(void);  //打开数据库
 BOOL Close(void);  //关闭数据库

public:
 //增加
 BOOL AddRecord(CProtocolVer record);
 BOOL AddRecord(CInfoManufactory record);
 BOOL AddRecord(CInfoProtocolName record);
 BOOL AddRecord(CInfoDeviceType record);
 BOOL AddRecord(CInfoProtocol record);
 BOOL AddRecord(CInfoIndexYCFinally record);
 BOOL AddRecord(CInfoRTUProtocol record);

 //根据指定条件获取
 BOOL GetRecord(CProtocolVer &record);
 BOOL GetRecord(CInfoManufactory &record);
 BOOL GetRecord(CInfoProtocolName &record);
 BOOL GetRecord(CInfoDeviceType &record);
 BOOL GetRecord(CInfoProtocol &record);
 BOOL GetRecord(CInfoIndexYCFinally &record);
 BOOL GetRecord(CInfoRTUProtocol &record);

 //编辑
 BOOL EditRecord(CProtocolVer record);
 BOOL EditRecord(CInfoManufactory record);
 BOOL EditRecord(CInfoProtocolName record);
 BOOL EditRecord(CInfoDeviceType record);
 BOOL EditRecord(CInfoProtocol record);
 BOOL EditRecord(CInfoIndexYCFinally record);
 BOOL EditRecord(CInfoRTUProtocol record);

 //删除
 BOOL DeleteRecord(void);      //删除版本号
 BOOL DeleteRecord(CInfoManufactory record);
 BOOL DeleteRecord(CInfoProtocolName record);
 BOOL DeleteRecord(CInfoDeviceType record);
 BOOL DeleteRecord(CInfoProtocol record);
 BOOL DeleteRecord(CInfoIndexYCFinally record);
 BOOL DeleteRecord(CInfoRTUProtocol record);

 //判断是否存在
 BOOL HaveRecord(void);
 BOOL HaveRecord(CInfoManufactory record);
 BOOL HaveRecord(CInfoProtocolName record);
 BOOL HaveRecord(CInfoDeviceType record);
 BOOL HaveRecord(CInfoProtocol record);
 BOOL HaveRecord(CInfoIndexYCFinally record);
 BOOL HaveRecord(CInfoRTUProtocol record);

 //获取指定表中的所有记录
 BOOL LoadRecord(CList<CProtocolVer, CProtocolVer> &templ);
 BOOL LoadRecord(CList<CInfoManufactory, CInfoManufactory> &templ);
 BOOL LoadRecord(CList<CInfoProtocolName, CInfoProtocolName> &templ);
 BOOL LoadRecord(CList<CInfoDeviceType, CInfoDeviceType> &templ);
 BOOL LoadRecord(CList<CInfoProtocol, CInfoProtocol> &templ);
 BOOL LoadRecord(CList<CInfoIndexYCFinally, CInfoIndexYCFinally> &templ);
 BOOL LoadRecord(CList<CInfoRTUProtocol, CInfoRTUProtocol> &templ);

public:
 void SetbUpdateDataBase(BOOL bUpdateDataBase);
 BOOL GetbUpdateDataBase();

private:
 BOOL MountVol(void);
 BOOL CreateDB(void);
 BOOL OpenDB(void);

 //读取
 BOOL ReadRecord(CProtocolVer &record);
 BOOL ReadRecord(CInfoManufactory &record);
 BOOL ReadRecord(CInfoProtocolName &record);
 BOOL ReadRecord(CInfoDeviceType &record);
 BOOL ReadRecord(CInfoProtocol &record);
 BOOL ReadRecord(CInfoIndexYCFinally &record);
 BOOL ReadRecord(CInfoRTUProtocol &record);

private:
 CEGUID m_guid2;
 CEGUID m_guid3;

 HANDLE m_hDB_ProtocolVer;
 HANDLE m_hDB_Manufactory;
 HANDLE m_hDB_ProtocolName;
 HANDLE m_hDB_DeviceType;
 HANDLE m_hDB_Protocol;
 HANDLE m_hDB_IndexYCFinally;
 HANDLE m_hDB_RTUProtocol;

private:
 enum{TABLECOUNT = 7};       //记录表的个数
 static CString s_strTablesName[TABLECOUNT];  //记录表名

private:
 BOOL m_bIsOpen;         //记录是否数据库已经打开
 BOOL m_bUpdateDataBase;       //数据库升级标志 FALSE 不升级,TRUE 升级


};

#endif // !defined(AFX_PROTOCOLDB_H__060DFC2F_EDF2_417C_A5CC_850BBD2AEF47__INCLUDED_)

// ProtocolDB.cpp: implementation of the CProtocolDB class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ProtocolDB.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CString CProtocolDB::s_strTablesName[TABLECOUNT] = {_T("DB_ProtocolVer"),
             _T("DB_Manufactory"),
             _T("DB_ProtocolName"),
             _T("DB_DeviceType"),
             _T("DB_ProtocolInfo"),
             _T("DB_IndexYCFInally"),
             _T("DB_RTUProtocol")};

CProtocolDB::CProtocolDB()
{
 m_bIsOpen = FALSE;
 m_bUpdateDataBase = FALSE;
}

CProtocolDB::~CProtocolDB()
{

}

BOOL CProtocolDB::MountVol()
{
 // Mount a volume
 BOOL bResult;
 if(m_bUpdateDataBase)
 {
  ::CreateDirectory(_T("\\Disk\\DataBase"), NULL);
  bResult = CeMountDBVol(
      &m_guid3,        // guid of mount
      TEXT("\\Disk\\DataBase\\ProtocolDB.cdb"), // full path and name of database volume
      OPEN_ALWAYS);
 }
 else
 {
  ::CreateDirectory(_T("\\Disk\\Test"), NULL);
  bResult = CeMountDBVol(
      &m_guid2,        // guid of mount
      TEXT("\\Disk\\Test\\ProtocolDB.cdb"), // full path and name of database volume
      OPEN_ALWAYS); 
 }// flags

 return bResult;
}

BOOL CProtocolDB::CreateDB()
{
 CEGUID *pGUID = m_bUpdateDataBase ? (&m_guid3) : (&m_guid2);

 for(int i = 0; i < TABLECOUNT; i++)
 {
  CEOID oid = 0;

  CEDBASEINFO ced;
  ZeroMemory(&ced, sizeof(CEDBASEINFO));
  ced.dwSize = sizeof(CEDBASEINFO);
  ced.dwFlags = CEDB_VALIDNAME;
  wcscpy(ced.szDbaseName, CProtocolDB::s_strTablesName[i]);  

  oid = CeCreateDatabaseEx( pGUID,  // guid of mounted database
         &ced);  // database information

  if(!oid)
   return FALSE;
 }

 CProtocolVer protocolVer;
 protocolVer.SetVerNo(_T("1.0"));
 AddRecord(protocolVer);

 return TRUE;
}

BOOL CProtocolDB::OpenDB()
{
 CEGUID *pGUID = m_bUpdateDataBase ? (&m_guid3) : (&m_guid2);

 HANDLE *phDB[TABLECOUNT] = {&m_hDB_ProtocolVer,
        &m_hDB_Manufactory,
        &m_hDB_ProtocolName,
        &m_hDB_DeviceType,
        &m_hDB_Protocol,
        &m_hDB_IndexYCFinally,
        &m_hDB_RTUProtocol};

 for(int i = 0; i < TABLECOUNT; i++)
 {
  CEOID oid = 0;
  *phDB[i] = CeOpenDatabaseEx(
         &m_guid2,            // guid of mounted database
         &oid,            // object identifier of database
         CProtocolDB::s_strTablesName[i].GetBuffer(0),  // name of database
         0,             // Property id for sort order
         0/*CEDB_AUTOINCREMENT*/,       // auto increment record pointer on ReadRecord
         NULL);
  
  if(*phDB[i] == INVALID_HANDLE_VALUE)
   return FALSE;
 }

 return TRUE;
}

BOOL CProtocolDB::Open()
{
 if(m_bIsOpen)
  return TRUE;

 BOOL bResult = FALSE;

 // Mount database volume
 bResult = MountVol();
 if(!bResult)
  return FALSE;

 // Open the database
 bResult = OpenDB();
 if(!bResult)
 { // If not create the database
  bResult = CreateDB();
  if(!bResult)
   return FALSE;
  
  // Open the database
  bResult = OpenDB();
  if(!bResult)
   return FALSE;
 }

 // Seek to the beginning of a populated database
 DWORD dwIndex;
 CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 m_bIsOpen = TRUE;

 return TRUE;
}

BOOL CProtocolDB::Close()
{
 if(!m_bIsOpen)
  return TRUE;

 CEGUID *pGUID = m_bUpdateDataBase ? (&m_guid3) : (&m_guid2);

 if(!CeFlushDBVol(pGUID))
  return FALSE;

 if(!CeUnmountDBVol(pGUID))
  return FALSE;

 CloseHandle(m_hDB_ProtocolVer);
 CloseHandle(m_hDB_Manufactory);
 CloseHandle(m_hDB_ProtocolName);
 CloseHandle(m_hDB_DeviceType);
 CloseHandle(m_hDB_Protocol);
 CloseHandle(m_hDB_IndexYCFinally);
 CloseHandle(m_hDB_RTUProtocol);

 m_bIsOpen = FALSE;

/* if(m_bUpdateDataBase)
 {
  ::DeleteFile(_T("\\Disk\\Test\\ProtocolDB.cdb"));
  if(!::CopyFile(_T("\\Disk\\DataBase\\ProtocolDB.cdb"),_T("\\Disk\\Test\\ProtocolDB.cdb"),FALSE))
   return FALSE;
  ::DeleteFile(_T("\\Disk\\DataBase\\ProtocolDB.cdb"));

 }
*/
 return TRUE;
}

BOOL CProtocolDB::AddRecord(CProtocolVer record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_ProtocolVer,       // handle to database
     0,           // Create new record
     CProtocolVer::GetPropertyCount(),   // properties count
     prgPropVal);        // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::AddRecord(CInfoManufactory record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_Manufactory,       // handle to database
     0,           // Create new record
     CInfoManufactory::GetPropertyCount(),  // properties count
     prgPropVal);        // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::AddRecord(CInfoProtocolName record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_ProtocolName,       // handle to database
     0,           // Create new record
     CInfoProtocolName::GetPropertyCount(),  // properties count
     prgPropVal);        // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::AddRecord(CInfoDeviceType record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_DeviceType,       // handle to database
     0,           // Create new record
     CInfoDeviceType::GetPropertyCount(),  // properties count
     prgPropVal);        // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::AddRecord(CInfoProtocol record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_Protocol,        // handle to database
     0,           // Create new record
     CInfoProtocol::GetPropertyCount(),   // properties count
     prgPropVal);        // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::AddRecord(CInfoIndexYCFinally record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_IndexYCFinally,       // handle to database
     0,            // Create new record
     CInfoIndexYCFinally::GetPropertyCount(),  // properties count
     prgPropVal);         // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::AddRecord(CInfoRTUProtocol record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();
 CEOID oid = CeWriteRecordProps(
     m_hDB_RTUProtocol,       // handle to database
     0,           // Create new record
     CInfoRTUProtocol::GetPropertyCount(),  // properties count
     prgPropVal);        // propval structure
 record.DeletePropVal(prgPropVal);

 // return TRUE/FALSE based on resultant value
 if(oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CProtocolVer &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_ProtocolVer,   // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CInfoManufactory &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_Manufactory,  // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CInfoProtocolName &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_ProtocolName,  // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CInfoDeviceType &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_DeviceType,  // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CInfoProtocol &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_Protocol,   // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CInfoIndexYCFinally &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_IndexYCFinally,   // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::ReadRecord(CInfoRTUProtocol &record)
{
 BYTE *prgBuffer = NULL;
 DWORD dwBuffer = 0;
 WORD wPropId = 0;

 CEOID oid = CeReadRecordPropsEx(
     m_hDB_RTUProtocol,  // handle to database
     CEDB_ALLOWREALLOC,  // flags
     &wPropId,    // read all properties
     NULL,     // read all properties
     &prgBuffer,    // pointer to buffer
     &dwBuffer,    // sizeof buffer
     NULL);     // parameter not meaningful

 if(oid)
 {
  record.PropValToRecord((CEPROPVAL *) prgBuffer);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::GetRecord(CProtocolVer &record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 if(!oid)
 {
  ReadRecord(record);
  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::GetRecord(CInfoManufactory &record)
{
 CInfoManufactory infoManufactory;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoManufactory);

  if(record.GetNo() != _T(""))
  {
   if(infoManufactory.GetNo() == record.GetNo())
   {
    record = infoManufactory;

    return TRUE;
   }
  }
  else
  {
   if(infoManufactory.GetManufactoryName() == record.GetManufactoryName())
   {
    record = infoManufactory;

    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE; 
}

BOOL CProtocolDB::GetRecord(CInfoProtocolName &record)
{
 CInfoProtocolName infoProtocolName;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoProtocolName);

  if(record.GetNo() != _T(""))
  {
   if(infoProtocolName.GetNo() == record.GetNo())
   {
    record = infoProtocolName;

    return TRUE;
   }
  }
  else
  {
   if( (infoProtocolName.GetSNo() == record.GetSNo()) &&
    (infoProtocolName.GetProtocolName() == record.GetProtocolName()))
   {
    record = infoProtocolName;

    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::GetRecord(CInfoDeviceType &record)
{
 CInfoDeviceType infoDeviceType;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoDeviceType);

  if(record.GetNo() != _T(""))
  {
   if(infoDeviceType.GetNo() == record.GetNo())
   {
    record = infoDeviceType;

    return TRUE;
   }
  }
  else
  {
   if( (infoDeviceType.GetManufactoryNo() == record.GetManufactoryNo()) &&
    (infoDeviceType.GetDeviceType() == record.GetDeviceType()))
   {
    record = infoDeviceType;

    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::GetRecord(CInfoProtocol &record)
{
 CInfoProtocol infoProtocol;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoProtocol);

  if(record.GetNo() != _T(""))
  {
   if(infoProtocol.GetNo() == record.GetNo())
   {
    record = infoProtocol;

    return TRUE;
   }
  }
  else
  {
   if(infoProtocol.GetSNo() == record.GetSNo())
   {
    record = infoProtocol;

    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::GetRecord(CInfoIndexYCFinally &record)
{
 CInfoIndexYCFinally infoIndexYCFinally;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoIndexYCFinally);

  if(infoIndexYCFinally.GetNo() == record.GetNo())
  {
   record = infoIndexYCFinally;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::GetRecord(CInfoRTUProtocol &record)
{
 CInfoRTUProtocol infoRTUProtocol;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoRTUProtocol);

  if(infoRTUProtocol.GetNo() == _T(""))
  {
   if(infoRTUProtocol.GetNo() == record.GetNo())
   {
    record = infoRTUProtocol;

    return TRUE;
   }
  }
  else
  {
   if(infoRTUProtocol.GetRTUNo() == record.GetRTUNo())
   {
    record = infoRTUProtocol;

    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CProtocolVer record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 if(!oid)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_ProtocolVer,        // handle to database
     oid,           // Modify record
     CProtocolVer::GetPropertyCount(),   // properties count
     prgPropVal))         // propval structure
 {
  record.DeletePropVal(prgPropVal);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CInfoManufactory record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 CInfoManufactory tempRecord;
 BOOL bExist = FALSE;
 while(oid)
 {
  ReadRecord(tempRecord);

  if(tempRecord.GetNo() == record.GetNo())
  {
   bExist = TRUE;
   break;
  }

  oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }
 
 if(!bExist)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_Manufactory,        // handle to database
     oid,           // Modify record
     CInfoManufactory::GetPropertyCount(),   // properties count
     prgPropVal))         // propval structure
 {
  record.DeletePropVal(prgPropVal);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CInfoProtocolName record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 CInfoProtocolName tempRecord;
 BOOL bExist = FALSE;
 while(oid)
 {
  ReadRecord(tempRecord);

  if(tempRecord.GetNo() == record.GetNo())
  {
   bExist = TRUE;
   break;
  }

  oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }
 
 if(!bExist)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_ProtocolName,        // handle to database
     oid,           // Modify record
     CInfoProtocolName::GetPropertyCount(),   // properties count
     prgPropVal))         // propval structure
 {
  record.DeletePropVal(prgPropVal);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CInfoDeviceType record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 CInfoDeviceType tempRecord;
 BOOL bExist = FALSE;
 while(oid)
 {
  ReadRecord(tempRecord);

  if(tempRecord.GetNo() == record.GetNo())
  {
   bExist = TRUE;
   break;
  }

  oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }
 
 if(!bExist)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_DeviceType,        // handle to database
     oid,           // Modify record
     CInfoDeviceType::GetPropertyCount(),   // properties count
     prgPropVal))         // propval structure
 {
  record.DeletePropVal(prgPropVal);

  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CInfoProtocol record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 CInfoProtocol tempRecord;
 BOOL bExist = FALSE;
 while(oid)
 {
  ReadRecord(tempRecord);

  if(tempRecord.GetNo() == record.GetNo())
  {
   bExist = TRUE;
   break;
  }

  oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }
 
 if(!bExist)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_Protocol,        // handle to database
     oid,          // Modify record
     CInfoProtocol::GetPropertyCount(),   // properties count
     prgPropVal))        // propval structure
 {
  record.DeletePropVal(prgPropVal);
  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CInfoIndexYCFinally record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 CInfoIndexYCFinally tempRecord;
 BOOL bExist = FALSE;
 while(oid)
 {
  ReadRecord(tempRecord);

  if(tempRecord.GetNo() == record.GetNo())
  {
   bExist = TRUE;
   break;
  }

  oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }
 
 if(!bExist)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_IndexYCFinally,        // handle to database
     oid,          // Modify record
     CInfoIndexYCFinally::GetPropertyCount(),   // properties count
     prgPropVal))        // propval structure
 {
  record.DeletePropVal(prgPropVal);
  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::EditRecord(CInfoRTUProtocol record)
{
 CEPROPVAL *prgPropVal = record.NewPropVal();

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);

 CInfoRTUProtocol tempRecord;
 BOOL bExist = FALSE;
 while(oid)
 {
  ReadRecord(tempRecord);

  if(tempRecord.GetNo() == record.GetNo())
  {
   bExist = TRUE;
   break;
  }

  oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }
 
 if(!bExist)
  return FALSE;

 if(CeWriteRecordProps(
     m_hDB_RTUProtocol,       // handle to database
     oid,          // Modify record
     CInfoRTUProtocol::GetPropertyCount(),  // properties count
     prgPropVal))        // propval structure
 {
  record.DeletePropVal(prgPropVal);
  return TRUE;
 }

 return FALSE;
}

BOOL CProtocolDB::DeleteRecord()
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 if(!oid)
  return TRUE;
 
 if(!CeDeleteRecord(m_hDB_ProtocolVer, oid))
  return FALSE;

 return TRUE;
}

BOOL CProtocolDB::DeleteRecord(CInfoManufactory record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 CInfoManufactory tempRecord;

 while(oid)
 {
  ReadRecord(tempRecord);

  // Update GUI with currently selected record
  if(tempRecord.GetNo() == record.GetNo())
  {
   if(!CeDeleteRecord(m_hDB_Manufactory, oid))
    return FALSE;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::DeleteRecord(CInfoProtocolName record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 CInfoProtocolName tempRecord;

 while(oid)
 {
  ReadRecord(tempRecord);

  // Update GUI with currently selected record
  if(tempRecord.GetNo() == record.GetNo())
  {
   if(!CeDeleteRecord(m_hDB_ProtocolName, oid))
    return FALSE;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::DeleteRecord(CInfoDeviceType record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 CInfoDeviceType tempRecord;

 while(oid)
 {
  ReadRecord(tempRecord);

  // Update GUI with currently selected record
  if(tempRecord.GetNo() == record.GetNo())
  {
   if(!CeDeleteRecord(m_hDB_DeviceType, oid))
    return FALSE;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::DeleteRecord(CInfoProtocol record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 CInfoProtocol tempRecord;

 while(oid)
 {
  ReadRecord(tempRecord);

  // Update GUI with currently selected record
  if(tempRecord.GetNo() == record.GetNo())
  {
   if(!CeDeleteRecord(m_hDB_Protocol, oid))
    return FALSE;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::DeleteRecord(CInfoIndexYCFinally record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 CInfoIndexYCFinally tempRecord;

 while(oid)
 {
  ReadRecord(tempRecord);

  // Update GUI with currently selected record
  if(tempRecord.GetNo() == record.GetNo())
  {
   if(!CeDeleteRecord(m_hDB_IndexYCFinally, oid))
    return FALSE;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::DeleteRecord(CInfoRTUProtocol record)
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 //ASSERT(oid);

 CInfoRTUProtocol tempRecord;

 while(oid)
 {
  ReadRecord(tempRecord);

  // Update GUI with currently selected record
  if(tempRecord.GetNo() == record.GetNo())
  {
   if(!CeDeleteRecord(m_hDB_RTUProtocol, oid))
    return FALSE;

   return TRUE;
  }

  oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::HaveRecord()
{
 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 if(!oid)
  return TRUE;

 return FALSE;
}

BOOL CProtocolDB::HaveRecord(CInfoManufactory record)
{
 CInfoManufactory infoManufactory;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoManufactory);

  if(record.GetNo() != _T(""))
  {
   if(infoManufactory.GetNo() == record.GetNo())
   {
    return TRUE;
   }
  }
  else
  {
   if(infoManufactory.GetManufactoryName() == record.GetManufactoryName())
   {
    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::HaveRecord(CInfoProtocolName record)
{
 CInfoProtocolName infoProtocolName;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoProtocolName);

  if(record.GetNo() != _T(""))
  {
   if(infoProtocolName.GetNo() == record.GetNo())
   {
    return TRUE;
   }
  }
  else
  {
   if( (infoProtocolName.GetSNo() == record.GetSNo()) &&
    (infoProtocolName.GetProtocolName() == record.GetProtocolName()))
   {
    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::HaveRecord(CInfoDeviceType record)
{
 CInfoDeviceType infoDeviceType;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoDeviceType);

  if(record.GetNo() != _T(""))
  {
   if(infoDeviceType.GetNo() == record.GetNo())
   {
    return TRUE;
   }
  }
  else
  {
   if( (infoDeviceType.GetManufactoryNo() == record.GetManufactoryNo()) &&
    (infoDeviceType.GetProtocolNameNo() == record.GetProtocolNameNo()) &&
    (infoDeviceType.GetDeviceType() == record.GetDeviceType()))
   {
    return TRUE;
   }
  }

  oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::HaveRecord(CInfoProtocol record)
{
 CInfoProtocol infoProtocol;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoProtocol);

  if(infoProtocol.GetSNo() == record.GetSNo())
   return TRUE;

  oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::HaveRecord(CInfoIndexYCFinally record)
{
 CInfoIndexYCFinally infoIndexYCFinally;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoIndexYCFinally);

  if(infoIndexYCFinally.GetSNo() == record.GetSNo())
   return TRUE;

  oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::HaveRecord(CInfoRTUProtocol record)
{
 CInfoRTUProtocol infoRTUProtocol;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoRTUProtocol);

  if(infoRTUProtocol.GetRTUNo() == record.GetRTUNo())
   return TRUE;

  oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return FALSE;
}

BOOL CProtocolDB::LoadRecord(CList<CProtocolVer, CProtocolVer> &templ)
{
 templ.RemoveAll();

 CProtocolVer protocolVer;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(protocolVer);

  if(templ.IsEmpty())
   templ.AddHead(protocolVer);
  else
   templ.AddTail(protocolVer);

  oid = CeSeekDatabase(m_hDB_ProtocolVer, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::LoadRecord(CList<CInfoManufactory, CInfoManufactory> &templ)
{
 templ.RemoveAll();

 CInfoManufactory infoManufactory;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoManufactory);

  if(templ.IsEmpty())
   templ.AddHead(infoManufactory);
  else
   templ.AddTail(infoManufactory);

  oid = CeSeekDatabase(m_hDB_Manufactory, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::LoadRecord(CList<CInfoProtocolName, CInfoProtocolName> &templ)
{
 templ.RemoveAll();

 CInfoProtocolName infoProtocolName;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoProtocolName);

  if(templ.IsEmpty())
   templ.AddHead(infoProtocolName);
  else
   templ.AddTail(infoProtocolName);

  oid = CeSeekDatabase(m_hDB_ProtocolName, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::LoadRecord(CList<CInfoDeviceType, CInfoDeviceType> &templ)
{
 templ.RemoveAll();

 CInfoDeviceType infoDeviceType;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoDeviceType);

  if(templ.IsEmpty())
   templ.AddHead(infoDeviceType);
  else
   templ.AddTail(infoDeviceType);

  oid = CeSeekDatabase(m_hDB_DeviceType, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::LoadRecord(CList<CInfoProtocol, CInfoProtocol> &templ)
{
 templ.RemoveAll();

 CInfoProtocol infoProtocol;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoProtocol);

  if(templ.IsEmpty())
   templ.AddHead(infoProtocol);
  else
   templ.AddTail(infoProtocol);

  oid = CeSeekDatabase(m_hDB_Protocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::LoadRecord(CList<CInfoIndexYCFinally, CInfoIndexYCFinally> &templ)
{
 templ.RemoveAll();

 CInfoIndexYCFinally infoIndexYCFinally;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoIndexYCFinally);

  if(templ.IsEmpty())
   templ.AddHead(infoIndexYCFinally);
  else
   templ.AddTail(infoIndexYCFinally);

  oid = CeSeekDatabase(m_hDB_IndexYCFinally, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

BOOL CProtocolDB::LoadRecord(CList<CInfoRTUProtocol, CInfoRTUProtocol> &templ)
{
 templ.RemoveAll();

 CInfoRTUProtocol infoRTUProtocol;

 DWORD dwIndex;
 CEOID oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_BEGINNING, 0, &dwIndex);
 while(oid)
 {
  ReadRecord(infoRTUProtocol);

  if(templ.IsEmpty())
   templ.AddHead(infoRTUProtocol);
  else
   templ.AddTail(infoRTUProtocol);

  oid = CeSeekDatabase(m_hDB_RTUProtocol, CEDB_SEEK_CURRENT, 1, &dwIndex);
 }

 return TRUE;
}

void CProtocolDB::SetbUpdateDataBase(BOOL bUpdateDataBase)
{
 m_bUpdateDataBase = bUpdateDataBase;
}
BOOL CProtocolDB::GetbUpdateDataBase()
{
 return m_bUpdateDataBase;
}


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理