关于投票系统动态添加项目的问题。

a12321321321312321 2009-04-14 01:38:59
最近项目里要做个投票系统,不知道管理员如何在后台实现动态添加投票选项的问题。
因为每个的投票可选的项目是不同的,有的有三个可选,有的四个可选,还有的是多选有的是单选。
不知道如何去实现该功能。大家给点意见或给个例子参考下。邮箱fanlv1988@qq.com。谢了。~
...全文
185 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2009-04-14
  • 打赏
  • 举报
回复
通过后台添加类型和项目,可参考IWMS,很好。
叶子 2009-04-14
  • 打赏
  • 举报
回复
不通过数据库,怎样来维护选项呢,难道放到xml里?
在数据层调用存储过程就可以了,而存储过程就是添加选项、删除选型,添加新调查,查询调查结果等处理。
幕夜 2009-04-14
  • 打赏
  • 举报
回复
报投票项目放入数据库再从数据库根据自己所需要的导出就行了。
winner2050 2009-04-14
  • 打赏
  • 举报
回复
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TopWinCMS_Vote]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TopWinCMS_Vote]
GO

CREATE TABLE [dbo].[TopWinCMS_Vote] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[Title] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[Pass] [int] NULL ,
[DataTime] [datetime] NULL ,
[VoteType] [int] NULL ,
[PicUrl] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[EndData] [datetime] NULL ,
[windowsize] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[TemplateFileName] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[LimitIP] [int] NULL
) ON [PRIMARY]
GO


exec sp_addextendedproperty N'MS_Description', N'投票主题', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'Title'
GO
exec sp_addextendedproperty N'MS_Description', N'是否通过审核', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'Pass'
GO
exec sp_addextendedproperty N'MS_Description', N'添加时间', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'DataTime'
GO
exec sp_addextendedproperty N'MS_Description', N'主题 选项类型0,单选;1多选', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'VoteType'
GO
exec sp_addextendedproperty N'MS_Description', N'缩略图', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'PicUrl'
GO
exec sp_addextendedproperty N'MS_Description', N'过期时间', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'EndData'
GO
exec sp_addextendedproperty N'MS_Description', N'查看投票窗口(宽高) 格式:120*90', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'windowsize'
GO
exec sp_addextendedproperty N'MS_Description', N'模板文件名称', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'TemplateFileName'
GO
exec sp_addextendedproperty N'MS_Description', N'限制IP :0不限制,1限制', N'user', N'dbo', N'table', N'TopWinCMS_Vote', N'column', N'LimitIP'


GO

zhaolingliuxiaoyi 2009-04-14
  • 打赏
  • 举报
回复
http://aspx.bcbbs.net/Default.aspx
源码
yiyeqiubo 2009-04-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 maco_wang 的回复:]
SQL code
declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1

