<!--#include file="include/nowshop.asp" -->

<%
call checklogin()
call aspsql()

set rs=conn.execute("select * from buser where UserId='"&request.cookies("buyok")("userid")&"'")
usertype=rs("usertype")
userid=rs("UserID")
totallogin=rs("totallogin")
if usertype="2" then
usertype=type2
userkou=kou2
elseif usertype="3" then
usertype=type3
userkou=kou3
elseif usertype="4" then
usertype=type4
userkou=kou4
elseif usertype="5" then
usertype=type5
userkou=kou5
elseif usertype="6" then
usertype=type6
userkou=kou6
else
usertype=type1
userkou=kou1
end if
response.cookies("buyok")("userkou")=userkou
IP=Request.serverVariables("REMOTE_ADDR")
%>
<%
call aspsql()
call checklogin()
if request("del")<>"" then call delorder()
if request("cancel")<>"" then call cancelorder()

sql = "select A.OrderNum,A.OrderTime,A.RecName,A.OrderSum,A.RecName,A.Status,B.StatusDefine"&_
          " from bOrderList A,type B "&_
		  " where A.del<>true and A.UserId='"&request.cookies("buyok")("userid")&"' and A.Status = B.Status order by A.OrderTime desc"
set rs=Server.Createobject("ADODB.RecordSet")
rs.Open sql,conn,1,1
%>

<HTML>
<HEAD>
<TITLE>用户中心首页-<%=sitename%>-<%=siteurl%></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="description" content="<%=sitedescription%>">
<meta name="keywords" content="<%=sitekeywords%>">
<link rel="stylesheet" href="css.css" type="text/css">
</HEAD>
<CENTER>
<%
set rsuser=conn.execute("select * from buser where UserId='"&request.cookies("buyok")("userid")&"'")
%>

<!--#include file="top.asp"-->
<table width="768" border="0" cellspacing="0" cellpadding="0">
  <tr> 
      <td width="186" align="center" valign="top" bgcolor="#f4f5fd"><!--#include file="zuo_member.asp"--></td>
    <td align="center" valign="top"> <TABLE width=560 border=0 cellPadding=0 cellSpacing=0 bordercolor="#587ad9">
        <TBODY>
          <TR> 
            <TD height=12><table>
                  <tr> 
                    <td align="center" valign="middle"><TABLE cellSpacing=0 cellPadding=0 width=547 border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
                        <TBODY>
                          <TR> 
                            <TD bgColor=#f4f5fd height=60>&nbsp;&nbsp;欢迎 <font color=red> 
                              <%=userid%></font> 进入用户中心 ！您是第 <font color=red><%=totallogin%></font> 
                              次登陆本站。<br>
                              <br>
                              &nbsp;&nbsp;您本次登陆IP为 <font color=red><%=Request.serverVariables("REMOTE_ADDR")%></font></TD>
                          </TR>
                        </TBODY>
                      </TABLE></td>
                  </tr>
                  <tr> 
                    <td align="center" valign="middle">
                      <table width="547"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
                        <tr bgcolor="#f0f0f0" height="30"> 
                          <td align="center" valign="middle" bgcolor="#f4f5fd">订单号</td>
                          <td align="center" valign="middle" bgcolor="#f4f5fd">提交时间</td>
                          <td align="center" valign="middle" bgcolor="#f4f5fd">总金额</td>
                          <td align="center" valign="middle" bgcolor="#f4f5fd">订单状态</td>
                          <td align="center" valign="middle" bgcolor="#f4f5fd">订单操作</td>
                        </tr>
                        <%
if rs.eof and rs.bof  then
	response.write "<tr><td colspan=5 height=50 align=center bgcolor=#FFFFFF>没有订单</td></tr>"
	else
	do while not rs.eof
%>
                        <tr bgcolor="#FFFFFF" height="30"> 
                          <td align="center" valign="middle"> 
                            <% set rs_pay=conn.execute("select * from pay") 

if rs_pay("pay")=3 then
%>
                            <a href="order_view1.asp?OrderNum=<%=rs("OrderNum")%>"> 
                            <%=rs("OrderNum")%></a> 
                            <% else %>
                            <a href="order_view2.asp?OrderNum=<%=rs("OrderNum")%>"> 
                            <%=rs("OrderNum")%></a> 
                            <% end if %>
                          </td>
                          <td align="center" valign="middle" ><%=rs("OrderTime")%></td>
                          <td align="center" valign="middle"><%=formatnumber(rs("OrderSum"),2)%></td>
                          <td align="center" valign="middle"> <%=rs("StatusDefine")%> 
                          <td align=center valign="middle"><a href="my_order.asp?cancel=<%=rs("OrderNum")%>"> 
                            <%if rs("Status")="11" then response.write "恢复" else response.write "取消"%>
                            </a> &nbsp; <span style="cursor:hand" onclick="{if(confirm('该操作不可恢复！\n\n确实删除所选订单吗？ ')){location.href='my_order.asp?Del=<%=rs("OrderNum")%>';}}">删除</span></td>
                        </tr>
                        <%
rs.movenext
loop
end if
%>
                      </table>
					                        <%
rs.close
set rs=nothing
%> 
                    </td>
                  </tr>
                </table></TD>
          </TR>
        </TBODY>
      </TABLE>
      
    </td>
  </tr>
</table>

<!--#include file="down.asp"-->
</BODY></center>

</HTML>
<%
conn.close
set conn=nothing
%>
<%
sub cancelorder()
sql="select * from bOrderList where OrderNum='"&request("cancel")&"'"
set rs=Server.Createobject("ADODB.RecordSet")
rs.Open sql,conn,1,3
	if rs.eof and rs.bof then
		tishi="出错了，没有此订单！"
	elseif rs("userid")<>request.cookies("buyok")("userid") then
		tishi="出错了，您不能操作此订单！"
	else
		if rs("Status")="11" then
		   rs("Status")="0"
		   rs.update
		   tishi="操作成功，所选订单已被恢复！"
		elseif rs("Status")="0" then
		   rs("Status")="11"
		   tishi="操作成功，所选订单已被取消！"
		   rs.update
		else
	  	  tishi="操作失败，此订单不能自行取消！"
		end if
	end if
		   rs.close
		   set rs=nothing
	response.write "<script language='javascript'>"
	response.write "alert('"&tishi&"');"
	response.write "location.href='my_order.asp';"
	response.write "</script>"
end sub

sub delorder()
sql="select * from bOrderList where OrderNum='"&request("Del")&"'"
set rs=Server.Createobject("ADODB.RecordSet")
rs.Open sql,conn,1,3

	if rs.eof and rs.bof then
		tishi="出错了，没有此订单！"
	elseif rs("userid")<>request.cookies("buyok")("userid") then
		tishi="出错了，您不能操作此订单！"
	else
		conn.execute("update bOrderList set del=true where OrderNum='"&request("Del")&"'")
		tishi="操作成功，所选订单已被删除！"
	end if
  		response.write "<script language='javascript'>"
		response.write "alert('"&tishi&"');"
		response.write "location.href='my_order.asp';"
		response.write "</script>"
rs.close
set rs=nothing
end sub
conn.close
set conn=nothing
%>
