示例#1
0
        private static IList <object> ToDataTableRow(IDictionary <string, object> dict, IList <MyGridColumn> columns)
        {
            NotNull(dict, "dict");
            NotNull(columns, "columns");

            return(columns.Select <MyGridColumn, object>(gc => {
                var origin = dict.ContainsKey(gc.DataKey) ? dict[gc.DataKey].TrimStr() : "";
                if (origin.Length == 0)
                {
                    return null;
                }
                switch (gc.Type)
                {
                case MyGridColumnType.Text:
                    return origin;

                case MyGridColumnType.Number:
                    return Convert.ToInt64(origin);

                case MyGridColumnType.Money:
                    return Commons.ToDecimal(origin);

                case MyGridColumnType.IntMoney:
                    return decimal.Floor(Commons.ToDecimal(origin));

                case MyGridColumnType.Percent:
                    return Convert.ToDouble(origin);

                case MyGridColumnType.Date:
                case MyGridColumnType.DateTime: {
                    var dateTime = Commons.FromTimestamp(Convert.ToInt64(origin));
                    if (dateTime.Year >= 3000)
                    {
                        return null;
                    }
                    else
                    {
                        return dateTime;
                    }
                }

                case MyGridColumnType.Boolean:
                    return Commons.ToBoolean(origin);

                default:
                    return origin;
                }
            }).ToList());
        }