<%@ Page Language="c#" Inherits="WebApp.NewsStat" CodeBehind="NewsStat.aspx.cs" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>子站新闻发布量查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--#include file = "../Css/adminCssEdit.htm" -->

    <script language="javascript" src="../Script/DateTimePicker.js" ></script>

    <script language="javascript">
			function selectSchools()
			{	
				var arr = showModalDialog("selectSchools.aspx", window, "dialogWidth:500px;dialogHeight:326px;help:no;scroll:no;resizable:yes;status:no");
		   		if(arr!=null)
		   		  location.href="NewsStat.aspx";
			}
			function DelAll() 
			{
				var selectTo=document.frmNewsStat.schoolList;
				var nLen = selectTo.length;
				if (nLen<1) return;
				for(var loop=nLen;loop>=0;loop--)
				{ 
               		selectTo.options[loop] = null;
               	}			  
			}
			function checkform(text,value) 
			{				
				var selectFrom=document.frmNewsStat.schoolList;
			    selectFrom.add(new Option(text,value));
			}
			function queryform() {
				var sel=document.frmNewsStat.schoolList;
				var nLen = sel.length;
				var str1="";
				var str2="";
				for (var i=0;i<nLen;i++) {
					if (i>0) 
					{str2+=",";str1+=",";}
					str2+=sel.options[i].value;
					str1+=sel.options[i].text;
				}
				document.frmNewsStat.d_name.value=str1;
				document.frmNewsStat.d_value.value=str2;
				//alert(str1+str2);
				return true;
			}
			function showTime(type)
			{				
				if(type==1)
				{	
					document.all("ddlMonthFrom").style.visibility="visible";
					document.all("ddlMonthTo").style.visibility="visible";
					document.all("month1").style.visibility="visible";
					document.all("month2").style.visibility="visible";
				}
				else if(type==2)
				{
					document.all("ddlMonthFrom").style.visibility="hidden";
					document.all("ddlMonthTo").style.visibility="hidden";	
					document.all("month1").style.visibility="hidden";
					document.all("month2").style.visibility="hidden";				
				}
			}
    </script>

    <base target="_self">
