• 大小: 320KB
    文件类型: .rar
    金币: 2
    下载: 3 次
    发布日期: 2021-06-12
  • 语言: C#
  • 标签:

资源简介

基于Session实现ASP.NET购物车源码,数据库为SqlServer2005,含数据库备份

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Security.Cryptography;

public partial class Cart : System.Web.UI.Page
{
    Int32 Total = 0;
    protected void Page_Load(object sender EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BindCartList();
        }
    }

    private void BindCartList()
    {
        DataTable dt = new DataTable();

        #region
        if (Session[“Cart“] != null)
        {
            dt = (DataTable)Session[“Cart“];
        }
        else
        {
            DataColumn dc = new DataColumn(“ID“ typeof(Int32));
            dt.Columns.Add(dc);
            dc = new DataColumn(“ProductNo“ typeof(String));
            dt.Columns.Add(dc);
            dc = new DataColumn(“ProductName“ typeof(String));
            dt.Columns.Add(dc);
            dc = new DataColumn(“BuyPrice“ typeof(Int32));
            dt.Columns.Add(dc);
            dt.Columns.Add(new DataColumn(“Amount“ typeof(Int32)));
        }
        #endregion

        if (ID != null)
        {
            #region 
            Int32 rows = dt.Select(“ID=“ + ID.ToString()).Length;

            if (rows == 0)
            {
                DAL.SqlHelper helper = new DAL.SqlHelper();
                DataTable dtRow = helper.FillDataTable(
                    “select * from Products where id=“ + ID.ToString());
                dt.Rows.Add(new object[]{
            ID
            dtRow.Rows[0][“ProductNo“].ToString()
            dtRow.Rows[0][“ProductName“].ToString()
            Int32.Parse(dtRow.Rows[0][“BuyPrice“].ToString())
            1
            });
            }
            else
            {
                //scriptManager.RegisterStartupscript
                Response.Write(“ript>alert(‘该商品在购物车中已经存在!‘)ript>“);

            }
            #endregion
        }
        gvCart.DataSource = dt;
        gvCart.DataBind();

        Session[“Cart“] = dt;
    }

    private Nullable ID
    {
        get
        {
            try
            {
                return Int32.Parse(Request.QueryString[“ID“]);
            }
            catch
            {
                return null;
            }
        }
    }
    protected void gvCart_RowDataBound(object sender GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView drv = 
                (DataRowView)e.Row.DataItem;
            Total += Int32.Parse(drv[“BuyPrice“].ToString())*
                Int32.Parse(drv[“Amount“].ToString());

            TextBox tb =
               (TextBox)e.Row.FindControl(“txtAmount“);
            HtmlImage imgReduce =
               (HtmlImage) e.Row.FindControl(“imgReduce“);
            HtmlImage imgPlus =
               (H

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5120  2010-08-02 09:11  Buy\Bin\DAO.dll

     文件         64  2010-08-02 09:10  Buy\Bin\DAO.dll.refresh

     文件      13824  2010-08-02 09:11  Buy\Bin\DAO.pdb

     文件       3190  2010-07-20 18:20  Buy\Cart.aspx

     文件       4417  2010-07-20 18:19  Buy\Cart.aspx.cs

     文件        194  2010-07-20 13:53  Buy\CSS\buy.css

     文件    3414528  2010-09-30 18:00  Buy\Database\Buy_SqlServer2005.bak

     文件       4590  2010-07-18 22:22  Buy\Images\addtocart.png

     文件      23459  2010-07-19 00:13  Buy\Images\back.jpg

     文件         86  2010-07-18 21:18  Buy\Images\bag_close.gif

     文件         90  2010-07-18 21:18  Buy\Images\bag_open.gif

     文件      20441  2010-07-18 22:17  Buy\Images\cart.jpg

     文件       2748  2010-07-18 21:17  Buy\Images\cart_001.gif

     文件       2427  2010-07-18 22:19  Buy\Images\go_on.gif

     文件       5313  2010-07-18 22:20  Buy\Images\icon_24.png

     文件      19802  2010-07-18 22:17  Buy\Images\imagesCAKYFIFT.jpg

     文件       1979  2010-07-18 22:20  Buy\Images\pay.gif

     文件       8789  2010-07-18 21:45  Buy\Images\Products\05a6958e-799d-43f8-9eeb-439e2eaabd22.jpg

     文件       8729  2010-07-18 21:45  Buy\Images\Products\0e7b87b1-9195-4e9b-9c97-21826226de6c.jpg

     文件       6928  2010-07-18 21:16  Buy\Images\Products\1e29e446-09de-4e1f-b42a-1aeab6521050.jpg

     文件       7159  2010-07-18 21:45  Buy\Images\Products\211035a2-a994-4789-b478-d0c587c36491.jpg

     文件       8478  2010-07-18 21:45  Buy\Images\Products\267bbfcb-af1e-4270-b356-1efc23a3d496.jpg

     文件       6492  2010-07-18 21:16  Buy\Images\Products\56b25800-bbfe-4893-bbfd-1fb4a6791b90.jpg

     文件       6492  2010-07-18 21:45  Buy\Images\Products\5b6fa10b-846f-4523-abfc-a23a1d4f77cc.jpg

     文件       8023  2010-07-18 21:45  Buy\Images\Products\62fc28fa-cbdb-43c2-a7c3-7e74b0dd9936.jpg

     文件       7821  2010-07-18 21:45  Buy\Images\Products\65f60917-28c9-438f-a32f-c5b9c5ca6352.jpg

     文件       6985  2010-07-18 21:45  Buy\Images\Products\689a53da-77ef-48bf-9a40-54b282297919.jpg

     文件       7584  2010-07-18 21:45  Buy\Images\Products\81e6813c-ccee-434b-b885-de04441ed18a.jpg

     文件       8448  2010-07-18 21:45  Buy\Images\Products\a533a7bc-95f6-4c9f-ae05-a016eee7a06c.jpg

     文件       9332  2010-07-18 21:16  Buy\Images\Products\b7a2079f-c09d-43d7-a894-d1942d5f485a.jpg

............此处省略22个文件信息

评论

共有 条评论