当前位置:编程学习 > C#/ASP.NET >>

购物网站的购物车模块问题——确认后如果把订单在另外页显示

先感谢各位前辈帮忙,本人近日正在制作一个订餐网站,在购物车模块中的遇到了一些棘手的问题,望大家帮忙~
这个购物车模块是我在网上找的,修改一些数据库连接后为我所用,界面如下:

这是一个拖动式的购物车,把商品图片拖入黄色区域时就会自动把商品名加入其中,并计算总价进行显示。
右上角的“确认订单”按钮是我自己添加的,还没进行编辑,我的想法是购物车购物完毕时点击此按钮可跳转下一页面,
页面中可对已选购的商品和总价进行列表显示,可我现在不知道如何从本页面获取信息放到下页进行显示,我把本页已有的程序放到下面,希望可以得到大家的指教,最好能把我上面的想法根据我已有的购物车程序写出程序,十分感谢~~

购物车.aspx:
age Language="C#" AutoEventWireup="true" CodeFile="Shopping Cart.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>订餐购物车</title>
    <link href="Site.css" rel="stylesheet" type="text/css" />
    
     
</head>
<body id="documentBody">
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
        
       <div  id="dZone" style="position:absolute;top:28px; left:633px; width:284px; overflow:auto; height:535px" class="DefaultDropZoneColor">
    购物费用        
    
    总共: $                    
           <asp:Button ID="Button1" runat="server" Height="27px" Text="确认订单" Width="79px" /><div class="totalBox" id="divTotal">0.00</div>      
    </div>            
                               
               <asp:DataList  Height="100%" Width="80%" ID="DLdishes" runat="server" RepeatColumns="3" CellPadding="20" CellSpacing="20"><ItemTemplate>
                         
               <div ID="a" runat = "server" class="dragElement">
               <asp:Label ID="lblTitle" runat="server" Text='<%# Eval("dName") %>'  />
               <asp:Label ID="lblPrice" runat="server" Text = '<%# Eval("dPrice") %>' />
               <asp:Image ID="imgPicture" runat="server" ImageUrl='<%# Eval("dImageUrl") %>' />
               
               </div>          
                                              
               </ItemTemplate>
               </asp:DataList>
                
                               
         </div>                 
        
    </form>

</body>
</html>

<script language="javascript" type="text/javascript">

var mouseState = 'up';
var clone = null; 
var totalPurchase = 0.0; 
var dropZoneArray = new Array(1); 
dropZoneArray[0] = "dZone";
var titlePattern = ".+_lblTitle$"
var pricePattern = ".+_lblPrice$"
var dragElementPattern = ".+_a$";

var uniqueNumber = 1; 

function ResetColor() 
{
    document.getElementById("dZone").className = 'DefaultDropZoneColor';   
}

function IsInDropZone(evtTarget) 
{     
    var result = false;  
   
    // 查询数组,找到它存在的ID 
    for(i = 0; i < dropZoneArray.length; i++) 
    {
        if(evtTarget.id == dropZoneArray[i]) 
        {
            result = true; 
            break; 
        }
    } 
    
    return result;
}

