<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Config" %>
<%@ Import Namespace="Kesion.Components" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Controllers" %>
<script runat="server" type="text/C#">
    dynamic __user = HttpContext.Current.Items["user"];
    private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
    bool isLoadPage = true;  //定义页面是否加载
    int classId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        classId = Utils.StrToInt(KSCMS.S("classid"));
        CheckUserLogin.Run();

    }

 </script> 
<%
    if (!isLoadPage) return;
%>

<div class="r_tybox nomar">

    <div class="r_title"><%=DataFactory.GetOnlyValue("select top 1 classname from KS_Sjclass where classid="+classId) %>
	
    	 <div class="tabs">
            <ul>
             <%using (DataTable dt = DataFactory.GetDataTable("select top 1 ExpiryDate,ExpiryMonth from KS_SJBuyClassItem where SjclassId=" + classId))
                 {
                     if(dt.Rows.Count>0)
                     {
                         DataRow dr = dt.Rows[0];
                         int ExpiryMonth = Utils.StrToInt(dr["ExpiryMonth"].ToString());
                         if(ExpiryMonth>0)
                         {
                             if (Convert.ToDateTime(dr["ExpiryDate"]) >=Convert.ToDateTime(Utils.GetDateTime()))
                             {
                                  KSCMS.W(@"<li "+(BasicField.GetParam("show") == "4"?"class='puton'":"")+"><a href="+BasicField.GetUserUrl("exam/MySjClassRecord,classid-"+classId+",show-4") +">可考试卷</a></li>");
                             }
                            
                         }
                         else
                         {
                             KSCMS.W(@"<li "+(BasicField.GetParam("show") == "4"?"class='puton'":"")+"><a href="+BasicField.GetUserUrl("exam/MySjClassRecord,classid-"+classId+",show-4") +">可考试卷</a></li>");
                         }
                     }
                 }%>
           
                <li <%if (BasicField.GetParam("show") == "") Response.Write(" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("exam/MySjClassRecord,classid-"+classId) %>">考试记录</a></li>
                <li <%if (BasicField.GetParam("show") == "1") Response.Write(" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("exam/MySjClassRecord","classid-"+classId+",show-1") %>">练习记录</a></li>
                <li <%if (BasicField.GetParam("show") == "2") Response.Write(" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("exam/MySjClassRecord","classid-"+classId+",show-2") %>">错题本</a></li>
                <li <%if (BasicField.GetParam("show") == "3") Response.Write(" class='puton'"); %>><a href="<%=BasicField.GetUserUrl("exam/MySjClassRecord","classid-"+classId+",show-3") %>">收藏题</a></li>
            </ul>	
        </div>
    </div>

     <%if (KSCMS.S("show") == "")
         { %>
    <div class="cos-learn" id="learnbox">
        <div class="cos-learn-line"></div>
        <div class="clear"></div>
        <!--//年份归类整理-->
    </div>
    <!--// cos-learn-->

      <div id="myRecord" >
		     <%
                 int recordcount, pagecount;
                 int CurrPage = new BasicField().GetCurrPage;
                 int PageSize = 10;
                 //Kesion.HtmlTags.CommonFunc.InitBlogNav(UserManage.GetUserInfo().UserID, (new TemporaryVar()).UserName);
                 string sql = string.Empty;

                 if (!string.IsNullOrEmpty(KSCMS.S("classid")))
                 {
                     sql += " and classid in(" + Function.GetSJCategoryChildID(Utils.StrToInt(KSCMS.S("classid"))) + ")";
                 }
                 sql += " and  a.UserID=" + (new TemporaryVar()).UserID;
                 string sqlstr = "  KS_SJScore A Left Join KS_SJ B on a.sjid=b.id Where 1=1 " + sql;
                 string orderstr = "order by a.adddate desc";

                 using (DataTable dt = DataFactory.GetPage("a.*,b.RealTest,b.dtfs,b.title,b.id,B.CmtNum,b.ScorePubType,b.ScorePubDate,b.classid", sqlstr, "ScoreID", orderstr, CurrPage, PageSize, out recordcount, out pagecount))
                 {
                     int i = 1;
                     if (dt.Rows.Count > 0)
                     {
                         foreach (DataRow dr in dt.Rows)
                         {

                             string cosname = dr["title"].ToString();
                             string PeriodID = dr["id"].ToString();
                             DateTime adddate = Utils.StrToDateTime(dr["adddate"].ToString());

                             KSCMS.W("<li data-year=\"" + adddate.Year.ToString() + "\">");
                             KSCMS.W("<div class=\"cos-learn-date\"><i></i>" + adddate.ToString("M-d H:m") + "</div>");
                             KSCMS.W("<div class=\"cos-learn-info\">");
                             KSCMS.W("<div class=\"name\"><a href=\"" + BaseFun.GetRewriteUrl("examview", Utils.StrToInt(PeriodID)) + "\" target=\"_blank\">" + cosname + "</a></div>");
                             KSCMS.W("<div class=\"other\">");
                             if (dr["istj"].ToString() == "0")
                             {
                                 KSCMS.W("<a href=\"" + BaseFun.GetRewriteUrl("exam", "do-explained/scoreid-" + Utils.StrToInt(dr["scoreid"].ToString())) + "\"target=\"_blank\" class=\"grey-bt\">查看详情</a>");

                             }
                             else
                             {
                                 KSCMS.W("<a href=\"" + BaseFun.GetRewriteUrl("exam", "do-ex/id-" + Utils.StrToInt(PeriodID)) + "\" target=\"_blank\" class=\"green-bt\">继续考试</a> ");
                             }
                             KSCMS.W("<span>练习时间：" + dr["KSSJ"].ToString() + "</span><span>练习类型：" + (dr["RealTest"].ToString() == "1" ? "正规" : "模拟") + "</span><span>考试得分：" + dr["score"].ToString() + "分" + "</span></div>");

                             KSCMS.W("</div></li>");

                             i++;
                         }
                     }
                     else
                     {
                         KSCMS.W("<div class=\"empty\">还没有考试记录</div><style>.cz_btn{display:none;}</style>");
                     }
                 }

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

    <script>
  //年份分割
  var defaultYear;
  var length = 0;
  $('#myRecord').find('li').each(function(){
     length++;
     if(defaultYear!=$(this).attr('data-year')){
        defaultYear = $(this).attr('data-year');
        $('#learnbox').append('<div class="cos-learn-year">'+defaultYear+'年</div><ul class="ul-year'+defaultYear+' clearfix"></ul>');

     };

    $(this).appendTo($('#learnbox').find('.ul-year'+defaultYear+''));

  });
  if(length==0){
     $('#myRecord').show();
     $('#learnbox').hide();
  }

</script>
    <%}
        else if (KSCMS.S("show") == "1")
        { %>

     <div class="cos-learn" id="learnbox1">
        <div class="cos-learn-line"></div>
        <div class="clear"></div>
        <!--// 年份归类整理-->
    </div>
    <!--// cos-learn-->



        <div id="mytrang" >
		     <%
                 int recordcount, pagecount;
                 int CurrPage = new BasicField().GetCurrPage;
                 int PageSize = 10;
                // Kesion.HtmlTags.CommonFunc.InitBlogNav(UserManage.GetUserInfo().UserID, (new TemporaryVar()).UserName);


                 string sql = " KS_SJMyTrainPaper Where 1=1  and username='" + (new TemporaryVar()).UserName + "'";



                 if (!string.IsNullOrEmpty(KSCMS.S("classid")))
                 {
                     sql += " and classid in(" + Function.GetSJCategoryChildID(Utils.StrToInt(KSCMS.S("classid"))) + ")";
                 }
                 string orderstr = "order by adddate desc";
                 using (DataTable dt = DataFactory.GetPage("*", sql, "id", orderstr, CurrPage, PageSize, out recordcount, out pagecount))
                 {
                     int i = 1;
                     if (dt.Rows.Count > 0)
                     {
                         foreach (DataRow dr in dt.Rows)
                         {

                             string cosname = dr["title"].ToString();
                             string PeriodID = dr["id"].ToString();
                             DateTime adddate = Utils.StrToDateTime(dr["adddate"].ToString());

                             KSCMS.W("<li data-year=\"" + adddate.Year.ToString() + "\">");
                             KSCMS.W("<div class=\"cos-learn-date\"><i></i>" + adddate.ToString("M-d H:m") + "</div>");
                             KSCMS.W("<div class=\"cos-learn-info\">");
                             KSCMS.W("<div class=\"name\">" + cosname + "</div>");
                             KSCMS.W("<div class=\"other\">");
                             if (dr["istj"].ToString() == "0")
                             {
                                 KSCMS.W("<a href=\"" + BaseFun.GetRewriteUrl("exam", "do-trang/id-" + Utils.StrToInt(dr["ID"].ToString())) + "\" target=\"_blank\" class=\"green-bt\">继续考试</a> ");
                             }
                             else
                             {

                                 KSCMS.W("<a href=\"" + BaseFun.GetRewriteUrl("exam", "do-trainingplained/id-" + Utils.StrToInt(dr["id"].ToString())) + "\"target=\"_blank\" class=\"grey-bt\">查看详情</a>");
                             }
                             KSCMS.W("<span>练习用时：" + dr["HasUseTime"].ToString() + "</span><span>练习类型：" + (dr["type"].ToString() == "0" ? "每日一练" : (dr["type"].ToString()) == "1" ? "随机练习" : "章节练习") + "</span></div>");

                             KSCMS.W("</div></li>");

                             i++;
                         }
                     }
                     else
                     {
                         KSCMS.W("<div class=\"empty\">还没有练习记录</div><style>.cz_btn{display:none;}</style>");
                     }
                 }

        %>
	   </div>	
        <div class="cz_btn">
		      <%
                  #region 分页
                  string PageStr = "[KS:PageStr2]";
                  BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
                  KSCMS.W(PageStr);
                  #endregion
         %>
         </div>
    <script>
  //年份分割
  var defaultYear;
  var length = 0;
  $('#mytrang').find('li').each(function(){
     length++;
     if(defaultYear!=$(this).attr('data-year')){
        defaultYear = $(this).attr('data-year');
        $('#learnbox1').append('<div class="cos-learn-year">'+defaultYear+'年</div><ul class="ul-year'+defaultYear+' clearfix"></ul>');

     };

    $(this).appendTo($('#learnbox1').find('.ul-year'+defaultYear+''));

  });
  if(length==0){
     $('#mytrang').show();
     $('#learnbox1').hide();
  }

</script>

 <%}
     else if (KSCMS.S("show") == "2")
     { %>

     <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
        <tr class="title">
            <td width="40px" align="center">序号</td>
		    <td align="center">题目内容</td>
          
	        <td width="10%" align="center">操作 </td>
        </tr>
		     <%
                 int recordcount, pagecount;
                 int CurrPage = new BasicField().GetCurrPage;
                 int PageSize = 10;
                // Kesion.HtmlTags.CommonFunc.InitBlogNav(UserManage.GetUserInfo().UserID, (new TemporaryVar()).UserName);


                 string sql = "  KS_SJCTB a inner join KS_SJTK B ON a.tmid=b.tmid Where flag=1 And a.userid=" + (new TemporaryVar()).UserID;
                 if (!string.IsNullOrEmpty(KSCMS.S("classid")))
                 {
                     sql += " and b.classid in(" + Function.GetSJCategoryChildID(Utils.StrToInt(KSCMS.S("classid"))) + ")";
                 }
                 string orderstr = "order by a.adddate desc";
                 using (DataTable dt = DataFactory.GetPage("a.id,a.adddate,b.*", sql, "a.id", orderstr, CurrPage, PageSize, out recordcount, out pagecount))
                 {
                     int i = 1;
                     if (dt.Rows.Count > 0)
                     {
                         foreach (DataRow dr in dt.Rows)
                         {


                             int tmType = Utils.StrToInt(dr["TmType"].ToString());


                             string cosname = dr["title"].ToString();
                             string PeriodID = dr["id"].ToString();

                             KSCMS.W("<tr class=\"tdbg\">");
                             KSCMS.W("<td class=\"splittd t-a-center\">" + i.ToString() + "</td>");
                             KSCMS.W("<td class=\"splittd tag_left\">");
                             if (tmType == 6 || tmType == 7)
                             {
                                 string tmTypeName = Kesion.Exam.Function.TMTypeArr[tmType - 1];
                                 StringBuilder sb = new StringBuilder();
                                 sb.AppendFormat(@"<textarea  name='ans{0}' id='ans{0}' typeid='{0}' class='hidans' style='display:none'></textarea>", dr["tmid"].ToString());
                                 sb.AppendFormat(@"<input hassubtm='true' name='num{0}' id='num{0}' class='hidnum' type='hidden' value='{1}' tmtype='{2}' index='0'/>", dr["tmid"].ToString(), DataFactory.GetOnlyValue("select count(1) from ks_sjtksub where parentTmId=" + dr["tmid"].ToString()), dr["tmtype"].ToString());
                                 sb.AppendFormat(@"<input type='hidden' name='pid' id='pid' value='{0}'/>", dr["tmid"].ToString());
                                 sb.AppendFormat(@"<div class=""xttitleclass""><strong> {0}：</strong></div><div>{1}</div>", tmTypeName, dr["tmnr"].ToString());
                                 KSCMS.S(sb.ToString());
                             }
                             KSCMS.W(Kesion.Exam.Function.GetTMList(dr, 0, 0, 0, 1, 0, string.Empty, string.Empty, 1, 2));
                             KSCMS.W("</td>");


                             KSCMS.W(" <td class=\"splittd\" nowrap=\"nowrap\" style=\"text-align:center\"><a onClick=\"return(confirm('确定移除吗？'));\" href=\"{=GetUserUrl(exam/myexamctb,do-myctb|action-delete|ids-" + dr["tmid"].ToString() + ")}\"><i class=\"userfont uf-delete\"></div></a></td> ");

                             KSCMS.W("</tr>");
                             i++;
                         }
                     }
                     else
                     {
                         KSCMS.W(" <tr class=\"tdbg\"> <td class=\"splittd\" style=\"text-align:center\" colspan=\"10\" ><div class=\"empty\">还没有错题记录</div> </td></tr> ");
                     }
                 }

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

            else if (KSCMS.S("show") == "3")
            { %>  
            
           
    
     <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
      <tr class="title">
        	<td width="40px" align="center">序号</td>
			 <td  align="center">题目内容</td>
	       <td width="10%" align="center">操作 </td>
     </tr>

		
		     <%
                 int recordcount, pagecount;
                 int CurrPage = new BasicField().GetCurrPage;
                 int PageSize = 10;
                // Kesion.HtmlTags.CommonFunc.InitBlogNav(UserManage.GetUserInfo().UserID, (new TemporaryVar()).UserName);


                 string sql = "  KS_SJCTB a inner join KS_SJTK B ON a.tmid=b.tmid Where flag=0 And a.userid=" + (new TemporaryVar()).UserID;
                 if (!string.IsNullOrEmpty(KSCMS.S("classid")))
                 {
                     sql += " and b.classid in(" + Function.GetSJCategoryChildID(Utils.StrToInt(KSCMS.S("classid"))) + ")";
                 }
                 string orderstr = "order by a.adddate desc";
                 using (DataTable dt = DataFactory.GetPage("a.id,a.adddate,b.*", sql, "a.id", orderstr, CurrPage, PageSize, out recordcount, out pagecount))
                 {
                     int i = 1;
                     if (dt.Rows.Count > 0)
                     {
                         foreach (DataRow dr in dt.Rows)
                         {


                             int tmType = Utils.StrToInt(dr["TmType"].ToString());

                             string cosname = dr["title"].ToString();
                             string PeriodID = dr["id"].ToString();

                             KSCMS.W("<tr class=\"tdbg\">");
                             KSCMS.W("<td class=\"splittd\" style=\"text-align:center\">" + i.ToString() + "</td>");
                             KSCMS.W("<td class=\"splittd tag_left\">");
                             if (tmType == 6 || tmType == 7)
                             {
                                 string tmTypeName = Kesion.Exam.Function.TMTypeArr[tmType - 1];
                                 StringBuilder sb = new StringBuilder();
                                 sb.AppendFormat(@"<textarea  name='ans{0}' id='ans{0}' typeid='{0}' class='hidans' style='display:none'></textarea>", dr["tmid"].ToString());
                                 sb.AppendFormat(@"<input hassubtm='true' name='num{0}' id='num{0}' class='hidnum' type='hidden' value='{1}' tmtype='{2}' index='0'/>", dr["tmid"].ToString(), DataFactory.GetOnlyValue("select count(1) from ks_sjtksub where parentTmId=" + dr["tmid"].ToString()), dr["tmtype"].ToString());
                                 sb.AppendFormat(@"<input type='hidden' name='pid' id='pid' value='{0}'/>", dr["tmid"].ToString());
                                 sb.AppendFormat(@"<div class=""xttitleclass""><strong> {0}：</strong></div><div>{1}</div>", tmTypeName, dr["tmnr"].ToString());
                                 KSCMS.S(sb.ToString());
                             }
                             KSCMS.W(Kesion.Exam.Function.GetTMList(dr, 0, 0, 0, 1, 0, string.Empty, string.Empty, 1, 2));
                             KSCMS.W("</td>");


                             KSCMS.W(" <td class=\"splittd\" nowrap=\"nowrap\" style=\"text-align:center\"><a onClick=\"return(confirm('确定移除吗？'));\" href=\"{=GetUserUrl(exam/myexamfavorite,do-myfavorite|action-delete|ids-" + dr["tmid"].ToString() + ")}\">删除</a></td> ");

                             KSCMS.W("</tr>");
                             i++;
                         }
                     }
                     else
                     {
                         KSCMS.W(" <tr class=\"tdbg\"> <td class=\"splittd\" style=\"text-align:center\" colspan=\"10\" ><div class=\"empty\">还没有收藏试题记录</div> </td></tr> ");
                     }
                 }

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

          <%}
              else if(KSCMS.S("show") == "4")
              {  %>
     <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
            <tr align="center" class="title">
                <td>序号</td>
                <td width="45%">试卷名称</td>
                <td>添加时间</td>
                <td>操作</td>

            </tr>
            <%
                int recordcount2, pagecount2;//分页的参数信息
                int pagesize2 =12;
                int PageIndex2 = new BasicField().GetCurrPage;
                string sql = "KS_SJ where classid in(" + Function.GetSJCategoryChildID(classId) + ")";
                using (DataTable dt = DataFactory.GetPage("*", sql, "id", "order by  adddate  desc", PageIndex2, pagesize2, out recordcount2, out pagecount2))
                {
                    if (dt.Rows.Count > 0)
                    {
                        int i = 0;
                        foreach (DataRow dr in dt.Rows)
                        {
            %>
            <tr>
                <td class="splittd" style="text-align: center"><%=i+1 %></td>
                <td class="splittd" style="text-align: left">
                    
                     <a href="<%=BaseFun.GetRewriteUrl("examview",  Utils.StrToInt(dr["id"].ToString())) %>" target="_blank" >
                         
                         <%=dr["title"].ToString() %>
                         </a>
                    <p class="p-sub-info" >

                    <span class="coursenum" data-num="<%=dr["id"].ToString() %>"><%=Utils.StrToInt(dr["realtest"].ToString())==1?"正规试卷":"模拟试卷" %></span>  
                    <span class="coursenum" data-num="<%=dr["id"].ToString() %>">总分:<%=dr["Score"].ToString() %></span>
                    <span class="coursenum" data-num="<%=dr["id"].ToString() %>">考试时长:<%=dr["kssj"].ToString() %></span>
                    <span class="coursenum" data-num="<%=dr["id"].ToString() %>">答卷次数:<%=Utils.StrToInt(dr["times"].ToString())==0?"不限": Utils.StrToInt(dr["times"].ToString()).ToString()%></span>
                    </p>
                 </td>

                <td class="splittd" style="text-align: center"><%=dr["adddate"].ToString() %></td>
                <td class="splittd" style="text-align: center">

                  <a href="<%=BaseFun.GetRewriteUrl("examview",  Utils.StrToInt(dr["id"].ToString())) %>" target="_blank" class="grey-bt">去考试</a>

                </td>
            </tr>
            <%
                            i++;
                        }
                    }
                    else
                    {
                        KSCMS.S(@"<tr><td colspan='5'><div class=""empty"">
                                        暂时没有您购买考试分类的信息
                                  </div></td></tr>");
                    }
                }
            %>
        </table>

        <div class="cz_btn">
            <%
                #region 分页
                string PageStr2 = "[KS:PageStr2]";
                BasicField.ReplaceFilterPage(ref PageStr2, PageIndex2, pagesize2, pagecount2, recordcount2);
                KSCMS.W(PageStr2);
                #endregion
            %>
        </div>





    <%} %>
</div>

