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 lbtnAllDelete_Click(object sender, EventArgs e) { Guid buyer = new Guid(Session["buyerID"].ToString()); int Numcart = 0; int select = 0; long cartID = new long(); ShopCartTableAdapter cartDA = new ShopCartTableAdapter(); if (chbAllSelect.Checked) { int allcart = cartDA.DeleteAll(buyer); if (allcart == 1) { Response.Write("<Script>alert('已成功从购物车删除!')</Script>"); // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true); } else { Response.Write("<Script>alert('未成功从购物车删除!!')</Script>"); //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true); } } else { 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++) { CheckBox chbSelectPhone = dlCartPhone.Items[j].FindControl("chbSelectPhone") as CheckBox; Label lblCartID = dlCartPhone.Items[j].FindControl("lblCartId") as Label; if (chbSelectPhone.Checked) { select++; cartID = Convert.ToInt64(lblCartID.Text); Numcart += cartDA.DeleteShoppingCart(cartID); } } } if (select == 0) { Response.Write("<Script>alert('请选择物品!')</Script>"); // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true); } else { if (Numcart == 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 lbtnSettlement_Click(object sender, EventArgs e) { ShopCartTableAdapter cartDA = new ShopCartTableAdapter(); int Numcart = 0; int select = 0; long cartID = new long(); 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++) { CheckBox chbSelectPhone = dlCartPhone.Items[j].FindControl("chbSelectPhone") as CheckBox; Label lblCartID = dlCartPhone.Items[j].FindControl("lblCartId") as Label; if (chbSelectPhone.Checked) { select++; cartID = Convert.ToInt64(lblCartID.Text); Numcart += cartDA.UpdateCartState("是", cartID); } } } if (Numcart == select) { Response.Redirect("~/Buyer/SubmitOrder.aspx"); } }
protected void lbtnInChart1_Click(object sender, EventArgs e) { string phoneid = ((LinkButton)sender).CommandArgument.ToString(); if (Session["name"] != null) { BuyerDSTableAdapters.aspnet_UsersTableAdapter userDA = new BuyerDSTableAdapters.aspnet_UsersTableAdapter(); DataTable userdDT = userDA.GetDataByUName(Session["name"].ToString()); ShopCartTableAdapter shopcartDA = new ShopCartTableAdapter(); if (userdDT.Rows.Count > 0) { DataTable shopcartDT = shopcartDA.GetDataBySCidPid(System.Guid.Parse(userdDT.Rows[0][1].ToString()), long.Parse(phoneid)); if (shopcartDT.Rows.Count > 0) { Response.Redirect("~/Buyer/ShoppingCart.aspx"); } 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 seller = ""; if (ds.Tables[0].Rows.Count > 0) { seller = ds.Tables[0].Rows[0]["sellerId"].ToString().Trim(); int DT = shopcartDA.AddShoppingCart(System.Guid.Parse(userdDT.Rows[0][1].ToString()), System.Guid.Parse(seller), long.Parse(phoneid), 1, int.Parse(ds.Tables[0].Rows[0]["price"].ToString().Trim()), DateTime.Now, "否"); if (DT > 0) { Response.Redirect("~/Buyer/ShoppingCart.aspx"); } else { Response.Write("<Script>alert('未能成功加入购物车!')</Script>"); } } } } else { Response.Write("<Script>alert('未能成功加入购物车!')</Script>"); } } else { Session["lasturl"] = Server.UrlDecode(Request.Url.AbsoluteUri.ToString()); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>openDiv('newDiv');</script>"); //Response.Write("<Script>alert('登录后才能加入购物车!')</Script>"); } }
protected void lbtnInChart2_Click(object sender, EventArgs e) { string phoneid = ((LinkButton)sender).CommandArgument.ToString(); if (Session["name"] != null) { BuyerDSTableAdapters.aspnet_UsersTableAdapter userDA = new BuyerDSTableAdapters.aspnet_UsersTableAdapter(); DataTable userdDT = userDA.GetDataByUName(Session["name"].ToString()); ShopCartTableAdapter shopcartDA = new ShopCartTableAdapter(); if (userdDT.Rows.Count > 0) { DataTable shopcartDT = shopcartDA.GetDataBySCidPid(System.Guid.Parse(userdDT.Rows[0][1].ToString()), long.Parse(phoneid)); if (shopcartDT.Rows.Count > 0) { Response.Redirect("~/Buyer/ShoppingCart.aspx"); } 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 seller = ""; if (ds.Tables[0].Rows.Count > 0) { seller = ds.Tables[0].Rows[0]["sellerId"].ToString().Trim(); int DT = shopcartDA.AddShoppingCart(System.Guid.Parse(userdDT.Rows[0][1].ToString()), System.Guid.Parse(seller), long.Parse(phoneid), 1, int.Parse(ds.Tables[0].Rows[0]["price"].ToString().Trim()), DateTime.Now, "否"); if (DT > 0) { Response.Redirect("~/Buyer/ShoppingCart.aspx"); } else { Response.Write("<Script>alert('未能成功加入购物车!')</Script>"); } } } } else { Response.Write("<Script>alert('未能成功加入购物车!')</Script>"); } } else { Session["lasturl"] = Server.UrlDecode(Request.Url.AbsoluteUri.ToString()); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>openDiv('newDiv');</script>"); //Response.Write("<Script>alert('登录后才能加入购物车!')</Script>"); } }
protected void lbtnDelete_Click(object sender, EventArgs e) { string id = ((LinkButton)sender).CommandArgument.ToString(); long cartID = new long(); cartID = Convert.ToInt64(id); ShopCartTableAdapter cartDA = new ShopCartTableAdapter(); int Dcart = cartDA.DeleteShoppingCart(cartID); if (Dcart != 1) { Response.Write("<Script>alert('未删除!')</Script>"); } dlCartShop.DataBind(); }
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(); }
protected void ibtnBuyNow_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()); string buyer = ""; ShopCartTableAdapter shopcartDA = new ShopCartTableAdapter(); if (userdDT.Rows.Count > 0) { buyer = userdDT.Rows[0][1].ToString(); DataTable shopcartDT = shopcartDA.GetDataBySCidPid(System.Guid.Parse(buyer), long.Parse(phoneid)); if (shopcartDT.Rows.Count > 0) { int Dt = shopcartDA.UpdateCartQuantity(int.Parse(txtNum.Text), int.Parse(lblAllPrice.Text), DateTime.Now, "是", long.Parse(shopcartDT.Rows[0][0].ToString())); if (Dt == 1) { Response.Redirect("~/Buyer/SubmitOrder.aspx"); } else { 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 seller = ""; if (ds.Tables[0].Rows.Count > 0) { seller = ds.Tables[0].Rows[0]["sellerId"].ToString().Trim(); int DT = shopcartDA.AddShoppingCart(System.Guid.Parse(buyer), System.Guid.Parse(seller), long.Parse(phoneid), int.Parse(txtNum.Text.Trim()), int.Parse(lblAllPrice.Text.Trim()), DateTime.Now, "是"); if (DT > 0) { Response.Redirect("~/Buyer/SubmitOrder.aspx"); } else { Response.Write("<Script>alert('未能成功结算!')</Script>"); } } } } else { Response.Write("<Script>alert('未能成功结算!')</Script>"); } } else { Session["lasturl"] = Server.UrlDecode(Request.Url.AbsoluteUri.ToString()); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>openDiv('newDiv');</script>"); //Response.Write("<Script>alert('登录后才能购买!')</Script>"); } }
protected void ibtnBuyNow_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()); string buyer = ""; ShopCartTableAdapter shopcartDA = new ShopCartTableAdapter(); if (userdDT.Rows.Count > 0) { buyer = userdDT.Rows[0][1].ToString(); DataTable shopcartDT = shopcartDA.GetDataBySCidPid(System.Guid.Parse(buyer), long.Parse(phoneid)); if (shopcartDT.Rows.Count > 0) { int Dt = shopcartDA.UpdateCartQuantity(int.Parse(txtNum.Text), int.Parse(lblAllPrice.Text), DateTime.Now, "是", long.Parse(shopcartDT.Rows[0][0].ToString())); if (Dt == 1) { Response.Redirect("~/Buyer/SubmitOrder.aspx"); } else { 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 seller = ""; if (ds.Tables[0].Rows.Count > 0) { seller = ds.Tables[0].Rows[0]["sellerId"].ToString().Trim(); int DT = shopcartDA.AddShoppingCart(System.Guid.Parse(buyer), System.Guid.Parse(seller), long.Parse(phoneid), int.Parse(txtNum.Text.Trim()), int.Parse(lblAllPrice.Text.Trim()), DateTime.Now, "是"); if (DT > 0) { Response.Redirect("~/Buyer/SubmitOrder.aspx"); } else { Response.Write("<Script>alert('未能成功结算!')</Script>"); } } } } else { Response.Write("<Script>alert('未能成功结算!')</Script>"); } } else { Session["lasturl"] = Server.UrlDecode(Request.Url.AbsoluteUri.ToString()); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>openDiv('newDiv');</script>"); //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 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 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"); } }
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(); }
protected void lbtnSettlement_Click(object sender, EventArgs e) { ShopCartTableAdapter cartDA = new ShopCartTableAdapter(); int Numcart = 0; int select = 0; long cartID = new long(); 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++) { CheckBox chbSelectPhone = dlCartPhone.Items[j].FindControl("chbSelectPhone") as CheckBox; Label lblCartID = dlCartPhone.Items[j].FindControl("lblCartId") as Label; if (chbSelectPhone.Checked) { select++; cartID = Convert.ToInt64(lblCartID.Text); Numcart += cartDA.UpdateCartState("是",cartID); } } } if (Numcart == select) { Response.Redirect("~/Buyer/SubmitOrder.aspx"); } }
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 lbtnDelete_Click(object sender, EventArgs e) { string id = ((LinkButton)sender).CommandArgument.ToString(); long cartID = new long(); cartID = Convert.ToInt64(id); ShopCartTableAdapter cartDA = new ShopCartTableAdapter(); int Dcart = cartDA.DeleteShoppingCart(cartID); if (Dcart != 1) { Response.Write("<Script>alert('未删除!')</Script>"); } dlCartShop.DataBind(); }
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"); } }
protected void lbtnAllDelete_Click(object sender, EventArgs e) { Guid buyer = new Guid(Session["buyerID"].ToString()); int Numcart = 0; int select = 0; long cartID = new long(); ShopCartTableAdapter cartDA = new ShopCartTableAdapter(); if (chbAllSelect.Checked) { int allcart = cartDA.DeleteAll(buyer); if (allcart == 1) { Response.Write("<Script>alert('已成功从购物车删除!')</Script>"); // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true); } else { Response.Write("<Script>alert('未成功从购物车删除!!')</Script>"); //ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true); } } else { 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++) { CheckBox chbSelectPhone = dlCartPhone.Items[j].FindControl("chbSelectPhone") as CheckBox; Label lblCartID = dlCartPhone.Items[j].FindControl("lblCartId") as Label; if (chbSelectPhone.Checked) { select++; cartID = Convert.ToInt64(lblCartID.Text); Numcart += cartDA.DeleteShoppingCart(cartID); } } } if (select == 0) { Response.Write("<Script>alert('请选择物品!')</Script>"); // ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('');", true); } else { if (Numcart == 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(); }