Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        public Status deleteMultipe(List <int> votes)
        {
            if (votes == null || votes.Count == 0)
            {
                return(Status.SUCCESS);
            }

            VoteDAO       voteDao                 = Factory.getInstance <VoteDAO>();
            VoteOptionDAO voteOptionDao           = Factory.getInstance <VoteOptionDAO>();
            AgendaDAO     agendaDao               = Factory.getInstance <AgendaDAO>();
            Dictionary <string, object> wherelist = new Dictionary <string, object>();

            foreach (int voteID in votes)
            {
                //获取表决信息
                VoteVO voteVo = voteDao.getOne <VoteVO>(voteID);
                if (voteVo == null)
                {
                    continue;
                }

                //判断投票是否未开启,如果 不是”未开启“,直接退出
                if (!IsNotOpen_Vote(voteVo.voteStatus))
                {
                    return(Status.FAILURE);
                }

                //获取议程信息
                AgendaVO agendaVo = agendaDao.getOne <AgendaVO>(voteVo.agendaID);
                if (agendaVo == null)
                {
                    continue;
                }

                //初始化会场操作
                meeting_initOperator(agendaVo.meetingID);

                //判断会议是否 未开启,如果 不是”未开启“,直接退出
                if (!meeting_isNotOpen())
                {
                    return(Status.FAILURE);
                }
                //删除选项
                wherelist.Clear();
                wherelist.Add("voteID", voteID);
                voteOptionDao.delete(wherelist);

                //更新其他投票的序号信息
                voteDao.updateIndex(voteVo.agendaID, voteVo.voteIndex);
                //删除当前投票
                voteDao.delete(voteVo.voteID);
            }
            return(Status.SUCCESS);
        }
Esempio n. 3
0
        public Status update(UpdateVote vote)
        {
            VoteDAO voteDao = Factory.getInstance <VoteDAO>();
            VoteVO  voteVo  = voteDao.getOne <VoteVO>(vote.voteID);

            if (voteVo == null)
            {
                return(Status.NONFOUND);
            }

            //修正字符串
            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>(voteVo.agendaID);

            if (agendaVo == null)
            {
                return(Status.FAILURE);
            }

            //初始化会议操作
            meeting_initOperator(agendaVo.meetingID);

            //判断会议是否开启,如果正在开启,直接退出
            if (meeting_isOpening())
            {
                return(Status.MEETING_OPENING);
            }
            else if (meeting_isOpended())//如果会议已结束,直接退出
            {
                return(Status.FAILURE);
            }

            // 更新vote
            Dictionary <string, object> wherelist = new Dictionary <string, object>();

            wherelist.Add("voteName", vote.voteName);
            wherelist.Add("voteDescription", vote.voteDescription);
            wherelist.Add("voteType", vote.voteType);
            if (voteDao.update(wherelist, vote.voteID) < 0)
            {
                return(Status.FAILURE);
            }

            // 清空投票选项列表
            VoteOptionDAO voteOptionDao            = Factory.getInstance <VoteOptionDAO>();
            Dictionary <string, object> wherelist1 = new Dictionary <string, object>();

            wherelist1.Add("voteID", vote.voteID);
            voteOptionDao.delete(wherelist1);

            // 重写投票选项列表
            int index = 1;

            if (vote.voteOptions != null)
            {
                HashSet <string> hs = new HashSet <string>(vote.voteOptions);
                foreach (string voteOption in hs)
                {
                    int newVoteOptionID = VoteOptionDAO.getID();
                    if (voteOptionDao.insert <VoteOptionVO>(
                            new VoteOptionVO
                    {
                        voteOptionID = newVoteOptionID,
                        voteOptionName = voteOption,
                        voteOptionIndex = index,
                        voteID = vote.voteID
                    }) < 0)
                    {
                        return(Status.FAILURE);
                    }

                    ++index;
                }
            }

            return(Status.SUCCESS);
        }