Professional Documents
Culture Documents
Technical
Solution
ModuleGlobal;
Code;
Imports System.IO
Imports MySql.Data.MySqlClient
Imports System.Security.Cryptography
Imports System.Text
Module ModuleGlobal
'Module is used to store all of the global functions and subroutines that are required for the program
Dim Connect As New MySqlConnection
'declares the connection to the database
Dim Path As String = (Application.StartupPath & Convert.ToString("\DatabaseSettings.txt"))
'path points to where database settings are kept
Try
Dim COMMAND As MySqlCommand
Dim Query As String
'declares the variables required to execute queries
Query = "CREATE TABLE tbl_StaffInfo ( StaffID VARCHAR (10) NOT NULL PRIMARY
KEY, Forename VARCHAR(25) NOT NULL, Surname VARCHAR(35) NOT NULL, Position
VARCHAR (35) )"
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
'creates staff info table
Connect.Close()
'closes connection to the database
End Module
FormLogin;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormLogin
Dim Connect As New MySqlConnection
Dim DatabaseName As String
Dim ServerIp As String
Dim ServerUsername As String
Dim ServerPassword As String
Public UserExit As Boolean
'variables
'Connect is a MySqlConnection, queries will be passed through here
'if the user answers yes then the tables are set up by calling a subroutine in the global
module
MessageBox.Show("Program Exiting, this program cannot run without a database
connection.", "Program requires a database.", MessageBoxButtons.OK)
'tells user that program cannot run without a database connection
Close()
End If
End If
End Sub
Username = TxtUsername.Text
Password = TxtPassword.Text
ValidConnection = ValidateConnect()
'assigns the variable 'validconnection' the returned value from subroutine ValidateConnect
MessageBox.Show("The database connection has failed, please ensure database settings are
correct ", "Database connection error has occurred.")
FormDbInfo.ShowDialog()
'if there is not a valid database connection present then the program prompts user
End If
Else
'if correct details weren't provided
TxtUsername.Text = ""
TxtPassword.Text = ""
MessageBox.Show("Your username or password is incorrect, please try again.",
"Username/Password error.", MessageBoxButtons.OK)
End If
End Sub
Do While READER.Read
CheckPassword = READER("Password")
'assigns the password string to the CheckPassword variable
Loop
Connect.Close()
Catch ex As Exception
MessageBox.Show("Connection to the database has failed. Please check that the information
is correct.", "Error connecting to the database.", MessageBoxButtons.OK)
End Try
Return LoginSuccess
End Function
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormLogin
Inherits System.Windows.Forms.Form
'
Me.TxtUsername.Location = New System.Drawing.Point(128, 172)
Me.TxtUsername.Name = "TxtUsername"
Me.TxtUsername.Size = New System.Drawing.Size(146, 20)
Me.TxtUsername.TabIndex = 5
'
'TxtPassword
'
Me.TxtPassword.Location = New System.Drawing.Point(128, 212)
Me.TxtPassword.Name = "TxtPassword"
Me.TxtPassword.Size = New System.Drawing.Size(146, 20)
Me.TxtPassword.TabIndex = 6
Me.TxtPassword.UseSystemPasswordChar = True
'
'BtnLogin
'
Me.BtnLogin.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.BtnLogin.Location = New System.Drawing.Point(151, 253)
Me.BtnLogin.Name = "BtnLogin"
Me.BtnLogin.Size = New System.Drawing.Size(75, 23)
Me.BtnLogin.TabIndex = 7
Me.BtnLogin.Text = "Login "
Me.BtnLogin.UseVisualStyleBackColor = True
'
'BtnDatabaseInfo
'
Me.BtnDatabaseInfo.Location = New System.Drawing.Point(12, 328)
Me.BtnDatabaseInfo.Name = "BtnDatabaseInfo"
Me.BtnDatabaseInfo.Size = New System.Drawing.Size(89, 23)
Me.BtnDatabaseInfo.TabIndex = 8
Me.BtnDatabaseInfo.Text = "Database Info"
Me.BtnDatabaseInfo.UseVisualStyleBackColor = True
'
'FormLogin
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(366, 363)
Me.Controls.Add(Me.BtnDatabaseInfo)
Me.Controls.Add(Me.BtnLogin)
Me.Controls.Add(Me.TxtPassword)
Me.Controls.Add(Me.TxtUsername)
Me.Controls.Add(Me.LblPassword)
Me.Controls.Add(Me.LblUsername)
Me.Controls.Add(Me.LblLogin)
Me.Controls.Add(Me.ImgLogo)
Me.Name = "FormLogin"
Me.RightToLeftLayout = True
Me.Text = "Login"
CType(Me.ImgLogo, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgLogo As System.Windows.Forms.PictureBox
Friend WithEvents LblLogin As System.Windows.Forms.Label
Friend WithEvents LblUsername As System.Windows.Forms.Label
Friend WithEvents LblPassword As System.Windows.Forms.Label
Friend WithEvents TxtUsername As System.Windows.Forms.TextBox
Friend WithEvents TxtPassword As System.Windows.Forms.TextBox
Friend WithEvents BtnLogin As System.Windows.Forms.Button
Friend WithEvents BtnDatabaseInfo As System.Windows.Forms.Button
End Class
FormDbInfo;
Screenshot;
Form Code;
Imports System.IO
Imports MySql.Data.MySqlClient
Public Class FormDbInfo
Me.Close()
Else
MessageBox.Show("Connection has not been made. Ensure you have entered the right
details.", "Connection error.", MessageBoxButtons.OK)
End If
End Sub
Try
'tries to connect to the server
Connect.Open()
'opens the connection to the server
ValidConnection = True
'if this succeeds then the variable is assigned the value 'true'
Catch ex As Exception
ValidConnection = False
'a false value is assigned to the variable
MessageBox.Show("Valid Connection = False")
MessageBox.Show(ex.Message)
End Try
Connect.Close()
'connection is closed
Return ValidConnection
End Function
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormDbInfo
Inherits System.Windows.Forms.Form
'
Me.LblDatabaseName.AutoSize = True
Me.LblDatabaseName.Location = New System.Drawing.Point(23, 155)
Me.LblDatabaseName.Name = "LblDatabaseName"
Me.LblDatabaseName.Size = New System.Drawing.Size(87, 13)
Me.LblDatabaseName.TabIndex = 15
Me.LblDatabaseName.Text = "Database Name:"
'
'LblUsername
'
Me.LblUsername.AutoSize = True
Me.LblUsername.Location = New System.Drawing.Point(23, 192)
Me.LblUsername.Name = "LblUsername"
Me.LblUsername.Size = New System.Drawing.Size(61, 13)
Me.LblUsername.TabIndex = 16
Me.LblUsername.Text = "Username: "
'
'LblPassword
'
Me.LblPassword.AutoSize = True
Me.LblPassword.Location = New System.Drawing.Point(23, 231)
Me.LblPassword.Name = "LblPassword"
Me.LblPassword.Size = New System.Drawing.Size(56, 13)
Me.LblPassword.TabIndex = 17
Me.LblPassword.Text = "Password:"
'
'TxtServerIP
'
Me.TxtServerIP.Location = New System.Drawing.Point(26, 132)
Me.TxtServerIP.Name = "TxtServerIP"
Me.TxtServerIP.Size = New System.Drawing.Size(244, 20)
Me.TxtServerIP.TabIndex = 18
'
'TxtDatabaseName
'
Me.TxtDatabaseName.Location = New System.Drawing.Point(26, 171)
Me.TxtDatabaseName.Name = "TxtDatabaseName"
Me.TxtDatabaseName.Size = New System.Drawing.Size(244, 20)
Me.TxtDatabaseName.TabIndex = 19
'
'TxtUsername
'
Me.TxtUsername.Location = New System.Drawing.Point(26, 208)
Me.TxtUsername.Name = "TxtUsername"
Me.TxtUsername.Size = New System.Drawing.Size(244, 20)
Me.TxtUsername.TabIndex = 20
'
'TxtPassword
'
Me.TxtPassword.Location = New System.Drawing.Point(26, 247)
Me.TxtPassword.Name = "TxtPassword"
End Sub
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents LblDbConnectionInfo As System.Windows.Forms.Label
Friend WithEvents LblServerIP As System.Windows.Forms.Label
Friend WithEvents LblDatabaseName As System.Windows.Forms.Label
Friend WithEvents LblUsername As System.Windows.Forms.Label
Friend WithEvents LblPassword As System.Windows.Forms.Label
Friend WithEvents TxtServerIP As System.Windows.Forms.TextBox
Friend WithEvents TxtDatabaseName As System.Windows.Forms.TextBox
Friend WithEvents TxtUsername As System.Windows.Forms.TextBox
Friend WithEvents TxtPassword As System.Windows.Forms.TextBox
Friend WithEvents BtnConfirm As System.Windows.Forms.Button
End Class
FormMainMenu;
Screenshot;
Form Code;
Public Class FormMainMenu
End Sub
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormMainMenu
Inherits System.Windows.Forms.Form
End Sub
Friend WithEvents LblWelcome As System.Windows.Forms.Label
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents BtnRecords As System.Windows.Forms.Button
Friend WithEvents BtnQuit As System.Windows.Forms.Button
Friend WithEvents LblInfo1 As System.Windows.Forms.Label
Friend WithEvents LblUser As System.Windows.Forms.Label
Friend WithEvents BtnSettings As System.Windows.Forms.Button
Friend WithEvents LblInfo2 As System.Windows.Forms.Label
Friend WithEvents LblCreateBill As System.Windows.Forms.Label
Friend WithEvents BtnCreateBill As System.Windows.Forms.Button
End Class
FormRecords;
Screenshot;
Form Code;
Public Class FormRecords
Private Sub BtnAddNewStaffMember_Click(sender As Object, e As EventArgs) Handles
BtnAddNewStaffMember.Click
'runs when add new staff member button is clicked
Hide()
FormAddStaffMember.Show()
End Sub
Private Sub BtnAddNewChild_Click(sender As Object, e As EventArgs) Handles
BtnAddNewChild.Click
'runs when add new child button is clicked
Hide()
FormAddNewChild.Show()
End Sub
Private Sub BtnEditStaffMember_Click(sender As Object, e As EventArgs) Handles
BtnEditStaffMember.Click
'runs when edit staff member button is clicked
Hide()
FormEditStaffMember.Show()
End Sub
Private Sub BtnEditChild_Click(sender As Object, e As EventArgs) Handles BtnEditChild.Click
'runs when edit child button is clicked
Hide()
FormEditChildRecord.Show()
End Sub
Private Sub BtnRemoveStaffMember_Click(sender As Object, e As EventArgs) Handles
BtnRemoveStaffMember.Click
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormRecords
Inherits System.Windows.Forms.Form
'Lbl_Records
'
Me.Lbl_Records.AutoSize = True
Me.Lbl_Records.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Lbl_Records.Location = New System.Drawing.Point(142, 25)
Me.Lbl_Records.Name = "Lbl_Records"
Me.Lbl_Records.Size = New System.Drawing.Size(69, 20)
Me.Lbl_Records.TabIndex = 0
Me.Lbl_Records.Text = "Records"
'
'ImgBunnies
'
Me.ImgBunnies.Image = CType(resources.GetObject("ImgBunnies.Image"),
System.Drawing.Image)
Me.ImgBunnies.Location = New System.Drawing.Point(2, 1)
Me.ImgBunnies.Name = "ImgBunnies"
Me.ImgBunnies.Size = New System.Drawing.Size(102, 65)
Me.ImgBunnies.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.ImgBunnies.TabIndex = 2
Me.ImgBunnies.TabStop = False
'
'BtnExit
'
Me.BtnExit.Location = New System.Drawing.Point(251, 269)
Me.BtnExit.Name = "BtnExit"
Me.BtnExit.Size = New System.Drawing.Size(75, 23)
Me.BtnExit.TabIndex = 6
Me.BtnExit.Text = "Exit"
Me.BtnExit.UseVisualStyleBackColor = True
'
'BtnAddNewChild
'
Me.BtnAddNewChild.Location = New System.Drawing.Point(130, 108)
Me.BtnAddNewChild.Name = "BtnAddNewChild"
Me.BtnAddNewChild.Size = New System.Drawing.Size(108, 23)
Me.BtnAddNewChild.TabIndex = 8
Me.BtnAddNewChild.Text = "Add New Child"
Me.BtnAddNewChild.UseVisualStyleBackColor = True
'
'BtnAddNewStaffMember
'
Me.BtnAddNewStaffMember.Location = New System.Drawing.Point(115, 79)
Me.BtnAddNewStaffMember.Name = "BtnAddNewStaffMember"
Me.BtnAddNewStaffMember.Size = New System.Drawing.Size(137, 23)
Me.BtnAddNewStaffMember.TabIndex = 9
Me.BtnAddNewStaffMember.Text = "Add New Staff Member"
Me.BtnAddNewStaffMember.UseVisualStyleBackColor = True
'
'BtnEditChild
'
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Lbl_Records As System.Windows.Forms.Label
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents BtnExit As System.Windows.Forms.Button
Friend WithEvents BtnAddNewChild As System.Windows.Forms.Button
Friend WithEvents BtnAddNewStaffMember As System.Windows.Forms.Button
Friend WithEvents BtnEditChild As System.Windows.Forms.Button
Friend WithEvents BtnEditStaffMember As System.Windows.Forms.Button
Friend WithEvents BtnRemoveChild As System.Windows.Forms.Button
Friend WithEvents BtnRemoveStaffMember As System.Windows.Forms.Button
End Class
FormAddStaffMember;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormAddStaffMember
'imports the required assemblies needed to create MySql Connections
Else
QueryStaffMember = "INSERT INTO tbl_StaffInfo (StaffID, Forename, Surname, Position)
VALUES ('" & TxtStaffID.Text & "','" & TxtForename.Text & "','" & TxtSurname.Text & "','" &
TxtPosition.Text & ")"
End If
'Checks to see if the query requires the position of the employee to be included
QueryLogin = "INSERT INTO tbl_LoginInfo ( Username, Password, StaffID, Admin ) VALUES ('"
& TxtUsername.Text & "','" & UseCipher(TxtPassword.Text) & "','" & TxtStaffID.Text & "','" &
AdminChar & ")"
'assigns the query for entering data into login info table
Try
Connect.Open()
COMMAND = New MySqlCommand(Query, Connect)
COMMAND = ExecuteNonQuery()
COMMAND.Dispose()
'executes the query that adds information to tbl_LoginInfo
COMMAND = New MySqlCommand(QueryStaffMember, Connect)
COMMAND = ExecuteNonQuery()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Connect.close()
MessageBox.Show("New Staff Member has been successfully added, they will now be able to
log onto the system.", "New Staff Member successfully added", MessageBoxButtons.OK)
Close()
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormAddStaffMember
Inherits System.Windows.Forms.Form
Me.LblAddNewStaff.TabIndex = 5
Me.LblAddNewStaff.Text = "Add New Staff Member"
'
'LblStaffID
'
Me.LblStaffID.AutoSize = True
Me.LblStaffID.Location = New System.Drawing.Point(65, 127)
Me.LblStaffID.Name = "LblStaffID"
Me.LblStaffID.Size = New System.Drawing.Size(46, 13)
Me.LblStaffID.TabIndex = 6
Me.LblStaffID.Text = "Staff ID:"
'
'Lbl_Forename
'
Me.Lbl_Forename.AutoSize = True
Me.Lbl_Forename.Location = New System.Drawing.Point(59, 165)
Me.Lbl_Forename.Name = "Lbl_Forename"
Me.Lbl_Forename.Size = New System.Drawing.Size(57, 13)
Me.Lbl_Forename.TabIndex = 7
Me.Lbl_Forename.Text = "Forename:"
'
'LblSurname
'
Me.LblSurname.AutoSize = True
Me.LblSurname.Location = New System.Drawing.Point(59, 205)
Me.LblSurname.Name = "LblSurname"
Me.LblSurname.Size = New System.Drawing.Size(52, 13)
Me.LblSurname.TabIndex = 8
Me.LblSurname.Text = "Surname:"
'
'LblPosition
'
Me.LblPosition.AutoSize = True
Me.LblPosition.Location = New System.Drawing.Point(57, 244)
Me.LblPosition.Name = "LblPosition"
Me.LblPosition.Size = New System.Drawing.Size(50, 13)
Me.LblPosition.TabIndex = 9
Me.LblPosition.Text = "Position: "
'
'LblAdmin
'
Me.LblAdmin.AutoSize = True
Me.LblAdmin.Location = New System.Drawing.Point(205, 126)
Me.LblAdmin.Name = "LblAdmin"
Me.LblAdmin.Size = New System.Drawing.Size(39, 13)
Me.LblAdmin.TabIndex = 10
Me.LblAdmin.Text = "Admin:"
'
'LblUsername
'
Me.LblUsername.AutoSize = True
Me.RadBtnYes.Text = "Yes"
Me.RadBtnYes.UseVisualStyleBackColor = True
'
'RadBtnNo
'
Me.RadBtnNo.AutoSize = True
Me.RadBtnNo.Location = New System.Drawing.Point(269, 143)
Me.RadBtnNo.Name = "RadBtnNo"
Me.RadBtnNo.Size = New System.Drawing.Size(39, 17)
Me.RadBtnNo.TabIndex = 18
Me.RadBtnNo.TabStop = True
Me.RadBtnNo.Text = "No"
Me.RadBtnNo.UseVisualStyleBackColor = True
'
'TxtUsername
'
Me.TxtUsername.Location = New System.Drawing.Point(208, 182)
Me.TxtUsername.Name = "TxtUsername"
Me.TxtUsername.Size = New System.Drawing.Size(100, 20)
Me.TxtUsername.TabIndex = 19
'
'TxtPassword
'
Me.TxtPassword.Location = New System.Drawing.Point(208, 221)
Me.TxtPassword.Name = "TxtPassword"
Me.TxtPassword.Size = New System.Drawing.Size(100, 20)
Me.TxtPassword.TabIndex = 20
'
'BtnCancel
'
Me.BtnCancel.Location = New System.Drawing.Point(60, 319)
Me.BtnCancel.Name = "BtnCancel"
Me.BtnCancel.Size = New System.Drawing.Size(75, 23)
Me.BtnCancel.TabIndex = 21
Me.BtnCancel.Text = "Cancel "
Me.BtnCancel.UseVisualStyleBackColor = True
'
'BtnConfirm
'
Me.BtnConfirm.Location = New System.Drawing.Point(233, 319)
Me.BtnConfirm.Name = "BtnConfirm"
Me.BtnConfirm.Size = New System.Drawing.Size(75, 23)
Me.BtnConfirm.TabIndex = 22
Me.BtnConfirm.Text = "Confirm"
Me.BtnConfirm.UseVisualStyleBackColor = True
'
'FormAddStaffMember
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(407, 376)
Me.Controls.Add(Me.BtnConfirm)
Me.Controls.Add(Me.BtnCancel)
Me.Controls.Add(Me.TxtPassword)
Me.Controls.Add(Me.TxtUsername)
Me.Controls.Add(Me.RadBtnNo)
Me.Controls.Add(Me.RadBtnYes)
Me.Controls.Add(Me.TxtPosition)
Me.Controls.Add(Me.TxtSurname)
Me.Controls.Add(Me.TxtForename)
Me.Controls.Add(Me.TxtStaffID)
Me.Controls.Add(Me.LblPassword)
Me.Controls.Add(Me.LblUsername)
Me.Controls.Add(Me.LblAdmin)
Me.Controls.Add(Me.LblPosition)
Me.Controls.Add(Me.LblSurname)
Me.Controls.Add(Me.Lbl_Forename)
Me.Controls.Add(Me.LblStaffID)
Me.Controls.Add(Me.LblAddNewStaff)
Me.Controls.Add(Me.ImgBunnies)
Me.Name = "FormAddStaffMember"
Me.Text = "Add New Staff Member"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblAddNewStaff As System.Windows.Forms.Label
Friend WithEvents LblStaffID As System.Windows.Forms.Label
Friend WithEvents Lbl_Forename As System.Windows.Forms.Label
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents LblPosition As System.Windows.Forms.Label
Friend WithEvents LblAdmin As System.Windows.Forms.Label
Friend WithEvents LblUsername As System.Windows.Forms.Label
Friend WithEvents LblPassword As System.Windows.Forms.Label
Friend WithEvents TxtStaffID As System.Windows.Forms.TextBox
Friend WithEvents TxtForename As System.Windows.Forms.TextBox
Friend WithEvents TxtSurname As System.Windows.Forms.TextBox
Friend WithEvents TxtPosition As System.Windows.Forms.TextBox
Friend WithEvents RadBtnYes As System.Windows.Forms.RadioButton
Friend WithEvents RadBtnNo As System.Windows.Forms.RadioButton
Friend WithEvents TxtUsername As System.Windows.Forms.TextBox
Friend WithEvents TxtPassword As System.Windows.Forms.TextBox
Friend WithEvents BtnCancel As System.Windows.Forms.Button
Friend WithEvents BtnConfirm As System.Windows.Forms.Button
End Class
FormEditStaffMember;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormEditStaffMember
While READER.Read()
TxtPosition.Text = READER("Position")
TxtStaffID.Text = READER("StaffID")
StaffID = TxtStaffID.Text
AdminChar = READER("Admin")
'reads in data to matching textboxes
Else
Admin = False
'assigns a boolean value based on the value that is read in
'allows radio button to be set correctly
End If
RadBtnYes.Checked = Admin
RadBtnNo.Checked = Not Admin
TxtUsername.Text = READER("Username")
TxtForenameChange.Text = TxtForenameChange.Text
TxtSurnameChange.Text = TxtSurnameChange.Text
'assigns the correct values for the radio buttons
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Connect.Close()
End Sub
Try
Connect.Open()
Catch ex As Exception
End Try
Query = "Select * from tbl_StaffInfo, tbl_LoginInfo where tbl_StaffInfo.Forename = '" & Forename
& "' AND tbl_StaffInfo.Surname = '" & Surname & "' AND tbl_LoginInfo.StaffID = tbl_StaffInfo.StaffID"
COMMAND = New MySqlCommand(Query, Connect)
READER = COMMAND.ExecuteReader
While READER.Read()
CheckForename = READER("Forename")
CheckSurname = READER("Surname")
CheckPosition = READER("Position")
CheckStaffID = READER("StaffID")
CheckUsername = READER("Username")
CheckAdmin = READER("Admin")
CheckAdmin = "0"
Else
CheckAdmin = "1"
End If
Try
Query = "UPDATE tbl_LoginInfo SET Admin" & CheckAdmin & " WHERE StaffID = '" &
TxtStaffID.Text & "'"
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Select
MessageBox.Show(ex.Message)
End Try
End Select
'select cases used to check each piece of information to see whether it is
'the same as information already stored
'if it isn't then command is executed in order to update the info
Surname = TxtSurname.Text
'counter is reset and variables are assigned values
PopulateInfo(TxtForename.Text, TxtSurname.Text)
'calls populateinfo to pass on staff member forename and surname to the subroutine
End Sub
Private Sub UpdateSpecific(ByRef Table As String, ByVal Column As String, ByVal Text As String,
ByVal ConstColumn As String, ByVal ConstText As String)
'update specific routine, used to automate large amount of update commands
If ConstColumn = "" Then
ConstColumn = "StaffID"
'used for default, if the constcolumn is not specified then StaffID used
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormEditStaffMember
Inherits System.Windows.Forms.Form
Me.LblForenameChange.Text = "Forename:"
'
'LblSurnameChange
'
Me.LblSurnameChange.AutoSize = True
Me.LblSurnameChange.Location = New System.Drawing.Point(211, 225)
Me.LblSurnameChange.Name = "LblSurnameChange"
Me.LblSurnameChange.Size = New System.Drawing.Size(55, 13)
Me.LblSurnameChange.TabIndex = 10
Me.LblSurnameChange.Text = "Surname: "
'
'LblPosition
'
Me.LblPosition.AutoSize = True
Me.LblPosition.Location = New System.Drawing.Point(50, 264)
Me.LblPosition.Name = "LblPosition"
Me.LblPosition.Size = New System.Drawing.Size(50, 13)
Me.LblPosition.TabIndex = 11
Me.LblPosition.Text = "Position: "
'
'LblStaffID
'
Me.LblStaffID.AutoSize = True
Me.LblStaffID.Location = New System.Drawing.Point(50, 304)
Me.LblStaffID.Name = "LblStaffID"
Me.LblStaffID.Size = New System.Drawing.Size(49, 13)
Me.LblStaffID.TabIndex = 12
Me.LblStaffID.Text = "Staff ID: "
'
'LblUsername
'
Me.LblUsername.AutoSize = True
Me.LblUsername.Location = New System.Drawing.Point(208, 264)
Me.LblUsername.Name = "LblUsername"
Me.LblUsername.Size = New System.Drawing.Size(58, 13)
Me.LblUsername.TabIndex = 13
Me.LblUsername.Text = "Username:"
'
'LblAdmin
'
Me.LblAdmin.AutoSize = True
Me.LblAdmin.Location = New System.Drawing.Point(211, 304)
Me.LblAdmin.Name = "LblAdmin"
Me.LblAdmin.Size = New System.Drawing.Size(42, 13)
Me.LblAdmin.TabIndex = 14
Me.LblAdmin.Text = "Admin: "
'
'BtnSearch
'
Me.BtnSearch.Location = New System.Drawing.Point(141, 187)
Me.BtnSearch.Name = "BtnSearch"
Me.Controls.Add(Me.TxtStaffID)
Me.Controls.Add(Me.TxtUsername)
Me.Controls.Add(Me.TxtPosition)
Me.Controls.Add(Me.TxtSurnameChange)
Me.Controls.Add(Me.TxtForenameChange)
Me.Controls.Add(Me.TxtSurname)
Me.Controls.Add(Me.TxtForename)
Me.Controls.Add(Me.BtnExit)
Me.Controls.Add(Me.BtnSearch)
Me.Controls.Add(Me.LblAdmin)
Me.Controls.Add(Me.LblUsername)
Me.Controls.Add(Me.LblStaffID)
Me.Controls.Add(Me.LblPosition)
Me.Controls.Add(Me.LblSurnameChange)
Me.Controls.Add(Me.LblForenameChange)
Me.Controls.Add(Me.LblSurname)
Me.Controls.Add(Me.LblForename)
Me.Controls.Add(Me.LblEditStaffMember)
Me.Controls.Add(Me.ImgBunnies)
Me.Name = "FormEditStaffMember"
Me.Text = "Edit Staff Member"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblEditStaffMember As System.Windows.Forms.Label
Friend WithEvents LblForename As System.Windows.Forms.Label
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents LblForenameChange As System.Windows.Forms.Label
Friend WithEvents LblSurnameChange As System.Windows.Forms.Label
Friend WithEvents LblPosition As System.Windows.Forms.Label
Friend WithEvents LblStaffID As System.Windows.Forms.Label
Friend WithEvents LblUsername As System.Windows.Forms.Label
Friend WithEvents LblAdmin As System.Windows.Forms.Label
Friend WithEvents BtnSearch As System.Windows.Forms.Button
Friend WithEvents BtnExit As System.Windows.Forms.Button
Friend WithEvents TxtForename As System.Windows.Forms.TextBox
Friend WithEvents TxtSurname As System.Windows.Forms.TextBox
Friend WithEvents TxtForenameChange As System.Windows.Forms.TextBox
Friend WithEvents TxtSurnameChange As System.Windows.Forms.TextBox
Friend WithEvents TxtPosition As System.Windows.Forms.TextBox
Friend WithEvents TxtUsername As System.Windows.Forms.TextBox
Friend WithEvents TxtStaffID As System.Windows.Forms.TextBox
Friend WithEvents RadBtnYes As System.Windows.Forms.RadioButton
Friend WithEvents RadBtnNo As System.Windows.Forms.RadioButton
Friend WithEvents BtnEdit As System.Windows.Forms.Button
End Class
FormRemoveStaffMember;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormRemoveStaffMember
Dim Connect As New MySqlConnection
Dim Query As String
Dim READER As MySqlDataReader
Dim COMMAND As MySqlCommand
Dim ServerIP As String
Dim ServerUsername As String
Dim ServerPassword As String
Dim DatabaseName As String
'variables
While READER.Read
ComBoxForename.Items.Add(READER("Forename"))
'populares the combobox
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Try
Connect.Open()
While READER.Read
ComBoxSurname.Items.Add(READER("Surname"))
'populares the combobox
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Connect.Close()
End Sub
Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click
'runs when user clicks the remove button, deletes the selected Staff's record
Query = "Delete from tbl_StaffInfo where Forename = '" & ComBoxForename.Text & "where
Surname = " & ComBoxSurname.Text & "'"
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormRemoveStaffMember
Inherits System.Windows.Forms.Form
'
'LblForename
'
Me.LblForename.AutoSize = True
Me.LblForename.Location = New System.Drawing.Point(56, 125)
Me.LblForename.Name = "LblForename"
Me.LblForename.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.LblForename.Size = New System.Drawing.Size(60, 13)
Me.LblForename.TabIndex = 14
Me.LblForename.Text = "Forename: "
'
'LblRemoveStaffMember
'
Me.LblRemoveStaffMember.AutoSize = True
Me.LblRemoveStaffMember.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LblRemoveStaffMember.Location = New System.Drawing.Point(96, 69)
Me.LblRemoveStaffMember.Name = "LblRemoveStaffMember"
Me.LblRemoveStaffMember.Size = New System.Drawing.Size(169, 20)
Me.LblRemoveStaffMember.TabIndex = 13
Me.LblRemoveStaffMember.Text = "Remove Staff Member"
'
'ImgBunnies
'
Me.ImgBunnies.Image = CType(resources.GetObject("ImgBunnies.Image"),
System.Drawing.Image)
Me.ImgBunnies.Location = New System.Drawing.Point(-1, 1)
Me.ImgBunnies.Name = "ImgBunnies"
Me.ImgBunnies.Size = New System.Drawing.Size(102, 65)
Me.ImgBunnies.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.ImgBunnies.TabIndex = 19
Me.ImgBunnies.TabStop = False
'
'FormRemoveStaffMember
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(334, 263)
Me.Controls.Add(Me.ImgBunnies)
Me.Controls.Add(Me.BtnRemove)
Me.Controls.Add(Me.ComBoxSurname)
Me.Controls.Add(Me.ComBoxForename)
Me.Controls.Add(Me.LblSurname)
Me.Controls.Add(Me.LblForename)
Me.Controls.Add(Me.LblRemoveStaffMember)
Me.Name = "FormRemoveStaffMember"
Me.Text = "FormRemoveStaffMember"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents BtnRemove As System.Windows.Forms.Button
Friend WithEvents ComBoxSurname As System.Windows.Forms.ComboBox
Friend WithEvents ComBoxForename As System.Windows.Forms.ComboBox
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents LblForename As System.Windows.Forms.Label
Friend WithEvents LblRemoveStaffMember As System.Windows.Forms.Label
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
End Class
FormAddNewChild;
Screenshot;
Form Code;
Imports MySql.Data.SqlClient
Public Class FormAddNewChild
'imports the required assemblies needed in order to use MySQL Connection
Public Class FormAddNewChild
Dim Connect As New MySqlConnection
Dim Query As String
Dim READER As MySqlDataReader
Dim COMMAND As MySqlCommand
Dim ServerIP As String
Dim ServerUsername As String
Dim ServerPassword As String
Dim DatabaseName As String
'These are the class variables used throughout the class
'so they are declared at the top
'not accessible anywhere else in program
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormAddNewChild
Inherits System.Windows.Forms.Form
Me.LblChildID.Text = "ChildID:"
'
'LblForename
'
Me.LblForename.AutoSize = True
Me.LblForename.Location = New System.Drawing.Point(48, 159)
Me.LblForename.Name = "LblForename"
Me.LblForename.Size = New System.Drawing.Size(39, 13)
Me.LblForename.TabIndex = 13
Me.LblForename.Text = "LblForename"
'
'LblSurname
'
Me.LblSurname.AutoSize = True
Me.LblSurname.Location = New System.Drawing.Point(48, 197)
Me.LblSurname.Name = "LblSurname"
Me.LblSurname.Size = New System.Drawing.Size(39, 13)
Me.LblSurname.TabIndex = 14
Me.LblSurname.Text = "LblSurname"
'
'LblDateOfBirth
'
Me.LblDateOfBirth.AutoSize = True
Me.LblDateOfBirth.Location = New System.Drawing.Point(48, 235)
Me.LblDateOfBirth.Name = "LblDateOfBirth"
Me.LblDateOfBirth.Size = New System.Drawing.Size(39, 13)
Me.LblDateOfBirth.TabIndex = 15
Me.LblDateOfBirth.Text = "LblDateOfBirth"
'
'LblChildMedicalNeeds
'
Me.LblChildMedicalNeeds.AutoSize = True
Me.LblChildMedicalNeeds.Location = New System.Drawing.Point(220, 122)
Me.LblChildMedicalNeeds.Name = "LblChildMedicalNeeds"
Me.LblChildMedicalNeeds.Size = New System.Drawing.Size(39, 13)
Me.LblChildMedicalNeeds.TabIndex = 16
Me.LblChildMedicalNeeds.Text = "LblChildMedicalNeeds"
'
'LblMedicineNeeded
'
Me.LblMedicineNeeded.AutoSize = True
Me.LblMedicineNeeded.Location = New System.Drawing.Point(220, 159)
Me.LblMedicineNeeded.Name = "LblMedicineNeeded"
Me.LblMedicineNeeded.Size = New System.Drawing.Size(39, 13)
Me.LblMedicineNeeded.TabIndex = 17
Me.LblMedicineNeeded.Text = "LblMedicineNeeded"
'
'LblAddNewChild
'
Me.LblAddNewChild.AutoSize = True
Me.LblAddNewChild.Location = New System.Drawing.Point(165, 78)
Me.LblAddNewChild.Name = "LblAddNewChild"
Me.LblAddNewChild.Size = New System.Drawing.Size(39, 13)
Me.LblAddNewChild.TabIndex = 18
Me.LblAddNewChild.Text = "LblAddNewChild"
'
'FormAddNewChild
'
Me.ClientSize = New System.Drawing.Size(371, 322)
Me.Controls.Add(Me.LblMedicineNeeded)
Me.Controls.Add(Me.LblChildMedicalNeeds)
Me.Controls.Add(Me.LblDateOfBirth)
Me.Controls.Add(Me.LblSurname)
Me.Controls.Add(Me.LblForename)
Me.Controls.Add(Me.LblChildID)
Me.Controls.Add(Me.PictureBox1)
Me.Name = "FormAddNewChild"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblAddNewChild As System.Windows.Forms.Label
Friend WithEvents LblChildID As System.Windows.Forms.Label
Friend WithEvents LblForename As System.Windows.Forms.Label
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents LblChildMedicalNeeds As System.Windows.Forms.Label
Friend WithEvents LblMedicineNeeded As System.Windows.Forms.Label
Friend WithEvents TxtChildID As System.Windows.Forms.TextBox
Friend WithEvents TxtForename As System.Windows.Forms.TextBox
Friend WithEvents TxtSurname As System.Windows.Forms.TextBox
Friend WithEvents TxtChildMedicalNeeds As System.Windows.Forms.TextBox
Friend WithEvents TxtMedicineNeeded As System.Windows.Forms.TextBox
Friend WithEvents LblDateOfBirth As System.Windows.Forms.Label
Friend WithEvents TxtDateOfBirth As System.Windows.Forms.TextBox
Friend WithEvents Exit_Button As System.Windows.Forms.Button
Friend WithEvents Confirm_Button As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents LblChildID As System.Windows.Forms.Label
Friend WithEvents LblForename As System.Windows.Forms.Label
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents LblDateOfBirth As System.Windows.Forms.Label
Friend WithEvents LblChildMedicalNeeds As System.Windows.Forms.Label
Friend WithEvents LblMedicineNeeded As System.Windows.Forms.Label
Friend WithEvents LblAddNewChild As System.Windows.Forms.Label
End Class
FormEditChildRecord;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
TxtChildID.Text = READER("StaffID")
TxtForename.Text = READER("Forename")
TxtSurname.Text = READER("Surname")
TxtChildMedicalNeeds.Text = READER("ChildMedicalNeeds")
TxtMedicineNeeded.Text = READER("MedicineNeeded")
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'reads in info and assigns it to textboxes
End Sub
End Try
Case Else
End Select
'do nothing
Catch ex As Exception
End Try
Select Case CheckForename
Case Is <> TxtForename.Text
Try
Query = ("UPDATE tbl_ChildInfo SET Forename = '" & TxtForename.Text & "' WHERE
Forename = '" & ComBoxChild.Text & "'")
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
'case statement to check whether the data in textboxes
'is the same as the check data
'if it isn't, command executes in order to update
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Case Else
End Select
'do nothing
Select Case CheckSurname
Case Is <> TxtSurname.Text
Try
Query = ("UPDATE tbl_ChildInfo SET Surname = '" & TxtSurname.Text & "' WHERE
Forename = '" & ComBoxChild.Text & "'")
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
'case statement to check whether the data in textboxes
'is the same as the check data
'if it isn't, command executes in order to update
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Case Else
End Select
'do nothing
Select Case CheckChildMedicalNeeds
Case Is <> TxtChildMedicalNeeds.Text
Try
Query = ("UPDATE tbl_ChildInfo SET ChildMedicalNeeds = '" &
TxtChildMedicalNeeds.Text & "' WHERE Forename = '" & ComBoxChild.Text & "'")
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
'case statement to check whether the data in textboxes
'is the same as the check data
'if it isn't, command executes in order to update
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Case Else
End Select
'do nothing
Select Case CheckMedicineNeeded
Case Is <> TxtMedicineNeeded.Text
Try
Query = ("UPDATE tbl_ChildInfo SET MedicineNeeded = '" & TxtMedicineNeeded.Text
& "' WHERE Forename = '" & ComBoxChild.Text & "'")
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
'case statement to check whether the data in textboxes
'is the same as the check data
'if it isn't, command executes in order to update
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Case Else
End Select
Try
'do nothing
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Connect.Close()
Else
MessageBox.Show("Please make amendments to the boxes so that the string limit is not
exceeded.")
End If
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormEditChildRecord
Inherits System.Windows.Forms.Form
Me.ImgBunnies.Name = "ImgBunnies"
Me.ImgBunnies.Size = New System.Drawing.Size(102, 65)
Me.ImgBunnies.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.ImgBunnies.TabIndex = 4
Me.ImgBunnies.TabStop = False
'
'LblEditChildRecord
'
Me.LblEditChildRecord.AutoSize = True
Me.LblEditChildRecord.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LblEditChildRecord.Location = New System.Drawing.Point(164, 52)
Me.LblEditChildRecord.Name = "LblEditChildRecord"
Me.LblEditChildRecord.Size = New System.Drawing.Size(112, 16)
Me.LblEditChildRecord.TabIndex = 5
Me.LblEditChildRecord.Text = "Edit Child Record"
'
'LblChild
'
Me.LblChild.AutoSize = True
Me.LblChild.Location = New System.Drawing.Point(64, 107)
Me.LblChild.Name = "LblChild"
Me.LblChild.Size = New System.Drawing.Size(36, 13)
Me.LblChild.TabIndex = 6
Me.LblChild.Text = "Child: "
'
'LblChildID
'
Me.LblChildID.AutoSize = True
Me.LblChildID.Location = New System.Drawing.Point(46, 159)
Me.LblChildID.Name = "LblChildID"
Me.LblChildID.Size = New System.Drawing.Size(44, 13)
Me.LblChildID.TabIndex = 7
Me.LblChildID.Text = "ChildID:"
'
'LblForename
'
Me.LblForename.AutoSize = True
Me.LblForename.Location = New System.Drawing.Point(47, 231)
Me.LblForename.Name = "LblForename"
Me.LblForename.Size = New System.Drawing.Size(60, 13)
Me.LblForename.TabIndex = 8
Me.LblForename.Text = "Forename: "
'
'LblSurname
'
Me.LblSurname.AutoSize = True
Me.LblSurname.Location = New System.Drawing.Point(47, 281)
Me.LblSurname.Name = "LblSurname"
Me.LblSurname.Size = New System.Drawing.Size(55, 13)
Me.LblSurname.TabIndex = 9
Me.TxtMedicineNeeded.Name = "TxtMedicineNeeded"
Me.TxtMedicineNeeded.Size = New System.Drawing.Size(163, 20)
Me.TxtMedicineNeeded.TabIndex = 16
'
'BtnUpdate
'
Me.BtnUpdate.Location = New System.Drawing.Point(284, 320)
Me.BtnUpdate.Name = "BtnUpdate"
Me.BtnUpdate.Size = New System.Drawing.Size(75, 23)
Me.BtnUpdate.TabIndex = 17
Me.BtnUpdate.Text = "Update"
Me.BtnUpdate.UseVisualStyleBackColor = True
'
'ComBoxChild
'
Me.ComBoxChild.FormattingEnabled = True
Me.ComBoxChild.Location = New System.Drawing.Point(106, 107)
Me.ComBoxChild.Name = "ComBoxChild"
Me.ComBoxChild.Size = New System.Drawing.Size(121, 21)
Me.ComBoxChild.TabIndex = 18
'
'BtnSelect
'
Me.BtnSelect.Location = New System.Drawing.Point(264, 107)
Me.BtnSelect.Name = "BtnSelect"
Me.BtnSelect.Size = New System.Drawing.Size(75, 23)
Me.BtnSelect.TabIndex = 19
Me.BtnSelect.Text = "Select"
Me.BtnSelect.UseVisualStyleBackColor = True
'
'FormEditChildRecord
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(405, 355)
Me.Controls.Add(Me.BtnSelect)
Me.Controls.Add(Me.ComBoxChild)
Me.Controls.Add(Me.BtnUpdate)
Me.Controls.Add(Me.TxtMedicineNeeded)
Me.Controls.Add(Me.TxtChildMedicalNeeds)
Me.Controls.Add(Me.TxtSurname)
Me.Controls.Add(Me.TxtForename)
Me.Controls.Add(Me.TxtChildID)
Me.Controls.Add(Me.LblMedicineNeeded)
Me.Controls.Add(Me.LblChildMedicalNeeds)
Me.Controls.Add(Me.LblSurname)
Me.Controls.Add(Me.LblForename)
Me.Controls.Add(Me.LblChildID)
Me.Controls.Add(Me.LblChild)
Me.Controls.Add(Me.LblEditChildRecord)
Me.Controls.Add(Me.ImgBunnies)
Me.Name = "FormEditChildRecord"
Me.Text = "Edit Child Record"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblEditChildRecord As System.Windows.Forms.Label
Friend WithEvents LblChild As System.Windows.Forms.Label
Friend WithEvents LblChildID As System.Windows.Forms.Label
Friend WithEvents LblForename As System.Windows.Forms.Label
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents LblChildMedicalNeeds As System.Windows.Forms.Label
Friend WithEvents LblMedicineNeeded As System.Windows.Forms.Label
Friend WithEvents TxtChildID As System.Windows.Forms.TextBox
Friend WithEvents TxtForename As System.Windows.Forms.TextBox
Friend WithEvents TxtSurname As System.Windows.Forms.TextBox
Friend WithEvents TxtChildMedicalNeeds As System.Windows.Forms.TextBox
Friend WithEvents TxtMedicineNeeded As System.Windows.Forms.TextBox
Friend WithEvents BtnUpdate As System.Windows.Forms.Button
Friend WithEvents ComBoxChild As System.Windows.Forms.ComboBox
Friend WithEvents BtnSelect As System.Windows.Forms.Button
End Class
FormRemoveChildRecord;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormRemoveChildRecord
Dim Connect As New MySqlConnection
Dim Query As String
Dim READER As MySqlDataReader
Dim COMMAND As MySqlCommand
Dim ServerIP As String
Dim ServerUsername As String
Dim ServerPassword As String
Dim DatabaseName As String
'variables
End Sub
While READER.Read
ComBoxForename.Items.Add(READER("Forename"))
'populares the combobox
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Try
Connect.Open()
While READER.Read
ComBoxSurname.Items.Add(READER("Surname"))
'populares the combobox
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Connect.Close()
End Sub
Query = "Delete from tbl_ChildInfo where Forename = '" & ComBoxForename.Text & "where
Surname = " & ComBoxSurname.Text & "'"
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show("The record for child has been deleted successfully, the record has been
removed from the appropriate database(s).", "Record deleted successfully.", MessageBoxButtons.OK)
End Try
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormRemoveChildRecord
Inherits System.Windows.Forms.Form
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblRemoveChildRecord As System.Windows.Forms.Label
Friend WithEvents LblForename As System.Windows.Forms.Label
Friend WithEvents LblSurname As System.Windows.Forms.Label
Friend WithEvents ComBoxForename As System.Windows.Forms.ComboBox
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents ComBoxSurname As System.Windows.Forms.ComboBox
Friend WithEvents BtnRemove As System.Windows.Forms.Button
End Class
FormSettings;
Screenshot;
Form Code;
Public Class FormSettings
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormSettings
Inherits System.Windows.Forms.Form
End Try
End Sub
'BtnChangePassword
'
Me.BtnChangePassword.Location = New System.Drawing.Point(184, 126)
Me.BtnChangePassword.Name = "BtnChangePassword"
Me.BtnChangePassword.Size = New System.Drawing.Size(114, 23)
Me.BtnChangePassword.TabIndex = 8
Me.BtnChangePassword.Text = "Change Password"
Me.BtnChangePassword.UseVisualStyleBackColor = True
'
'FormSettings
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(335, 208)
Me.Controls.Add(Me.BtnChangePassword)
Me.Controls.Add(Me.BtnChangeUsername)
Me.Controls.Add(Me.LblSettings)
Me.Controls.Add(Me.ImgBunnies)
Me.Name = "FormSettings"
Me.Text = "FormSettings"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblSettings As System.Windows.Forms.Label
Friend WithEvents BtnChangeUsername As System.Windows.Forms.Button
Friend WithEvents BtnChangePassword As System.Windows.Forms.Button
End Class
FormChangeUsername;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormChangeUsername
Private Sub BtnChange_Click(sender As Object, e As EventArgs) Handles BtnChange.Click
'runs when change button is clicked by user
Dim Query As String = ""
Dim DatabaseName As String = ""
Dim ServerIP As String = ""
Query = "UPDATE tbl_LoginInfo SET Username = '" & TxtNewUsername.Text & "'WHERE
Username = '" & TxtOldUsername.Text & "'"
'updates the new password
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormChangeUsername
Inherits System.Windows.Forms.Form
Me.LblNewUsername.Name = "LblNewUsername"
Me.LblNewUsername.Size = New System.Drawing.Size(86, 13)
Me.LblNewUsername.TabIndex = 9
Me.LblNewUsername.Text = "New Username: "
'
'FormChangeUsername
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(317, 246)
Me.Controls.Add(Me.LblNewUsername)
Me.Controls.Add(Me.LblOldUsername)
Me.Controls.Add(Me.TxtNewUsername)
Me.Controls.Add(Me.TxtOldUsername)
Me.Controls.Add(Me.ImgBunnies)
Me.Controls.Add(Me.BtnChange)
Me.Name = "FormChangeUsername"
Me.Text = "Change Username"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents BtnChange As System.Windows.Forms.Button
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents TxtOldUsername As System.Windows.Forms.TextBox
Friend WithEvents TxtNewUsername As System.Windows.Forms.TextBox
Friend WithEvents LblOldUsername As System.Windows.Forms.Label
Friend WithEvents LblNewUsername As System.Windows.Forms.Label
End Class
FormChangePassword;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormChangePassword
Private Sub BtnChange_Click(sender As Object, e As EventArgs) Handles BtnChange.Click
'runs when change button is clicked by user
Dim Query As String = ""
Dim DatabaseName As String = ""
Dim ServerIP As String = ""
Query = "UPDATE tbl_LoginInfo SET Password = '" & TxtNewPassword.Text & "'WHERE
Password = '" & TxtOldPassword.Text & "'"
'updates the new password
COMMAND.ExecuteNonQuery()
ChangeComplete = True
'if everything matches, then change is successfully
Catch ex As Exception
ChangeComplete = False
MessageBox.Show("Your Password has not been changed.", "Error Occurred.",
MessageBoxButtons.OK)
'if not then change will not occur
End Try
If ChangeComplete = True Then
MessageBox.Show("Your Password has been successfully changed.", "Password changed
successfully.", MessageBoxButtons.OK)
'message displayed to user to tell them their Password has been changed
Close()
End If
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormChangePassword
Inherits System.Windows.Forms.Form
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'LblNewPassword
'
Me.LblNewPassword.AutoSize = True
Me.LblNewPassword.Location = New System.Drawing.Point(85, 123)
Me.LblNewPassword.Name = "LblNewPassword"
Me.LblNewPassword.Size = New System.Drawing.Size(81, 13)
Me.LblNewPassword.TabIndex = 15
Me.LblNewPassword.Text = "New Password:"
'
'LblOldPassword
'
Me.LblOldPassword.AutoSize = True
Me.LblOldPassword.Location = New System.Drawing.Point(85, 74)
Me.LblOldPassword.Name = "LblOldPassword"
Me.LblOldPassword.Size = New System.Drawing.Size(75, 13)
Me.LblOldPassword.TabIndex = 14
Me.LblOldPassword.Text = "Old Password:"
'
'TxtNewPassword
'
Me.TxtNewPassword.Location = New System.Drawing.Point(88, 139)
Me.TxtNewPassword.Name = "TxtNewPassword"
Me.TxtNewPassword.Size = New System.Drawing.Size(165, 20)
Me.TxtNewPassword.TabIndex = 13
Me.TxtNewPassword.UseSystemPasswordChar = True
'
'TxtOldPassword
'
Me.TxtOldPassword.Location = New System.Drawing.Point(88, 90)
Me.TxtOldPassword.Name = "TxtOldPassword"
Me.TxtOldPassword.Size = New System.Drawing.Size(165, 20)
Me.TxtOldPassword.TabIndex = 12
Me.TxtOldPassword.UseSystemPasswordChar = True
'
'ImgBunnies
'
Me.ImgBunnies.Image = CType(resources.GetObject("ImgBunnies.Image"),
System.Drawing.Image)
Me.ImgBunnies.Location = New System.Drawing.Point(0, -2)
Me.ImgBunnies.Name = "ImgBunnies"
Me.ImgBunnies.Size = New System.Drawing.Size(102, 65)
Me.ImgBunnies.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.ImgBunnies.TabIndex = 11
Me.ImgBunnies.TabStop = False
'
'BtnChange
'
Me.BtnChange.Location = New System.Drawing.Point(117, 187)
Me.BtnChange.Name = "BtnChange"
Me.BtnChange.Size = New System.Drawing.Size(75, 23)
Me.BtnChange.TabIndex = 10
Me.BtnChange.Text = "Change"
Me.BtnChange.UseVisualStyleBackColor = True
'
'FormChangePassword
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(336, 214)
Me.Controls.Add(Me.LblNewPassword)
Me.Controls.Add(Me.LblOldPassword)
Me.Controls.Add(Me.TxtNewPassword)
Me.Controls.Add(Me.TxtOldPassword)
Me.Controls.Add(Me.ImgBunnies)
Me.Controls.Add(Me.BtnChange)
Me.Name = "FormChangePassword"
Me.Text = "FormChangePassword"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents LblNewPassword As System.Windows.Forms.Label
Friend WithEvents LblOldPassword As System.Windows.Forms.Label
Friend WithEvents TxtNewPassword As System.Windows.Forms.TextBox
Friend WithEvents TxtOldPassword As System.Windows.Forms.TextBox
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents BtnChange As System.Windows.Forms.Button
End Class
FormCreateBill;
Screenshot;
Form Code;
Imports MySql.Data.MySqlClient
Public Class FormCreateBill
Dim Connect As New MySqlConnection
Dim Query As String
Dim READER As MySqlDataReader
Dim COMMAND As MySqlCommand
Dim ServerIP As String
Dim ServerUsername As String
Dim ServerPassword As String
Dim DatabaseName As String
'variables
While READER.Read
ComBoxForename.Items.Add(READER("Forename"))
'populares the combobox
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Try
Connect.Open()
While READER.Read
ComBoxSurname.Items.Add(READER("Surname"))
'populares the combobox
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Connect.Close()
End Sub
Try
Connect.Open()
Query = "SELECT ChildID, Forename, Surname from tbl_ChildInfo where Name ='" &
ComBoxForename.Text & ComBoxSurname.Text & "'"
COMMAND = New MySqlCommand(Query, Connect)
READER = COMMAND.ExecuteReader()
'selects the information from database related to selected child
'so it can be displayed to user
While READER.Read()
ComBoxForename.Text = READER("Forename")
ComBoxSurname.Text = READER("Surname")
End While
READER.Close()
COMMAND.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'reads in info and assigns it to textboxes
End Sub
End Class
Designer Code;
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FormCreateBill
Inherits System.Windows.Forms.Form
MyBase.Dispose(disposing)
End Try
End Sub
'
Me.LblCreateBill.AutoSize = True
Me.LblCreateBill.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LblCreateBill.Location = New System.Drawing.Point(157, 58)
Me.LblCreateBill.Name = "LblCreateBill"
Me.LblCreateBill.Size = New System.Drawing.Size(94, 24)
Me.LblCreateBill.TabIndex = 3
Me.LblCreateBill.Text = "Create Bill"
'
'LblChild
'
Me.LblChild.AutoSize = True
Me.LblChild.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LblChild.Location = New System.Drawing.Point(55, 98)
Me.LblChild.Name = "LblChild"
Me.LblChild.Size = New System.Drawing.Size(49, 18)
Me.LblChild.TabIndex = 4
Me.LblChild.Text = "Child: "
'
'LblChildForename
'
Me.LblChildForename.AutoSize = True
Me.LblChildForename.Location = New System.Drawing.Point(73, 121)
Me.LblChildForename.Name = "LblChildForename"
Me.LblChildForename.Size = New System.Drawing.Size(60, 13)
Me.LblChildForename.TabIndex = 5
Me.LblChildForename.Text = "Forename: "
'
'LblChildSurname
'
Me.LblChildSurname.AutoSize = True
Me.LblChildSurname.Location = New System.Drawing.Point(222, 121)
Me.LblChildSurname.Name = "LblChildSurname"
Me.LblChildSurname.Size = New System.Drawing.Size(55, 13)
Me.LblChildSurname.TabIndex = 6
Me.LblChildSurname.Text = "Surname: "
'
'BtnSearch
'
Me.BtnSearch.Location = New System.Drawing.Point(161, 168)
Me.BtnSearch.Name = "BtnSearch"
Me.BtnSearch.Size = New System.Drawing.Size(75, 23)
Me.BtnSearch.TabIndex = 7
Me.BtnSearch.Text = "Search"
Me.BtnSearch.UseVisualStyleBackColor = True
'
'LblParent
'
Me.LblParent.AutoSize = True
Me.Controls.Add(Me.LblGvnmtFunding)
Me.Controls.Add(Me.LblHoursAttended)
Me.Controls.Add(Me.LblParentSurname)
Me.Controls.Add(Me.LblParentForename)
Me.Controls.Add(Me.LblParent)
Me.Controls.Add(Me.BtnSearch)
Me.Controls.Add(Me.LblChildSurname)
Me.Controls.Add(Me.LblChildForename)
Me.Controls.Add(Me.LblChild)
Me.Controls.Add(Me.LblCreateBill)
Me.Controls.Add(Me.ImgBunnies)
Me.Name = "FormCreateBill"
Me.Text = "FormCreateBill"
CType(Me.ImgBunnies, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ImgBunnies As System.Windows.Forms.PictureBox
Friend WithEvents LblCreateBill As System.Windows.Forms.Label
Friend WithEvents LblChild As System.Windows.Forms.Label
Friend WithEvents LblChildForename As System.Windows.Forms.Label
Friend WithEvents LblChildSurname As System.Windows.Forms.Label
Friend WithEvents BtnSearch As System.Windows.Forms.Button
Friend WithEvents LblParent As System.Windows.Forms.Label
Friend WithEvents LblParentForename As System.Windows.Forms.Label
Friend WithEvents LblParentSurname As System.Windows.Forms.Label
Friend WithEvents LblHoursAttended As System.Windows.Forms.Label
Friend WithEvents LblGvnmtFunding As System.Windows.Forms.Label
Friend WithEvents LblAmountToPay As System.Windows.Forms.Label
Friend WithEvents BtnEmail As System.Windows.Forms.Button
Friend WithEvents BtnPrint As System.Windows.Forms.Button
Friend WithEvents TxtHoursAttended As System.Windows.Forms.TextBox
Friend WithEvents TxtParentForename As System.Windows.Forms.TextBox
Friend WithEvents TxtParentSurname As System.Windows.Forms.TextBox
Friend WithEvents TxtAmountToPay As System.Windows.Forms.TextBox
Friend WithEvents RadBtnYes As System.Windows.Forms.RadioButton
Friend WithEvents RadBtnNo As System.Windows.Forms.RadioButton
Friend WithEvents ComBoxForename As System.Windows.Forms.ComboBox
Friend WithEvents ComBoxSurname As System.Windows.Forms.ComboBox
End Class
I have completed this objective by creating forms that allow the user to input the information
they need in order to create a new record for either a child or a staff member. The boxes and
buttons are clearly labelled which would help to reduce confusion and allow users to
complete the task with ease.
Evidence;
I have completed this objective by creating forms that allow the user to input the information
they need in order to edit an existing record for either a child or a staff member. The boxes
and buttons are clearly labelled which would help to reduce confusion and allow users to
complete the task with ease.
Evidence;
I have completed this objective by creating forms that allow the user to input the information
they need in order to delete an existing record for either a child or a staff member. The
boxes and buttons are clearly labelled which would help to reduce confusion and allow users
to complete the task with ease.
Evidence;
I have completed this objective by designing and including a login screen which requires
users to enter their username and password. This will help to make the program more
secure and unauthorised people should not be able to get past this if the users keep their
usernames and passwords secure.
Evidence;
I have completed this objective by ensuring that each of forms has a user interface that is
simple and easy to understand. I also made sure that this was consistent throughout my
project so that the user would be able to navigate the program efficiently and have a sense
of familiarity with each form they use.
Evidence;
I feel that I achieved this objective by having the calculations that need to be done written
into the code. This means that each time a calculation is performed, the program will perform
the same calculation with whatever variable value has been entered. I also aimed to improve
the integrity and accuracy of my databases by including verification methods, such as
making sure important fields are ‘not null’.
Evidence;
Query = "CREATE TABLE tbl_Login ( Username VARCHAR(25) NOT NULL PRIMARY KEY,
Password VARCHAR(35) NOT NULL, StaffID(10) NOT NULL, Admin BIT(1) NOT NULL )"
‘Section of code from ModuleGlobal that creates a table and uses the verification method ‘NOT NULL’
I have achieved this objective by writing the calculations into the code. As the computer will
have to perform them, this means that the outcomes will be returned almost instantly. I have
also ensured that the interface allows the user to know the results of any calculations.
Evidence;
I have achieved this by creating a simplistic UI which is easy to navigate through. Each of
the buttons are clearly labelled and allow the user to move from one form to the next. For
example, the ‘Records’ button shown in the image below would allow the user to open the
form that deals with the records.
Evidence;
I have completed this objective by designing a login form as well as forms that allow the user
to change their username and password. This means that the user can regularly change
their username and password to help improve the security of the system. Having a logon
screen means that only authorised people can access the program.
Evidence;
I have used dynamic SQL throughout mu program as almost all of the queries that are made
to the server need an input from the user in order to determine which records need to be
returned.
FormLogin;
Query = "SELECT Password FROM tbl_LoginInfo WHERE Username = '" & Username & "'"
ModuleGlobal;
FormEditChildRecord;
Query = ("UPDATE tbl_ChildInfo SET ChildID = '" & TxtChildID.Text & "' WHERE Forename = '" &
ComBoxChild.Text & "'")
Query = ("UPDATE tbl_ChildInfo SET Forename = '" & TxtForename.Text & "' WHERE Forename = '"
& ComBoxChild.Text & "'")
FormEditStaffMember;
Query = "UPDATE" & Table & " SET " & Column & " = " & Text & "'WHERE" & ConstColumn & "='" &
ConstText & "'”
Query = "UPDATE tbl_LoginInfo SET Forename" & TxtForenameChange.Text & " WHERE Forename
= '" & Forename & "' AND Surname = '" & Surname & "'"
The DDL within my program is dependant on whether the database exists or not. When the
program is started up, a query is executed in order to check the number of tables that are
present within the database. If zero is returned then the DDL statements are executed.
FormLogin;
Private Sub FormLogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'this subroutine runs when the form first loads
TxtUsername.Focus()
'makes the username textbox the focus
Dim Setup As Boolean
Dim Query As String
Dim COMMAND As MySqlCommand
Dim Tables As Integer
'Declares the variables that will be needed for the initial SQL query
'checks whether the database has been set up
ModuleGlobal.GetDatabaseInformation(ServerIp, ServerUsername, ServerPassword,
DatabaseName)
'gets info for database connection
If ServerIp = "" And ServerPassword = "" And ServerUsername = "" And DatabaseName = ""
Then
'checks to see whether the variables for database connection have been set
'if they have not then the database information form is displayed
'so user can input correct info
MessageBox.Show("Database information not found, please enter the right information",
"Database settings error", MessageBoxButtons.OK)
FormDbInfo.ShowDialog()
End If
ModuleGlobal;
Public Sub CreateTables()
'subroutine is called when program is started up by user, used to setup database
Dim DatabaseName As String = ""
Try
Dim COMMAND As MySqlCommand
Dim Query As String
'declares the variables required to execute queries
Query = "CREATE TABLE tbl_StaffInfo ( StaffID VARCHAR (10) NOT NULL PRIMARY
KEY, Forename VARCHAR(25) NOT NULL, Surname VARCHAR(35) NOT NULL, Position
VARCHAR (35) )"
COMMAND = New MySqlCommand(Query, Connect)
COMMAND.ExecuteNonQuery()
COMMAND.Dispose()
'creates staff info table
Connect.Close()
'closes connection to the database
The aggregate functions within my program are used to count the number of tables within
the database. This allows the program to know whether the correct database has connected
to or whether the database even exists.
FormLogin;
Query = "select count(*) from information_schema.tables where table_type = 'BASE TABLE' and
table_schema = '" & DatabaseName & "';"
COMMAND = New MySqlCommand(Query, Connect)
Tables = COMMAND.ExecuteScalar
'sets query to check for tables in database
The data for my program is stored in a complex database which consists of 5 joined tables.
There are two instances within my program where data needs o be written to or stored within
text files; the database connection information and information required in the global module.
Both of these instances use the I/O reader and writer in order to read/write the required data.
ModuleGlobal;
Public Sub GetDatabaseInformation(ByRef ServerIP As String, ByRef ServerUsername As String,
ByRef ServerPassword As String, ByRef DatabaseName As String)
'gets and assigns the database connection string information
Using StreamReader As StreamReader = New StreamReader
ServerIP = StreamReader.ReadLine()
DatabaseName = StreamReader.ReadLine()
ServerUsername = StreamReader.ReadLine()
ServerPassword = StreamReader.ReadLine()
End Using
End Sub
FormDbInfo;
If ValidConnection = True Then
Using StreamWriter As StreamWriter = New StreamWriter
StreamWriter.WriteLine(TxtServerIP.Text)
StreamWriter.WriteLine(TxtDatabaseName.Text)
StreamWriter.WriteLine(TxtPassword.Text)
End Using
Me.Close()
Else
MessageBox.Show("Connection has not been made. Ensure you have entered the right
details.", "Connection error.", MessageBoxButtons.OK)
End If