这是登录系统的代码
Imports System.Data.OleDb
Module koneksi
Public conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\pemilu.accdb")
Public da As OleDbDataAdapter
Public ds As DataSet
Public cmd As OleDbCommand
Public rd As OleDbDataReader
Public dgv As New DataGridView
End Module
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PasswordTextBox.UseSystemPasswordChar = True
NimTextBox.Focus()
End Sub
Private Sub btnpilih_Click(sender As Object, e As EventArgs) Handles btnpilih.Click
conn.Close()
conn.Open()
cmd = New OleDbCommand("SELECT * FROM pemilih WHERE nim = '" &
NimTextBox.Text & "' AND password = '" &
PasswordTextBox.Text & "'", conn)
rd = cmd.ExecuteReader
Dim userfound As Boolean = False
Dim firstname As String = ""
Dim lastname As String = ""
While rd.Read
If NimTextBox.Text = rd("nim").ToString And PasswordTextBox.Text = rd("password").ToString Then
userfound = True
firstname = rd("firstname").ToString
lastname = rd("lastname").ToString
End If
End While
If userfound = True Then
MsgBox("Pilihlah Pemimpin Sesuai Hati Nurani Anda. Selamat Memilih.", MsgBoxStyle.Information, "Selamat Memilih")
NimTextBox.Text = ""
PasswordTextBox.Text = ""
Form1.Label1.Text = "Selamat Memilih, " & firstname & " " & lastname
Me.Hide()
Form1.Show()
Else
MsgBox("Maaf, NIM Atau Password Anda Masukkan Salah Atau NIM Anda Belum Terdaftar. Silahkan Ulangi Kembali.", MsgBoxStyle.Information, "Info")
NimTextBox.Focus()
End If
End Sub
Private Sub PasswordTextBox_Keypress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles PasswordTextBox.KeyPress
If e.KeyChar = Chr(13) Then
btnpilih_Click(Me, EventArgs.Empty)
End If
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
PasswordTextBox.UseSystemPasswordChar = False
Else
PasswordTextBox.UseSystemPasswordChar = True
End If
End Sub
End Class
This is the database of login system.
它发挥得最好。
这是投票代码
Imports System.Data.OleDb
Public Class Form1
Private Sub btnpilih_Click(sender As Object, e As EventArgs) Handles btnpilih.Click
conn.Close()
conn.Open()
If ckagus.Checked And cksuyamto.Checked And ckfarid.Checked Then
MsgBox("Anda hanya bisa memilih satu kandidat", MsgBoxStyle.Information, "Info")
ElseIf ckagus.Checked And cksuyamto.Checked Then
MsgBox("Anda hanya bisa memilih satu kandidat", MsgBoxStyle.Information, "Info")
ElseIf ckagus.Checked And ckfarid.Checked Then
MsgBox("Anda hanya bisa memilih satu kandidat", MsgBoxStyle.Information, "Info")
ElseIf cksuyamto.Checked And ckfarid.Checked Then
MsgBox("Anda hanya bisa memilih satu kandidat", MsgBoxStyle.Information, "Info")
ElseIf ckagus.Checked Then
cmd = New OleDbCommand("UPDATE kandidat SET [agus] = agus + 1", conn)
cmd.ExecuteNonQuery()
MsgBox("Terimakasih karena sudah memilih", MsgBoxStyle.Information, "Info")
Me.Hide()
Form2.Show()
Form2.NimTextBox.Focus()
ElseIf cksuyamto.Checked Then
cmd = New OleDbCommand("UPDATE kandidat SET [suyamto] = suyamto + 1", conn)
cmd.ExecuteNonQuery()
MsgBox("Terimakasih karena sudah memilih", MsgBoxStyle.Information, "Info")
Me.Hide()
Form2.Show()
Form2.NimTextBox.Focus()
ElseIf ckfarid.Checked Then
cmd = New OleDbCommand("UPDATE kandidat SET [farid] = farid + 1", conn)
cmd.ExecuteNonQuery()
MsgBox("Terimakasih karena sudah memilih", MsgBoxStyle.Information, "Info")
Me.Hide()
Form2.Show()
Form2.NimTextBox.Focus()
End If
ckagus.CheckState = CheckState.Unchecked
cksuyamto.CheckState = CheckState.Unchecked
ckfarid.CheckState = CheckState.Unchecked
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Label1.Text = "Selamat Memilih, Admin " Then
btnreport.Visible = True
End If
End Sub
End Class
This is the database to count the point of candidate
问题是: