protected void gv_List_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { if (Session["LogisticsOrderApplyDetail"] != null) { ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"]; switch (cart.AddProduct((int)gv_List.DataKeys[e.NewSelectedIndex]["Product"], (decimal)gv_List.DataKeys[e.NewSelectedIndex]["Price"])) { case 0: gv_List.Rows[e.NewSelectedIndex].FindControl("cb_Check").Visible = false; gv_List.Rows[e.NewSelectedIndex].FindControl("imbt_Select").Visible = false; lb_CartCount.Text = cart.Items.Count.ToString(); //MessageBox.Show(this, "成功将该品项加入购物车中!"); break; case -1: MessageBox.Show(this, "发布目录中不包括此品项!"); break; case -2: MessageBox.Show(this, "已超可申请数量!"); break; case -3: MessageBox.Show(this, "该产品已在购物车中!"); break; default: MessageBox.Show(this, "加入购物车失败!"); break; } } e.Cancel = true; }
protected void bt_BuyIn_Click(object sender, ImageClickEventArgs e) { if (Session["LogisticsOrderApplyDetail"] != null) { int count = 0; ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"]; foreach (GridViewRow row in gv_List.Rows) { CheckBox cb_check = (CheckBox)row.FindControl("cb_Check"); if (cb_check.Visible && cb_check.Checked) { if (cart.AddProduct((int)gv_List.DataKeys[row.RowIndex]["Product"], (decimal)gv_List.DataKeys[row.RowIndex]["Price"]) == 0) { row.FindControl("cb_Check").Visible = false; row.FindControl("imbt_Select").Visible = false; count++; } } } lb_CartCount.Text = cart.Items.Count.ToString(); MessageBox.Show(this, "成功将" + count.ToString() + "个品项加入购物车中!"); } }