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

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


    int recordcount, pagecount;
    int CurrPage = new BasicField().GetCurrPage;
    int PageSize =10;
	float chargemoney = 100;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (KSCMS.S("action") == "del")
        {
            isLoadPage = false;
            DelRecord();
            return;
        }
		if (Utils.StrToFloat(KSCMS.S("chargemoney")) > 0)
		{
			chargemoney = Utils.StrToFloat(KSCMS.S("chargemoney"));
		}
    }


    private void DelRecord()
    {
        #region 保存修改密码
       Hashtable ht = new Hashtable();
            ht.Add("id", Utils.StrToInt(KSCMS.S("id")));
            ht.Add("username", __user.UserName);
            ht.Add("status", 0);
            CommonDataUser.Delete("KS_RechargeRecords", ht);
            Msg.Alert("恭喜，删除成功！", KSCMS.GetComeUrl());
        #endregion
    }
</script>
<%
    if (!isLoadPage) return;
%>
  <div class="r_tybox t_tybox nomar">
    <div class="r_title title-style tytitle  pd0">
		<h4 class="float-none   disting_show">充值业务</h4>
    </div>
    
    <table cellspacing="0" cellpadding="0" class="border" width="100%" align="center" border="0">
     <tr class="tdbg">
         <td style="text-align:left;" class="splittd">
             &nbsp;&nbsp;&nbsp;&nbsp; <!--您好,<%=__user.UserName %> !您的身份级别：<font class=red-color><%=UserGroupManage.GetUserGroupInfo(__user.GroupID).GroupName %></font>,--> 
             当前余额 <font class=red-color><%=__user.Money.ToString("f2") %></font> 元 
             本次充值：<input type="text" class="textbox" name="money" id="money" style="width:50px"  value="<%=chargemoney %>"/>
           <%=MyCache.GetCurrencyUnit %> 
                 
           <div class="tytitle">选择支付平台：</div>
           <div class="paylist p20">
         <ul class="clearfix">
     <%
         string payId = "0";
         StringBuilder sb = new StringBuilder();
         using (DataTable dt = CommonData.GetDataTable(4))
         {
             if (dt.Rows.Count > 0)
             {
                 foreach (DataRow dr in dt.Rows)
                 {
                     if (Utils.IsShowPayMentOnDevice(dr["showdevice"].ToString()))
                     {
                         if (dr["isdefault"].ToString() == "1")
                         {
                             payId = dr["id"].ToString();
                         }
                         sb.AppendLine(string.Format(@"<li{2} payid=""{3}""><img src=""{0}"" title=""{1}"" alt=""{1}""/></li>", dr["logo"].ToString(), dr["platname"].ToString(), dr["isdefault"].ToString() == "1" ? @" class=""paycurr""" : string.Empty, dr["id"].ToString()));
                     }
                 }
             }
         }
         Response.Write(sb.ToString());
		 string orderID = KSCMS.S("orderid");
		 if (string.IsNullOrEmpty(orderID))
		 {
			orderID= string.Concat("OP", DateTime.Now.ToString("yy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), DateTime.Now.ToString("HH"), DateTime.Now.ToString("mm"), DateTime.Now.ToString("ss"));
		 }
      %>
         </ul>
     </div>
             
      
     <div class="clear"> </div>

     <div class="pay-bt p20"><input type="button" value="确认支付" class="green-bt green-bt-big button" onclick="return(doPay())" /></div>
                 </td>
     </tr>
    
    </table>

   
     
      <script>
          var pid=<%=payId%>;
          $(document).ready(function(){
              $(".paylist").find("li").click(function(){
                  pid=$(this).attr("payid");
                  $(".paylist").find("li").attr("style","");
                  $(".paylist").find("li").removeClass("paycurr");
                  $(this).addClass("paycurr");
              });
          });

          function doPay() {
              if ($("#money").val()==''){
                  KesionJS.Alert('请输入充值金额!','$("#money").focus();');
                  return false;
              }
              window.open('/plus/pay/PayConfirm.aspx?OrderID=<%=orderID%>&PlatID=' + pid + '&Money='+$("#money").val()+'&from=<%=KSCMS.S("from")%>');
              return false;
           }
       </script>
        
    
     <div class="title-style tytitle">历史充值记录</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>
        	<td>状态</td>
        	<td>支付平台</td>
        	<td>操作</td>
        </tr>
         <%
             string param = "KS_RechargeRecords a Where a.ordertype=0 and a.UserName='" + KSCMS.Filter(Utils.ChkSQL(__user.UserName)) + "'";

             using (DataTable dt = DataFactoryUser.GetPage("a.*", param, "a.id", "order by a.id desc", CurrPage, PageSize, out recordcount, out pagecount))
             {
                 if (dt.Rows.Count > 0)
                 {
                     int i = 0;
                     foreach(DataRow dr in dt.Rows)
                     {
                         KSCMS.W(@"<tr class=""tdbg"">");
                         KSCMS.W(@" <td class=""splittd"" style=""text-align:center"">" + (i +1+ (CurrPage - 1) * PageSize) + "、</td>");
                         KSCMS.W(@"<td class=""splittd"">" + dr["orderid"].ToString() + "</td>");
                         KSCMS.W(@"<td class=""splittd"">");
                         KSCMS.W(Utils.FormatHumanizedTime(Convert.ToDateTime(dr["AddDate"].ToString())));
                         KSCMS.W(@"</td>");
                         KSCMS.W(@"<td class=""splittd"" nowrap>" + MyCache.GetCurrencySymbol + Math.Round(Convert.ToDecimal(dr["paymoney"]), 2) + MyCache.GetCurrencyUnit + "</td>");
                         KSCMS.W(@"<td class=""splittd"" nowrap><span style=""font-size:16px;color:#ff6600"">" + MyCache.GetCurrencySymbol + @"" + Math.Round(Convert.ToDecimal(dr["realmoney"].ToString()), 2) + "</span></td>");
                         KSCMS.W(@" <td class=""splittd"" style=""text-align:center"">");
                         KSCMS.W(Kesion.Controllers.userBasicController.GetPayStatus(Convert.ToInt32(dr["status"].ToString())));
                         KSCMS.W(@"</td>");
                         KSCMS.W(@"<td class=""splittd"">" + dr["platname"].ToString() + "</td>");
                         KSCMS.W(@" <td class=""splittd""  style=""text-align:center;"" nowrap>");
                         KSCMS.W(dr["status"].ToString() == "0" ? "<a href='" + BasicField.GetUserUrl("basic/payonline", "action-del,id-" + dr["id"].ToString()) + @"' onclick=""return(confirm('确定删除吗？'))"">删除</a> | <a target='_blank' href='/plus/pay/PayConfirm.aspx?from=recharge&platid=" + dr["platid"].ToString() + "&orderid=" + dr["orderid"].ToString() + "'>支付</a>" : "---");
                         KSCMS.W(@"</td></tr>");
                         i++;
                     }

                 }else
                 {
                     KSCMS.W(@"<tr class=""tdbg"">");
                         KSCMS.W(@" <td colspan=""10""  style=""text-align:center""><div class=""empty"">没有记录！</div></td></tr><style>.cz_btn{display:none;}</style>");
                 }
             }
        %>
    </table>
     
    <div class="fy_box">
    	<%
		#region 分页
		  string PageStr=__user.GroupID==3||__user.GroupID==4?"[KS:PageStr1]": "[KS:PageStr2]";
		BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
		KSCMS.W(PageStr);
		#endregion
	 	%>
    </div>
    <div class="clearfix"></div>
</div>

