Esempio n. 1
0
        bool IsFieldNumber(
            string fieldName)
        {
            // sanity
            if (_schema == null)
            {
                return(false);
            }

            // check field type
            C1.Win.FlexReport.FieldInfo fi = _schema.Fields.Find((fi_) => fi_.Name == fieldName);
            if (fi == null)
            {
                return(false);
            }

            switch (Type.GetTypeCode(fi.DataType))
            {
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
            case TypeCode.Single:
            case TypeCode.Double:
            case TypeCode.Decimal:
                return(true);
            }

            // not a number
            return(false);
        }
Esempio n. 2
0
        int GetFieldWidth(
            string fieldName)
        {
            int size = 10; // << default value in chars

            // use schema information if available
            if (_schema != null)
            {
                // C1.C1Report.FieldInfo fi = _schema[fieldName];
                C1.Win.FlexReport.FieldInfo fi = _schema.Fields.Find((fi_) => fi_.Name == fieldName);
                if (fi != null)
                {
                    switch (Type.GetTypeCode(fi.DataType))
                    {
                    case TypeCode.String:
                        size = (fi.MaxLength < 0) ? DEFCHARCOUNT : Math.Min(fi.MaxLength, 5000);
                        break;

                    case TypeCode.Boolean:
                    case TypeCode.Byte:
                        size = 3;
                        break;

                    case TypeCode.Int16:
                    case TypeCode.Int32:
                    case TypeCode.Int64:
                        size = 6;
                        break;

                    case TypeCode.Decimal:
                    case TypeCode.Single:
                    case TypeCode.Double:
                        size = 10;
                        break;

                    case TypeCode.DateTime:
                        size = 10;
                        break;

                    default:
                        Debug.WriteLine(string.Format("** don't know the width for {0}", fi.DataType));
                        break;
                    }
                }
            }

            // convert from chars to twips (approximation)
            return(size * 1440 * 8 / 72);
        }