</head>
<body>
    <div class="edit-func-box func-box">
        <div class="hd">
            子站新闻发布量统计</div>
        <form id="frmNewsStat" method="post" runat="server">
       <table class="border" cellSpacing="0" cellPadding="4" width="760" align="center">
            <tr>
                <td style="width: 387px" valign="top" width="387">
                    <table cellspacing="0" cellpadding="6" width="100%" align="center" border="0">
                        <tr>
                            <td>
                                查询方式：
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RadioButton ID="orderBySchool" Checked="True" runat="server" GroupName="order"
                                    Text="按子站查询"></asp:RadioButton><asp:RadioButton ID="orderByMonth" runat="server"
                                        GroupName="order" Text="按时间查询"></asp:RadioButton>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                显示方式：
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RadioButton ID="showTable" Checked="True" runat="server" GroupName="Show" Text="二维表显示">
                                </asp:RadioButton><asp:RadioButton ID="showGrap" runat="server" GroupName="Show"
                                    Text="图表显示"></asp:RadioButton>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:RadioButton ID="rbMonth" Checked="True" runat="server" GroupName="query" Text="月报"
                                    onclick="showTime(1)"></asp:RadioButton><asp:RadioButton ID="rbyear" runat="server"
                                        GroupName="query" Text="年报" onclick="showTime(2)"></asp:RadioButton>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                开始时间：<asp:DropDownList ID="ddlYearFrom" runat="server" Width="64px">
                                </asp:DropDownList>
                                年&nbsp;<select id="ddlMonthFrom" runat="server">
                                    <option selected>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                    <option>6</option>
                                    <option>7</option>
                                    <option>8</option>
                                    <option>9</option>
                                    <option>10</option>
                                    <option>11</option>
                                    <option>12</option>
                                </select>
                                <div style="display: inline; width: 70px; height: 15px" id="month1" runat="server">
                                    月</div>
                                <br>
                                结束时间：<asp:DropDownList ID="ddlYearTo" runat="server" Width="64px">
                                </asp:DropDownList>
                                年&nbsp;<select id="ddlMonthTo" runat="server">
                                    <option selected>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                    <option>6</option>
                                    <option>7</option>
                                    <option>8</option>
                                    <option>9</option>
                                    <option>10</option>
                                    <option>11</option>
                                    <option>12</option>
                                </select>
                                <div style="display: inline; width: 70px; height: 15px" id="month2" runat="server">
                                    月</div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table border="0" cellpadding="4" cellspacing="0">
                                    <tr>
                                        <td>
                                            <asp:Button ID="btnQuery" runat="server" Text="查询" OnClick="btnQuery_Click" CssClass="btn">
                                            </asp:Button>&nbsp;
                                        </td>
                                        <td>
                                            <asp:Button ID="btnUpdate" runat="server" Text="统计所有站点" CausesValidation="False"
                                                OnClick="btnUpdate_Click" CssClass="btn"></asp:Button>&nbsp;
                                        </td>
                                        <td>
                                            <asp:RadioButtonList ID="rbStatOption" runat="server" RepeatColumns="2">
                                                <asp:ListItem Selected="True" Value="0">最新统计</asp:ListItem>
                                                <asp:ListItem Value="1">重新统计</asp:ListItem>
                                            </asp:RadioButtonList>
                                        </td>
                                    </tr>
                                </table>
                                <input id="updated" type="hidden" value="false" name="Hidden1" runat="server">
                            </td>
                        </tr>
                    </table>
                </td>
                <td class="tdbg" valign="top" width="50%">
                    <table cellspacing="0" cellpadding="2" width="100%" align="center" border="0">
                        <tr>
                            <td>
                                子站列表：&nbsp;&nbsp;
                                <asp:Button ID="btnSelSchools" runat="server" Text="选择子站" CssClass="btn"></asp:Button>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:ListBox ID="schoolList" runat="server" Width="100%" Rows="8" Height="216px">
                                </asp:ListBox>
                            </td>
                        </tr>
                    </table>
                    <input id="d_name" style="width: 80px; height: 21px" type="hidden" size="8" name="Hidden1"
                        runat="server"><input id="d_value" style="width: 88px; height: 21px" type="hidden"
                            size="9" name="Hidden2" runat="server">
                </td>
            </tr>
        </table>
        <table cellspacing="0" cellpadding="4" width="760" align="center" border="0">
            <tr>
                <td>
                    <asp:Panel ID="pnl1" runat="server" Width="100%" Visible="False">
                        <table cellspacing="1" class="border" cellpadding="0" width="760" align="center"
                            border="0">
                            <tr>
                                <td>
                                    <asp:Repeater ID="Repeater1" runat="server">
                                        <SeparatorTemplate>
                                            <hr color="#719FD4" />
                                        </SeparatorTemplate>
                                        <ItemTemplate>
                                            <table cellspacing="0" cellpadding="4" width="756" align="center" border="0">
                                                <tr>
                                                    <td align="center" class="topbg">
                                                        <asp:Label ID="lblSchoolName" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.schoolName") %>'>
                                                        </asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td class="tdbg">
                                                        <asp:DataGrid ID="Datagrid1" runat="server" Width="100%" AutoGenerateColumns="False"
                                                            DataKeyField="pkID" DataSource='<%# GetNewsStat(DataBinder.Eval(Container,"DataItem.applyID").ToString()) %>'>
                                                            <Columns>
                                                                <asp:BoundColumn DataField="pkID" HeaderText="ID"></asp:BoundColumn>
                                                                <asp:BoundColumn DataField="applyID" HeaderText="子站ID"></asp:BoundColumn>
                                                                <asp:TemplateColumn HeaderText="统计时间">
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lbl1" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy-MM") %>'
                                                                            Visible='<%# visibleMonth %>'>
                                                                        </asp:Label>
                                                                        <asp:Label ID="lbl2" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy") %>'
                                                                            Visible='<%# visibleYear %>'>
                                                                        </asp:Label>
                                                                    </ItemTemplate>
                                                                </asp:TemplateColumn>
                                                                <asp:BoundColumn DataField="newsCount" HeaderText="新闻条数"></asp:BoundColumn>
                                                            </Columns>
                                                        </asp:DataGrid>
                                                    </td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="pnl2" runat="server" Visible="False">
                        <table class="border" cellspacing="0" cellpadding="4" width="760" align="center">
                            <tr>
                                <td class="tdbg">
                                    <asp:Repeater ID="Repeater2" runat="server">
                                        <SeparatorTemplate>
                                            <hr color="#719FD4" noshade />
                                        </SeparatorTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lbl3" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.schoolName") %>'>
                                            </asp:Label>
                                            <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="12"
                                                DataSource='<%# GetNewsStat(DataBinder.Eval(Container,"DataItem.applyID").ToString()) %>'>
                                                <ItemStyle VerticalAlign="Bottom"></ItemStyle>
                                                <ItemTemplate>
                                                    <table cellpadding="0" width="60px" border="0" cellspacing="0">
                                                        <tr>
                                                            <td align="center">
                                                                <asp:Label ID="lblNum" runat="server" Text='<%# Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount")) %>'>
                                                                </asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center">
                                                                <asp:Image ID="imgDate" runat="server" Height='<%# (int)(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount"))/2) %>'
                                                                    Width="20px" ImageUrl="./Images/ballot_v.GIF"></asp:Image>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center">
                                                                <asp:Label ID="Label1" runat="server" Text='<%# GetStatTime(DataBinder.Eval(Container, "DataItem.statTime").ToString()) %>'>
                                                                </asp:Label>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </ItemTemplate>
                                            </asp:DataList>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="pnl3" runat="server" Visible="False">
                        <table class="border" cellspacing="0" cellpadding="0" width="760" align="center">
                            <tr>
                                <td>
                                    <asp:Repeater ID="Repeater3" runat="server">
                                        <SeparatorTemplate>
                                            <hr color="#719FD4" />
                                        </SeparatorTemplate>
                                        <ItemTemplate>
                                            <table cellspacing="0" cellpadding="4" width="756" align="center" class="tdbg">
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label2" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy-MM") %>'
                                                            runat="server" Visible='<%# visibleMonth %>'>
                                                        </asp:Label>
                                                        <asp:Label ID="Label7" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy") %>'
                                                            Visible='<%# visibleYear %>'>
                                                        </asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:DataGrid ID="Datagrid2" runat="server" Width="100%" DataSource='<%# GetNewsStatByMonth(DataBinder.Eval(Container,"DataItem.statTime").ToString()) %>'
                                                            DataKeyField="pkID" AutoGenerateColumns="False">
                                                            <Columns>
                                                                <asp:BoundColumn DataField="pkID" HeaderText="ID"></asp:BoundColumn>
                                                                <asp:BoundColumn DataField="applyID" HeaderText="子站ID"></asp:BoundColumn>
                                                                <asp:BoundColumn DataField="schoolName" HeaderText="子站名称"></asp:BoundColumn>
                                                                <asp:BoundColumn DataField="statTime" HeaderText="统计时间" DataFormatString="{0:yyyy}">
                                                                </asp:BoundColumn>
                                                                <asp:BoundColumn DataField="newsCount" HeaderText="新闻条数"></asp:BoundColumn>
                                                            </Columns>
                                                        </asp:DataGrid>
                                                        <asp:Label ID="lblInfo" runat="server" Text='<%# StatInfo %>'>
                                                        </asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                            <br>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td class="tdbg">
                    <asp:Panel ID="pnl4" runat="server" Visible="False">
                        <table class="border" cellspacing="0" cellpadding="4" width="760" align="center">
                            <tr>
                                <td>
                                    <asp:Repeater ID="Repeater4" runat="server">
                                        <SeparatorTemplate>
                                            <hr color="#719FD4" />
                                        </SeparatorTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy-MM") %>'
                                                Visible='<%# visibleMonth %>'>
                                            </asp:Label>
                                            <asp:Label ID="Label6" runat="server" Text='<%# Convert.ToDateTime(DataBinder.Eval(Container,"DataItem.statTime")).ToString("yyyy") %>'
                                                Visible='<%# visibleYear %>'>
                                            </asp:Label>
                                            <asp:DataList ID="Datalist2" runat="server" RepeatDirection="Horizontal" RepeatColumns="12"
                                                DataSource='<%# GetNewsStatByMonth(DataBinder.Eval(Container,"DataItem.statTime").ToString()) %>'>
                                                <ItemStyle VerticalAlign="Bottom"></ItemStyle>
                                                <ItemTemplate>
                                                    <table cellpadding="0" width="120px" border="0" cellspacing="0">
                                                        <tr>
                                                            <td align="center">
                                                                <asp:Label ID="Label4" runat="server" Text='<%# Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount")) %>'>
                                                                </asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center">
                                                                <asp:Image ID="Image1" runat="server" Height='<%# (int)(Convert.ToInt32(DataBinder.Eval(Container, "DataItem.newsCount"))/2) %>'
                                                                    Width="20px" ImageUrl="./Images/ballot_v.GIF"></asp:Image>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center">
                                                                <asp:Label ID="Label5" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.schoolName") %>'>
                                                                </asp:Label>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </ItemTemplate>
                                            </asp:DataList>
                                            <asp:Label ID="lblRecordInfo" runat="server" Text='<%# StatInfo %>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
        </table>
        </form>
    </div>
</body>
</html>
