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(); }
protected void ibtnCollect_Click(object sender, ImageClickEventArgs e) { if (Session["name"] != null) { string phoneid = Request.QueryString["PhoneId"].ToString(); BuyerDSTableAdapters.aspnet_UsersTableAdapter userDA = new BuyerDSTableAdapters.aspnet_UsersTableAdapter(); DataTable userdDT = userDA.GetDataByUName(Session["name"].ToString()); CollectionTableAdapter collect = new CollectionTableAdapter(); string buyer = ""; if (userdDT.Rows.Count > 0) { buyer = userdDT.Rows[0][1].ToString(); DataTable collectDT = collect.GetDataByUidPid(System.Guid.Parse(buyer), long.Parse(phoneid)); if (collectDT.Rows.Count > 0) { Response.Write("<Script>alert('您已收藏过此商品!')</Script>"); } else { string ConnSql = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString(); SqlConnection Conn = new SqlConnection(ConnSql); Conn.Open(); string SelectSql = "SELECT * FROM V_PhoneDetailInfo WHERE phone_id =" + long.Parse(phoneid) + ""; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = new SqlCommand(SelectSql, Conn); DataSet ds = new DataSet(); da.Fill(ds); string shopid = ""; if (ds.Tables[0].Rows.Count > 0) { shopid = ds.Tables[0].Rows[0]["shopId"].ToString().Trim(); } int DT = collect.AddCollect(System.Guid.Parse(buyer), long.Parse(phoneid), long.Parse(shopid), DateTime.Now, "phone"); if (DT > 0) { Response.Write("<Script>alert('收藏成功!')</Script>"); } } } } else { Response.Write("<Script>alert('登陆后才能收藏!')</Script>"); } }
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(); }
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(); }
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(); }