Пример #1
0
        private ReportParameter GetRptParams()
        {
            ReportParameter rptParams = new ReportParameter();
            string dsName = "NewDataSet";
            if (_isWebReport)
            {
                rptParams.RptRootName = this.cmbRootName.Text;
                rptParams.RptXSDFile = this.cmbXSDName.Text;
                if (this.cmbXSDName.Text.IndexOf(".xsd") != -1)
                    dsName = this.cmbXSDName.Text.Substring(0, this.cmbXSDName.Text.IndexOf(".xsd"));
            }
            else
            {
                rptParams.RptProjName = this.cmbProName.Text;
                rptParams.RptXSDFile = this.cmbWinXSDName.Text;
                if (this.cmbWinXSDName.Text.IndexOf(".xsd") != -1)
                    dsName = this.cmbWinXSDName.Text.Substring(0, this.cmbWinXSDName.Text.IndexOf(".xsd"));
            }
            rptParams.RptFileNames = new string[] { this.txtRptFileName.Text, this.txtDetailsRptFileName.Text };
            rptParams.IsMasterDetails = this.chkIsMasterDetails.Checked;
            rptParams.RptStyle = (EEPReportStyle)this.cmbMasterReportStyle.SelectedIndex;
            rptParams.LayoutColumnNum = (int)this.numLayoutColumn.Value;
            rptParams.SelectAlias = this.cmbSelectAlias.Text;
            rptParams.ClientType = (ClientType)this.cmbDataBaseType.SelectedIndex;
            rptParams.RptSet = new ReportSet(dsName);
            rptParams.HorGaps = this.tbHorGaps.Text;
            rptParams.VertGaps = this.tbVertGaps.Text;

            foreach (System.Windows.Forms.TreeNode tabNode in this.tvGroupSelect.Nodes)
            {
                ReportTable tab = null;
                if (rptParams.IsMasterDetails)
                {
                    if (ds.Relations.Count > 0 && tabNode.Text != ds.Relations[0].ParentTable.TableName)
                        tab = new ReportTable(tabNode.Text);
                    else
                        tab = new ReportTable(tabNode.Text, this.txtRptCaption.Text);
                }
                else
                {
                    tab = new ReportTable(tabNode.Text, this.txtRptCaption.Text);
                }

                foreach (System.Windows.Forms.TreeNode colNode in tabNode.Nodes)
                {
                    tab.ReportColumns.Add(new ReportColumn(colNode.Text, colNode.Checked));
                }
                rptParams.RptSet.ReportTables.Add(tab);
            }

            return rptParams;
        }
