通过不同的按钮来实现报表数据的不同的排序功能

所用技术通过在JSP页面按下不同的排序按钮,调用存储过程返回不同的参数,然后在XSL页面显示的时候通过返回的不同的参数调用不同的摸板来做.

 

存储过程:

 

if @SubmitButtonFlag='searchByTractMoney'
   begin
    select top 1 'searchByTractMoney' as Type from #temp1 table0  for xml auto
   end
  else if @SubmitButtonFlag='searchByViewCount'
   begin
    select top 1 'searchByViewCount' as Type from #temp1 table0  for xml auto
   end
  else if @SubmitButtonFlag='search'
   begin
    select top 1 'search' as Type from #temp1 table0  for xml auto
   end

 

XSL:

<?xml version="1.0" encoding="gbk" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xsl2="http://www.w3.org/TR/WD-xsl"
 xmlns:msxsl="urn:schemas-microsoft-com:xslt"
 xmlns:myxsl="http://www.jobcn.com"
 version="1.0">
 <xsl:output method="html" encoding="gbk"/>

 <xsl:decimal-format NaN="0"/><!-- NaN处理 -->
 
  
 
 
 <xsl:template match="/root">
  <xsl:variable name="numCount" select="count(/root/table1)"/>
  <html>
   <head>
    <title><xsl:value-of select="/root/table0/@XslTitle"/></title>
   </head>
   
   <body topmargin="0" leftmargin="0" oncontextmenu="return false;" ondragstart="return false;" onsource="return false;" onselectstart="return false;" >
    <center>
     <p class="reportstatisticdate"><xsl:value-of select="/root/table0/@ReportStatisticDate"/></p>
     
     <xsl:choose>
      <xsl:when test="$numCount =0">
       <br/><font color='red' size='3'>没有数据!</font><br/>
      </xsl:when>
      <xsl:otherwise>
       <table border='0' cellpadding='4' cellspacing='1' class="reporttable">
        <tr class="reporttabletitle">
         <td colspan="100"  nowrap='true'>
          <font color="red">【<xsl:value-of select="/root/table0/@ReportTableDate"/>】</font><xsl:value-of select="/root/table0/@ReportTableTitle"/>
         </td>
        </tr>
        <tr class="reporttablehead_b" nowrap="true">
         <td  nowrap="true">序号</td>
         <td  nowrap="true">员工编码</td>
         <td  nowrap="true">销售人员</td>
         <td  nowrap="true">T数</td>
         
         <td  nowrap="true">销售部门</td>
         <td  nowrap="true">查看简历数</td>
         <td  nowrap="true">签单金额(元)</td>
         <td  nowrap="true">效费比(签单金额/查看简历数)</td>
         
        </tr>
        通过不同的参数来调用不同的摸板
        <xsl:if test="./table0/@Type='search'">
         <xsl:call-template name="search">
          
         </xsl:call-template>
        </xsl:if>
        <xsl:if test="
./table0/@Type='searchByViewCount'">
         <xsl:call-template name="searchByViewCount">
          
         </xsl:call-template>
        </xsl:if>
        <xsl:if test="
