All pastes #459763 Raw Edit

DaTaco

public text v1 · immutable
#459763 ·published 2007-04-26 17:48 UTC
rendered paste body
#By: I-Vote Corporation
#Version: 0.13
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"
package require sqlite3

#global variables
global zipList
global candidateList
global allElectionList
global electionSignal
global ballotSignal
global candidate
set ballotSignal 0
sqlite3 db ivote.db

#declare the prodcedure for Main Screen
proc mainMenuScreen {} {

	#make the buttons
	button .vote -text "Click to\n Vote" -command {reset;voterLoginScreen} -font defaultfont -justify center -background steelblue4 -foreground white
	button .register -text "Click to\n Register" -command {reset;registrationScreen} -font defaultfont -justify center -background steelblue4 -foreground white
	button .configuration -text "Configuration" -command {reset;configLoginScreen } -font labelfont -background steelblue4 -foreground white

	#make the labels
	label .welcome -text "Florida Electronic Voting Machine" -font titlefont -background lightsteelblue2	
	label .or -text "or" -font defaultfont -background lightsteelblue2

	#display buttons
	place .vote -relx 0.40 -rely 0.35 -relwidth 0.2
	place .register -relx 0.40 -rely 0.52 -relwidth 0.2
	place .configuration -relx 0.01 -rely 0.95

	#display the labels
	pack .welcome -anchor n
	place .or -relx 0.491 -rely 0.459

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

#declare the procedure for Reset
proc reset {} {
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Button"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Label"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Radiobutton"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Entry"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Spinbox"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Text"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Listbox"} {
			destroy $w
		}
	}
	foreach w [winfo children .] {
		if {[winfo class $w] eq "Scrollbar"} {
			destroy $w
		}
	}
}

#declare the procedure for config login
proc configLoginScreen {} {

	#create labels
	label .title -text "Configuration Login" -font titlefont -background lightsteelblue2
	label .userName -text "User Name" -font defaultfont -background lightsteelblue2
	label .passWord -text "Password" -font defaultfont -background lightsteelblue2

	#create entry boxes	
	entry .userNameEntry -width 11 -font defaultfont -textvariable userName
	entry .passWordEntry -width 11 -font defaultfont -show * -textvariable passWord

	#creating buttons
	button .submit -text "Submit" -font defaultfont -command {OfficialconfigcheckLogin $userName $passWord; unset userName; unset passWord} -background steelblue4 -foreground white
	button .back -text "Back" -font defaultfont -command {reset;mainMenuScreen} -background steelblue4 -foreground white

	#display objects etc
	pack .title -anchor n
	place .userName -relx 0.30 -rely 0.30
	place .passWord -relx 0.30 -rely 0.40 
	place .submit -relx .4 -rely .77 -relwidth 0.2
	place .userNameEntry -relx 0.45 -rely 0.30
	place .passWordEntry -relx 0.45 -rely 0.40
	place .back -relx .02 -rely 0.91 -relwidth 0.15

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc OfficialconfigcheckLogin {userName passWord} {
	if {[db exists {SELECT * FROM ElectionOfficial WHERE username = $userName AND passWord = $passWord}]} {
   		tk_messageBox -message "Login Sucessful" -type ok
		reset
		configScreen
	} else {
		set answer [tk_messageBox -message "Incorrect Username/Password. Try Agian?" -type yesno]
		switch -- $answer {
			yes { }
			no {reset;mainMenuScreen}
		}
	}
}

#declare the procedure for Configuration
proc configScreen {} {
	#create label
	label .welcome -text "Election Configuration" -font titlefont -background lightsteelblue2 

	#create buttons
	button .electTally -text "Election Tally" -font defaultfont -command {reset;tallyScreen} -background steelblue4 -foreground white
	button .admConfig -text "Administration Configuration" -font defaultfont -command {reset;adminLoginScreen} -background steelblue4 -foreground white
	button .removeVoter -text "Remove Voter" -font defaultfont -command {reset;removeVoterScreen} -background steelblue4 -foreground white
	button .createElec -text "Create Election" -font defaultfont -command {reset;addElectionScreen} -background steelblue4 -foreground white
	button .createBallot -text "Create Ballot" -font defaultfont -command {reset;set allElectionList {};createElectionList;createBallotScreen} -background steelblue4 -foreground white
	button .shutDown -text "Shutdown" -font defaultfont -command shutDownCheck -background steelblue4 -foreground white
	button .back -text "Back" -command {reset;mainMenuScreen} -font defaultfont -background steelblue4 -foreground white

	#display label
	pack .welcome -anchor n

	#display buttons
	place .electTally -relx 0.31 -rely 0.2 -relwidth 0.35
	place .admConfig -relx 0.31 -rely 0.3 -relwidth 0.35
	place .back -relx .02 -rely 0.91 -relwidth 0.15
	place .removeVoter -relx 0.31 -rely 0.4 -relwidth 0.35
	place .createElec -relx 0.31 -rely 0.5 -relwidth 0.35
	place .createBallot -relx 0.31 -rely 0.6 -relwidth 0.35
	place .shutDown -relx 0.31 -rely 0.7 -relwidth 0.35

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

#check to see if they really want to shut down
proc shutDownCheck {} {
	set answer [tk_messageBox -message "Are you sure you want to Shutdown the Voting Software?" -type yesno -icon question]
	switch -- $answer {
	    yes exit
	    no {reset;configScreen}
	}
}

#procedure for remove voter screen
proc removeVoterScreen {} {
	#create labels
	label .title -text "Remove Voter" -font titlefont  -background lightsteelblue2
	label .ssn -text "Social Security Number:" -font defaultfont -background lightsteelblue2
	label .voterInfo -text "Voter Information:" -font defaultfont -background lightsteelblue2 
	label .name -text "Name:" -font defaultfont -background lightsteelblue2
	label .address -text "Address:" -font defaultfont -background lightsteelblue2

	entry .ssnText1 -font defaultfont -width 3 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<4}} -textvariable SSN1
	entry .ssnText2 -font defaultfont -width 2 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<3}} -textvariable SSN2
	entry .ssnText3 -font defaultfont -width 4 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<5}} -textvariable SSN3

	#create buttons
	button .back -text "Back" -command {reset; configScreen} -font defaultfont -background steelblue4 -foreground white
	button .findVoter -text "Find Voter" -font defaultfont -command {findVoter $SSN1 $SSN2 $SSN3} -background steelblue4 -foreground white
	button .deleteVoter -text "Delete Voter" -font defaultfont -command {deleteVoter $SSN1 $SSN2 $SSN3} -background steelblue4 -foreground white

	#display labels
	pack .title -anchor n
	place .ssn -relx .1 -rely .2
	place .ssnText1 -relx .4 -rely .2
	place .ssnText2 -relx .48 -rely .2  
	place .ssnText3 -relx .55 -rely .2
	place .voterInfo -relx .1 -rely .4
	place .name -relx .24 -rely .5 
	#place .nameText -relx .34 -rely .5
	place .address -relx .22 -rely .6
	#place .addressText -relx .3 -rely .6

	#display buttons
	place .back -relx .3 -rely 0.9 -relwidth .2
	place .findVoter -relx .65 -rely .18
	place .deleteVoter -relx .53 -rely .9 -relwidth .2

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc findVoter {SSN1 SSN2 SSN3} {

	if {[db exists {SELECT * FROM Voter WHERE SSN1 = $SSN1 AND SSN2 = $SSN2 AND SSN3 = $SSN3}]} {
		db eval {SELECT * FROM Voter WHERE SSN1 = $SSN1 AND SSN2 = $SSN2 AND SSN3 = $SSN3} {
			set votername [concat $FirstName $SuffixName $MiddleName $LastName] 
			set voteraddress [concat $Street $Apt $City $State]
			label .addressText -text $voteraddress -font confirmfont -background lightsteelblue2
			label .nameText -text $votername -font confirmfont -background lightsteelblue2
			place .nameText -relx .33 -rely .502	
			place .addressText -relx .33 -rely .604
		}
	} else {
		tk_messageBox -message "Voter doesn't exist" -type ok
	}

} 

