在线投票系统代码(在线投票管理系统)

http://www.itjxue.com  2023-01-30 12:45  来源:未知  点击次数: 

用.net编程,在线投票的代码!

捐献了免费ASP.NET web控件:CodeHighlighter .

CodeHighlighter is是.net环境下最强大的源代码语法高亮组件.代码语法高亮是很体现专业性的特性,增加了代码的易读性.只需要以内联或这编程设置文本属性的方式告诉CodeHighlighter,在代码就会以语法高亮的形式输出呈现.还支持自定义语言,行号,关键词连接等.

用jsp做网上投票系统 代码

我之前做过类似的投票小项目,在这里把源码发给你。你自己好好的参考一下。--------------------------package com.tv.bean;public class TVBean {

private String tvName;

private int tvCount;

public String getTvName() {

return tvName;

}

public void setTvName(String tvName) {

this.tvName = tvName;

}

public int getTvCount() {

return tvCount;

}

public void setTvCount(int tvCount) {

this.tvCount = tvCount;

}

}------------------------------package com.tv.dao;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;import com.tv.bean.TVBean;

public class DBUtil {

private Connection con;

private PreparedStatement ps = null;

private ResultSet rs;

public void getCon(){

try {

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=TV","sa","");

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

}

}

public void closeCon(){

try {

if(rs !=null) rs.close();

if(ps != null) ps.close();

if(con != null) con.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

public ArrayList getAll(){

ArrayList al = new ArrayList();

this.getCon();

String sql = "select * from TVInfo order by tvCount desc";

try {

ps = con.prepareStatement(sql);

rs = ps.executeQuery();

while(rs.next()){

TVBean tb = new TVBean();

tb.setTvName(rs.getString(1));

tb.setTvCount(rs.getInt(2));

al.add(tb);

}

} catch (SQLException e) {

e.printStackTrace();

} finally {

this.closeCon();

}

return al;

}

public boolean updateByName(String name){

this.getCon();

String sql = "update TVInfo set tvCount=tvCount+1 where tvName='"+name+"'";

try {

ps = con.prepareStatement(sql);

int i = ps.executeUpdate();

if(i 0) return true;

else return false;

} catch (SQLException e) {

e.printStackTrace();

return false;

} finally {

this.closeCon();

}

}

}

---------------------------------------package com.tv.servlet;import java.io.IOException;

import java.util.ArrayList;import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;import com.tv.dao.DBUtil;public class VoteServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

request.setCharacterEncoding("UTF-8");

response.setContentType("text/html;charset=UTF-8");

DBUtil dao = new DBUtil();

String [] name = request.getParameterValues("tvs");

int num = name.length;

for(int i =0; i num; i++){

if(dao.updateByName(name[i])){

request.setAttribute("to", "投票成功!");

ArrayList al = dao.getAll();

HttpSession session = request.getSession();

session.setAttribute("al", al);

request.getRequestDispatcher("success.jsp").forward(request, response);

}else{

request.setAttribute("to", "投票失败!请重新再试!");

}

}

} public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

doGet(request,response);

}

}

-----------------------------------%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%

%@taglib prefix="c" uri=" "%html

head

title电视投票/title

/head body

center

form action="vote" method="post"

table border="1" align="center"

tr align="center"

td

h2

选择您最喜欢的电视剧并投上一票

/h2

/td

/tr

tr

td

input type="checkbox" name="tvs" value="咏春" /

咏春

/td

/tr

tr

td

input type="checkbox" name="tvs" value="金婚" /

金婚

/td

/tr

tr

td

input type="checkbox" name="tvs" value="士兵突击" /

士兵突击

/td

/tr

tr

td

input type="checkbox" name="tvs" value="少年张三丰" /

少年张三丰

/td

/tr

tr

td align="center"

input type="submit" value=" 提交 " /

input type="reset" value=" 重置 " /

/td

/tr

/table

/form

/center

/body

/html

-------------------------------------第一段代码为JavaBean;第二段代码为数据库连接类;第三段代码为Servlet控制类;第四段代码为JSP显示页面。希望能够解决你的问题!

求C语言投票系统源代码代码的注释。

#includestdio.h

#includeconio.h

struct hxr

{

int m;

int point;

} hxr[3]; //选票结构体

void main()

{

int i=0,j=0,k,temp=0;

char x,y,z;

struct hxr hxr[3];

for(i=0;i3;i++)//初始化选票结构体

{

hxr[i].m=i;

hxr[i].point=0;

}

printf("请输入投票总人数\n");

scanf("%d",k);

printf("请输入投票\n");

getchar();

for(i=1;i=k;i++)

{

scanf("%c%c%c",x,y,z); //输入选票

getchar();

if(x!=yx!=zy!=z)//3个选票不能相同否则为无效选票

{

hxr[0].point+=(x=='a'?5:(y=='a'?3:(z=='a'?2:0))); //统计a的得票数,切输入3个选票从左到右得分分别是5.3.2

hxr[1].point+=(x=='b'?5:(y=='b'?3:(z=='b'?2:0)));

hxr[2].point+=(x=='c'?5:(y=='c'?3:(z=='c'?2:0)));

printf(" point: %d %d %d\n",hxr[0].point,hxr[1].point,hxr[2].point); //输出a,b,c的得分

continue;

}

printf("此票无效\n");

}

for(i=0;i3;i++)//分别输出a,b,c的得分

{

if(temphxr[i].point)

{

temp=hxr[i].point;

j='a'+i;

}

printf("people %c point %d\n",'a'+hxr[i].m,hxr[i].point);

}

if(((hxr[0].point==hxr[1].point)hxr[0].point=hxr[2].pointhxr[1].point=hxr[2].point ) ||( (hxr[0].point==hxr[2].point)hxr[0].point=hxr[1].pointhxr[2].point=hxr[1].point) ||((hxr[1].point==hxr[2].point)hxr[1].point=hxr[0].pointhxr[2].point=hxr[0].point))

printf("重新投票\n");

else

{ printf("祝贺%c当选冠军\n",j); }

getchar();

}

交易系统网络投票方法

投资者利用招商证券交易系统进行网络投票具体方法如下:

一、投票要素以下要素构成交易系统的一笔委托,对应网络投票一个议案的投票表决意见:

1、投票代码。深交所上市公司投票代码以“36”开头,上交所“73”开头,可以在上市公司公告查询。

2、投票简称。上市公司投票简称为“XX投票”,前两个汉字,由上市公司根据其证券简称自行决定。

3、买卖方向。均为买入。

4、申购价格。代表股东大会议案序号,如股东大会有多个待表决的议案,则1.00元代表议案1,2.00元代表议案2,依此类推。行情中的“昨日收盘价”,被设置为该上市公司本次股东大会讨论的议案总数,供投资者参考。

5、申购股数。代表表决意见,申报1股代表“同意”,申报2股代表“反对”,申报3股代表“弃权”。

二、投票规则

1、如果同一股东分别持有上市公司A、B股票,股东应当用其持有的A股股东帐号与B股股东帐号分别投票。

2、股东大会有多个待表决的议案时,投资者可以按照任意次序对各议案进行表决申报,表决申报不能撤单。

(责任编辑:IT教学网)

更多

推荐java认证文章