Пример #2
0
        private void GenSingleLabelRdlc(string rdlcFileName, TBlockItem BlockItem, bool isMaster, String detailsRptFileName = "", DataColumn[] relationColumns = null)
        {
            String DataSetName = BlockItem.TableName;
            String ModuleName = FClientData.ProviderName.Substring(0, FClientData.ProviderName.IndexOf('.'));
            String SolutionName = System.IO.Path.GetFileNameWithoutExtension(FDTE2.Solution.FullName);
            String realTableName = CliUtils.GetTableName(ModuleName, DataSetName, SolutionName, "", true);
            realTableName = WzdUtils.RemoveQuote(realTableName, FClientData.DatabaseType);

            DataTable dtDataDic = GetDDTable(FClientData.DatabaseType, FClientData.Owner.SelectedAlias, realTableName);
            XmlDocument doc = new XmlDocument();
            doc.Load(rdlcFileName);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("ms", ms);
            nsmgr.AddNamespace("rd", rd);
            GenDataSources(doc, nsmgr);
            GenDataSets(doc, nsmgr, BlockItem);
            ReportTable rt = new ReportTable(BlockItem.TableName);
            foreach (TBlockFieldItem item in BlockItem.BlockFieldItems)
            {
                bool isGroup = false;
                if (!String.IsNullOrEmpty(item.CheckNull) && item.CheckNull.ToLower() == "true")
                    isGroup = true;
                ReportColumn rc = new ReportColumn(item.DataField, isGroup);
                rc.TextAlign = item.EditMask;
                rt.ReportColumns.Add(rc);
            }
            //GenList(doc, nsmgr, rt, FClientData.TableName);

            XmlNode nBodyRptItems = doc.SelectSingleNode("ms:Report/ms:Body/ms:ReportItems", nsmgr);
            XmlNode nRect = nBodyRptItems.SelectSingleNode("ms:Rectangle[@Name='rectContainer']", nsmgr);
            nBodyRptItems.RemoveChild(nRect);
            //List
            XmlNode nTablix = doc.CreateElement("Tablix", nBodyRptItems.NamespaceURI);
            XmlAttribute aListName = doc.CreateAttribute("Name");
            aListName.Value = "lstContainer";
            nTablix.Attributes.Append(aListName);
            XmlNode nTablixBody = doc.CreateElement("TablixBody", nBodyRptItems.NamespaceURI);
            nTablix.AppendChild(nTablixBody);
            XmlNode nTablixColumns = doc.CreateElement("TablixColumns", nBodyRptItems.NamespaceURI);
            nTablixBody.AppendChild(nTablixColumns);
            XmlNode nTablixColumn = doc.CreateElement("TablixColumn", nBodyRptItems.NamespaceURI);
            nTablixColumns.AppendChild(nTablixColumn);
            XmlNode nWidth = doc.CreateElement("Width", nBodyRptItems.NamespaceURI);
            nWidth.InnerText = "21cm";
            nTablixColumn.AppendChild(nWidth);
            XmlNode nTablixRows = doc.CreateElement("TablixRows", nBodyRptItems.NamespaceURI);
            nTablixBody.AppendChild(nTablixRows);
            XmlNode nTablixRow = doc.CreateElement("TablixRow", nBodyRptItems.NamespaceURI);
            nTablixRows.AppendChild(nTablixRow);
            XmlNode nHeight = doc.CreateElement("Height", nBodyRptItems.NamespaceURI);
            nHeight.InnerText = "4.9cm";
            nTablixRow.AppendChild(nHeight);
            XmlNode nTablixCells = doc.CreateElement("TablixCells", nBodyRptItems.NamespaceURI);
            nTablixRow.AppendChild(nTablixCells);
            XmlNode nTablixCell = doc.CreateElement("TablixCell", nBodyRptItems.NamespaceURI);
            nTablixCells.AppendChild(nTablixCell);
            XmlNode nCellContents = doc.CreateElement("CellContents", nBodyRptItems.NamespaceURI);
            nTablixCell.AppendChild(nCellContents);
            XmlNode nRectangle = doc.CreateElement("Rectangle", nBodyRptItems.NamespaceURI);
            XmlAttribute aRectangleName = doc.CreateAttribute("Name");
            aRectangleName.Value = "lstContainer_Contents";
            nRectangle.Attributes.Append(aRectangleName);
            nCellContents.AppendChild(nRectangle);
            XmlNode nReportItems = doc.CreateElement("ReportItems", nBodyRptItems.NamespaceURI);
            nRectangle.AppendChild(nReportItems);
            XmlNode nRectangle2 = doc.CreateElement("Rectangle", nBodyRptItems.NamespaceURI);
            XmlAttribute aRectangle2Name = doc.CreateAttribute("Name");
            aRectangle2Name.Value = "rectContainer";
            nRectangle2.Attributes.Append(aRectangle2Name);
            nReportItems.AppendChild(nRectangle2);

            //生成Group设置
            if (HasGroupCondition(rt))
            {
                //Grouping
                XmlNode nGrouping = doc.CreateElement("Grouping", nTablix.NamespaceURI);
                XmlAttribute aGroupingName = doc.CreateAttribute("Name");
                aGroupingName.Value = "lstContainer_Details_" + FClientData.TableName;
                nGrouping.Attributes.Append(aGroupingName);
                //Grouping.PageBreakAtEnd
                XmlNode nPageBreakAtEnd = doc.CreateElement("PageBreakAtEnd", nTablix.NamespaceURI);
                nPageBreakAtEnd.InnerText = "true";
                nGrouping.AppendChild(nPageBreakAtEnd);
                //Grouping.GroupExpressions
                XmlNode nGroupExpressions = doc.CreateElement("GroupExpressions", nTablix.NamespaceURI);
                List<ReportColumn> lstGroupConditionFields = GetGroupConditionRptColumns(rt);
                foreach (ReportColumn cdtField in lstGroupConditionFields)
                {
                    //Grouping.GroupExpressions.GroupExpression
                    XmlNode nGroupExpression = doc.CreateElement("GroupExpression", nTablix.NamespaceURI);

                    nGroupExpression.InnerText = "=Fields!" + cdtField.ColumnName + ".Value";
                    nGroupExpressions.AppendChild(nGroupExpression);
                }
                nGrouping.AppendChild(nGroupExpressions);
                nTablix.AppendChild(nGrouping);
            }
            //List.Style
            XmlNode nListStyle = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
            //List.Style.FontFamily
            XmlNode nFont = doc.CreateElement("FontFamily", nBodyRptItems.NamespaceURI);
            nFont.InnerText = "PMingLiU";
            nListStyle.AppendChild(nFont);
            nTablix.AppendChild(nListStyle);
            nBodyRptItems.AppendChild(nTablix);

            XmlNode startNode = nRectangle2;//;GetStartXPathNode(doc, nsmgr, true, isMaster);
            //给Title赋值
            XmlNode nTitle = GetTitleNode(doc, nsmgr, true);
            if (nTitle != null)
            {
                XmlNode nTitleValue = nTitle.SelectSingleNode("ms:Paragraphs/ms:Paragraph/ms:TextRuns/ms:TextRun/ms:Value", nsmgr);
                if (nTitleValue != null)
                {
                    nTitleValue.InnerText = FClientData.FormTitle;
                }
            }

            #region GenDataRegion
            // Top Init
            float curLeft = 0.5f;
            float curTop = 0.5f;
            int layoutIndex = 0;
            XmlDocument docrealContext = startNode.OwnerDocument;
            XmlNode temNode = startNode;
            //if (!isMaster)
            //{
            temNode = docrealContext.CreateElement("ReportItems", temNode.NamespaceURI);
            //}
            int iLayoutColumnNum = 2;// rptParams.LayoutColumnNum
            String sHorGaps = "2.54";//rptParams.HorGaps
            String sVertGaps = "0.64";//rptParams.VertGaps
            for (int i = 0; i < rt.ReportColumns.Count; i++)
            {
                string colName = rt.ReportColumns[i].ColumnName;
                string EditMask = GetFieldEditMask(dtDataDic, colName);
                string textAlign = rt.ReportColumns[i].TextAlign;
                if (layoutIndex >= iLayoutColumnNum)
                {
                    layoutIndex = 0;
                    curLeft = 0.5f;
                    curTop += 0.94f;

                    //GenLabel
                    GenLabel(temNode, curLeft, curTop, "lbl" + colName, GetFieldCaption(dtDataDic, colName) + ":", sHorGaps, sVertGaps, false, "");
                    //GenrTextBox
                    curLeft += (float)Convert.ToDouble(sHorGaps);
                    GenLabel(temNode, curLeft, curTop, "txt" + colName, EditMask, sHorGaps, sVertGaps, false, textAlign);
                    layoutIndex++;
                    curLeft += (float)Convert.ToDouble(sHorGaps) + 0.5f;
                }
                else
                {
                    //GenLabel
                    GenLabel(temNode, curLeft, curTop, "lbl" + colName, GetFieldCaption(dtDataDic, colName) + ":", sHorGaps, sVertGaps, false, "");
                    //GenrTextBox
                    curLeft += (float)Convert.ToDouble(sHorGaps);
                    GenLabel(temNode, curLeft, curTop, "txt" + colName, EditMask, sHorGaps, sVertGaps, false, textAlign);
                    layoutIndex++;
                    curLeft += (float)Convert.ToDouble(sHorGaps) + 0.5f;
                }
            }
            //if (!isMaster)
            //{
            startNode.AppendChild(temNode);
            //}
            XmlNode nStyleRectangle = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
            startNode.AppendChild(nStyleRectangle);
            XmlNode nBorderStyleRectangle = doc.CreateElement("Border", nBodyRptItems.NamespaceURI);
            nStyleRectangle.AppendChild(nBorderStyleRectangle);
            XmlNode nStyleBorderStyleRectangle = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
            nStyleBorderStyleRectangle.InnerText = "Solid";
            nBorderStyleRectangle.AppendChild(nStyleBorderStyleRectangle);

            if (isMaster)
            {
                //nBodyRptItems
                XmlNode nSubreport = doc.CreateElement("Subreport", nBodyRptItems.NamespaceURI);
                XmlAttribute aSubreportName = doc.CreateAttribute("Name");
                aSubreportName.Value = "subreport1";
                nSubreport.Attributes.Append(aSubreportName);
                temNode.AppendChild(nSubreport);
                XmlNode nReportName = doc.CreateElement("ReportName", nBodyRptItems.NamespaceURI);
                nReportName.InnerText = detailsRptFileName;
                nSubreport.AppendChild(nReportName);
                XmlNode nKeepTogether1 = doc.CreateElement("KeepTogether", nBodyRptItems.NamespaceURI);
                nKeepTogether1.InnerText = "true";
                nSubreport.AppendChild(nKeepTogether1);
                XmlNode nTopSubreport = doc.CreateElement("Top", nBodyRptItems.NamespaceURI);
                nTopSubreport.InnerText = "9.8cm";
                nSubreport.AppendChild(nTopSubreport);
                XmlNode nHeightSubreport = doc.CreateElement("Height", nBodyRptItems.NamespaceURI);
                nHeightSubreport.InnerText = "9.6cm";
                nSubreport.AppendChild(nHeightSubreport);
                XmlNode nWidthSubreport = doc.CreateElement("Width", nBodyRptItems.NamespaceURI);
                nWidthSubreport.InnerText = "21cm";
                nSubreport.AppendChild(nWidthSubreport);

                //Parameters
                XmlNode nParameters = doc.CreateElement("Parameters", nBodyRptItems.NamespaceURI);
                foreach (DataColumn col in relationColumns)
                {
                    //Parameters.Parameter
                    XmlNode nParameter = doc.CreateElement("Parameter", nBodyRptItems.NamespaceURI);
                    XmlAttribute aParamName = doc.CreateAttribute("Name");
                    aParamName.Value = "p" + col.ColumnName;
                    nParameter.Attributes.Append(aParamName);
                    //Parameters.Parameter.Value
                    string EditMask = GetFieldEditMask(dtDataDic, col.ColumnName);
                    XmlNode nParamValue = doc.CreateElement("Value", nBodyRptItems.NamespaceURI);
                    nParamValue.InnerText = EditMask;
                    nParameter.AppendChild(nParamValue);
                    nParameters.AppendChild(nParameter);
                }
                nSubreport.AppendChild(nParameters);
            }

            GenReportBodyHeight(doc, curTop, nsmgr, isMaster);

            #endregion

            XmlNode nTablixColumnHierarchy = doc.CreateElement("TablixColumnHierarchy", nBodyRptItems.NamespaceURI);
            nTablix.AppendChild(nTablixColumnHierarchy);
            XmlNode nTablixMembers = doc.CreateElement("TablixMembers", nBodyRptItems.NamespaceURI);
            nTablixColumnHierarchy.AppendChild(nTablixMembers);
            XmlNode nTablixMember = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
            nTablixMembers.AppendChild(nTablixMember);

            XmlNode nTablixRowHierarchy = doc.CreateElement("TablixRowHierarchy", nBodyRptItems.NamespaceURI);
            nTablix.AppendChild(nTablixRowHierarchy);
            XmlNode nTablixMembers2 = doc.CreateElement("TablixMembers", nBodyRptItems.NamespaceURI);
            nTablixRowHierarchy.AppendChild(nTablixMembers2);
            XmlNode nTablixMember2 = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
            nTablixMembers2.AppendChild(nTablixMember2);
            XmlNode nGroup = doc.CreateElement("Group", nBodyRptItems.NamespaceURI);
            XmlAttribute aGroupName = doc.CreateAttribute("Name");
            aGroupName.Value = "lstContainer_Details_Group";
            nGroup.Attributes.Append(aGroupName);
            nTablixMember2.AppendChild(nGroup);
            XmlNode nDataElementName = doc.CreateElement("DataElementName", nBodyRptItems.NamespaceURI);
            nDataElementName.InnerText = "Item";
            nGroup.AppendChild(nDataElementName);
            XmlNode nDataElementName2 = doc.CreateElement("DataElementName", nBodyRptItems.NamespaceURI);
            nDataElementName2.InnerText = "Item_Collection";
            nTablixMember2.AppendChild(nDataElementName2);
            XmlNode nDataElementOutput = doc.CreateElement("DataElementOutput", nBodyRptItems.NamespaceURI);
            nDataElementOutput.InnerText = "Output";
            nTablixMember2.AppendChild(nDataElementOutput);
            XmlNode nKeepTogether = doc.CreateElement("KeepTogether", nBodyRptItems.NamespaceURI);
            nKeepTogether.InnerText = "true";
            nTablixMember2.AppendChild(nKeepTogether);

            doc.Save(rdlcFileName);
        }
