Exemplo n.º 1
0
 /// <summary>
 /// add
 /// </summary>
 /// <param name="pParam"></param>
 /// <returns></returns>
 public RptParam Add(RptParam pParam)
 {
     base.Add(pParam.ParamName, pParam);
     return(pParam);
 }
Exemplo n.º 2
0
        //画文本对象
        private void drawTextObj(Graphics g, DIYReport.Interface.IRptSingleObj pObj, DataRow pDRow)
        {
            DIYReport.Interface.IRptTextObj textObj = pObj as DIYReport.Interface.IRptTextObj;
            StringFormat strFormat = new StringFormat();
            SolidBrush   foreBrush = new SolidBrush(pObj.ForeColor);

            if (textObj.WordWrap == false)
            {
                strFormat.Trimming    = StringTrimming.EllipsisCharacter;
                strFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit;
            }
            else
            {
                strFormat.FormatFlags = StringFormatFlags.LineLimit;
            }
            strFormat.Alignment = textObj.Alignment;
            RectangleF strRect    = RealRectangle(textObj);
            SizeF      fontSize   = g.MeasureString("A", textObj.Font);
            float      fontFirstY = strRect.Y + (textObj.Size.Height - fontSize.Height) / 2;

            strRect.Y = fontFirstY;
            if (textObj.Type == DIYReport.ReportModel.RptObjType.Text)
            {
                DIYReport.ReportModel.RptObj.RptLable lab = pObj as DIYReport.ReportModel.RptObj.RptLable;
                if (lab.Text != null)
                {
                    g.DrawString(lab.Text, lab.Font, foreBrush, strRect, strFormat);
                }
            }
            else
            {
                //如果绑定的不是文本而是字段、表达式或者系统参数等,那么就需要对它进行解释并绘制它
                string val = "";
                DIYReport.ReportModel.RptObj.RptExpressBox box = pObj as DIYReport.ReportModel.RptObj.RptExpressBox;
                if (box.DataSource != null && box.DataSource != "" && box.DataSource != "[未绑定]")
                {
                    switch (box.ExpressType)
                    {
                    case ReportModel.ExpressType.Express:
                        int beginIndex = 0, endIndex = 0;
                        if (box.Section.SectionType == DIYReport.SectionType.ReportBottom)                                 //统计的字段在报表脚,那么是统计所有的行
                        {
                            beginIndex = 0;
                            endIndex   = _Rows.Length;
                        }
                        else if (box.Section.SectionType == DIYReport.SectionType.PageFooter)                                //统计的字段在页脚,那么是统计当前页所有的行
                        {
                            beginIndex = _HasDrawRowCount - _RowPoint;
                            endIndex   = _HasDrawRowCount;
                        }
                        else if (box.Section.SectionType == DIYReport.SectionType.GroupFooter)                                //统计的字段在分组的脚,那么统计分组涉及到的行
                        {
                            DIYReport.Print.DrawGroupField groupField = _DrawDetailInfo.GetGroupFieldByName(box.Section.GroupField.FieldName);
                            beginIndex = groupField.PrevFirstRowIndex;
                            endIndex   = _HasDrawRowCount;
                        }
                        else
                        {
                            //g.DrawString("不支持的表达式",box.Font,foreBrush,strRect,strFormat);
                            g.DrawString(string.Empty, box.Font, foreBrush, strRect, strFormat);
                            break;
                        }
                        val = DIYReport.Express.ExStatistical.GetStatisticalValue(beginIndex, endIndex - 1, box.DataSource, box.BingDBFieldName, _Rows);
                        if (val == null)
                        {
                            val = " ";
                        }
                        double dval = DIYReport.PublicFun.ToDouble(val);
                        if (box.FormatStyle != null && box.FormatStyle != "")
                        {
                            try{
                                //val = String.Format(box.FormatStyle,dval);
                                val = DIYReport.PublicFun.FormatString(box.FormatStyle.Trim(), dval);
                            }
                            catch {}
                        }
                        g.DrawString(val, box.Font, foreBrush, strRect, strFormat);
                        break;

                    case ReportModel.ExpressType.SysParam:                               //系统参数
                        Type       clsType = System.Type.GetType("DIYReport.Express.ExSpecial");
                        MethodInfo meth    = clsType.GetMethod(box.DataSource);
                        if (meth != null)
                        {
                            object speTxt = meth.Invoke(clsType, null);
                            val = speTxt.ToString();
                        }
                        g.DrawString(val, box.Font, foreBrush, strRect, strFormat);
                        break;

                    case ReportModel.ExpressType.UserParam:                             //用户外部参数
                        DIYReport.ReportModel.RptParam param = DIYReport.UserDIY.DesignEnviroment.CurrentReport.UserParamList[box.DataSource];
                        if (param != null)
                        {
                            g.DrawString(param.Value.ToString(), box.Font, foreBrush, strRect, strFormat);
                        }
                        break;

                    case ReportModel.ExpressType.Field:                             //用户绑定字段
//							string str = "";
//							if(pDRow!=null)
//								str = pDRow[box.DataSource].ToString();
//							g.DrawString(str,box.Font ,foreBrush,RealRectangle(box) ,strFormat);
                        DrawField(g, pDRow, box, foreBrush, strRect, strFormat);
                        break;

                    default:
                        break;
                    }
                }
            }
            if (textObj.ShowFrame == true)
            {
                drawRect(g, pObj);
            }
        }