protected void LinkButton1_Click(object sender, EventArgs e) { string ids = selInfo(); int num = 0; if (ids.Length == 0) { Jscript.Alert("请选择要Delete的记录!", this.Page); return; } string[] arr = ids.TrimEnd(',').Split(','); for (int i = 0; i < arr.Length; i++) { if (CartTempService.Delete(Convert.ToInt32(arr[i]))) { num++; } } BindData(); }
/// <summary> /// 控件行命令事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("add")) { int id = Convert.ToInt32(e.CommandArgument); CartTemp ct = CartTempService.GetModel(id); if (ct != null) { ct.productCount++; Product p = ProductService.GetModel(ct.productId); if (p != null) { ct.remark = (ct.productCount * p.price1).ToString("0.00"); } CartTempService.UpdateCart(ct); } } if (e.CommandName.Equals("del")) { CartTempService.Delete(Convert.ToInt32(e.CommandArgument)); } if (e.CommandName.Equals("reduce")) { int id = Convert.ToInt32(e.CommandArgument); CartTemp ct = CartTempService.GetModel(id); if (ct != null) { if (ct.productCount > 1) { ct.productCount--; Product p = ProductService.GetModel(ct.productId); if (p != null) { ct.remark = (ct.productCount * p.price1).ToString("0.00"); } CartTempService.UpdateCart(ct); } } } BindData(); }