<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Course" %>
<script runat="server" type="text/C#">
	dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
	private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
	bool isLoadPage = true;  //定义页面是否加载
	public static int CurrPage = 1;
	public static int PageSize = 10;
	public static int id = 0;
	public static DataRow dr = null;
	protected void Page_Load(object sender, EventArgs e)
	{
		id = Utils.StrToInt(KSCMS.S("id"), 0);
		if (id == 0) return;

		if (KSCMS.S("do") == "delreply")
		{
			delReply();
		}

		using (DataTable dt = DataFactory.GetDataTable("select top 1 a.*,b.title From KS_SJReviews a inner join ks_sj b on a.sjid=b.id Where b.inputer='" + new TemporaryVar().UserName + "' and a.ID=" + id))
		{
			if (dt.Rows.Count > 0)
			{
				dr = dt.Rows[0];
			}
			else
			{
				Msg.AlertDoFun("出错啦！", "parent.box.close();");
				isLoadPage = false;
				return;
			}
		}
	}
	private void delReply()
	{
		int rid = Utils.StrToInt(KSCMS.S("rid"));
		
		Hashtable ht = new Hashtable();
		ht.Add("id", rid);
		CommonData.Delete("KS_SJReviewsCmt", ht);
		ht.Clear();
		ht.Add("CmtNum", DataFactory.GetOnlyValue("select count(1) From KS_SJReViewsCmt Where Status=1 and cmtid=" + id));
		CommonData.Update("KS_SJReviews", ht, "where id=" + id);
		string url=BasicField.GetUserUrl("sj/TcSjShowReviews","frame-no,id-"+KSCMS.S("id"));
		Msg.AlertDoFun("恭喜，评论删除成功!","location.href='"+url+"'" );
		isLoadPage = false;
		return;
	}

	
</script>
<%
    if (!isLoadPage) return;
%>
<style>
.fy_box #Page1_labPage{
	border-radius: 3px;
    width: 26px !important;
    height: 26px !important;
    line-height: 26px !important;
    border: 1px solid #dce2e4 !important;
    outline: none;
}
</style>

<div class="t_tybox" style="padding-right:10px;">
    <form id="form1" runat="server">
    <table id="tbs0" width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="border"> 
          <tr>
            <td class="lefttd" height="30" align="right" style="width: 155px">试卷名称：</td>
            <td class="tag_left">
               
             <%=dr["title"].ToString() %>   
             </td>
          </tr>
    <tr>
        <td align="right" class="lefttd" height="30" style="width: 155px">
            发表人昵称：</td>
        <td class="tag_left">
            <%=dr["UserName"].ToString() %>

    </tr>

    <tr>
        <td align="right" class="lefttd" style="width: 155px; height: 30px">
            发表人IP地址：</td>
        <td class="tag_left" style="height: 30px">
            
            <%=dr["userip"].ToString() %>
            </td>
    </tr>
    <tr>
        <td align="right" class="lefttd" height="30" style="width: 155px">
            发表时间：</td>
        <td class="tag_left">
            <%=dr["adddate"].ToString() %>
            </td>
    </tr>

    <tr>
        <td align="right" class="lefttd" height="30" style="width: 155px">
            发表详细内容：</td>
        <td class="tag_left">
        <%=dr["content"].ToString() %>
            </td>
    </tr>
    <tr>
        <td align="right" class="lefttd" height="30" style="width: 155px">
            回复条数：</td>
        <td class="tag_left">
        <%=dr["cmtnum"].ToString() %>
            </td>
    </tr>
</table>
<br />

          <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="border">
              <tr class="title">
               <td height="25" width="100" align="center"><b>序号</b></td>
               <td style="width:100px;text-align:center"><b>回复人</b></td>
               <td align="center"><b>回复内容</b></td>
               <td style="text-align:center;width:150px"><b>状态</b></td>
               <td width="150" align="center"><b>操作</b></td>
              </tr>
              <%  int recordcount, pagecount;
                  int CurrPage = new BasicField().GetCurrPage;
                  int PageSize = 10;
                  using (DataTable dt = DataFactory.GetPage("*", "KS_SJReviewsCmt Where cmtid=" + id, "id", "order by id desc", CurrPage, PageSize, out recordcount, out pagecount))
                  {
                      if (dt.Rows.Count > 0)
                      {
                          int i = (CurrPage - 1) * PageSize + 1;
                          foreach (DataRow drs in dt.Rows)
                          {    %>
              <tr class="tdbg">
                  <td height="25" width="48" align="center"><%=i.ToString() %></td>
                  <td style="text-align: center"><%=drs["username"].ToString()  %></td>
                  <td><%= drs["content"].ToString() %></td>
                  <td style="text-align: center"><%=(Utils.StrToInt(drs["status"].ToString()) == 1 ? "<font color=green>已审核</font>" : "<font color=red>未审核</font>") %></td>
                  <td width="70" align="center"><a href="<%=BasicField.GetUserUrl("sj/TcSjShowReviews", "do-delreply,id-" + id + ",rid-" + drs["id"].ToString() + "")  %>">删除</a></td>
              </tr>
              <%
                              i++;
                          }
                      }
                      else
                      {
                          KSCMS.W("<tr class=\"tdbg\" ><td style=\"text-align:center\" colspan=\"5\"><div class=\"empty\">没有回复记录!</div></td></tr> ");
                      }
                  }
              %>
           </table>

	<div class="clearfix">
		<div class="cz_btn">
		  <span><input type="button" value="浏览发表页" class="button" onclick="window.open('<%= Kesion.BLL.BaseFun.GetRewriteUrl("exam","do-reviews/id-"+Convert.ToInt32(dr["sjid"].ToString()))%>	')" /></span>
		  <span><input type="button" class="button" value="取消关闭(C)" accesskey="C" onclick="closed()" /></span>
		</div>
	</div>

    <div class="fy_box">
 <%
            #region 分页
            string PageStr = "[KS:PageStr1]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
    </div>


    </form>
    <script>
    	function closed() {
    		//alert(1);
    		//  box.close();
    		top.location.reload();
    	}
        </script>
</div>