Пример #3
0
        private void GenSingleTableRdlc(string rdlcFileName, TBlockItem BlockItem, bool isDetails)
        {
            String DataSetName = BlockItem.TableName;
            String ModuleName = FClientData.ProviderName.Substring(0, FClientData.ProviderName.IndexOf('.'));
            String SolutionName = System.IO.Path.GetFileNameWithoutExtension(FDTE2.Solution.FullName);
            String realTableName = CliUtils.GetTableName(ModuleName, DataSetName, SolutionName, "", true);
            realTableName = WzdUtils.RemoveQuote(realTableName, FClientData.DatabaseType);

            DataTable dtDataDic = GetDDTable(FClientData.DatabaseType, FClientData.Owner.SelectedAlias, realTableName);
            XmlDocument doc = new XmlDocument();
            doc.Load(rdlcFileName);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("ms", ms);
            nsmgr.AddNamespace("rd", rd);
            GenDataSources(doc, nsmgr);
            GenDataSets(doc, nsmgr, BlockItem);
            ReportTable rt = new ReportTable(BlockItem.TableName);
            foreach (TBlockFieldItem item in BlockItem.BlockFieldItems)
            {
                bool isGroup = false;
                if (!String.IsNullOrEmpty(item.CheckNull) && item.CheckNull.ToLower() == "true")
                    isGroup = true;
                ReportColumn rc = new ReportColumn(item.DataField, isGroup);
                rc.Width = item.Length * 0.2;
                if (rc.Width == 0)
                    rc.Width = 2;
                else if (rc.Width < 1)
                    rc.Width = 1;
                else if (rc.Width > 8)
                    rc.Width = 8;
                double titleWidth = (item.Description == null ? item.DataField.Length : item.Description.Length) * 0.4;
                if (rc.Width < titleWidth)
                    rc.Width = titleWidth;
                rc.TextAlign = item.EditMask;
                rt.ReportColumns.Add(rc);
            }

            XmlNode nBodyRptItems = doc.SelectSingleNode("ms:Report/ms:Body/ms:ReportItems", nsmgr);
            XmlNode nRect = nBodyRptItems.SelectSingleNode("ms:Rectangle[@Name='rectContainer']", nsmgr);
            nBodyRptItems.RemoveChild(nRect);
            //List
            XmlNode nRectangle1 = doc.CreateElement("Rectangle", nBodyRptItems.NamespaceURI);
            XmlAttribute aRectangleName1 = doc.CreateAttribute("Name");
            aRectangleName1.Value = "rectContainer";
            nRectangle1.Attributes.Append(aRectangleName1);
            XmlNode nReportItems1 = doc.CreateElement("ReportItems", nBodyRptItems.NamespaceURI);
            nRectangle1.AppendChild(nReportItems1);
            XmlNode nDataElementOutput1 = doc.CreateElement("DataElementOutput", nBodyRptItems.NamespaceURI);
            nDataElementOutput1.InnerText = "ContentsOnly";
            nRectangle1.AppendChild(nDataElementOutput1);
            XmlNode nListStyle1 = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
            //List.Style.FontFamily
            XmlNode nFont1 = doc.CreateElement("FontFamily", nBodyRptItems.NamespaceURI);
            nFont1.InnerText = "Verdana";
            nListStyle1.AppendChild(nFont1);
            nRectangle1.AppendChild(nListStyle1);
            XmlNode nTop1 = doc.CreateElement("Top", nBodyRptItems.NamespaceURI);
            nTop1.InnerText = "0cm";
            nRectangle1.AppendChild(nTop1);
            XmlNode nHeight3 = doc.CreateElement("Height", nBodyRptItems.NamespaceURI);
            nHeight3.InnerText = "5.5cm";
            nRectangle1.AppendChild(nHeight3);
            XmlNode nWidth3 = doc.CreateElement("Width", nBodyRptItems.NamespaceURI);
            nWidth3.InnerText = "21cm";
            nRectangle1.AppendChild(nWidth3);

            String sHorGaps = "2.54";//rptParams.HorGaps
            String sVertGaps = "0.64";//rptParams.VertGaps
            float curLeft = 0.5f;
            float curTop = 0.5f;
            if (isDetails)
            {
                //XmlNode nLine = doc.CreateElement("Line", nBodyRptItems.NamespaceURI);
                //XmlAttribute aLineName = doc.CreateAttribute("Name");
                //aLineName.Value = "line1";
                //nLine.Attributes.Append(aLineName);
                //nReportItems1.AppendChild(nLine);
                //XmlNode nTopLine = doc.CreateElement("Top", nBodyRptItems.NamespaceURI);
                //nTopLine.InnerText = "1.5cm";
                //nLine.AppendChild(nTopLine);
                //XmlNode nHeightLine = doc.CreateElement("Height", nBodyRptItems.NamespaceURI);
                //nHeightLine.InnerText = "0cm";
                //nLine.AppendChild(nHeightLine);
                //XmlNode nWidthLine = doc.CreateElement("Width", nBodyRptItems.NamespaceURI);
                //nWidthLine.InnerText = "21cm";
                //nLine.AppendChild(nWidthLine);
                //XmlNode nStyleLine = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
                //nLine.AppendChild(nStyleLine);
                //XmlNode nBorderStyleLine = doc.CreateElement("Border", nBodyRptItems.NamespaceURI);
                //nStyleLine.AppendChild(nBorderStyleLine);
                //XmlNode nStyleBorderStyleLine = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
                //nStyleBorderStyleLine.InnerText = "Solid";
                //nBorderStyleLine.AppendChild(nStyleBorderStyleLine);
                //XmlNode nFontFamilyStyleLine = doc.CreateElement("FontFamily", nBodyRptItems.NamespaceURI);
                //nFontFamilyStyleLine.InnerText = "Verdana";
                //nStyleLine.AppendChild(nFontFamilyStyleLine);

                //int layoutIndex = 0;
                //foreach (var item in BlockItem.Relation.ParentColumns)
                //{
                //    string colName = item.ColumnName;
                //    string EditMask = GetFieldEditMask2(dtDataDic, colName);

                //    GenLabel(nReportItems1, curLeft, curTop, "cap" + colName, GetFieldCaption(dtDataDic, colName), sHorGaps, sVertGaps, false);
                //    curLeft += (float)Convert.ToDouble(sHorGaps);
                //    GenLabel(nReportItems1, curLeft, curTop, "txt" + colName, EditMask, sHorGaps, sVertGaps, false);
                //    layoutIndex++;
                //    curLeft += (float)Convert.ToDouble(sHorGaps) + 0.5f;
                //}
            }

            XmlNode nTablix = doc.CreateElement("Tablix", nBodyRptItems.NamespaceURI);
            XmlAttribute aListName = doc.CreateAttribute("Name");
            aListName.Value = "lstContainer";
            nTablix.Attributes.Append(aListName);
            nReportItems1.AppendChild(nTablix);
            XmlNode nTablixBody = doc.CreateElement("TablixBody", nBodyRptItems.NamespaceURI);
            nTablix.AppendChild(nTablixBody);
            XmlNode nTablixColumns = doc.CreateElement("TablixColumns", nBodyRptItems.NamespaceURI);
            nTablixBody.AppendChild(nTablixColumns);
            for (int i = 0; i < rt.ReportColumns.Count; i++)
            {
                XmlNode nTablixColumn = doc.CreateElement("TablixColumn", nBodyRptItems.NamespaceURI);
                nTablixColumns.AppendChild(nTablixColumn);
                XmlNode nWidth = doc.CreateElement("Width", nBodyRptItems.NamespaceURI);
                nWidth.InnerText = rt.ReportColumns[i].Width.ToString() + "cm";
                nTablixColumn.AppendChild(nWidth);
            }
            XmlNode nTablixRows = doc.CreateElement("TablixRows", nBodyRptItems.NamespaceURI);
            nTablixBody.AppendChild(nTablixRows);

            for (int j = 0; j < 2; j++)
            {
                XmlNode nTablixRow = doc.CreateElement("TablixRow", nBodyRptItems.NamespaceURI);
                nTablixRows.AppendChild(nTablixRow);
                XmlNode nHeight = doc.CreateElement("Height", nBodyRptItems.NamespaceURI);
                nHeight.InnerText = "0.64cm";
                nTablixRow.AppendChild(nHeight);
                XmlNode nTablixCells = doc.CreateElement("TablixCells", nBodyRptItems.NamespaceURI);
                nTablixRow.AppendChild(nTablixCells);

                //生成Group设置
                //if (HasGroupCondition(rt))
                //{
                //    //Grouping
                //    XmlNode nGrouping = doc.CreateElement("Grouping", nTablix.NamespaceURI);
                //    XmlAttribute aGroupingName = doc.CreateAttribute("Name");
                //    aGroupingName.Value = "lstContainer_Details_" + FClientData.TableName;
                //    nGrouping.Attributes.Append(aGroupingName);
                //    //Grouping.PageBreakAtEnd
                //    XmlNode nPageBreakAtEnd = doc.CreateElement("PageBreakAtEnd", nTablix.NamespaceURI);
                //    nPageBreakAtEnd.InnerText = "true";
                //    nGrouping.AppendChild(nPageBreakAtEnd);
                //    //Grouping.GroupExpressions
                //    XmlNode nGroupExpressions = doc.CreateElement("GroupExpressions", nTablix.NamespaceURI);
                //    List<ReportColumn> lstGroupConditionFields = GetGroupConditionRptColumns(rt);
                //    foreach (ReportColumn cdtField in lstGroupConditionFields)
                //    {
                //        //Grouping.GroupExpressions.GroupExpression
                //        XmlNode nGroupExpression = doc.CreateElement("GroupExpression", nTablix.NamespaceURI);

                //        nGroupExpression.InnerText = "=Fields!" + cdtField.ColumnName + ".Value";
                //        nGroupExpressions.AppendChild(nGroupExpression);
                //    }
                //    nGrouping.AppendChild(nGroupExpressions);
                //    nTablix.AppendChild(nGrouping);
                //}

                XmlNode startNode = nTablixCells;//;GetStartXPathNode(doc, nsmgr, true, isMaster);
                //给Title赋值
                XmlNode nTitle = GetTitleNode(doc, nsmgr, true);
                if (nTitle != null)
                {
                    XmlNode nTitleValue = nTitle.SelectSingleNode("ms:Paragraphs/ms:Paragraph/ms:TextRuns/ms:TextRun/ms:Value", nsmgr);
                    if (nTitleValue != null)
                    {
                        nTitleValue.InnerText = FClientData.FormTitle;
                    }
                }

                // Top Init
                XmlDocument docrealContext = startNode.OwnerDocument;
                //XmlNode temNode = startNode;

                for (int i = 0; i < rt.ReportColumns.Count; i++)
                {
                    string colName = rt.ReportColumns[i].ColumnName;
                    string EditMask = GetFieldEditMask(dtDataDic, colName);
                    string textAlign = rt.ReportColumns[i].TextAlign;

                    curLeft = 0.5f;
                    curTop += 0.94f;

                    //GenLabel
                    if (j == 0)
                        GenTableLabel(startNode, curLeft, curTop, "hd" + colName, GetFieldCaption(dtDataDic, colName), sHorGaps, sVertGaps, false, textAlign);
                    else if (j == 1)
                        GenTableLabel(startNode, curLeft, curTop, "cnt" + colName, EditMask, sHorGaps, sVertGaps, false, textAlign);
                }
                //if (!isMaster)
                //{
                //    startNode.AppendChild(temNode);
                //}
            }
            //List.Style
            XmlNode nListStyle = doc.CreateElement("Style", nBodyRptItems.NamespaceURI);
            //List.Style.FontFamily
            XmlNode nFont = doc.CreateElement("FontFamily", nBodyRptItems.NamespaceURI);
            nFont.InnerText = "PMingLiU";
            nListStyle.AppendChild(nFont);
            nTablix.AppendChild(nListStyle);
            XmlNode nDataSetName = doc.CreateElement("DataSetName", nBodyRptItems.NamespaceURI);
            nDataSetName.InnerText = "NewDataSet";
            nTablix.AppendChild(nDataSetName);
            XmlNode nTop = doc.CreateElement("Top", nBodyRptItems.NamespaceURI);
            nTop.InnerText = "0.1cm";
            nTablix.AppendChild(nTop);
            XmlNode nLeft = doc.CreateElement("Left", nBodyRptItems.NamespaceURI);
            nLeft.InnerText = "0.5cm";
            nTablix.AppendChild(nLeft);
            XmlNode nHeight2 = doc.CreateElement("Height", nBodyRptItems.NamespaceURI);
            nHeight2.InnerText = "1.28cm";
            nTablix.AppendChild(nHeight2);
            XmlNode nWidth2 = doc.CreateElement("Width", nBodyRptItems.NamespaceURI);
            nWidth2.InnerText = "10.16cm";
            nTablix.AppendChild(nWidth2);
            nBodyRptItems.AppendChild(nRectangle1);
            //GenReportBodyHeight(doc, curTop, nsmgr, isMaster);

            XmlNode nTablixColumnHierarchy = doc.CreateElement("TablixColumnHierarchy", nBodyRptItems.NamespaceURI);
            nTablix.AppendChild(nTablixColumnHierarchy);
            XmlNode nTablixMembers = doc.CreateElement("TablixMembers", nBodyRptItems.NamespaceURI);
            nTablixColumnHierarchy.AppendChild(nTablixMembers);
            for (int i = 0; i < rt.ReportColumns.Count; i++)
            {
                XmlNode nTablixMember = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
                nTablixMembers.AppendChild(nTablixMember);
            }

            if (HasGroupCondition(rt))
            {
                CreateGroup(nTablix, doc, rt, dtDataDic, nBodyRptItems);
            }
            else
            {
                XmlNode nTablixRowHierarchy = doc.CreateElement("TablixRowHierarchy", nBodyRptItems.NamespaceURI);
                nTablix.AppendChild(nTablixRowHierarchy);
                XmlNode nTablixMembers2 = doc.CreateElement("TablixMembers", nBodyRptItems.NamespaceURI);
                nTablixRowHierarchy.AppendChild(nTablixMembers2);
                XmlNode nTablixMember3 = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
                nTablixMembers2.AppendChild(nTablixMember3);
                XmlNode nKeepWithGroup = doc.CreateElement("KeepWithGroup", nBodyRptItems.NamespaceURI);
                nKeepWithGroup.InnerText = "After";
                nTablixMember3.AppendChild(nKeepWithGroup);
                XmlNode nRepeatOnNewPage = doc.CreateElement("RepeatOnNewPage", nBodyRptItems.NamespaceURI);
                nRepeatOnNewPage.InnerText = "true";
                nTablixMember3.AppendChild(nRepeatOnNewPage);
                XmlNode nKeepTogether = doc.CreateElement("KeepTogether", nBodyRptItems.NamespaceURI);
                nKeepTogether.InnerText = "true";
                nTablixMember3.AppendChild(nKeepTogether);
                XmlNode nTablixMember2 = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
                nTablixMembers2.AppendChild(nTablixMember2);
                XmlNode nGroup = doc.CreateElement("Group", nBodyRptItems.NamespaceURI);
                XmlAttribute aGroupName = doc.CreateAttribute("Name");
                aGroupName.Value = "lstContainer_Details_Group";
                nGroup.Attributes.Append(aGroupName);
                nTablixMember2.AppendChild(nGroup);
                XmlNode nTablixMembers3 = doc.CreateElement("TablixMembers", nBodyRptItems.NamespaceURI);
                nTablixMember2.AppendChild(nTablixMembers3);
                XmlNode nTablixMember4 = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
                nTablixMembers3.AppendChild(nTablixMember4);
                XmlNode nDataElementName = doc.CreateElement("DataElementName", nBodyRptItems.NamespaceURI);
                nDataElementName.InnerText = "Item";
                nGroup.AppendChild(nDataElementName);
                XmlNode nDataElementName2 = doc.CreateElement("DataElementName", nBodyRptItems.NamespaceURI);
                nDataElementName2.InnerText = "Item_Collection";
                nTablixMember2.AppendChild(nDataElementName2);
                XmlNode nDataElementOutput = doc.CreateElement("DataElementOutput", nBodyRptItems.NamespaceURI);
                nDataElementOutput.InnerText = "Output";
                nTablixMember2.AppendChild(nDataElementOutput);
                XmlNode nKeepTogether2 = doc.CreateElement("KeepTogether", nBodyRptItems.NamespaceURI);
                nKeepTogether2.InnerText = "true";
                nTablixMember2.AppendChild(nKeepTogether2);
            }

            if (isDetails)
            {
                XmlNode nFilters = doc.CreateElement("Filters", nBodyRptItems.NamespaceURI);
                nTablix.AppendChild(nFilters);
                foreach (var item in BlockItem.Relation.ParentColumns)
                {
                    XmlNode nFilter = doc.CreateElement("Filter", nBodyRptItems.NamespaceURI);
                    nFilters.AppendChild(nFilter);
                    XmlNode nFilterExpression = doc.CreateElement("FilterExpression", nBodyRptItems.NamespaceURI);
                    nFilterExpression.InnerText = "=Fields!" + item.ColumnName + ".Value";
                    nFilter.AppendChild(nFilterExpression);
                    XmlNode nOperator = doc.CreateElement("Operator", nBodyRptItems.NamespaceURI);
                    nOperator.InnerText = "Equal";
                    nFilter.AppendChild(nOperator);
                    XmlNode nFilterValues = doc.CreateElement("FilterValues", nBodyRptItems.NamespaceURI);
                    nFilter.AppendChild(nFilterValues);
                    XmlNode nFilterValue = doc.CreateElement("FilterValue", nBodyRptItems.NamespaceURI);
                    nFilterValue.InnerText = "=Parameters!p" + item.ColumnName + ".Value";
                    nFilterValues.AppendChild(nFilterValue);
                }
                GenReportParameters(doc, nsmgr, BlockItem);
            }

            doc.Save(rdlcFileName);
        }
