473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

a poll system with different condition

hi guy,

My question is to create a poll system for basically 2 condition which is single vote and mulitiple vote per poll.
For the single vote, it can be single vote per day or per duration.

In our system there is a few poll to vote. But the code that i had implement unable to remember the cookie base on the poll.
I am a newbie in vb.net.
I think i should use the HttpCookieCollection to differentiate the cookies that i want to store. But Can you guys give me some guide?
Really hope you guys can help.

thanks! ^^

this is part of the code.
Expand|Select|Wrap|Line Numbers
  1. Protected Sub rp_polls_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rp_polls.ItemCommand
  2.  
  3.         Dim alIn As ArrayList = New ArrayList
  4.         Dim mclas As ExodusG2.dbOps = New ExodusG2.dbOps
  5.         Dim ssql As String
  6.  
  7.         Dim r As RadioButtonList
  8.         Dim strID As String
  9.         r = e.Item.FindControl("rblAnswer")
  10.  
  11.         strID = r.SelectedValue
  12.         ViewState("AnswerID") = strID
  13.  
  14.         Dim lbl As Label
  15.         lbl = e.Item.FindControl("lblError")
  16.  
  17.         sLanguageCodeAndID = xTool.getPublicLanguage
  18.         sLanguageID = Right(sLanguageCodeAndID, 36)
  19.         sLanguageCode = Left(sLanguageCodeAndID, 5)
  20.         sDefaultLanguageCode = Left(xTool.getDefaultLanguage, 5) & "_"
  21.  
  22.  
  23.         If e.CommandName = "Vote" Then
  24.  
  25.             If strID = "" Then
  26.  
  27.                 lbl.Text = xTool.getStatictext("9cfebdd1-7cc9-4e33-8707-943e0265fab5", sLanguageID, sDefaultLanguageCode)
  28.                 lbl.Visible = True
  29.                 MessageBox(xTool.getStatictext("9cfebdd1-7cc9-4e33-8707-943e0265fab5", sLanguageID, sDefaultLanguageCode))
  30.                 Exit Sub
  31.             End If
  32.  
  33.  
  34.             Dim GUID As String = System.Guid.NewGuid.ToString
  35.  
  36.             'Dim aCookie As New HttpCookie("userInfo")
  37.             'aCookie.Values("userName") = "patrick"
  38.             'aCookie.Values("lastVisit") = DateTime.Now.ToString()
  39.             'aCookie.Expires = DateTime.Now.AddDays(1)
  40.             'Response.Cookies.Add(aCookie)
  41.  
  42.             Dim oCookiedu As New HttpCookie("VotedResultDu")
  43.             Dim oCookieda As New HttpCookie("VotedResultDa")
  44.             Dim oCookiem As New HttpCookie("VotedResultM")
  45.  
  46.             'single Vote
  47.             If ViewState(ViewState("QID") & "condition") = "1" Then
  48.                 If ViewState(ViewState("QID") & "sCondition") = "1" Then
  49.                     If oCookiedu.Values(e.CommandArgument) Is Nothing Then
  50.                         oCookiedu.Values(e.CommandArgument) = e.CommandArgument
  51.                         oCookiedu.Expires = DateTime.Now.AddDays(600)
  52.                         Response.Cookies.Add(oCookiedu)
  53.  
  54.                         'oCookie.Expires = DateTime.Now.AddDays(600)
  55.                         'ViewState("QDuID") = e.CommandArgument
  56.                         'oCookie.Value = e.CommandArgument
  57.                         'Response.Cookies.Add(oCookie)
  58.                         lbl.Visible = False
  59.  
  60.                         'Insert Records
  61.                         ssql = "Insert into PollResult (pollResultID,pollID,pollAnswerID,IP_address,pollResult_addDate,pollResult_status,websiteID) values (@param1,@param2,@param3,@param4,@param5,@param6,@param7)"
  62.  
  63.                         alIn.Clear()
  64.                         alIn.Add(System.Guid.NewGuid.ToString)
  65.                         alIn.Add(ViewState("QID"))
  66.                         alIn.Add(ViewState("AnswerID"))
  67.                         alIn.Add(Request.ServerVariables("REMOTE_ADDR"))
  68.                         alIn.Add(Date.Now.ToString)
  69.                         alIn.Add("1")
  70.                         'Corp site
  71.                         alIn.Add("25e2f6f0-d842-4457-a613-409c6088fad3")
  72.                         mclas.execute_query(ssql, alIn)
  73.  
  74.                         Response.Write("Duration")
  75.                         Response.Redirect("result_polls.aspx?pollID=" & e.CommandArgument & "")
  76.  
  77.                     Else
  78.                         Response.Write("Duration failed")
  79.                         'Response.Redirect("result_polls.aspx?pollID=" & e.CommandArgument & "")
  80.  
  81.                     End If
  82.  
  83.                 Else
  84.                     If oCookiedu.Values(e.CommandArgument) Is Nothing Then
  85.                         oCookiedu.Expires = DateTime.Now.AddDays(1)
  86.  
  87.                         ViewState("QID") = e.CommandArgument
  88.                         oCookiedu.Value = e.CommandArgument
  89.                         Response.Cookies.Add(oCookiedu)
  90.                         lbl.Visible = False
  91.  
  92.                         'Insert Records
  93.                         ssql = "Insert into PollResult (pollResultID,pollID,pollAnswerID,IP_address,pollResult_addDate,pollResult_status,websiteID) values (@param1,@param2,@param3,@param4,@param5,@param6,@param7)"
  94.  
  95.                         alIn.Clear()
  96.                         alIn.Add(System.Guid.NewGuid.ToString)
  97.                         alIn.Add(ViewState("QID"))
  98.                         alIn.Add(ViewState("AnswerID"))
  99.                         alIn.Add(Request.ServerVariables("REMOTE_ADDR"))
  100.                         alIn.Add(Date.Now.ToString)
  101.                         alIn.Add("1")
  102.                         'Corp site
  103.                         alIn.Add("25e2f6f0-d842-4457-a613-409c6088fad3")
  104.                         mclas.execute_query(ssql, alIn)
  105.  
  106.                         Response.Write("Day")
  107.                         'Response.Redirect("result_polls.aspx?pollID=" & e.CommandArgument & "")
  108.  
  109.                     Else
  110.                         Response.Write("Day failed")
  111.                         'Response.Redirect("result_polls.aspx?pollID=" & e.CommandArgument & "")
  112.  
  113.                     End If
  114.  
  115.                 End If
  116.  
  117.                 ' multiple vote
  118.             Else
  119.                 oCookiem.Expires = DateTime.Now.AddDays(-1)
  120.                 Response.Cookies.Add(oCookiem)
  121.  
  122.                 ViewState("QID") = e.CommandArgument
  123.                 oCookiem.Value = e.CommandArgument
  124.                 Response.Cookies.Add(oCookiem)
  125.                 lbl.Visible = False
  126.  
  127.                 'Insert Records
  128.                 ssql = "Insert into PollResult (pollResultID,pollID,pollAnswerID,IP_address,pollResult_addDate,pollResult_status,websiteID) values (@param1,@param2,@param3,@param4,@param5,@param6,@param7)"
  129.  
  130.                 alIn.Clear()
  131.                 alIn.Add(System.Guid.NewGuid.ToString)
  132.                 alIn.Add(ViewState("QID"))
  133.                 alIn.Add(ViewState("AnswerID"))
  134.                 alIn.Add(Request.ServerVariables("REMOTE_ADDR"))
  135.                 alIn.Add(Date.Now.ToString)
  136.                 alIn.Add("1")
  137.                 'Corp site
  138.                 alIn.Add("25e2f6f0-d842-4457-a613-409c6088fad3")
  139.                 mclas.execute_query(ssql, alIn)
  140.  
  141.                 Response.Write("Multiple")
  142.                 'Response.Redirect("result_polls.aspx?pollID=" & e.CommandArgument & "")
  143.  
  144.             End If
  145.  
  146.         End If
  147.         If e.CommandName = "Result" Then
  148.             Response.Redirect("result_polls.aspx?pollID=" & e.CommandArgument & "")
  149.         End If
  150.  
  151.     End Sub
  152.  
