//类别删除操作 protected void CatTypeList_RowDeleting(object sender, GridViewDeleteEventArgs e) { int catTypeId = Convert.ToInt32(CatTypeList.DataKeys[e.RowIndex].Value); string catTypeName = ((Label)CatTypeList.Rows[e.RowIndex].FindControl("CatTypeNameLab")).Text; string catTypePrice = ((Label)CatTypeList.Rows[e.RowIndex].FindControl("CatTypePriceLab")).Text; DataTable items = item_bll.GetItemListByCategoryId(userId, catTypeId); if (items.Rows.Count > 0) { Utility.Alert(this, "不能删除已使用的类别!"); return; } if (this.CatTypeList.Rows.Count == 1) { Utility.Alert(this, "不能删除最后一个类别!"); return; } UserCategoryInfo category = new UserCategoryInfo(); category.CategoryTypeID = catTypeId; category.CategoryTypeName = catTypeName; category.CategoryTypePrice = Convert.ToInt32(catTypePrice); category.UserID = userId; category.CategoryTypeLive = 0; category.Synchronize = 1; category.ModifyDate = DateTime.Now; bool success = bll.DeleteUserCategory(category); if (success) { CacheHelper.RemoveCache(string.Format("cattype_{0}", userId)); Utility.Alert(this, "删除成功。"); CatTypeList.EditIndex = -1; BindGrid(); } else { Utility.Alert(this, "删除失败!"); } }