Пример #4
0
 private static bool HasGroupCondition(ReportTable rptTable)
 {
     foreach (ReportColumn rptCol in rptTable.ReportColumns)
     {
         if (rptCol.IsGroupCondition)
             return true;
     }
     return false;
 }
Пример #5
0
        private void CreateGroup(XmlNode nTablix, XmlDocument doc, ReportTable rt, DataTable dtDataDic, XmlNode nBodyRptItems)
        {
            XmlNode nTablixRowHierarchy = doc.CreateElement("TablixRowHierarchy", nBodyRptItems.NamespaceURI);
            nTablix.AppendChild(nTablixRowHierarchy);
            XmlNode nTablixMembers2 = doc.CreateElement("TablixMembers", nBodyRptItems.NamespaceURI);
            nTablixRowHierarchy.AppendChild(nTablixMembers2);
            List<ReportColumn> lstGroupConditionFields = GetGroupConditionRptColumns(rt);

            int index = 0;
            String str = String.Empty;
            XmlNode nTablixMember3 = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
            str += "<TablixHeader>";
            str += "<Size>2.5cm</Size>";
            str += "<CellContents>";
            str += "<Textbox Name=\"Textbox_Group_" + lstGroupConditionFields[index].ColumnName + "\">";
            str += "<CanGrow>true</CanGrow><KeepTogether>true</KeepTogether>";
            str += "<Paragraphs><Paragraph><TextRuns><TextRun><Value>";
            str += GetFieldCaption(dtDataDic, lstGroupConditionFields[index].ColumnName);
            str += "</Value><Style><FontFamily>PMingLiU</FontFamily></Style></TextRun></TextRuns><Style /></Paragraph></Paragraphs>";
            str += "<Style><Border><Style>Solid</Style></Border><BackgroundColor>SteelBlue</BackgroundColor>";
            str += "<PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style>";
            //str += "<rd:DefaultName>\"Textbox_Group_" + cdtField.ColumnName + "\"</rd:DefaultName>";
            str += "</Textbox></CellContents></TablixHeader>";
            str += "<TablixMembers><TablixMember>";
            if (index + 1 < lstGroupConditionFields.Count)
                str += CreateGroup1(dtDataDic, index, lstGroupConditionFields);
            else
                str += "<TablixMembers><TablixMember><KeepTogether>true</KeepTogether></TablixMember></TablixMembers>";
            str += "</TablixMember></TablixMembers>";
            str += "<KeepWithGroup>After</KeepWithGroup><RepeatOnNewPage>true</RepeatOnNewPage>";
            nTablixMember3.InnerXml = str;
            nTablixMembers2.AppendChild(nTablixMember3);

            str = String.Empty;
            XmlNode nTablixMember4 = doc.CreateElement("TablixMember", nBodyRptItems.NamespaceURI);
            str += "<Group Name=\"" + lstGroupConditionFields[index].ColumnName + "\">";
            str += "<GroupExpressions><GroupExpression>=Fields!" + lstGroupConditionFields[index].ColumnName + ".Value</GroupExpression></GroupExpressions>";
            str += "</Group>";
            str += "<SortExpressions><SortExpression><Value>=Fields!" + lstGroupConditionFields[index].ColumnName + ".Value</Value>";
            str += "</SortExpression></SortExpressions>";
            str += "<TablixHeader><Size>2.5cm</Size><CellContents>";
            str += "<Textbox Name=\"" + lstGroupConditionFields[index].ColumnName + "\">";
            str += "<CanGrow>true</CanGrow><KeepTogether>true</KeepTogether>";
            str += "<Paragraphs><Paragraph><TextRuns><TextRun><Value>";
            str += "=Fields!" + lstGroupConditionFields[index].ColumnName + ".Value";
            str += "</Value><Style><FontFamily>PMingLiU</FontFamily></Style></TextRun></TextRuns><Style /></Paragraph></Paragraphs>";
            str += "<Style><Border><Style>Solid</Style></Border><BackgroundColor>SteelBlue</BackgroundColor>";
            str += "<PaddingLeft>2pt</PaddingLeft><PaddingRight>2pt</PaddingRight><PaddingTop>2pt</PaddingTop><PaddingBottom>2pt</PaddingBottom></Style>";
            //str += "<rd:DefaultName>\"" + cdtField.ColumnName + "\"</rd:DefaultName>";
            str += "</Textbox></CellContents></TablixHeader>";
            str += "<TablixMembers><TablixMember>";
            if (index + 1 < lstGroupConditionFields.Count)
                str += CreateGroup2(dtDataDic, index, lstGroupConditionFields);
            else
            {
                str += "<Group Name=\"table1_Details_Group\"><DataElementName>Detail</DataElementName></Group>";
                str += "<TablixMembers><TablixMember /></TablixMembers><DataElementName>Detail_Collection</DataElementName>";
                str += "<DataElementOutput>Output</DataElementOutput><KeepTogether>true</KeepTogether>";
                //str += "<TablixMember><KeepWithGroup>Before</KeepWithGroup></TablixMember>";
            }
            str += "</TablixMember></TablixMembers>";
            nTablixMember4.InnerXml = str;
            nTablixMembers2.AppendChild(nTablixMember4);
            nTablixMembers2.InnerXml = nTablixMembers2.InnerXml.Replace(" xmlns=\"\"", String.Empty);
        }
