<%@ 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 string sqlParam = string.Empty;
	public int recordcount, pagecount;
	public int CurrPage = new BasicField().GetCurrPage;
	public int PageSize = 10;
	public DataRow drr = null;
    public string tcid = string.Empty;
    public int status = 1;
	protected void Page_Load(object sender, EventArgs e)
	{
        if (KSCMS.S("status") == "2") 
        {
            status = 2;
        }
	//	tcid = DataFactory.GetOnlyValue("select top 1 tcid from KS_CosTeacher where userid='" + UserManage.GetUserInfo().UserName + "'");
        DataTable dt = DataFactory.GetDataTable("select * from KS_costeacher where userid=" +new TemporaryVar().UserID);
		if (dt.Rows.Count > 0)
		{
			 drr = dt.Rows[0];
             tcid = drr["tcid"].ToString();
		}
		else
		{
			Msg.Alert("对不起，您查看的教师不存在！", Utils.GetRootPath());
			isLoadPage = false;
			return;
		}
		
		
	}
    /// <summary>
    /// 获取点播课程名称
    /// </summary>
    /// <param name="courseid">课程id</param>
    /// <returns></returns>
    public string GetCourseName(int courseid)
    {
        string name = DataFactory.GetOnlyValue("select name from KS_course where courseid="+courseid);
        if (name == "0") { name = "未查询到课程信息"; }
        return name;
    }

</script>
<%
    if (!isLoadPage) return;
