<%@ 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;  //定义页面是否加载
    
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserLogin.Run();
        if (KSCMS.S("action") == "delete")
        {
            deleteSj(KSCMS.S("ids"));//删除
        }
    }
    private void deleteSj(string ids)
    {
        if (!string.IsNullOrEmpty(ids))
        {
            ids = Utils.FilterIDs(ids);
            string[] id_arr = ids.Split(',');
            Hashtable ht = new Hashtable();
            foreach (string id in id_arr)
            {
                ht.Add("tmid", Utils.StrToInt(id));
                ht.Add("UserID", (new TemporaryVar()).UserID);
                CommonData.Delete("[KS_SJCTB]", ht);
           
                ht.Clear();
            }
        }
    }
    
 </script> 
<%
    if (!isLoadPage) return;
%>
<script src="ks_inc/exam/exam.js"></script>
<div class="r_tybox nomar">

    <div class="r_title">我收藏的试题
		<div class="tabs">
            <ul>
             <%if (BaseFun.CheckModulePower("edu"))
             { %>
               <li><a href='<%=BasicField.GetUserUrl("other/mycollect", "optype-cos") %>'>课程收藏</a> </li>
              <li><a href='<%=BasicField.GetUserUrl("other/mycollect") %>'>教师收藏</a></li>
              <%}
                  if (BaseFun.CheckModulePower("plus.group"))
                  {%>
              <li><a href='<%=BasicField.GetUserUrl("other/mycollect", "optype-group") %>'>小组收藏</a></li>
                  <%
               }%>
              <li class="puton"><a href='<%=BasicField.GetUserUrl("other/mycollect","optype-sj") %>'>试卷收藏</a></li>
               <li><a href="<%=BasicField.GetUserUrl("other/mycollect", "optype-article") %>">内容收藏</a></li>
                 <%if (BaseFun.CheckModulePower("plus.ask"))
                     { %>
              <li><a href='<%=BasicField.GetUserUrl("other/favorite","flag-1") %>'>问题收藏</a></li>
                <%} %>
            </ul>	
        </div>
    </div>
     <div class="top-sort clearfix">
            <div class="top-sort-tab">
                <ul>
                    <li ><a href='<%=BasicField.GetUserUrl("other/mycollect","optype-sj") %>'>试卷收藏</a> </li>
                    <li class="puton"><a href='<%=BasicField.GetUserUrl("exam/Myexamfavorite") %>'>试题收藏</a></li>
                     
                </ul>
            </div>
        </div>
    <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;


            string sql = "  KS_SJCTB a inner join KS_SJTK B ON a.tmid=b.tmid Where flag=0 And a.userid=" + (new TemporaryVar()).UserID;
            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>
  </div>