Пример #6
0
 private static List<ReportColumn> GetGroupConditionRptColumns(ReportTable rptTable)
 {
     List<ReportColumn> lstGCols = new List<ReportColumn>();
     foreach (ReportColumn rptCol in rptTable.ReportColumns)
     {
         if (rptCol.IsGroupCondition)
             lstGCols.Add(rptCol);
     }
     return lstGCols;
 }
Пример #7
0
 //ReportParameter rptParams
 private static void GenList(XmlDocument doc, XmlNamespaceManager nsmgr, ReportTable rt, string designerTableName)
 {
 }
Пример #8
0
 public static void GenTableRows(XmlNode nParent, ReportTable rptTable, ReportParameter rptParams, string tag, ClientType dataBaseType, string dbName, string RealTableName)
 {
     XmlDocument doc = nParent.OwnerDocument;
     //TableRows
     XmlNode nTableRows = doc.CreateElement("TableRows", nParent.NamespaceURI);
     //TableRows.TableRow
     XmlNode nTableRow = doc.CreateElement("TableRow", nParent.NamespaceURI);
     GenTableCells(nTableRow, rptTable, rptParams, tag, dataBaseType, dbName, RealTableName);
     //TableRows.TableRow.Height
     XmlNode nHeight = doc.CreateElement("Height", nParent.NamespaceURI);
     nHeight.InnerText = rptParams.VertGaps + "cm";
     nTableRow.AppendChild(nHeight);
     nTableRows.AppendChild(nTableRow);
     nParent.AppendChild(nTableRows);
 }
Пример #9
0
        public static void GenTableGroups(XmlNode nParent, ReportTable rptTable, ReportParameter rptParams, string RealTableName)
        {
            XmlDocument doc = nParent.OwnerDocument;
            //TableGroups
            XmlNode nTableGroups = doc.CreateElement("TableGroups", nParent.NamespaceURI);
            //TableGroups.TableGroup
            XmlNode nTableGroup = doc.CreateElement("TableGroup", nParent.NamespaceURI);
            //TableGroups.TableGroup.Header
            XmlNode nHeader = doc.CreateElement("Header", nParent.NamespaceURI);
            GenTableRows(nHeader, rptTable, rptParams, "hdg", ClientType.ctMsSql, string.Empty, RealTableName);
            nTableGroup.AppendChild(nHeader);

            //TableGroups.TableGroup.Grouping
            XmlNode nGrouping = doc.CreateElement("Grouping", nParent.NamespaceURI);
            XmlAttribute aGroupingName = doc.CreateAttribute("Name");
            aGroupingName.Value = "table1_Group1";
            nGrouping.Attributes.Append(aGroupingName);
            //TableGroups.TableGroup.Grouping.PageBreakAtEnd
            XmlNode nPageBreakAtEnd = doc.CreateElement("PageBreakAtEnd", nParent.NamespaceURI);
            nPageBreakAtEnd.InnerText = "true";
            nGrouping.AppendChild(nPageBreakAtEnd);
            //TableGroups.TableGroup.Grouping.GroupExpressions
            XmlNode nGroupExpressions = doc.CreateElement("GroupExpressions", nParent.NamespaceURI);
            List<ReportColumn> lstGroupConditionFields = GetGroupConditionRptColumns(rptTable);
            foreach (ReportColumn cdtField in lstGroupConditionFields)
            {
                //TableGroups.TableGroup.Grouping.GroupExpressions.GroupExpression
                XmlNode nGroupExpression = doc.CreateElement("GroupExpression", nParent.NamespaceURI);
                nGroupExpression.InnerText = "=Fields!" + cdtField.ColumnName + ".Value";
                nGroupExpressions.AppendChild(nGroupExpression);
            }
            nGrouping.AppendChild(nGroupExpressions);
            nTableGroup.AppendChild(nGrouping);
            nTableGroups.AppendChild(nTableGroup);
            nParent.AppendChild(nTableGroups);
        }
