Exemplo n.º 1
0
        /// <summary>
        /// 输出转换
        /// </summary>
        public override object InputConvert(object sourceValue, ColumnItemModel colmodel)
        {
            //string name = colmodel.Property.Name;
            //if (name == @"TimeAdd") {
            //    name = name;
            //}
            Type propertytype = colmodel.Property.PropertyType;

            if (propertytype.BaseType.FullName == typeof(Enum).FullName)
            {
                sourceValue = ConvertTool.ObjToInt(sourceValue, 0);
            }

            if (propertytype.FullName == typeof(Int32).FullName)
            {
                sourceValue = ConvertTool.ObjToInt(sourceValue, 0);
            }
            if (propertytype.FullName == typeof(Single).FullName)
            {
                sourceValue = ConvertTool.ObjToFloat(sourceValue, 0);
            }
            if (propertytype.FullName == typeof(Double).FullName)
            {
                sourceValue = ConvertTool.ObjToFloat(sourceValue, 0);
            }
            if (propertytype.FullName == typeof(Boolean).FullName)
            {
                sourceValue = ConvertTool.ObjToBool(sourceValue, false);
            }
            if (propertytype.FullName == typeof(DateTime).FullName)
            {
                sourceValue = ConvertTool.ObjToDateTime(sourceValue, SqlDateTime.MinValue.Value);
            }

            return(sourceValue);
        }