proc deleteVoter {SSN1 SSN2 SSN3} {
	destroy .nameText
	destroy .addressText

	if {[db exists {SELECT * FROM Voter WHERE SSN1 = $SSN1 AND SSN2 = $SSN2 AND SSN3 = $SSN3}]} {
		db eval {DELETE FROM Voter WHERE SSN1 = $SSN1 AND SSN2 = $SSN2 AND SSN3 = $SSN3} {
			tk_messageBox -message "Voter Deleted" -type ok	
			label .addressText -text "" -font confirmfont
			label .nameText -text "" -font confirmfont
			place .nameText -relx .34 -rely .5	
			place .addressText -relx .34 -rely .65
		}
		} else {
   			tk_messageBox -message "Voter doesn't exist" -type ok
		}
}

#declare procedure for Add Election Screen
proc addElectionScreen {} {
	global zipList

	#create labels/buttons/etc
	label   .title -text "Add Election" -font titlefont -background lightsteelblue2
	label   .zipCode -text "Zipcode" -font defaultfont -background lightsteelblue2
	label	 .startDate -text "Start Date" -font defaultfont -background lightsteelblue2
	label   .finishDate -text "Finish Date" -font defaultfont -background lightsteelblue2
	label   .electionName -text "Name of Election" -font defaultfont -background lightsteelblue2
	entry   .zipFirstText -font defaultfont -width 5 -textvariable zipFirst -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<6}}
	spinbox .startMonthText -from 1 -to 12 -font defaultfont -width 2 -textvariable startMonth
	spinbox .startDayText -from 1 -to 31 -font defaultfont -width 2 -textvariable startDay
	spinbox .startYearText -from 2007 -to 2060 -font defaultfont -width 4 -textvariable startYear
	spinbox .finishMonthText -from 1 -to 12 -font defaultfont -width 2 -textvariable finishMonth
	spinbox .finishDayText -from 1 -to 31 -font defaultfont -width 2 -textvariable finishDay
	spinbox .finishYearText -from 2007 -to 2060 -font defaultfont -width 4 -textvariable finishYear
	entry   .electionNameText  -font defaultfont -width 16 -textvariable electionName
	label   .startTime -text "MM/DD/YY" -font labelfont -background lightsteelblue2 
	label   .finishTime -text "MM/DD/YY" -font labelfont -background lightsteelblue2
	listbox .zipList -height 7 -width 12 -font defaultfont -listvariable zipList -yscrollcommand \
		".scroll set"
	scrollbar .scroll -command {.zipList yview}
	label   .zipListText -text "List of Zip Codes for This Election" -font labelfont -background lightsteelblue2
	button .back -text "Back" -command {reset; configScreen} -font defaultfont -background steelblue4 -foreground white
	button .createElec -text "Create Election" -font defaultfont -command {reset;confirmElectionScreen \
		$electionName $startMonth $startDay $startYear $finishMonth $finishDay $finishYear $zipList; } -background steelblue4 -foreground white
	button .addZipCode -text "Add Zip Code" -font labelfont -command {addZipCodeBox $zipFirst; \
		set zipFirst {};} -background steelblue4 -foreground white

	#display label
	pack  .title -anchor n
	place .zipCode  -relx 0.23 -rely 0.55
	place .startDate -relx 0.20 -rely 0.35
	place .finishDate -relx .19 -rely .45
	place .electionName -relx .13 -rely .25
	place .zipFirstText  -relx 0.34 -rely 0.55
	place .startMonthText -relx .34 -rely .35
	place .startDayText -relx .40 -rely .35
	place .startYearText -relx .46 -rely .35
	place .finishMonthText -relx .34 -rely .45
	place .finishDayText -relx .40 -rely .45
	place .finishYearText -relx .46 -rely .45 
	place .electionNameText -relx 0.34 -rely 0.25
	place .startTime -relx .40 -rely .31
	place .finishTime -relx .40 -rely .41
	place .zipList -relx 0.64 -rely 0.25
	place .zipListText -relx 0.617 -rely 0.223
	place .scroll -relx 0.61125 -rely 0.2540 -relwidth 0.20 -relheight 0.278

	#display buttons
	place .back -relx .02 -rely 0.91 -relwidth 0.15
	place .createElec -relx .35 -rely .7 -relwidth 0.3
	place .addZipCode -relx 0.51 -rely 0.55
}

