投票系统

来源:互联网 发布:进出口海关数据 编辑:程序博客网 时间:2024/05/01 20:41

一个小小的投票系统,首先创建四张数据库的表,user用户表,vms_vote投票表,vms_voteitem投票选项表,vms_ joinvote用户投票表

各个表字段如下





各个界面如下







主界面主要用到iframe

<script>    <!-- 编写脚本 -->    function ifmresize(){        var ifm= document.getElementById("contentframe");        ifm.height=document.documentElement.clientHeight;    }    window.onresize=function(){        ifmresize();    }</script> <div class="col-md-10">                <iframe                        width="100%"                        id="contentframe"                        name="contentframe"                        onload="ifmresize()"                        frameborder="0"                        scrolling="auto"                        src="listjoinvotes.jsp">                </iframe>            </div>

界面基本是一样的结构,有些界面加入了模态框,界面遍历部分代码如下,

                        <table class="table table-hover">                                              <thead>                            <tr>                                <th>                                    选项编号                                </th>                                <th>                                    选项名称                                </th>                                <th>                                    投票人数                                </th>                            </tr>                            </thead>                      <%                      VoteItemDAO voteItemDAO = new VoteItemDAO();                      List<VoteItem> voteItemList = voteItemDAO.getVoteItemResult(votes.getVoteid());                      for(VoteItem voteItem : voteItemList) {                                                %>                            <tr>                            <td>                            <%=voteItem.getItemid()+1 %>                            </td>                            <td>                            <%=voteItem.getName() %>                            </td>                            <td>                            <%=voteItem.getVotecount() %>                            </td>                            </tr>                            <%                      }                            %>                        </table>

因为数据库的时间字段是时间戳格式,在界面获取的是String类型,而且使用的日期选择器格式也是mm/dd/yy的,所以在装换的时候,就使用了private SimpleDateFormat simpleDateFormatTemp = new SimpleDateFormat("MM/dd/yyyy");
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

来对日期进行转换.

做完后,感觉就是对数据库的增改查,还有业务逻辑的思考,虽然不是很难,但是代码写的很多重复的,也很乱.所以就不继续粘贴代码了,

基本的投票发起投票和进行投票的功能都实现了,不过还没实现进行多选的投票,还有数据库查询后分页的功能没有实现,以后再看看能不能继续完善,

0 0
原创粉丝点击