LOGIN CODE
Imports System.Data
Imports System.Data.OleDb
Public Class Login
Dim constring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\baAdel\Desktop\HIGHVELD PRIMARY SCHOOL FEES PAYMENT SYSTEM\
HIGHVELD PRIMARY.mdb"
Dim dbcon As New OleDbDbcon(constring)
Dim command As OleDbCommand
Dim dtable As DataTable = New DataTable()
Dim adapter As OleDbDataAdapter
Dim dsetet As New DataSet
Dim attempt As Integer = 0
Sub clear()
txtusername.Clear()
txtpassword.Clear()
txtusername.Focus()
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles
btnLogin.Click
dset = New DataSet
dapter = New OleDbDataAdapter("SELECT * FROM users WHERE username='" +
txtusername.Text + "'and password='" + txtpassword.Text + "'", dbcon)
Try
If txtusername.Text = "" Or txtpassword.Text = "" Then
MessageBox.Show("Either username or password is Empty, please
fill in all fieldset")
clear()
Else
adapter.Fill(dset, "users")
If dset.Tables("users").Rows.Count > 0 Then
MsgBox("Login successful", vbInformation)
MAIN_FORM.Show()
txtusername.Clear()
txtpassword.Clear()
Me.Hide()
Else
MsgBox("Either username or password is incorrect, please
try again", MessageBoxButtons.OK)
txtusername.Clear()
txtpassword.Clear()
txtusername.Focus()
attempt += 1
If attempt = 3 Then
MsgBox("Your login details are incorrect, please
contact the administrator", vbCritical)
Application.Exit()
End If
End If
End If
Catch ex As Exception
MsgBox("Either username or password is incorrect",
MessageBoxButtons.OK, ex.Message)
End Try
End Sub
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles
btnReset.Click
clear()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Application.Exit()
End Sub
Private Sub Chkpswd_CheckedChanged(sender As Object, e As EventArgs)
Handles Chkpswd.CheckedChanged
If Me.Chkpswd.Checked = True Then
txtpassword.PasswordChar = ""
Else
txtpassword.PasswordChar = "*"
End If
End Sub
Private Sub Register_LinkClicked(sender As Object, e As
LinkLabelLinkClickedEventArgs) Handles Register.LinkClicked
Dim ur As New USER_REGISTRATION
ur.Show()
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles
GroupBox1.Enter
End Sub
End Class
FEES PAYMENT
Imports System.Data
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Public Class FEES_PAYMENT_FORM
'Global declaration of variables
Dim constring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\baAdel\Desktop\HIGHVELD PRIMARY SCHOOL FEES PAYMENT SYSTEM\
HIGHVELD PRIMARY.mdb"
Dim dbcon As New OleDbDbcon(constring)
Dim command As OleDbCommand
Dim dtable As DataTable = New DataTable()
Dim adapter As OleDbDataAdapter
Dim count As Integer
Private Sub btnGenerateReceipt_Click(sender As Object, e As EventArgs)
fees_Calculate()
End Sub
Sub clear() 'Sub Procedure to clear fieldset
txtid.Clear()
txtnames.Clear()
txtform.Clear()
txtdate.Clear()
combopayment.Text = "-select payment method-"
txtamount.Clear()
txttotalfees.Clear()
txtbalance.Clear()
txtreceipt.Clear()
txtid.Focus()
End Sub
Sub fees_Calculate()
Dim totalfees, amountpaid, balance As Double
totalfees = txttotalfees.Text
amountpaid = txtamount.Text
balance = totalfees - amountpaid
txtbalance.Text = balance
End Sub
Private Sub btnMakePayment_Click(sender As Object, e As EventArgs) Handles
btnMakePayment.Click
Dim sql As String = String.Format("INSERT INTO feestbl VALUES('" +
txtid.Text + "','" + txtnames.Text + "','" + txtform.Text + "','" +
txtdate.Text + "',
'" + combopayment.Text + "', '" + txtreceipt.Text + "','" +
txttotalfees.Text + "','" + txtamount.Text + "','" + txtbalance.Text + "')")
command = New OleDbCommand(sql, dbcon)
command.Parameters.AddWithValue("@student_id", txtid.Text)
command.Parameters.AddWithValue("@class", txtform.Text)
command.Parameters.AddWithValue("@payment_date", txtdate.Text)
command.Parameters.AddWithValue("@payment_method", combopayment.Text)
command.Parameters.AddWithValue("@amount_paid", txtamount.Text)
command.Parameters.AddWithValue("@total_fees", txttotalfees.Text)
command.Parameters.AddWithValue("@balance", txtbalance.Text)
command.Parameters.AddWithValue("@receipt_number", txtreceipt.Text)
Try
dbcon.Open()
If command.ExecuteNonQuery() > 0 Then
MsgBox("Payment successful", vbInformation, vbOK)
dbcon.Close()
clear()
End If
Catch ex As Exception
MsgBox("Payment not successful", vbCritical, vbOK)
dbcon.Close()
clear()
End Try
End Sub
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles
btnSearch.Click
dbcon.Open()
Dim sql As String = "SELECT*FROM feestbl WHERE student_id='" +
txtid.Text + "'"
Try
If txtid.Text = "" Then
MsgBox("Please enter student id to search",
MessageBoxIcon.Error)
txtid.Focus()
Else
adapter = New OleDbDataAdapter(sql, dbcon)
adapter.Fill(dtable)
count = 0
'txtid.Text = dtable.Rows(count).Item(0)
txtnames.Text = dtable.Rows(count).Item(1)
txtform.Text = dtable.Rows(count).Item(2)
txtdate.Text = dtable.Rows(count).Item(3)
combopayment.Text = dtable.Rows(count).Item(4)
txtreceipt.Text = dtable.Rows(count).Item(5)
txttotalfees.Text = dtable.Rows(count).Item(6)
txtamount.Text = dtable.Rows(count).Item(7)
txtbalance.Text = dtable.Rows(count).Item(8)
MsgBox("Payment details found", vbInformation, vbOK)
End If
dbcon.Close()
Catch ex As Exception
MsgBox("Payment details not found", vbCritical)
dbcon.Close()
End Try
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles
btnDelete.Click
Dim sql As String = "DELETE FROM feestbl WHERE student_id='" +
txtid.Text + "'"
command = New OleDbCommand(sql, dbcon)
Try
dbcon.Open()
adapter = New OleDbDataAdapter(command)
adapter.DeleteCommand = dbcon.CreateCommand()
adapter.DeleteCommand.CommandText = sql
If MessageBox.Show("Are you sure you want to delete?", "DELETE",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) Then
If command.ExecuteNonQuery() > 0 Then
MsgBox("Payment details deleted successfully!!")
clear()
End If
End If
dbcon.Close()
Catch ex As Exception
MsgBox("Payment details not deleted", ex.Message)
dbcon.Close()
End Try
End Sub
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles
btnReset.Click
clear()
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles
btnClose.Click
MAIN_FORM.Show()
End Sub
Private Sub txtamount_LostFocus(sender As Object, e As EventArgs) Handles
txtamount.LostFocus
fees_Calculate()
End Sub
Private Sub btnReceipt_Click(sender As Object, e As EventArgs)
RECEIPT_FORM.Show()
End Sub
Private Sub btnMain_Click(sender As Object, e As EventArgs) Handles
btnMain.Click
Dim fmain As New MAIN_FORM
fmain.Show()
Me.Hide()
End Sub
Private Sub txtamount_TextChanged(sender As Object, e As EventArgs)
Handles txtamount.TextChanged
End Sub
End Class
MAIN FORM
Public Class MAIN_FORM
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click
Application.Exit()
End Sub
Private Sub btnReport_Click(sender As Object, e As EventArgs) Handles
btnReport.Click
Dim rpt As New RECEIPT_FORM
rpt.Show()
Me.Hide()
End Sub
Private Sub btnBack_To_Login_Click(sender As Object, e As EventArgs)
Handles btnBack_To_Login.Click
Dim lgn As New Login
lgn.Show()
Me.Hide()
End Sub
Private Sub btnFeesPayment_Click(sender As Object, e As EventArgs) Handles
btnFeesPayment.Click
Dim fp As New FEES_PAYMENT_FORM
fp.Show()
Me.Hide()
End Sub
Private Sub btnStudent_Registration_Click(sender As Object, e As
EventArgs) Handles btnStudent_Registration.Click
Dim sr As New STUDENT_REGISTRATION_FORM
sr.Show()
Me.Hide()
End Sub
Private Sub btnUser_Registration_Click(sender As Object, e As EventArgs)
Handles btnUser_Registration.Click
Dim ur As New USER_REGISTRATION
ur.Show()
Me.Hide()
End Sub
End Class
REPORT CODE
Imports CrystalDecisions.CrystalReports.Engine
Public Class RECEIPT_FORM
Private Sub RECEIPT_FORM_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim rpt As New ReportDocument
rpt.Load("C:\Users\baAdel\source\repos\HIGHVELD PRIMARY SCHOOL FEES
PAYMENT SYSTEM\Highveld.rpt")
CrystalReportViewer4.ReportSource = rpt
CrystalReportViewer4.Refresh()
End Sub
Private Sub RECEIPT_FORM_Load_1(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim rpt As New ReportDocument
rpt.Load("C:\Users\baAdel\source\repos\HIGHVELD PRIMARY SCHOOL FEES
PAYMENT SYSTEM\Highveld.rpt")
CrystalReportViewer4.ReportSource = rpt
CrystalReportViewer4.Refresh()
End Sub
Private Sub btnMain_Click(sender As Object, e As EventArgs) Handles
btnMain.Click
Dim main As New MAIN_FORM
main.Show()
Me.Hide()
End Sub
End Class
STUDENT REGISTRATION CODE
Imports System.Data
Imports System.Data.OleDb
Public Class STUDENT_REGISTRATION_FORM
Dim dbconstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\baAdel\Desktop\HIGHVELD PRIMARY SCHOOL FEES PAYMENT SYSTEM\
HIGHVELD PRIMARY.mdb"
Dim dbcon As New OleDbDbcon(dbconstring)
Dim command As OleDbCommand
Dim dtable As DataTable = New DataTable()
Dim adapter As OleDbDataAdapter
Dim count As Integer
Function NullValidate() As Boolean
NullValidate = True
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is TextBox Then
If ctrl.Text = "" Then
ctrl.BackColor = Color.Red
MessageBox.Show(ctrl.Name & " " & "is Blank, please fill
all blank fieldset!")
NullValidate = False
Exit Function
Else
NullValidate = True
End If
End If
Next
End Function
Sub clear()
txtid.Clear()
txtnames.Clear()
txtdob.Clear()
combogender.Text = "-select gender-"
txtclass.Clear()
txtaddress.Clear()
txtphone.Clear()
txtid.Focus()
End Sub
Private Sub STUDENT_REGISTRATION_FORM_Load(sender As Object, e As
EventArgs) Handles MyBase.Load
End Sub
Private Sub nRegister_Click(sender As Object, e As EventArgs) Handles
nRegister.Click
Dim sql As String = String.Format("INSERT INTO patients VALUES('" +
txtid.Text + "','" + txtnames.Text + "','" + txtdob.Text + "',
'" + combogender.Text + "','" + txtclass.Text + "','" +
txtaddress.Text + "','" + txtphone.Text + "')")
command = New OleDbCommand(sql, dbcon)
command.Parameters.AddWithValue("@user_id", txtid.Text)
command.Parameters.AddWithValue("@names", txtnames.Text)
command.Parameters.AddWithValue("@dob", txtdob.Text)
command.Parameters.AddWithValue("@gender", combogender.Text)
command.Parameters.AddWithValue("@class", txtclass.Text)
command.Parameters.AddWithValue("@address", txtaddress.Text)
command.Parameters.AddWithValue("@phone", txtphone.Text)
Try
dbcon.Open()
If NullValidate() = True Then
If command.ExecuteNonQuery() > 0 Then
MsgBox("Student successfully registered", vbInformation,
vbOK)
dbcon.Close()
clear()
ElseIf NullValidate() = False Then
dbcon.Close()
MsgBox("Student not Registered", vbCritical, vbOK)
dbcon.Close()
End If
End If
Catch ex As Exception
MsgBox("Student not Registered", vbCritical, vbOK)
dbcon.Close()
clear()
End Try
End Sub
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles
btnSearch.Click
dbcon.Open()
Dim sql As String = "SELECT*FROM studentstbl WHERE student_id='" +
txtid.Text + "'"
Try
If txtid.Text = "" Then
MsgBox("Please enter student id to search",
MessageBoxIcon.Error)
txtid.Focus()
Else
adapter = New OleDbDataAdapter(sql, dbcon)
adapter.Fill(dtable)
count = 0
txtid.Text = dtable.Rows(count).Item(0)
txtnames.Text = dtable.Rows(count).Item(1)
txtdob.Text = dtable.Rows(count).Item(2)
combogender.Text = dtable.Rows(count).Item(3)
txtclass.Text = dtable.Rows(count).Item(4)
txtaddress.Text = dtable.Rows(count).Item(5)
txtphone.Text = dtable.Rows(count).Item(6)
MsgBox("Student record found!", vbInformation, vbOK)
End If
dbcon.Close()
Catch ex As Exception
MsgBox("Record not found", vbCritical)
dbcon.Close()
End Try
End Sub
Private Sub txtid_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtid.KeyPress
If Asc(e.KeyChar) <> 1 Then
If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
MsgBox("Only numbers are allowed in this field!!")
e.Handled = True
End If
End If
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles
btnDelete.Click
Dim sql As String = "DELETE FROM studentstbl WHERE student_id='" +
txtid.Text + "'"
command = New OleDbCommand(sql, dbcon)
Try
dbcon.Open()
adapter = New OleDbDataAdapter(command)
adapter.DeleteCommand = dbcon.CreateCommand()
adapter.DeleteCommand.CommandText = sql
If MessageBox.Show("Are you sure you want to delete?", "DELETE",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) Then
If command.ExecuteNonQuery() > 0 Then
MsgBox("Student record deleted successfully!!")
clear()
End If
End If
dbcon.Close()
Catch ex As Exception
MsgBox("Student record not deleted", ex.Message)
dbcon.Close()
End Try
End Sub
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles
btnReset.Click
clear()
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles
btnClose.Click
MAIN_FORM.Show()
Me.Hide()
End Sub
Private Sub btnMainForm_Click(sender As Object, e As EventArgs) Handles
btnMainForm.Click
Dim frmain As New MAIN_FORM
frmain.Show()
Me.Hide()
End Sub
Private Sub txtid_TextChanged(sender As Object, e As EventArgs) Handles
txtid.TextChanged
End Sub
Private Sub txtnames_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtnames.KeyPress
If Asc(e.KeyChar) <> 0 Then
If Asc(e.KeyChar) >= 65 And Asc(e.KeyChar) <= 90 Or Asc(e.KeyChar)
>= 97 And Asc(e.KeyChar) <= 122 Or Asc(e.KeyChar) = 32 Then
e.Handled = False
Else
e.Handled = True
MsgBox("Only letters are allowed in this field!!", vbOKCancel)
If vbOK Then
txtnames.Text = ""
End If
End If
End If
End Sub
End Class
SYSTEM LOADING CODE
Public Class System_Loading
Private Sub System_Loading_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Timer1 = New Timer
Timer1.Start()
ProgressBar1.MarqueeAnimationSpeed = 2
Timer1.Interval = 100
lblload.Text = "System Loading.... please wait ......"
If Timer1.Interval = 10 Then
Timer1.Stop()
Me.Close()
End If
End Sub
Private Sub lblload_Click(sender As Object, e As EventArgs) Handles
lblload.Click
End Sub
End Class
USER REGISTRATION CODE
Imports System.Data
Imports System.Data.OleDb
Public Class USER_REGISTRATION
Dim dbconstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\baAdel\Desktop\HIGHVELD PRIMARY SCHOOL FEES PAYMENT SYSTEM\
HIGHVELD PRIMARY.mdb"
Dim dbcon As New OleDbDbcon(dbconstring)
Dim command As OleDbCommand
Dim dtable As DataTable = New DataTable()
Dim adapter As OleDbDataAdapter
Sub clear()
txtid.Clear()
txtusername.Clear()
txtpassword.Clear()
txtid.Focus()
End Sub
Private Sub nRegister_Click(sender As Object, e As EventArgs) Handles
nRegister.Click
Dim stmt As String = String.Format("INSERT INTO users VALUES('" +
txtid.Text + "','" + txtusername.Text + "','" + txtpassword.Text + "')")
command = New OleDbCommand(stmt, dbcon)
command.Parameters.AddWithValue("@user_id", txtid.Text)
command.Parameters.AddWithValue("@username", txtusername.Text)
command.Parameters.AddWithValue("@password", txtpassword.Text)
Try
dbcon.Open()
If command.ExecuteNonQuery() > 0 Then
MsgBox("User successfully registered", vbInformation, vbOK)
dbcon.Close()
clear()
End If
Catch ex As Exception
MsgBox("User not Registered", vbCritical, vbOK)
dbcon.Close()
clear()
End Try
End Sub
Private Sub b_Click(sender As Object, e As EventArgs) Handles b.Click
clear()
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles
btnClose.Click
MAIN_FORM.Show()
Me.Hide()
End Sub
Private Sub Login_LinkClicked(sender As Object, e As
LinkLabelLinkClickedEventArgs) Handles Login.LinkClicked
Login.Show()
Me.Close()
End Sub
Private Sub txtid_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtid.KeyPress
If Asc(e.KeyChar) <> 1 Then
If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
MsgBox("Only numbers are allowed in this field!!")
e.Handled = True
End If
End If
End Sub
Private Sub txtusername_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtusername.KeyPress
If Asc(e.KeyChar) <> 0 Then
If Asc(e.KeyChar) >= 65 And Asc(e.KeyChar) <= 90 Or Asc(e.KeyChar)
>= 97 And Asc(e.KeyChar) <= 122 Or Asc(e.KeyChar) = 32 Then
e.Handled = False
' MsgBox("Only letters are allowed in this field!!")
'e.Handled = True
Else
e.Handled = True
MsgBox("Only letters are allowed in this field!!")
End If
End If
End Sub
End Class