Exemple #1
0
        public static DateTimeOffset?GetConvertdatetimeoffset(this IDataRecord dr, int i)
        {
            if (dr.IsDBNull(i))
            {
                return(default(DateTimeOffset));
            }
            var date = dr.GetValue(i);

            if (date is DateTime)
            {
                return(UtilMethods.GetDateTimeOffsetByDateTime((DateTime)(date)));
            }
            else
            {
                var result = (DateTimeOffset)date;
                return(result);
            }
        }
Exemple #2
0
        public static object ConvertDataByTypeName(string ctypename, string value)
        {
            var item = new ConditionalModel()
            {
                CSharpTypeName = ctypename,
                FieldValue     = value
            };

            if (item.CSharpTypeName.EqualCase(UtilConstants.DecType.Name))
            {
                return(Convert.ToDecimal(item.FieldValue));
            }
            else if (item.CSharpTypeName.EqualCase(UtilConstants.DobType.Name))
            {
                return(Convert.ToDouble(item.FieldValue));
            }
            else if (item.CSharpTypeName.EqualCase(UtilConstants.DateType.Name))
            {
                return(Convert.ToDateTime(item.FieldValue));
            }
            else if (item.CSharpTypeName.EqualCase(UtilConstants.IntType.Name))
            {
                return(Convert.ToInt32(item.FieldValue));
            }
            else if (item.CSharpTypeName.EqualCase(UtilConstants.LongType.Name))
            {
                return(Convert.ToInt64(item.FieldValue));
            }
            else if (item.CSharpTypeName.EqualCase(UtilConstants.ShortType.Name))
            {
                return(Convert.ToInt16(item.FieldValue));
            }
            else if (item.CSharpTypeName.EqualCase(UtilConstants.DateTimeOffsetType.Name))
            {
                return(UtilMethods.GetDateTimeOffsetByDateTime(Convert.ToDateTime(item.FieldValue)));
            }
            else
            {
                return(item.FieldValue);
            }
        }