Ejemplo n.º 1
0
        public static ReportClass GetClass(string classID)
        {
            int id = 0;

            if (!int.TryParse(classID, out id))
            {
                throw new ReportTypeIDInvalidException(classID);
            }
#if DEBUG
            if (id != 1 && id != 0 && id != 2)
            {
                throw new ReportTypeIDInvalidException(classID);
            }
#endif
            ReportClass reportClass = Grid;
            if (freeForm.TypeID == id)
            {
                reportClass = FreeForm;
            }
            else if (bigText.typeID == id)
            {
                reportClass = BigText;
            }
            return(reportClass);
        }
Ejemplo n.º 2
0
        private void addProperty(string context)
        {
            //如d0001=xxx
            int spliteIndex = context.IndexOf("=");

            if (spliteIndex <= 0)
            {
                throw new ReportPropertyFormatException(context);
            }
            //段标识
            string key = context.Substring(0, spliteIndex);

            if (key.Length < 3)
            {
                throw new ReportPropertyKeyException(context);
            }
            string val = context.Remove(0, spliteIndex + 1);

            //寻找属性字段
            switch (int.Parse(key.Substring(1, 3)))
            {
            case 1:
                if (key.Length <= 4)
                {
                    //报表类型1:自由风格报表 0:网格风格报表
                    //d001=0|1
                    if (val == "3")
                    {
                        val = "1";
                    }
                    report.RptClass = ReportClass.GetClass(val);
                }
                else
                {
                    //报表整体属性
                    //d001001=报表名称,上边界,下边界,左边界,右边界,纸张方向,行高,横向分页设置,缺省省字体大小,表脚是每页都打印还是只在最后页打印,是否简洁报表样式,表格线宽度
                    report.Attributes.Add(val);
                }
                break;

            case 2:
                //该段无用,直接丢弃
                break;

            case 3:
                //报表列相关
                if (key.Length > 4)
                {
                    report.Columns.Add(key, val);
                }
                break;

            case 4:
                //Band区相关
                if (key.Length == 12)
                {
                    report.Bands.SetBindRowEcho(key, val);
                }
                else if (key.Length == 8)
                {
                    report.Bands.SetBindRowNum(key, val);
                }
                break;

            case 5:
                if (key.Length == 8)
                {
                    report.Texts.Add(val);
                }
                else if (key.Length == 4)
                {
                    int textCount = 0;
                    if (!int.TryParse(val, out textCount))
                    {
                        throw new TextCountInvalidException();
                    }
                    report.Texts.Capacity = textCount;
                }
                break;
            }
        }