0% found this document useful (0 votes)
15 views13 pages

5.system Implementation

The document describes the implementation of an online voting system. It includes sample screens like the home page, login options, admin login, candidate registration, voter registration and voting screens. It also provides code samples for admin login, candidate login, candidate registration, voter login, voter registration and the voting functionality. The code uses SQL connections and commands to query and insert user and vote data into databases tables.

Uploaded by

Viswanathan S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views13 pages

5.system Implementation

The document describes the implementation of an online voting system. It includes sample screens like the home page, login options, admin login, candidate registration, voter registration and voting screens. It also provides code samples for admin login, candidate login, candidate registration, voter login, voter registration and the voting functionality. The code uses SQL connections and commands to query and insert user and vote data into databases tables.

Uploaded by

Viswanathan S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

CHAPTER 5 SYSTEM IMPLEMENTATION

5.SYSTEM IMPLEMENTATION

5.1 SAMPLE SCREENS

Fig 5.1.1 Home Page

Fig 5.1.2 Login Options

ONLINE VOTING SYSTEM 32


CHAPTER 5 SYSTEM IMPLEMENTATION

Fig 5.1.3 Admin Login

Fig 5.1.4 Admin Details

ONLINE VOTING SYSTEM 33


CHAPTER 5 SYSTEM IMPLEMENTATION

Fig 5.1.5 Candidate Details

Fig 5.1.6 Voter Details

ONLINE VOTING SYSTEM 34


CHAPTER 5 SYSTEM IMPLEMENTATION

Fig 5.1.7 Candidate Registration

Fig 5.1.8 Candidate Login

ONLINE VOTING SYSTEM 35


CHAPTER 5 SYSTEM IMPLEMENTATION

Fig 5.1.9 Voter Registration

Fig 5.1.3 Voter Login

ssss

ONLINE VOTING SYSTEM 36


CHAPTER 5 SYSTEM IMPLEMENTATION

Fig 5.1.3 Voting

ONLINE VOTING SYSTEM 37


CHAPTER 5 SYSTEM IMPLEMENTATION

5.2 SAMPLE CODING

