示例#1
0
BOOL CObjectAttDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	if(m_pRecordset != NULL)
	{		
		m_lstObject.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_INFOTIP|LVS_EX_FULLROWSELECT);
		LVCOLUMN lvColumn;
		lvColumn.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_FMT;
		lvColumn.fmt = LVCFMT_LEFT;
		
		CString strText = _T("");
		lvColumn.cx = 100;
		
		strText.LoadString(IDS_FIELD_NAME);
		OgdcString strTmp = (OgdcString)strText;
		lvColumn.pszText = (char*)strTmp.Cstr();
		
		m_lstObject.InsertColumn(0, &lvColumn);

		lvColumn.cx = 100;
		strText.LoadString(IDS_FIELD_VALUE);
		OgdcString strTmp2 = (OgdcString)strText;
		lvColumn.pszText = (char*)strTmp2.Cstr();
		m_lstObject.InsertColumn(1, &lvColumn);

		OgdcFieldInfos fieldInfos;
		m_pRecordset->GetFieldInfos(fieldInfos);
		for(int i=0;i<fieldInfos.GetSize();i++)
		{
			OgdcFieldInfo fieldInfo = fieldInfos.GetAt(i);
			OgdcString strName = fieldInfo.m_strForeignName;
			if(strName.IsEmpty())
			{
				strName = fieldInfo.m_strName;
			}
			m_lstObject.InsertItem(i, strName);
			m_lstObject.SetItemText(i, 0, fieldInfo.m_strName);
			OgdcVariant var;
			m_pRecordset->GetFieldValue(fieldInfo.m_strName, var);
			m_lstObject.SetItemText(i, 1, var.ToString());
		}
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#2
0
OgdcBool OgdcFeatureMdb::SetValue( OgdcInt nIndex, const OgdcVariant& varValue )
{
	if (nIndex >= m_fieldValues.GetSize())
	{
		return FALSE;
	}
			
	OgdcByte* pData = new OgdcByte[m_fieldDefines.ElementAt(nIndex).m_nSize];
	OgdcByte* pDataMirror = pData;
	switch (m_fieldDefines.ElementAt(nIndex).m_nType)
	{		
	case OgdcFieldInfo::Boolean:
	case OgdcFieldInfo::Byte:
		{
			OgdcByte nResult = (OgdcByte)varValue.ToInt();
			memcpy(pDataMirror, &nResult,sizeof(OgdcByte));
			break;
		}
	case OgdcFieldInfo::INT16:
		{
			OgdcShort nResult = (OgdcShort)varValue.ToInt();
			memcpy(pDataMirror, &nResult,sizeof(OgdcShort));
			break;
		}
	case OgdcFieldInfo::INT32:
		{
			OgdcInt nResult = varValue.ToInt();
			memcpy(pDataMirror, &nResult, sizeof(OgdcInt));
			break;
		}
	case OgdcFieldInfo::INT64:
		{
			OgdcLong nResult = varValue.ToLong();
			memcpy(pDataMirror, &nResult, sizeof(OgdcLong));
			break;
		}
	case OgdcFieldInfo::Float:
		{
			OgdcFloat fResult = (OgdcFloat)varValue.ToDouble();
			memcpy(pDataMirror, &fResult, sizeof(OgdcFloat));
			break;
		}
	case OgdcFieldInfo::Double:
		{
			OgdcDouble dResult = varValue.ToDouble();
			memcpy(pDataMirror, &dResult, sizeof(OgdcDouble));
			break;
		}
	case OgdcFieldInfo::Text:
	case OgdcFieldInfo::Char:
	case OgdcFieldInfo::NText:
		{
			OgdcString strTemp = varValue.ToString();
			strTemp.SetCharset(m_nCharset);
			OgdcInt nLength = strTemp.GetLength() + 1;
			OgdcInt nByteSize = nLength * sizeof(OgdcChar);
			OgdcByte* pByte1 = new OgdcByte[nByteSize];
			memset(pByte1, 0, nByteSize);
			strcpy((char*)pByte1, (char*)strTemp.Cstr());
			m_fieldValues.SetAt(nIndex, pByte1);
			delete pData;
			pData = NULL;
			pByte1 = NULL;
			return TRUE;
		}
	case OgdcFieldInfo::Date:
	case OgdcFieldInfo::Time:	
	case OgdcFieldInfo::TimeStamp:
		{
			if (varValue.GetType() == OgdcVariant::Time) 
			{	
				memcpy(pDataMirror, &varValue.GetValue().tmVal,sizeof(OgdcDouble));
			}			
			break;
		}
	case OgdcFieldInfo::LongBinary:
		{
			if (varValue.GetType() == OgdcVariant::Binary) 
			{	
				OgdcInt nLength = varValue.m_value.binVal.nSize;
				nLength = OGDCMIN(m_fieldDefines.ElementAt(nIndex).m_nSize, nLength);
			
				memcpy(pDataMirror, varValue.m_value.binVal.pVal, nLength);
				m_fieldValues.SetAt(nIndex, pData);
				delete pData;
				pData = NULL;
				return TRUE;
			}		
			break;
		} 
	case OgdcFieldInfo::Geometry:
	default:
		return FALSE;		
	}
	if (pData == NULL)
	{
		pData = new OgdcByte[m_fieldDefines.ElementAt(nIndex).m_nSize];
	}
	delete m_fieldValues.ElementAt(nIndex);
	m_fieldValues.SetAt(nIndex, pData);

	//!!这里不能删除,不然外面又没值
//	delete pData;
	pData = NULL;
	pDataMirror = NULL;
	return TRUE;
}