proc confirmElectionScreen {electionName startMonth startDay startYear finishMonth finishDay finishYear zipList} {
	#create labels
	label   .title -text "Election Confirmation" -font titlefont -background lightsteelblue2
	label   .electionName -text "Name of Election" -font defaultfont -background lightsteelblue2
	label   .startDate -text "Start Date" -font defaultfont -background lightsteelblue2
	label   .finishDate -text "Finish Date" -font defaultfont -background lightsteelblue2
	listbox .zipList -height 7 -width 12 -font defaultfont -listvariable zipList -yscrollcommand \
		".scroll set"
	scrollbar .scroll -command {.zipList yview}	
	label   .zipListText -text "List of Zip Codes for This Election" -font labelfont -background lightsteelblue2
	label   .startTime -text "MM/DD/YY" -font messagefont -background lightsteelblue2
	label   .finishTime -text "MM/DD/YY" -font messagefont -background lightsteelblue2

	#labels for variables
	label .electionVar -text $electionName -font defaultfont -background lightsteelblue2
	label .startDateLabel -text [concat $startMonth / $startDay / $startYear] -font defaultfont -background lightsteelblue2
	label .finishDateLabel -text [concat $finishMonth / $finishDay / $finishYear] -font defaultfont -background lightsteelblue2

	#create buttons
	button .back -text "Back" -command {reset;addElectionScreen} -font defaultfont -background steelblue4 -foreground white
	button .createElec -text "Confirm" -font defaultfont -command {electionConfirmed $electionName $startMonth $startDay \
			$startYear $finishMonth $finishDay $finishYear $zipList; set electionName {}; set startMonth 1;set startDay 1;\
			set startYear 2007; set zipList {}; set finishMonth 1; set finishDay 1; set finishYear 2007; reset; configScreen} -background steelblue4 -foreground white

	#display label
	pack .title -anchor n	
	place .startDate -relx 0.20 -rely 0.35
	place .finishDate -relx .19 -rely .45
	place .electionName -relx .13 -rely .25
	place .startTime -relx .40 -rely .31
	place .finishTime -relx .40 -rely .41
	place .zipList -relx 0.64 -rely 0.25
	place .zipListText -relx 0.617 -rely 0.223
	place .scroll -relx 0.61125 -rely 0.2540 -relwidth 0.20 -relheight 0.278

	#placing variables
	place .startDateLabel -relx 0.34 -rely 0.35
	place .finishDateLabel -relx 0.34 -rely 0.45
	place .electionVar -relx 0.34 -rely 0.25

	#display buttons
	place .back -relx .02 -rely 0.91 -relwidth 0.15
	place .createElec -relx .35 -rely .7 -relwidth 0.3
}

proc electionConfirmed {electionName startMonth startDay startYear finishMonth finishDay finishYear zipList} {
	if {$startMonth < 10} {
		set startMonth [concat 0$startMonth] 
	}
	if {$startDay < 10} {
		set startDay [concat 0$startDay]
	}
	if {$finishMonth < 10} {
		set finishMonth [concat 0$finishMonth]
	} 
	if {$finishDay < 10} {
		set finishDay [concat 0$finishDay]
	} 	
	#finally makes the election in the database
	db eval {Insert Into Election Values($electionName, $startMonth, $startDay,\
			$startYear, $finishMonth, $finishDay, $finishYear)};
	foreach z $zipList {
		db eval {Insert Into ZipCodeList Values(NULL, $z, $electionName)}
	}
}

proc addZipCodeBox {zipFirst} {
	global zipList
	tk_messageBox -message "Added Zip Code Sucessfully" -type ok
	set zipList [concat $zipFirst $zipList]
}

