<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="System.Data" %>
<script runat="server" type="text/C#">

    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息
    bool isLoadPage = true;  //定义页面是否加载

    public static int InNum = 0;
    public static int OutNum = 0;
    string param = string.Empty;

    int recordcount, pagecount;
    int CurrPage = new BasicField().GetCurrPage;
    int PageSize = 10;
    protected void Page_Load(object sender, EventArgs e)
    {
         param = " WHERE userId=" + __user.UserID;
        if (!IsPostBack)
        {
                InNum = Utils.StrToInt(DataFactoryUser.GetOnlyValue("select count(1) from KS_LogScore" + param + " and InOrOutFlag=1"));
                OutNum = Utils.StrToInt(DataFactoryUser.GetOnlyValue("select count(1) from KS_LogScore" + param + " and InOrOutFlag=2"));
        }
    }
 public string GetScore(double point, int inoroutflag, int type)
        {
            if (type == inoroutflag)
            {
                return string.Format("{0}", point);
            }
            else
            {
                return "-";
            }
        }

        public string GetOpType(int type)
        {
            if (type == 1)
                return "<span class=green-color>收入</span>";
            else
                return "<span class=red-color>支出</span>";

        }
        public string GetNowScore(double point)
        {
            return string.Format("{0}", point);
        }
</script>
<%
    if (!isLoadPage) return;
%>
<div class="t_tybox nomar clearfix disting">
      <div class="tytitle r_title"><h4 class="disting-title disting_show"><%=MyCache.GetCacheConfig(90)  %>明细</h4>
         
      </div>
      <div class="top-sort clearfix">
      
        <div class="top-sort-option fl">
            <a href='<%=BasicField.GetUserUrl("basic/logscore") %>'>所有记录（<%=InNum+OutNum %>）</a>
            <a href='<%=BasicField.GetUserUrl("basic/logscore","IncomeOrPayOut-1") %>'>收入记录（<%=InNum %>）</a>
            <a href='<%=BasicField.GetUserUrl("basic/logscore","IncomeOrPayOut-2") %>'>支出记录（<%=OutNum %>）</a>
        </div>
      </div>
       
    <table id="tablist" width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="border">
     <tr align="center" class="title">
        	<td width="60" align="center">用户</td>
        	<td align="center">消费时间</td>
            <td align="center" nowrap> 收入(<%=MyCache.GetCacheConfig(91)  %>) </td>
            <td nowrap align="center"> 支出((<%=MyCache.GetCacheConfig(91)  %>)) </td>
            <td align="center">摘要</td>
	        <td align="center" nowrap>余额((<%=MyCache.GetCacheConfig(91)  %>))</td>
	        <td align="center">备注</td>
        </tr>
   <%
       if (Utils.StrToInt(KSCMS.S("IncomeOrPayOut")) >0)
       {
           param += " and InOrOutFlag=" + Utils.StrToInt(KSCMS.S("IncomeOrPayOut"));
       }

       using (DataTable dt = DataFactoryUser.GetPage("*", "[KS_LogScore]"+param, "id", "order by id 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"">" + dr["UserName"].ToString() + @"</td>
                      <td class=""splittd"" style=""text-align:center"">" +
                    Utils.FormatHumanizedTime(Convert.ToDateTime(dr["AddDate"].ToString())) + @"
                      </td>
                      <td class=""splittd"" align=""center"">" + GetScore(Convert.ToDouble(dr["score"].ToString()), Convert.ToInt16(dr["InOrOutFlag"].ToString()), 1) + @"</td>
                      <td class=""splittd"" align=""center"">"+
                     GetScore(Convert.ToDouble(dr["Score"].ToString()), Convert.ToInt16(dr["InOrOutFlag"].ToString()), 2) + @"
                      </td>
                      <td class=""splittd"" align=""center"">" +
                    GetOpType(Convert.ToInt16(dr["InOrOutFlag"].ToString())) + @"
                      </td>
                      <td class=""splittd"" align=""center"">累计"+dr["nowScore"].ToString()+" &nbsp; 可用<strong class=black-color>"+ dr["AvailableScore"].ToString() +@"</strong>
                      </td>
                      <td class=""tag_left"" style=""width:180px;word-break:break-all;color:#999;"">" +
                     dr["remark"].ToString() + @"
                      </td>
                  </tr>");

               }
           }else
           {
               KSCMS.W(@" <tr class=""tr-nobor"">
                <td class=""splittd"" style=""text-align:center"" colspan=""10"">
                 <div class=""empty"">没有消费记录！</div>
                </td>
           </tr><style>.cz_btn{display:none;}</style>");
           }
       }

        %>
    </table>
    <div class="fy_box">
        <%
            #region 分页
            string PageStr = "[KS:PageStr1]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
	   </div>
</div>
<script>
  var url = location.href.replace(location.origin,'');
  $('.top-sort-option').find('a').each(function(){
    var href = $(this).attr('href');
    if(href==url){
      $(this).addClass('on');
    }
  });

</script>