<%@Page Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web" %>
<%@ Register TagPrefix="Diss_Cate" Namespace="Diss_vb" Assembly="Diss_vb" %>
<%@ Import Namespace="DissData_vb" %>
<html>
<head>
<style type="text/css">
<!--
A:link {color: blue text-decoration: none}
A:hover {color:red text-decoration: none}
A:Visited {text-decoration: none}
A:hover {text-decoration: none}
-->
<!--
table { font-size: 11 pt    		
	font-family: 新细明体, 细明体, Mingli, Verdana, Arial, Helvetica  }
-->
<!--
body { font-size: 11 pt    		
	font-family: 新细明体, 细明体, Mingli, Verdana, Arial, Helvetica  }
-->
</style>
	<script language="vb" runat="server">
	sub Page_load(sender as object, e as EventArgs)
		GetCate.ServerName=Session("NowSQLServer").ToString()
		GetCate.Uid=Session("Nowuid").ToString()
		GetCate.Pass=Session("NowPassword").ToString()
		GetCate.DBName=Session("NowDBName").ToString()
		if IsPostBack=false then
			if Session("Lg_ok")<>"-1" then
				Session("NowFile")=Request.RawUrl
				lg.Visible=true
				go.Visible=true
			else
				lg.Visible=false
				go.Visible=false
			end if
			GetCate.FirstLoad=true'第一次加载
			dim x1 as string = Request.QueryString("NowCateID")
			if x1= "" then	x1="1"
			GetCate.NowSelect=Convert.ToInt32(x1)'设定目前类别ID
			dim t as DateTime = DateTime.Now
			dim y as integer = Convert.ToInt32(t.DayOfWeek)
			dim k as DateTime = Convert.ToDateTime("2002/02/01")'
			dim StartDate,EndDate as DateTime
			if Request.QueryString("StartDate") <> ""  then
				dim g as DateTime =Convert.ToDateTime(Request.QueryString("StartDate"))
				StartDate = g.AddDays(0-y+1)
				EndDate = StartDate.AddDays(6)'加六天
			else
				StartDate = k.AddDays(0 - y + 1)'取得起始日
				EndDate = StartDate.AddDays(6)'加六天
			end if
			GetCate.StartDate=StartDate
			GetCate.EndDate=EndDate
			if Request.QueryString("GetSession")="True" then
				bindNew(false)
			else
				bindNew(true)
			end if
		end if
	end sub
	sub ViewDetail(sender as object,e as CommandEventArgs)
		Response.Redirect("View.aspx?StartDate=" & GetCate.StartDate.ToString() & "&CID=" & e.CommandArgument & "&NowCateID=" & GetCate.NowSelect & "&NowCate=" & GetCate.NowCate)
	end sub
	sub Full_Click(sender as object,e as EventArgs)
		Response.Redirect("Search.aspx")
	end sub
	sub ToNew_Click(sender as object,e as EventArgs)
		Response.Redirect("WriteNew.aspx")
	end sub
	sub moveweek(sender as object,e as CommandEventArgs)
		if e.CommandArgument="PrevWeek" then
			GetCate.StartDate=GetCate.StartDate.AddDays(-7)
			GetCate.EndDate=GetCate.EndDate.AddDays(-7)
		else
			GetCate.StartDate=GetCate.StartDate.AddDays(7)
			GetCate.EndDate=GetCate.EndDate.AddDays(7)
		end if
		GetCate.FirstLoad=true
		bindNew(true)
	end sub
	sub bindNew(tag as Boolean)
		dim NowTable as DataTable
		if tag = true then
			dim NewDiss as DissSql = Ctype(Session("NowDissSqlvb"),DissSql)
			dim c as string=GetCate.StartDate.ToString("yyyy/MM/dd")
			dim d as string=GetCate.EndDate.ToString("yyyy/MM/dd")
			NowTable = NewDiss.GetDataTable(GetCate.NowSelect,c,d)
			Session("NowDissvb")=NowTable
		else
			NowTable = Ctype(Session("NowDissvb"),DataTable)
		end if
		Re0.DataSource=NowTable.DefaultView
		Re0.DataBind()
		if Session("Lg_ok")="-1" then
			Re0.Columns(0).Visible = true
			Re0.Columns(1).Visible = false
			ToNew.Visible=true
			Full.Visible=true
		else
			Re0.Columns(0).Visible = false
			Re0.Columns(1).Visible = true
			ToNew.Visible=false
			Full.Visible=false
		end if
	end sub
	sub Get_Click(sender as object,e as CommandEventArgs)
		bindNew(true)
	end sub
	</script>
</head>
<body background="../../../images/winback.gif">
<form runat="server">
<img runat="server" id="go" src="go.gif" align="middle"><asp:hyperlink text="登陆" navigateurl="Login.aspx" runat="server" id="lg" />
<p><Diss_Cate:GetCate ID="GetCate" onCommand="Get_Click" Runat="server" />
<asp:LinkButton Text="前一周" id="prev" oncommand="moveweek" commandargument="PrevWeek" runat="server" />　<asp:LinkButton Text="下一周" id="next" oncommand="moveweek" commandargument="NextWeek" runat="server" /><p>
<p><asp:LinkButton Text="发表新意见" id="ToNew" onclick="ToNew_Click" runat="server" />　<asp:LinkButton Text="全文检索" id="Full" onclick="Full_Click" runat="server" /><p>
<asp:DataGrid ID="Re0" Runat="server"
        BorderWidth="0"
        CellPadding="3"
        CellSpacing="0"
	width="600"
        Font-Name="Verdana"
        Font-Size="9pt"
        HeaderStyle-BackColor="Blue"
        HeaderStyle-ForeColor="White"
	DataKeyfield="id"
	AutoGenerateColumns="false"
 >

      <Columns>
<asp:TemplateColumn HeaderText="主题" itemstyle-width="300">
          <ItemTemplate>
<asp:LinkButton runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "subject") %> CommandArgument=<%# DataBinder.Eval(Container.DataItem, "id") %> Oncommand="ViewDetail" id="d1"/>
          </ItemTemplate>
        </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="主题" itemstyle-width="300">
          <ItemTemplate>
<asp:Label runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "subject") %> id="ld1"/>
          </ItemTemplate>
        </asp:TemplateColumn>
        <asp:BoundColumn HeaderText="发送人" DataField="send"/>
        <asp:BoundColumn HeaderText="发送时间" DataField="nowtime"/>
     </Columns>
</asp:Datagrid>


</form>
</body>