%>
<%if(string.IsNullOrEmpty(KSCMS.S("do"))){ %>
<div class="t_tybox">

  <asp:Panel ID="PanList" runat="server">
   
	  <div class="message_info tytitle clearfix" style="line-height:50px">
			评价等级:<span><%=Utils.StrToFloat(drr["totalPJ"].ToString()).ToString("0.00") %></span>
			留言总数:<span>8</span>
			评价总数:<span>4</span>
			好评率:<span>25.00%</span>
			 <div class="top_c_sc mt10">
                <span>赠送用户：</span>
                <form name="myform" action="<%=BasicField.GetUserUrl("teacher/TcAchieve") %>" method="post" id="Form1" style="float:left">
                  <input name="TextBox1" type="text"  class="textbox" value ="<%=KSCMS.S("TextBox1") %>" />
                  <input type="submit" name="Button4" value=" 搜索 " class="button" />
                </form>
              </div>
              
	  </div>
	  <div class="tabs_header">
          <ul class="tabs clearfix">
          <li class="<%=KSCMS.S("status")!="2"?"active":"" %>"><a href="<%=BasicField.GetUserUrl("teacher/TcAchieve") %>" >直播道具礼物</a></li>
          <li class="<%=KSCMS.S("status")=="2"?"active":"" %>"><a  href="<%=BasicField.GetUserUrl("teacher/TcAchieve","status-2") %>">点播道具礼物</a></li>
          </ul>
      </div>
	  <div id="manage_top" class="clearfix  m20">
          <span class="f-l" style="padding-right:10px">收到的礼物总数</span>
          <div id="myDJ" class="f-l clearfix">
          <%
              StringBuilder sb = new StringBuilder();
              DataTable dts = DataFactory.GetDataTable("select acimage,acname,holdnum,a.acid from KS_CosLiveHold as a inner join KS_CosLiveacClass as b on a.acid=b.id where b.status=1 and username='" + new TemporaryVar().UserName + "'");
              if (dts.Rows.Count > 0)
              {
                  foreach (DataRow dr in dts.Rows)
                  {
                      sb.Append("<span style='margin-left:10px' class=\"fl\"><img style='width:50px' src='" + dr["acimage"].ToString() + "'>" + dr["acname"].ToString() + ":<em>" + dr["holdnum"].ToString() + "</em></span>");
                  }
              }
              sb.Append("<span style='margin-right:10px' class=\"fl\">道具可提现额度：<em style='color:red'>"+Kesion.APPCode.Public.CashMoneys(__user.UserName,status)+"</em></span>");
              KSCMS.W(sb.ToString());
            %>
          </div>
      </div>
 	  <div class="clear blank10"></div>
            <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
                 <tr align="center" class="title">
                    <td>编号</td>
                    <td>赠送道具</td>
                    <td>赠送数量</td>
                    <td>赠送者</td>
                    <td>赠送时间</td>
                     <%if (status == 2) { %>
                    <td>课程</td>
                     <%} %>
                    <td>获得的提现额度</td>
                </tr>
        <%
            string sqlParam = " KS_CosLiveac  Where status=" + status + " and acepter='" + __user.UserName + "'";
            if (KSCMS.S("TextBox1") != "") { sqlParam += " and sender like '%" + Utils.RemoveXss(KSCMS.S("TextBox1")) + "%'"; }
            using (DataTable dt = DataFactory.GetPage("*", sqlParam, "id", "order by id desc", CurrPage, PageSize, out recordcount, out pagecount))
            {
                if (dt.Rows.Count > 0)
                {
                    foreach(DataRow dr in dt.Rows)
                    {
                    %>
         <tr class="tdbg">
             <td  align="center"><%=dr["id"].ToString() %></td> 
             <td  align="center"><img style="width:40px;height:40px;" src="<%=DataFactory.GetOnlyValue("select top 1 acimage from KS_CosLiveacclass where id="+Utils.StrToInt(dr["acid"].ToString())) %>" onerror="this.src='/sysimg/nopic.gif'" /><%=DataFactory.GetOnlyValue("select top 1 acname from KS_CosLiveacclass where id="+dr["acid"].ToString()) %></td>
             <td  align="center"><%=dr["sendnum"].ToString() %></td>  
             <td  align="center"><%=dr["sender"].ToString() %></td>
             <td  align="center"><%=dr["senddate"].ToString() %></td>  
              <%if (status == 2) { %>
             <td align="center"><%=GetCourseName(Utils.StrToInt(dr["courseid"].ToString())) %></td>
              <%} %>
             <td  align="center"><%=Utils.StrToFloat(Kesion.APPCode.Public.ReturnShopPrice(DataFactory.GetOnlyValue("select top 1 cashmoneys from KS_CosLiveacclass where id="+dr["acid"].ToString())))*Utils.StrToFloat(dr["sendnum"].ToString())  %></td> 
        </tr>
        <%
                    }
                }
                else {
                    KSCMS.W("<tr class=\"tdbg\"> <td colspan=\"6\" style=\"border-bottom:0px;\"><div class=\"clear blank10\"></div><div class=\"empty\">暂无收到的道具记录！</div></td></tr>");
                }
            }
             
              %>
    </table>
    <div class="fy_box">
    <%
            #region 分页
            string PageStr = "[KS:PageStr1]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
  </div>
		<div class="cz_btn mt10 cz_btnhide">
		  <form name="myform" action="<%=BasicField.GetUserUrl("teacher/TcAchieve") %>" method="post" id="myform" >
			  <span><a href="<%=BasicField.GetUserUrl("teacher/TcAchieve","do-zan") %>">我获得的赞</a></span>
			  <span><a href="<%=BasicField.GetUserUrl("teacher/TcAchieve","do-collect") %>">被收藏</a></span>
			  </form>
		</div>   
		<div class="clear"></div> 
			<div class="clear"></div> 
	 </asp:Panel>
</div>
	 <%}else if(KSCMS.S("do").Equals("zan")){ %>
	
<div class="t_tybox">	

          <div class="tytitle"><h4 class="h4cor">赞我的人:<span><%=DataFactory.GetOnlyValue("select count(*) from KS_CoseUserZan where channelid=0 and tcid=" + Utils.StrToInt(tcid)) %></span></h4></div> 
       
           <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" class="border">
            <tr align="center" class="title">
                <td width="30%" align="center">用户名</td>
                <td width="70%" align="center">点赞时间</td>            
            </tr>
       <%
		   if (tcid != "")
		   {
               sqlParam = "KS_CoseUserZan  Where channelid=0 and tcid=" + Utils.StrToInt(tcid) + "";
		   }
		   using (DataTable dt = DataFactory.GetPage("*", sqlParam, "ID", "order by adddate desc", CurrPage, PageSize, out recordcount, out pagecount))
		   {
			   if (dt.Rows.Count > 0)
			   {
				   foreach (DataRow dr in dt.Rows)
				   {
					   KSCMS.W("<TR class=\"tdbg sort bar\"><td align=\"center\">" + dr["username"] + "</td><td align=\"center\" class=\"star_cor\">" + dr["adddate"] + " </td></TR>");
				   }
			   }
		   }
		    %>
          </table>
		  <div class="cz_btn">
          	<span><input type="button" value="返回" class="button" onclick="window.history.back()" /></span>
		  </div>
		  <div class="clear"></div>

</div>
<%}else if(KSCMS.S("do").Equals("collect")){ %>
<div class="t_tybox">			 
	  <div class="tytitle"><h4 class="h4cor">关注我的人:<span><%=DataFactory.GetOnlyValue("select count(*) from KS_Favorite where InfoId=" + Utils.StrToInt(tcid) + " and channelid=0") %></span></h4></div>
	<table id="Table1" width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" class="border">
		<tr align="center" class="title">
			<td width="30%" align="center">用户名</td>
			<td width="70%" align="center">收藏时间</td>            
		</tr>

		  <%
		   if (tcid != "")
		   {
               sqlParam = "KS_Favorite  Where InfoId=" + Utils.StrToInt(tcid) + " and channelid=0";
		   }
		   using (DataTable dt = DataFactory.GetPage("*", sqlParam, "ID", "order by AddDate desc", CurrPage, PageSize, out recordcount, out pagecount))
		   {
			   if (dt.Rows.Count > 0)
			   {
				   foreach (DataRow dr in dt.Rows)
				   {
					   KSCMS.W("<tr class=\"tdbg sort bar\"><td align=\"center\">" + dr["username"].ToString() + "</td><td align=\"center\" class=\"star_cor\">" + dr["adddate"].ToString() + " </td></tr>");
				   }
			   }
		   }
		    %>
		

	   </table>
	   <div class="cz_btn" style="">
		  <span><input type="button" value="返回" class="button" onclick="window.history.back()" /></span>
	   </div>
	   <div class="clear"></div>
	   
	 </div>	
	 <%}else if(KSCMS.S("do").Equals("pj")){ %>
	
<div class="t_tybox">	

          <div class="tytitle"><h4 class="h4cor">评价我的人:<span><%=DataFactory.GetOnlyValue("select count(*) from KS_CosTeacherPJ where tcid=" + Utils.StrToInt(tcid)) %></span></h4></div> 
       
           <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" class="border">
            <tr align="center" class="title">
                <td width="30%" align="center">用户名</td>
                <td width="10%" align="center">评价等级</td>  
                 <td width="70%" align="center">评价内容</td> 
                <td width="10%" align="center">评价时间</td>            
            </tr>
       <%
           if (tcid != "")
           {
               sqlParam = "KS_CosTeacherPJ  Where status=1 AND tcid=" + Utils.StrToInt(tcid) + "";
           }
           using (DataTable dt = DataFactory.GetPage("*", sqlParam, "ID", "order by PJdate desc", CurrPage, PageSize, out recordcount, out pagecount))
           {
               if (dt.Rows.Count > 0)
               {
                   foreach (DataRow dr in dt.Rows)
                   {
                       KSCMS.W("<TR class=\"tdbg sort bar\"><td align=\"center\">" + dr["username"] + "</td>");
                       KSCMS.W("<td align=\"center\" class=\"star_cor\"> <img src=\"/SysImg/star/star-"+dr["PJstar"]+".jpg\" title=\""+dr["PJstar"] +"颗星\" /> </td>");
                       KSCMS.W("<td align=\"center\" class=\"star_cor\">" + dr["PJcontent"].ToString() + "</td>");
                       KSCMS.W("<td align=\"center\" class=\"star_cor\">" + dr["PJdate"].ToString() + "</td></tr>");

                   }
               }else
               {
                    KSCMS.W("<tr class=\"tdbg\"><td class=\"Ctd\" style=\"text-align:center\" colspan=\"4\"><div class=\"empty\">暂未无学员对我评价</div></td></tr> ");
               }
           }
		    %>
          </table>
		  <div class="cz_btn">
          	<span><input type="button" value="返回" class="button" onclick="window.history.back()" /></span>
		  </div>
		  <div class="clear"></div>

</div><% }%>

 