./table0/@Type='searchByTractMoney'">
         <xsl:call-template name="searchByTractMoney">
          
         </xsl:call-template>
        </xsl:if>
        
        <tr class="reporttablehead_b">
         <td  colspan="5">合计</td>
         <td style="text-align:center">
          <xsl:value-of select="format-number(sum(./*/@ViewCount),'###,###,##0')"/>
         </td>
         <td style="text-align:right">
          <xsl:value-of select="format-number(sum(./*/@TractMoney),'###,###,##0')"/>
         </td>
         <td  ></td>
        </tr>
       </table>
      </xsl:otherwise>
     </xsl:choose>
    </center>
   </body>
  </html>
 </xsl:template>
 
 <xsl:template name="search">
  <xsl:for-each select="./table1">
   <xsl:variable name="table1Position" select="position()"/>
   <xsl:sort select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" data-type="number" order="descending"/>
   <!--<xsl:sort select="$condition" data-type="number" order="descending"/>-->
   
   <tr class="reporttrcenter">
    <xsl:attribute name="onMouseOver">changetrbgcolor(this,"over");</xsl:attribute>
    <xsl:attribute name="onMouseOut">changetrbgcolor(this,"out");</xsl:attribute>
    <xsl:choose>
     <xsl:when test="position() mod 2 =1">
      <xsl:attribute name="bgColor">#FFFFFF</xsl:attribute>
     </xsl:when>
     <xsl:otherwise>
      <xsl:attribute name="bgColor">#ECFBF9</xsl:attribute>
     </xsl:otherwise>
    </xsl:choose>
    <td nowrap="true">
     <xsl:value-of select="position()" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@PerID" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@PerName" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@Tnum" />
    </td>
    
    <td nowrap="true">
     <xsl:value-of select="./@DeptName" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@ViewCount" />
    </td>
    <td nowrap="true" style="text-align:right">
     <xsl:value-of select="format-number(./@TractMoney,'###,###,##0')" />
    </td>
    <xsl:choose>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')='Infinity'">
      <td nowrap="true" style="text-align:right">
       --
      </td>
     </xsl:when>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')=0">
      <td nowrap="true" style="text-align:right">
       0.00%
      </td>
     </xsl:when>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')!='Infinity'">
      <td nowrap="true" style="text-align:right">
       <xsl:value-of select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" />
       %
      </td>
     </xsl:when>
    </xsl:choose>
    <!--  <td nowrap="true">
     <xsl:value-of select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" />
     %
     </td>
    -->
   </tr>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="searchByViewCount">
  <xsl:for-each select="./table1">
   <xsl:variable name="table1Position" select="position()"/>
   <xsl:sort select="./@ViewCount" data-type="number" order="descending"/>
   <!--<xsl:sort select="$condition" data-type="number" order="descending"/>-->
   
   <tr class="reporttrcenter">
    <xsl:attribute name="onMouseOver">changetrbgcolor(this,"over");</xsl:attribute>
    <xsl:attribute name="onMouseOut">changetrbgcolor(this,"out");</xsl:attribute>
    <xsl:choose>
     <xsl:when test="position() mod 2 =1">
      <xsl:attribute name="bgColor">#FFFFFF</xsl:attribute>
     </xsl:when>
     <xsl:otherwise>
      <xsl:attribute name="bgColor">#ECFBF9</xsl:attribute>
     </xsl:otherwise>
    </xsl:choose>
    <td nowrap="true">
     <xsl:value-of select="position()" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@PerID" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@PerName" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@Tnum" />
    </td>
    
    <td nowrap="true">
     <xsl:value-of select="./@DeptName" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@ViewCount" />
    </td>
    <td nowrap="true" style="text-align:right">
     <xsl:value-of select="format-number(./@TractMoney,'###,###,##0')" />
    </td>
    <xsl:choose>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')='Infinity'">
      <td nowrap="true" style="text-align:right">
       --
      </td>
     </xsl:when>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')=0">
      <td nowrap="true" style="text-align:right">
       0.00%
      </td>
     </xsl:when>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')!='Infinity'">
      <td nowrap="true" style="text-align:right">
       <xsl:value-of select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" />
       %
      </td>
     </xsl:when>
    </xsl:choose>
    <!--  <td nowrap="true">
     <xsl:value-of select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" />
     %
     </td>
    -->
   </tr>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="searchByTractMoney">
  <xsl:for-each select="./table1">
   <xsl:variable name="table1Position" select="position()"/>
   <xsl:sort select="./@TractMoney" data-type="number" order="descending"/>
   <!--<xsl:sort select="$condition" data-type="number" order="descending"/>-->
   
   <tr class="reporttrcenter">
    <xsl:attribute name="onMouseOver">changetrbgcolor(this,"over");</xsl:attribute>
    <xsl:attribute name="onMouseOut">changetrbgcolor(this,"out");</xsl:attribute>
    <xsl:choose>
     <xsl:when test="position() mod 2 =1">
      <xsl:attribute name="bgColor">#FFFFFF</xsl:attribute>
     </xsl:when>
     <xsl:otherwise>
      <xsl:attribute name="bgColor">#ECFBF9</xsl:attribute>
     </xsl:otherwise>
    </xsl:choose>
    <td nowrap="true">
     <xsl:value-of select="position()" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@PerID" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@PerName" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@Tnum" />
    </td>
    
    <td nowrap="true">
     <xsl:value-of select="./@DeptName" />
    </td>
    <td nowrap="true">
     <xsl:value-of select="./@ViewCount" />
    </td>
    <td nowrap="true" style="text-align:right">
     <xsl:value-of select="format-number(./@TractMoney,'###,###,##0')" />
    </td>
    <xsl:choose>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')='Infinity'">
      <td nowrap="true" style="text-align:right">
       --
      </td>
     </xsl:when>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')=0">
      <td nowrap="true" style="text-align:right">
       0.00%
      </td>
     </xsl:when>
     <xsl:when test="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')!='Infinity'">
      <td nowrap="true" style="text-align:right">
       <xsl:value-of select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" />
       %
      </td>
     </xsl:when>
    </xsl:choose>
    <!--  <td nowrap="true">
     <xsl:value-of select="format-number( 100*(./@TractMoney div ./@ViewCount), '##0.00')" />
     %
     </td>
    -->
   </tr>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

 

 

你可能感兴趣的:(xml,jsp,Microsoft,XSL)