bool ui2db(ref object value, sys_column yoColumn) { var result = true; switch (yoColumn.datatype) { case DataType.ID: case DataType.Refer: result = YoConvert.ToInt(ref value); break; case DataType.Number: case DataType.Calc: result = YoConvert.ToDouble(ref value); break; case DataType.Text: case DataType.Set: result = YoConvert.ToString(ref value); break; case DataType.Datetime: result = YoConvert.ToDatetime(ref value); break; } return(result); }
bool checkUptime() { bool result = false; while (true) { if (!m_yoColumnDict.ContainsKey(UPTIME)) { result = true; break; } // ui uptime if (!m_uiDict.ContainsKey(UPTIME)) { break; } object uiUptime = m_uiDict[UPTIME]; if (!YoConvert.ToDatetime(ref uiUptime)) { break; } // db uptime var uptime = m_dataRow[UPTIME]; if (!YoConvert.ToDatetime(ref uptime)) { break; } if ((DateTime)uptime != (DateTime)uiUptime) { break; } result = true; break; } return(result); }
object db2ui(object value, sys_column yoColumn) { object result = value; switch (yoColumn.datatype) { case DataType.Number: case DataType.Calc: { object format = yoColumn.format; if (format != null && YoConvert.ToInt(ref format)) { result = string.Format("{0:F" + format + "}", value); } } break; case DataType.Datetime: if (yoColumn.format != null && YoConvert.ToDatetime(ref value)) { result = ((DateTime)value).ToShortDateString(); } break; case DataType.Set: if (value != null && yoColumn.setDict != null) { var setKey = value.ToString(); if (yoColumn.setDict.ContainsKey(setKey)) { result = yoColumn.setDict[setKey]; } } break; } return(result); }