 <%@ WebHandler Language="C#" Class="ListCart" %>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 Model;
using BLL;

public class ListCart : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        int uid = 0;
        try
        {
            if (context.Request.Cookies["UserId"].Value != null)
            {
                uid = Convert.ToInt32(context.Request.Cookies["UserId"].Value);
            }
        }
        catch (Exception exc)
        {

        }
        DataSet ds = new DataSet();
        BLLCart bll = new BLLCart();
        ds = bll.detail(uid);
        string str = "";
        if (uid != 0)
        {
            str += "<table cellpadding='0' cellspacing='0'>";
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                str += "<tr>";
                str += "<td colspan='6' class='c_tdt' valign='bottom'>";
                str += "店铺：<a href='"+ IsCnzz.getDns2(ds.Tables[0].Rows[i]["id"].ToString(), ds.Tables[0].Rows[i]["syuming"].ToString()) + "'>" + ds.Tables[0].Rows[i]["sname"] + "</a>&nbsp;&nbsp;&nbsp;卖家：<a href='user/?uid=" + ds.Tables[0].Rows[i]["suid"] + "'>" + ds.Tables[0].Rows[i]["uname"] + "</a>";
                str += "</td>";
                str += "</tr>";
                for (int j = 0; j < ds.Tables[1].Rows.Count; j++)
                {
                    if (ds.Tables[0].Rows[i]["id"].ToString() == ds.Tables[1].Rows[j]["cshop_id"].ToString())
                    {
                        str += "<tr class='trc'>";
                        str += "<td class='c_td1_l' align='center' valign='middle'>";
                        str += "<input name='checkboxc' type='checkbox' value=" + ds.Tables[1].Rows[j]["id"] + " checked />";
                        str += "<input id='hid_" + ds.Tables[1].Rows[j]["id"] + "' type='hidden' value=" + ds.Tables[1].Rows[j]["cod"] + " />";
                        str += "</td>";
                        str += "<td class='c_td2_l'>";
                        str += "<div style='float: left;'>";
                        str += "<a href='Detail.aspx?cid=" + ds.Tables[1].Rows[j]["cid"] + "'>";
                        str += "<img src='Upload/commodity/" + ds.Tables[1].Rows[j]["cmin_img"] + "' width='50px' style='border:0' /></a></div>";
                        str += "<div style='margin-left: 10px; float: left;'>";
                        str += "<a href='Detail.aspx?cid=" + ds.Tables[1].Rows[j]["cid"] + "'>";
                        str += ds.Tables[1].Rows[j]["cname"];
                        str += "</a>";
                        str += "</div>";
                        str += "</td>";
                        str += "<td class='c_td3_l' align='center'>";
                        str += ds.Tables[1].Rows[j]["cprice"];
                        str += "</td>";
                        str += "<td class='c_td4_l' align='center'>";
                        str += "<input type='text' class='txt_num' id='txt" + ds.Tables[1].Rows[j]["id"] + "'  value='" + ds.Tables[1].Rows[j]["cnum"] + "' onfocus='this.select();' />";
                        str += "<input type='button' value='确定' onclick='update(\"" + ds.Tables[1].Rows[j]["id"] + "\",document.getElementById(\"txt" + ds.Tables[1].Rows[j]["id"] + "\").value,\"" + ds.Tables[1].Rows[j]["num"] + "\")' />";
                        str += "<br /><div id='msg" + ds.Tables[1].Rows[j]["id"] + "' style='display:none;'></div></td>";
                        str += "<td class='c_td5_l' align='center'>";
                        str += ds.Tables[1].Rows[j]["sumprice"];
                        str += "</td>";
                        str += "<td class='c_td6_l' align='center'>";
                        str += "<a href='#' onclick='del_id("+ ds.Tables[1].Rows[j]["id"] +")'>删除</a></td>";
                        str += "</tr>       ";
                    }
                }
            }
            str += "</table>";
            str += "<div class='bottom_div'><div class='bottom_divl'>";
            str += "<input type='button' id='btn' value='删除' onclick='del_sumid()' /></div>";
            str += "<div class='bottom_divr'>";
            str += "商品总价(不含运费)：<span class='sp_zj'>" + ds.Tables[2].Rows[0][0] + "</span>元";
            str += "</div></div>";
        }
        
        context.Response.Write(str);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}