<%@ 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;  //定义页面是否加载

	protected void Page_Load(object sender, EventArgs e)
	{
		string DoMethod = BasicField.GetParam("do");
		if (string.IsNullOrEmpty(DoMethod))
		{
			DoMethod = KSCMS.S("action");
		}
		switch (DoMethod)
		{
			case "cancel":
				RemoveFromFavorite();
				break;
		}
	}

	public static string GetTname(int tcid)
	{
		string str = DataFactory.GetOnlyValue("select top 1 tname from  KS_Costeacher where tcid=" + tcid);
		return str;
	}
	public void RemoveFromFavorite()
	{
		string ids = BasicField.GetParam("ids").Replace(" ", "");
		if (string.IsNullOrEmpty(ids))
		{
			ids = KSCMS.S("ids");
		}
		if (ids != "")
		{
			string[] id_arr = ids.Split(',');
			Hashtable ht = new Hashtable();
			foreach (string id in id_arr)
			{
				ht.Add("id", id);
				CommonData.Delete("[KS_CoseUserZan]", ht);
				ht.Clear();
			}
		}
		Msg.Alert("删除成功！", KSCMS.GetComeUrl());
		isLoadPage = false;
		return;
	}
</script>
<%
    if (!isLoadPage) return;
%>
	<div class="r_tybox nomar">
	<div class="r_title">讲师互动</div>
	 <div class="tabs">
                <ul>
                    <li  class='puton'><a href="<%=BasicField.GetUserUrl("course/Mycoszan")%>">我点赞的教师</a></li>
					<li><a href="<%=BasicField.GetUserUrl("course/MyTeacherPJ")%>">我评价的教师</a></li>
					<li><a href="<%=BasicField.GetUserUrl("course/MyCosTalk")%>">我留言的教师</a></li>
					<li><a href="<%=BasicField.GetUserUrl("course/MyCosLiveTalk")%>">我的直播发言</a></li>
                </ul>
            </div>
				  <form name="myform" action="<%=BasicField.GetUserUrl("course/mycoszan") %>" method="post" id="myform" >
			     <div class="r_padbox">
			
				 <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
				 <tr class="title">
				 <td width="5%" align="center" nowrap="nowrap">选择</td>
				 <td width="10%">教师头像</td>
				 <td align="center">教师姓名</td>
				 <td width="20%" align="center">教师星级</td>
				 <td width="20%" align="center">点赞时间 </td>
				 <td align="center" width="10%">操作</td>
				 </tr>
				 <%
					 KSCMS.W(" <input type=\"hidden\" name=\"action\" value=\"cancel\"/>");
					 int recordcount, pagecount;
					 int CurrPage = new BasicField().GetCurrPage;
					 int PageSize = 10;
					 using (DataTable dt = DataFactory.GetPage("a.*,b.photo,b.grade", "[KS_CoseUserZan] as a inner join KS_CosTeacher as b on a.tcid=b.tcid  where a.UserName='" + Utils.ChkSQL((new TemporaryVar()).UserName) + "'", "a.id", "order by a.AddDate Desc", CurrPage, PageSize, out recordcount, out pagecount))
					 {
						 if (dt.Rows.Count > 0)
						 {
							 foreach (DataRow dr in dt.Rows)
							 {
								 KSCMS.W("<tr class=\"tdbg\"><td class=\"splittd\" align=\"center\"><input class=\"cleckbtn\" type=\"checkbox\" name=\"ids\" value=\"" + dr["id"].ToString() + "\" /></td>");
								 KSCMS.W("<td class=\"splittd\" align=\"center\"><img src=\"" + dr["photo"].ToString() + "\" onerror=\"/SysImg/face/boy.jpg\" style=\"border-radius:50%;width:60px;height:60px;\" /></td>");
								 KSCMS.W("<td class=\"splittd tdTitle\" align=\"center\"> <a href='" + BaseFun.GetRewriteUrl("teacherview", Utils.StrToInt(dr["id"].ToString())) + "' title=\"前台页\" target=\"_blank\">" + GetTname(Utils.StrToInt(dr["tcid"].ToString())) + "</a> </td>");
								 KSCMS.W("<td class=\"splittd\" align=\"center\"><img src=\"/user/images/10/star" + dr["grade"].ToString() + ".png\" height=\"16\"></td>");
								 KSCMS.W("<td class=\"splittd\" align=\"center\">" + Utils.FormatHumanizedTime(Convert.ToDateTime(dr["AddDate"].ToString())) + "  </td> ");
								 KSCMS.W("<td class=\"splittd\" align=\"center\"> <a class=\"deletebtn link-color\" onclick=\"return(confirm('确定删除吗？'));\" href=\"" + BasicField.GetUserUrl("course/MyCosZan", "do-cancel,ids-" + dr["id"].ToString() + "") + "\">删除</a></div></td></tr>");
							 }
						 }
						 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">
        <span><input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);"/>全选</span>
        <span><input type="submit" class="button" value="批量删除" onclick="return (CheckIds('del'));"></span>
        <div class="clear"></div>
     </div>
	  <%
            #region 分页
            string PageStr = "[KS:PageStr2]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
				 </div>
				 		  </form>
				 </div>