#declare the procedure for config login
proc adminLoginScreen {} {

	#create labels
	label .title -text "Administration Login" -font titlefont -background lightsteelblue2
	label .userName -text "UserName" -font defaultfont -background lightsteelblue2
	label .passWord -text "Password" -font defaultfont -background lightsteelblue2

	#create entry boxes	
	entry .userNameEntry -width 11 -font defaultfont -textvariable userName
	entry .passWordEntry -width 11 -font defaultfont -show * -textvariable passWord

	#creating buttons
	button .submit -text "Submit" -font defaultfont -command {adminLoginScreenCheck $userName $passWord; unset userName; unset passWord} -background steelblue4 -foreground white
	button .back -text "Back" -font defaultfont -command {reset;configScreen} -background steelblue4 -foreground white

	#display objects etc
	pack .title -anchor n
	place .userName -relx 0.30 -rely 0.30
	place .passWord -relx 0.30 -rely 0.40 
	place .submit -relx .4 -rely .77 -relwidth 0.2
	place .userNameEntry -relx 0.45 -rely 0.30
	place .passWordEntry -relx 0.45 -rely 0.40
	place .back -relx .02 -rely 0.91 -relwidth 0.15

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc adminLoginScreenCheck {userName passWord} {
	if {
		[db exists {SELECT * FROM Administrator WHERE username = $userName AND passWord = $passWord}]
	} then {
   		tk_messageBox -message "Login Sucessful" -type ok
		reset
		adminScreen
	} else {
		set answer [tk_messageBox -message "Incorrect Username/Password. Try Agian?" -type yesno]
		switch -- $answer {
			yes { }
			no {reset;configScreen}
		}
	}
}

#declare procedure for Administrator Config
proc adminScreen {} {
	#create label
	label .welcome -text "Administration Configuration" -font titlefont -background lightsteelblue2

	#create buttons
	button .addRemoveEO -text "Add/Remove Election Official" -font defaultfont -command {reset;addRemoveEOScreen} -background steelblue4 -foreground white
	button .exitDesktp -text "Exit to Desktop" -font defaultfont -command shutDownCheck -background steelblue4 -foreground white
	button .back -text "Back" -command {reset;configScreen} -font defaultfont -background steelblue4 -foreground white

	#display label
	pack .welcome -anchor n

	#display buttons
	place .addRemoveEO -relx 0.31 -rely 0.3 -relwidth 0.4
	place .exitDesktp -relx 0.31 -rely 0.4 -relwidth 0.4
	place .back -relx .02 -rely 0.91 -relwidth 0.15

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

#declare procedure for Creating Ballot
proc createBallotScreen {} {
	global candidateList
	global allElectionList
	#unsetting radiobutton if already set
	set ballotType NULL
	
	#create labels
	label   .title -text "Create Ballot" -font titlefont -background lightsteelblue2
	label   .selectElection -text "Select Election" -font defaultfont -background lightsteelblue2
	listbox .listOfElectionText -font defaultfont -width 15 -listvariable allElectionList

	label .ballotQuestion -text "Ballot Question" -font defaultfont -background lightsteelblue2
	entry .ballotQuestionText -font defaultfont -width 16 -textvariable ballotQuestion
	
	label .candidate -text "Candidate" -font defaultfont -background lightsteelblue2
	entry .candidateText -font defaultfont -textvariable candidate
	
	label   .listOfCandidates -text "List of Candidates" -font labelfont -background lightsteelblue2
	listbox .listOfCandidatesText -font defaultfont -listvariable candidateList -yscrollcommand \
		".scroll set"
	scrollbar .scroll -command {.listOfCandidatesText yview}

	#create buttons
	button .back -text "Back" -command {reset;configScreen} -font defaultfont -background steelblue4 -foreground white
	button .addCandidate -text "Add Candidate" -font defaultfont -command {addCandidateBox $candidate; set candidate {};} -background steelblue4 -foreground white
	button .addBallot -text "Add Ballot" -font defaultfont -command {set electionIndex [.listOfElectionText curselect]; \
		set electionName [lindex $allElectionList $electionIndex]; submitBallotToDB $electionName $candidateList $ballotQuestion;} -background steelblue4 -foreground white

	#display labels
	
	pack  .title -anchor n
	place .selectElection -relx .12 -rely .22
	place .listOfElectionText -relx .32 -rely .22 -relheight .3 -relwidth .3
	
	place .ballotQuestion -relx .12 -rely .56
	place .ballotQuestionText -relx .32 -rely .56 -relwidth .6	

	place .candidate -relx .12 -rely .69
	place .candidateText -relx .32 -rely .69 -relwidth .27

	place .listOfCandidates -relx .74 -rely .65
	place .listOfCandidatesText -relx .63 -rely .68 -relheight .15 -relwidth .33 

	#display buttons
	place .back -relx .02 -rely 0.91 -relwidth 0.15
	place .addCandidate -relx .35 -rely .75 -relwidth .2
	place .addBallot -relx .4 -rely .9 -relwidth .2

	place .scroll -relx 0.759 -rely 0.68 -relwidth 0.20 -relheight 0.148

	#exit for testing   
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc submitBallotToDB {electionName candidateList ballotQuestion} {
	db eval {INSERT INTO Ballot VALUES(NULL, $ballotQuestion , $electionName)}
	set ballotID [db eval {SELECT ballot_id FROM Ballot WHERE question = $ballotQuestion AND ballot_to_election = $electionName}]
	foreach choice $candidateList {
		db eval {INSERT INTO Choice VALUES(NULL, $choice , 0, $ballotID)}}
	tk_messageBox -message "Ballot Sucessfully Added" -type ok
}

proc createElectionList {} {
	global allElectionList
	db eval {SELECT * FROM Election} {
		lappend allElectionList $election_name
	}
}

proc addCandidateBox {candidate} {
	global candidateList
	tk_messageBox -message "Added Candidate Sucessfully" -type ok
	lappend candidateList $candidate
}

proc addElectionBox {} {
	tk_messageBox -message "Sucessfully Added an Election" -type ok
	reset
	configScreen
}

#declare procedure for Graph Screen
proc tallyScreen {} {
	#create labels
	label .welcome -text "Election Tally" -font titlefont -background lightsteelblue2

	#create buttons
	button .continue -text "Click to Continue" -command {reset;configScreen} -font defaultfont -background steelblue4 -foreground white

	#display buttons
	place .continue -relx .75 -rely 0.91
	pack .welcome -anchor n

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc voteControl {voter_id} {
	global electionSignal
	db eval {SELECT election_name FROM Election} {
		set trueCount 0
		if {[valididateDate4Election $election_name] == True} {
			set trueCount [expr $trueCount + 1]
		}
		if {[validdiateZip4Election $election_name $voter_id] == True} {
			set trueCount [expr $trueCount + 1]
		}
		#truecount analysis
		if {$trueCount == 2} {
			lappend electionList $election_name
		}
	}
	if {[votedbefore $voter_id] == False} {
		tk_messageBox -message "I'm sorry It appears that you have already voted" -type ok
	} else {
		foreach election $electionList {
			voteScreen $election
			vwait electionSignal
		}
		tk_messageBox -message "Thanks" -type ok
	}
	reset
	tk_messageBox -message "Thank you for voting" -type ok
	mainMenuScreen
}

proc votedbefore {voter_id} {
	db eval {SELECT * FROM voter WHERE Voter_ID = $voter_id} {
		if {$Voted == 0} {
			return True
		} else {
			return False
		}
	}
}

proc validdiateZip4Election {election voter_id} {
	db eval {SELECT ZipCode FROM ZipCodeList where zip_to_election = $election} {
		db eval {SELECT Zip FROM Voter WHERE Voter_ID = $voter_id} {
			if {$Zip == $ZipCode} {
				return True
			} else {
				return False
			}		
		}	
	}
}

proc valididateDate4Election {election} {
	db eval {SELECT * FROM Election WHERE election_name = $election} {
		set dayStart [clock format [clock scan [concat $startMonth/$startDay/$startYear]] -format "%m/%d/%Y"]
		set dayEnd [clock format [clock scan [concat $finishMonth/$finishDay/$finishYear]] -format "%m/%d/%Y"]
		set currentTime [clock format [clock scan "today"] -format "%m/%d/%Y"]
		if {$dayStart <= $currentTime && $dayEnd >= $currentTime} {
			return True
		} else { 
			return False
		}
	}
}

#declare procedure for Vote Screen
proc voteScreen {election} {
	global candidate
	global ballotSignal
	global electionSignal
	global candidate
	set ballotList [db eval {SELECT ballot_id FROM Ballot WHERE ballot_to_election = $election}]
	foreach ballot $ballotList {
		tk_messageBox -message "Ballot ID" -title $ballot -type ok 
		set choiceList [db eval {SELECT choice FROM Choice WHERE ballot_id = $ballot}]
		set y 0.30
		set ::candidate {}
		foreach choice $choiceList {
			radiobutton .choice_$choice -text $choice -variable candidate -value $choice -font defaultfont -background lightsteelblue2
			place .choice_$choice -relx 0.15 -rely $y
			set y [expr $y + 0.075]
		}
		db eval {SELECT question FROM Ballot WHERE ballot_id = $ballot} {
			set ballot_question $question
		}
		radiobutton .choice_no_choice -text None -variable candidate -value None -font defaultfont -background lightsteelblue2
		place .choice_no_choice -relx 0.15 -rely $y		

		#create labels
		label .welcome -text "Vote" -font titlefont -background lightsteelblue2
		label .question -text $ballot_question -font defaultfont -background lightsteelblue2
		
		#create buttons
		button .continue -text "Click to Continue" -font defaultfont -command "voteCheck $ballot" -background steelblue4 -foreground white

		#display label
		pack .welcome -anchor n
		place .question -relx .09 -rely .2
	
		#display buttons
		place .continue -relx .75 -rely 0.91
			
		#exit for testing
		button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
		place .exit -relx 0.02 -rely 0.09	
		vwait ballotSignal
	}
	tk_messageBox -message "Election Signal" -type ok
	set electionSignal 1	
}

proc voteCheck {ballot} {
	global candidate
	if {$candidate == {}} {
		tk_messageBox -message "Please Cast a vote." -type ok
	} elseif {$candidate == "None"} {
		set answer [tk_messageBox -message "Are you sure you do not wish to vote in this election?" -type yesno]
		switch -- $answer {
			yes "reset; voteConfirmationScreen $ballot"
			no { }
		}
	} else {
		tk_messageBox -message "Vote Taken!" -type ok
		reset
		voteConfirmationScreen $ballot
	}
}

#declare procedure for Vote Screen
proc voteConfirmationScreen {ballot} {
	global candidate
	global ballotSignal
	#create labels
	label .welcome -text "Voter Confirmation Screen" -font titlefont -background lightsteelblue2
	label .check -text "Are you Sure you want to vote for:" -font defaultfont -background lightsteelblue2

	#create buttons
	button .continue -text "Confirm your Vote" -command "submitChoiceToDB $ballot; reset; set ballotSignal 1" -font defaultfont -background steelblue4 -foreground white
	label .candiateSelection -text $candidate -font defaultfont -background lightsteelblue2

	#display label
	pack .welcome -anchor n
	place .check -relx .09 -rely .2

	#display buttons
	place .continue -relx .75 -rely 0.91
	place .candiateSelection -relx .15 -rely .4

	#exit for testing
	button .exit -text "Exit" -command {db close; exit} -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc submitChoiceToDB {ballot} {	
	global candidate
	db eval {UPDATE Choice SET for_talley = for_talley + 1}
	tk_messageBox -type ok -message [db eval {PRAGMA synchronous;}]
}

#declare procedure for Add/Remove Election Offical
proc addRemoveEOScreen {} {

	set selection "None"

	#create label
	label .welcome -text "Add or Remove Election Official" -font titlefont -background lightsteelblue2
	label .electOff -text "Select Add or Remove and fill in the approiate fields" -font defaultfont -background lightsteelblue2
	label .userName1 -text "Username" -font defaultfont -background lightsteelblue2
	label .userName2 -text "Username" -font defaultfont -background lightsteelblue2
	label .passWord -text "Password" -font defaultfont -background lightsteelblue2
	entry .usrName -font defaultfont -width 16 -textvariable userName
	entry .pasWrd -font defaultfont -width 16 -show * -textvariable passWord
	entry .usrName2 -font defaultfont -width 16 -textvariable userName
	label .characters -text "Please note Password must be \n greater than 7 characters and \
		\n must contain a combination of \n letters and numbers" -font labelfont -background lightsteelblue2

	#create buttons
	button .back -text "Back" -command {reset; adminScreen} -font defaultfont -background steelblue4 -foreground white
	radiobutton .add -text "Add" -font defaultfont -variable selection -value "add" -background lightsteelblue2
	radiobutton .remove -text "Remove" -font defaultfont -variable selection -value "remove" -background lightsteelblue2
	button .submit -text "Submit" -font defaultfont -command {addRemoveEOCheck $selection $userName $passWord;set selection "None"} -background steelblue4 -foreground white


	#display label
	pack .welcome -anchor n
	place .electOff -relx 0.2 -rely 0.2
	place .userName1 -relx 0.07 -rely 0.45
	place .usrName -relx 0.2 -rely 0.45
	place .passWord -relx 0.07 -rely 0.55
	place .pasWrd -relx 0.2 -rely 0.55
	place .userName2 -relx 0.6 -rely 0.45
	place .usrName2 -relx 0.72 -rely 0.45
	place .characters -relx 0.2 -rely 0.6


	#display buttons
	place .back -relx .02 -rely 0.91 -relwidth 0.15
	place .submit -relx .4 -rely .77 -relwidth 0.2
	place .add -relx .14 -rely 0.3
	place .remove -relx .75 -rely 0.3

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc addRemoveEOCheck {radio userName passWord} {
	if {$radio == "add"} {
		set answer [tk_messageBox -message "Add Election Offical?" -type yesno -icon question]
		switch -- $answer {
			yes {
				tk_messageBox -message "Election Offical Added." -type ok
				db eval {INSERT INTO ElectionOfficial VALUES(NULL, $userName, $passWord)}
				}
			no {}
		}
	} elseif {$radio == "remove"} {
		set answer [tk_messageBox -message "Remove Election Offical?" -type yesno -icon question]
		switch -- $answer {
			yes {
				tk_messageBox -message "Election Offical Removed." -type ok}
			no {}
		}
	} else {
		tk_messageBox -message "Please make a Selection." -type ok
	}
}

#declare the procedure for Voter Registration
proc registrationScreen {} {

	set zipInput {}
	#creating text boxes for names
	label .registarTitle -text "Voter Registration" -font titlefont -background lightsteelblue2 
	label .name -text Name -font defaultfont -background lightsteelblue2
	label .lastNameLabel -text Last -font labelfont -background lightsteelblue2
	entry .lastName -font defaultfont -width 11 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<25}} -textvariable lastNameInput
	label .suffixLabel -text Suffix -font labelfont -background lightsteelblue2
	entry .suffix -font defaultfont -width 6 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<7}} -textvariable suffixNameInput
	label .middleNameLabel -text Middle -font labelfont -background lightsteelblue2
	entry .middleName -font defaultfont -width 11 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<25}} -textvariable middleNameInput
	label .firstNameLabel -text First -font labelfont -background lightsteelblue2
	entry .firstName -font defaultfont -width 11 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<25}} -textvariable firstNameInput
	
	#placing text boxes for name
	pack .registarTitle -anchor n
	place .name -relx 0.1 -rely 0.25
	place .lastNameLabel -relx 0.25 -rely 0.22
	place .lastName -relx 0.185 -rely 0.25
	place .suffixLabel -relx 0.382 -rely 0.22
	place .suffix -relx 0.362 -rely 0.25
	place .middleNameLabel -relx 0.52 -rely 0.22
	place .middleName -relx 0.47 -rely 0.25
	place .firstNameLabel -relx 0.71 -rely 0.22
	place .firstName -relx 0.65 -rely 0.25

	#creating objects for Social Security Number
	label .ssn -text "Social Security Number" -font defaultfont -background lightsteelblue2
	entry .ssnFirst -font defaultfont -width 3 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<4}} -textvariable ssn1Input
	entry .ssnSecond -font defaultfont -width 2 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<3}} -textvariable ssn2Input
	entry .ssnThird -font defaultfont -width 4 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<5}} -textvariable ssn3Input

	#placing objects for Social Security Number
	place .ssn -relx 0.1 -rely 0.33
	place .ssnFirst -relx 0.40 -rely 0.33
	place .ssnSecond -relx 0.467 -rely 0.33
	place .ssnThird -relx 0.52 -rely 0.33

	#creating objects for Address
	label .address -text Address -font defaultfont -background lightsteelblue2
	label .addyStreetLabel -text "Street Address" -font labelfont -background lightsteelblue2
	entry .addyStreetText -font defaultfont -width 25 -textvariable streetInput 
	label .addyAptLabel -text "Apt/Lot/Unit" -font labelfont -background lightsteelblue2
	entry .addyAptText -font defaultfont -width 11 -textvariable aptInput
	label .addyCityLabel -text "City" -font labelfont -background lightsteelblue2
	entry .addyCityText -font defaultfont -width 11 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<25}} -textvariable cityInput
	label .addyStateLabel -text "State" -font labelfont -background lightsteelblue2 
	entry .addyStateText -font defaultfont -width 3 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<3}} -textvariable stateInput
	label .addyZipLabel -text "Zip Code" -font labelfont -background lightsteelblue2
	entry .addyZipText -font defaultfont -width 5 -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<6}} -textvariable zipInput

	#placing objects for Address
	place .address -relx 0.1 -rely 0.42
	place .addyStreetLabel -relx 0.31 -rely 0.39
	place .addyStreetText -relx 0.20 -rely 0.42
	place .addyAptLabel -relx 0.605 -rely 0.39
	place .addyAptText -relx 0.57 -rely 0.42
	place .addyCityLabel -relx 0.26 -rely 0.48
	place .addyCityText -relx 0.20 -rely 0.51
	place .addyStateLabel -relx 0.385 -rely 0.48
	place .addyStateText -relx 0.38 -rely 0.51
	place .addyZipLabel -relx 0.46 -rely 0.48
	place .addyZipText -relx 0.455 -rely 0.51

	#creating date of birth objects
	label .dateOfBirth -text "Date of Birth" -font defaultfont -background lightsteelblue2
	label .dateOfBirthMonthLabel -text "Month" -font labelfont -background lightsteelblue2
	spinbox .dateOfBirthMonth -from 1 -to 12 -font defaultfont -width 2 -textvariable voterMonth
	label .dateOfBirthDayLabel -text "Day" -font labelfont -background lightsteelblue2
	spinbox .dateOfBirthDay -from 1 -to 31 -font defaultfont -width 2 -textvariable voterDay
	label .dateOfBirthYearLabel -text "Year" -font labelfont -background lightsteelblue2
	spinbox .dateOfBirthYear -from 1870 -to 2007 -font defaultfont -width 4 -textvariable voterYear

	#placing objects for Date of Birth
	place .dateOfBirth -relx 0.10 -rely 0.60
	place .dateOfBirthMonth -relx 0.27 -rely 0.60
	place .dateOfBirthMonthLabel -relx 0.27 -rely 0.574
	place .dateOfBirthDay -relx 0.36 -rely 0.60
	place .dateOfBirthDayLabel -relx 0.37 -rely 0.574
	place .dateOfBirthYear -relx 0.47 -rely 0.60
	place .dateOfBirthYearLabel -relx 0.49 -rely 0.574


	#creating last couple objects
	label .usQuestion -text "Are you a U.S. Citizen?" -font defaultfont -background lightsteelblue2
	radiobutton .usYes -text "Yes" -variable Citizen -value yes -font defaultfont -background lightsteelblue2
	radiobutton .usNo -text "No" -variable Citizen -value no -font defaultfont -background lightsteelblue2
	label .felonQuestion -text "I affirm I am not a convicted felon, or if I am, my \
		\n rights relating to voting have been restored." -font defaultfont -background lightsteelblue2
	radiobutton .felonYes -text "Yes" -variable felon -value yes -font defaultfont -background lightsteelblue2
	radiobutton .felonNo -text "No" -variable felon -value no -font defaultfont -background lightsteelblue2
	button .submit -text "Submit Registration" -font defaultfont -command {reset; voterRegistrationCheck $Citizen $felon $ssn1Input $ssn2Input $ssn3Input $firstNameInput $suffixNameInput $middleNameInput $lastNameInput $streetInput $aptInput $cityInput $stateInput $zipInput $voterDay $voterMonth $voterYear} -background steelblue4 -foreground white
	button .back -text "Back" -command {reset; mainMenuScreen} -font defaultfont -background steelblue4 -foreground white


	#placing last couple of objects
	place .usQuestion -relx 0.10 -rely 0.69
	place .usYes -relx 0.38 -rely 0.685
	place .usNo -relx 0.46 -rely 0.685
	place .felonYes -relx 0.10 -rely 0.77
	place .felonNo -relx 0.10 -rely 0.81
	place .felonQuestion -relx 0.20 -rely 0.78
	place .submit -relx .3 -rely .90 -relwidth 0.3
	place .back -relx .02 -rely 0.91 -relwidth 0.15

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

