<%@ 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" %>
<%@ Import Namespace="Kesion.Components" %>
<script runat="server" type="text/C#">

    int recordcount, pagecount;
    int PageIndex = new BasicField().GetCurrPage;
    int pagesize = 10;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public string GetPointOrEdays(int chargettype, int point, int edays, DateTime begindate)
    {
        string tep = string.Empty;
        if (chargettype.Equals(1))
            tep = string.Concat("<font color=red>", point.ToString(), "</font> " + MyCache.GetCacheConfig(50));
        else if (chargettype.Equals(2))
        {
            TimeSpan ts = DateTime.Now - begindate;
            int days = edays - ts.Days;
            if (days < 0)
                tep = string.Concat("已过期 <font color=red>", -days, "</font> 天");
            else
                tep = string.Concat("剩 <font color=blue>", days, "</font>  天");
        }
        else
            tep = "<font color=red>永不过期</font>";
        return tep;
    }

 </script>
 <div ID="ListPanel"  Width="100%">

      <div class="t_tybox">
	      <form method="post" action="{$GetCurrUrl}">  
          <div class="top_c_sc mt10">
                <span>会员名称：</span>
                <input type="text" name="TxtKeyWord" ID="TxtKeyWord" value="<%=KSCMS.S("TxtKeyWord") %>" Class="textbox" ></input>
                <input type="submit" ID="Button4"  value=" 搜索 " Class="button"   />
            </div>
              </form>

			<div class="tytitle clearfix"><h4 class="lf">会员信息列表</h4><a href="<%=BasicField.GetUserUrl("teacher/StuImport") %>" class="addbtn">导入会员</a></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  align="center">序号</td>				
                   <td  align="center">ID</td>
				   <td align="center">用户名</td>
				   <td align="center">用户组</td>
                   <td align="center">财富</td>
                   <td align="center">最后登录IP</td>
                    <td align="center">最后登录时间</td>        
                 
              </tr><%
                       
                       string sqlParam = "KS_User u  inner JOIN KS_UserGroup g on U.groupid=g.groupid  Where u.groupid!=3 and u.groupid!=4 and u.schoolid=" + new TemporaryVar().UserID + " ";


            if (!string.IsNullOrEmpty(KSCMS.S("TxtKeyWord")))
            {
                sqlParam += " and u.username like '%" + Utils.ChkSQL(KSCMS.S("TxtKeyWord")) + "%'";
            }
            //绑定及翻页
            using (DataTable dt = DataFactory.GetPage("*,groupname", sqlParam, "userid", "order by  userid desc", PageIndex, pagesize, out recordcount, out pagecount))
            {
                if (dt.Rows.Count > 0) {
                int i=0;
                    foreach(DataRow dr in dt.Rows)
                    {
                    %>
                   <tr class="tdbg">
                             <td height="25" align="v">
                             <%=i+1 %> 
                             </td>                  
                           <td  align="center">				
				            <%= dr["UserID"] %>
				            </td>
                             <td class="tag_left lefticon">          
                             <%= dr["UserName"] %>
                             </td>

				             <td align="center">
               	             <%= dr["GroupName"] %>
                             </td>
           	                 <td >
                              <%= Math.Round(Convert.ToDouble(dr["money"]),2).ToString() %><%=MyCache.GetCurrencyUnit %>
                              <%if (MyCache.GetShopCommonConfig(98) == "1")
                                { %> 
                                <%=GetPointOrEdays(Convert.ToInt32(dr["chargetype"]),Convert.ToInt32(dr["point"]),Convert.ToInt32(dr["edays"]),Utils.StrToDateTime(dr["begindate"])) %>/<%} %>
                                 <span style="color:blue"><%= dr["score"] %>分</span>
                            </td>
                             <td>
                                 <%= dr["LastLoginIP"] %>
                             </td>    
			            <td>
                            <%= dr["lastlogintime"] %>
			            </td>
                     </tr>
                  <%    
                    i++;
                    }
                } 
                else {
                    KSCMS.W(@" <tr class=""tdbg""  >
                            <td class=""Ctd"" style=""text-align:center"" colspan=""10"">
                              <div class=""empty"">暂未添加任何推广会员</div>
                            </td>
                           </tr> ");
                }
            }
                       
                       
                        %>
               </table> 
       
      	<div class="fy_box" >
                      <%
            #region 分页
            string PageStr = "[KS:PageStr3]";
            BasicField.ReplaceFilterPage(ref PageStr, PageIndex, pagesize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
      	</div>
    <div class="clearfix"></div>
    </div>
	
</div>