예제 #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 lbtnAllRemove_Click(object sender, EventArgs e)
    {
        Guid buyer   = new Guid(Session["buyerID"].ToString());
        int  Numcart = 0;
        int  select  = 0;
        long cartID  = new long();
        long phoneid = new long();
        long shopid  = new long();
        ShopCartTableAdapter   cartDA    = new ShopCartTableAdapter();
        CollectionTableAdapter collectDA = new CollectionTableAdapter();
        int addcollect = 0;

        for (int i = 0; i < dlCartShop.Items.Count; i++)
        {
            DataList dlCartPhone = dlCartShop.Items[i].FindControl("dlCartPhone") as DataList;
            Label    lblShopID   = dlCartShop.Items[i].FindControl("lblShopId") as Label;
            shopid = Convert.ToInt64(lblShopID.Text);
            for (int j = 0; j < dlCartPhone.Items.Count; j++)
            {
                CheckBox chbSelectPhone = dlCartPhone.Items[j].FindControl("chbSelectPhone") as CheckBox;
                Label    lblCartID      = dlCartPhone.Items[j].FindControl("lblCartId") as Label;
                Label    lblPhoneID     = dlCartPhone.Items[j].FindControl("lblPhoneId") as Label;
                if (chbSelectPhone.Checked)
                {
                    select++;
                    cartID  = Convert.ToInt64(lblCartID.Text);
                    phoneid = Convert.ToInt64(lblPhoneID.Text);
                    DataTable collectDT = collectDA.GetCollectByPidUid(System.Guid.Parse(Session["buyerID"].ToString()), long.Parse(lblPhoneID.Text), "phone");

                    if (collectDT.Rows.Count > 0)
                    {
                        addcollect++;
                    }
                    else
                    {
                        addcollect += collectDA.InsertCollectedPhone(buyer, phoneid, shopid, DateTime.Now, "phone");
                    }
                    Numcart += cartDA.DeleteShoppingCart(cartID);
                }
            }
        }
        if (select == 0)
        {
            Response.Write("<Script>alert('请选择物品!')</Script>");
            // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true);
        }
        else
        {
            if (Numcart == select && addcollect == select)
            {
                Response.Write("<Script>alert('已成功收藏!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true);
            }
            else
            {
                Response.Write("<Script>alert('未成功收藏')</Script>");
                // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('!');", true);
            }
        }
        dlCartShop.DataBind();
    }
예제 #3
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();
    }
예제 #4
0
    protected void lbtnAllRemove_Click(object sender, EventArgs e)
    {
        Guid buyer = new Guid(Session["buyerID"].ToString());
        int Numcart = 0;
        int select = 0;
        long cartID = new long();
        long phoneid = new long();
        long shopid = new long();
        ShopCartTableAdapter cartDA = new ShopCartTableAdapter();
        CollectionTableAdapter collectDA = new CollectionTableAdapter();
        int addcollect=0 ;
        for (int i = 0; i < dlCartShop.Items.Count; i++)
        {
            DataList dlCartPhone = dlCartShop.Items[i].FindControl("dlCartPhone") as DataList;
            Label lblShopID = dlCartShop.Items[i].FindControl("lblShopId") as Label;
            shopid = Convert.ToInt64(lblShopID.Text);
            for (int j = 0; j < dlCartPhone.Items.Count; j++)
            {
                CheckBox chbSelectPhone = dlCartPhone.Items[j].FindControl("chbSelectPhone") as CheckBox;
                Label lblCartID = dlCartPhone.Items[j].FindControl("lblCartId") as Label;
                Label lblPhoneID = dlCartPhone.Items[j].FindControl("lblPhoneId") as Label;
                if (chbSelectPhone.Checked)
                {
                    select++;
                    cartID = Convert.ToInt64(lblCartID.Text);
                    phoneid = Convert.ToInt64(lblPhoneID.Text);
                    DataTable collectDT = collectDA.GetCollectByPidUid(System.Guid.Parse(Session["buyerID"].ToString()), long.Parse(lblPhoneID.Text),"phone");

                    if (collectDT.Rows.Count > 0)
                    {
                        addcollect++;
                    }
                    else
                    {
                        addcollect += collectDA.InsertCollectedPhone(buyer, phoneid, shopid, DateTime.Now, "phone");
                    }
                    Numcart += cartDA.DeleteShoppingCart(cartID);
                }
            }
        }
        if (select == 0)
        {
            Response.Write("<Script>alert('请选择物品!')</Script>");
           // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true);
        }
        else
        {
            if (Numcart == select && addcollect==select)
            {
                Response.Write("<Script>alert('已成功收藏!')</Script>");
                //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true);
            }
            else
            {
                Response.Write("<Script>alert('未成功收藏')</Script>");
               // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('!');", true);
            }
        }
        dlCartShop.DataBind();
    }