#
proc confirmRegistrationScreen { ssn1Input ssn2Input ssn3Input firstNameInput suffixNameInput middleNameInput lastNameInput streetInput aptInput cityInput stateInput zipInput} {
	
	#creating text boxes for names
	label .registarTitle -text "Voter Registration Confirmation" -font titlefont -background lightsteelblue2
	label .name -text "Name:" -font oldfont -background lightsteelblue2
	label .lastName -text $lastNameInput -font confirmfont -background lightsteelblue2 
	label .suffix -text $suffixNameInput -font confirmfont -background lightsteelblue2
	label .middleNameLabel -text Middle -font labelfont -background lightsteelblue2
	label .middleName -text $middleNameInput -font confirmfont -background lightsteelblue2
	label .firstNameLabel -text First -font labelfont -background lightsteelblue2
	label .firstName -text $firstNameInput -font confirmfont -background lightsteelblue2
	
	#placing text boxes for name
	pack .registarTitle -anchor n
	place .name -relx 0.297 -rely 0.33
	place .lastName -relx 0.4 -rely 0.33
	place .suffix -relx 0.53 -rely 0.33
	place .middleName -relx 0.59 -rely 0.33
	place .firstName -relx 0.7 -rely 0.33

	#creating objects for Social Security Number
	label .ssn -text "Social Security Number:" -font defaultfont -background lightsteelblue2
	label .ssnFirst -text $ssn1Input -font confirmfont -background lightsteelblue2
	label .ssnSecond -text $ssn2Input -font confirmfont -background lightsteelblue2
	label .ssnThird -text $ssn3Input -font confirmfont -background lightsteelblue2

	#placing objects for Social Security Number
	place .ssn -relx 0.1 -rely 0.25
	place .ssnFirst -relx 0.40 -rely 0.253
	place .ssnSecond -relx 0.467 -rely 0.253
	place .ssnThird -relx 0.52 -rely 0.2543

	#creating objects for Address
	label .address -text "Address:" -font defaultfont -background lightsteelblue2
	label .addyStreetText -text $streetInput -font confirmfont -background lightsteelblue2
	label .addyAptText -text $aptInput -font confirmfont -background lightsteelblue2
	label .addyCityText -text $cityInput -font confirmfont -background lightsteelblue2
	label .addyStateText -text $stateInput -font confirmfont -background lightsteelblue2
	label .addyZipText -text $zipInput -font confirmfont -background lightsteelblue2

	#placing objects for Address
	place .address -relx 0.28 -rely 0.41
	place .addyStreetText -relx 0.401 -rely 0.413
	place .addyAptText -relx 0.7 -rely 0.413
	place .addyCityText -relx 0.397 -rely 0.475
	place .addyStateText -relx 0.57 -rely 0.475
	place .addyZipText -relx 0.68 -rely 0.475

	#creating last couple objects
	button .edit -text "Edit" -font defaultfont -command {reset;registrationScreen} -background steelblue4 -foreground white
	button .submit -text "Submit Information" -font defaultfont -command {reset;db eval {Insert Into Voter Values(NULL, $ssn1Input, $ssn2Input, $ssn3Input, $firstNameInput, $suffixNameInput, $middleNameInput, $lastNameInput, $streetInput, $aptInput, $cityInput, $stateInput, $zipInput, "no")}} -background steelblue4 -foreground white

	#placing last couple of objects
	place .edit -relx .02 -rely 0.91 -relwidth 0.15
	place .submit -relx 0.73 -rely 0.91 -relwidth 0.25

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

#validating voter requirements
proc voterRegistrationCheck {citizen felon ssn1Input ssn2Input ssn3Input firstNameInput suffixNameInput middleNameInput lastNameInput streetInput aptInput cityInput stateInput zipInput voterDay voterMonth voterYear} {
	set trueCount 0

	if {[voterCitizenCheck $citizen] == true} {
		set trueCount [expr $trueCount + 1]
	} 

	if {[voterFelonCheck $felon] == true} {
		set trueCount [expr $trueCount + 1]
	}
	if {[voterSSNcheck $ssn1Input $ssn2Input $ssn3Input] == true} {
		set trueCount [expr $trueCount + 1]
	}
	if {[voterDOBcheck $voterDay $voterMonth $voterYear] == true} {
		set trueCount [expr $trueCount + 1]
	}
	
	if {$trueCount == 4} {
		confirmRegistrationScreen $ssn1Input $ssn2Input $ssn3Input $firstNameInput $suffixNameInput $middleNameInput $lastNameInput $streetInput $aptInput $cityInput $stateInput $zipInput
	} else {
		registrationScreen
	}
}

proc voterCitizenCheck {citizen} {
	if {$citizen == "yes"} {
      	return true
	} elseif {$citizen == "no"} {	
		tk_messageBox -message "You must be a citizen to vote." -type ok
	} else {
		tk_messageBox -message "Please specify whether or not you are a citizen." -type ok
	}
}

proc voterFelonCheck {felon} {
	if {$felon == "yes"} {
		return true
	} elseif {$felon == "no"} {
		tk_messageBox -message "Sorry, convicted felons are not allowed to vote in this state." -type ok
	} else {
		tk_messageBox -message "Please specify whether or not you are a felon." -type ok
	}
}

proc voterSSNcheck {SSN1 SSN2	SSN3} {
	if {[db exists {SELECT * FROM Voter WHERE SSN1 = $SSN1 AND SSN2 = $SSN2 AND SSN3 = $SSN3}]} {
		db eval {SELECT * FROM Voter  WHERE SSN1 = $SSN1 AND SSN2 = $SSN2 AND SSN3 = $SSN3}
		  tk_messageBox -message "A voter with that social security number already exists.  Please check your registration information and ask an election official for assistance." -type ok
		    return false	
	} else {
		return true
	}
}

proc voterDOBcheck {voterDay voterMonth voterYear} {

	if {$voterDay < 10} {
		set voterDay [concat 0$voterDay]
	}
	if {$voterMonth < 10} {
		set voterMonth [concat 0$voterMonth]
	}
	set currentTime [clock format [clock scan "today"] -format "%m/%d/%Y"]
	set dob [clock format [clock scan [concat $voterMonth/$voterDay/$voterYear]] -format "%m/%d/%Y"]
	if { [clock seconds] >= [clock scan {18 years} -base [clock scan $dob]] } { 
		return true 
	} else { 
		return false }
}

proc voterLoginScreen {} {
	
	#creating new labels/buttons etc
	button .mainMenu -text "Main Menu" -font defaultfont -command {reset;mainMenuScreen} -background steelblue4 -foreground white
	label .loginTitle -text "Voter Login" -font titlefont -background lightsteelblue2
	label .loginName -text "Name" -font defaultfont -background lightsteelblue2
	label .firstNameLabel -text "First" -font labelfont -background lightsteelblue2 
	entry .firstNameText -font defaultfont -width 11 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<25}} -textvariable voterFirstName
	label .lastNameLabel -text "Last" -font labelfont -background lightsteelblue2
	entry .lastNameText -font defaultfont -width 11 -validate key \
            -vcmd {expr {[string is alpha %P] && [string length %P]<25}} -textvariable voterLastName
	label .ssnLabel -text "SSN" -font defaultfont -background lightsteelblue2
	label .ssnTextLabel -text "Social Security Number" -font labelfont -background lightsteelblue2
	entry .ssnTextFirst -font defaultfont -width 3 -show * -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<4}} -textvariable voterSSNFirst
	entry .ssnTextSecond -font defaultfont -width 2 -show * -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<3}} -textvariable voterSSNSecond
	entry .ssnTextThird -font defaultfont -width 4 -show * -validate key \
            -vcmd {expr {[string is int %P] && [string length %P]<5}} -textvariable voterSSNThird
	button .login -text "Login" -font defaultfont -command {voterLoginScreenCheck $voterSSNFirst $voterSSNSecond $voterSSNThird $voterFirstName $voterLastName} -background steelblue4 -foreground white
	label .or -text or -font defaultfont -background lightsteelblue2
	button .modify -text "Modify" -font defaultfont -justify center -background steelblue4 -foreground white
	
	#placing new labels/buttons etc
	place .mainMenu -relx 0.02 -rely 0.91
	pack .loginTitle -anchor n
	place .loginName -relx 0.22 -rely 0.3
	place .firstNameLabel -relx 0.37 -rely 0.27
	place .firstNameText -relx 0.3 -rely 0.3
	place .lastNameLabel -relx 0.57 -rely 0.27
	place .lastNameText -relx 0.51 -rely 0.3
	place .ssnLabel -relx 0.32 -rely 0.39
	place .ssnTextFirst -relx 0.4 -rely 0.39
	place .ssnTextSecond -relx 0.47 -rely 0.39
	place .ssnTextThird -relx 0.525 -rely 0.39
	place .ssnTextLabel -relx 0.42 -rely 0.36
	place .login -relx 0.32 -rely 0.53 -relwidth 0.15
	place .or -relx 0.48 -rely 0.545 
	place .modify -relx 0.515 -rely 0.53 -relwidth 0.15

	#exit for testing
	button .exit -text "Exit" -command exit -font defaultfont -background steelblue4 -foreground white
	place .exit -relx 0.02 -rely 0.09
}

