/// <summary> /// 删除会议时使用 /// </summary> /// <param name="agendaID"></param> /// <returns></returns> public Status deleteAll(int agendaID) { Dictionary <string, object> wherelist = new Dictionary <string, object>(); VoteDAO voteDao = Factory.getInstance <VoteDAO>(); VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); wherelist.Add("agendaID", agendaID); var voteVolist = voteDao.getAll <VoteVO>(wherelist); if (voteVolist != null) { foreach (var voteVo in voteVolist) { wherelist.Clear(); wherelist.Add("voteID", voteVo.voteID); voteOptionDao.delete(wherelist); } } wherelist.Clear(); wherelist.Add("agendaID", agendaID); voteDao.delete(wherelist);//删除表决 return(Status.SUCCESS); }
public Status getAll(int agendaID, out List <VoteInfo> votes) { votes = new List <VoteInfo>(); Dictionary <string, object> wherelist = new Dictionary <string, object>(); VoteDAO voteDao = Factory.getInstance <VoteDAO>(); wherelist.Add("agendaID", agendaID); List <VoteVO> voteVolist = voteDao.getAll <VoteVO>(wherelist); if (voteVolist == null) { return(Status.NONFOUND); } foreach (VoteVO voteVo in voteVolist) { wherelist.Clear(); VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); wherelist.Add("voteID", voteVo.voteID); List <VoteOptionVO> voteOptionVolist = voteOptionDao.getAll <VoteOptionVO>(wherelist); List <String> optionList = new List <string>(); if (voteOptionVolist != null) { //将选项按序号排序 voteOptionVolist.Sort((x, y) => x.voteOptionIndex - y.voteOptionIndex); foreach (VoteOptionVO voteOptionVo in voteOptionVolist) { optionList.Add(voteOptionVo.voteOptionName); } } votes.Add( new VoteInfo { voteID = voteVo.voteID, voteName = voteVo.voteName, voteDescription = voteVo.voteDescription, voteType = voteVo.voteType, optionNum = optionList.Count, options = optionList }); } return(Status.SUCCESS); }
public Status create(CreateVote vote) { //修正字符串 vote.voteName = vote.voteName.Trim(); vote.voteDescription = vote.voteDescription.Trim(); //检查参数格式 if (!checkFormat(vote.voteOptions)) { return(Status.FORMAT_ERROR); } //验证当前用户的更新当前会议权限 AgendaDAO agendaDao = Factory.getInstance <AgendaDAO>(); AgendaVO agendaVo = agendaDao.getOne <AgendaVO>(vote.agendaID); if (agendaVo == null) { return(Status.FAILURE); } //初始化会议操作 meeting_initOperator(agendaVo.meetingID); bool isUpdate = false; //判断会议是否开启,如果开启,更新"更新状态”,设置数据更新状态 if (meeting_isOpening()) { meeting_updatevote(); isUpdate = true; } else if (meeting_isOpended())//如果会议已结束,直接退出 { return(Status.FAILURE); } Dictionary <string, object> wherelist = new Dictionary <string, object>(); // 插入投票 VoteDAO voteDao = Factory.getInstance <VoteDAO>(); wherelist.Clear(); wherelist.Add("agendaID", vote.agendaID); List <VoteVO> voteVolist = voteDao.getAll <VoteVO>(wherelist); //设置新的投票编号 int voteIndex = voteVolist == null ? 1 : voteVolist.Count + 1; // 先获取新的ID int newVoteID = VoteDAO.getID(); if (voteDao.insert <VoteVO>( new VoteVO { voteID = newVoteID, voteIndex = voteIndex, voteName = vote.voteName, voteDescription = vote.voteDescription, voteType = vote.voteType, voteStatus = 0, // 未开 agendaID = vote.agendaID, isUpdate = isUpdate }) < 0) { return(Status.FAILURE); } // 插入投票选项列表 int index = 1; VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>(); if (vote.voteOptions != null) { HashSet <string> hs = new HashSet <string>(vote.voteOptions); foreach (string voteOption in hs) { if (voteOptionDao.insert <VoteOptionVO>( new VoteOptionVO { voteOptionID = VoteOptionDAO.getID(), voteOptionName = voteOption, voteOptionIndex = index, voteID = newVoteID }) < 0) { return(Status.FAILURE); } ++index; } } return(Status.SUCCESS); }