Exemple #1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public void SaveVote(VoteVO entity)
        {
            if (entity.id > 0)
            {
                VotingEventsDA.UpdateVote(entity);
            }
            else
            {
                var id = VotingEventsDA.InsertVote(entity);
                entity.id = id;
            }
            entity.vote_item.ForEach(_ => _.vote_id = entity.id);
            int order = 1;

            foreach (var item in entity.vote_item)
            {
                item.vote_id   = entity.id;
                item.order_num = order++;
                if (item.id > 0)
                {
                    VotingEventsDA.UpdateVoteItem(item);
                }
                else
                {
                    VotingEventsDA.InsertVoteItem(item);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int UpdateVote(VoteVO entity)
        {
            var cmd = new DataCommand("VotingEvents.UpdateVote");

            cmd.SetParameter(entity);
            int result = cmd.ExecuteNonQuery();

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int InsertVote(VoteVO entity)
        {
            var cmd = new DataCommand("VotingEvents.InsertVote");

            cmd.SetParameter(entity);
            int result = cmd.ExecuteScalar <int>();

            return(result);
        }
Exemple #4
0
 public ActionResult SaveVote(VoteVO entity)
 {
     entity.id = entity.voteid;
     _basisService.SaveVote(entity);
     return(Json(new AjaxResult()
     {
         Success = true, Message = string.Format("保存成功!")
     }, JsonRequestBehavior.AllowGet));
 }
Exemple #5
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);
        }
Exemple #6
0
        public Status getOne(int voteID, out VoteInfo vote)
        {
            vote = new VoteInfo();
            try
            {
                Dictionary <string, object> wherelist = new Dictionary <string, object>();

                VoteDAO       voteDao       = Factory.getInstance <VoteDAO>();
                VoteOptionDAO voteOptionDao = Factory.getInstance <VoteOptionDAO>();

                VoteVO voteVo = voteDao.getOne <VoteVO>(voteID);
                if (voteVo == null)
                {
                    return(Status.NONFOUND);
                }
                //获取表决选项列表
                List <string> voteOptions = new List <string>();
                wherelist.Add("voteID", voteID);
                List <VoteOptionVO> voteOptionVolist = voteOptionDao.getAll <VoteOptionVO>(wherelist);
                //将选项按序号排序
                voteOptionVolist.Sort((x, y) => x.voteOptionIndex - y.voteOptionIndex);
                //填充返回列表
                if (voteOptionVolist != null)
                {
                    foreach (VoteOptionVO voteOptionVo in voteOptionVolist)
                    {
                        voteOptions.Add(voteOptionVo.voteOptionName);
                    }
                }

                vote.agendaID        = voteVo.agendaID;
                vote.voteID          = voteVo.voteID;
                vote.voteName        = voteVo.voteName;
                vote.voteDescription = voteVo.voteDescription;
                vote.voteType        = voteVo.voteType;
                vote.optionNum       = voteOptions.Count;
                vote.options         = voteOptions;

                return(Status.SUCCESS);
            }
            catch (Exception e)
            {
                Log.LogInfo("为更新获取表决信息", e);
                return(Status.SERVER_EXCEPTION);
            }
        }
Exemple #7
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);
        }