예제 #1
0
    protected void lbtnRemove_Click(object sender, EventArgs e)
    {
        //Guid buyer = new Guid(Session["buyerID"].ToString());
        string id     = ((LinkButton)sender).CommandArgument.ToString();
        long   cartID = new long();

        cartID = Convert.ToInt64(id);
        V_ShopCartTableAdapter cartInfo = new V_ShopCartTableAdapter();
        DataTable cartInfoDT            = cartInfo.GetCartInfoByCid(cartID);
        //long phoneid = new long();
        string phoneid = cartInfoDT.Rows[0][4].ToString();
        long   shopid  = new long();

        shopid = Convert.ToInt64(cartInfoDT.Rows[0][3].ToString());
        CollectionTableAdapter collectDA = new CollectionTableAdapter();
        DataTable collectDT = collectDA.GetCollectByPidUid(System.Guid.Parse(Session["buyerID"].ToString()), long.Parse(phoneid), "phone");

        if (collectDT.Rows.Count > 0)
        {
            Response.Write("<Script>alert('您已收藏过该商品!')</Script>");
        }
        else
        {
            collectDA.InsertCollectedPhone(System.Guid.Parse(Session["buyerID"].ToString()), long.Parse(phoneid), shopid, DateTime.Now, "phone");
        }
        ShopCartTableAdapter cartDA = new ShopCartTableAdapter();
        int Dcart = cartDA.DeleteShoppingCart(cartID);

        dlCartShop.DataBind();
    }
예제 #2
0
    protected void lbtnSub_Click(object sender, EventArgs e)
    {
        string id     = ((LinkButton)sender).CommandArgument.ToString();
        long   cartID = new long();

        cartID = Convert.ToInt64(id);
        V_ShopCartTableAdapter cartInfo = new V_ShopCartTableAdapter();

        DataTable cartInfoDT = cartInfo.GetCartInfoByCid(cartID);

        int quantity = int.Parse(cartInfoDT.Rows[0][6].ToString());
        int price    = int.Parse(cartInfoDT.Rows[0][9].ToString());
        int amount   = (quantity - 1) * price;
        ShopCartTableAdapter cartDA = new ShopCartTableAdapter();

        lblTotalNumber.Text = (int.Parse(lblTotalNumber.Text) - 1).ToString();
        int subQuantity = cartDA.UpdateCartPhoneQuantity(quantity - 1, amount, cartID);

        dlCartShop.DataBind();
    }
예제 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblSelected.Text = "0";
        if (Session["name"] != null)
        {
            string id = "";
            BuyerDSTableAdapters.aspnet_UsersTableAdapter userDA = new BuyerDSTableAdapters.aspnet_UsersTableAdapter();
            DataTable userdDT = userDA.GetDataByUName(Session["name"].ToString());
            if (userdDT.Rows.Count != 0)
            {
                id = userdDT.Rows[0][1].ToString();
                Session["buyerID"] = System.Guid.Parse(id);
                V_ShopCartTableAdapter shop     = new V_ShopCartTableAdapter();
                ShopCartTableAdapter   shopcart = new ShopCartTableAdapter();
                DataTable shopDT = shop.GetShopCartInfoByBuyer(System.Guid.Parse(Session["buyerID"].ToString()));
                if (shopDT.Rows.Count > 0)
                {
                    for (int i = 0; i < shopDT.Rows.Count; i++)
                    {
                        if (int.Parse(shopDT.Rows[i]["store_quantity"].ToString()) == 0)
                        {
                            shopcart.DeleteShoppingCart(long.Parse(shopDT.Rows[0][0].ToString()));
                        }
                        else
                        {
                            if (int.Parse(shopDT.Rows[i]["buy_quantity"].ToString()) > int.Parse(shopDT.Rows[i]["store_quantity"].ToString()))
                            {
                                shopcart.UpdateCartPhoneQuantity(int.Parse(shopDT.Rows[i]["store_quantity"].ToString()), int.Parse(shopDT.Rows[i]["price"].ToString()) * int.Parse(shopDT.Rows[i]["store_quantity"].ToString()), long.Parse(shopDT.Rows[0][0].ToString()));
                            }
                        }
                    }
                }
            }

            int number = 0;
            if (dlCartShop.Items.Count > 0)
            {
                for (int i = 0; i < dlCartShop.Items.Count; i++)
                {
                    DataList dlCartPhone = dlCartShop.Items[i].FindControl("dlCartPhone") as DataList;

                    for (int j = 0; j < dlCartPhone.Items.Count; j++)
                    {
                        TextBox txtQuantity = dlCartPhone.Items[j].FindControl("txtQuantity") as TextBox;
                        number += int.Parse(txtQuantity.Text);
                    }
                }
                lblMsg.Visible         = false;
                lblMsg.Enabled         = false;
                lbtnGo.Enabled         = false;
                lbtnGo.Visible         = false;
                Panel2.Visible         = true;
                Panel1.Visible         = true;
                Panel3.Visible         = true;
                lblTotalNumber.Text    = number.ToString();
                lbtnSettlement.Enabled = false;
            }
            else
            {
                lblTotalNumber.Text    = "0";
                lblMsg.Visible         = true;
                lbtnGo.Enabled         = true;
                lbtnGo.Visible         = true;
                Panel1.Visible         = false;
                lbtnSettlement.Enabled = false;
                Panel2.Visible         = false;
                Panel3.Visible         = false;
            }
        }
        else
        {
            Response.Redirect("~/Public/Index.aspx");
        }
    }
