/// <summary> /// VoteGridView的删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void VoteGridView_OnRowDeleting(object sender, GridViewDeleteEventArgs e) { CY.CSTS.Core.Business.Vote vote = new CY.CSTS.Core.Business.Vote(); int ID = 0; if (int.TryParse(this.VoteGridView.DataKeys[e.RowIndex].Value.ToString(), out ID)) { try { vote = CY.CSTS.Core.Business.Vote.Load(ID); vote.DeleteOnSave(); vote.Save(); CY.CSTS.Core.Business.VoteRole.DeleteVoteRoleByVoteId(ID); IList<CY.CSTS.Core.Business.VoteItem> vIList = DeleteVoteItem(ID);//删除所有投票项 DeleteVoteAnswer(vIList);//删除所有答案项 List<CY.CSTS.Core.Business.VoteRecord> voteRecordList = CY.CSTS.Core.Business.VoteRecord.GetVoteAdviceByVoteID(ID) as List<CY.CSTS.Core.Business.VoteRecord>; if (voteRecordList != null) { for (int m = 0; m < voteRecordList.Count; ++m) { CY.CSTS.Core.Business.VoteRecord voteReco = CY.CSTS.Core.Business.VoteRecord.Load(voteRecordList[m].Id); if (voteReco != null) { voteReco.DeleteOnSave(); voteReco.Save(); CY.CSTS.Core.Business.UserAnswer.DeleteByVoteRecordID(voteRecordList[m].Id); CY.CSTS.Core.Business.VoteRecordDetail.DeleteByVoteRecordID(voteRecordList[m].Id); } } } ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('删除成功!');</script>"); VoteGridView_DataBind(); } catch { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('删除成功!');</script>"); } } }
/// <summary> /// VoteGridView的删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void VoteGridView_OnRowDeleting(object sender, GridViewDeleteEventArgs e) { CY.CSTS.Core.Business.Vote vote = new CY.CSTS.Core.Business.Vote(); int ID = 0; if (int.TryParse(this.VoteGridView.DataKeys[e.RowIndex].Value.ToString(), out ID)) { try { vote = CY.CSTS.Core.Business.Vote.Load(ID); vote.DeleteOnSave(); vote.Save(); CY.CSTS.Core.Business.VoteRole.DeleteVoteRoleByVoteId(ID); IList<CY.CSTS.Core.Business.VoteItem> vIList = DeleteVoteItem(ID);//删除所有投票项 DeleteVoteAnswer(vIList);//删除所有答案项 ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('删除成功!');</script>"); VoteGridView_DataBind(); } catch { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('删除失败!');</script>"); } } }