Admin Login:

Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class Admin
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim sql, sql1 As String
con = New SqlConnection("Data Source=lb3-87;Initial Catalog=login;User
ID=sa;Password=skc")
sql = "select Username from log"
sql1 = "select Password from log"
con.Open()
cmd = New SqlCommand(sql, con)
Dim a As Object = cmd.ExecuteScalar
cmd = New SqlCommand(sql1, con)
Dim b As Object = cmd.ExecuteScalar
If TextBox1.Text = a And TextBox2.Text = b Then
MsgBox("Login Success", MsgBoxStyle.OkOnly)
Server.Transfer("adminhome.aspx")
Else
MsgBox("Login failed", MsgBoxStyle.Exclamation)
End If
End Sub
End Class

ONLINE VOTING SYSTEM 38


CHAPTER 5 SYSTEM IMPLEMENTATION

Candidate Login:

Imports System.Data.Sql
Imports System.Data.SqlClient
Partial Class candidatelogin
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim sql, sql1 As String
con = New SqlConnection("Data Source=lb3-87;Initial Catalog=reg;User ID=sa;Password=skc")
sql = "select candidateid from canreg"
sql1 = "select password from canreg"
con.Open()
cmd = New SqlCommand(sql, con)
Dim a As Object = cmd.ExecuteScalar
cmd = New SqlCommand(sql1, con)
Dim b As Object = cmd.ExecuteScalar
If TextBox1.Text = a And TextBox2.Text = b Then
MsgBox("Login Success", MsgBoxStyle.OkOnly)
Server.Transfer("Voting1.aspx")
Else
MsgBox("Login Failed", MsgBoxStyle.Exclamation)
TextBox2.Text = ""
End If
End Sub
End Class

Candidate Session Id:


Imports System.Data.Sql
Imports System.Data.SqlClient

ONLINE VOTING SYSTEM 39


CHAPTER 5 SYSTEM IMPLEMENTATION

Public Class candidateregister


Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim con As SqlConnection
Dim cmd As SqlCommand
con = New SqlConnection("Data Source=lb3-87;Initial Catalog=reg;User ID=sa;Password=skc")
cmd = New SqlCommand("Select MAX(candidateid)from canreg", con)
Dim res As String
Dim dight As Integer
res = cmd.ExecuteScalar().ToString()
If String.IsNullOrEmpty(res) Then
res = "ECIC0000"
TextBox1.Text = res
End If
res = res.Substring(4)
Int32.TryParse(res, dight)
dight = dight + 1
res = "ECIC" + dight.ToString("D4")
TextBox1.Text = res

Dim a As String
If FileUpload2.HasFile Then
FileUpload2.SaveAs(Server.MapPath(FileUpload2.FileName))
a = "insert into
canreg(candidateid,fname,lname,fathername,gender,dob,addressline1,addressline2,city,state,pinc
ode,phoneno,email,aadhar,certificate,photo,password,confpassword)values('" & TextBox1.Text
& "','" & TextBox14.Text & "','" & TextBox12.Text & "','" & TextBox2.Text & "','" &
RadioButtonList1.SelectedItem.Value & "','" & TextBox3.Text & "','" & TextBox4.Text & "','"
& TextBox5.Text & "','" & DropDownList1.SelectedItem.Value & "','" &

ONLINE VOTING SYSTEM 40


CHAPTER 5 SYSTEM IMPLEMENTATION

DropDownList2.SelectedItem.Value & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" &
TextBox8.Text & "','" & TextBox13.Text & "','" & FileUpload2.FileName & "','" &
TextBox10.Text & "','" & TextBox11.Text & "')"
End If
cmd = New SqlCommand(a, con)
cmd.ExecuteNonQuery()
MsgBox("Registration Success", MsgBoxStyle.OkOnly)
con.Close()
End Sub
End Class

Voter Login:
Imports System.Data.Sql
Imports System.Data.SqlClient
Partial Class Voterlogin
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim sql, sql1 As String
con = New SqlConnection("Data Source=lb3-87;Initial Catalog=reg;User ID=sa;Password=skc")
sql = "select voterid from votreg"
sql1 = "select password from votreg"
con.Open()
cmd = New SqlCommand(sql, con)
Dim a As Object = cmd.ExecuteScalar
cmd = New SqlCommand(sql1, con)
Dim b As Object = cmd.ExecuteScalar
If TextBox1.Text = a And TextBox2.Text = b Then
MsgBox("Login Success", MsgBoxStyle.OkOnly)

ONLINE VOTING SYSTEM 41


CHAPTER 5 SYSTEM IMPLEMENTATION

Server.Transfer("Voting.aspx")
Else
MsgBox("Login Failed", MsgBoxStyle.Exclamation)
TextBox2.Text = ""
End If
End Sub
End Class

Voter Session Id:


Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class Voterregisteration
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim con As SqlConnection
Dim cmd As SqlCommand
con = New SqlConnection("Data Source=lb3-87;Initial Catalog=reg;User ID=sa;Password=skc")
con.Open()
cmd = New SqlCommand("Select MAX(voterid)from votreg", con)
Dim res As String
Dim dight As Integer
res = cmd.ExecuteScalar().ToString()
If String.IsNullOrEmpty(res) Then
res = "ECIV0000"
TextBox1.Text = res
End If
res = res.Substring(4)
Int32.TryParse(res, dight)
dight = dight + 1

ONLINE VOTING SYSTEM 42


CHAPTER 5 SYSTEM IMPLEMENTATION

res = "ECIV" + dight.ToString("D4")


TextBox1.Text = res
Dim a As String
If FileUpload2.HasFile Then
FileUpload2.SaveAs(Server.MapPath(FileUpload2.FileName))
a = "insert into
votreg(voterid,fname,lname,fathername,gender,dob,addressline1,addressline2,city,state,pincode,
phoneno,email,aadhar,photo,password,confpassword)values('" & TextBox1.Text & "','" &
TextBox14.Text & "','" & TextBox12.Text & "','" & TextBox2.Text & "','" &
RadioButtonList1.SelectedItem.Value & "','" & TextBox3.Text & "','" & TextBox4.Text & "','"
& TextBox5.Text & "','" & DropDownList1.SelectedItem.Value & "','" &
DropDownList2.SelectedItem.Value & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" &
TextBox8.Text & "','" & TextBox13.Text & "','" & FileUpload2.FileName & "','" &
TextBox10.Text & "','" & TextBox11.Text & "')"
End If
cmd = New SqlCommand(a, con)
cmd.ExecuteNonQuery()
MsgBox("Registration Success", MsgBoxStyle.OkOnly)
con.Close()
End Sub
End Class

Voting:

Imports System.Data.Sql
Imports System.Data.SqlClient
Partial Class Voting
Inherits System.Web.UI.Page
Protected Sub ImageButton5_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton5.Click
Dim con As SqlConnection
Dim cmd As SqlCommand

ONLINE VOTING SYSTEM 43


CHAPTER 5 SYSTEM IMPLEMENTATION

Dim Sql, sql1, sql2, sql3 As String


con = New SqlConnection("Data Source=LB3-88;Initial Catalog=Voterreg;User
ID=sa;Password=skc")
Sql = "select Max(vote) from lap"
sql1 = "select Max(vote) from pend"
sql2 = "select Max(vote) from mous"
sql3 = "select Max(vote) from phon"
con.Open()
cmd = New SqlCommand(Sql, con)
cmd = New SqlCommand(sql1, con)
cmd = New SqlCommand(sql2, con)
cmd = New SqlCommand(sql3, con)
Dim max As Object = cmd.ExecuteScalar()
RadioButtonList1.SelectedItem.Value = max + 1
con.Close()
End Sub
End Class

ONLINE VOTING SYSTEM 44

You might also like