//取得某字段的位置(从零开始) 失败,则返回-1. int CFieldList::IndexOf(CTString strFieldName) { CField *pField = FieldByName(strFieldName); if (pField ==NULL ) return -1; return m_pPages->m_pFields->IndexOf(pField); }
/************************************************************************************ 函数名称: CFieldList::GetExclusiveName 功能说明: 获得strFldName在字段集中的唯一字段名,用于字段有重名时获取. 详细解释: 出入参数: [in] :strFldName,字段名字. 返回类型: 制作: 修改: ************************************************************************************/ CTString CFieldList::GetExclusiveName(CField* pFld) { CTString strOldName = pFld->GetFieldName(); CTString strName(strOldName); int Cnt = 0; TVarInfo var(strName,""); var.strName = strName; while(FieldByName(strName)) { Cnt++; var.count = Cnt; strName = var.AdjustAlias(); strName.Format("%s%d",strName,Cnt); } return strName; }
/************************************************************************************ 函数名称: CField* CFields::NewFieldType(CFieldType chType) 功能说明:根据传入的字段类型生成相应的字段类型. 详细解释:1.返回新生成的字段. 2.如果传入的chType无效,则返回NULL. 出入参数: [in]: 1.chType:传入的字段类型. [out]:无. 返回类型:CField* 制作:YTLI 2002/07/15 修改: ***********************************************************************************/ CField* CFields::NewFieldType(CFields* pOwner ,CFieldType chType) { CField* pField = NULL;//如果传入的chType无效,则返回NULL. switch(chType) { case fString : pField = new CStringField(this); break; case fDouble : pField = new CDoubleField(this); break; case fInt : pField = new CIntField(this); break; case fBoolean : pField = new CBooleanField(this); break; case fDate : pField = new CDateField(this); break; case fCurrency : pField = new CCurrencyField(this); break; } CTString str;//###_Mod 2002-9-24 zlq 缺省字段名 int nCount = m_FieldVersion.GetAbsoluteFieldCount(); do {//#_S 2003-5-28 $ 9 zlq 确保生成时,就唯一 str.Format("%d",nCount+1); while (str.GetLength()<4) {//#_修改 2002-11-15 $ 9:15:44 zlq str = "0"+str; } str = "变量" +str; nCount++; }while (FieldByName(str)!=NULL); pField->SetFieldName(str); pField->m_pFields = pOwner; return pField ; }
//取值并字符处理后返回 CString CSObj::GetValue(CString sKeyName) { return EnterTo( FieldByName( sKeyName ) ); }