proc voterLoginScreenCheck {voterSSNFirst voterSSNSecond voterSSNThird voterFirstName voterLastName} {
	db eval {SELECT * FROM Voter } { 
		if {$FirstName == $voterFirstName && $LastName == $voterLastName && $SSN1 == $voterSSNFirst && $SSN2 == $voterSSNSecond && $SSN3 == $voterSSNThird} {
			tk_messageBox -message "Correct Password" -type ok
			reset
			voteControl $Voter_ID
		} else {
			tk_messageBox -message "Sorry, your name and Social Security Number does not appear to be registered. Try Again?" -type yesno
		}
	}
}

#creating a procedure incase there are ever any errors that reset to the mainMenu
#will work on some more
#proc unknown {} {
#	{reset;mainMenuScreen}
#}

#starting Main
#setting up the main interface window
eval destroy [winfo child .]
wm geometry . [winfo screenwidth .]x[winfo screenheight .]+0+0		;# sets to full screen
wm overrideredirect . yes      							;# removes window decorations
wm attributes . -topmost yes   							;# stays on top of other windows
. configure -background lightsteelblue2


#creating fonts to use
font create defaultfont -family Tahoma -size 25
font create titlefont -family Tahoma -size 60
font create labelfont -family Times -size 15

#calling the mainMenu procedure
mainMenuScreen