E Voting
E Voting
1.1 GENERAL
India is a constitutional democracy with a parliamentary system of government, and at the heart of the system is a commitment to hold regular, free and fair elections. These elections determine the composition of the government, the membership of the two houses of parliament, the state and union territory legislative assemblies, and the Presidency and vice-presidency. Elections are conducted according to the constitutional provisions, supplemented by laws made by Parliament. The aim of the project is to create and manage polling and election details. This is a system which enables all citizens to cast their vote online. Increasing the voting percentage across the country is the major goal of this project. People have to visit the booth to cast their vote in the present system across the country. This system is online and hence even people who live out of their home town can also vote. Database of all the eligible citizens and candidates are maintained by the system. Online voting system gathers its own significance since the NRI voting Rights bill have been passed by the parliament on Feb 11 ,2011. . The new law will allow an Indian citizen residing abroad to enroll in voters list and exercise his franchise even if he or she remained away from place of residence in India for more than six months owing to employment, education or otherwise. In the present case the person should be present within the constituency on the day of polling for exercising his right to vote. Thus our project, online voting should enhance the opportunities of voters outside the country to vote for their nation on implementation.
We have a large no of customers from various business domains spread across the country. We are in the technology business to ensure our customers satisfaction, further, promoting our innovative products globally through collaborations and determined to grow global. Focuz Infotech is an ever-expanding IT Consultancy Company promoted by Focuz innovations (Pvt) Ltd, India, backed up by Focuz Group ,established in 1978 , A Rs. 2500 million, highly reputed, multifaceted corporate focused to Information Technology, Automobiles and Tourism. For more information, Plz visit www.focuz.co.in Focuz Infotech started its IT initiatives in the year 1998, initially concentrating on Oracle based solutions and further to UNIX and Linux Technologies in a big way. Focuz Infotech owns world-class 24/7 capable 15000 sq. Ft. Linux Research and Development unit in Kochi, a beautiful Island in Kerala, the God's own country.
1.3.1. LINUX
Linux is an operating system, a software program that controls your computer. Most vendors load an operating system onto the har d drive of a PC before delivering the PC. Linux is distinguished from many popular operating systems in three important ways: Linux is a cross-platform operating system that runs on many computer models. Only UNIX, an ancestor of Linux, rivals Linux in this respect.Linux is free, in two senses. First, you may pay nothing to obtain and use Linux. On the other hand, you may choose to purchase Linux from a vendor who bundles Linux with special documentation or applications, or who provides technical support. However, even in this case, the cost of Linux is likely to be a fraction of what you'd pay for another operating system. So, Linux is free or nearly free in an economic sense.
ADVANTAGES OF LINUX
Linux source code is freely distributed. Tens of thousands of programmers have reviewed the source code to improve performance, eliminate bugs, and strengthen security. No other operating system has ever undergone this level of review. This Open Source design has created most of the advantages listed below.
Linux has the best technical support available. Linux is supported by commercial distributors, consultants, and by a very active community of users and developers. In 1997, the Linux community was awarded InfoWorld's Product of the Year Award for Best Technical Support over all commercial software vendors. Linux has no vendor lock-in. The availability of source code means that every user and support provider is empowered to get to the root of technical problems quickly and effectively. This contrasts sharply with proprietary operating systems, where even top-tier support providers must rely on the OS vendor for technical information and bug fixes. Linux runs on a wide range of hardware. Most Linux systems are based on standard PC hardware, and Linux supports a very wide range of PC devices. However, it also supports a wide range of other computer types, including Alpha, Power PC, 680x0, SPARC, and Strong Arm processors, and system sizes ranging from PDAs Linux has the tools and applications you need. Programs ranging from the market-dominating Apache web server to the powerful GIMP graphics editor are included in most Linux distributions. Free and commercial applications meet are available to meet most application needs. Linux interoperates with many other types of computer systems. Linux communicates using the native networking protocols of Unix, Microsoft Windows 95/NT, IBM OS/2, Netware, and Macintosh systems and can also read and write disks and partitions from these and other operating systems. Linux has a low total cost of ownership. Although the Linux learning curve is significant, the stability, design, and breadth of tools available for Linux result in very low ongoing operating costs. Linux: all for one and one for all?? All changes one makes in Open Source software will benefit each and everyone, all over the world. Without exceptions or constraints.
1.3.2. JAVA
Java is an object oriented, platform independent programming language, which has become inseparably linked with the online environment of the internet. Java had a profound effect on the internet. The reason for this is quite simple. Java expands the universe of objects that can move about freely in cyberspace. Java achieves security by confining a java program to the java execution environment and not allowing it access to other parts of the computer. Java provides an elegant and efficient mechanism for attaining portability. The java virtual machine specification defines JVM as: An imaginary machine that is implemented by emulating it in software on a real machine. Code for the JVM is stored in the .class files, each of which contains code for at most one public class. Its represented as in fig1. The java virtual machine specification provides the hardware platform specifications to which we compile all java technology codes. This software enables the Java software to be platform independent because the compilation is done for a generic machine, known as the JVM.
Sourcecode2.java
Sourcecocde2.class
UNIX JVM
DOS JV M
Java OS
Request Response
RV SE ET L
The Java Script is a commonly used scripting language for HTML pages. The scripting languages are mainly used for client side validation purpose. As we know the scripting statements are sent to the client machine and executed there during the client operations, it reduces the work load of server. The other features are: It has procedural capabilities, Platform independent Low disc space needed Easy debugging and testing
1.3.5 HTML
It is a language used for the specification of structural markup. HTML give the web authors the means to publish online documents with headings,texts,tables,lists,photos,etc.HTML is used in our program to create forms in the server side for entering, updating and viewing the server applications in a user friendly environment.
1.3.6 JDBC
JDBC is a Java API for executing SQL statements. It consists of classes and interfaces written in the Java Programming language. JDBC provides a standard API tool for database developers and make s it possible to write database applications using a pure Java API. Using JDBC, it is easy to send SQL statements to virtually any relational database. One can write a single program using JDBC API, and the program will be able to send SQL statements to the appropriate database. The two tier jdbc modelis as given below:
JDBC makes it possible to do three things as follows: Establish a connection with database Send SQL statements. Process the results.
1.3.6 MYSQL
MySQL provides our small, medium and large enterprise customers with affordable, open access to their web data warehouses. MySQL allows us to offer our System Administrator low cost, low maintenance database solution for applications without sacrificing power, performance or scalability. Benefits of MySQL are as follows: up. Its table format does not vary between releases It has cleanly separated table handler modules and can mix access to different type of It seems to be developed iteratively, and the features are very stable when they ship It is a relational database. Over the past several years, this relational database management systems have become the most widely accepted way to manage data. It offers benefits such as: Easy to access data Flexibility in data modeling Reduced data storage and redundancy Independence of physical storage and logical data design A high level data manipulation language Easy to maintain & upgrade, does not have a slew of administrative tasks to put
tables. them.
REQUIREMENT SPECIFICATION
10
Requirement Specification is the part of the project which gives the details about the hardware and software requirements of our project. It also details the features of the programming language used.
11
12
3. SYSTEM ANALYSIS
System analysis is the process of gathering and interpreting facts, diagnosing problems and the information to recommended improvements on the system. System analysis is a problem solving activity that requires intensive communication between the system users and system developers. System analysis or study is an important phase of any system development process. The system is studied to the minutest detail and analyzed. The system analyst plays the role of the interrogator and dwells deep into the working of the present system. The system is viewed as a whole and the input to the system are identified. The outputs from the organizations are traced to the various processes. A detailed study of the process must be by various techniques like interviews, questionnaires etc. The data collected by these sources must be scrutinized to arrive to a conclusion. The conclusion is an understanding of how the system functions. This system is called existing system. Now the existing system is subjected to close study and problem areas are identified. The designer now functions as a problem solver and tries to sort out difficulties that the enterprise faces. The solutions are given as proposals. The proposal is then weighed with the existing system analytically and the best one is selected. The proposal is presented to the user for an endorsement by the user .The proposal is reviewed on user request and suitable changes are made. This is loop that ends as soon as the user is satisfied with proposal.
13
The government to do this process manually wastes a lot of time and money. Thus the present system proves itself to be an inefficient one. The existing system is not web based. The user or person must want to go to the polling station for casting their votes.
Structured
System
Analysis and Design Method SSADM. The sponsor of the project and the end users will need to be brief and consulted through out all stages of a systems evolution. With a data flow diagram users are able to visualize how the system will operate, what the system will accomplish, and how the system will be implemented. The old systems data flow diagrams can be drawn up and compared with new systems data flow diagrams to draw comparisons to implement a more efficient system. Diagram
Elements of a DFD
There are 4 key elements in a Data Flow diagram, Processes, Data Flows, Data stores, and external entities. SYMBOLS DESCRIPTION EXTERNAL ENTITIES (INPUT/OUTPUT)
PROCESSES
DATAFLOWS
DATA STORES
Table3.1.Elements of DFD
15
The Process entity identifies a process taking place, it must have atleast one input and output. A process with no input is known as miracle process. An output is a black hole process. Each process has the following: A Number,A Name (verb phrase),A Description,At least one input,At least one output The Data Flow entity identifies the flow of data between processes, data stores and external entities. A data flow cannot connect an external entity to a data source, at least one connection must be with a process. There are also physical flows, i.e. those that use a physical medium, like a membership card. Each data flow has the following: A name (Noun),A Description ,One or more connection to a process The Data Store entity identifies stores of data, both manual and electronic. Electronic or digital stores are identified by the letter D, and manual filing systems by the letter M. Each data store has the following: A numberA name,A description, One or more input data flows,One or more output data flows The External Entity identifies external entities which interact with the system, usually clients but can be within the same entity, e.g. the same doctor shown twice on the same diagram can be identified by a horizontal line in the top left corner of the symbol. Each external entity has the following: A Name (Noun),A Description
16
Preliminary or general design: In the preliminary or general design, the features of the new system are specified. The costs of implementing these features and benefits to be derived are estimated. If the project is still considered to be feasible, we move to detailed design stage. Structure or detailed design: In the detailed design stage, computer oriented work begins in the earnest. At this stage, the design of the system becomes more structured. Structured design is a blue print of a computer system solution to a given problem having the same components and inter- relationship among the same components as the original problem. Input, output and processing specifications are drawn up in detail .In the design stage, the programming language and the platform in which the new system will run are also decided. There are several tools and techniques used for designing. Simple designs are easily understood, easily built, and easily tested. Simplicity is the most important criteria of a design. Other design criteria include the following: Documentation: A good design always comes with a set of well-written documents. Testability: In a good design, every requirement is testable. A design that cannot be easily tested against its requirements is not acceptable design. Structure: A good design presents hierarchical structure that makes logical use of control policies among components. Modularity: A good design is modular and exhibits the properties of high cohesiveness and low coupling. Representation: A good design should be easily communicated to all interested parties through appropriate abstraction and representation. Reusability: a good design should be repeatable and reusable.
Candidate List
This facilitates the voter to view the candidate names, the constituency name, their symbol and their party name.
Vote
This provides the voter with a list of candidate with in his/her constituency along with selection option (radio button) to select the preferred candidate from the list. If the voting date is before termination date, the vote goes valid else goes invalid.
View Results
This provides graphical and user friendly representation of the votes obtained by each candidate. It includes the percentage of the votes obtained by each candidate. But the result can be viewed only after the termination date of the election.
Logout
This provides an option for the voter to quit the session ,while in the voter home page.
ADMINISTRATOR MODULE
18
Administrator interface consists of a login name and unique password using which admin can login into the Online Voting System. Administrator has the main control of the system. By logging into the page it can perform the following tasks. Add Candidate Here the admin can add the list of candidates in the election. It includes candidates name, address.gender,party, party symbol etc. The candidates will be added to the list only after completing the procedures.
Add Voter Here the voters can be added to the database. The voters have also the privilege to check the voters list from the homepage. The voters details includes name, address, gender, age, constituency, image etc. Add Election Here the election to be conducted is selected. To add an election the constituency should be selected and termination date of election should be specified. Add Constituency The constituency that is going to conduct election should be selected. Voters List Here we can view the voters list. Each constituency will be having separate voters list. Candidate List The list of candidates participating in the election can be seen. It includes the candidates name, party name and party symbol.
Voting Structure
Here the eligible voters who are permitted to login to the system can utilize the right to vote. Each voter can register a single vote to a candidates favour in his/her constituency. The security measures taken within the system prevents them from exercising their votes again i.e. the second vote by the same user goes invalid. The starting and ending dates of the election are specified by the administrator. The user must have an identity card and he must be in voters list.
Voters Registration
The registration procedure of all the eligible voters .This registration process is done by the administrator. According to voters database each voter is provided with a unique identification codes which includes username and password. The details of the voters include username, password, name, address, gender, constituency, image etc.With the voter registration, thus producing the voter list with the given information of the voters. The voter list can be viewed by anyone accessing the webpage. The admin can view the voter list with in his homepage.
Candidate Registration
The registration of the candidates in each constituency is done by the administrator. The details of the candidate includes name, address, gender ,his/her constituency, party and image. With the candidate registration, thus producing the candidate list with the given information of the candidates. The candidate list can be viewed by admin and the vote within their respective homepages. According to candidates database (manual) each details of the candidates are stored in database controlled by the admin including candidates details.
clicks the RESULT link, before the termination date of the election, Result not Published yet Message will be displayed. The result comes with their party symbol on the top of the graph representing the percentage of vote obtained by each candidate.
3.4.1.1 DATA FLOW DIAGRAMS Fig 3.1 to Fig 3.4.2 shows various levels of DFDs in our project entitled Online Voting System.
Level-0
Fig 3.1:Level-0-DFD
Level-1
21
22
Level-2
Admin
Election Master
23
Candidate Name
24
Voter
25
There are different forms of normal forms First normal form(1NF) Second normal form(2NF) Third normal form(3NF) Boyce code normal form(BCNF) Fourth Normal form(4NF) Fifth Normal Form(5NF)
TABLES
26
FIELD Pkicandidate id Fkilogin id Candidate name Candidate address cangender candidateofbirth cansymbol fkiconstituencyid phone emailid candesc status party
TYPE int(11) int(11) varchar(40) varchar(40) varchar(10) Date varchar(30) int(11) bigint(20) varchar(15) varchar(30) Varchar(10) varchar(20)
KEY Primary
Foreign
Table 3.4.2 represents Constituency FIELD pksiconstituencyid fkilocationid constituencyname candidatenumber voternumber TYPE int(11) int(11) varchar(20) int(11) int(11) KEY Primary Foreign
Table 3.4.4 represents Electionmaster FIELD Pkielectionmasterid Electionname Fkiconstituencyid Terminationdate Table 3.4.5 represents Location FIELD Pkilocationid Locationname Voterno TYPE int(11) varchar(40) int(11) KEY Primary TYPE int(11) varchar(30) int(11) date Foreign KEY Primary
Table 3.4.6 represents Login FIELD Pkiloginid Username Password Role Status TYPE int(11) varchar(20) varchar(20) varchar(20) varchar(20) KEY Primary
Table 3.4.7 represents Result FIELD Pkresultid fkicandidateid Count TYPE int(11) int(11) int(11) 28 KEY Primary Foreign
Termdate
Date
Table 3.4.18 represents Voterreg FIELD Pkivoterid Fkiloginid Votername voteraddress Votergender Voterofbirth Voterimg fkiconstituencyid Fkilocationid Phone Emailed Voterid Status Age TYPE int(11) int(11) varchar(40) varchar(40) varchar(10) Date varchar(30) int(11) int(11) Bigint(20) varchar(30) int(11) varchar(10) int(11) Foreign Foreign KEY Primary
29
of tests like responsiveness, its value, stress and security are performed before the system is ready for user acceptance testing. System testing follows the logical conclusion that is all part of the system are tested and found to be working properly under all kinds of situations, and then the system is achieving its goal of processing the data perfectly according to user rules and requirements.The different types of testing are given below.
package. Interfacing errors have been uncovered and correct and final series of test, ie validation begins. Validation test van is defined with a simple definition that validation succeeds when the software functions in a manner that can be reasonably accepted by the customer. Thus we have successfully done validation testing. 4.1.3 OUTPUT TESTING After performing the validation testing, next is the output testing of the proposed system. The system cannot the output be useful if it not produce required output. The output o/p displayed by the system under consideration will be compared with the user needs. Here format is considered in 2 ways, screen format and printed format. The for the hardcopy the o/p format on the screen is found to be correct as the format was defined in the design phase according to user needs. As comes according to the
31
specification
requested
in any
4.1.4 USER ACCEPTANCE TESTING It is the key for success of any system. The system under consideration is tested for user acceptance by constantly keeping in touch with perspective system at the time of development and making changes whenever required. This is done with regarding to the input screen design and output screen design. Thus we have successfully done user acceptance testing.
Test plans
32
4.2.1:Test plans
The implementation of a computer based system requires that the test data can be prepared and the system and its elements be tested in a structured manner.
4.2.2:Training
The purpose of training is to ensure that all the personnel who are to be associated with the computer based system possesses necessary knowledge skills.
4.2.3:Equipment installation
Equipment vendors can provide specifications for equipment installation. They usually work with projects equipment installation team is planning for adequate space, power and light, and a suitable environment. After a suitable site has been completed, the computer equipment can be installed.
4.2.4:Conversion
It is the processes of performing all of the operations that result directly in turnover of the new system to the user. Conversion has two parts:1. The creation of a conversion plan at the start of the development phase and the implementation of the plan throughout the development phase. 2. The creation of a system change over plan at the end of the development phase and the implementation of the plan at the beginning of operation phase.
33
34
5.1 CONCLUSION
By doing this project we were able to bring a new system for online national voting for our country. With the advent of technology and Internet in our day to day life, we were able to offer advanced voting system to voters both in the country and outside through our Online voting system. Top 4 Reasons to Move to the Online Voting Platform 1. Efficient and Cost Effective The system offers significant cost benefits over paper elections in a vote to vote comparison. It saves an organization the cost of creating, printing and postage, since everything can be handled electronically. Online elections reduce the use of paper and the amount of work for both the organization, as well as voters. 2. Intelligent The Online Voting Platform offers intelligent ballots, smart checklist features, vote tallying, tabulation and reporting. These functions are automatic and do not need to be assigned to personnel in-house. Additionally, it allows administrators to create rules on ballots so that voters cannot cast invalid votes, nor do they need to be checked while counting. 3. Save Time and Resources Online voting system drastically reduces the time required to set up and conduct elections. There is no excess time required to create paper ballots, set up paper ballots for printing, wait for the printing to be completed, or wait for ballots to be filled out and returned. 4. Easy and convenient The Online Voting Platform offers the easiest and most convenient method for administrators and voters alike. For administrators, the process of setting up a ballot and conducting an election is simple and manageable. The other advantages that the system offers are: Efficient data storage. Accuracy, real-time response and user friendliness. Intelligent Management
35
The password used by the user to vote is provided by the administrator. In the future the user can be given the privilege of changing the password. So it helps to increase the security of the system. The other two methods that can be used are cornea detection and fingerprinting. But here the problem is that it decreases the scope of the platform because these systems need some electronic components to implement. So it will avoid the users privilege to cast the votes at their fingertips. But it can guarantee that fake voting will be impossible. The OVS system can be used for different elections. In this project we had done election for a single loksabha constituency. But this same system can be used in future for conducting different elections like local body, legislative assembly, loksabha elections for many constituencies and wards. For eg: In Kerala there are more than 10000 panchayat wards. The whole election can be conducted using this single platform. The only requirement is that we need to create the whole voters database. Results update through SMS. In future we can add an SMS query also. ie we wil get the result updates at the time of counting. To receive the SMS we need to register with our mobile number in the site.
36
BIBLIOGRAPHY
37
BIBLIOGRAPHY
Pankaj Jalote. An Integrated Approach to Software Engineering , Third Edition, Narosa Publications. A case study approach whereby a project is Developed through the course of the book, illustrating different activities of Software development Herbert Schildt Java 2: The Complete Reference, Fifth Edition. This book covers all aspect of java programming language. Educational Services Study Guide, Learn the basics of JAVA. Sun Micro Systems publications. Larne Pekowsky, Java Server Pages Covers 2.0,Second Edition ,Pearson Education.-contains all the information necessary to start writing JSP.
38
APPENDIX -A
39
SCREENSHOTS
Fig A.1 : Screenshot of the index page A.2 ADMIN HOME PAGE
40
41
42
43
44
45
APPENDIX B
DBCONNECTION
package com; import java.sql.*; public class DBconnection { Connection con; ResultSet rs=null; public DBconnection() { try { Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost/kr","root",""); } catch(Exception e) { System.out.println(e); } } public ResultSet loginValidate(String name,String password) { try {
46
PreparedStatement ps=con.prepareStatement("select * from login where username=? and password =? and status=?"); ps.setString(1,name); ps.setString(2,password); ps.setString(3,"accepted"); rs=ps.executeQuery(); } catch(Exception e) { System.out.println(e); } return rs; } public void addCandidate(String canusrname,String canpassword,String canname,String canaddress,String cangender,String candob,String constituency,String canphno,String canemailid,String canddescription,String party,String cansymbol) { int constituencyid=Integer.parseInt(constituency); ResultSet rs = null; int id=0; try { PreparedStatement ps=con.prepareStatement("insert into login(username,password,role) values(?,?,?)"); ps.setString(1,canusrname); ps.setString(2,canpassword); ps.setString(3,"candidate"); ps.executeUpdate(); PreparedStatement ps1=con.prepareStatement("select max(pkiloginid) as pkiloginid from login"); rs=ps1.executeQuery(); while(rs.next()) { id=rs.getInt("pkiloginid"); } PreparedStatement ps2=con.prepareStatement("insert into candidatereg(fkiloginid,candidatename,candidateaddress,cangender,candateofbirth,fkicon stituencyid,phone,emailid,candesc,status,party,cansymbol) values(?,?,?,?,?,?,?,?,?,?,?,?)"); ps2.setInt(1,id); ps2.setString(2,canname); ps2.setString(3,canaddress); ps2.setString(4,cangender); ps2.setString(5,candob); ps2.setInt(6,constituencyid); ps2.setString(7,canphno); ps2.setString(8,canemailid); ps2.setString(9,canddescription); ps2.setString(10,"accepted"); ps2.setString(11,party); ps2.setString(12,cansymbol); ps2.executeUpdate(); PreparedStatement ps3=con.prepareStatement("select max(pkicandidateid) as pkicandidateid from candidatereg"); rs=ps3.executeQuery(); while(rs.next()) { id=rs.getInt("pkicandidateid"); } PreparedStatement ps4=con.prepareStatement("insert into result(fkicandidateid,count) values(?,?)"); ps4.setInt(1,id); ps4.setInt(2,0); ps4.executeUpdate();
47
PreparedStatement ps5=con.prepareStatement("update constituency set candidatenumber=candidatenumber+1 where pksiconstituencyid=?"); ps5.setInt(1,constituencyid); ps5.executeUpdate(); } catch (Exception e) { System.out.println(e); } } public void addVoter(String voterusrname,String voterpassword,String votername,String voteraddresss,String dateofbirth,String location,String constituency,String emailid,String phno,String voterid,String gender,String age,String voterimg) { int locationid=Integer.parseInt(location); int constituencyid=Integer.parseInt(constituency); int voterid1=Integer.parseInt(voterid); int age1=Integer.parseInt(age); ResultSet rs = null; int id=0; try { PreparedStatement ps=con.prepareStatement("insert into login(username,password,role) values(?,?,?)"); ps.setString(1,voterusrname); ps.setString(2,voterpassword); ps.setString(3,"voter"); ps.executeUpdate(); PreparedStatement ps1=con.prepareStatement("select max(pkiloginid) as pkiloginid from login"); rs=ps1.executeQuery(); while(rs.next()) { id=rs.getInt("pkiloginid"); } PreparedStatement ps2=con.prepareStatement("insert into voterreg(fkiloginid,votername,voteraddress,votergender,voterofbirth,fkiconstituencyid, fkilocationid,phone,emailid,voterid,status,age,voterimg) values(?,?,?,?,?,?,?,?,?,?,?,?,?)"); ps2.setInt(1,id); ps2.setString(2,votername); ps2.setString(3,voteraddresss); ps2.setString(4,gender); ps2.setString(5,dateofbirth); ps2.setInt(6,constituencyid); ps2.setInt(7,locationid); ps2.setString(8,phno); ps2.setString(9,emailid); ps2.setInt(10,voterid1); ps2.setString(11,"accepted"); ps2.setInt(12,age1); ps2.setString(13,voterimg); ps2.executeUpdate(); PreparedStatement ps3=con.prepareStatement("update location set voterno=voterno+1 where pkilocationid=?"); ps3.setInt(1,locationid); ps3.executeUpdate(); PreparedStatement ps4=con.prepareStatement("update constituency set voternumber=voternumber+1 where pksiconstituencyid=?"); ps4.setInt(1,constituencyid); ps4.executeUpdate(); } catch (Exception e) {
48
System.out.println(e); } } public void addLocation(String locationname) { try { PreparedStatement ps=con.prepareStatement("insert into location(locationname) values(?)"); ps.setString(1,locationname); ps.executeUpdate(); } catch (Exception e) { System.out.println(e); } } public void addConstituency(String location,String constituencyname) { int locationid=Integer.parseInt(location); try { PreparedStatement ps=con.prepareStatement("insert into constituency(fkilocationid,constituencyname) values(?,?)"); ps.setInt(1,locationid); ps.setString(2,constituencyname); ps.executeUpdate(); } catch (Exception e) { System.out.println(e); } } public ResultSet listVoters() { try { PreparedStatement ps=con.prepareStatement("select * from voterreg,constituency where pksiconstituencyid=fkiconstituencyid"); rs=ps.executeQuery(); } catch (Exception e) { System.out.println(e); } return rs; } public void addElectionAction(String electionname,String constituency,String terminationdate) { System.out.println(electionname+constituency+terminationdate); int constituencyid=Integer.parseInt(constituency); try { PreparedStatement ps=con.prepareStatement("insert into electionmaster(electionname,fkiconstituencyid,terminationdate) values(?,?,?)"); ps.setString(1,electionname); ps.setInt(2,constituencyid); ps.setString(3,terminationdate); ps.executeUpdate(); PreparedStatement ps1=con.prepareStatement("update result set termdate=?"); ps1.setString(1,terminationdate); ps1.executeUpdate();
49
} catch(Exception e) { System.out.println(e); } } public ResultSet listElectionMaster(int constituency) { try { PreparedStatement ps=con.prepareStatement("select * from electionmaster where fkiconstituencyid=? and terminationdate > '(select curdate())'"); ps.setInt(1,constituency); rs=ps.executeQuery(); } catch (Exception e) { System.out.println(e); } return rs; } public ResultSet getVotersCount() { try { PreparedStatement ps=con.prepareStatement("select count(*) from voterreg"); rs=ps.executeQuery(); } catch (Exception e) { System.out.println(e); } return rs; } public void vote(String electionname,String candidate,int logid) { int candidateid=Integer.parseInt(candidate); int electionid=Integer.parseInt(electionname); try { PreparedStatement ps=con.prepareStatement("insert into electiondetails(fkivoterid,fkielectionmasterid) values(?,?)"); ps.setInt(1,logid); ps.setInt(2,electionid); ps.executeUpdate(); PreparedStatement ps1=con.prepareStatement("update result set count=count+1 where fkicandidateid=?"); ps1.setInt(1,candidateid); ps1.executeUpdate(); } catch(Exception e) { System.out.println(e); } } }
50
51