Dec 22 '10 #1
0 1083

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Enno Middelberg | last post by:
Hi all, I am using mpeg_encode under Linux to generate little movies. The parameter file is generated by a Python script, the last line of which is os.system('mpeg_encode mpeg.par') When I...
4
by: Mario | last post by:
Hello everybody, Does anybody know how i make a script to make a poll? I mean a small poll when you can choose yes or no? -- -------"""------- ---()--- °?----(_)-----?° | Greetz Mario|
0
by: xixi | last post by:
hi, we are using db2 udb v8.1 on win 64 bit with fp3 with type 4 db2jcc.jar driver. when i execute this query , select id, arno01, arcd01, arno16, artx01, armo09, ardy09, arcc09, aryr09,...
3
by: Alexander | last post by:
When i store rule on PC with .NET.SP1 i cant restore them from PC without SP1. An i get this Error: System.Runtime.Serialization.SerializationException: Possible Version mismatch. Type...
6
by: Scott Brady Drummonds | last post by:
Hi, everyone, I was in a code review a couple of days ago and noticed one of my coworkers never used for() loops. Instead, he would use while() loops such as the following: i = 0; while (i...
20
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool...
0
by: jinfeng_Wang | last post by:
I have writen the following souce code : m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_Socket.Blocking = false; try {...
7
by: pbd22 | last post by:
Hi. I really need some advice on fine-tuning a stored procedure that is the meat of the search logic on my site. Customers are allowed to save searches, which dumps the search logic in a table...
1
by: Sunfire | last post by:
Does anybody know how to create an online poll generator? or be able to put me to a place that can help me out?
1
by: christam1 | last post by:
Hi there, I'm creating a PHP/XML-based voting system. There are 24 options for a user to vote from, and ideally I'd like the user to see a picture of each person they vote for. So far, I've managed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.