|
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script language="javascript">
function love(id,name,price,kunum)
{
// alert(id);
// alert(name);
// alert(price);
// alert(kunum);
document.getElementById("show").style.display="block";
document.getElementById("sname").value=name;
document.getElementById("sprice").value=price;
document.getElementById("skunum").value=kunum;
document.getElementById("sid").value=id;
}
function xiao()
{
document.getElementById("show").style.display="none";
}
var ziwin;
function doSearch(type)
{
if(type=="cha")
{
ziwin= window.open ("chaxun.aspx", "", "height=600, width=800, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}
else
{
var gounum=parseInt(document.getElementById("snum").value);
var skunum=parseInt(document.getElementById("skunum").value);
if(gounum<=skunum)
{
var output=document.getElementById("sid").value;
output+="+++"+document.getElementById("sname").value;
output+="+++"+document.getElementById("sprice").value;
output+="+++"+gounum;
CallServer(output,"");
}
else
{
document.getElementById("snum").value="请重新购买信息";
document.getElementById("snum").select();
document.getElementById("snum").focus();
}
}
}
function receive(text)
{
messageShow(text);
document.getElementById("snum").value="";
xiao();
// document.getElementById("form1").reset();
// document.getElementById("show").innerHTML=text;
// alert(document.getElementById("show"));
}
var j;
function messageShow(text)
{
var w=document.body.offsetWidth;
var h=document.body.offsetHeight;
var mw=document.getElementById("message").style.width;
var mh=document.getElementById("message").style.height;
var toph=parseInt(document.body.scrollTop);
//alert(toph);
document.getElementById("message").style.left=parseInt(w)-parseInt(mw)-30;
document.getElementById("message").style.top=parseInt(h)+toph-parseInt(mh);
document.getElementById("message").innerHTML=text;
document.getElementById("message").style.display="block";
j=window.setTimeout("messageXiao()",3000);
}
function messageXiao()
{
window.clearTimeout(j);
document.getElementById("message").innerText="";
document.getElementById("message").style.display="none";
}
function test()
{
// var toph=parseInt(document.body.scrollTop);
// alert(document.body.scrollTop);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="xianshi" style="position:absolute; left:300px; top:300px; width:300px">
</div>
<div id="message" style="position:absolute; left:0px; top:0px; display:none; width:150px; height:60px;background-color:#8cacbb"></div>
<div style="position:absolute;left:100px; top:100px; display:none; background-color:#8cacbb" id="show">
<table>
<tr><td>商品名</td><td><input id="sname" readonly/><input type="hidden" id="sid"/></td></tr>
<tr><td>单价</td><td><input id="sprice" readonly/></td></tr>
<tr><td>库存数量</td><td><input id="skunum" readonly/></td></tr>
<tr><td>购买</td><td><input id="snum" /></td></tr>
<tr><td><input type="button" value="购买" onclick="doSearch('mai')" /></td><td><input type="button" value="取消" onclick="xiao()"/></td></tr>
</table>
</div>
<a href="#" onclick="doSearch('cha')">查看购物车</a>
<div>
<%
String temppage = Request.QueryString["page"];
int page = 0;
if (temppage == null || temppage.Trim() == "")
{
page = 1;
}
else {
page = Convert.ToInt32(temppage);
}
if (page < 1)
{
page = 1;
}
int hangnum = HangNum;
int pagecount = Pagecount;
int MaxPage = (int)Math.Ceiling((double)hangnum / pagecount);
if (page > MaxPage)
{
page = MaxPage;
}
System.Data.SqlClient.SqlConnection conn = Conn;
conn.Open();
SqlCommand command = conn.CreateCommand();
command.CommandText = "exec propro " + page + "," + pagecount;
SqlDataReader reader = command.ExecuteReader();
%>
<table><tr>
<%
int n = 0;
while (reader.Read())
{
n++;
if (n % 3 == 0)
{
%>
<td><table><tr><td><a href="#" onclick="love('<%=reader.GetInt32(0) %>','<%=reader.GetString(1) %>','<%=reader.GetDecimal(2) %>','<%=reader.GetInt32(3) %>')"><img src="<%=reader.GetString(reader.GetOrdinal("imgurl")) %>" width="80" height="80" border="0"/></a></td></tr><tr><td><%=reader.GetString(reader.GetOrdinal("name"))%></td></tr><tr><td><%="¥"+reader.GetDecimal(reader.GetOrdinal("price")) %></td></tr></table></td></tr><tr>
<%
}
else
{
%>
<td><table><tr><td><a href="#" onclick="love('<%=reader.GetInt32(0) %>','<%=reader.GetString(1) %>','<%=reader.GetDecimal(2) %>','<%=reader.GetInt32(3) %>')"><img src="<%=reader.GetString(reader.GetOrdinal("imgurl")) %>" width="80" height="80" border="0"/></a></td></tr><tr><td><%=reader.GetString(reader.GetOrdinal("name"))%></td></tr><tr><td><%="¥"+reader.GetDecimal(reader.GetOrdinal("price")) %></td></tr></table></td>
<%
}
}
reader.Close();
conn.Close();
%>
</table>
<table>
<tr>
<td><a href="Default.aspx?page=1">首页</a></td>
<%
if (page == 1)
{
%>
<td>上一页</td>
<%
}
else
{
%>
<td><a href="Default.aspx?page=<%=page-1 %>">上一页</a></td>
<%
}
if (page ==MaxPage)
{
%>
<td>下一页</td>
<%
}
else
{
%>
<td><a href="Default.aspx?page=<%=page+1 %>">下一页</a></td>
<%
}
%>
<td><a href="Default.aspx?page=<%=MaxPage %>">尾页</a></td>
</tr>
</table>
</div>
</form>
<input type="button" onclick="test()" />
</body>
</html> |
|