select * from @table
/*
num name type
----------- ---------------…
有用么???
悔说话的哑巴 2009-04-14
  • 打赏
  • 举报
回复
别人是给数据库的代码
真是的
难道不用数据库》
zhong2006 2009-04-14
  • 打赏
  • 举报
回复
两张表,一张存题目(标题,选项类型(单/多),是否显示),一张存选项………………

显示时,根据选项类型,选择是用RadioButtonList,还是CheckBoxList绑定选项
saisky 2009-04-14
  • 打赏
  • 举报
回复
多选,单选处理方式的思路都是一样的
最终处理结果也是一样的
lucas406 2009-04-14
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 f800051235 的回复:]
引用 2 楼 lucas406 的回复:
偶也刚做了个
但由于是动态生成的速度很慢
很痛苦

数据的插入量还非常大

恐怖
帮你顶下吧

你是怎么做的,能否分享下?
[/Quote]

我的方法比较笨 你就当个思路吧 希望不会给你拐到坑里
表1 考核项表(考核项1、考核项2、考核项3、...)
表2 记录投票表(投票的信息)
表3 记录投票的考核项的结果(跟表2是多对1的关系,也就是以表2为外键。或者说 表2插入1条数据,那么表3插入对应表2的表1数据量的数据)
表4 考核参与人员

页面的表单都是动态生成的根据表1动态生成表单的列,根据表4生成表单的行,然后在动态绑定 单选多选什么的。
结果就是很慢,并发后速度更是慢......

http://topic.csdn.net/u/20090408/17/23a5c757-2894-4fe6-8865-d20fefb2d462.html
这个是一个CSDN里的朋友给我贴的动态生成的代码,我还没来得急看,你可以研究下。

见笑

  • 打赏
  • 举报
回复
[Quote=引用 7 楼 f800051235 的回复:]
引用 6 楼 maco_wang 的回复:
SQL code
declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1

--首页取出一个网上投票

declare @id int
set @id=1…
[/Quote]

那个 哈尔滨 叶子 给你的代码我觉得应该是写到数据层的,是数据库的方法,你在表示层调用数据层的方法就是了,自己添加控件来显示就是
a12321321321312321 2009-04-14
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 bxbacn 的回复:]
七楼回复搞笑,今天也碰到一个...给他sql语句,他说我要的是.net代码,这种sql查询只能在sql中用
[/Quote]
你是不是没看明白我的发帖的意思?我说的是要管理员能够动态添加选项的,就想CSDN押宝那样。You know 不?
bxbacn 2009-04-14
  • 打赏
  • 举报
回复
七楼回复搞笑,今天也碰到一个...给他sql语句,他说我要的是.net代码,这种sql查询只能在sql中用
a12321321321312321 2009-04-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lucas406 的回复:]
偶也刚做了个
但由于是动态生成的速度很慢
很痛苦

数据的插入量还非常大

恐怖
帮你顶下吧
[/Quote]
你是怎么做的,能否分享下?
a12321321321312321 2009-04-14
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 maco_wang 的回复:]
SQL code
declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1

--首页取出一个网上投票

declare @id int
set @id=1
--用○代替单选按钮
select (case type w…
[/Quote]
晕~我要做的事ASP.NET的,你这个发的是什么意思?
叶子 2009-04-14
  • 打赏
  • 举报
回复

declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1

--首页取出一个网上投票

declare @id int
set @id=1
--用○代替单选按钮
select (case type when 0 then [name] else '○ '+[name] end) as 网上调查 from @table where num=@id

/*
网上调查
------------------------
你最喜欢的颜色是什么?
○ 红
○ 黄
○ 蓝
*/
叶子 2009-04-14
  • 打赏
  • 举报
回复

declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1

select * from @table
/*
num name type
----------- --------------------- -----------
1 你最喜欢的颜色是什么? 0
1 红 1
1 黄 1
1 蓝 1
2 你喜欢旅游吗? 0
2 喜欢 1
2 不喜欢 1
*/

--新添加一个投票
insert into @table
select 3,'你去过长城吗?',0 union all
select 3,'去过',1 union all
select 3,'没有',1

select * from @table

--为第一个投票添加一个选项
insert into @table
select 1,'绿',1

select * from @table order by num



--首页取出一个网上投票
declare @id int
set @id=1

select [name] from @table where num=@id
叶子 2009-04-14
  • 打赏
  • 举报
回复

declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1

select * from @table
/*
num name type
----------- --------------------- -----------
1 你最喜欢的颜色是什么? 0
1 红 1
1 黄 1
1 蓝 1
2 你喜欢旅游吗? 0
2 喜欢 1
2 不喜欢 1
*/
zftow110 2009-04-14
  • 打赏
  • 举报
回复
一个字段用关键字符分开
或单独建表放项
lucas406 2009-04-14
  • 打赏
  • 举报
回复
偶也刚做了个
但由于是动态生成的速度很慢
很痛苦

数据的插入量还非常大

恐怖
帮你顶下吧
加载更多回复(1)

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