def FieldConvert(self, strValue, strField=None):
if dmGlobals.TraceFunctionMessages: print 'Method: dmParameters:FieldConvert(stringValue, stringFieldName)'
FieldValue = self.Field
if strField != None:
FieldValue = strField
theVal = strValue
try:
if FieldValue in dmGlobals.ALLOWEDVALS:
if FieldValue in dmGlobals.FIELDSLIST and not dmGlobals.IsList(strValue):
theVal = strValue.Split(Array[str](dmGlobals.CRLISTDELIMITER), StringSplitOptions.RemoveEmptyEntries)
elif FieldValue in dmGlobals.FIELDSBOOL and not dmGlobals.IsBool(strValue):
theVal = dmGlobals.StringToBool(strValue)
elif FieldValue in dmGlobals.FIELDSDATETIME and not dmGlobals.IsDateTime(strValue):
theVal = dmGlobals.StringToDate(strValue)
elif FieldValue in dmGlobals.FIELDSNUMERIC and not dmGlobals.IsFloat(strValue):
theVal = dmGlobals.StringToFloat(strValue)
elif FieldValue in dmGlobals.FIELDSMANGAYESNO and not dmGlobals.IsMangaYesNo(strValue):
theVal = dmGlobals.StringToMangaYesNo(strValue)
elif FieldValue in dmGlobals.FIELDSYESNO and not dmGlobals.IsYesNo(strValue):
theVal = dmGlobals.StringToYesNo(strValue)
elif FieldValue in dmGlobals.FIELDSPSUEDONUMERIC and not isinstance(strValue,str):
try:
theVal = strValue.ToString()
except:
pass
#otherwise just return the value
except Exception as ex:
pass
return theVal
评论列表
文章目录