Пример #10
0
        public static void GenTableCells(XmlNode nParent, ReportTable rptTable, ReportParameter rptParams, string tag, ClientType databaseType, string dbName, string RealTableName)
        {
            DataTable tabDataDic = null;
            //if (tag == "hd")
            //{
            tabDataDic = GetDDTable(databaseType, dbName, RealTableName);
            //}
            XmlDocument doc = nParent.OwnerDocument;
            //TableCells
            XmlNode nTableCells = doc.CreateElement("TableCells", nParent.NamespaceURI);
            List<ReportColumn> lstGCols = GetGroupConditionRptColumns(rptTable);
            foreach (ReportColumn rptCol in rptTable.ReportColumns)
            {
                if (!lstGCols.Contains(rptCol))
                {
                    lstGCols.Add(rptCol);
                }
            }
            foreach (ReportColumn rptCol in lstGCols)
            {
                //TableCells.TableCell
                XmlNode nTableCell = doc.CreateElement("TableCell", nParent.NamespaceURI);
                //TableCells.TableCell.ReportItems
                XmlNode nReportItems = doc.CreateElement("ReportItems", nParent.NamespaceURI);
                //TableCell Expression
                if (tag == "hd")
                {
                    GenLabel(nReportItems, 0, 0, tag + rptCol.ColumnName, GetFieldCaption(tabDataDic, rptCol.ColumnName), rptParams.HorGaps, rptParams.VertGaps, true);
                }
                else if (tag == "cnt")
                {
                    if (!rptCol.IsGroupCondition)
                    {

                        string EditMask = GetFieldEditMask(tabDataDic, rptCol.ColumnName);
                        GenLabel(nReportItems, 0, 0, tag + rptCol.ColumnName, EditMask, rptParams.HorGaps, rptParams.VertGaps, true);
                    }
                    else
                    {
                        GenLabel(nReportItems, 0, 0, tag + rptCol.ColumnName, "", rptParams.HorGaps, rptParams.VertGaps, true);
                    }
                }
                else if (tag == "hdg")
                {
                    if (rptCol.IsGroupCondition)
                    {

                        string EditMask = GetFieldEditMask(tabDataDic, rptCol.ColumnName);
                        GenLabel(nReportItems, 0, 0, tag + rptCol.ColumnName, EditMask, rptParams.HorGaps, rptParams.VertGaps, true);
                    }
                    else
                    {
                        GenLabel(nReportItems, 0, 0, tag + rptCol.ColumnName, "", rptParams.HorGaps, rptParams.VertGaps, true);
                    }
                }
                nTableCell.AppendChild(nReportItems);
                nTableCells.AppendChild(nTableCell);
            }
            nParent.AppendChild(nTableCells);
        }