예제 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblSelected.Text = "0";
        if (Session["name"] != null)
        {
            string id = "";
         BuyerDSTableAdapters.aspnet_UsersTableAdapter userDA = new BuyerDSTableAdapters.aspnet_UsersTableAdapter();
        DataTable userdDT = userDA.GetDataByUName(Session["name"].ToString());
        if (userdDT.Rows.Count != 0)
        {
            id = userdDT.Rows[0][1].ToString();
            Session["buyerID"] = System.Guid.Parse(id);
            V_ShopCartTableAdapter shop = new V_ShopCartTableAdapter();
            ShopCartTableAdapter shopcart = new ShopCartTableAdapter();
            DataTable shopDT = shop.GetShopCartInfoByBuyer(System.Guid.Parse(Session["buyerID"].ToString()));
            if (shopDT.Rows.Count > 0)
            {
                for (int i = 0; i < shopDT.Rows.Count; i++)
                {
                    if (int.Parse(shopDT.Rows[i]["store_quantity"].ToString()) == 0)
                    {
                        shopcart.DeleteShoppingCart(long.Parse(shopDT.Rows[0][0].ToString()));
                    }
                    else
                    {

                        if (int.Parse(shopDT.Rows[i]["buy_quantity"].ToString()) > int.Parse(shopDT.Rows[i]["store_quantity"].ToString()))
                        {
                            shopcart.UpdateCartPhoneQuantity(int.Parse(shopDT.Rows[i]["store_quantity"].ToString()), int.Parse(shopDT.Rows[i]["price"].ToString()) * int.Parse(shopDT.Rows[i]["store_quantity"].ToString()), long.Parse(shopDT.Rows[0][0].ToString()));
                        }
                    }
                }
            }
        }

        int number = 0;
        if (dlCartShop.Items.Count > 0)
        {
            for (int i = 0; i < dlCartShop.Items.Count; i++)
            {

                DataList dlCartPhone = dlCartShop.Items[i].FindControl("dlCartPhone") as DataList;

                for (int j = 0; j < dlCartPhone.Items.Count; j++)
                {

                    TextBox txtQuantity = dlCartPhone.Items[j].FindControl("txtQuantity") as TextBox;
                    number += int.Parse(txtQuantity.Text);

                }
            }
            lblMsg.Visible = false;
            lblMsg.Enabled = false;
            lbtnGo.Enabled = false;
            lbtnGo.Visible = false;
            Panel2.Visible = true;
            Panel1.Visible = true;
            Panel3.Visible = true;
            lblTotalNumber.Text = number.ToString();
            lbtnSettlement.Enabled = false;
        }
        else
        {
            lblTotalNumber.Text = "0";
            lblMsg.Visible = true;
            lbtnGo.Enabled = true;
            lbtnGo.Visible = true;
            Panel1.Visible = false;
            lbtnSettlement.Enabled = false;
            Panel2.Visible = false;
            Panel3.Visible = false;
        }
        }
        else
        {
            Response.Redirect("~/Public/Index.aspx");
        }
    }
예제 #5
0
    protected void lbtnSub_Click(object sender, EventArgs e)
    {
        string id = ((LinkButton)sender).CommandArgument.ToString();
        long cartID = new long();
        cartID = Convert.ToInt64(id);
        V_ShopCartTableAdapter cartInfo = new V_ShopCartTableAdapter();

        DataTable cartInfoDT = cartInfo.GetCartInfoByCid(cartID);

        int quantity = int.Parse(cartInfoDT.Rows[0][6].ToString());
        int price = int.Parse(cartInfoDT.Rows[0][9].ToString());
        int amount = (quantity -1) * price;
        ShopCartTableAdapter cartDA = new ShopCartTableAdapter();
        lblTotalNumber.Text = (int.Parse(lblTotalNumber.Text) - 1).ToString();
        int subQuantity = cartDA.UpdateCartPhoneQuantity(quantity - 1, amount, cartID);
        dlCartShop.DataBind();
    }
예제 #6
0
    protected void lbtnRemove_Click(object sender, EventArgs e)
    {
        //Guid buyer = new Guid(Session["buyerID"].ToString());
        string id = ((LinkButton)sender).CommandArgument.ToString();
        long cartID = new long();
        cartID = Convert.ToInt64(id);
        V_ShopCartTableAdapter cartInfo = new V_ShopCartTableAdapter();
        DataTable cartInfoDT = cartInfo.GetCartInfoByCid(cartID);
        //long phoneid = new long();
           string  phoneid =cartInfoDT.Rows[0][4].ToString();
        long shopid = new long();
        shopid = Convert.ToInt64(cartInfoDT.Rows[0][3].ToString());
        CollectionTableAdapter collectDA = new CollectionTableAdapter();
        DataTable collectDT = collectDA.GetCollectByPidUid(System.Guid.Parse(Session["buyerID"].ToString()), long.Parse(phoneid), "phone");
        if (collectDT.Rows.Count > 0)
        {
            Response.Write("<Script>alert('您已收藏过该商品!')</Script>");
        }
        else
        {
           collectDA.InsertCollectedPhone(System.Guid.Parse(Session["buyerID"].ToString()), long.Parse(phoneid), shopid, DateTime.Now, "phone");

        }
        ShopCartTableAdapter cartDA = new ShopCartTableAdapter();
        int Dcart = cartDA.DeleteShoppingCart(cartID);
        dlCartShop.DataBind();
    }