示例#1
0
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            Member    member    = (Member)Session["Member"];
            CartTable cartTable = new CartTable();
            DataTable dt        = cartTable.GetCart(member);
            Sale      sale      = new Sale();

            sale.SaleDate = DateTime.Now;
            sale.MemberId = member.MemberId;
            SaleDetail[] details = new SaleDetail[dt.Rows.Count];
            for (int i = 0; i < details.Length; i++)
            {
                details[i]           = new SaleDetail();
                details[i].GoodsCode = dt.Rows[i]["GoodsCode"].ToString();
                details[i].Num       = (int)dt.Rows[i]["Num"];
            }
            sale.Detail = details;

            SaleTable st  = new SaleTable();
            int       cnt = st.Insert(sale);

            if (cnt != 0)
            {
                cartTable.Delete(member);
            }
            Server.Transfer("endmessage.aspx");
        }
示例#2
0
        protected void dlItems_ItemCommand(object source, DataListCommandEventArgs e)
        {
            Member member = (Member)Session["Member"];

            Cart cart = new Cart();

            cart.MemberId  = member.MemberId;
            cart.GoodsCode = e.CommandArgument.ToString();
            CartTable ct = new CartTable();

            if (e.CommandName == "UpdateCart")
            {
                TextBox textBox = (TextBox)(e.Item.FindControl("txtNum"));
                cart.Num = int.Parse(textBox.Text);

                ct.Updata(cart);
            }
            else if (e.CommandName == "DeleteCart")
            {
                ct.Delete(cart);
            }
            PageDisplay();
        }