function MakeElementDraggable(obj) 
{    
    var startX = 0; 
    var startY = 0; 
        
function InitiateDrag(e) 
{    
    mouseState = 'down';
    
    var evt = e || window.event;
    
    startX = parseInt(evt.clientX); 
    startY = parseInt(evt.clientY);    
    
    clone = obj.cloneNode(true);
           
    clone.style.position = 'absolute';   
    clone.style.top = parseInt(startY) + 'px';
    clone.style.left = parseInt(startX) + 'px';  
    
    document.body.appendChild(clone);     
    
    document.onmousemove = Drag;
    document.onmouseup = Drop;  
    
    return false;             
}

function Drop(e) 
{
       var evt = e || window.event;
       var evtTarget = evt.target || evt.srcElement;                          
            
       var dZone = document.getElementById("dZone"); 
        
        if( evt.clientX > dZone.offsetLeft && evt.clientX < (dZone.offsetLeft + dZone.offsetWidth) 
            && evt.clientY > dZone.offsetTop && evt.clientY < (dZone.offsetTop + dZone.offsetHeight))
            {               
                AddPrice(); 
            }    
              
        document.onmouseup = null; 
        document.onmousemove = null;               
       
        document.body.removeChild(clone); 
        mouseState = 'up';
        ResetColor();   
       
}

function AddPrice() 
{   
          
   var title = GetProductTitle();
   var price = GetProductPrice(); 
   
       
    var dZone = document.getElementById("dZone"); 
    var textNode = document.createTextNode(title);    
    var priceNode = document.createTextNode(price); 
        
    var spaceNode = document.createTextNode(':  $');   
    var paragraphElement = document.createElement('p');
    
    // 设置删除按钮 
    
    var deleteButton = document.createElement('button');
    deleteButton.value = 'Delete';
    deleteButton.innerHTML = '删除';
    deleteButton.onclick = DeleteItem;
    
    var item = document.createElement('div'); 
    item.id = 'itemDiv' + uniqueNumber; 
      
    item.appendChild(paragraphElement);     
    item.appendChild(textNode); 
    item.appendChild(spaceNode); 
    item.appendChild(priceNode); 
    item.appendChild(spaceNode); 
    item.appendChild(deleteButton);
    
    dZone.appendChild(item);  
    
    // 总价计算
    IncrementTotal(price);
    uniqueNumber++; 
    
}

function DeleteItem(e) 
{    
    var evt = e || window.event;
    var evtTarget = evt.target || evt.srcElement;
    
    if(IsFireFox()) 
    {
        price = evtTarget.parentNode.childNodes[2].nodeValue; 
        evtTarget.parentNode.parentNode.removeChild(evtTarget.parentNode); 
    }    
    else
    {      
    price = evtTarget.parentElement.childNodes[2].nodeValue;
    evtTarget.parentElement.parentElement.removeChild(evtTarget.parentElement); 
    } 
       
    DecrementTotal(price); 
}

function DecrementTotal(price) 
{
    totalPurchase -= Math.ceil(Number(price)); 
    document.getElementById("divTotal").innerHTML = totalPurchase; 
}

function IncrementTotal(price) 
{      
    totalPurchase += Math.ceil(Number(price)); 
    document.getElementById("divTotal").innerHTML = totalPurchase; 
}



function GetProductPrice() 
{
    var price = '';  
    
    if(IsFireFox()) {        
    price = (clone.childNodes[3].innerHTML);          
    }
    else price = (clone.childNodes[2].innerHTML); 
   
   
    return price;    
}

function GetProductTitle() 
{
   
    var title = '';   
    
    if(IsFireFox()) 
    {
    title = clone.childNodes[1].innerHTML; 
    
    }
    
    else { title = clone.childNodes[0].innerHTML;  }    
    
   return title; 
}

function IsFireFox() 
{
    if(navigator.appName == 'Netscape') 
     return true; 
     else return false; 
}


function Drag(e) 
{
   
    if(mouseState == 'down') {
      
    // 只有当鼠标拖动向下 
    var evt = e || window.event;
    
    var evtTarget = evt.target || evt.srcElement;    
    
    clone.style.top = evt.clientY + 'px'; 
    clone.style.left = evt.clientX + 'px';
    
     // 检查如果在drop Zone中 
    if(IsInDropZone(evtTarget)) 
    {   
       
        evtTarget.className = 'highlightDropZone';       
    }
    
    else 
    {  
        ResetColor();          
    }
    
    } 
    
}

obj.onmousedown = InitiateDrag;

}

function IsMatch(id, pattern) 
{
    var regularExpresssion = new RegExp(pattern);
    if(id.match(regularExpresssion)) return true;
    else return false;
}

var divElements = document.getElementsByTagName("div");      

for(i=0;i<divElements.length;i++) 
{   
    
    if(IsMatch(divElements[i].id, dragElementPattern)) 
    {            
        MakeElementDraggable(divElements[i]);  
    }
}


</script>


----------------------------------华丽的分割线-------------------------------------------

购物车.asp.cs:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection myConnection = new SqlConnection(connectionString);

        SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM dishes", myConnection);
        DataSet ds = new DataSet();
        ad.Fill(ds);

        DLdishes.DataSource = ds;
        DLdishes.DataBind(); //DLdishes为DataList控件
    }
} --------------------编程问答-------------------- 确认后一般都会将结果存在数据库中,根据订单号检索后在另外一页显示即可 --------------------编程问答-------------------- 你的订单存在哪?就从哪里取出来显示即可 --------------------编程问答--------------------
引用 1 楼 anyqu 的回复:
确认后一般都会将结果存在数据库中,根据订单号检索后在另外一页显示即可

问题是由于程序不是我写的,我不知道如何获取菜单信息存入数据库中,它显示商品名和总价的控件好像不是Laber,请帮我看看程序从哪里(具体哪个控件,控件的ID)获取我需要的信息,谢谢 --------------------编程问答--------------------
引用 2 楼 dopsop110 的回复:
你的订单存在哪?就从哪里取出来显示即可

这个程序应该是还没有存,好像购物车只是在cookie里临时保存,我现在就是想如何获取信息存在我的数据库中 --------------------编程问答-------------------- 参考
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,