You are on page 1of 253

1

Forms:Form About:Private Sub cmdClose_Click() Unload Me End Sub Private Sub Form_Load() End Sub

Form AddMedical TreatmentsIn:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Add Medical Treatments Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 09/05/10 'Date Of Last Modification: 09/05/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Medical_Treatments Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Medical Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdAdd_Click() If textfieldsValidations = False Then If MsgBox("Are You Sure You Wish To Add This Record?", vbYesNo + vbQuestion, "Add This Record?") = vbYes Then 'Enabling the DataGrid dgrdMedicalTreatmentsInfo.Enabled = True txtNettTotal.Text = Val(txtNettTotal.Text) + Val(txtTotal) Call Connection 'Calling the Connection function to set up a connection with the database Call Medical_Treatments 'Calling the Medical_Treatments Procedure to interact with the recordset 'Generate Medical Treatment ID By Utilizing the Medical_Treatments Table With rsMedicalTreatments If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "MTR0001" Else 'Calculating the number of records and storing in a variable iNumOfTreatments = .RecordCount iNumOfTreatments = iNumOfTreatments + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Medical_Treatments Table If iNumOfTreatments < 10 Then strDisplay = "MTR000" & iNumOfTreatments ElseIf iNumOfTreatments < 100 Then strDisplay = "MTR00" & iNumOfTreatments ElseIf iNumOfTreatments < 1000 Then strDisplay = "MTR0" & iNumOfTreatments ElseIf iNumOfTreatments < 10000 Then

2
strDisplay = "MTR" & iNumOfTreatments End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With saveProcedure 'Calling a function which will save the record in the database Call InpatientsMedicalTreatments 'Calling the Inpatients Medical Treatments Function Set dgrdMedicalTreatmentsInfo.DataSource = rsInpatientsMedicalTreatments 'Setting the datasource for the datagrid Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" End If 'Checking if the user wants to add another record for the same patient If MsgBox("Do You Wish To Add Another Medication For This Patient?", vbYesNo + vbQuestion, "Add New Medication?") = vbYes Then 'Clearing All Necessary Textfields txtMedicineID.Text = "" txtMedicineName.Text = "" txtUnitPrice.Text = "" txtQty.Text = "" txtDateOfIssue.Text = DateTime.Date 'Setting the default value for the DateOfIssue textfield txtTotal.Text = "0" 'Setting the default value for the Total Value textfield cmdClose.Enabled = False 'Disabling the Close button because I do not want the user to close the form henceforth Else Unload Me 'Closing the form End If End If End Sub Private Function saveProcedure() 'This procedure will save the record into the database. With rsMedicalTreatments 'Save the user-entered data into the recordset .Fields(0) = strDisplay .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtMedicineID.Text .Fields(5) = txtMedicineName.Text .Fields(6) = txtDateOfIssue.Text .Fields(7) = txtUnitPrice.Text .Fields(8) = txtQty.Text .Fields(9) = txtTotal.Text .Update 'Display Success Message MsgBox "The Record Was Added Successfully!", vbInformation, "Succesful Save Procedure!" .Requery 'Requerying the Table End With End Function Private Sub cmdDelete_Click() With rsInpatientsMedicalTreatments 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Remove This Medication?", vbYesNo + vbQuestion, "Remove Medication?") = vbYes Then txtNettTotal.Text = Val(txtNettTotal.Text) - .Fields(9).Value .Delete 'Delete the record from the database 'Display Success Message

3
MsgBox "The Medication Has Been Removed Successfully!", vbInformation, "Successfully Removed Medication!" Else 'Display 'Medication Not Removed' Message MsgBox "The Medication Was Not Removed!", vbExclamation, "Medication Not Removed!" End If .Requery 'Requerying the Table Set dgrdMedicalTreatmentsInfo.DataSource = rsInpatientsMedicalTreatments 'Setting the Datasource for the Datagrid cmdDelete.Enabled = False 'Disabling the Remove Button at the end 'In the following code, I will be enabling the user to close the form if there are no records If .RecordCount = 0 Then cmdClose.Enabled = True End If End With End Sub Private Sub cmdClose_Click() 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdMedicineSearchWizard_Click() frmSearchMedsWizard.Show End Sub Private Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmInpatientsSearchMedicals.Show End Sub Private Sub dgrdMedicalTreatmentsInfo_Click() 'Here, I am enabling the Remove button only if the user has already added a record If txtNettTotal.Text <> "0" Then cmdDelete.Enabled = True End If End Sub Private Sub Form_Load() txtDateOfIssue.Text = DateTime.Date 'Displaying the date in the DateOfIssue textfield. End Sub Private Sub txtQty_Change() If txtQty.Text = "0" Then MsgBox "Error! The Figure Cannot Begin With Zero!", vbCritical, "Cannot Begin Figure With 0!" txtQty.Text = "" Exit Sub Else txtTotal.Text = Val(txtQty.Text) * Val(txtUnitPrice.Text) End I End Sub Private Sub txtQty_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 6360 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

4
Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Medicine ID textfield is empty If txtMedicineID.Text = "" Then txtMedicineID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtMedicineName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtUnitPrice.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtMedicineID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtMedicineName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtUnitPrice.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Total textfield has been filled in If txtTotal.Text = "0" Then txtQty.BackColor = &H80000018 'Highlighting the textfield in a different colour txtTotal.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtQty.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtTotal.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function

FormAddMedicalTreatmentsOut:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Add Medical Treatments Interface 'Programmer: Bhaskar BDPS

5
'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 09/05/08 'Date Of Last Modification: 09/05/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Medical_Treatments_Out Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Medical Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdAdd_Click() If textfieldsValidations = False Then If MsgBox("Are You Sure You Wish To Add This Record?", vbYesNo + vbQuestion, "Add This Record?") = vbYes Then 'Enabling the DataGrid dgrdMedicalTreatmentsInfo.Enabled = True txtNettTotal.Text = Val(txtNettTotal.Text) + Val(txtTotal) Call Connection 'Calling the Connection function to set up a connection with the database Call Medical_Treatments_Out 'Calling the Medical_Treatments_Out Procedure to interact with the recordset 'Generate Medical Treatment ID By Utilizing the Medical_Treatments_Out Table With rsMedicalTreatmentsOut If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "OMT0001" Else 'Calculating the number of records and storing in a variable iNumOfTreatments = .RecordCount iNumOfTreatments = iNumOfTreatments + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Medical_Treatments_Out Table If iNumOfTreatments < 10 Then strDisplay = "OMT000" & iNumOfTreatments ElseIf iNumOfTreatments < 100 Then strDisplay = "OMT00" & iNumOfTreatments ElseIf iNumOfTreatments < 1000 Then strDisplay = "OMT0" & iNumOfTreatments ElseIf iNumOfTreatments < 10000 Then strDisplay = "OMT" & iNumOfTreatments End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With saveProcedure 'Calling a function which will save the record in the database Call OutpatientsMedicalTreatments 'Calling the Outpatients Medical Treatments Function Set dgrdMedicalTreatmentsInfo.DataSource = rsOutpatientsMedicalTreatments 'Setting the datasource for the datagrid Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" End If 'Checking if the user wants to add another record for the same patient

6
If MsgBox("Do You Wish To Add Another Medication For This Patient?", vbYesNo + vbQuestion, "Add New Medication?") = vbYes Then 'Clearing All Necessary Textfields txtMedicineID.Text = "" txtMedicineName.Text = "" txtUnitPrice.Text = "" txtQty.Text = "" txtDateOfIssue.Text = DateTime.Date 'Setting the default value for the DateOfIssue textfield txtTotal.Text = "0" 'Setting the default value for the Total Value textfield cmdClose.Enabled = False 'Disabling the Close button because I do not want the user to close the form henceforth Else Unload Me 'Closing the form End If End If End Sub Private Function saveProcedure() 'This procedure will save the record into the database. With rsMedicalTreatmentsOut 'Save the user-entered data into the recordset .Fields(0) = strDisplay .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtMedicineID.Text .Fields(5) = txtMedicineName.Text .Fields(6) = txtDateOfIssue.Text .Fields(7) = txtUnitPrice.Text .Fields(8) = txtQty.Text .Fields(9) = txtTotal.Text .Update 'Display Success Message MsgBox "The Record Was Added Successfully!", vbInformation, "Succesful Save Procedure!" .Requery 'Requerying the Table End With End Function Private Sub cmdDelete_Click() With rsOutpatientsMedicalTreatments 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Remove This Medication?", vbYesNo + vbQuestion, "Remove Medication?") = vbYes Then txtNettTotal.Text = Val(txtNettTotal.Text) - .Fields(9).Value .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Medication Has Been Removed Successfully!", vbInformation, "Successfully Removed Medication!" Else 'Display 'Medication Not Removed' Message MsgBox "The Medication Was Not Removed!", vbExclamation, "Medication Not Removed!" End If .Requery 'Requerying the Table Set dgrdMedicalTreatmentsInfo.DataSource = rsOutpatientsMedicalTreatments 'Setting the Datasource for the Datagrid cmdDelete.Enabled = False 'Disabling the Remove Button at the end 'In the following code, I will be enabling the user to close the form if there are no records If .RecordCount = 0 Then cmdClose.Enabled = True End If End With

7
End Sub Private Sub cmdClose_Click() 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdMedicineSearchWizard_Click() frmMedicinesWizardOut.Show End Sub Private Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmOutpatientSearchMeds.Show End Sub Private Sub dgrdMedicalTreatmentsInfo_Click() 'Here, I am enabling the Remove button only if the user has already added a record If txtNettTotal.Text <> "0" Then cmdDelete.Enabled = True End If End Sub Private Sub Form_Load() txtDateOfIssue.Text = DateTime.Date 'Displaying the date in the DateOfIssue textfield. End Sub Private Sub txtQty_Change() If txtQty.Text = "0" Then MsgBox "Error! The Figure Cannot Begin With Zero!", vbCritical, "Cannot Begin Figure With 0!" txtQty.Text = "" Exit Sub Else txtTotal.Text = Val(txtQty.Text) * Val(txtUnitPrice.Text) End If End Sub Private Sub txtQty_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 6360 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour

8
txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Medicine ID textfield is empty If txtMedicineID.Text = "" Then txtMedicineID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtMedicineName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtUnitPrice.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtMedicineID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtMedicineName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtUnitPrice.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Total textfield has been filled in If txtTotal.Text = "0" Then txtQty.BackColor = &H80000018 'Highlighting the textfield in a different colour txtTotal.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtQty.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtTotal.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function

FormAddMedicalTreatmentsOut:FormAddNewDepartment:FormAddNewDoctor:FormAddNewHospitalService:FormAddNewMedicine:FormAddNewOutPatient:FormAddNewPatient:FormAddNewRoom:FormAddNewWard:FormAddRooms:FormAddServiceTreatment:FormAddServiceTreatmentsIn:'--------------------------------------------------------------------------------

9
'Hospital Management System - Extended Edition 'Form Name: Add Service Treatments Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 10/05/08 'Date Of Last Modification: 10/05/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Service_Treatments Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Service Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdAdd_Click() If textfieldsValidations = False Then If MsgBox("Are You Sure You Wish To Add This Record?", vbYesNo + vbQuestion, "Add This Record?") = vbYes Then 'Enabling the DataGrid dgrdServiceTreatmentsInfo.Enabled = True txtNettTotal.Text = Val(txtNettTotal.Text) + Val(txtServiceCharge.Text) Call Connection 'Calling the Connection function to set up a connection with the database Call Service_Treatments 'Calling the Service_Treatments Procedure to interact with the recordset 'Generate Service Treatment ID By Utilizing the Service_Treatments Table With rsServiceTreatments If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "STR0001" Else 'Calculating the number of records and storing in a variable iNumOfTreatments = .RecordCount iNumOfTreatments = iNumOfTreatments + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Service_Treatments Table If iNumOfTreatments < 10 Then strDisplay = "STR000" & iNumOfTreatments ElseIf iNumOfTreatments < 100 Then strDisplay = "STR00" & iNumOfTreatments ElseIf iNumOfTreatments < 1000 Then strDisplay = "STR0" & iNumOfTreatments ElseIf iNumOfTreatments < 10000 Then strDisplay = "STR" & iNumOfTreatments End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With saveProcedure 'Calling a function which will save the record in the database Call InpatientsServiceTreatments 'Calling the InpatientsServiceTreatments Function Set dgrdServiceTreatmentsInfo.DataSource = rsInpatientsServiceTreatments 'Setting the datasource for the datagrid Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" End If 'Checking if the user wants to add another record for the same patient

10
If MsgBox("Do You Wish To Add Another Service Treatment For This Patient?", vbYesNo + vbQuestion, "Add New Service Treatment?") = vbYes Then 'Clearing All Necessary Textfields txtServiceID.Text = "" txtServiceName.Text = "" txtServiceCharge.Text = "" txtTreatmentDate.Text = DateTime.Date 'Setting the default value for the Treatment Date textfield cmdClose.Enabled = False 'Disabling the Close button because I do not want the user to close the form henceforth Else Unload Me 'Closing the form End If End If End Sub Private Function saveProcedure() 'This procedure will save the record into the database. With rsServiceTreatments 'Save the user-entered data into the recordset .Fields(0) = strDisplay .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtServiceID.Text .Fields(5) = txtServiceName.Text .Fields(6) = txtServiceCharge.Text .Fields(7) = txtTreatmentDate.Text .Update 'Display Success Message MsgBox "The Record Was Added Successfully!", vbInformation, "Succesful Save Procedure!" .Requery 'Requerying the Table End With End Function Private Sub cmdDelete_Click() With rsInpatientsServiceTreatments 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Remove This Service?", vbYesNo + vbQuestion, "Remove Service?") = vbYes Then txtNettTotal.Text = Val(txtNettTotal.Text) - .Fields(6).Value .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Service Has Been Removed Successfully!", vbInformation, "Successfully Removed Service!" Else 'Display 'Service Not Removed' Message MsgBox "The Service Was Not Removed!", vbExclamation, "Service Not Removed!" End If .Requery 'Requerying the Table Set dgrdServiceTreatmentsInfo.DataSource = rsInpatientsServiceTreatments 'Setting the Datasource for the Datagrid cmdDelete.Enabled = False 'Disabling the Remove Button at the end 'In the following code, I will be enabling the user to close the form if there are no records If .RecordCount = 0 Then cmdClose.Enabled = True End If End With End Sub Private Sub cmdClose_Click() 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then

11
Unload Me End If End Sub Private Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmInpatientsSearchAndFind.Show End Sub Private Sub cmdServiceSearchWizard_Click() frmServicesSearchAndFind.Show End Sub Private Sub dgrdServiceTreatmentsInfo_Click() 'Here, I am enabling the Remove button only if the user has already added a record If txtNettTotal.Text <> "0" Then cmdDelete.Enabled = True End If End Sub Private Sub Form_Load() txtTreatmentDate.Text = DateTime.Date 'Displaying the Date in the Treatment Date textfield. End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Service ID textfield is empty If txtServiceID.Text = "" Then txtServiceID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtServiceName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtServiceCharge.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtServiceID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtServiceName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtServiceCharge.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function

FormAddServiceTreatmentsOut:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Add Service Treatments Interface 'Programmer: Bhaskar BDPS

12
'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 10/05/08 'Date Of Last Modification: 10/05/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Service_Treatments_Out Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Service Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdAdd_Click() If textfieldsValidations = False Then If MsgBox("Are You Sure You Wish To Add This Record?", vbYesNo + vbQuestion, "Add This Record?") = vbYes Then 'Enabling the DataGrid dgrdServiceTreatmentsInfo.Enabled = True txtNettTotal.Text = Val(txtNettTotal.Text) + Val(txtServiceCharge.Text) Call Connection 'Calling the Connection function to set up a connection with the database Call Service_Treatments_Out 'Calling the Service_Treatments_Out Procedure to interact with the recordset 'Generate Service Treatment ID By Utilizing the Service_Treatments_Out Table With rsServiceTreatmentsOut If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "OST0001" Else 'Calculating the number of records and storing in a variable iNumOfTreatments = .RecordCount iNumOfTreatments = iNumOfTreatments + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Service_Treatments Table If iNumOfTreatments < 10 Then strDisplay = "OST000" & iNumOfTreatments ElseIf iNumOfTreatments < 100 Then strDisplay = "OST00" & iNumOfTreatments ElseIf iNumOfTreatments < 1000 Then strDisplay = "OST0" & iNumOfTreatments ElseIf iNumOfTreatments < 10000 Then strDisplay = "OST" & iNumOfTreatments End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With saveProcedure 'Calling a function which will save the record in the database Call OutpatientsServiceTreatments 'Calling the Outpatients Service Treatments Function Set dgrdServiceTreatmentsInfo.DataSource = rsOutpatientsServiceTreatments 'Setting the datasource for the datagrid Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" End If 'Checking if the user wants to add another record for the same patient If MsgBox("Do You Wish To Add Another Service Treatment For This Patient?", vbYesNo + vbQuestion, "Add New Service Treatment?") = vbYes Then

13
'Clearing All Necessary Textfields txtServiceID.Text = "" txtServiceName.Text = "" txtServiceCharge.Text = "" txtTreatmentDate.Text = DateTime.Date 'Setting the default value for the Treatment Date textfield cmdClose.Enabled = False 'Disabling the Close button because I do not want the user to close the form henceforth Else Unload Me 'Closing the form End If End If End Sub Private Function saveProcedure() 'This procedure will save the record into the database. With rsServiceTreatmentsOut 'Save the user-entered data into the recordset .Fields(0) = strDisplay .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtServiceID.Text .Fields(5) = txtServiceName.Text .Fields(6) = txtServiceCharge.Text .Fields(7) = txtTreatmentDate.Text .Update 'Display Success Message MsgBox "The Record Was Added Successfully!", vbInformation, "Succesful Save Procedure!" .Requery 'Requerying the Table End With End Function Private Sub cmdDelete_Click() With rsOutpatientsServiceTreatments 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Remove This Service?", vbYesNo + vbQuestion, "Remove Service?") = vbYes Then txtNettTotal.Text = Val(txtNettTotal.Text) - .Fields(6).Value .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Service Has Been Removed Successfully!", vbInformation, "Successfully Removed Service!" Else 'Display 'Service Not Removed' Message MsgBox "The Service Was Not Removed!", vbExclamation, "Service Not Removed!" End If .Requery 'Requerying the Table Set dgrdServiceTreatmentsInfo.DataSource = rsOutpatientsServiceTreatments 'Setting the Datasource for the Datagrid cmdDelete.Enabled = False 'Disabling the Remove Button at the end 'In the following code, I will be enabling the user to close the form if there are no records If .RecordCount = 0 Then cmdClose.Enabled = True End If End With End Sub Private Sub cmdClose_Click() 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If

14
End Sub Private Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmOutpatientsSearchAndFind.Show End Sub Private Sub cmdServiceSearchWizard_Click() frmServicesSearchNFind.Show End Sub Private Sub dgrdServiceTreatmentsInfo_Click() 'Here, I am enabling the Remove button only if the user has already added a record If txtNettTotal.Text <> "0" Then cmdDelete.Enabled = True End If End Sub Private Sub Form_Load() txtTreatmentDate.Text = DateTime.Date 'Displaying the Date in the Treatment Date textfield. End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Service ID textfield is empty If txtServiceID.Text = "" Then txtServiceID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtServiceName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtServiceCharge.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtServiceID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtServiceName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtServiceCharge.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function

FormAdmitPatient:'-----------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Inpatients Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS

15
'Start Date: 24/04/08 'Date Of Last Modification: 24/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Inpatients_Admission Table '-----------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean Private Sub cmdAssignedDoctorWizardButton_Click() frmAssignedDocSelectionWizard.Show End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdDepartmentIDWizardButton_Click() frmDepartmentsSearchWizardAdmit.Show End Sub Private Sub cmdLaunchInpatientSearch_Click() 'This function is fired when the Launch Inpatient Search Wizard Command Button is Clicked. It opens up the Inpatient Search Wizard enableAllFields 'Calling a Private Function To Enable All Fields enableAllButtons 'Calling a Private Function To Enable All Command Buttons cmdSave.Enabled = False 'Disabling the Save Command Button frmInpatientSearchWizardAdmit.Show 'Displays the Inpatient Search Wizard End Sub Private Sub cmdReferredDoctorIDWizardButton_Click() frmReferringDoctorWizard.Show End Sub Private Sub cmdRoomIDWizardButton_Click() frmRoomsSearchWizard.Show End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsInpatientsAdmission 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtReferredDoctorID.Text = "" Then txtReferredDoctorID.Text = "-" End If If txtReferredDoctorName.Text = "" Then txtReferredDoctorName.Text = "-" End If If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtAdmissionID.Text .Fields(1) = txtPatientID.Text .Fields(2) = txtGuardianID.Text

16
.Fields(3) = txtAdmissionDate.Text .Fields(4) = txtAdmissionTime.Text .Fields(5) = cboPatientStatus.Text .Fields(6) = txtReasonForStatus.Text .Fields(7) = txtReferredDoctorID.Text .Fields(8) = txtReferredDoctorName.Text .Fields(9) = txtAssignedDoctorID.Text .Fields(10) = txtAssignedDoctorName.Text .Fields(11) = txtDepartmentID.Text .Fields(12) = txtDepartmentName.Text .Fields(13) = txtWardID.Text .Fields(14) = txtWardNo.Text .Fields(15) = txtRoomID.Text .Fields(16) = txtAdditionalNotes.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully! The Inpatient Admission Process Is Over!", vbInformation, "Succesful Save Procedure!" Unload Me Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdStep1_Click() Call Inpatients_Maintenance With rsInpatientMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = txtPatientID.Text Then 'Entering the values in the particular record into the fields on the interface frmInpatientsMaintenance.txtPatientID.Text = .Fields(0).Value frmInpatientsMaintenance.txtFirstName.Text = .Fields(1).Value frmInpatientsMaintenance.txtSurname.Text = .Fields(2).Value frmInpatientsMaintenance.cboGender.Text = .Fields(3).Value frmInpatientsMaintenance.dtpDateOfBirth.Value = .Fields(4).Value frmInpatientsMaintenance.txtNICNumber.Text = .Fields(5).Value frmInpatientsMaintenance.txtAddress.Text = .Fields(6).Value frmInpatientsMaintenance.txtPhoneHome.Text = .Fields(7).Value frmInpatientsMaintenance.txtPhoneMob.Text = .Fields(8).Value frmInpatientsMaintenance.txtPatientOccupation.Text = .Fields(9).Value frmInpatientsMaintenance.cboCivilStatus.Text = .Fields(10).Value frmInpatientsMaintenance.cboAccountType.Text = .Fields(11).Value frmInpatientsMaintenance.txtCompanyID.Text = .Fields(12).Value frmInpatientsMaintenance.txtCompanyName.Text = .Fields(13).Value Exit Do Else .MoveNext End If Loop End With 'Enabling / Diabling the Navigation Buttons as necessary frmInpatientsMaintenance.cmdFirst.Enabled = False

17
frmInpatientsMaintenance.cmdLast.Enabled = True frmInpatientsMaintenance.cmdPrevious.Enabled = False frmInpatientsMaintenance.cmdNext.Enabled = True 'Enabling the Update Button, Delete Button and The Close Button frmInpatientsMaintenance.cmdUpdate.Enabled = True frmInpatientsMaintenance.cmdDelete.Enabled = True frmInpatientsMaintenance.cmdClose.Enabled = True 'Enabling the Wizard Buttons frmInpatientsMaintenance.cmdCompanySearchWizard.Enabled = True 'Enabling the "Step" Buttons frmInpatientsMaintenance.cmdStep2.Enabled = True frmInpatientsMaintenance.enableAllFields Unload Me frmInpatientsMaintenance.Show End Sub Private Sub cmdStep2_Click() Call Guardians_Maintenance With rsGuardiansMaintenance .MoveFirst Do While .EOF = False If .Fields(1).Value = txtPatientID.Text Then 'Entering the values in the particular record into the fields on the interface frmGuardiansMaintenance.txtGuardianID.Text = .Fields(0).Value frmGuardiansMaintenance.txtPatientID.Text = .Fields(1).Value frmGuardiansMaintenance.txtFirstName.Text = .Fields(2).Value frmGuardiansMaintenance.txtSurname.Text = .Fields(3).Value frmGuardiansMaintenance.cboGender.Text = .Fields(4).Value frmGuardiansMaintenance.txtNICNumber.Text = .Fields(5).Value frmGuardiansMaintenance.txtAddress.Text = .Fields(6).Value frmGuardiansMaintenance.txtPhoneHome.Text = .Fields(7).Value frmGuardiansMaintenance.txtPhoneMob.Text = .Fields(8).Value frmGuardiansMaintenance.txtOccupation.Text = .Fields(9).Value frmGuardiansMaintenance.txtRelationToPatient.Text = .Fields(10).Value Exit Do Else .MoveNext End If Loop End With 'Enabling / Diabling the Navigation Buttons as necessary frmGuardiansMaintenance.cmdFirst.Enabled = False frmGuardiansMaintenance.cmdLast.Enabled = True frmGuardiansMaintenance.cmdPrevious.Enabled = False frmGuardiansMaintenance.cmdNext.Enabled = True 'Enabling the Update Button frmGuardiansMaintenance.cmdUpdate.Enabled = True 'Enabling the "Step" Buttons frmGuardiansMaintenance.cmdStep1.Enabled = True frmGuardiansMaintenance.cmdStep3.Enabled = True frmGuardiansMaintenance.enableAllFields Unload Me frmGuardiansMaintenance.Show End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsInpatientsAdmission 'Making sure that the user wants to save the record

18
If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtReferredDoctorID.Text = "" Then txtReferredDoctorID.Text = "-" End If If txtReferredDoctorName.Text = "" Then txtReferredDoctorName.Text = "-" End If If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtAdmissionID.Text .Fields(1) = txtPatientID.Text .Fields(2) = txtGuardianID.Text .Fields(3) = txtAdmissionDate.Text .Fields(4) = txtAdmissionTime.Text .Fields(5) = cboPatientStatus.Text .Fields(6) = txtReasonForStatus.Text .Fields(7) = txtReferredDoctorID.Text .Fields(8) = txtReferredDoctorName.Text .Fields(9) = txtAssignedDoctorID.Text .Fields(10) = txtAssignedDoctorName.Text .Fields(11) = txtDepartmentID.Text .Fields(12) = txtDepartmentName.Text .Fields(13) = txtWardID.Text .Fields(14) = txtWardNo.Text .Fields(15) = txtRoomID.Text .Fields(16) = txtAdditionalNotes.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Save Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdWardIDWizardButton_Click() frmWardsSearchWizardAdmit.Show End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure disableAllFields 'Calling a Function To Disable All Fields disableAllButtons 'Calling a Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Close Button

19
cmdClose.Enabled = True 'Enabling the LaunchDoctorSearch Wizard Button cmdLaunchInpatientSearch.Enabled = True End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Public Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next 'Disabling the Step 1 Button 'cmdStep1.Enabled = False End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next 'The following lines will set the normal display values of the Gender 'ComboBox, Doctor Category ComboBox and the Date Of Birth Date Time Picker cboPatientStatus.Text = "----------SELECT-----------" End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False

20
cmdNext.Enabled = True 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep2.Enabled = True 'Enabling the Referring Doctor Search Wizard cmdReferredDoctorIDWizardButton.Enabled = True 'Enabling the Assigned Doctor Search Wizard cmdAssignedDoctorWizardButton.Enabled = True 'Enabling the Department ID Search Wizard cmdDepartmentIDWizardButton.Enabled = True 'Enabling the Ward ID Wizard Button cmdWardIDWizardButton.Enabled = True 'Enabling the Room ID Wizard Button cmdRoomIDWizardButton.Enabled = True Call Inpatients_Admission 'Calling the Inpatients_Admission Procedure to interact with the recordset With rsInpatientsAdmission .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtAdmissionID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtGuardianID.Text = .Fields(2).Value txtAdmissionDate.Text = .Fields(3).Value txtAdmissionTime.Text = .Fields(4).Value cboPatientStatus.Text = .Fields(5).Value txtReasonForStatus.Text = .Fields(6).Value txtReferredDoctorID.Text = .Fields(7).Value txtReferredDoctorName.Text = .Fields(8).Value txtAssignedDoctorID.Text = .Fields(9).Value txtAssignedDoctorName.Text = .Fields(10).Value txtDepartmentID.Text = .Fields(11).Value txtDepartmentName.Text = .Fields(12).Value txtWardID.Text = .Fields(13).Value txtWardNo.Text = .Fields(14).Value txtRoomID.Text = .Fields(15).Value txtAdditionalNotes.Text = .Fields(16).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsInpatientsAdmission .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtAdmissionID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtGuardianID.Text = .Fields(2).Value txtAdmissionDate.Text = .Fields(3).Value txtAdmissionTime.Text = .Fields(4).Value cboPatientStatus.Text = .Fields(5).Value txtReasonForStatus.Text = .Fields(6).Value txtReferredDoctorID.Text = .Fields(7).Value txtReferredDoctorName.Text = .Fields(8).Value

21
txtAssignedDoctorID.Text = .Fields(9).Value txtAssignedDoctorName.Text = .Fields(10).Value txtDepartmentID.Text = .Fields(11).Value txtDepartmentName.Text = .Fields(12).Value txtWardID.Text = .Fields(13).Value txtWardNo.Text = .Fields(14).Value txtRoomID.Text = .Fields(15).Value txtAdditionalNotes.Text = .Fields(16).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep2.Enabled = True 'Enabling the Referring Doctor Search Wizard cmdReferredDoctorIDWizardButton.Enabled = True 'Enabling the Assigned Doctor Search Wizard cmdAssignedDoctorWizardButton.Enabled = True 'Enabling the Department ID Search Wizard cmdDepartmentIDWizardButton.Enabled = True 'Enabling the Ward ID Wizard Button cmdWardIDWizardButton.Enabled = True 'Enabling the Room ID Wizard Button cmdRoomIDWizardButton.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsInpatientsAdmission .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtAdmissionID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtGuardianID.Text = .Fields(2).Value txtAdmissionDate.Text = .Fields(3).Value txtAdmissionTime.Text = .Fields(4).Value cboPatientStatus.Text = .Fields(5).Value txtReasonForStatus.Text = .Fields(6).Value txtReferredDoctorID.Text = .Fields(7).Value txtReferredDoctorName.Text = .Fields(8).Value txtAssignedDoctorID.Text = .Fields(9).Value txtAssignedDoctorName.Text = .Fields(10).Value txtDepartmentID.Text = .Fields(11).Value txtDepartmentName.Text = .Fields(12).Value txtWardID.Text = .Fields(13).Value txtWardNo.Text = .Fields(14).Value txtRoomID.Text = .Fields(15).Value txtAdditionalNotes.Text = .Fields(16).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button

22
cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep2.Enabled = True 'Enabling the Referring Doctor Search Wizard cmdReferredDoctorIDWizardButton.Enabled = True 'Enabling the Assigned Doctor Search Wizard cmdAssignedDoctorWizardButton.Enabled = True 'Enabling the Department ID Search Wizard cmdDepartmentIDWizardButton.Enabled = True 'Enabling the Ward ID Wizard Button cmdWardIDWizardButton.Enabled = True 'Enabling the Room ID Wizard Button cmdRoomIDWizardButton.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Disabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep2.Enabled = True 'Enabling the Referring Doctor Search Wizard cmdReferredDoctorIDWizardButton.Enabled = True 'Enabling the Assigned Doctor Search Wizard cmdAssignedDoctorWizardButton.Enabled = True 'Enabling the Department ID Search Wizard cmdDepartmentIDWizardButton.Enabled = True 'Enabling the Ward ID Wizard Button cmdWardIDWizardButton.Enabled = True 'Enabling the Room ID Wizard Button cmdRoomIDWizardButton.Enabled = True Call Inpatients_Admission 'Calling the Inpatients_Admission Procedure to interact with the recordset With rsInpatientsAdmission .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtAdmissionID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtGuardianID.Text = .Fields(2).Value txtAdmissionDate.Text = .Fields(3).Value txtAdmissionTime.Text = .Fields(4).Value cboPatientStatus.Text = .Fields(5).Value txtReasonForStatus.Text = .Fields(6).Value txtReferredDoctorID.Text = .Fields(7).Value txtReferredDoctorName.Text = .Fields(8).Value txtAssignedDoctorID.Text = .Fields(9).Value txtAssignedDoctorName.Text = .Fields(10).Value txtDepartmentID.Text = .Fields(11).Value txtDepartmentName.Text = .Fields(12).Value txtWardID.Text = .Fields(13).Value txtWardNo.Text = .Fields(14).Value txtRoomID.Text = .Fields(15).Value txtAdditionalNotes.Text = .Fields(16).Value

23
End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the user has made a selection in the Patient Status ComboBox If cboPatientStatus.Text = "" Then cboPatientStatus.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboPatientStatus.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Reason For Status textfield is empty If txtReasonForStatus.Text = "" Then txtReasonForStatus.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtReasonForStatus.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Referred Doctor ID textfield is empty If txtReferredDoctorID.Text = "" Then txtReferredDoctorID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtReferredDoctorName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtReferredDoctorID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtReferredDoctorName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Assigned Doctor ID textfield is empty If txtAssignedDoctorID.Text = "" Then txtAssignedDoctorID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtAssignedDoctorName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAssignedDoctorID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtAssignedDoctorName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Department ID textfield is empty If txtDepartmentID.Text = "" Then txtDepartmentID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtDepartmentName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtDepartmentID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtDepartmentName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Ward ID textfield is empty If txtWardID.Text = "" Then txtWardID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtWardNo.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtWardID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtWardNo.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Room ID textfield is empty If txtRoomID.Text = "" Then txtRoomID.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data

24
Else txtRoomID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub txtReasonForStatus_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtReasonForStatus.Text = "-" Then txtReasonForStatus.Text = "" End If End Sub Private Sub txtReasonForStatus_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtReasonForStatus.Text = "" Then txtReasonForStatus.Text = "-" End If End Sub Private Sub txtAdditionalNotes_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtAdditionalNotes.Text = "-" Then txtAdditionalNotes.Text = "" End If End Sub Private Sub txtAdditionalNotes_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If End Sub

FormAssignedDocSelectionWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call AssignedDoctor_Selection 'Calling the AssignedDoctor_Selection Procedure to interact with the recordset Set dgrdDoctorsInfoTable.DataSource = rsAssignedDoctor 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDoctorsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsAssignedDoctor 'Filter the Records As The User Types, According to the Criteria

25
Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DoctorID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Gender] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[LicenceNo] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[Specialization] Like '" & txtSearch.Text & "%" & "'" Case 7: .Filter = "[DoctorCategory] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDoctorsInfoTable.DataSource = rsAssignedDoctor 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsAssignedDoctor.RecordCount > 0 Then With rsAssignedDoctor 'Reset the textfields with the selected record frmAdmitPatient.txtAssignedDoctorID.Text = .Fields(0).Value frmAdmitPatient.txtAssignedDoctorName.Text = "Dr." & .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormAssignedDocWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call AssignedDoctor_Selection 'Calling the AssignedDoctor_Selection Procedure to interact with the recordset Set dgrdDoctorsInfoTable.DataSource = rsAssignedDoctor 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDoctorsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield

26
With rsAssignedDoctor 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DoctorID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Gender] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[LicenceNo] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[Specialization] Like '" & txtSearch.Text & "%" & "'" Case 7: .Filter = "[DoctorCategory] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDoctorsInfoTable.DataSource = rsAssignedDoctor 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsAssignedDoctor.RecordCount > 0 Then With rsAssignedDoctor 'Reset the textfields with the selected record frmOutpatientsMaintenance.txtAssignedDoctorID.Text = .Fields(0).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormBackupDatabase:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Backup Database Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 23/04/08 'Date Of Last Modification: 23/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: '-------------------------------------------------------------------------------Option Explicit Dim FileSystemObject As Object Dim strfilename As String Private Sub cmdBackup_Click() On Error GoTo e 'set the copying functionality strfilename = "" + txtPath.Text + "\" + txtFile.Text + ".mdb" 'Set the object contractions

27
Set FileSystemObject = CreateObject("Scripting.FileSystemObject") 'Copy the file according the path settings FileSystemObject.copyfile App.Path & "\sdp.mdb", strfilename PrgBar.Visible = True timPrgBar.Enabled = True Exit Sub e: MsgBox "Invalid Path Setting, Please Try Again", vbCritical, "Invalid Path Setting!" End Sub Private Sub Dir_Click() txtPath.Text = "" & Dir.Path End Sub Private Sub Drive_Change() Dim d, fs As Object 'Set the constrctions to created objectes Set fs = CreateObject("Scripting.FileSystemObject") Set d = fs.getdrive(fs.getdrivename(Drive.Drive)) 'Set the contents of the selected drives If d.isready Then Dir.Path = Drive.Drive Dir.SetFocus Else MsgBox "The Drive Is Not Ready!", vbExclamation, "Drive Not Ready!" End If End Sub Private Sub Form_Load() 'Display Today 's date txtFile.Text = FormatDateTime(Now, vbLongDate) End Sub Private Sub timPrgBar_Timer() Static iCnt As Integer 'Run the timer and check the condition If iCnt <= 100 Then PrgBar.Value = iCnt iCnt = iCnt + 1 Else MsgBox "The Backup Procedure Has Been Successfully Completed!", vbInformation, "Successful Backup Procedure!" Drive.SetFocus PrgBar.Visible = False timPrgBar.Enabled = False End If End Sub Private Sub cmdClose_Click() 'On click of the Close Button 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormCalendar:Private Sub cmdClose_Click() 'On click of the Close Button 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If

28
End Sub Private Sub Form_Load() cldrSystemCalendar.Today End Sub

FormChangePassword:'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Change Password Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 23/04/08 'Date Of Last Modification: 23/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: UserAccount Table '---------------------------------------------------------------------------Private Sub Form_Load() 'On Form Load Call Connection 'Establishing connectivity with the database Call User_Account 'Calling the User_Account procedure to interact with the recordset txtUsername.Text = userID 'Automatically including the User ID in the Username textfield End Sub Private Sub cmdSave_Click() 'When the Save Button is clicked With rsUserAccount .MoveFirst 'Moving to the first record While .EOF = False 'Running through all the records in the database If .Fields(0).Value = txtUsername.Text Then 'Checking for the right Employee ID If .Fields(6).Value <> txtOldPassword Then 'Checking if the Old Password typed by the user is correct MsgBox "Error! The Old Password You Provided Was Incorrect! Please Check Your Password!", vbCritical, "Password Mismatch!" txtOldPassword.Text = "" 'Clearing the Old Password textfield Exit Sub End If If txtNewPassword.Text <> txtConfirmPassword.Text Then 'Checking if the new passwords match MsgBox "Error! The New Passwords You Provided Do Not Match! Please Check Your Passwords!", vbCritical, "Password Mismatch!" txtNewPassword.Text = "" 'Clearing the New Password textfield txtConfirmPassword.Text = "" 'Clearing the Confirm Password textfield Exit Sub End If If txtNewPassword.Text = txtConfirmPassword.Text Then 'Checking if the passwords match 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Change Your Password?", vbYesNo + vbQuestion, "Change Password?") = vbYes Then .Fields(6).Value = txtNewPassword.Text .Update 'Updating the recordset 'Display Success Message MsgBox "Your Password Has Been Changed Successfully!", vbInformation, "Password Changed Succesfully!" .MoveLast Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .MoveLast End If End If Else .MoveNext 'Moving to the next record End If

29
Wend Unload Me End With End Sub Private Sub cmdClose_Click() 'On click of the Close Button 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormChannelingAppointments:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Change Password Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 14/05/08 'Date Of Last Modification: 14/05/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Channeling_Appointments Table '-------------------------------------------------------------------------------Dim iNumberOfRecords As Integer 'This variable will store the number of records belonging to the particular doctor Dim datagridText As String 'This variable will hold the appointment end time of the last patient in the datagrid Private Sub cmdCheckChannelingDays_Click() frmSelectADay.Show End Sub Private Sub cmdClose_Click() 'Obtaining confirmation from the user If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdLaunchDocSearch_Click() frmDoctorSearchChanneling.Show End Sub Private Sub cmdPrint_Click() On Error GoTo e DataEnvironment1.Commands("ChannelingReceipt").Parameters(0) = txtFirstName DataEnvironment1.Commands("ChannelingReceipt").Parameters(1) = txtLastName RptChannelingReceipt.Show DataEnvironment1.rsChannelingReceipt.Close Unload Me Exit Sub e: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End If End Sub Private Sub cmdSave_Click() Call All_Appointments With rsAllAppointments 'Making sure that the user wants to save the record

30
If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then .AddNew .Fields(0) = txtDoctorID.Text .Fields(1) = dtpChosenDate.Value .Fields(2) = txtTokenNo.Text .Fields(3) = txtSpecialization.Text .Fields(4) = txtChannelingCharges.Text .Fields(5) = txtAppointmentDuration.Text .Fields(6) = txtChosenDay.Text .Fields(7) = dtpStartTime.Value .Fields(8) = dtpEndTime.Value .Fields(9) = dtpAppointmentStartTime.Hour & ":" & dtpAppointmentStartTime.Minute & ":" & dtpAppointmentStartTime.Second .Fields(10) = dtpAppointmentEndTime.Hour & ":" & dtpAppointmentEndTime.Minute & ":" & dtpAppointmentEndTime.Second .Fields(11) = txtFirstName.Text .Fields(12) = txtLastName.Text .Fields(13) = txtContactNo.Text .Fields(14) = DateTime.Date .Update .Requery 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" End If End With Call Channeling_Appointments Set dgrdChannelingInfo.DataSource = rsChannelingAppointments cmdPrint.Enabled = True End Sub Private Sub dgrdChannelingInfo_Click() End Sub Private Sub dtpChosenDate_CloseUp() dtpChosenDate.MinDate = DateTime.Date Call Channeling_Appointments rsChannelingAppointments.Filter = "ChosenDate Like '" & dtpChosenDate.Value & "'" Set dgrdChannelingInfo.DataSource = rsChannelingAppointments iNumberOfRecords = rsChannelingAppointments.RecordCount If iNumberOfRecords = 0 Then dtpAppointmentStartTime.Value = dtpStartTime.Value dtpAppointmentEndTime.Value = dtpStartTime.Value dtpAppointmentEndTime.Minute = Val(dtpAppointmentEndTime.Minute) + Val(txtAppointmentDuration.Text) txtTokenNo.Text = "1" 'Here, I am enabling the textfields where I will be entering the patient's information txtFirstName.Enabled = True txtLastName.Enabled = True txtContactNo.Enabled = True txtTokenNo.Enabled = True Else On Error GoTo error_handler 'Here, I am enabling the textfields where I will be entering the patient's information txtFirstName.Enabled = True txtLastName.Enabled = True txtContactNo.Enabled = True txtTokenNo.Enabled = True txtTokenNo.Text = iNumberOfRecords + 1 Dim gCol As MSDataGridLib.Column

31
Set gCol = dgrdChannelingInfo.Columns("AppointmentEndTime") dtpAppointmentStartTime.Value = gCol.CellValue(dgrdChannelingInfo.RowBookmark(iNumberOfRecords - 1)) If dtpAppointmentStartTime.Value = dtpEndTime.Value Then MsgBox "All Appointment Slots Have Been Booked! Please Choose Another Day!", vbCritical, "All Slots Booked!" Unload Me Exit Sub Else dtpAppointmentEndTime.Value = dtpAppointmentStartTime.Value dtpAppointmentEndTime.Minute = Val(dtpAppointmentEndTime.Minute) + Val(txtAppointmentDuration.Text) End If End If Exit Sub error_handler: 'If dtpAppointmentStartTime.Value = DateTime.Time Then dtpAppointmentEndTime.Minute = "00" dtpAppointmentEndTime.Hour = dtpAppointmentEndTime.Hour + 1 End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidDataMsg.Visible = False picInvalidKeyMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtContactNo_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 7320 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtFirstName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 6600 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtLastName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then

32
ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 6960 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

FormCompaniesSearchWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Companies_Maintenance 'Calling the Companies_Maintenance Procedure to interact with the recordset Set dgrdCompaniesInfoTable.DataSource = rsCompaniesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdCompaniesInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsCompaniesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[CompanyFullName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[DiscountAllowed] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdCompaniesInfoTable.DataSource = rsCompaniesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsCompaniesMaintenance.RecordCount > 0 Then With rsCompaniesMaintenance 'Reset the textfields with the selected record frmOutpatientsMaintenance.txtCompanyID.Text = .Fields(0).Value frmOutpatientsMaintenance.txtCompanyName.Text = .Fields(1).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record

33
MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormCreateDoctorSchedule:FormCredits:Private Sub cmdClose_Click() Unload Me End Sub Private Sub Form_Load() End Sub

FormDepartmentSearchWizard Ward:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Departments_Maintenance 'Calling the Departments_Maintenance Procedure to interact with the recordset Set dgrdDepartmentsInfoTable.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDepartmentsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDepartmentsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DepartmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[DepartmentName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDepartmentsInfoTable.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsDepartmentsMaintenance.RecordCount > 0 Then With rsDepartmentsMaintenance 'Reset the textfields with the selected record frmWardsMaintenance.txtDepartmentID.Text = .Fields(0).Value frmWardsMaintenance.txtDepartmentName.Text = .Fields(1).Value Unload Me 'Unload the Wizard End With

34
Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormDepartmentSearchWizardRooms:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Departments_Maintenance 'Calling the Departments_Maintenance Procedure to interact with the recordset Set dgrdDepartmentsInfoTable.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDepartmentsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDepartmentsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DepartmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[DepartmentName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDepartmentsInfoTable.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsDepartmentsMaintenance.RecordCount > 0 Then With rsDepartmentsMaintenance 'Reset the textfields with the selected record frmRoomsMaintenance.txtDepartmentID.Text = .Fields(0).Value frmRoomsMaintenance.txtDepartmentName.Text = .Fields(1).Value frmRoomsMaintenance.txtRoomCost = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

35 FormDepartmentsMaintenance:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Departments Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Departments_Maintenance Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Service ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Service ID to be autogenerated Private Sub cmdAddNew_Click() enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Disabling the Search Frame lblCriteria.Enabled = False cboSearchType.Enabled = False lblSearchFor.Enabled = False txtSearch.Enabled = False 'Disabling the DataGrid dgrdDepartmentsInformation.Enabled = False Call Departments_Maintenance 'Calling the Departments_Maintenance Procedure to interact with the recordset 'Generate Department ID By Utilizing the Departments_Maintenance Table With rsDepartmentsMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "DEP0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Departments_Maintenance Table If iNumOfRecords < 10 Then strCode = "DEP000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "DEP00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "DEP0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "DEP" & iNumOfRecords End If End If .Requery 'Requerying the Table

36
.AddNew 'Adding a new recordset End With enableAllFields 'Calling a Private Function To Enable All Fields 'Disabling the Search Frame cboSearchType.Enabled = False txtSearch.Enabled = False 'The following line of code will enter the autogenerated Medicine ID 'into the Medicine ID textfield txtDepartmentID.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it. 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The Department Name Is Not Greater Than 40 Characters If Len(txtDepartmentName.Text) > 40 Then MsgBox "Error! The Department Name Cannot Be Greater Than 40 Characters!", vbCritical, "Error In Department Name!" Exit Sub End If With rsDepartmentsMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtDepartmentID.Text .Fields(1) = txtDepartmentName.Text .Fields(2) = txtRoomRate.Text .Fields(3) = txtAdditionalNotes.Text .Update .Requery 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdDepartmentsInformation_Click() 'Enabling the Update Button & the Delete Button

37
cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsDepartmentsMaintenance 'Entering the values in the particular record into the fields on the interface txtDepartmentID.Text = .Fields(0).Value txtDepartmentName.Text = .Fields(1).Value txtRoomRate.Text = .Fields(2).Value txtAdditionalNotes.Text = .Fields(3).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Departments_Maintenance 'Calling the Departments_Maintenance Procedure to interact with the recordset disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchFor.Enabled = True txtSearch.Enabled = True 'Enabling the DataGrid dgrdDepartmentsInformation.Enabled = True Set dgrdDepartmentsInformation.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next

38
For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsDepartmentsMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtDepartmentID.Text = .Fields(0).Value txtDepartmentName.Text = .Fields(1).Value txtRoomRate.Text = .Fields(2).Value txtAdditionalNotes.Text = .Fields(3).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsDepartmentsMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtDepartmentID.Text = .Fields(0).Value txtDepartmentName.Text = .Fields(1).Value txtRoomRate.Text = .Fields(2).Value txtAdditionalNotes.Text = .Fields(3).Value

39
End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsDepartmentsMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtDepartmentID.Text = .Fields(0).Value txtDepartmentName.Text = .Fields(1).Value txtRoomRate.Text = .Fields(2).Value txtAdditionalNotes.Text = .Fields(3).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsDepartmentsMaintenance .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtDepartmentID.Text = .Fields(0).Value txtDepartmentName.Text = .Fields(1).Value txtRoomRate.Text = .Fields(2).Value txtAdditionalNotes.Text = .Fields(3).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidKeypressMsg.Visible = False

40
picInvalidDataMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtDepartmentName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4440 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtRoomRate_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 5040 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDepartmentsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DepartmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[DepartmentName] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False cmdDelete.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Departments_Maintenance Set dgrdDepartmentsInformation.DataSource = rsDepartmentsMaintenance End If End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The Department Name Is Not Greater Than 40 Characters

41
If Len(txtDepartmentName.Text) > 40 Then MsgBox "Error! The Department Name Cannot Be Greater Than 40 Characters!", vbCritical, "Error In Department Name!" Exit Sub End If With rsDepartmentsMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtDepartmentID.Text .Fields(1) = txtDepartmentName.Text .Fields(2) = txtRoomRate.Text .Fields(3) = txtAdditionalNotes.Text .Update .Requery 'Requerying the Table 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Department Name textfield is empty If txtDepartmentName.Text = "" Then txtDepartmentName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtDepartmentName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Room Rate textfield is empty If txtRoomRate.Text = "" Then txtRoomRate.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtRoomRate.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then

42
MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtDepartmentID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsDepartmentsMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete the " & txtDepartmentName.Text & " Department's Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub txtServiceName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4200 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtAmount_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 4800 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

FormDepartmentsSearchWizardAdmit:-

43
'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Departments_Maintenance 'Calling the Departments_Maintenance Procedure to interact with the recordset Set dgrdDepartmentsInfoTable.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDepartmentsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDepartmentsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DepartmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[DepartmentName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDepartmentsInfoTable.DataSource = rsDepartmentsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsDepartmentsMaintenance.RecordCount > 0 Then With rsDepartmentsMaintenance 'Reset the textfields with the selected record frmAdmitPatient.txtDepartmentID.Text = .Fields(0).Value frmAdmitPatient.txtDepartmentName.Text = .Fields(1).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormDischargeDetails Maintenance:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Discharge Details Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS

44
'Start Date: 07/05/08 'Date Of Last Modification: 07/05/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Discharge_Details Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'This variable will hold the Room ID of the patient being discharged Dim strRoomIDStore As String 'This variable will help me to decide if the patient has settled the bill in full Dim checkBillingFlag As Boolean 'The following variables will be used to autogenerate the Discharge ID to be 'displayed on the Discharge Details Maintenance form on form load Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Discharge ID to be autogenerated

Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtDischargeID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsDischargeMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Discharge ID " & txtDischargeID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table Form_Load 'Calling the Form_Load Procedure End With End If End Sub Private Sub cmdInpatientSearchWizard_Click() frmInpatientSearchDischarge.Show End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database checkBillingFlag = False If txtAdmissionID.Text = "" Then MsgBox "Error! You Have Not Selected A Patient!", vbInformation, "Error! No Selection!" Exit Sub End If With rsDischargeMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Discharge This Patient?", vbYesNo + vbQuestion, "Discharge Patient?") = vbYes Then 'Save the user-entered data into the recordset .Fields(0) = txtDischargeID.Text .Fields(1) = txtAdmissionID.Text

45
.Fields(2) = txtPatientID.Text .Fields(3) = txtFirstName.Text .Fields(4) = txtSurname.Text .Fields(5) = txtAdmissionDate.Text .Fields(6) = txtAdmissionTime.Text .Fields(7) = txtDischargeDate.Text .Fields(8) = txtDischargeTime.Text .Fields(9) = txtAdditionalNotes.Text .Fields(10) = True .Update Call Inpatients_Admission With rsInpatientsAdmission .MoveFirst Do While .EOF = False If txtAdmissionID.Text = .Fields(0).Value Then strRoomIDStore = .Fields(15).Value Exit Do Else .MoveNext End If Loop .Close End With Call Rooms_Maintenance With rsRoomsMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = strRoomIDStore Then .Fields(8).Value = False .Update Exit Do Else .MoveNext End If Loop End With 'Display Success Message MsgBox "The Patient Has Been Discharged Successfully!", vbInformation, "Succesful Discharge Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it If txtAdmissionID.Text = "" Then MsgBox "Error! You Have Not Selected A Patient!", vbInformation, "Error! No Selection!" Exit Sub End If With rsDischargeMaintenance 'Making sure that the user wants to update the record

46
If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'Save the user-entered data into the recordset .Fields(0) = txtDischargeID.Text .Fields(1) = txtAdmissionID.Text .Fields(2) = txtPatientID.Text .Fields(3) = txtFirstName.Text .Fields(4) = txtSurname.Text .Fields(5) = txtAdmissionDate.Text .Fields(6) = txtAdmissionTime.Text .Fields(7) = txtDischargeDate.Text .Fields(8) = txtDischargeTime.Text .Fields(9) = txtAdditionalNotes.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure End If .Requery 'Requerying the Table End With End Sub Private Sub dgrdDischargeInfo_Click() 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True 'Enabling the Wizard Buttons cmdInpatientSearchWizard.Enabled = True With rsDischargeMaintenance 'Entering the values in the particular record into the fields on the interface txtDischargeID.Text = .Fields(0).Value txtAdmissionID.Text = .Fields(1).Value txtPatientID.Text = .Fields(2).Value txtFirstName.Text = .Fields(3).Value txtSurname.Text = .Fields(4).Value txtAdmissionDate.Text = .Fields(5).Value txtAdmissionTime.Text = .Fields(6).Value txtDischargeDate.Text = .Fields(7).Value txtDischargeTime.Text = .Fields(8).Value txtAdditionalNotes.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdAddNew_Click() 'This function adds a new recordset into the database enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Disabling the Search Frame

47
lblCriteria.Enabled = False cboSearchType.Enabled = False lblSearchText.Enabled = False txtSearch.Enabled = False 'Disabling the DataGrid dgrdDischargeInfo.Enabled = False 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Enabling the Wizard Buttons cmdInpatientSearchWizard.Enabled = True Call Discharge_Maintenance 'Calling the Discharge_Maintenance Procedure to interact with the recordset 'Generate Discharge ID By Utilizing the Discharge_Maintenance Table With rsDischargeMaintenance If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "DIS0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Discharge_Maintenance Table If iNumOfRecords < 10 Then strDisplay = "DIS000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strDisplay = "DIS00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strDisplay = "DIS0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strDisplay = "DIS" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated Discharge ID 'into the Discharge ID textfield txtDischargeID.Text = strDisplay txtDischargeDate.Text = DateTime.Date 'Setting the system date into this textfield. txtDischargeTime.Text = DateTime.Time 'Setting the system time into this textfield. txtAdditionalNotes.Text = "-" 'Setting the default value for this textfield End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Discharge_Maintenance 'Calling the Discharge_Maintenance Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchText.Enabled = True txtSearch.Enabled = True

48
dgrdDischargeInfo.Enabled = True Set dgrdDischargeInfo.DataSource = rsDischargeMaintenance 'Setting the DataSource of the DataGrid End Sub Public Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Public Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True

49
'Enabling the Wizard Buttons cmdInpatientSearchWizard.Enabled = True With rsDischargeMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtDischargeID.Text = .Fields(0).Value txtAdmissionID.Text = .Fields(1).Value txtPatientID.Text = .Fields(2).Value txtFirstName.Text = .Fields(3).Value txtSurname.Text = .Fields(4).Value txtAdmissionDate.Text = .Fields(5).Value txtAdmissionTime.Text = .Fields(6).Value txtDischargeDate.Text = .Fields(7).Value txtDischargeTime.Text = .Fields(8).Value txtAdditionalNotes.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsDischargeMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtDischargeID.Text = .Fields(0).Value txtAdmissionID.Text = .Fields(1).Value txtPatientID.Text = .Fields(2).Value txtFirstName.Text = .Fields(3).Value txtSurname.Text = .Fields(4).Value txtAdmissionDate.Text = .Fields(5).Value txtAdmissionTime.Text = .Fields(6).Value txtDischargeDate.Text = .Fields(7).Value txtDischargeTime.Text = .Fields(8).Value txtAdditionalNotes.Text = .Fields(9).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Wizard Buttons cmdInpatientSearchWizard.Enabled = True 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsDischargeMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtDischargeID.Text = .Fields(0).Value

50
txtAdmissionID.Text = .Fields(1).Value txtPatientID.Text = .Fields(2).Value txtFirstName.Text = .Fields(3).Value txtSurname.Text = .Fields(4).Value txtAdmissionDate.Text = .Fields(5).Value txtAdmissionTime.Text = .Fields(6).Value txtDischargeDate.Text = .Fields(7).Value txtDischargeTime.Text = .Fields(8).Value txtAdditionalNotes.Text = .Fields(9).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Wizard Buttons cmdInpatientSearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Wizard Buttons cmdInpatientSearchWizard.Enabled = True With rsDischargeMaintenance .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtDischargeID.Text = .Fields(0).Value txtAdmissionID.Text = .Fields(1).Value txtPatientID.Text = .Fields(2).Value txtFirstName.Text = .Fields(3).Value txtSurname.Text = .Fields(4).Value txtAdmissionDate.Text = .Fields(5).Value txtAdmissionTime.Text = .Fields(6).Value txtDischargeDate.Text = .Fields(7).Value txtDischargeTime.Text = .Fields(8).Value txtAdditionalNotes.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub txtSearch_Change() If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDischargeMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DischargeID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[AdmissionID] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 3:

51
.Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False cmdDelete.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Discharge_Maintenance Set dgrdDischargeInfo.DataSource = rsDischargeMaintenance End If End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormDoctorSearchChanneling:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDoctorsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call AssignedDoctor_Selection 'Calling the AssignedDoctor_Selection Procedure to interact with the recordset Set dgrdDoctorsInfoTable.DataSource = rsAssignedDoctor 'Setting the DataSource of the DataGrid End Sub Private Sub Label1_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsAssignedDoctor 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DoctorID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Gender] Like '" & txtSearch.Text & "%" & "'" Case 4:

52
.Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[LicenceNo] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[Specialization] Like '" & txtSearch.Text & "%" & "'" Case 7: .Filter = "[DoctorCategory] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDoctorsInfoTable.DataSource = rsAssignedDoctor 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsAssignedDoctor.RecordCount > 0 Then With rsAssignedDoctor 'Reset the textfields with the selected record frmChannelingAppointments.txtDoctorID.Text = .Fields(0).Value frmChannelingAppointments.txtSpecialization.Text = .Fields(10).Value frmChannelingAppointments.txtChannelingCharges.Text = .Fields(13).Value frmChannelingAppointments.txtAppointmentDuration.Text = .Fields(14).Value frmChannelingAppointments.cmdCheckChannelingDays.Enabled = True 'Enabling the "Check Channeling Days" Button the Channeling Appointments form 'Enabling the relevant textfields frmChannelingAppointments.txtDoctorID.Enabled = True frmChannelingAppointments.txtSpecialization.Enabled = True frmChannelingAppointments.txtChannelingCharges.Enabled = True frmChannelingAppointments.txtAppointmentDuration.Enabled = True Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormDoctorSearchWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard 'Calling the clearAllFields procedure in the Doctors Maintenance Form frmDoctorsMaintenance.clearAllFields 'Calling the Form_Load procedure in the Doctors Maintenance Form frmDoctorsMaintenance.Form_Load End Sub Private Sub dgrdDoctorsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Doctors_Maintenance 'Calling the Doctors_Maintenance Procedure to interact with the recordset Set dgrdDoctorsInfoTable.DataSource = rsDoctorsMaintenance 'Setting the DataSource of the DataGrid

53
End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDoctorsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DoctorID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Gender] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[LicenceNo] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[Specialization] Like '" & txtSearch.Text & "%" & "'" Case 7: .Filter = "[DoctorCategory] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDoctorsInfoTable.DataSource = rsDoctorsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsDoctorsMaintenance.RecordCount > 0 Then With rsDoctorsMaintenance 'Reset the textfields with the selected record frmDoctorsMaintenance.txtDoctorID.Text = .Fields(0).Value frmDoctorsMaintenance.txtFirstName.Text = .Fields(1).Value frmDoctorsMaintenance.txtSurname.Text = .Fields(2).Value frmDoctorsMaintenance.cboGender.Text = .Fields(3).Value frmDoctorsMaintenance.dtpDateOfBirth.Value = .Fields(4).Value frmDoctorsMaintenance.txtNICNumber.Text = .Fields(5).Value frmDoctorsMaintenance.txtAddress.Text = .Fields(6).Value frmDoctorsMaintenance.txtHomePhone.Text = .Fields(7).Value frmDoctorsMaintenance.txtMobPhone.Text = .Fields(8).Value frmDoctorsMaintenance.txtLicenseNo.Text = .Fields(9).Value frmDoctorsMaintenance.txtDoctorSpecialization.Text = .Fields(10).Value frmDoctorsMaintenance.cboDoctorCategory.Text = .Fields(11).Value frmDoctorsMaintenance.txtServiceCharges.Text = .Fields(12).Value frmDoctorsMaintenance.txtChannelingCharges.Text = .Fields(13).Value frmDoctorsMaintenance.cboAppointmentDuration.Text = .Fields(14).Value frmDoctorsMaintenance.txtReferringCharges.Text = .Fields(15).Value 'Here, I am ensuring that the SetUpDoctor'sVisitingDays Button 'will be enabled only if the Doctor is a Visiting Doctor If frmDoctorsMaintenance.cboDoctorCategory.Text = "Visiting" Then frmDoctorsMaintenance.cmdSetUpDocSchedule.Enabled = True Else frmDoctorsMaintenance.cmdSetUpDocSchedule.Enabled = False End If

54
'Here, I am ensuring that certain components will be disabled if the doctor is a "Referring Doctor" If frmDoctorsMaintenance.cboDoctorCategory.Text = "Referring" Then frmDoctorsMaintenance.lblServiceCharges.Enabled = False frmDoctorsMaintenance.txtServiceCharges.Enabled = False frmDoctorsMaintenance.lblChannelingCharges.Enabled = False frmDoctorsMaintenance.txtChannelingCharges.Enabled = False frmDoctorsMaintenance.lblAppointmentDuration.Enabled = False frmDoctorsMaintenance.cboAppointmentDuration.Enabled = False Else frmDoctorsMaintenance.lblServiceCharges.Enabled = True frmDoctorsMaintenance.txtServiceCharges.Enabled = True frmDoctorsMaintenance.lblChannelingCharges.Enabled = True frmDoctorsMaintenance.txtChannelingCharges.Enabled = True frmDoctorsMaintenance.lblAppointmentDuration.Enabled = True frmDoctorsMaintenance.cboAppointmentDuration.Enabled = True End If 'Here, I am ensuring that the Referring Charges textfield will be disabled if the Doctor is a "Permanent" Doctor If frmDoctorsMaintenance.cboDoctorCategory.Text = "Permanent" Then frmDoctorsMaintenance.lblReferringCharges.Enabled = False frmDoctorsMaintenance.txtReferringCharges.Enabled = False Else frmDoctorsMaintenance.lblReferringCharges.Enabled = True frmDoctorsMaintenance.txtReferringCharges.Enabled = True End If Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormDoctorSearchWizardSchedule:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Dim rsClearRecord As ADODB.Recordset 'This will be used to create a virtual recordset Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdDoctorsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Doctors_Maintenance 'Calling the Doctors_Maintenance Procedure to interact with the recordset Set dgrdDoctorsInfoTable.DataSource = rsDoctorsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsDoctorsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[DoctorID] Like '" & txtSearch.Text & "%" & "'" Case 1:

55
.Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Gender] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[LicenceNo] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[Specialization] Like '" & txtSearch.Text & "%" & "'" Case 7: .Filter = "[DoctorCategory] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdDoctorsInfoTable.DataSource = rsDoctorsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsDoctorsMaintenance.RecordCount > 0 Then With rsDoctorsMaintenance If .Fields(11).Value = "Referring" Then MsgBox "This Doctor Is A Referring Doctor! You Cannot Set Up A Channeling Schedule For A Referring Doctor!", vbExclamation, "Invalid Doctor Category!" Exit Sub End If 'Reset the textfields with the selected record frmDoctorScheduleMaintenance.txtDoctorID.Text = .Fields(0).Value 'Here, I am ensuring that the Grid gets filled up with values if the 'Doctor is a Visiting Doctor, in order to display the Visiting Doctors 'Schedule If .Fields(11).Value = "Visiting" Then Call Relevant_Doctor_Schedule Set frmDoctorScheduleMaintenance.dgrdVisitingDoctorsVisitSchedule.DataSource = rsRelevantDoctorSchedule 'Setting the DataSource of the DataGrid .Close Unload Me 'Unload the Wizard Else Set rsClearRecord = New ADODB.Recordset rsClearRecord.Fields.Append " ", adVarChar, 10 Set frmDoctorScheduleMaintenance.dgrdVisitingDoctorsVisitSchedule.DataSource = rsClearRecord End If End With Unload Me 'Closing the form Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormDoctorSpecializationWizard:Private Sub cmdCancel_Click() Unload Me End Sub

56
Private Sub cmdOK_Click() frmDoctorsMaintenance.txtDoctorSpecialization.Text = lstSpecializations.Text Unload Me End Sub Private Sub Form_Load() cmdOK.Enabled = False 'Disabling the OK Button End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub lstSpecializations_Click() cmdOK.Enabled = True End Sub

FormDoctorVisitingDays:Private Sub Form_Load() Call Connection 'Call Connection Procedure To Establish Connection With The Database Call VisitTimes_Schedule 'Calling the VisitTimes_Schedule Procedure To Interact With The Recordset With rsVisitTimesSchedule .MoveFirst 'Move To The First Record While .EOF = False 'Running Through All The Records 'Here, I Am Checking The Doctor ID In Order To I Find A Match If .Fields(1).Value = frmDoctorsMaintenance.txtDoctorID.Text Then 'In The Following Blocks Of If Else Conditions, I am enabling 'the DateTime Pickers if the times have already been set. 'Therefore for a new doctor, none of the DateTime Pickers 'will be enabled. If .Fields(2).Value <> "12:00:00 AM" Then chkMonday.Value = 1 dtpMondayTimeIn.Enabled = True dtpMondayTimeOut.Enabled = True dtpMondayTimeIn.Value = .Fields(2).Value dtpMondayTimeOut.Value = .Fields(3).Value End If If .Fields(4).Value <> "12:00:00 AM" Then chkTuesday.Value = 1 dtpTuesdayTimeIn.Enabled = True dtpTuesdayTimeOut.Enabled = True dtpTuesdayTimeIn.Value = .Fields(4).Value dtpTuesdayTimeOut.Value = .Fields(5).Value End If If .Fields(6).Value <> "12:00:00 AM" Then chkWednesday.Value = 1 dtpWednesdayTimeIn.Enabled = True dtpWednesdayTimeOut.Enabled = True dtpWednesdayTimeIn.Value = .Fields(6).Value dtpWednesdayTimeOut.Value = .Fields(7).Value End If If .Fields(8).Value <> "12:00:00 AM" Then chkThursday.Value = 1 dtpThursdayTimeIn.Enabled = True dtpThursdayTimeOut.Enabled = True dtpThursdayTimeIn.Value = .Fields(8).Value dtpThursdayTimeOut.Value = .Fields(9).Value End If If .Fields(10).Value <> "12:00:00 AM" Then chkFriday.Value = 1

57
dtpFridayTimeIn.Enabled = True dtpFridayTimeOut.Enabled = True dtpFridayTimeIn.Value = .Fields(10).Value dtpFridayTimeOut.Value = .Fields(11).Value End If If .Fields(12).Value <> "12:00:00 AM" Then chkSaturday.Value = 1 dtpSaturdayTimeIn.Enabled = True dtpSaturdayTimeOut.Enabled = True dtpSaturdayTimeIn.Value = .Fields(12).Value dtpSaturdayTimeOut.Value = .Fields(13).Value End If If .Fields(14).Value <> "12:00:00 AM" Then chkSunday.Value = 1 dtpSundayTimeIn.Enabled = True dtpSundayTimeOut.Enabled = True dtpSundayTimeIn.Value = .Fields(14).Value dtpSundayTimeOut.Value = .Fields(15).Value End If End If .MoveNext 'Moving to the next record Wend End With End Sub Private Sub chkMonday_Click() 'Enabling the DateTime Pickers If chkMonday.Value = 1 Then dtpMondayTimeIn.Enabled = True dtpMondayTimeOut.Enabled = True Else dtpMondayTimeIn.Enabled = False dtpMondayTimeOut.Enabled = False End If End Sub Private Sub chkTuesday_Click() 'Enabling the DateTime Pickers If chkTuesday.Value = 1 Then dtpTuesdayTimeIn.Enabled = True dtpTuesdayTimeOut.Enabled = True Else dtpTuesdayTimeIn.Enabled = False dtpTuesdayTimeOut.Enabled = False End If End Sub Private Sub chkWednesday_Click() 'Enabling the DateTime Pickers If chkWednesday.Value = 1 Then dtpWednesdayTimeIn.Enabled = True dtpWednesdayTimeOut.Enabled = True Else dtpWednesdayTimeIn.Enabled = False dtpWednesdayTimeOut.Enabled = False End If End Sub Private Sub chkThursday_Click() 'Enabling the DateTime Pickers If chkThursday.Value = 1 Then dtpThursdayTimeIn.Enabled = True dtpThursdayTimeOut.Enabled = True Else dtpThursdayTimeIn.Enabled = False dtpThursdayTimeOut.Enabled = False End If

58
End Sub Private Sub chkFriday_Click() 'Enabling the DateTime Pickers If chkFriday.Value = 1 Then dtpFridayTimeIn.Enabled = True dtpFridayTimeOut.Enabled = True Else dtpFridayTimeIn.Enabled = False dtpFridayTimeOut.Enabled = False End If End Sub Private Sub chkSaturday_Click() 'Enabling the DateTime Pickers If chkSaturday.Value = 1 Then dtpSaturdayTimeIn.Enabled = True dtpSaturdayTimeOut.Enabled = True Else dtpSaturdayTimeIn.Enabled = False dtpSaturdayTimeOut.Enabled = False End If End Sub Private Sub chkSunday_Click() 'Enabling the DateTime Pickers If chkSunday.Value = 1 Then dtpSundayTimeIn.Enabled = True dtpSundayTimeOut.Enabled = True Else dtpSundayTimeIn.Enabled = False dtpSundayTimeOut.Enabled = False End If End Sub Private Sub cmdClose_Click() 'Closing the Wizard Unload Me End Sub Private Sub cmdSave_Click() 'If the Save Button is Clicked With rsVisitTimesSchedule .MoveFirst 'Moving to the first record While .EOF = False 'Running Through All The Records 'Here, I Am Checking The Doctor ID In Order To I Find A Match. 'When I Find A Match, I Will Be Setting The Values Of The DateTime 'Pickers Accordingly. If .Fields(1).Value = frmDoctorsMaintenance.txtDoctorID.Text Then 'Monday If chkMonday.Value = 0 Then .Fields(2).Value = Null .Fields(3).Value = Null Else .Fields(2).Value = dtpMondayTimeIn.Hour & ":" & dtpMondayTimeIn.Minute & ":" & dtpMondayTimeIn.Second .Fields(3).Value = dtpMondayTimeOut.Hour & ":" & dtpMondayTimeOut.Minute & ":" & dtpMondayTimeOut.Second End If 'Tuesday If chkTuesday.Value = 0 Then .Fields(4).Value = Null .Fields(5).Value = Null Else .Fields(4).Value = dtpTuesdayTimeIn.Hour & ":" & dtpTuesdayTimeIn.Minute & ":" & dtpTuesdayTimeIn.Second .Fields(5).Value = dtpTuesdayTimeOut.Hour & ":" & dtpTuesdayTimeOut.Minute & ":" & dtpTuesdayTimeOut.Second End If

59
'Wednesday If chkWednesday.Value = 0 Then .Fields(6).Value = Null .Fields(7).Value = Null Else .Fields(6).Value = dtpWednesdayTimeIn.Hour & ":" & dtpWednesdayTimeIn.Minute & ":" & dtpWednesdayTimeIn.Second .Fields(7).Value = dtpWednesdayTimeOut.Hour & ":" & dtpWednesdayTimeOut.Minute & ":" & dtpWednesdayTimeOut.Second End If 'Thursday If chkThursday.Value = 0 Then .Fields(8).Value = Null .Fields(9).Value = Null Else .Fields(8).Value = dtpThursdayTimeIn.Hour & ":" & dtpThursdayTimeIn.Minute & ":" & dtpThursdayTimeIn.Second .Fields(9).Value = dtpThursdayTimeOut.Hour & ":" & dtpThursdayTimeOut.Minute & ":" & dtpThursdayTimeOut.Second End If 'Friday If chkFriday.Value = 0 Then .Fields(10).Value = Null .Fields(11).Value = Null Else .Fields(10).Value = dtpFridayTimeIn.Hour & ":" & dtpFridayTimeIn.Minute & ":" & dtpFridayTimeIn.Second .Fields(11).Value = dtpFridayTimeOut.Hour & ":" & dtpFridayTimeOut.Minute & ":" & dtpFridayTimeOut.Second End If 'Saturday If chkSaturday.Value = 0 Then .Fields(12).Value = Null .Fields(13).Value = Null Else .Fields(12).Value = dtpSaturdayTimeIn.Hour & ":" & dtpSaturdayTimeIn.Minute & ":" & dtpSaturdayTimeIn.Second .Fields(13).Value = dtpSaturdayTimeOut.Hour & ":" & dtpSaturdayTimeOut.Minute & ":" & dtpSaturdayTimeOut.Second End If 'Sunday If chkSunday.Value = 0 Then .Fields(14).Value = Null .Fields(15).Value = Null Else .Fields(14).Value = dtpSundayTimeIn.Hour & ":" & dtpSundayTimeIn.Minute & ":" & dtpSundayTimeIn.Second .Fields(15).Value = dtpSundayTimeOut.Hour & ":" & dtpSundayTimeOut.Minute & ":" & dtpSundayTimeOut.Second End If .Update 'Updating the Recordset Unload Me 'Closing the Form Exit Sub End If .MoveNext 'Moving To The Next Record Wend 'The Adding of a New Record Obviously Takes Place Only If There Is 'No Matching Doctor ID To Be Found, Which Would Mean That The Doctor 'Is New

60
.AddNew 'Adding a New Record 'Adding the Doctor ID Into The Relevant Field .Fields(1).Value = frmDoctorsMaintenance.txtDoctorID.Text 'Monday If chkMonday.Value = 0 Then .Fields(2).Value = Null .Fields(3).Value = Null Else .Fields(2).Value = dtpMondayTimeIn.Hour & ":" & dtpMondayTimeIn.Minute & ":" & dtpMondayTimeIn.Second .Fields(3).Value = dtpMondayTimeOut.Hour & ":" & dtpMondayTimeOut.Minute & ":" & dtpMondayTimeOut.Second End If 'Tuesday If chkTuesday.Value = 0 Then .Fields(4).Value = Null .Fields(5).Value = Null Else .Fields(4).Value = dtpTuesdayTimeIn.Hour & ":" & dtpTuesdayTimeIn.Minute & ":" & dtpTuesdayTimeIn.Second .Fields(5).Value = dtpTuesdayTimeOut.Hour & ":" & dtpTuesdayTimeOut.Minute & ":" & dtpTuesdayTimeOut.Second End If 'Wednesday If chkWednesday.Value = 0 Then .Fields(6).Value = Null .Fields(7).Value = Null Else .Fields(6).Value = dtpWednesdayTimeIn.Hour & ":" & dtpWednesdayTimeIn.Minute & ":" & dtpWednesdayTimeIn.Second .Fields(7).Value = dtpWednesdayTimeOut.Hour & ":" & dtpWednesdayTimeOut.Minute & ":" & dtpWednesdayTimeOut.Second End If 'Thursday If chkThursday.Value = 0 Then .Fields(8).Value = Null .Fields(9).Value = Null Else .Fields(8).Value = dtpThursdayTimeIn.Hour & ":" & dtpThursdayTimeIn.Minute & ":" & dtpThursdayTimeIn.Second .Fields(9).Value = dtpThursdayTimeOut.Hour & ":" & dtpThursdayTimeOut.Minute & ":" & dtpThursdayTimeOut.Second End If 'Friday If chkFriday.Value = 0 Then .Fields(10).Value = Null .Fields(11).Value = Null Else .Fields(10).Value = dtpFridayTimeIn.Hour & ":" & dtpFridayTimeIn.Minute & ":" & dtpFridayTimeIn.Second .Fields(11).Value = dtpFridayTimeOut.Hour & ":" & dtpFridayTimeOut.Minute & ":" & dtpFridayTimeOut.Second End If 'Saturday If chkSaturday.Value = 0 Then .Fields(12).Value = Null .Fields(13).Value = Null Else

61
.Fields(12).Value = dtpSaturdayTimeIn.Hour & ":" & dtpSaturdayTimeIn.Minute & ":" & dtpSaturdayTimeIn.Second .Fields(13).Value = dtpSaturdayTimeOut.Hour & ":" & dtpSaturdayTimeOut.Minute & ":" & dtpSaturdayTimeOut.Second End If 'Sunday If chkSunday.Value = 0 Then .Fields(14).Value = Null .Fields(15).Value = Null Else .Fields(14).Value = dtpSundayTimeIn.Hour & ":" & dtpSundayTimeIn.Minute & ":" & dtpSundayTimeIn.Second .Fields(15).Value = dtpSundayTimeOut.Hour & ":" & dtpSundayTimeOut.Minute & ":" & dtpSundayTimeOut.Second End If .Update 'Updating The Record Unload Me 'Closing the Form End With Unload Me End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub

FormEditCompany:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Companies Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Companies_Maintenance Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Service ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Service ID to be autogenerated Private Sub cmdAddNew_Click() enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Disabling the Search Frame lblCriteria.Enabled = False cboSearchType.Enabled = False lblSearchFor.Enabled = False txtSearch.Enabled = False 'Disabling the DataGrid

62
dgrdCompanyInformation.Enabled = False Call Companies_Maintenance 'Calling the Companies_Maintenance Procedure to interact with the recordset 'Generate Company ID By Utilizing the Companies_Maintenance Table With rsCompaniesMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "COM0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Companies_Maintenance Table If iNumOfRecords < 10 Then strCode = "COM000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "COM00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "COM0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "COM" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With enableAllFields 'Calling a Private Function To Enable All Fields 'Disabling the Search Frame cboSearchType.Enabled = False txtSearch.Enabled = False 'The following line of code will enter the autogenerated Company ID 'into the Company ID textfield txtCompanyID.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it. 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The Phone Number Is Not Greater Than 15 Digits If Len(txtPhoneNumber.Text) > 15 Then MsgBox "Error! The Phone Number Cannot Be Greater Than 15 Digits!", vbCritical, "Error In Phone Number!" Exit Sub End If With rsCompaniesMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following if else condition ensures that The Corporate Short Name 'textfield will not be completely blank when saving. 'This has been done in order to avoid errors. If txtCompanyShortName.Text = "" Then txtCompanyShortName.Text = "-" End If 'Save the user-entered data into the recordset

63
.Fields(0) = txtCompanyID.Text .Fields(1) = txtCompanyFullName.Text .Fields(2) = txtCompanyShortName.Text .Fields(3) = txtCompanyAddress.Text .Fields(4) = txtContactPerson.Text .Fields(5) = txtPhoneNumber.Text .Fields(6) = cboDiscountAllowed.Text .Update .Requery 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdCompanyInformation_Click() 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsCompaniesMaintenance 'Entering the values in the particular record into the fields on the interface txtCompanyID.Text = .Fields(0).Value txtCompanyFullName.Text = .Fields(1).Value txtCompanyShortName.Text = .Fields(2).Value txtCompanyAddress.Text = .Fields(3).Value txtContactPerson.Text = .Fields(4).Value txtPhoneNumber.Text = .Fields(5).Value cboDiscountAllowed.Text = .Fields(6).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Companies_Maintenance 'Calling the Companies_Maintenance Procedure to interact with the recordset disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True

64
lblSearchFor.Enabled = True txtSearch.Enabled = True 'Enabling the DataGrid dgrdCompanyInformation.Enabled = True Set dgrdCompanyInformation.DataSource = rsCompaniesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsCompaniesMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtCompanyID.Text = .Fields(0).Value txtCompanyFullName.Text = .Fields(1).Value txtCompanyShortName.Text = .Fields(2).Value txtCompanyAddress.Text = .Fields(3).Value

65
txtContactPerson.Text = .Fields(4).Value txtPhoneNumber.Text = .Fields(5).Value cboDiscountAllowed.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsCompaniesMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtCompanyID.Text = .Fields(0).Value txtCompanyFullName.Text = .Fields(1).Value txtCompanyShortName.Text = .Fields(2).Value txtCompanyAddress.Text = .Fields(3).Value txtContactPerson.Text = .Fields(4).Value txtPhoneNumber.Text = .Fields(5).Value cboDiscountAllowed.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsCompaniesMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtCompanyID.Text = .Fields(0).Value txtCompanyFullName.Text = .Fields(1).Value txtCompanyShortName.Text = .Fields(2).Value txtCompanyAddress.Text = .Fields(3).Value txtContactPerson.Text = .Fields(4).Value txtPhoneNumber.Text = .Fields(5).Value cboDiscountAllowed.Text = .Fields(6).Value

66
End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsCompaniesMaintenance .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtCompanyID.Text = .Fields(0).Value txtCompanyFullName.Text = .Fields(1).Value txtCompanyShortName.Text = .Fields(2).Value txtCompanyAddress.Text = .Fields(3).Value txtContactPerson.Text = .Fields(4).Value txtPhoneNumber.Text = .Fields(5).Value cboDiscountAllowed.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidKeypressMsg.Visible = False picInvalidDataMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtContactPerson_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 6000 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPhoneNumber_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then

67
Else picInvalidKeypressMsg.Top = 6480 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsCompaniesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[CompanyFullName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[DiscountAllowed] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Setting the Dicount Allowed ComboBox's default display text cboDiscountAllowed.Text = "-------SELECT-------" 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False cmdDelete.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Companies_Maintenance Set dgrdCompanyInformation.DataSource = rsCompaniesMaintenance 'Setting the Datasource for the DataGrid End If End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The Phone Number Is Not Greater Than 15 Digits If Len(txtPhoneNumber.Text) > 15 Then MsgBox "Error! The Phone Number Cannot Be Greater Than 15 Digits!", vbCritical, "Error In Phone Number!" Exit Sub End If With rsCompaniesMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtCompanyShortName.Text = "" Then txtCompanyShortName.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtCompanyID.Text .Fields(1) = txtCompanyFullName.Text .Fields(2) = txtCompanyShortName.Text

68
.Fields(3) = txtCompanyAddress.Text .Fields(4) = txtContactPerson.Text .Fields(5) = txtPhoneNumber.Text .Fields(6) = cboDiscountAllowed.Text .Update .Requery 'Requerying the Table 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Company Full Name textfield is empty If txtCompanyFullName.Text = "" Then txtCompanyFullName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtCompanyFullName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Company Address textfield is empty If txtCompanyAddress.Text = "" Then txtCompanyAddress.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtCompanyAddress.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Contact Person textfield is empty If txtContactPerson.Text = "" Then txtContactPerson.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtContactPerson.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Phone Number textfield is empty If txtPhoneNumber.Text = "" Then txtPhoneNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPhoneNumber.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Discount Allowed ComboBox If cboDiscountAllowed.Text = "" Then cboDiscountAllowed.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboDiscountAllowed.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If

69
'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtCompanyID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsCompaniesMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Company ID " & txtCompanyID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub

FormEditDepartments FormEditDischargeDetails FormEditDoctors:'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Doctors Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Doctors_Maintenance Table '---------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following Boolean Variable will determine if the Doctor's Date Of Birth 'entered by the user is valid

70
Dim dateFlag As Boolean 'The following variables will be used to autogenerate the Doctor ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Doctor ID to be autogenerated Private Sub cboDoctorCategory_Click() 'This function will manipulate other controls according to the type of doctor 'The following block of code will disable the Referring Charges textfield 'if the Doctor is a Permanent Doctor If cboDoctorCategory.ListIndex = 0 Then txtReferringCharges.Text = "-" txtReferringCharges.Enabled = False lblReferringCharges.Enabled = False Else txtReferringCharges.Enabled = True lblReferringCharges.Enabled = True End If 'The following block of code will enable the Set Up Doctor Schedule 'Command Button if the doctor is a Visiting Doctor If cboDoctorCategory.ListIndex = 1 Then cmdSetUpDocSchedule.Enabled = True Else cmdSetUpDocSchedule.Enabled = False End If 'The following block of code will disable the Channeling Charges textfield 'if the doctor is a Referring Doctor If cboDoctorCategory.ListIndex = 2 Then lblServiceCharges.Enabled = False txtServiceCharges.Enabled = False txtChannelingCharges.Text = "-" txtChannelingCharges.Enabled = False lblChannelingCharges.Enabled = False lblAppointmentDuration.Enabled = False cboAppointmentDuration.Enabled = False Else lblServiceCharges.Enabled = True txtServiceCharges.Enabled = True txtChannelingCharges.Enabled = True lblChannelingCharges.Enabled = True lblAppointmentDuration.Enabled = True cboAppointmentDuration.Enabled = True End If End Sub Private Sub cmdAddNew_Click() 'This function adds a new recordset into the database enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons txtLicenseNo.Text = "E" 'Since all doctor's License Numbers start with E txtNICNumber.Text = "-" 'Since this textfield is not compulsory txtMobPhone.Text = "-" 'Since this textfield is not compulsory txtServiceCharges.Text = "-" 'Since I do not want to store a null value in the database txtChannelingCharges.Text = "-" 'Since I do not want to store a null value in the database txtReferringCharges.Text = "-" 'Since I do not want to store a null value in the database 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Enabling the Specialization Wizard Button

71
cmdSpecializationWizard.Enabled = True Call Doctors_Maintenance 'Calling the Doctors_Maintenance Procedure to interact with the recordset 'Generate Doctor ID By Utilizing the Doctors_Maintenance Table With rsDoctorsMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "DOC0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Doctors_Maintenance Table If iNumOfRecords < 10 Then strCode = "DOC000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "DOC00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "DOC0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "DOC" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated Doctor ID 'into the Doctor ID textfield txtDoctorID.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtDoctorID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsDoctorsMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Doctor " & txtSurname.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Call VisitTimes_Schedule With rsVisitTimesSchedule .MoveFirst While .EOF = False If txtDoctorID.Text = .Fields(1).Value Then .Delete End If .MoveNext Wend .Close End With

72
Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdLaunchDocSearch_Click() 'This function is fired when the Launch Doctor-Search Wizard Command Button is Clicked. It opens up the Doctor Search Wizard enableAllFields 'Calling a Private Function To Enable All Fields enableAllButtons 'Calling a Private Function To Enable All Command Buttons cmdSave.Enabled = False 'Disabling the Save Command Button frmDoctorSearchWizard.Show 'Displays the Doctor Search Wizard End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If 'Validation To Ensure That The Channeling Charges Are Not Geater Than 3000 If txtChannelingCharges.Text <> "-" Then If Val(txtChannelingCharges.Text) > 3000 Then MsgBox "Error! Channeling Charges Cannot Be Greater Than 3000!", vbCritical, "Error In Channeling Charges!" txtChannelingCharges.BackColor = &H80000018 Exit Sub Else txtChannelingCharges.BackColor = &H80000004 End If End If 'Validation To Ensure That The Referring Charges Are Not Geater Than 1000 If txtReferringCharges.Text <> "-" Then If Val(txtReferringCharges.Text) > 1000 Then MsgBox "Error! Referring Charges Cannot Be Greater Than 1000!", vbCritical, "Error In Referring Charges!" txtReferringCharges.BackColor = &H80000018 Exit Sub Else txtReferringCharges.BackColor = &H80000004 End If End If With rsDoctorsMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then

73
'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtMobPhone.Text = "" Then txtMobPhone.Text = "-" End If If txtChannelingCharges.Text = "" Then txtChannelingCharges.Text = "-" End If If txtReferringCharges.Text = "" Then txtReferringCharges.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtDoctorID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtSurname.Text .Fields(3) = cboGender.Text .Fields(4) = dtpDateOfBirth.Value .Fields(5) = txtNICNumber.Text .Fields(6) = txtAddress.Text .Fields(7) = txtHomePhone.Text .Fields(8) = txtMobPhone.Text .Fields(9) = txtLicenseNo.Text .Fields(10) = txtDoctorSpecialization.Text .Fields(11) = cboDoctorCategory.Text .Fields(12) = txtServiceCharges.Text .Fields(13) = txtChannelingCharges.Text .Fields(14) = cboAppointmentDuration.Text .Fields(15) = txtReferringCharges.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdSetUpDocSchedule_Click() 'Opens up the Wizard to set up the Doctor's Visiting Days Schedule. frmDoctorVisitingDaysWizard.Show End Sub Private Sub cmdSpecializationWizard_Click() frmDoctorSpecializationWizard.Show End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then

74
'Here, i am ensuring that whilst editing, the user cannot enter 'Referring Charges for a Permanent Doctor and cannot enter 'Channeling Charges for a Referring Doctor If cboDoctorCategory.Text = "Permanent" Then txtReferringCharges.Text = "-" ElseIf cboDoctorCategory.Text = "Referring" Then txtChannelingCharges.Text = "-" End If 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" Exit Sub End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If Len(txtHomePhone.Text) > 15 Then MsgBox "Error! The Phone No (Home) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Home)!" Exit Sub End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtMobPhone.Text <> "-" Then If Len(txtMobPhone.Text) > 15 Then MsgBox "Error! The Phone No (Mob) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Mob)!" Exit Sub End If End If 'Validation To Ensure That The Channeling Charges Are Not Geater Than 3000 If txtChannelingCharges.Text <> "-" Then If Val(txtChannelingCharges.Text) > 3000 Then MsgBox "Error! Channeling Charges Cannot Be Greater Than 3000!", vbCritical, "Error In Channeling Charges!" Exit Sub End If End If 'Validation To Ensure That The Referring Charges Are Not Geater Than 1000 If txtReferringCharges.Text <> "-" Then If Val(txtReferringCharges.Text) > 1000 Then MsgBox "Error! Referring Charges Cannot Be Greater Than 1000!", vbCritical, "Error In Referring Charges!" Exit Sub End If End If With rsDoctorsMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtMobPhone.Text = "" Then txtMobPhone.Text = "-" End If

75
If txtChannelingCharges.Text = "" Then txtChannelingCharges.Text = "-" End If If txtReferringCharges.Text = "" Then txtReferringCharges.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtDoctorID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtSurname.Text .Fields(3) = cboGender.Text .Fields(4) = dtpDateOfBirth.Value .Fields(5) = txtNICNumber.Text .Fields(6) = txtAddress.Text .Fields(7) = txtHomePhone.Text .Fields(8) = txtMobPhone.Text .Fields(9) = txtLicenseNo.Text .Fields(10) = txtDoctorSpecialization.Text .Fields(11) = cboDoctorCategory.Text .Fields(12) = txtServiceCharges.Text .Fields(13) = txtChannelingCharges.Text .Fields(14) = cboAppointmentDuration.Text .Fields(15) = txtReferringCharges.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub dtpDateOfBirth_CloseUp() dtpDateOfBirth.MaxDate = DateTime.Date End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Doctors_Maintenance 'Calling the Doctors_Maintenance Procedure to interact with the recordset disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the LaunchDoctorSearch Wizard Button cmdLaunchDocSearch.Enabled = True End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next

76
For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next dtpDateOfBirth.Enabled = False 'Disabling the Date Of Birth Date Time Picker cmdSpecializationWizard.Enabled = False 'Disabling the Specialization Wizard Button End Function Private Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next dtpDateOfBirth.Enabled = True 'Enabling the Date Of Birth Date Time Picker cmdSpecializationWizard.Enabled = True End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next 'The following lines will set the normal display values of the 'Date Of Birth Date Time Picker dtpDateOfBirth.Value = "4/14/2008" End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True

77
Call Doctors_Maintenance 'Calling the Doctors_Maintenance Procedure to interact with the recordset With rsDoctorsMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtDoctorID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtHomePhone.Text = .Fields(7).Value txtMobPhone.Text = .Fields(8).Value txtLicenseNo.Text = .Fields(9).Value txtDoctorSpecialization.Text = .Fields(10).Value cboDoctorCategory.Text = .Fields(11).Value txtServiceCharges.Text = .Fields(12).Value txtChannelingCharges.Text = .Fields(13).Value cboAppointmentDuration.Text = .Fields(14).Value txtReferringCharges.Text = .Fields(15).Value End With enableAllFields 'Calling a Private Function To Enable All Fields 'Here, I am enabling the SetUpDoctor'sVisitingDays Button only if the Doctor Type is Visiting If cboDoctorCategory.Text = "Visiting" Then cmdSetUpDocSchedule.Enabled = True Else cmdSetUpDocSchedule.Enabled = False End If disableIfReferringDoctor 'Calling a function to disable certain components if the doctor is a "Referring" doctor disableIfPermanentDoctor 'Calling a function to disable the Referring Charges textfield if the Doctor is a "Permanent" doctor End Sub Public Function disableIfReferringDoctor() 'Here, I am disabling certain components if the doctor is a "Referring Doctor" If cboDoctorCategory.Text = "Referring" Then lblServiceCharges.Enabled = False txtServiceCharges.Enabled = False lblChannelingCharges.Enabled = False txtChannelingCharges.Enabled = False lblAppointmentDuration.Enabled = False cboAppointmentDuration.Enabled = False Else lblServiceCharges.Enabled = True txtServiceCharges.Enabled = True lblChannelingCharges.Enabled = True txtChannelingCharges.Enabled = True lblAppointmentDuration.Enabled = True cboAppointmentDuration.Enabled = True End If End Function Public Function disableIfPermanentDoctor() 'Here, I am disabling the Referring Charges textfield if the doctor is a Permanent Doctor If cboDoctorCategory.Text = "Permanent" Then lblReferringCharges.Enabled = False txtReferringCharges.Enabled = False Else lblReferringCharges.Enabled = True

78
txtReferringCharges.Enabled = True End If End Function Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsDoctorsMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtDoctorID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtHomePhone.Text = .Fields(7).Value txtMobPhone.Text = .Fields(8).Value txtLicenseNo.Text = .Fields(9).Value txtDoctorSpecialization.Text = .Fields(10).Value cboDoctorCategory.Text = .Fields(11).Value txtServiceCharges.Text = .Fields(12).Value txtChannelingCharges.Text = .Fields(13).Value cboAppointmentDuration.Text = .Fields(14).Value txtReferringCharges.Text = .Fields(15).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields 'Here, I am enabling the SetUpDoctor'sVisitingDays Button only if the Doctor Type is Visiting If cboDoctorCategory.Text = "Visiting" Then cmdSetUpDocSchedule.Enabled = True Else cmdSetUpDocSchedule.Enabled = False End If disableIfReferringDoctor 'Calling a function to disable certain components if the doctor is a "Referring" doctor disableIfPermanentDoctor 'Calling a function to disable the Referring Charges textfield if the Doctor is a "Permanent" doctor End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsDoctorsMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtDoctorID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value

79
txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtHomePhone.Text = .Fields(7).Value txtMobPhone.Text = .Fields(8).Value txtLicenseNo.Text = .Fields(9).Value txtDoctorSpecialization.Text = .Fields(10).Value cboDoctorCategory.Text = .Fields(11).Value txtServiceCharges.Text = .Fields(12).Value txtChannelingCharges.Text = .Fields(13).Value cboAppointmentDuration.Text = .Fields(14).Value txtReferringCharges.Text = .Fields(15).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields 'Here, I am enabling the SetUpDoctor'sVisitingDays Button only if the Doctor Type is Visiting If cboDoctorCategory.Text = "Visiting" Then cmdSetUpDocSchedule.Enabled = True Else cmdSetUpDocSchedule.Enabled = False End If disableIfReferringDoctor 'Calling a function to disable certain components if the doctor is a "Referring" doctor disableIfPermanentDoctor 'Calling a function to disable the Referring Charges textfield if the Doctor is a "Permanent" doctor End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True Call Doctors_Maintenance 'Calling the Doctors_Maintenance Procedure to interact with the recordset With rsDoctorsMaintenance .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtDoctorID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtHomePhone.Text = .Fields(7).Value txtMobPhone.Text = .Fields(8).Value txtLicenseNo.Text = .Fields(9).Value txtDoctorSpecialization.Text = .Fields(10).Value cboDoctorCategory.Text = .Fields(11).Value txtServiceCharges.Text = .Fields(12).Value

80
txtChannelingCharges.Text = .Fields(13).Value cboAppointmentDuration.Text = .Fields(14).Value txtReferringCharges.Text = .Fields(15).Value End With enableAllFields 'Calling a Private Function To Enable All Fields 'Here, I am enabling the SetUpDoctor'sVisitingDays Button only if the Doctor Type is Visiting If cboDoctorCategory.Text = "Visiting" Then cmdSetUpDocSchedule.Enabled = True Else cmdSetUpDocSchedule.Enabled = False End If disableIfReferringDoctor 'Calling a function to disable certain components if the doctor is a "Referring" doctor disableIfPermanentDoctor 'Calling a function to disable the Referring Charges textfield if the Doctor is a "Permanent" doctor End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True dateFlag = True 'Setting the dateFlag variable to True 'Checking if the First Name textfield is empty If txtFirstName.Text = "" Then txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Surname textfield is empty If txtSurname.Text = "" Then txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Gender ComboBox If cboGender.Text = "" Then cboGender.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboGender.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Date Of Birth is valid If dtpDateOfBirth.Value = "4/14/2008" Or dtpDateOfBirth.Value > DateTime.Date Then 'Displaying an error message, asking the user to alter the date accordingly MsgBox "The Date You Have Provided Is Incorrect! Please Check Your Date!", vbCritical, "Incorrect Date" dateFlag = False 'Setting the dateFlag variable to False to indicate invalid data End If 'Checking if the Address textfield is empty If txtAddress.Text = "" Then txtAddress.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAddress.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Phone Number (Home) textfield is empty If txtHomePhone.Text = "" Then txtHomePhone.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data

81
Else txtHomePhone.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the License Number textfield is empty If txtLicenseNo.Text = "E" Then txtLicenseNo.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtLicenseNo.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Doctor Specialization textfield is empty If txtDoctorSpecialization.Text = "" Then txtDoctorSpecialization.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtDoctorSpecialization.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Doctor Category ComboBox If cboDoctorCategory.Text = "" Then cboDoctorCategory.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboDoctorCategory.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'If the user chooses 'Permanent Doctor' from the Doctor Category ComboBox If cboDoctorCategory.ListIndex = 0 Then 'Checking if the Channeling Charges textfield is empty If txtChannelingCharges.Text = "-" Then txtChannelingCharges.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtChannelingCharges.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Service Charges textfield is empty If txtServiceCharges.Text = "-" Then txtServiceCharges.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False Else txtServiceCharges.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking to ensure that the user has made a selection in the Appointment Duration combo box If cboAppointmentDuration.Text = "" Then cboAppointmentDuration.BackColor = &H80000018 'Highlighting the combobox in a different colour Flag = False Else cboAppointmentDuration.BackColor = &H80000004 'Bringing the combobox BackColour back to normal End If End If 'If the user chooses 'Visiting Doctor' from te Doctor Category combo box If cboDoctorCategory.ListIndex = 1 Then If txtServiceCharges.Text = "-" Then txtServiceCharges.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False Else txtServiceCharges.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If

82
'If the user chooses 'Referring Doctor' from the Doctor Category ComboBox If cboDoctorCategory.ListIndex = 2 Then 'Checking if the Referring Charges textfield is empty If txtReferringCharges.Text = "-" Then txtReferringCharges.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtReferringCharges.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure ElseIf dateFlag = False Then textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidDataMsg.Visible = False picInvalidKeypressMsg.Visible = False picInvalidKeyMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtChannelingCharges_GotFocus() If txtChannelingCharges.Text = "-" Then txtChannelingCharges.Text = "" End If End Sub Private Sub txtServiceCharges_GotFocus() If txtServiceCharges.Text = "-" Then txtServiceCharges.Text = "" End If End Sub Private Sub txtChannelingCharges_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 4440 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtServiceCharges_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then

83
ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 3960 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtChannelingCharges_LostFocus() If txtChannelingCharges.Text = "" Then txtChannelingCharges.Text = "-" End If End Sub Private Sub txtServiceCharges_LostFocus() If txtServiceCharges.Text = "" Then txtServiceCharges.Text = "-" End If End Sub Private Sub txtFirstName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 3720 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtHomePhone_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 7200 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtMobPhone_GotFocus() If txtMobPhone.Text = "-" Then txtMobPhone.Text = "" End If End Sub Private Sub txtMobPhone_LostFocus() If txtMobPhone.Text = "" Then txtMobPhone.Text = "-" End If End Sub Private Sub txtMobPhone_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then

84
Else picInvalidKeypressMsg.Top = 7680 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtNICNumber_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtNICNumber.Text = "-" Then txtNICNumber.Text = "" End If End Sub Private Sub txtNICNumber_LostFocus() If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If End Sub Private Sub txtReferringCharges_GotFocus() If txtReferringCharges.Text = "-" Then txtReferringCharges.Text = "" End If End Sub Private Sub txtReferringCharges_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 5400 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtNICNumber_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = Asc("X") Then ElseIf KeyAscii = Asc("x") Then ElseIf KeyAscii = Asc("V") Then ElseIf KeyAscii = Asc("v") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 5640 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtReferringCharges_LostFocus() If txtReferringCharges.Text = "" Then txtReferringCharges.Text = "-" End If End Sub Private Sub txtSurname_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets

85
If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4200 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtServiceCharges_Change() 'Here, I am ensuring that the user cannot type 0 as the first digit If txtServiceCharges.Text = "0" Then MsgBox "Error! The Figure Cannot Begin With Zero!", vbCritical, "Cannot Begin Figure With 0!" txtServiceCharges.Text = "" Exit Sub End If End Sub

FormEditDoctorSchedule:'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Doctor Schedule Maintenance 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 25/04/08 'Date Of Last Modification: 25/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: '---------------------------------------------------------------------------Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdDoctorSearchWizard_Click() frmDoctorSearchWizardSchedule.Show End Sub Private Sub cmdSetUpChannelingTimes_Click() frmSetUpChannelingSchedule.Show End Sub Private Sub Form_Load() End Sub

FormEditGuardianDetails:'------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Guardians Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp

86
'The Name/s Of The Database Table/s Being Accessed: Guardians_Maintenance Table '------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Admission ID to be 'displayed on the Admit Patient form on form load Dim iNumOfInpatients As Integer 'This variable holds the number of records in the table Dim strDisplayAdmissionID As String 'This variable will eventually hold the Admission ID to be autogenerated Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking if the Phone Number (Home) textfield and the Phone Number (Mob) textfield are empty If txtPhoneHome.Text = "-" And txtPhoneMob.Text = "-" Then txtPhoneHome.BackColor = &H80000018 'Highlighting the textfield in a different colour txtPhoneMob.BackColor = &H80000018 'Highlighting the textfield in a different colour MsgBox "Error! Both Phone Number Textfields Cannot Be Empty! At Least One Has To Be Provided!", vbCritical, "Error In Phone Numbers!" Exit Sub Else txtPhoneHome.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtPhoneMob.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If With rsGuardiansMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If strGuardainID = txtGuardianID.Text 'Save the user-entered data into the recordset .Fields(0) = txtGuardianID.Text .Fields(1) = txtPatientID.Text

87
.Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = cboGender.Text .Fields(5) = txtNICNumber.Text .Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text .Fields(8) = txtPhoneMob.Text .Fields(9) = txtOccupation.Text .Fields(10) = txtRelationToPatient.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully! You Will Now Be Taken To Step 3!", vbInformation, "Succesful Save Procedure!" loadPatientAdmission Unload Me frmAdmitPatient.Show Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure End If .Requery 'Requerying the Table End With End If End Sub Private Function loadPatientAdmission() frmAdmitPatient.enableAllFields 'Calling a Private Function To Enable All Fields frmAdmitPatient.clearAllFields 'Calling a Private Function To Clear All Fields frmAdmitPatient.disableAllButtons 'Calling a Private Function To Disable All Command Buttons frmAdmitPatient.txtReferredDoctorID.Text = "-" 'Since this textfield is not compulsory frmAdmitPatient.txtReferredDoctorName.Text = "-" 'Since this textfield is not always compulsory frmAdmitPatient.txtAdditionalNotes.Text = "-" 'Since this textfield is not always compulsory 'Enabling the Save Command Button frmAdmitPatient.cmdSave.Enabled = True 'Disabling the "Launch Inpatient Search Wizard" Button frmAdmitPatient.cmdLaunchInpatientSearch.Enabled = False 'Enabling the Wizard Buttons frmAdmitPatient.cmdReferredDoctorIDWizardButton.Enabled = True frmAdmitPatient.cmdAssignedDoctorWizardButton.Enabled = True frmAdmitPatient.cmdDepartmentIDWizardButton.Enabled = True frmAdmitPatient.cmdWardIDWizardButton.Enabled = True frmAdmitPatient.cmdRoomIDWizardButton.Enabled = True Call Inpatients_Admission 'Calling the Inpatients_Admission Procedure to interact with the recordset 'Generate Admission ID By Utilizing the Inpatients_Admission Table With rsInpatientsAdmission If .RecordCount = 0 Then 'If there are no records in the table strDisplayAdmissionID = "ADM0001" Else 'Calculating the number of records and storing in a variable iNumOfInpatients = .RecordCount iNumOfInpatients = iNumOfInpatients + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Inpatients_Admission Table If iNumOfInpatients < 10 Then strDisplayAdmissionID = "ADM000" & iNumOfInpatients ElseIf iNumOfInpatients < 100 Then

88
strDisplayAdmissionID = "ADM00" & iNumOfInpatients ElseIf iNumOfInpatients < 1000 Then strDisplayAdmissionID = "ADM0" & iNumOfInpatients ElseIf iNumOfInpatients < 10000 Then strDisplayAdmissionID = "ADM" & iNumOfInpatients End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated Admission ID 'into the Admission ID textfield frmAdmitPatient.txtAdmissionID.Text = strDisplayAdmissionID frmAdmitPatient.txtPatientID.Text = strPatientID 'Global Variable frmAdmitPatient.txtGuardianID = strGuardainID 'Global Variable frmAdmitPatient.txtAdmissionDate = DateTime.Date frmAdmitPatient.txtAdmissionTime = DateTime.Time End Function Private Sub cmdStep3_Click() Call Inpatients_Admission With rsInpatientsAdmission .MoveFirst Do While .EOF = False If .Fields(1).Value = txtPatientID.Text Then 'Entering the values in the particular record into the fields on the interface frmAdmitPatient.txtAdmissionID = .Fields(0).Value frmAdmitPatient.txtPatientID.Text = .Fields(1).Value frmAdmitPatient.txtGuardianID.Text = .Fields(2).Value frmAdmitPatient.txtAdmissionDate.Text = .Fields(3).Value frmAdmitPatient.txtAdmissionTime.Text = .Fields(4).Value frmAdmitPatient.cboPatientStatus.Text = .Fields(5).Value frmAdmitPatient.txtReasonForStatus.Text = .Fields(6).Value frmAdmitPatient.txtReferredDoctorID.Text = .Fields(7).Value frmAdmitPatient.txtReferredDoctorName.Text = .Fields(8).Value frmAdmitPatient.txtAssignedDoctorID.Text = .Fields(9).Value frmAdmitPatient.txtAssignedDoctorName.Text = .Fields(10).Value frmAdmitPatient.txtDepartmentID.Text = .Fields(11).Value frmAdmitPatient.txtDepartmentName.Text = .Fields(12).Value frmAdmitPatient.txtWardID.Text = .Fields(13).Value frmAdmitPatient.txtWardNo.Text = .Fields(14).Value frmAdmitPatient.txtRoomID.Text = .Fields(15).Value frmAdmitPatient.txtAdditionalNotes.Text = .Fields(16).Value Exit Do Else .MoveNext End If Loop End With 'Enabling / Diabling the Navigation Buttons as necessary frmAdmitPatient.cmdFirst.Enabled = False frmAdmitPatient.cmdLast.Enabled = True frmAdmitPatient.cmdPrevious.Enabled = False frmAdmitPatient.cmdNext.Enabled = True 'Enabling the Update Button frmAdmitPatient.cmdUpdate.Enabled = True 'Enabling the Wizard Buttons frmAdmitPatient.cmdReferredDoctorIDWizardButton.Enabled = True frmAdmitPatient.cmdAssignedDoctorWizardButton.Enabled = True frmAdmitPatient.cmdDepartmentIDWizardButton.Enabled = True

89
frmAdmitPatient.cmdWardIDWizardButton.Enabled = True frmAdmitPatient.cmdRoomIDWizardButton.Enabled = True 'Enabling the "Step" Buttons frmAdmitPatient.cmdStep1.Enabled = True frmAdmitPatient.cmdStep2.Enabled = True 'frmAdmitPatient.enableAllFields frmAdmitPatient.enableAllFields Unload Me frmAdmitPatient.Show End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking if the Phone Number (Home) textfield and the Phone Number (Mob) textfield are empty If txtPhoneHome.Text = "-" And txtPhoneMob.Text = "-" Then txtPhoneHome.BackColor = &H80000018 'Highlighting the textfield in a different colour txtPhoneMob.BackColor = &H80000018 'Highlighting the textfield in a different colour MsgBox "Error! Both Phone Number Textfields Cannot Be Empty! At Least One Has To Be Provided!", vbCritical, "Error In Phone Numbers!" Exit Sub Else txtPhoneHome.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtPhoneMob.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If With rsGuardiansMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtGuardianID.Text .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = cboGender.Text .Fields(5) = txtNICNumber.Text

90
.Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text .Fields(8) = txtPhoneMob.Text .Fields(9) = txtOccupation.Text .Fields(10) = txtRelationToPatient.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdGuardiansInfo_Click() 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep3.Enabled = True With rsGuardiansMaintenance 'Entering the values in the particular record into the fields on the interface txtGuardianID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value cboGender.Text = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtOccupation.Text = .Fields(9).Value txtRelationToPatient.Text = .Fields(10).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub Form_Load() Call Connection 'Calling the Connection Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Close button cmdClose.Enabled = True 'Enabling the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True dgrdGuardiansInfo.Enabled = True

91
End Sub Public Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Public Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next 'Disabling the Step 2 Button cmdStep2.Enabled = False End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next 'The following lines will set the normal display values of the Gender 'ComboBox. cboGender.Text = "----------SELECT-----------" End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button

92
cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep3.Enabled = True Call Guardians_Maintenance 'Calling the Guardians_Maintenance Procedure to interact with the recordset With rsGuardiansMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtGuardianID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value cboGender.Text = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtOccupation.Text = .Fields(9).Value txtRelationToPatient.Text = .Fields(10).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsGuardiansMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtGuardianID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value cboGender.Text = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtOccupation.Text = .Fields(9).Value txtRelationToPatient.Text = .Fields(10).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep3.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsGuardiansMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then

93
MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtGuardianID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value cboGender.Text = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtOccupation.Text = .Fields(9).Value txtRelationToPatient.Text = .Fields(10).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep3.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the "Step" Buttons cmdStep1.Enabled = True cmdStep3.Enabled = True Call Guardians_Maintenance 'Calling the Guardians_Maintenance Procedure to interact with the recordset With rsGuardiansMaintenance .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtGuardianID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value cboGender.Text = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtOccupation.Text = .Fields(9).Value txtRelationToPatient.Text = .Fields(10).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True

94
'Checking if the First Name textfield is empty If txtFirstName.Text = "" Then txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Surname textfield is empty If txtSurname.Text = "" Then txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Gender ComboBox If cboGender.Text = "" Then cboGender.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboGender.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Address textfield is empty If txtAddress.Text = "" Then txtAddress.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAddress.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Patient Occupation textfield is empty If txtOccupation.Text = "" Then txtOccupation.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtOccupation.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Relation To Patient textfield is empty If txtRelationToPatient.Text = "" Then txtRelationToPatient.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtRelationToPatient.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidDataMsg.Visible = False picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False

95
Else i=i+1 End If End Sub Private Sub txtPhoneHome_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtPhoneHome.Text = "-" Then txtPhoneHome.Text = "" End If End Sub Private Sub txtPhoneHome_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If End Sub Private Sub txtPhoneMob_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtPhoneMob.Text = "-" Then txtPhoneMob.Text = "" End If End Sub Private Sub txtPhoneMob_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If End Sub 'This procedure will ensure that the textfield is empty when the user types in it. Private Sub txtNICNumber_GotFocus() If txtNICNumber.Text = "-" Then txtNICNumber.Text = "" End If End Sub Private Sub txtNICNumber_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If End Sub Private Sub txtNICNumber_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = Asc("X") Then ElseIf KeyAscii = Asc("x") Then ElseIf KeyAscii = Asc("V") Then ElseIf KeyAscii = Asc("v") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 5520 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPhoneHome_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then

96
ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 6960 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPhoneMob_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 7440 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtFirstName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4080 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSurname_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4560 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtOccupation_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 7920 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0

97
End If End Sub Private Sub txtSearch_Change() If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsGuardiansMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[GuardianID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Guardians_Maintenance Set dgrdGuardiansInfo.DataSource = rsGuardiansMaintenance End If End Sub Private Sub cmdStep1_Click() Call Inpatients_Maintenance With rsInpatientMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = txtPatientID.Text Then 'Entering the values in the particular record into the fields on the interface frmInpatientsMaintenance.txtPatientID.Text = .Fields(0).Value frmInpatientsMaintenance.txtFirstName.Text = .Fields(1).Value frmInpatientsMaintenance.txtSurname.Text = .Fields(2).Value frmInpatientsMaintenance.cboGender.Text = .Fields(3).Value frmInpatientsMaintenance.dtpDateOfBirth.Value = .Fields(4).Value frmInpatientsMaintenance.txtNICNumber.Text = .Fields(5).Value frmInpatientsMaintenance.txtAddress.Text = .Fields(6).Value frmInpatientsMaintenance.txtPhoneHome.Text = .Fields(7).Value frmInpatientsMaintenance.txtPhoneMob.Text = .Fields(8).Value frmInpatientsMaintenance.txtPatientOccupation.Text = .Fields(9).Value frmInpatientsMaintenance.cboCivilStatus.Text = .Fields(10).Value frmInpatientsMaintenance.cboAccountType.Text = .Fields(11).Value frmInpatientsMaintenance.txtCompanyID.Text = .Fields(12).Value frmInpatientsMaintenance.txtCompanyName.Text = .Fields(13).Value Exit Do Else .MoveNext End If Loop End With 'Enabling / Diabling the Navigation Buttons as necessary frmInpatientsMaintenance.cmdFirst.Enabled = False frmInpatientsMaintenance.cmdLast.Enabled = True

98
frmInpatientsMaintenance.cmdPrevious.Enabled = False frmInpatientsMaintenance.cmdNext.Enabled = True 'Enabling the Update Button and the Delete Button frmInpatientsMaintenance.cmdUpdate.Enabled = True frmInpatientsMaintenance.cmdDelete.Enabled = True 'Enabling the Wizard Buttons frmInpatientsMaintenance.cmdCompanySearchWizard.Enabled = True 'Enabling the "Step" Buttons frmInpatientsMaintenance.cmdStep2.Enabled = True frmInpatientsMaintenance.enableAllFields Unload Me frmInpatientsMaintenance.Show End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormEditHospitalServices:'----------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Hospital Services Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Services_Maintenance Table '----------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Service ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Service ID to be autogenerated Private Sub cmdAddNew_Click() enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Disabling the Search Frame lblCriteria.Enabled = False cboSearchType.Enabled = False lblSearchFor.Enabled = False txtSearch.Enabled = False 'Disabling the DataGrid dgrdServicesInformation.Enabled = False Call Services_Maintenance 'Calling the Services_Maintenance Procedure to interact with the recordset 'Generate Service ID By Utilizing the Services_Maintenance Table

99
With rsServicesMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "SER0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Services_Maintenance Table If iNumOfRecords < 10 Then strCode = "SER000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "SER00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "SER0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "SER" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With enableAllFields 'Calling a Private Function To Enable All Fields 'Disabling the Search Frame cboSearchType.Enabled = False txtSearch.Enabled = False 'The following line of code will enter the autogenerated Service ID 'into the Service ID textfield txtServiceID.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it. 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsServicesMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtServiceID.Text .Fields(1) = txtServiceName.Text .Fields(2) = txtAmount.Text .Fields(3) = txtAverageLengthOfStay.Text .Fields(4) = txtAdditionalNotes.Text .Update .Requery 'Display Success Message

100
MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdServicesInformation_Click() 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsServicesMaintenance 'Entering the values in the particular record into the fields on the interface txtServiceID.Text = .Fields(0).Value txtServiceName.Text = .Fields(1).Value txtAmount.Text = .Fields(2).Value txtAverageLengthOfStay.Text = .Fields(3).Value txtAdditionalNotes.Text = .Fields(4).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Services_Maintenance 'Calling the Services_Maintenance Procedure to interact with the recordset disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchFor.Enabled = True txtSearch.Enabled = True 'Enabling the DataGrid dgrdServicesInformation.Enabled = True Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then

101
eachField.Enabled = False End If Next End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsServicesMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtServiceID.Text = .Fields(0).Value txtServiceName.Text = .Fields(1).Value txtAmount.Text = .Fields(2).Value txtAverageLengthOfStay.Text = .Fields(3).Value txtAdditionalNotes.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Clearing the Search Textfield to Enable All Records To Be

102
'Displayed On The Grid txtSearch.Text = "" With rsServicesMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtServiceID.Text = .Fields(0).Value txtServiceName.Text = .Fields(1).Value txtAmount.Text = .Fields(2).Value txtAverageLengthOfStay.Text = .Fields(3).Value txtAdditionalNotes.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsServicesMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtServiceID.Text = .Fields(0).Value txtServiceName.Text = .Fields(1).Value txtAmount.Text = .Fields(2).Value txtAverageLengthOfStay.Text = .Fields(3).Value txtAdditionalNotes.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsServicesMaintenance

103
.MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtServiceID.Text = .Fields(0).Value txtServiceName.Text = .Fields(1).Value txtAmount.Text = .Fields(2).Value txtAverageLengthOfStay.Text = .Fields(3).Value txtAdditionalNotes.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub

Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidKeypressMsg.Visible = False picInvalidDataMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsServicesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[ServiceID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[ServiceName] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False cmdDelete.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Services_Maintenance Set dgrdServicesInformation.DataSource = rsServicesMaintenance End If End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsServicesMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes

104
'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtServiceID.Text .Fields(1) = txtServiceName.Text .Fields(2) = txtAmount.Text .Fields(3) = txtAverageLengthOfStay.Text .Fields(4) = txtAdditionalNotes.Text .Update .Requery 'Requerying the Table 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Service Name textfield is empty If txtServiceName.Text = "" Then txtServiceName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtServiceName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Amount textfield is empty If txtAmount.Text = "" Then txtAmount.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAmount.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Average Duration textfield is empty If txtAverageLengthOfStay.Text = "" Then txtAverageLengthOfStay.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAverageLengthOfStay.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields"

105
textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtServiceID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsServicesMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Service ID " & txtServiceID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub txtServiceName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4200 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtAmount_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 4800 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

106 FormEditMedicalTreatment:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Medical Treatments Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Medical_Treatments Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Medical Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdMedicineSearchWizard_Click() frmMedicinesSearchMeds.Show End Sub Private Sub cmdPatientSearchWizard_Click() frmInpatientsWizardMedicals.Show End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsMedicalTreatments 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'Save the user-entered data into the recordset .Fields(0) = txtTreatmentID.Text .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtMedicineID.Text .Fields(5) = txtMedicineName.Text .Fields(6) = txtDateOfIssue.Text .Fields(7) = txtUnitPrice.Text .Fields(8) = txtQty.Text .Fields(9) = txtTotal.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure End If .Requery 'Requerying the Table

107
End With End If End Sub Private Sub dgrdGuardiansInfo_Click() 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsMedicalTreatments 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub dgrdMedTreatmentInfo_Click() 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True With rsMedicalTreatments 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Medical_Treatments 'Calling the Medical_Treatments Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True

108
cmdLast.Enabled = True 'Enabling the Add New Button & Close Button cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchText.Enabled = True txtSearch.Enabled = True dgrdMedTreatmentInfo.Enabled = True Set dgrdMedTreatmentInfo.DataSource = rsMedicalTreatments 'Setting the DataSource of the DataGrid End Sub Public Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Public Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary

109
cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True With rsMedicalTreatments .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsMedicalTreatments .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsMedicalTreatments

110
.MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True With rsMedicalTreatments .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty

111
If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Medicine ID textfield is empty If txtMedicineID.Text = "" Then txtMedicineID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtMedicineName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtUnitPrice.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtMedicineID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtMedicineName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtUnitPrice.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Total textfield has been filled in If txtTotal.Text = "0" Then txtQty.BackColor = &H80000018 'Highlighting the textfield in a different colour txtTotal.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtQty.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtTotal.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub txtQty_Change() If txtQty.Text = "0" Then MsgBox "Error! The Figure Cannot Begin With Zero!", vbCritical, "Cannot Begin Figure With 0!" txtQty.Text = "" Exit Sub Else txtTotal.Text = Val(txtQty.Text) * Val(txtUnitPrice.Text) End If End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub

112
Private Sub txtQty_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 7200 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSearch_Change() If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsMedicalTreatments 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[TreatmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Medical_Treatments Set dgrdMedTreatmentInfo.DataSource = rsMedicalTreatments End If End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormEditMedicines:'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Medicines Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Doctors_Maintenance Table '----------------------------------------------------------------------------

113
Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Medicine ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Medicine ID to be autogenerated Private Sub cmdAddNew_Click() enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Disabling the Search Frame lblCriteria.Enabled = False cboSearchType.Enabled = False lblSearchFor.Enabled = False txtSearch.Enabled = False 'Disabling the DataGrid dgrdMedicineInfo.Enabled = False Call Medicines_Maintenance 'Calling the Medicines_Maintenance Procedure to interact with the recordset 'Generate Medicine ID By Utilizing the Medicines_Maintenance Table With rsMedicinesMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "MED0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Medicines_Maintenance Table If iNumOfRecords < 10 Then strCode = "MED000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "MED00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "MED0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "MED" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With enableAllFields 'Calling a Private Function To Enable All Fields 'Disabling the Search Frame cboSearchType.Enabled = False txtSearch.Enabled = False 'The following line of code will enter the autogenerated Medicine ID 'into the Medicine ID textfield txtMedicineID.Text = strCode End Sub Private Sub cmdClose_Click()

114
If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it. 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The Medicine Name is not Greater than 25 Characters in Length If Len(txtMedicineName.Text) > 25 Then MsgBox "Error! The Medicine Name Textfield Cannot Consist Of More Than 25 Characters!", vbCritical, "Error In Medicine Name!" Exit Sub End If With rsMedicinesMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtMedicineID.Text .Fields(1) = txtMedicineName.Text .Fields(2) = cboDosageForm.Text .Fields(3) = txtUnitPrice.Text .Fields(4) = txtUnitsInStock.Text .Fields(5) = txtReOrderLevel.Text .Fields(6) = txtAdditionalNotes.Text .Update .Requery 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_ Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdMedicineInfo_Click() 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsMedicinesMaintenance

115
'Entering the values in the particular record into the fields on the interface txtMedicineID.Text = .Fields(0).Value txtMedicineName.Text = .Fields(1).Value cboDosageForm.Text = .Fields(2).Value txtUnitPrice.Text = .Fields(3).Value txtUnitsInStock.Text = .Fields(4).Value txtReOrderLevel.Text = .Fields(5).Value txtAdditionalNotes.Text = .Fields(6).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Medicines_Maintenance 'Calling the Medicines_Maintenance Procedure to interact with the recordset disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchFor.Enabled = True txtSearch.Enabled = True 'Enabling the DataGrid dgrdMedicineInfo.Enabled = True Set dgrdMedicineInfo.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface

116
On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next 'The following lines will set the normal display values of the Dosage Form ComboBox cboDosageForm.Text = "" End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsMedicinesMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtMedicineID.Text = .Fields(0).Value txtMedicineName.Text = .Fields(1).Value cboDosageForm.Text = .Fields(2).Value txtUnitPrice.Text = .Fields(3).Value txtUnitsInStock.Text = .Fields(4).Value txtReOrderLevel.Text = .Fields(5).Value txtAdditionalNotes.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsMedicinesMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtMedicineID.Text = .Fields(0).Value txtMedicineName.Text = .Fields(1).Value cboDosageForm.Text = .Fields(2).Value txtUnitPrice.Text = .Fields(3).Value txtUnitsInStock.Text = .Fields(4).Value txtReOrderLevel.Text = .Fields(5).Value txtAdditionalNotes.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button

117
cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsMedicinesMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtMedicineID.Text = .Fields(0).Value txtMedicineName.Text = .Fields(1).Value cboDosageForm.Text = .Fields(2).Value txtUnitPrice.Text = .Fields(3).Value txtUnitsInStock.Text = .Fields(4).Value txtReOrderLevel.Text = .Fields(5).Value txtAdditionalNotes.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsMedicinesMaintenance .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtMedicineID.Text = .Fields(0).Value txtMedicineName.Text = .Fields(1).Value cboDosageForm.Text = .Fields(2).Value txtUnitPrice.Text = .Fields(3).Value txtUnitsInStock.Text = .Fields(4).Value txtReOrderLevel.Text = .Fields(5).Value txtAdditionalNotes.Text = .Fields(6).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub

118

Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidKeypressMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsMedicinesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[MedicineID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[MedicineName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[DosageForm] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False cmdDelete.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Medicines_Maintenance Set dgrdMedicineInfo.DataSource = rsMedicinesMaintenance End If End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The Medicine Name is not Greater than 25 Characters in Length If Len(txtMedicineName.Text) > 25 Then MsgBox "Error! The Medicine Name Textfield Cannot Consist Of More Than 25 Characters!", vbCritical, "Error In Medicine Name!" Exit Sub End If With rsMedicinesMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtAdditionalNotes.Text = "" Then txtAdditionalNotes.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtMedicineID.Text .Fields(1) = txtMedicineName.Text

119
.Fields(2) = cboDosageForm.Text .Fields(3) = txtUnitPrice.Text .Fields(4) = txtUnitsInStock.Text .Fields(5) = txtReOrderLevel.Text .Fields(6) = txtAdditionalNotes.Text .Update .Requery 'Requerying the Table 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Medicine Name textfield is empty If txtMedicineName.Text = "" Then txtMedicineName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtMedicineName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Dosage Form ComboBox If cboDosageForm.Text = "" Then cboDosageForm.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboDosageForm.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Unit Price textfield is empty If txtUnitPrice.Text = "" Then txtUnitPrice.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtUnitPrice.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Units In Stock textfield is empty If txtUnitsInStock.Text = "" Then txtUnitsInStock.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtUnitsInStock.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Re-order Level textfield is empty If txtReOrderLevel.Text = "" Then txtReOrderLevel.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtReOrderLevel.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If

120

'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtMedicineID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsMedicinesMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Medicine ID " & txtMedicineID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub txtUnitPrice_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 5040 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtUnitsInStock_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 5520 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True

121
KeyAscii = 0 End If End Sub Private Sub txtReOrderLevel_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only Digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 6000 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

FormEditOutPatient:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Outpatients Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Outpatients_Maintenance Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following Boolean Variable will determine if the Doctor's Date Of Birth 'entered by the user is valid Dim dateFlag As Boolean 'The following variables will be used to autogenerate the Doctor ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Doctor ID to be autogenerated Private Sub cboAccountType_Click() 'This function will manipulate other controls according to the type of account 'The following block of code will disable the Company related fields if the 'Patient Account Type is "Individual" If cboAccountType.ListIndex = 0 Then lblCompanyID.Enabled = True txtCompanyID.Enabled = True lblCompanyName.Enabled = True txtCompanyName.Enabled = True cmdCompanySearchWizard.Enabled = True Else lblCompanyID.Enabled = False txtCompanyID.Enabled = False lblCompanyName.Enabled = False txtCompanyName.Enabled = False cmdCompanySearchWizard.Enabled = False End If End Sub

122
Private Sub cmdAddNew_Click() 'This function adds a new recordset into the database enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons txtNICNumber.Text = "-" 'Since this textfield is not compulsory txtPhoneMob.Text = "-" 'Since this textfield is not compulsory txtPhoneHome.Text = "-" 'Since this textfield is not always compulsory 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Enabling the Doctor Search Wizard Button cmdDoctorSearchWizard.Enabled = True 'Disabling the Company Related Records lblCompanyID.Enabled = False txtCompanyID.Enabled = False lblCompanyName.Enabled = False txtCompanyName.Enabled = False cmdCompanySearchWizard.Enabled = False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset 'Generate Patient ID By Utilizing the Outpatients_Maintenance Table With rsOutpatientsMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "OUT0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Outpatients_Maintenance Table If iNumOfRecords < 10 Then strCode = "OUT000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "OUT00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "OUT0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "OUT" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated Patient ID 'into the Patient ID textfield txtPatientID.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdCompanySearchWizard_Click() frmCompaniesSearchWizard.Show End Sub Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection

123
If txtPatientID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsOutpatientsMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Patient ID " & txtPatientID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdDoctorSearchWizard_Click() frmAssignedDocWizard.Show End Sub Private Sub cmdLaunchOutpatientSearch_Click() enableAllFields 'Calling a Private Function To Enable All Fields enableAllButtons 'Calling a Private Function To Enable All Command Buttons cmdSave.Enabled = False 'Disabling the Save Command Button frmOutpatientsSearchWizard.Show 'Displays the Outpatient Search Wizard End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking if the Phone Number (Home) textfield and the Phone Number (Mob) textfield are empty If txtPhoneHome.Text = "-" And txtPhoneMob.Text = "-" Then txtPhoneHome.BackColor = &H80000018 'Highlighting the textfield in a different colour txtPhoneMob.BackColor = &H80000018 'Highlighting the textfield in a different colour MsgBox "Error! Both Phone Number Textfields Cannot Be Empty! At Least One Has To Be Provided!", vbCritical, "Error In Phone Numbers!" Exit Sub Else txtPhoneHome.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtPhoneMob.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length

124
If txtPhoneHome.Text <> "-" Then If Len(txtPhoneHome.Text) > 15 Then MsgBox "Error! The Phone No (Home) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Home)!" txtPhoneHome.BackColor = &H80000018 Exit Sub Else txtPhoneHome.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneMob.Text <> "-" Then If Len(txtPhoneMob.Text) > 15 Then MsgBox "Error! The Phone No (Mob) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Mob)!" txtPhoneMob.BackColor = &H80000018 Exit Sub Else txtPhoneMob.BackColor = &H80000004 End If End If 'Validation To Ensure That The Patient Occupation is not Greater than 30 Characters in Length If Len(txtPatientOccupation.Text) > 30 Then MsgBox "Error! The Patient Occupation Textfield Cannot Consist Of More Than 30 Characters", vbCritical, "Error In Patient Occupation!" txtPatientOccupation.BackColor = &H80000018 Exit Sub Else txtPatientOccupation.BackColor = &H80000004 End If With rsOutpatientsMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If If txtCompanyID.Text = "" Then txtCompanyID.Text = "-" End If If txtCompanyName.Text = "" Then txtCompanyName.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtPatientID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtSurname.Text .Fields(3) = cboGender.Text .Fields(4) = dtpDateOfBirth.Value .Fields(5) = txtNICNumber.Text

125
.Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text .Fields(8) = txtPhoneMob.Text .Fields(9) = txtPatientOccupation.Text .Fields(10) = cboCivilStatus.Text .Fields(11) = cboAccountType.Text .Fields(12) = txtCompanyID.Text .Fields(13) = txtCompanyName.Text .Fields(14) = txtAssignedDoctorID.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking if the Phone Number (Home) textfield and the Phone Number (Mob) textfield are empty If txtPhoneHome.Text = "-" And txtPhoneMob.Text = "-" Then txtPhoneHome.BackColor = &H80000018 'Highlighting the textfield in a different colour txtPhoneMob.BackColor = &H80000018 'Highlighting the textfield in a different colour MsgBox "Error! Both Phone Number Textfields Cannot Be Empty! At Least One Has To Be Provided!", vbCritical, "Error In Phone Numbers!" Exit Sub Else txtPhoneHome.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtPhoneMob.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneHome.Text <> "-" Then If Len(txtPhoneHome.Text) > 15 Then MsgBox "Error! The Phone No (Home) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Home)!" txtPhoneHome.BackColor = &H80000018 Exit Sub Else

126
txtPhoneHome.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneMob.Text <> "-" Then If Len(txtPhoneMob.Text) > 15 Then MsgBox "Error! The Phone No (Mob) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Mob)!" txtPhoneMob.BackColor = &H80000018 Exit Sub Else txtPhoneMob.BackColor = &H80000004 End If End If 'Validation To Ensure That The Patient Occupation is not Greater than 30 Characters in Length If Len(txtPatientOccupation.Text) > 30 Then MsgBox "Error! The Patient Occupation Textfield Cannot Consist Of More Than 30 Characters", vbCritical, "Error In Patient Occupation!" txtPatientOccupation.BackColor = &H80000018 Exit Sub Else txtPatientOccupation.BackColor = &H80000004 End If With rsOutpatientsMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If If txtCompanyID.Text = "" Then txtCompanyID.Text = "-" End If If txtCompanyName.Text = "" Then txtCompanyName.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtPatientID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtSurname.Text .Fields(3) = cboGender.Text .Fields(4) = dtpDateOfBirth.Value .Fields(5) = txtNICNumber.Text .Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text .Fields(8) = txtPhoneMob.Text .Fields(9) = txtPatientOccupation.Text .Fields(10) = cboCivilStatus.Text .Fields(11) = cboAccountType.Text .Fields(12) = txtCompanyID.Text

127
.Fields(13) = txtCompanyName.Text .Fields(14) = txtAssignedDoctorID.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub dtpDateOfBirth_CloseUp() dtpDateOfBirth.MaxDate = DateTime.Date End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the LaunchOutpatientSearch Wizard Button cmdLaunchOutpatientSearch.Enabled = True End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next dtpDateOfBirth.Enabled = False 'Disabling the Date Of Birth Date Time Picker End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next dtpDateOfBirth.Enabled = True 'Enabling the Date Of Birth Date Time Picker End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next

128
For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next 'The following lines will set the normal display values of the Gender 'ComboBox, Doctor Category ComboBox and the Date Of Birth Date Time Picker cboGender.Text = "----------SELECT-----------" cboCivilStatus.Text = "----------SELECT-----------" cboAccountType.Text = "----------SELECT-----------" dtpDateOfBirth.Value = "4/14/2008" End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Company Search Wizard Button cmdCompanySearchWizard.Enabled = True 'Enabling the Doctor Ssearch Wizard Button cmdDoctorSearchWizard.Enabled = True Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset With rsOutpatientsMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value

129
txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value txtAssignedDoctorID.Text = .Fields(14).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsOutpatientsMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value txtAssignedDoctorID.Text = .Fields(14).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True 'Enabling the Doctor Ssearch Wizard Button cmdDoctorSearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsOutpatientsMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value

130
cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value txtAssignedDoctorID.Text = .Fields(14).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True 'Enabling the Doctor Ssearch Wizard Button cmdDoctorSearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True 'Enabling the Doctor Ssearch Wizard Button cmdDoctorSearchWizard.Enabled = True Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset With rsOutpatientsMaintenance .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value txtAssignedDoctorID.Text = .Fields(14).Value

131
End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub

Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True dateFlag = True 'Setting the dateFlag variable to True 'Checking if the First Name textfield is empty If txtFirstName.Text = "" Then txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Surname textfield is empty If txtSurname.Text = "" Then txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Gender ComboBox If cboGender.Text = "" Then cboGender.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboGender.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Date Of Birth is valid If dtpDateOfBirth.Value = "4/14/2008" Then 'Displaying an error message, asking the user to alter the date accordingly MsgBox "The Date You Have Provided Is Incorrect! Please Check Your Date!", vbCritical, "Incorrect Date" dateFlag = False 'Setting the dateFlag variable to False to indicate invalid data End If 'Checking if the Address textfield is empty If txtAddress.Text = "" Then txtAddress.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAddress.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Patient Occupation textfield is empty If txtPatientOccupation.Text = "" Then txtPatientOccupation.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientOccupation.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If

132
'Checking if the user has made a selection in the Civil Status ComboBox If cboCivilStatus.Text = "" Then cboCivilStatus.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboCivilStatus.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the user has made a selection in the Account Type ComboBox If cboAccountType.Text = "" Then cboAccountType.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboAccountType.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Assigned Doctor ID textfield is empty If txtAssignedDoctorID.Text = "" Then txtAssignedDoctorID.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAssignedDoctorID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'If the user chooses 'Corporate' from the Account Type ComboBox If cboAccountType.ListIndex = 0 Then 'Checking if the Channeling Charges textfield is empty If txtCompanyID.Text = "" Then txtCompanyID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtCompanyName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtCompanyID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtCompanyName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure ElseIf dateFlag = False Then textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidDataMsg.Visible = False picInvalidKeypressMsg.Visible = False picInvalidKeyMsg.Visible = False picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If

133
End Sub Private Sub txtPhoneHome_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtPhoneHome.Text = "-" Then txtPhoneHome.Text = "" End If End Sub Private Sub txtPhoneHome_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If End Sub Private Sub txtPhoneMob_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtPhoneMob.Text = "-" Then txtPhoneMob.Text = "" End If End Sub Private Sub txtPhoneMob_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If End Sub 'This procedure will ensure that the textfield is empty when the user types in it. Private Sub txtNICNumber_GotFocus() If txtNICNumber.Text = "-" Then txtNICNumber.Text = "" End If End Sub Private Sub txtNICNumber_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If End Sub Private Sub txtPhoneHome_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 3360 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPhoneMob_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 3840 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0

134
End If End Sub Private Sub txtNICNumber_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = Asc("X") Then ElseIf KeyAscii = Asc("x") Then ElseIf KeyAscii = Asc("V") Then ElseIf KeyAscii = Asc("v") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 5760 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtFirstName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 3840 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSurname_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4320 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPatientOccupation_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 4320 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

FormEditPatientDetails:-

135
'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Inpatients Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 24/04/08 'Date Of Last Modification: 24/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Inpatient_Maintenance Table '---------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following Boolean Variable will determine if the Doctor's Date Of Birth 'entered by the user is valid Dim dateFlag As Boolean 'The following variables will be used to autogenerate the Doctor ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Doctor ID to be autogenerated 'The following variables will be used to autogenerate the Guardian ID to be 'displayed on the Guardians Maintenance form on form load Dim iNumOfGuardians As Integer 'This variable holds the number of records in the table Dim strDisplayID As String 'This variable will eventually hold the Guardian ID to be autogenerated Private Sub cboAccountType_Click() 'This function will manipulate other controls according to the type of account 'The following block of code will disable the Company related fields if the 'Patient Account Type is "Individual" If cboAccountType.ListIndex = 0 Then lblCompanyID.Enabled = True txtCompanyID.Enabled = True lblCompanyName.Enabled = True txtCompanyName.Enabled = True cmdCompanySearchWizard.Enabled = True Else lblCompanyID.Enabled = False txtCompanyID.Enabled = False lblCompanyName.Enabled = False txtCompanyName.Enabled = False cmdCompanySearchWizard.Enabled = False End If End Sub Private Sub cmdAddNew_Click() 'This function adds a new recordset into the database enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons txtNICNumber.Text = "-" 'Since this textfield is not compulsory txtPhoneMob.Text = "-" 'Since this textfield is not compulsory txtPhoneHome.Text = "-" 'Since this textfield is not always compulsory 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True

136
'Disabling the Company Related Records lblCompanyID.Enabled = False txtCompanyID.Enabled = False lblCompanyName.Enabled = False txtCompanyName.Enabled = False cmdCompanySearchWizard.Enabled = False Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset 'Generate Patient ID By Utilizing the Inpatients_Maintenance Table With rsInpatientMaintenance If .RecordCount = 0 Then 'If there are no records in the table strCode = "INP0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Inpatients_Maintenance Table If iNumOfRecords < 10 Then strCode = "INP000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "INP00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "INP0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "INP" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated Patient ID 'into the Patient ID textfield txtPatientID.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdCompanySearchWizard_Click() frmCompanySearchWizard.Show End Sub Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtPatientID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!" Else With rsInpatientMaintenance 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete Patient ID " & txtPatientID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields

137
Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub cmdLaunchInpatientSearch_Click() 'This function is fired when the Launch Inpatient Search Wizard Command Button is Clicked. It opens up the Inpatient Search Wizard enableAllFields 'Calling a Private Function To Enable All Fields enableAllButtons 'Calling a Private Function To Enable All Command Buttons cmdSave.Enabled = False 'Disabling the Save Command Button frmInpatientSearchWizard.Show 'Displays the Doctor Search Wizard 'Disabling the "Step" Buttons cmdStep1.Enabled = False cmdStep3.Enabled = False End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking if the Phone Number (Home) textfield and the Phone Number (Mob) textfield are empty If txtPhoneHome.Text = "-" And txtPhoneMob.Text = "-" Then txtPhoneHome.BackColor = &H80000018 'Highlighting the textfield in a different colour txtPhoneMob.BackColor = &H80000018 'Highlighting the textfield in a different colour MsgBox "Error! Both Phone Number Textfields Cannot Be Empty! At Least One Has To Be Provided!", vbCritical, "Error In Phone Numbers!" Exit Sub Else txtPhoneHome.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtPhoneMob.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneHome.Text <> "-" Then If Len(txtPhoneHome.Text) > 15 Then MsgBox "Error! The Phone No (Home) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Home)!" txtPhoneHome.BackColor = &H80000018 Exit Sub Else txtPhoneHome.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneMob.Text <> "-" Then If Len(txtPhoneMob.Text) > 15 Then

138
MsgBox "Error! The Phone No (Mob) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Mob)!" txtPhoneMob.BackColor = &H80000018 Exit Sub Else txtPhoneMob.BackColor = &H80000004 End If End If 'Validation To Ensure That The Patient Occupation is not Greater than 30 Characters in Length If Len(txtPatientOccupation.Text) > 30 Then MsgBox "Error! The Patient Occupation Textfield Cannot Consist Of More Than 30 Characters", vbCritical, "Error In Patient Occupation!" txtPatientOccupation.BackColor = &H80000018 Exit Sub Else txtPatientOccupation.BackColor = &H80000004 End If With rsInpatientMaintenance 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If If txtCompanyID.Text = "" Then txtCompanyID.Text = "-" End If If txtCompanyName.Text = "" Then txtCompanyName.Text = "-" End If strPatientID = txtPatientID.Text 'Save the user-entered data into the recordset .Fields(0) = txtPatientID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtSurname.Text .Fields(3) = cboGender.Text .Fields(4) = dtpDateOfBirth.Value .Fields(5) = txtNICNumber.Text .Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text .Fields(8) = txtPhoneMob.Text .Fields(9) = txtPatientOccupation.Text .Fields(10) = cboCivilStatus.Text .Fields(11) = cboAccountType.Text .Fields(12) = txtCompanyID.Text .Fields(13) = txtCompanyName.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully! You Will Now Be Taken To Step 2!", vbInformation, "Succesful Save Procedure!"

139

loadGuardiansMaintenance 'Calling a public function to prepare the Guardians Maintenance form Unload Me frmGuardiansMaintenance.Show Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Function loadGuardiansMaintenance() frmGuardiansMaintenance.enableAllFields 'Calling a Private Function To Enable All Fields frmGuardiansMaintenance.clearAllFields 'Calling a Private Function To Clear All Fields frmGuardiansMaintenance.disableAllButtons 'Calling a Private Function To Disable All Command Buttons frmGuardiansMaintenance.txtNICNumber.Text = "-" 'Since this textfield is not compulsory frmGuardiansMaintenance.txtPhoneMob.Text = "-" 'Since this textfield is not always compulsory frmGuardiansMaintenance.txtPhoneHome.Text = "-" 'Since this textfield is not always compulsory 'Enabling the Save Command Button frmGuardiansMaintenance.cmdSave.Enabled = True 'Disbaling the Search Frame frmGuardiansMaintenance.lblCriteria.Enabled = False frmGuardiansMaintenance.cboSearchType.Enabled = False frmGuardiansMaintenance.lblSearchText.Enabled = False frmGuardiansMaintenance.txtSearch.Enabled = False Call Guardians_Maintenance 'Calling the Guardians_Maintenance Procedure to interact with the recordset 'Generate Guardian ID By Utilizing the Guardians_Maintenance Table With rsGuardiansMaintenance If .RecordCount = 0 Then 'If there are no records in the table

strDisplayID = "GRD0001" Else 'Calculating the number of records and storing in a variable iNumOfGuardians = .RecordCount iNumOfGuardians = iNumOfGuardians + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Guardians_Maintenance Table If iNumOfGuardians < 10 Then strDisplayID = "GRD000" & iNumOfGuardians ElseIf iNumOfGuardians < 100 Then strDisplayID = "GRD00" & iNumOfGuardians ElseIf iNumOfGuardians < 1000 Then strDisplayID = "GRD0" & iNumOfGuardians ElseIf iNumOfGuardians < 10000 Then strDisplayID = "GRD" & iNumOfGuardians End If End If

140
.Requery .AddNew End With 'The following line of code will enter the autogenerated Guardian ID 'into the Guardian ID textfield frmGuardiansMaintenance.txtGuardianID.Text = strDisplayID frmGuardiansMaintenance.txtPatientID.Text = strPatientID 'Global Variable 'Requerying the Table 'Adding a new recordset

frmGuardiansMaintenance.dgrdGuardiansInfo.Enabled = False End Function Private Sub cmdStep2_Click() Call Guardians_Maintenance With rsGuardiansMaintenance .MoveFirst Do While .EOF = False If .Fields(1).Value = txtPatientID.Text Then 'Entering the values in the particular record into the fields on the interface frmGuardiansMaintenance.txtGuardianID.Text = .Fields(0).Value frmGuardiansMaintenance.txtPatientID.Text = .Fields(1).Value frmGuardiansMaintenance.txtFirstName.Text = .Fields(2).Value frmGuardiansMaintenance.txtSurname.Text = .Fields(3).Value frmGuardiansMaintenance.cboGender.Text = .Fields(4).Value frmGuardiansMaintenance.txtNICNumber.Text = .Fields(5).Value frmGuardiansMaintenance.txtAddress.Text = .Fields(6).Value frmGuardiansMaintenance.txtPhoneHome.Text = .Fields(7).Value frmGuardiansMaintenance.txtPhoneMob.Text = .Fields(8).Value frmGuardiansMaintenance.txtOccupation.Text = .Fields(9).Value frmGuardiansMaintenance.txtRelationToPatient.Text = .Fields(10).Value Exit Do Else .MoveNext End If Loop End With 'Enabling / Diabling the Navigation Buttons as necessary frmGuardiansMaintenance.cmdFirst.Enabled = False frmGuardiansMaintenance.cmdLast.Enabled = True frmGuardiansMaintenance.cmdPrevious.Enabled = False frmGuardiansMaintenance.cmdNext.Enabled = True

141
'Enabling the Update Button frmGuardiansMaintenance.cmdUpdate.Enabled = True 'Enabling the "Step" Buttons frmGuardiansMaintenance.cmdStep1.Enabled = True frmGuardiansMaintenance.cmdStep3.Enabled = True frmGuardiansMaintenance.enableAllFields Unload Me frmGuardiansMaintenance.Show

End Sub

Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking if the Phone Number (Home) textfield and the Phone Number (Mob) textfield are empty If txtPhoneHome.Text = "-" And txtPhoneMob.Text = "-" Then txtPhoneHome.BackColor = &H80000018 'Highlighting the textfield in a different colour txtPhoneMob.BackColor = &H80000018 'Highlighting the textfield in a different colour MsgBox "Error! Both Phone Number Textfields Cannot Be Empty! At Least One Has To Be Provided!", vbCritical, "Error In Phone Numbers!" Exit Sub Else txtPhoneHome.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtPhoneMob.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If

'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then 'Validation To Ensure That The NIC Number is 10 Characters In Length If txtNICNumber.Text <> "-" Then If Len(txtNICNumber.Text) <> 10 Then MsgBox "Error! The NIC Number Has To Consist Of 10 Characters!", vbCritical, "Error In NIC Number!" txtNICNumber.BackColor = &H80000018 'Highlighting the textfield in a different colour Exit Sub Else txtNICNumber.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneHome.Text <> "-" Then If Len(txtPhoneHome.Text) > 15 Then

142
MsgBox "Error! The Phone No (Home) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Home)!" txtPhoneHome.BackColor = &H80000018 Exit Sub Else txtPhoneHome.BackColor = &H80000004 End If End If 'Validation To Ensure That The Phone Numbers are not Greater than 15 Digits in Length If txtPhoneMob.Text <> "-" Then If Len(txtPhoneMob.Text) > 15 Then MsgBox "Error! The Phone No (Mob) Textfield Cannot Consist Of More Than 15 Digits!", vbCritical, "Error In Phone No (Mob)!" txtPhoneMob.BackColor = &H80000018 Exit Sub Else txtPhoneMob.BackColor = &H80000004 End If End If 'Validation To Ensure That The Patient Occupation is not Greater than 30 Characters in Length If Len(txtPatientOccupation.Text) > 30 Then MsgBox "Error! The Patient Occupation Textfield Cannot Consist Of More Than 30 Characters", vbCritical, "Error In Patient Occupation!" txtPatientOccupation.BackColor = &H80000018 Exit Sub Else txtPatientOccupation.BackColor = &H80000004 End If With rsInpatientMaintenance 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If If txtCompanyID.Text = "" Then txtCompanyID.Text = "-" End If

143
If txtCompanyName.Text = "" Then txtCompanyName.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtPatientID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtSurname.Text .Fields(3) = cboGender.Text .Fields(4) = dtpDateOfBirth.Value .Fields(5) = txtNICNumber.Text .Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text .Fields(8) = txtPhoneMob.Text .Fields(9) = txtPatientOccupation.Text .Fields(10) = cboCivilStatus.Text .Fields(11) = cboAccountType.Text .Fields(12) = txtCompanyID.Text .Fields(13) = txtCompanyName.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery End With End If End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Requerying the Table

144
'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the LaunchDoctorSearch Wizard Button cmdLaunchInpatientSearch.Enabled = True End Sub Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next dtpDateOfBirth.Enabled = False 'Disabling the Date Of Birth Date Time Picker End Function

Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next dtpDateOfBirth.Enabled = True 'Enabling the Date Of Birth Date Time Picker End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False

145
End If Next End Function

Private Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next 'Disabling the Step 1 Button cmdStep1.Enabled = False End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next 'The following lines will set the normal display values of the Gender 'ComboBox, Doctor Category ComboBox and the Date Of Birth Date Time Picker cboGender.Text = "----------SELECT-----------" cboCivilStatus.Text = "----------SELECT-----------" cboAccountType.Text = "----------SELECT-----------" dtpDateOfBirth.Value = "4/14/2008" End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button and the Delete Button

146
cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the "Step" Buttons cmdStep2.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset With rsInpatientMaintenance .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsInpatientMaintenance .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value

147
dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the "Step" Buttons cmdStep2.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsInpatientMaintenance .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value

148
txtCompanyName.Text = .Fields(13).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the "Step" Buttons cmdStep2.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the "Step" Buttons cmdStep2.Enabled = True 'Enabling the Company Search Wizard cmdCompanySearchWizard.Enabled = True Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset With rsInpatientMaintenance .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtPatientID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtSurname.Text = .Fields(2).Value cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value txtNICNumber.Text = .Fields(5).Value txtAddress.Text = .Fields(6).Value txtPhoneHome.Text = .Fields(7).Value

149
txtPhoneMob.Text = .Fields(8).Value txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value cboAccountType.Text = .Fields(11).Value txtCompanyID.Text = .Fields(12).Value txtCompanyName.Text = .Fields(13).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub

Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True dateFlag = True 'Setting the dateFlag variable to True 'Checking if the First Name textfield is empty If txtFirstName.Text = "" Then txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Surname textfield is empty If txtSurname.Text = "" Then txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Gender ComboBox If cboGender.Text = "" Then cboGender.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboGender.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the Date Of Birth is valid If dtpDateOfBirth.Value = "4/14/2008" Then 'Displaying an error message, asking the user to alter the date accordingly MsgBox "The Date You Have Provided Is Incorrect! Please Check Your Date!", vbCritical, "Incorrect Date" dateFlag = False 'Setting the dateFlag variable to False to indicate invalid data End If 'Checking if the Address textfield is empty If txtAddress.Text = "" Then txtAddress.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAddress.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If

150
'Checking if the Patient Occupation textfield is empty If txtPatientOccupation.Text = "" Then txtPatientOccupation.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientOccupation.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Civil Status ComboBox If cboCivilStatus.Text = "" Then cboCivilStatus.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboCivilStatus.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'Checking if the user has made a selection in the Account Type ComboBox If cboAccountType.Text = "" Then cboAccountType.BackColor = &H80000018 'Highlighting the ComboBox in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboAccountType.BackColor = &H80000004 'Bringing the ComboBox BackColour back to normal End If 'If the user chooses 'Corporate' from the Account Type ComboBox If cboAccountType.ListIndex = 0 Then 'Checking if the Channeling Charges textfield is empty If txtCompanyID.Text = "" Then txtCompanyID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtCompanyName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtCompanyID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtCompanyName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure ElseIf dateFlag = False Then textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function

Private Sub tmrErrMsg_Timer() Static i As Integer

151
If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidDataMsg.Visible = False picInvalidKeypressMsg.Visible = False picInvalidKeyMsg.Visible = False picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtPhoneHome_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtPhoneHome.Text = "-" Then txtPhoneHome.Text = "" End If End Sub Private Sub txtPhoneHome_LostFocus() user is not typing in it. If txtPhoneHome.Text = "" Then txtPhoneHome.Text = "-" End If End Sub Private Sub txtPhoneMob_GotFocus() 'This procedure will ensure that the textfield is empty when the user types in it. If txtPhoneMob.Text = "-" Then txtPhoneMob.Text = "" End If End Sub Private Sub txtPhoneMob_LostFocus() 'This procedure will ensure that the textfield is not empty when the user is not typing in it. If txtPhoneMob.Text = "" Then txtPhoneMob.Text = "-" End If End Sub 'This procedure will ensure that the textfield is empty when the user types in it. Private Sub txtNICNumber_GotFocus() If txtNICNumber.Text = "-" Then txtNICNumber.Text = "" End If End Sub 'This procedure will ensure that the textfield is not empty when the

152
Private Sub txtNICNumber_LostFocus() user is not typing in it. If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End If End Sub Private Sub txtPhoneHome_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 3360 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPhoneMob_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeypressMsg.Top = 3840 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtNICNumber_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = Asc("X") Then ElseIf KeyAscii = Asc("x") Then ElseIf KeyAscii = Asc("V") Then ElseIf KeyAscii = Asc("v") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 5760 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True 'This procedure will ensure that the textfield is not empty when the

153
KeyAscii = 0 End If End Sub Private Sub txtFirstName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 3840 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSurname_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4320 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtPatientOccupation_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 4320 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub

FormEditRooms

154 FormEditServiceTreatment FormEditWards FormInpatientSearchDischarge:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Dim checkBillingFlag As Boolean 'This variable will check if the user has settled the bill in full or not Dim strCode As String Private Sub cmdClose_Click() 'This procedure will close the Wizard

Unload Me 'Unloading the Wizard End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid

'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False 'Calling the Inpatients_Maintenance Procedure to interact with the recordset

Call Inpatients_Maintenance

Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'"

155
Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button

checkBillingFlag = False 'Initializing the value of this variable 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then 'Here, I am checking if the patient has already settled his / her bill Call Inpatient_Billing With rsInpatientBilling .MoveFirst Do While .EOF = False If .Fields(3).Value = rsInpatientMaintenance.Fields(0) And .Fields(12).Value = "PAID" Then checkBillingFlag = True Exit Do Else .MoveNext End If Loop End With If checkBillingFlag = False Then 'Display Success Message MsgBox "You Cannot Discharge This Patient! He / She Has Not Settled All Payments!", vbCritical, "Error! Patient Cannot Be Discharged!" Exit Sub End If With rsInpatientMaintenance frmDischargeDetailsMaintenance.txtFirstName.Text = .Fields(1).Value frmDischargeDetailsMaintenance.txtSurname.Text = .Fields(2).Value End With Call Inpatients_Admission

156
With rsInpatientsAdmission .MoveFirst While .EOF = False If .Fields(1).Value = rsInpatientMaintenance.Fields(0).Value Then 'Entering the values in the particular record into the fields on the interface frmDischargeDetailsMaintenance.txtAdmissionID.Text = .Fields(0).Value frmDischargeDetailsMaintenance.txtPatientID.Text = .Fields(1).Value frmDischargeDetailsMaintenance.txtAdmissionDate.Text = .Fields(3).Value frmDischargeDetailsMaintenance.txtAdmissionTime.Text = .Fields(4).Value End If .MoveNext Wend End With Unload Me 'Closing the wizard Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormInpatientSearchWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard

Unload Me 'Unloading the Wizard 'Calling the clearAllFields procedure in the Inpatients Maintenance Form frmInpatientsMaintenance.clearAllFields 'Calling the Form_Load procedure in the Inpatients Maintenance Form frmInpatientsMaintenance.Form_Load End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid

'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid

157
Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False 'Calling the Inpatients_Maintenance Procedure to interact with the recordset

Call Inpatients_Maintenance

Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button

158
'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then With rsInpatientMaintenance 'Reset the textfields with the selected record frmInpatientsMaintenance.txtPatientID.Text = .Fields(0).Value frmInpatientsMaintenance.txtFirstName.Text = .Fields(1).Value frmInpatientsMaintenance.txtSurname.Text = .Fields(2).Value frmInpatientsMaintenance.cboGender.Text = .Fields(3).Value frmInpatientsMaintenance.dtpDateOfBirth.Value = .Fields(4).Value frmInpatientsMaintenance.txtNICNumber.Text = .Fields(5).Value frmInpatientsMaintenance.txtAddress.Text = .Fields(6).Value frmInpatientsMaintenance.txtPhoneHome.Text = .Fields(7).Value frmInpatientsMaintenance.txtPhoneMob.Text = .Fields(8).Value frmInpatientsMaintenance.txtPatientOccupation.Text = .Fields(9).Value frmInpatientsMaintenance.cboCivilStatus.Text = .Fields(10).Value frmInpatientsMaintenance.cboAccountType.Text = .Fields(11).Value frmInpatientsMaintenance.txtCompanyID.Text = .Fields(12).Value frmInpatientsMaintenance.txtCompanyName.Text = .Fields(13).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormInpatientSearchWizardAdmit:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard

Unload Me 'Unloading the Wizard 'Calling the clearAllFields procedure in the Inpatients Admission Form frmAdmitPatient.clearAllFields 'Calling the Form_Load procedure in the Inpatients Admission Form frmAdmitPatient.Form_Load End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid

'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True

159
End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False 'Calling the Inpatients_Maintenance Procedure to interact with the recordset

Call Inpatients_Maintenance

Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then Call Inpatients_Admission With rsInpatientsAdmission .MoveFirst While .EOF = False If .Fields(1).Value = rsInpatientMaintenance.Fields(0).Value Then 'Entering the values in the particular record into the fields on the interface frmAdmitPatient.txtAdmissionID.Text = .Fields(0).Value frmAdmitPatient.txtPatientID.Text = .Fields(1).Value frmAdmitPatient.txtGuardianID.Text = .Fields(2).Value

160
frmAdmitPatient.txtAdmissionDate.Text = .Fields(3).Value frmAdmitPatient.txtAdmissionTime.Text = .Fields(4).Value frmAdmitPatient.cboPatientStatus.Text = .Fields(5).Value frmAdmitPatient.txtReasonForStatus.Text = .Fields(6).Value frmAdmitPatient.txtReferredDoctorID.Text = .Fields(7).Value frmAdmitPatient.txtReferredDoctorName.Text = .Fields(8).Value frmAdmitPatient.txtAssignedDoctorID.Text = .Fields(9).Value frmAdmitPatient.txtAssignedDoctorName.Text = .Fields(10).Value frmAdmitPatient.txtDepartmentID.Text = .Fields(11).Value frmAdmitPatient.txtDepartmentName.Text = .Fields(12).Value frmAdmitPatient.txtWardID.Text = .Fields(13).Value frmAdmitPatient.txtWardNo.Text = .Fields(14).Value frmAdmitPatient.txtRoomID.Text = .Fields(15).Value frmAdmitPatient.txtAdditionalNotes.Text = .Fields(16).Value Unload Me Exit Sub End If .MoveNext Wend Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormInpatientsSearchAndFind:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'"

161
Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then With rsInpatientMaintenance 'Reset the textfields with the selected record frmAddServiceTreatmentsIn.txtPatientID.Text = .Fields(0).Value frmAddServiceTreatmentsIn.txtFirstName.Text = .Fields(1).Value frmAddServiceTreatmentsIn.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormInpatientsSearchMedicals:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'"

162
Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then With rsInpatientMaintenance 'Reset the textfields with the selected record frmAddMedicalTreatmentsIn.txtPatientID.Text = .Fields(0).Value frmAddMedicalTreatmentsIn.txtFirstName.Text = .Fields(1).Value frmAddMedicalTreatmentsIn.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormInpatientsWizardMedTreatments:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'"

163
Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then With rsInpatientMaintenance 'Reset the textfields with the selected record frmMedicalTreatmentsMaintenance.txtPatientID.Text = .Fields(0).Value frmMedicalTreatmentsMaintenance.txtFirstName.Text = .Fields(1).Value frmMedicalTreatmentsMaintenance.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormInpatientsWizardService:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'"

164
Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then With rsInpatientMaintenance 'Reset the textfields with the selected record frmServiceTreatmentsMaintenance.txtPatientID.Text = .Fields(0).Value frmServiceTreatmentsMaintenance.txtFirstName.Text = .Fields(1).Value frmServiceTreatmentsMaintenance.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormIPDCreateBill:'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Inpatients Create Bill Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Inpatient_Billing Table '---------------------------------------------------------------------------'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'This variable will hold the invoice ID when saving for the purpose of report generation. Dim invoiceid As String Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

165
Private Sub cmdGO_Click() 'Here, I am checking to ensure that the user does not type in a value that is higher than the Balance Owing If Val(txtAmountPaid.Text) > Val(txtBalanceOwing.Text) Then MsgBox "Error! The Amount Paid Cannot Be Greater Than The Balance Owing!", vbCritical, "Figure Is Too High!" txtAmountPaid.Text = "0" Exit Sub End If 'Incrementing the value in the Total Paid So far textfield txtTotalPaidSoFar.Text = Val(txtTotalPaidSoFar.Text) + Val(txtAmountPaid.Text) 'Decrementing the value in the Balance Owing textfield txtBalanceOwing.Text = Val(txtBalanceOwing.Text) - Val(txtAmountPaid.Text) If txtBalanceOwing.Text = "0" Then txtBillStatus.Text = "PAID" Else txtBillStatus.Text = "UNPAID" End If cmdGO.Enabled = False txtAmountPaid.Enabled = False End Sub Private Sub cmdOK_Click() 'Here, I am checking to ensure that the user does not type in a value that is lower than the Amount Paid If Val(txtTotalRecieved.Text) < Val(txtAmountPaid.Text) Then MsgBox "Error! The Total Received Cannot Be Less Than The Amount Paid!", vbCritical, "Figure Is Too Low!" txtTotalRecieved.Text = "0" Exit Sub End If 'Calculating the balance to be given to the user txtBalance.Text = Val(txtTotalRecieved.Text) - Val(txtAmountPaid.Text) cmdOK.Enabled = False txtTotalRecieved.Enabled = False txtBalance.Enabled = False End Sub Private Sub cmdPrint_Click() 'For Reports On Error GoTo e DataEnvironment1.Commands("InpatientReceipt").Parameters(0) = invoiceid RptInpatientReceipt.Show DataEnvironment1.rsInpatientReceipt.Close Unload Me Exit Sub e: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End If End Sub Private Sub cmdSave_Click() 'Checking if the user has filled in the Payment Plan frame If optCheque.Value <> True And optCash.Value <> True And optCreditCard.Value <> True Then MsgBox "Error! You Have Not Chosen A Payment Type!", vbCritical, "Please Choose Payment Type!" Exit Sub End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsInpatientBilling 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Record This Payment?", vbYesNo + vbQuestion, "Record Payment?") = vbYes Then

166
'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtChequeNo.Text = "" Then txtChequeNo.Text = "-" End If If txtCardNo.Text = "" Then txtCardNo.Text = "-" End If If txtBankName.Text = "" Then txtBankName.Text = "-" End If If txtDiscount.Text = "" Then txtDiscount.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtInvoiceID.Text 'invoiceid = "" 'Clearing the string invoiceid = txtInvoiceID.Text .Fields(1) = txtBillingDate.Text .Fields(2) = txtAdmissionID.Text .Fields(3) = txtPatientID.Text .Fields(4) = txtPatientName.Text .Fields(5) = txtAccountType.Text .Fields(6) = txtTotalCost.Text .Fields(7) = txtDiscount.Text .Fields(8) = txtTotalPayable.Text .Fields(9) = txtTotalPaidSoFar.Text .Fields(10) = txtBalanceOwing.Text .Fields(11) = txtAmountPaid.Text .Fields(12) = txtBillStatus.Text If optCheque.Value = True Then .Fields(13).Value = "Cheque" ElseIf optCash.Value = True Then .Fields(13).Value = "Cash" ElseIf optCreditCard.Value = True Then .Fields(13).Value = "Credit Card" End If .Fields(14) = txtChequeNo.Text .Fields(15) = txtCardNo.Text .Fields(16) = txtBankName.Text .Fields(17) = txtTotalRecieved.Text .Fields(18) = txtBalance.Text .Update 'Display Success Message MsgBox "The Payment Was Recorded Successfully!", vbInformation, "Payment Recorded Successfully!" Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure End If .Requery 'Requerying the Table End With End If cmdPrint.Enabled = True 'Enabling the Print button End Sub Private Sub Form_Load() End Sub

167
Private Sub optCash_Click() 'Here, I am checking to see if the Payment Info frame has been filled If txtAmountPaid.Text = "0" Then MsgBox "Error! Please Fill-in The Payment Info Frame First!", vbCritical, "Payment Info Missing!" Exit Sub End If disablePaymentPlan 'Calling a function to diable all fields in the Payment Plan frame lblTotalRecieved.Enabled = True txtTotalRecieved.Enabled = True lblBalance.Enabled = True txtBalance.Enabled = True cmdOK.Enabled = True End Sub Private Sub optCheque_Click() 'Here, I am checking to see if the Payment Info frame has been filled If txtAmountPaid.Text = "0" Then MsgBox "Error! Please Fill-in The Payment Info Frame First!", vbCritical, "Payment Info Missing!" Exit Sub End If disablePaymentPlan 'Calling a function to diable all fields in the Payment Plan frame lblChequeNo.Enabled = True txtChequeNo.Enabled = True lblBankName.Enabled = True txtBankName.Enabled = True End Sub Private Sub optCreditCard_Click() 'Here, I am checking to see if the Payment Info frame has been filled If txtAmountPaid.Text = "0" Then MsgBox "Error! Please Fill-in The Payment Info Frame First!", vbCritical, "Payment Info Missing!" Exit Sub End If disablePaymentPlan 'Calling a function to diable all fields in the Payment Plan frame lblCardNo.Enabled = True txtCardNo.Enabled = True lblBankName.Enabled = True txtBankName.Enabled = True End Sub Public Function disablePaymentPlan() 'This function will disable all fields in the Payment Plan frame lblChequeNo.Enabled = False txtChequeNo.Enabled = False lblCardNo.Enabled = False txtCardNo.Enabled = False lblBankName.Enabled = False txtBankName.Enabled = False lblTotalRecieved.Enabled = False txtTotalRecieved.Enabled = False lblBalance.Enabled = False txtBalance.Enabled = False End Function Private Sub txtAmountPaid_GotFocus() txtAmountPaid.Text = "" End Sub Private Sub txtAmountPaid_LostFocus() If txtAmountPaid.Text = "" Then txtAmountPaid.Text = "0" End If End Sub Private Sub tmrErrMsg_Timer()

168
Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtAmountPaid_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 2640 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtBankName_GotFocus() txtBankName.Text = "" End Sub Private Sub txtBankName_LostFocus() If txtBankName.Text = "" Then txtBankName.Text = "-" End If End Sub Private Sub txtCardNo_GotFocus() txtCardNo.Text = "" End Sub Private Sub txtCardNo_LostFocus() If txtCardNo.Text = "" Then txtCardNo.Text = "-" End If End Sub Private Sub txtChequeNo_GotFocus() txtChequeNo.Text = "" End Sub Private Sub txtChequeNo_LostFocus() If txtChequeNo.Text = "" Then txtChequeNo.Text = "-" End If End Sub Private Sub txtTotalRecieved_GotFocus() txtTotalRecieved.Text = "" End Sub Private Sub txtTotalRecieved_LostFocus() If txtTotalRecieved.Text = "" Then txtTotalRecieved.Text = "0" End If End Sub Private Sub txtTotalRecieved_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else

169
picInvalidTypingMsg.Top = 6600 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Public Function textfieldsValidations() Flag = True 'Setting the Flag variable to True 'Checking if the Amount Paid textfield is empty If txtAmountPaid.Text = "0" Then txtAmountPaid.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAmountPaid.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Cheque No textfield is empty If txtChequeNo.Enabled = True Then If txtChequeNo.Text = "-" Then txtChequeNo.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtChequeNo.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Checking if the Card No textfield is empty If txtCardNo.Enabled = True Then If txtCardNo.Text = "-" Then txtCardNo.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtCardNo.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Checking if the Bank Name textfield is empty If txtBankName.Enabled = True Then If txtBankName.Text = "-" Then txtBankName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtBankName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Checking if the Total Recieved textfield is empty If txtTotalRecieved.Enabled = True Then If txtTotalRecieved.Text = "0" Then txtTotalRecieved.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtTotalRecieved.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else

170
textfieldsValidations = False 'Passing values to the Save procedure End If End Function

FormIPDOverallBilling:'----------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Inpatient Overall Billing Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Inpatient_Payment_Details '----------------------------------------------------------------------------Option Explicit 'The following variables will be used to autogenerate the Invoice ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Invoice ID to be autogenerated Dim iNumberOfRecords As Integer 'This variable will hold the number of records in the Inpatient_Payment_Details table Dim strDisplay As String 'This variable will eventually display the OverallInBillID in the invisible textfield Dim iTotalPayable As Double 'This variable will hold the value of the Total Payable Dim billID As String 'This variable will hold the Billing ID of the patient Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdGoToPayments_Click() 'Ensuring that the user has selected a patient If txtPatientID.Text = "" Then MsgBox "You Cannot Go To The Payments Process Until You Select A Patient!", vbCritical, "Please Select A Patient!" Exit Sub End If On Error GoTo error_handler Call Inpatient_Billing 'Calling the Inpatient_Billing Procedure to interact with the recordset 'Generate Invoice ID By Utilizing the Inpatient_Billing Table With rsInpatientBilling If .RecordCount = 0 Then 'If there are no records in the table strCode = "IIN0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Inpatient_Billing Table If iNumOfRecords < 10 Then strCode = "IIN000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "IIN00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "IIN0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then

171
strCode = "IIN" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With iTotalPayable = Int(Val(txtNettTotal.Text)) 'Storing the Nett Total in this variable 'The following line of code will enter the autogenerated Invoice ID into the relevant textfield frmIPDCreateBill.txtInvoiceID.Text = strCode 'Entering all relevant data onto the Payment Form frmIPDCreateBill.txtBillingDate.Text = DateTime.Date 'System Date frmIPDCreateBill.txtAdmissionID.Text = txtAdmissionID.Text frmIPDCreateBill.txtPatientID.Text = txtPatientID.Text frmIPDCreateBill.txtPatientName.Text = txtFirstName.Text & " " & txtSurname.Text frmIPDCreateBill.txtAccountType.Text = txtAccountType.Text frmIPDCreateBill.txtTotalCost.Text = txtTotal.Text frmIPDCreateBill.txtDiscount.Text = txtDiscount.Text frmIPDCreateBill.txtTotalPayable.Text = iTotalPayable 'Here, I am calculating the Total Paid So Far Call TotalPaidSoFar Set frmIPDCreateBill.dgrdTotalPaidSoFar.DataSource = rsTotalPaidSoFar frmIPDCreateBill.txtTotalPaidSoFar.Text = frmIPDCreateBill.dgrdTotalPaidSoFar.Columns(0).Value 'Here, I am calculating the balance owed by the patient frmIPDCreateBill.txtBalanceOwing.Text = Val(frmIPDCreateBill.txtTotalPayable.Text) Val(frmIPDCreateBill.txtTotalPaidSoFar.Text) 'Here, I am displaying the Bill Status If frmIPDCreateBill.txtTotalPaidSoFar.Text <> "0" Then If frmIPDCreateBill.txtBalanceOwing.Text = "0" Then frmIPDCreateBill.txtBillStatus.Text = "PAID" End If End If Unload Me 'Closing this form frmIPDCreateBill.Show 'Opening Up The Payments Form Exit Sub error_handler: frmIPDCreateBill.txtTotalPaidSoFar.Text = "0" frmIPDCreateBill.txtBalanceOwing.Text = frmIPDCreateBill.txtTotalPayable.Text Unload Me End Sub Private Sub cmdInpatientSearchWizard_Click() frmInpatientSearchBilling.Show End Sub Private Sub cmdPrint_Click() On Error GoTo e DataEnvironment1.Commands("InpatientInvoice").Parameters(0) = billID DataEnvironment1.Commands("InpatientInvoice").Parameters(1) = "" RptInpatientInvoice.Show DataEnvironment1.rsInpatientInvoice.Close Unload Me Exit Sub e: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End If End Sub Private Sub cmdSave_Click() 'Ensuring that the user has selected a patient If txtAdmissionID.Text = "" Then MsgBox "Error! You Have Not Selected A Patient!", vbCritical, "Please Select A Patient!"

172
Exit Sub End If Call Inpatient_Payment_Details 'Calling the Inpatient_Payment_Details Procedure to interact with the recordset 'Generate OverallInBillID By Utilizing the Inpatient_Payment_Details Table With rsInpatientPaymentDetails If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "IPD0001" Else 'Calculating the number of records and storing in a variable iNumberOfRecords = .RecordCount iNumberOfRecords = iNumberOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Inpatient_Payment_Details Table If iNumberOfRecords < 10 Then strDisplay = "IPD000" & iNumberOfRecords ElseIf iNumberOfRecords < 100 Then strDisplay = "IPD00" & iNumberOfRecords ElseIf iNumberOfRecords < 1000 Then strDisplay = "IPD0" & iNumberOfRecords ElseIf iNumberOfRecords < 10000 Then strDisplay = "IPD" & iNumberOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated OverallInBillID 'into the invisible OverallInBillID textfield txtOverallInBillID.Text = strDisplay 'Here, I am ensuring that the Discount textfield is not empty when I save If txtDiscount.Text = "" Then txtDiscount.Text = "-" End If 'Now I am going to save the record in the database With rsInpatientPaymentDetails 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then .Fields(0) = txtOverallInBillID.Text billID = txtOverallInBillID.Text 'Passing this value to a variable .Fields(1) = txtAdmissionID.Text .Fields(2) = txtPatientID.Text .Fields(3) = txtFirstName.Text .Fields(4) = txtSurname.Text .Fields(5) = txtAccountType.Text .Fields(6) = txtAssignedDoctorID.Text .Fields(7) = txtDepartmentID.Text .Fields(8) = txtDepartmentName.Text .Fields(9) = txtWardNo.Text .Fields(10) = txtRoomID.Text .Fields(11) = dtpAdmissionDate.Value .Fields(12) = dtpTodaysDate.Value .Fields(13) = txtNoOfDays.Text 'Length Of Stay .Fields(14) = txtDoctorsCharges.Text .Fields(15) = txtMedicalTreatmentCharges.Text .Fields(16) = txtServiceTreatmentCharges.Text .Fields(17) = txtRoomCharges.Text .Fields(18) = txtHospitalCharges.Text

173
.Fields(19) = txtTotal.Text .Fields(20) = txtVAT.Text .Fields(21) = txtDiscount.Text .Fields(22) = txtNettTotal.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure!" Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure End If End With cmdPrint.Enabled = True 'Enabling the Print button End Sub Private Sub Form_Load() 'Displaying the system date in the Today's Date textfield dtpTodaysDate.Value = DateTime.Date End Sub

FormLogin:'--------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Login Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 01/04/08 'Date Of Last Modification: 01/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: User_Account Table '--------------------------------------------------------------------Option Explicit Dim rsLogin As ADODB.Recordset 'Creating a Recordset Variable Dim iLoginFailure As Integer 'This variable will count the number of times the user's login is unsuccessful. Private Sub Form_Initialize() Call Connection 'Calling the Connection Procedure. 'Creating a New Recordset To Be Used For Login Purposes Only Set rsLogin = New ADODB.Recordset With rsLogin .CursorType = adOpenDynamic .LockType = adLockOptimistic .ActiveConnection = conn .CursorLocation = adUseClient End With iLoginFailure = 1 ' When a login attempt is unsuccessful, I decrement this variable's value. End Sub Private Sub txtUsername_Change() 'This block of code will enable or disable the "Go" button accordingly If txtUserName.Text = "" Then cmdGo.Enabled = False Else cmdGo.Enabled = True End If End Sub Private Sub txtUserName_keypress(KeyAscii As Integer) 'This block of code prevents the user from using "Copy-Paste" (Ctrl+C, Ctrl+V) functions. If KeyAscii = 3 Or KeyAscii = 22 Or KeyAscii = 24 Then

174
KeyAscii = 0 ElseIf KeyAscii = 13 Then 'This is for using the Enter key KeyAscii = 0 SendKeys "{Tab}" End If End Sub Private Sub txtPassword_Keypress(KeyAscii As Integer) 'This block of code prevents the user from using "Copy-Paste" (Ctrl+C, Ctrl+V) functions. If KeyAscii = 3 Or KeyAscii = 22 Or KeyAscii = 24 Then KeyAscii = 0 ElseIf KeyAscii = 13 Then 'This is for using the Enter key KeyAscii = 0 SendKeys "{Tab}" Call cmdGO_Click End If End Sub Private Sub cmdGO_Click() If iLoginFailure <= 3 Then 'Checking If The User Is Still Allowed To Login 'Selecting the Related Login Record from the User_Account Table. rsLogin.Open "select * from UserAccount where Username='" & txtUserName.Text & "'", conn With rsLogin If .RecordCount = 0 Then 'This Means That There Is No Matching Record iLoginFailure = iLoginFailure + 1 'Decrementing The Value Of i On Each Unsuccessful Login Attempt MsgBox "Sorry! Invalid User Name! Please Try Again!", vbCritical, "Invalid Login!" txtUserName.BackColor = &H80000018 'Highlighting The Textbox With The Error txtPassword.BackColor = &H80000005 'Highlighting The Textbox With The Error txtUserName.Text = "" txtUserName.SetFocus End If If .RecordCount <> 0 Then 'This Means That There Is A Matching Record If txtPassword.Text = .Fields(6).Value Then 'Checking Password If .Fields(4) = "Administrator" Then 'Checking Designation 'Passing Necessary Values To Global Variables userName = .Fields(1).Value & " " & .Fields(2).Value accessLevel = "Administrator" userID = .Fields(0).Value frmMDI.Show Unload Me ElseIf .Fields(4) = "Cashier" Then 'Checking Designation 'Passing Necessary Values To Global Variables userName = .Fields(1).Value & " " & .Fields(2).Value accessLevel = "Cashier" userID = .Fields(0).Value Unload Me frmMDI.Show ElseIf .Fields(4) = "Inpatient Staff" Then 'Checking Designation 'Passing Necessary Values To Global Variables userName = .Fields(1).Value & " " & .Fields(2).Value accessLevel = "Inpatient Staff" userID = .Fields(0).Value frmMDI.Show Unload Me ElseIf .Fields(4) = "Outpatient Staff" Then 'Checking Designation 'Passing Necessary Values To Global Variables userName = .Fields(1).Value & " " & .Fields(2).Value accessLevel = "Outpatient Staff" userID = .Fields(0).Value

175
frmMDI.Show Unload Me ElseIf .Fields(4) = "Receptionist" Then 'Checking Designation 'Passing Necessary Values To Global Variables userName = .Fields(1).Value & " " & .Fields(2).Value accessLevel = "Receptionist" userID = .Fields(0).Value frmMDI.Show Unload Me End If Else 'Error Mesage For Invalid Password iLoginFailure = iLoginFailure + 1 'Decrementing The Value Of i On Each Unsuccessful Login Attempt MsgBox "Sorry! Invalid Password! Please Try Again!", vbCritical, "Invalid Login!" txtPassword.BackColor = &H80000018 'Highlighting The Textbox With The Error txtUserName.BackColor = &H80000005 'Highlighting The Textbox With The Error txtPassword.Text = "" txtPassword.SetFocus End If End If .Close 'Closing Recordset End With Else 'Error Message If User's Login Attempt Is Unsuccesful On Three 'Consecutive Occasions MsgBox "Sorry! You Have To Login Within Three Tries! Unloading...", vbCritical, "Login Failure" End End If End Sub Private Sub cmdExit_Click() 'This block of code will be executed if the user decides to quit the application 'from the Login page Dim ans As Variant ans = MsgBox("Are You Sure You Wish To Quit The Application?", vbYesNo + vbQuestion, "Quit Application?") If ans = vbYes Then End End If End Sub

FormManageUserAccounts:'----------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Manage User Accounts Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 22/04/08 'Date Of Last Modification: 22/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: UserAccount Table '----------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine

176
'if the data the user enters is valid or not Dim Flag As Boolean 'This variable will count the number of times the user keys in the "@" symbol. Dim iNumOfSymbols As Integer 'The following variables will be used to autogenerate the User ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the User ID to be autogenerated Dim rsSelectionOfFields As ADODB.Recordset 'This will limit the fields I show in the grid Private Sub cmdAddNew_Click() enableAllFields 'Calling a Private Function To Enable All Fields clearAllFields 'Calling a Private Function To Clear All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the Save Command Button & Close Command Button cmdSave.Enabled = True cmdClose.Enabled = True 'Disabling the Search Frame lblCriteria.Enabled = False cboSearchType.Enabled = False lblSearchFor.Enabled = False txtSearch.Enabled = False 'Disabling the DataGrid dgrdUserAccount.Enabled = False Call UserAccounts_Maintenance 'Calling the UserAccounts_Maintenance Procedure to interact with the recordset 'Generate User ID By Utilizing the UserAccounts_Maintenance Table With rsUserAccount If .RecordCount = 0 Then 'If there are no records in the table strCode = "EMP0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Doctors_Maintenance Table If iNumOfRecords < 10 Then strCode = "EMP000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "EMP00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "EMP0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "EMP" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated User ID 'into the User ID textfield & Username textfield. txtUserID.Text = strCode txtUsername.Text = strCode End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it.

177
If txtPassword.Text <> txtConfirmation.Text Then MsgBox "Error! The Passwords You Provided Do Not Match", vbCritical, "Password Mismatch!" Exit Sub End If Flag = True 'Setting the Flag variable to True 'Checking if the First Name textfield is empty If txtFirstName.Text = "" Then txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Last Name textfield is empty If txtLastName.Text = "" Then txtLastName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtLastName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Designation ComboBox If cboDesignation.Text = "" Then cboDesignation.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboDesignation.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Update procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" Exit Sub End If With rsSelectionOfFields 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtEmail.Text = "" Then txtEmail.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtUserID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtLastName.Text .Fields(3) = txtEmail.Text .Fields(4) = cboDesignation.Text .Update .Requery 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!"

178
.CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End Sub Private Sub dgrdUserAccount_Click() 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsSelectionOfFields 'Entering the values in the particular record into the fields on the interface txtUserID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtLastName.Text = .Fields(2).Value txtEmail.Text = .Fields(3).Value cboDesignation.Text = .Fields(4).Value txtUsername.Text = "" txtPassword.Text = "" txtConfirmation.Text = "" End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub Form_Load() Call Connection 'Calling the Connection Procedure Call UserAccounts_Maintenance 'Calling the UserAccounts_Maintenance Procedure to interact with the recordset disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & the Close Button cmdAddNew.Enabled = True cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchFor.Enabled = True txtSearch.Enabled = True 'Enabling the DataGrid dgrdUserAccount.Enabled = True Call Selection_Of_Fields Set dgrdUserAccount.DataSource = rsSelectionOfFields 'Setting the DataSource of the DataGrid End Sub 'This function will interact with the UserAccount table, whilst hiding 'sensitive information from the user Private Function Selection_Of_Fields() Set rsSelectionOfFields = New ADODB.Recordset With rsSelectionOfFields .CursorType = adOpenDynamic .LockType = adLockOptimistic .ActiveConnection = conn

179
.Source = "Select [UserID],[FirstName],[LastName],[EMail],[Designation] from UserAccount" .CursorLocation = adUseClient .Open End With End Function Private Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Private Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Private Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsSelectionOfFields .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtUserID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtLastName.Text = .Fields(2).Value txtEmail.Text = .Fields(3).Value cboDesignation.Text = .Fields(4).Value

180
End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsSelectionOfFields .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtUserID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtLastName.Text = .Fields(2).Value txtEmail.Text = .Fields(3).Value cboDesignation.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsSelectionOfFields .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtUserID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtLastName.Text = .Fields(2).Value txtEmail.Text = .Fields(3).Value cboDesignation.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record

181
'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Clearing the Search Textfield to Enable All Records To Be 'Displayed On The Grid txtSearch.Text = "" With rsSelectionOfFields .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtUserID.Text = .Fields(0).Value txtFirstName.Text = .Fields(1).Value txtLastName.Text = .Fields(2).Value txtEmail.Text = .Fields(3).Value cboDesignation.Text = .Fields(4).Value End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidDataMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsSelectionOfFields 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[UserID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[LastName] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Designation] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False cmdDelete.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Selection_Of_Fields

182
Set dgrdUserAccount.DataSource = rsSelectionOfFields 'Setting the DataSource of the DataGrid End If End Sub Private Sub cmdSave_Click() 'This function will save all the user's data in the database 'Checking if the Passwords Match If txtPassword.Text <> txtConfirmation.Text Then MsgBox "Error! The Passwords You Provided Do Not Match", vbCritical, "Password Mismatch!" Exit Sub End If 'Checking the number of times the "@" symbol was pressed If iNumOfSymbols < 1 Then MsgBox "Error! The Email ID You Provided Does Not Contain The @ Symbol!", vbCritical, "No @ Symbol!" txtEmail.Text = "" 'Clearing the textfield iNumOfSymbols = 0 'Setting the value of the variable to 0 Exit Sub ElseIf iNumOfSymbols > 1 Then MsgBox "Error! The Email ID You Provided Can Contain Only One @ Symbol!", vbCritical, "Too Many @ Symbols!" txtEmail.Text = "" 'Clearing the texfield iNumOfSymbols = 0 'Setting the value of the variable to 0 Exit Sub End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsUserAccount 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then 'The following if else condition ensures that The Additional Notes 'textfield will not be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtEmail.Text = "" Then txtEmail.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtUserID.Text .Fields(1) = txtFirstName.Text .Fields(2) = txtLastName.Text .Fields(3) = txtEmail.Text .Fields(4) = cboDesignation.Text .Fields(5) = txtUsername.Text .Fields(6) = txtPassword.Text .Update .Requery 'Requerying the Table 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If '.Requery 'Requerying the Table End With End If End Sub

183
Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the First Name textfield is empty If txtFirstName.Text = "" Then txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Last Name textfield is empty If txtLastName.Text = "" Then txtLastName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtLastName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the User Name textfield is empty If txtUsername.Text = "" Then txtUsername.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtUsername.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Password textfield is empty If txtPassword.Text = "" Then txtPassword.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPassword.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Confirm Password textfield is empty If txtConfirmation.Text = "" Then txtConfirmation.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtConfirmation.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the user has made a selection in the Designation ComboBox If cboDesignation.Text = "" Then cboDesignation.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else cboDesignation.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtUserID.Text = "" Then MsgBox "Error! No Record Has Been Selected", vbCritical, "No Record Selected!"

184
Else With rsSelectionOfFields 'Confirm the Delete procedure with the user If MsgBox("Are You Sure You Wish To Delete User ID " & txtUserID.Text & "'s Record?", vbYesNo + vbQuestion, "Delete Record?") = vbYes Then .Delete 'Delete the record from the database 'Display Success Message MsgBox "The Record Has Been Deleted Successfully!", vbInformation, "Successful Delete Procedure!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'Delete Procedure Cancelled' Message MsgBox "The Delete Procedure Was Cancelled!", vbExclamation, "Delete Procedure Cancelled!" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields End If .Requery 'Requerying the Table End With End If End Sub Private Sub txtFirstName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4200 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtLastName_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") Then ElseIf KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidDataMsg.Top = 4680 'Validation Note View picInvalidDataMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtEmail_KeyPress(KeyAscii As Integer) 'Counting the number of times the "@" symbol was pressed If KeyAscii = Asc("@") Then iNumOfSymbols = iNumOfSymbols + 1 End If End Sub

FormMDI:'--------------------------------------------------------------------'Hospital Management System - Extended Edition

185
'Form Name: Menu Driven Interface (MDI) 'Programmer: Bhaskar BDPS & Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 01/04/08 'Date Of Last Modification: 01/04/08 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: None '--------------------------------------------------------------------Option Explicit Dim iExitReply As Integer 'This variable will hold the user's choice, once he has been asked whether he wants to exit or not Dim iLogOutReply As Integer 'This variable will hold the user's choice, once he has been asked whether he wants to log out or not Private Sub MDIForm_Load() 'In the following lines of code, I am checking the user access level 'and appropriately disabling certain restricted functions If accessLevel = "Administrator" Then lblDesignation.Caption = "Welcome, Administrator" frmQuickLaunch.lblDesignation.Caption = "Administrator" Call Enable_Controls 'Calling a User Defined Function In Order To Enable All Components ElseIf accessLevel = "Cashier" Then lblDesignation.Caption = "Welcome, Cashier" frmQuickLaunch.lblDesignation.Caption = "Cashier" Call Enable_Controls 'Calling a User Defined Function In Order To Enable All Components lblShortcut(0).Enabled = False lblShortcut(1).Enabled = False lblShortcut(2).Enabled = False lblShortcut(4).Enabled = False lblShortcut(5).Enabled = False mnuPatientAdmission.Enabled = False mnuTreatment.Enabled = False mnuDischargePatient.Enabled = False mnuOutpatientsMaintenance.Enabled = False mnuTreatments.Enabled = False mnuChanneling.Enabled = False mnuReports.Enabled = False mnuManageUserAccounts.Enabled = False mnuMaintenance.Enabled = False mnuSearchEngine.Enabled = False mnuBackupDatabase.Enabled = False ElseIf accessLevel = "Receptionist" Then lblDesignation.Caption = "Welcome, Receptionist" frmQuickLaunch.lblDesignation.Caption = "Receptionist" Call Enable_Controls 'Calling a User Defined Function In Order To Enable All Components lblShortcut(0).Enabled = False lblShortcut(1).Enabled = False lblShortcut(3).Enabled = False lblShortcut(4).Enabled = False mnuInpatients.Enabled = False mnuOutpatients.Enabled = False mnuPayments.Enabled = False mnuReports.Enabled = False mnuManageUserAccounts.Enabled = False mnuMaintenance.Enabled = False mnuBackupDatabase.Enabled = False ElseIf accessLevel = "Inpatient Staff" Then

186
lblDesignation.Caption = "Welcome, Inpatient Staff" frmQuickLaunch.lblDesignation.Caption = "Inpatient Staff" Call Enable_Controls 'Calling a User Defined Function In Order To Enable All Components lblShortcut(1).Enabled = False lblShortcut(2).Enabled = False lblShortcut(3).Enabled = False lblShortcut(4).Enabled = False lblShortcut(5).Enabled = False mnuOutpatients.Enabled = False mnuChanneling.Enabled = False mnuPayments.Enabled = False mnuReports.Enabled = False mnuMaintenance.Enabled = False mnuManageUserAccounts.Enabled = False mnuSearchEngine.Enabled = False mnuBackupDatabase.Enabled = False ElseIf accessLevel = "Outpatient Staff" Then lblDesignation.Caption = "Welcome, Outpatient Staff" frmQuickLaunch.lblDesignation.Caption = "Outpatient Staff" Call Enable_Controls 'Calling a User Defined Function In Order To Enable All Components lblShortcut(0).Enabled = False lblShortcut(2).Enabled = False lblShortcut(3).Enabled = False lblShortcut(4).Enabled = False lblShortcut(5).Enabled = False mnuInpatients.Enabled = False mnuChanneling.Enabled = False mnuPayments.Enabled = False mnuReports.Enabled = False mnuMaintenance.Enabled = False mnuManageUserAccounts.Enabled = False mnuSearchEngine.Enabled = False mnuBackupDatabase.Enabled = False End If frmQuickLaunch.Show lblDateTime.Caption = "Today is " & FormatDateTime(Now, vbLongDate) BottomStatusBar.Panels(4).Text = userName BottomStatusBar.Panels(5).Text = accessLevel End Sub Private Function Enable_Controls() 'This is a User Defined Function That Will Enable All The Components On The Screen. 'Here, I am running a For loop to include all the controls on the interface and then 'I enable them all, with one line of code Dim ctrl As Control On Error Resume Next For Each ctrl In Controls ctrl.Enabled = True Next End Function Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) 'This event occurs when the user tries to quit the application by clicking the 'standard red cross button, on the top left hand corner of the interface If UnloadMode = 0 Then iExitReply = MsgBox(userName & ", Are You Sure You Wish To Exit The Application?", vbYesNo + vbQuestion, "Exit Application?") If iExitReply = vbNo Then Cancel = 1 End If

187
End If End Sub Private Sub lblShortcut_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) 'Here, I am creating Rollover Effects For Each Button On The Shortcut Panel Select Case (Index) Case 0: 'Manage User Accounts Button lblShortcut(0).ForeColor = &H800000 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = True lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 1: 'Manage Inpatients Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H800000 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = True lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 2: 'Manage Outpatients Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H800000 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006

188
lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = True lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 3: 'Channeling Services Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H800000 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = True lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 4: 'Reports Quick Launch Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H800000 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = True lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 5: 'Search Engine Button

189
lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H800000 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = True lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 6: 'Change Password Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H800000 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = True lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 7: 'Log Off / Exit Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H800000 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False

190
lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = True lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False Case 8: 'Log Off Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H800000 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = True lblShortcut(9).FontUnderline = False Case 9: 'Exit Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H800000 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = True End Select End Sub Private Sub imgRecordExplorer_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'The Following Block Of Code Ensures That The Mouse Pointer 'Returns To Normal When It Is Not Over A Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006

191
lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False End Sub Private Sub imgUserAccount_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'The Following Block Of Code Ensures That The Mouse Pointer 'Returns To Normal When It Is Not Over A Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006 lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False End Sub Private Sub mnuAbout_Click() frmAbout.Show End Sub Private Sub mnuAddMedicalTreatment_Click() frmAddMedicalTreatmentsOut.Show End Sub Private Sub mnuAddMedicalTreatments_Click() frmAddMedicalTreatmentsIn.Show End Sub Private Sub mnuAddServiceTreatment_Click() frmAddServiceTreatmentsOut.Show End Sub Private Sub mnuAddServiceTreatments_Click()

192
frmAddServiceTreatmentsIn.Show End Sub Private Sub mnuBackupDatabase_Click() frmBackupDatabase.Show End Sub Private Sub mnuCalendar_Click() frmCalendar.Show End Sub Private Sub mnuCascade_Click() Me.Arrange vbCascade End Sub Private Sub mnuCloseAll_Click() Me.Arrange vbCascade End Sub Private Sub mnuCorporateMaintenance_Click() frmCompaniesMaintenance.Show End Sub Private Sub mnuCredits_Click() frmCredits.Show End Sub Private Sub mnuEditMedicalTreatment_Click() frmMedicalTreatmentsOut.Show End Sub Private Sub mnuEditMedicalTreatmentRecords_Click() frmMedicalTreatmentsMaintenance.Show End Sub Private Sub mnuEditServiceTreatmentRecord_Click() frmServiceTreatmentsMaintenance.Show End Sub Private Sub mnuEditServiceTreatmentRecords_Click() frmServiceTreatmentsOut.Show End Sub Private Sub mnuHelpFile_Click() '---Opening the Help Guide File with the Common Dialog Object On Error GoTo e Const cdlHelpPartialKey = &H105 ' Calls the search engine in Windows Help CommonDialog.HelpCommand = cdlHelpPartialKey CommonDialog.Action = 6 Exit Sub e: MsgBox Err.Description 'MsgBox "Error! The Help Guide does not exist!", vbCritical, "Help File Does Not Exist!" End Sub Private Sub mnuLogOff_Click() iLogOutReply = MsgBox(userName & ", Are You Sure You Wish To Log Out Of Your Account?", vbYesNo + vbQuestion, "Log Out?") If iLogOutReply = vbYes Then frmLogin.Show Unload Me End If End Sub Private Sub mnuMicrosoftMagnifier_Click() 'Opens Up The Magnifier Utility On Error GoTo errcode Dim a As Double a = Shell("C:\WINDOWS\System32\magnify.exe", vbNormalFocus) Exit Sub errcode: MsgBox "Unable to run Microsoft Magnifier on your computer", vbError, "Error Loading Microsoft Magnifier!"

193
Resume Next End Sub Private Sub mnuMicrosoftNarrator_Click() 'Opens Up The Narrator Utility On Error GoTo errcode Dim a As Double a = Shell("C:\WINDOWS\System32\narrator.exe", vbNormalFocus) Exit Sub errcode: MsgBox "Unable to run Microsoft Narrator on your computer", vbError, "Error Loading Microsoft Narrator!" Resume Next End Sub Private Sub mnuRoomsMaintenance_Click() frmRoomsMaintenance.Show End Sub Private Sub mnuSearchEngine_Click() frmSearchEngine.Show End Sub Private Sub mnuSystemCalculator_Click() 'Opens Up The Calculator Utility On Error GoTo errcode Dim a As Double a = Shell("C:\WINDOWS\System32\calc.exe", vbNormalFocus) Exit Sub errcode: MsgBox "Unable to run the Calculator Utility on your computer", vbError, "Error Loading Calculator!" Resume Next End Sub Private Sub mnuSystemMediaPlayer_Click() 'Opens Up The System Media Player Utility On Error GoTo errcode Dim a As Double a = Shell("C:\WINDOWS\System32\dvdplay.exe", vbNormalFocus) Exit Sub errcode: MsgBox "Unable to run System Media Player on your computer", vbError, "Error Loading System Media Player!" Resume Next End Sub Private Sub mnuSystemNotepad_Click() 'Opens Up The Notepad Utility On Error GoTo errcode Dim a As Double a = Shell("C:\WINDOWS\System32\notepad.exe", vbNormalFocus) Exit Sub errcode: MsgBox "Unable to run the Notepad Utility on your computer", vbError, "Error Loading Notepad!" Resume Next End Sub Private Sub mnuTileHorizontally_Click() Me.Arrange vbTileHorizontal End Sub Private Sub mnuTileVertically_Click() Me.Arrange vbTileVertical End Sub Private Sub picTopNavigation_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'The Following Block Of Code Ensures That The Mouse Pointer 'Returns To Normal When It Is Not Over A Button lblShortcut(0).ForeColor = &H80000006 lblShortcut(1).ForeColor = &H80000006 lblShortcut(2).ForeColor = &H80000006

194
lblShortcut(3).ForeColor = &H80000006 lblShortcut(4).ForeColor = &H80000006 lblShortcut(5).ForeColor = &H80000006 lblShortcut(6).ForeColor = &H80000006 lblShortcut(7).ForeColor = &H80000006 lblShortcut(8).ForeColor = &H80000006 lblShortcut(9).ForeColor = &H80000006 lblShortcut(0).FontUnderline = False lblShortcut(1).FontUnderline = False lblShortcut(2).FontUnderline = False lblShortcut(3).FontUnderline = False lblShortcut(4).FontUnderline = False lblShortcut(5).FontUnderline = False lblShortcut(6).FontUnderline = False lblShortcut(7).FontUnderline = False lblShortcut(8).FontUnderline = False lblShortcut(9).FontUnderline = False End Sub Private Sub lblShortcut_Click(Index As Integer) 'The following block of code illustrates which interfaces are displayed on click of 'each respective button Select Case (Index) Case 0: 'Manage Inpatients Button Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset frmInpatientsMaintenance.Show Case 1: 'Manage Outpatients Button frmOutpatientsMaintenance.Show Case 2: 'Channeling Services Button frmChannelingAppointments.Show Case 3: 'Payments Button frmPaymentOptions.Show Case 4: 'Reports Quick Launch Button frmReportsQuickLaunch.Show Case 5: 'Search Engine Button frmSearchEngine.Show Case 6: 'Change Password Button frmChangePassword.Show Case 7: 'Log Off / Exit Button frmTurnOff.Show Case 8: 'Log Off Button iLogOutReply = MsgBox(userName & ", Are You Sure You Wish To Log Out Of Your Account?", vbYesNo + vbQuestion, "Log Out?") If iLogOutReply = vbYes Then frmLogin.Show Unload Me End If Case 9: 'Exit Button iExitReply = MsgBox(userName & ", Are You Sure You Wish To Quit The Application?", vbYesNo + vbQuestion, "Quit Application?") If iExitReply = vbYes Then End End If End Select End Sub Private Sub mnuChangePassword_Click() frmChangePassword.Show End Sub

195
Private Sub mnuCompanyMaintenance_Click() frmCompaniesMaintenance.Show End Sub Private Sub mnuDepartmentsMaintenance_Click() frmDepartmentsMaintenance.Show End Sub Private Sub mnuDischargePatient_Click() frmDischargeDetailsMaintenance.Show End Sub Private Sub mnuDoctorScheduleMaintenance_Click() frmDoctorScheduleMaintenance.Show End Sub Private Sub mnuDoctorsMaintenance_Click() frmDoctorsMaintenance.Show End Sub Private Sub mnuDoctorsVisitMaintenance_Click() frmDoctorVisitsMaintenance.Show End Sub Private Sub mnuDoctorVisitMaintenance_Click() frmDoctorVisitsMaintenance.Show End Sub Private Sub mnuExit_Click() If MsgBox(userName & ", Are You Sure You Wish To Quit The Application?", vbYesNo + vbQuestion, "Quit Application?") = vbYes Then End End If End Sub Private Sub mnuGuardiansMaintenance_Click() Call Guardians_Maintenance Set frmGuardiansMaintenance.dgrdGuardiansInfo.DataSource = rsGuardiansMaintenance frmGuardiansMaintenance.Show End Sub Private Sub mnuHopitalServicesMaintenance_Click() frmServicesMaintenance.Show End Sub Private Sub mnuInpatientsMaintenance_Click() Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset frmInpatientsMaintenance.Show End Sub Private Sub mnuManageAppointments_Click() frmChannelingAppointments.Show End Sub Private Sub mnuManagePatientBill_Click() frmIPDOverallBilling.Show End Sub Private Sub mnuManagePatientsBill_Click() frmOPDOverallBilling.Show End Sub Private Sub mnuManageUserAccounts_Click() frmManageUserAccounts.Show End Sub Private Sub mnuMedicinesMaintenance_Click() frmMedicinesMaintenance.Show End Sub Private Sub mnuOSearchPayments_Click() frmSearchOutpatientPayments.Show End Sub Private Sub mnuOutpatientsMaintenance_Click() frmOutpatientsMaintenance.Show

196
End Sub Private Sub mnuRegisterAdmitPatient_Click() Call Inpatients_Admission frmAdmitPatient.Show End Sub Private Sub mnuSearchPayments_Click() frmSearchPayments.Show End Sub Private Sub mnuViewOverallPatientBill_Click() frmOPDOverallBilling.cmdSave.Enabled = False frmOPDOverallBilling.cmdGoToPayments.Enabled = False frmOPDOverallBilling.Show End Sub Private Sub mnuViewOveralPatientBill_Click() frmIPDOverallBilling.cmdSave.Enabled = False frmIPDOverallBilling.cmdGoToPayments.Enabled = False frmIPDOverallBilling.Show End Sub Private Sub mnuWardsMaintenance_Click() frmWardsMaintenance.Show End Sub '----------------------------REPORTS MDI--------------------------------------------------Private Sub mnuAllCompaniesMasterReport_Click() RptAllCompaniesMaster.Show End Sub Private Sub mnuAllDoctors_Click() RptDoctorsMaster.Show End Sub Private Sub mnuAllDoctorsSchedulesMasterReport_Click() RptAllDoctorsShedule.Show End Sub Private Sub mnuChannelingPatientsMasterReport_Click() frmReportChannelingMaster.Show End Sub Private Sub mnuDepartmentsMasterReport_Click() RptDepartmentMaster.Show End Sub Private Sub mnuDoctorsVisitsMasterReport_Click() RptVisitingDoctorsShedule.Show End Sub Private Sub mnuIndividualDoctorsScheduleReport_Click() RptAllDoctorsShedule.Show End Sub Private Sub mnuInpatientsInvoice_Click() frmReportInpatientInvoice.Show End Sub Private Sub mnuInpatientsMasterReport_Click() frmReportInpatientMaster.Show End Sub Private Sub mnuMedicalServicesMasterReport_Click() RptMedicalServicesMaster.Show End Sub Private Sub mnuMedicinesMasterReport_Click() RptMedicinesMaster.Show End Sub Private Sub mnuOutpatientsMasterReport_Click() frmReportOutpatientMaster.Show

197
End Sub Private Sub mnuPatientAdmissionMasterReport_Click() frmReportPatientAdmission.Show End Sub Private Sub mnuPatientDischargeMasterReport_Click() frmReportPatientDischarge.Show End Sub Private Sub mnuRoomsMasterReport_Click() RptRoomsMaster.Show End Sub Private Sub mnuInpatientMedicines_Click() frmReportInpatientMedicalTreatment.Show End Sub Private Sub mnuOutpatientsMedicines_Click() frmReportOutpatientMedicalTreatments.Show End Sub Private Sub mnuInpatientsServices_Click() frmReportInpatientServiceTreatments.Show End Sub Private Sub mnuOutpatientsServices_Click() frmReportOutPatientPatientServiceTreatements.Show End Sub Private Sub mnuDoctorsChannelingSchedule_Click() RptAllDoctorsShedule.Show End Sub Private Sub mnuIndividualCompanyOutpatients_Click() RptIndividualCompanyOutpatients.Show End Sub Private Sub mnuIndividualCompanyInpatients_Click() RptIndividualCompanyInpatients.Show End Sub Private Sub mnuInpatientsRevenueReports_Click() frmReportInpatientRevenue.Show End Sub Private Sub mnuOutpatientsRevenueReports_Click() frmReportOutpatientRevenue.Show End Sub Private Sub mnuDoctorEarningsReports_Click() frmReportDoctorsEarnings.Show End Sub Private Sub mnuBillStatusReport_Click() frmReportAging.Show End Sub

FormMedicalTreatmentsOut:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Medical Treatments Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Medical_Treatments Table '-------------------------------------------------------------------------------Option Explicit

198
Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Medical Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdMedicineSearchWizard_Click() frmMedsSearchMeds.Show End Sub Private Sub cmdPatientSearchWizard_Click() frmOutpatientsSearchMeds.Show End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsMedicalTreatmentsOut 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'Save the user-entered data into the recordset .Fields(0) = txtTreatmentID.Text .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtMedicineID.Text .Fields(5) = txtMedicineName.Text .Fields(6) = txtDateOfIssue.Text .Fields(7) = txtUnitPrice.Text .Fields(8) = txtQty.Text .Fields(9) = txtTotal.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdGuardiansInfo_Click() 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True With rsMedicalTreatmentsOut 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value

199
txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub dgrdMedTreatmentInfo_Click() 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True With rsMedicalTreatmentsOut 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Medical_Treatments_Out 'Calling the Medical_Treatments Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button & Close Button cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchText.Enabled = True txtSearch.Enabled = True dgrdMedTreatmentInfo.Enabled = True Set dgrdMedTreatmentInfo.DataSource = rsMedicalTreatmentsOut 'Setting the DataSource of the DataGrid End Sub Public Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls

200
'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If Next End Function Public Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True With rsMedicalTreatmentsOut .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value

201
txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsMedicalTreatmentsOut .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsMedicalTreatmentsOut .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value

202
txtTotal.Text = .Fields(9).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button & Delete Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button & the Delete Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdMedicineSearchWizard.Enabled = True With rsMedicalTreatmentsOut .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtMedicineID.Text = .Fields(4).Value txtMedicineName.Text = .Fields(5).Value txtDateOfIssue.Text = .Fields(6).Value txtUnitPrice.Text = .Fields(7).Value txtQty.Text = .Fields(8).Value txtTotal.Text = .Fields(9).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Medicine ID textfield is empty If txtMedicineID.Text = "" Then txtMedicineID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtMedicineName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtUnitPrice.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else

203
txtMedicineID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtMedicineName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtUnitPrice.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Total textfield has been filled in If txtTotal.Text = "0" Then txtQty.BackColor = &H80000018 'Highlighting the textfield in a different colour txtTotal.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtQty.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtTotal.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub txtQty_Change() If txtQty.Text = "0" Then MsgBox "Error! The Figure Cannot Begin With Zero!", vbCritical, "Cannot Begin Figure With 0!" txtQty.Text = "" Exit Sub Else txtTotal.Text = Val(txtQty.Text) * Val(txtUnitPrice.Text) End If End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtQty_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 7200 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtSearch_Change() If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsMedicalTreatmentsOut 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex)

204
Case 0: .Filter = "[TreatmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button and the Delete Button cmdUpdate.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Medical_Treatments_Out Set dgrdMedTreatmentInfo.DataSource = rsMedicalTreatmentsOut End If End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormMedicinesSearchMeds:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Medicines_Maintenance 'Calling the Medicines_Maintenance Procedure to interact with the recordset Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdMedicinesInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub lblWizardHeader_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsMedicinesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[MedicineID] Like '" & txtSearch.Text & "%" & "'" Case 1:

205
.Filter = "[MedicineName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[DosageForm] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsMedicinesMaintenance.RecordCount > 0 Then With rsMedicinesMaintenance 'Reset the textfields with the selected record frmMedicalTreatmentsMaintenance.txtMedicineID.Text = .Fields(0).Value frmMedicalTreatmentsMaintenance.txtMedicineName.Text = .Fields(1).Value frmMedicalTreatmentsMaintenance.txtUnitPrice.Text = .Fields(3).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormMedicinesWizardOut:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Medicines_Maintenance 'Calling the Medicines_Maintenance Procedure to interact with the recordset Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdMedicinesInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsMedicinesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[MedicineID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[MedicineName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[DosageForm] Like '" & txtSearch.Text & "%" & "'"

206
End Select End With Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsMedicinesMaintenance.RecordCount > 0 Then With rsMedicinesMaintenance 'Reset the textfields with the selected record frmAddMedicalTreatmentsOut.txtMedicineID.Text = .Fields(0).Value frmAddMedicalTreatmentsOut.txtMedicineName.Text = .Fields(1).Value frmAddMedicalTreatmentsOut.txtUnitPrice.Text = .Fields(3).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormMedsSearchMeds:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Medicines_Maintenance 'Calling the Medicines_Maintenance Procedure to interact with the recordset Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdMedicinesInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub lblWizardHeader_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsMedicinesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[MedicineID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[MedicineName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[DosageForm] Like '" & txtSearch.Text & "%" & "'" End Select End With

207
Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsMedicinesMaintenance.RecordCount > 0 Then With rsMedicinesMaintenance 'Reset the textfields with the selected record frmMedicalTreatmentsOut.txtMedicineID.Text = .Fields(0).Value frmMedicalTreatmentsOut.txtMedicineName.Text = .Fields(1).Value frmMedicalTreatmentsOut.txtUnitPrice.Text = .Fields(3).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormOPDCreateBill:'---------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Outpatients Create Bill Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Outpatient_Billing Table '---------------------------------------------------------------------------'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'This variable will hold the invoice ID when saving for the purpose of report generation. Dim invoiceid As String Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdGO_Click() If Val(txtAmountPaid.Text) <> Val(txtTotalPayable.Text) Then MsgBox "Error! The Amount Paid Has To Be Equal To The Total Payable!", vbCritical, "Amount Paid Has To Equal Total Payable!" txtBillStatus.Text = "UNPAID" txtAmountPaid.Text = "" Exit Sub Else txtBillStatus.Text = "PAID" End If cmdGO.Enabled = False txtAmountPaid.Enabled = False End Sub

208
Private Sub cmdOK_Click() 'Here, I am checking to ensure that the user does not type in a value that is lower than the Amount Paid If Val(txtTotalRecieved.Text) < Val(txtAmountPaid.Text) Then MsgBox "Error! The Total Received Cannot Be Less Than The Amount Paid!", vbCritical, "Figure Is Too Low!" txtTotalRecieved.Text = "0" Exit Sub End If 'Calculating the balance to be given to the user txtBalance.Text = Val(txtTotalRecieved.Text) - Val(txtAmountPaid.Text) cmdOK.Enabled = False txtTotalRecieved.Enabled = False txtBalance.Enabled = False End Sub Private Sub cmdPrint_Click() On Error GoTo e DataEnvironment1.Commands("OutpatientReceipt").Parameters(0) = invoiceid RptOutpatientReceipt.Show DataEnvironment1.rsOutpatientReceipt.Close Unload Me Exit Sub e: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End If End Sub Private Sub cmdSave_Click() 'Checking if the user has filled in the Payment Plan frame If optCheque.Value <> True And optCash.Value <> True And optCreditCard.Value <> True Then MsgBox "Error! You Have Not Chosen A Payment Type!", vbCritical, "Please Choose Payment Type!" Exit Sub End If 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsOutpatientBilling 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Record This Payment?", vbYesNo + vbQuestion, "Record Payment?") = vbYes Then 'The following block of if else conditions ensure that no 'textfield will be completely blank when saving in the database. 'This has been done in order to avoid errors. If txtChequeNo.Text = "" Then txtChequeNo.Text = "-" End If If txtCardNo.Text = "" Then txtCardNo.Text = "-" End If If txtBankName.Text = "" Then txtBankName.Text = "-" End If If txtDiscount.Text = "" Then txtDiscount.Text = "-" End If 'Save the user-entered data into the recordset .Fields(0) = txtInvoiceID.Text invoiceid = txtInvoiceID.Text .Fields(1) = txtBillingDate.Text .Fields(2) = txtPatientID.Text .Fields(3) = txtPatientName.Text

209
.Fields(4) = txtAccountType.Text .Fields(5) = txtTotalCost.Text .Fields(6) = txtDiscount.Text .Fields(7) = txtTotalPayable.Text .Fields(8) = txtAmountPaid.Text .Fields(9) = txtBillStatus.Text If optCheque.Value = True Then .Fields(10).Value = "Cheque" ElseIf optCash.Value = True Then .Fields(10).Value = "Cash" ElseIf optCreditCard.Value = True Then .Fields(10).Value = "CreditCard" End If .Fields(11) = txtChequeNo.Text .Fields(12) = txtCardNo.Text .Fields(13) = txtBankName.Text .Fields(14) = txtTotalRecieved.Text .Fields(15) = txtBalance.Text .Update 'Display Success Message MsgBox "The Payment Was Recorded Successfully!", vbInformation, "Payment Recorded Successfully!" Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure End If .Requery 'Requerying the Table End With End If cmdPrint.Enabled = True 'Enabling the Print button End Sub Private Sub Form_Load() End Sub Private Sub optCash_Click() 'Here, I am checking to see if the Payment Info frame has been filled If txtAmountPaid.Text = "0" Then MsgBox "Error! Please Fill-in The Payment Info Frame First!", vbCritical, "Payment Info Missing!" Exit Sub End If disablePaymentPlan 'Calling a function to diable all fields in the Payment Plan frame lblTotalRecieved.Enabled = True txtTotalRecieved.Enabled = True lblBalance.Enabled = True txtBalance.Enabled = True cmdOK.Enabled = True End Sub Private Sub optCheque_Click() 'Here, I am checking to see if the Payment Info frame has been filled If txtAmountPaid.Text = "0" Then MsgBox "Error! Please Fill-in The Payment Info Frame First!", vbCritical, "Payment Info Missing!" Exit Sub End If disablePaymentPlan 'Calling a function to diable all fields in the Payment Plan frame lblChequeNo.Enabled = True txtChequeNo.Enabled = True lblBankName.Enabled = True txtBankName.Enabled = True End Sub

210
Private Sub optCreditCard_Click() 'Here, I am checking to see if the Payment Info frame has been filled If txtAmountPaid.Text = "0" Then MsgBox "Error! Please Fill-in The Payment Info Frame First!", vbCritical, "Payment Info Missing!" Exit Sub End If disablePaymentPlan 'Calling a function to diable all fields in the Payment Plan frame lblCardNo.Enabled = True txtCardNo.Enabled = True lblBankName.Enabled = True txtBankName.Enabled = True End Sub Public Function disablePaymentPlan() 'This function will disable all fields in the Payment Plan frame lblChequeNo.Enabled = False txtChequeNo.Enabled = False lblCardNo.Enabled = False txtCardNo.Enabled = False lblBankName.Enabled = False txtBankName.Enabled = False lblTotalRecieved.Enabled = False txtTotalRecieved.Enabled = False lblBalance.Enabled = False txtBalance.Enabled = False End Function Private Sub txtAmountPaid_GotFocus() txtAmountPaid.Text = "" End Sub Private Sub txtAmountPaid_LostFocus() If txtAmountPaid.Text = "" Then txtAmountPaid.Text = "0" End If End Sub Private Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i=i+1 End If End Sub Private Sub txtAmountPaid_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 2400 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Private Sub txtTotalRecieved_GotFocus() txtTotalRecieved.Text = "" End Sub Private Sub txtTotalRecieved_LostFocus() If txtTotalRecieved.Text = "" Then txtTotalRecieved.Text = "0"

211
End If End Sub Private Sub txtTotalRecieved_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 6120 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End If End Sub Public Function textfieldsValidations() Flag = True 'Setting the Flag variable to True 'Checking if the Amount Paid textfield is empty If txtAmountPaid.Text = "0" Then txtAmountPaid.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtAmountPaid.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Cheque No textfield is empty If txtChequeNo.Enabled = True Then If txtChequeNo.Text = "-" Then txtChequeNo.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtChequeNo.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Checking if the Card No textfield is empty If txtCardNo.Enabled = True Then If txtCardNo.Text = "-" Then txtCardNo.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtCardNo.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Checking if the Bank Name textfield is empty If txtBankName.Enabled = True Then If txtBankName.Text = "-" Then txtBankName.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtBankName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If 'Checking if the Total Recieved textfield is empty If txtTotalRecieved.Enabled = True Then If txtTotalRecieved.Text = "0" Then txtTotalRecieved.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtTotalRecieved.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If End If

212
'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function

FormOPDOverallBilling:'----------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Outpatient Overall Billing Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: '----------------------------------------------------------------------------Option Explicit 'The following variables will be used to autogenerate the Invoice ID Dim iNumOfRecords As Integer 'This variable holds the number of records in the table Dim strCode As String 'This variable will eventually hold the Invoice ID to be autogenerated Dim iNumberOfRecords As Integer 'This variable will hold the number of records in the Inpatient_Payment_Details table Dim strDisplay As String 'This variable will eventually display the OverallInBillID in the invisible textfield Dim iTotalPayable As Double 'This variable will hold the value of the Total Payable Dim billID As String 'This variable will hold the Billing ID for the purpose of report generation. Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub cmdGoToPayments_Click() 'Ensuring that the user has selected a patient If txtPatientID.Text = "" Then MsgBox "You Cannot Go To The Payments Process Until You Select A Patient!", vbCritical, "Please Select A Patient!" Exit Sub End If Call Outpatient_Billing With rsOutpatientBilling .MoveFirst Do While .EOF = False If .Fields(2).Value = txtPatientID.Text Then MsgBox "This Patient Has Already Settled The Bill!", vbCritical, "Bill Already Settled!" Exit Sub Else .MoveNext End If Loop End With

213
Call Outpatient_Billing 'Calling the Outpatient_Billing Procedure to interact with the recordset 'Generate Invoice ID By Utilizing the Outpatient_Billing Table With rsOutpatientBilling If .RecordCount = 0 Then 'If there are no records in the table strCode = "OIN0001" Else 'Calculating the number of records and storing in a variable iNumOfRecords = .RecordCount iNumOfRecords = iNumOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Outpatient_Billing Table If iNumOfRecords < 10 Then strCode = "OIN000" & iNumOfRecords ElseIf iNumOfRecords < 100 Then strCode = "OIN00" & iNumOfRecords ElseIf iNumOfRecords < 1000 Then strCode = "OIN0" & iNumOfRecords ElseIf iNumOfRecords < 10000 Then strCode = "OIN" & iNumOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With iTotalPayable = Int(Val(txtNettTotal.Text)) 'Storing the Nett Total in this variable 'The following line of code will enter the autogenerated Invoice ID into the relevant textfield frmOPDCreateBill.txtInvoiceID.Text = strCode 'Entering all relevant data onto the Payment Form frmOPDCreateBill.txtBillingDate.Text = DateTime.Date 'System Date frmOPDCreateBill.txtPatientID.Text = txtPatientID.Text frmOPDCreateBill.txtPatientName.Text = txtFirstName.Text & " " & txtSurname.Text frmOPDCreateBill.txtAccountType.Text = txtAccountType.Text frmOPDCreateBill.txtTotalCost.Text = txtTotal.Text frmOPDCreateBill.txtDiscount.Text = txtDiscount.Text frmOPDCreateBill.txtTotalPayable.Text = iTotalPayable Unload Me 'Closing this form frmOPDCreateBill.Show 'Opening Up The Payments Form Exit Sub End Sub Private Sub cmdOutpatientSearchWizard_Click() frmOutpatientSearchBilling.Show End Sub Private Sub cmdPrint_Click() On Error GoTo e DataEnvironment1.Commands("OutpatientInvoice").Parameters(0) = billID 'Passing the value of the variable as a parameter. RptOutpatientInvoice.Show DataEnvironment1.rsOutpatientInvoice.Close Unload Me Exit Sub If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End If End Sub Private Sub cmdSave_Click() 'Ensuring that the user has selected a patient If txtPatientID.Text = "" Then MsgBox "Error! You Have Not Selected A Patient!", vbCritical, "Please Select A Patient!" Exit Sub

214
End If Call Outpatient_Payment_Details 'Calling the Outpatient_Payment_Details Procedure to interact with the recordset 'Generate OverallOutBillID By Utilizing the Outpatient_Payment_Details Table With rsOutpatientPaymentDetails If .RecordCount = 0 Then 'If there are no records in the table strDisplay = "OPD0001" Else 'Calculating the number of records and storing in a variable iNumberOfRecords = .RecordCount iNumberOfRecords = iNumberOfRecords + 1 'incrementing the number by 1 'The following block of code will generate the ID according 'to the number of records in the Outpatient_Payment_Details Table If iNumberOfRecords < 10 Then strDisplay = "OPD000" & iNumberOfRecords ElseIf iNumberOfRecords < 100 Then strDisplay = "OPD00" & iNumberOfRecords ElseIf iNumberOfRecords < 1000 Then strDisplay = "OPD0" & iNumberOfRecords ElseIf iNumberOfRecords < 10000 Then strDisplay = "OPD" & iNumberOfRecords End If End If .Requery 'Requerying the Table .AddNew 'Adding a new recordset End With 'The following line of code will enter the autogenerated OverallOutBillID 'into the invisible OverallOutBillID textfield txtOverallOutBillID.Text = strDisplay 'Here, I am ensuring that the Discount textfield is not empty when I save If txtDiscount.Text = "" Then txtDiscount.Text = "-" End If 'Now I am going to save the record in the database With rsOutpatientPaymentDetails 'Making sure that the user wants to save the record If MsgBox("Are You Sure You Wish To Save This Record?", vbYesNo + vbQuestion, "Save This Record?") = vbYes Then .Fields(0) = txtOverallOutBillID.Text billID = txtOverallOutBillID.Text 'Storing values in a variable .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtAccountType.Text .Fields(5) = txtAssignedDoctorID.Text .Fields(6) = txtDoctorsCharges.Text .Fields(7) = txtHospitalCharges.Text .Fields(8) = txtTotal.Text .Fields(9) = txtVAT.Text .Fields(10) = txtDiscount.Text .Fields(11) = txtNettTotal.Text .Update 'Display Success Message MsgBox "The Record Was Saved Successfully!", vbInformation, "Succesful Save Procedure!" Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Save Procedure End If

215
End With cmdPrint.Enabled = True 'Enabling the Print button End Sub Private Sub Form_Load() End Sub

FormOPTSearchTreatments:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdOutpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsOutpatientsMaintenance.RecordCount > 0 Then

216
With rsOutpatientsMaintenance 'Reset the textfields with the selected record frmServiceTreatmentsOut.txtPatientID.Text = .Fields(0).Value frmServiceTreatmentsOut.txtFirstName.Text = .Fields(1).Value frmServiceTreatmentsOut.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormOutpatientSearchBilling:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Dim strCorporateID As String 'This variable will hold the Corporate ID of the sponsoring company Dim strDoctorID As String 'This variable will hold the Assigned Doctor's ID Dim totalWithoutDiscount As Double 'This variable will hold the addition of the Total and The VAT Dim totalWithDiscount As Double 'This variable will hold the Total after subtracting the discount Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdOutpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'"

217
Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsOutpatientsMaintenance.RecordCount > 0 Then With rsOutpatientsMaintenance 'Reset the textfields with the selected record frmOPDOverallBilling.txtPatientID.Text = .Fields(0).Value frmOPDOverallBilling.txtFirstName.Text = .Fields(1).Value frmOPDOverallBilling.txtSurname.Text = .Fields(2).Value frmOPDOverallBilling.txtAccountType.Text = .Fields(11).Value strCorporateID = .Fields(12).Value frmOPDOverallBilling.txtAssignedDoctorID.Text = .Fields(14).Value End With 'Here, I am including the corporate discount if the patient is a corporate patient If frmOPDOverallBilling.txtAccountType.Text = "Corporate" Then Call Companies_Maintenance 'Calling the Companies_Maintenance recordset With rsCompaniesMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = strCorporateID Then frmOPDOverallBilling.txtDiscount = .Fields(6).Value Exit Do Else .MoveNext End If Loop End With Else frmOPDOverallBilling.txtDiscount.Text = "" End If 'Here, I am calculating the Doctor's Charges Call Doctors_Maintenance With rsDoctorsMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = frmOPDOverallBilling.txtAssignedDoctorID.Text Then frmOPDOverallBilling.txtDoctorsCharges.Text = .Fields(12).Value Exit Do Else .MoveNext End If Loop End With 'Here, I am displaying the Hospital Charges frmOPDOverallBilling.txtHospitalCharges.Text = 1000 'Here, I am calculating the total of all costs frmOPDOverallBilling.txtTotal.Text = Val(frmOPDOverallBilling.txtDoctorsCharges.Text) + Val(frmOPDOverallBilling.txtHospitalCharges.Text) 'Here, I am calculating the VAT amount frmOPDOverallBilling.txtVAT.Text = Val(frmOPDOverallBilling.txtTotal.Text) * 0.15

218
'Here, I am calculating the NETT TOTAL If frmOPDOverallBilling.txtDiscount.Text = "" Then frmOPDOverallBilling.txtNettTotal.Text = Val(frmOPDOverallBilling.txtTotal.Text) + Val(frmOPDOverallBilling.txtVAT.Text) Else totalWithoutDiscount = Val(frmOPDOverallBilling.txtTotal.Text) + Val(frmOPDOverallBilling.txtVAT.Text) totalWithDiscount = totalWithoutDiscount - ((Val(frmOPDOverallBilling.txtDiscount.Text) / 100) * totalWithoutDiscount) frmOPDOverallBilling.txtNettTotal.Text = totalWithDiscount End If Unload Me 'Unloading the form Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormOutpatientSearchMeds:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdOutpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub lblWizardHeader_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5:

219
.Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsOutpatientsMaintenance.RecordCount > 0 Then With rsOutpatientsMaintenance 'Reset the textfields with the selected record frmAddMedicalTreatmentsOut.txtPatientID.Text = .Fields(0).Value frmAddMedicalTreatmentsOut.txtFirstName.Text = .Fields(1).Value frmAddMedicalTreatmentsOut.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormOutpatientsSearchAndFind:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdOutpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'"

220
Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsOutpatientsMaintenance.RecordCount > 0 Then With rsOutpatientsMaintenance 'Reset the textfields with the selected record frmAddServiceTreatmentsOut.txtPatientID.Text = .Fields(0).Value frmAddServiceTreatmentsOut.txtFirstName.Text = .Fields(1).Value frmAddServiceTreatmentsOut.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormOutpatientsSearchMeds:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdOutpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub lblWizardHeader_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientsMaintenance 'Filter the Records As The User Types, According to the Criteria

221
Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsOutpatientsMaintenance.RecordCount > 0 Then With rsOutpatientsMaintenance 'Reset the textfields with the selected record frmMedicalTreatmentsOut.txtPatientID.Text = .Fields(0).Value frmMedicalTreatmentsOut.txtFirstName.Text = .Fields(1).Value frmMedicalTreatmentsOut.txtSurname.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormOutpatientsSearchWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard 'Calling the clearAllFields procedure in the Outpatients Admission Form frmOutpatientsMaintenance.clearAllFields 'Calling the Form_Load procedure in the Outpatients Admission Form frmOutpatientsMaintenance.Form_Load End Sub Private Sub dgrdOutpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Outpatients_Maintenance 'Calling the Outpatients_Maintenance Procedure to interact with the recordset

222
Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientsMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsOutpatientsMaintenance.RecordCount > 0 Then With rsOutpatientsMaintenance 'Reset the textfields with the selected record frmOutpatientsMaintenance.txtPatientID.Text = .Fields(0).Value frmOutpatientsMaintenance.txtFirstName.Text = .Fields(1).Value frmOutpatientsMaintenance.txtSurname.Text = .Fields(2).Value frmOutpatientsMaintenance.cboGender.Text = .Fields(3).Value frmOutpatientsMaintenance.dtpDateOfBirth.Value = .Fields(4).Value frmOutpatientsMaintenance.txtNICNumber.Text = .Fields(5).Value frmOutpatientsMaintenance.txtAddress.Text = .Fields(6).Value frmOutpatientsMaintenance.txtPhoneHome.Text = .Fields(7).Value frmOutpatientsMaintenance.txtPhoneMob.Text = .Fields(8).Value frmOutpatientsMaintenance.txtPatientOccupation.Text = .Fields(9).Value frmOutpatientsMaintenance.cboCivilStatus.Text = .Fields(10).Value frmOutpatientsMaintenance.cboAccountType.Text = .Fields(11).Value frmOutpatientsMaintenance.txtCompanyID.Text = .Fields(12).Value frmOutpatientsMaintenance.txtCompanyName.Text = .Fields(13).Value frmOutpatientsMaintenance.txtAssignedDoctorID.Text = .Fields(14).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

223 FormPaymentOptions:Private Sub cmdInpatient_Click() frmIPDOverallBilling.Show Unload Me End Sub Private Sub cmdOutpatient_Click() frmOPDOverallBilling.Show Unload Me End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub imgbg2_Click(Index As Integer) End Sub

FormQuickLaunch:Private Sub cmdAbout_Click() frmAbout.Show End Sub Private Sub Form_Load() lblDisplayTimeIn.Caption = DateTime.Time lblCurrentDateTime.Caption = "Today is " & FormatDateTime(Now, vbLongDate) End Sub Private Sub lblDisplayPresentTime_Click() End Sub Private Sub tmrTimer_Timer() lblDisplayPresentTime.Caption = DateTime.Time End Sub

FormReferringDoctorWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call ReferringDoctor_Selection 'Calling the ReferringDoctor_Selection Procedure to interact with the recordset Set dgrdReferringDoctorsInfoTable.DataSource = rsReferringDoctor 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdReferringDoctorsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsReferringDoctor 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex)

224
Case 0: .Filter = "[DoctorID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Gender] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[LicenceNo] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[Specialization] Like '" & txtSearch.Text & "%" & "'" Case 7: .Filter = "[DoctorCategory] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdReferringDoctorsInfoTable.DataSource = rsReferringDoctor 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsReferringDoctor.RecordCount > 0 Then With rsReferringDoctor 'Reset the textfields with the selected record frmAdmitPatient.txtReferredDoctorID.Text = .Fields(0).Value frmAdmitPatient.txtReferredDoctorName.Text = "Dr." & .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

Form ReportsQuickLaunch FormRoomBookings FormRoomsSearchWizard FormSearchEngine:'------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Search Engine 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: '-------------------------------------------------------------------------------Option Explicit Private Sub cboInfoTable_Click() Dim strTitle As String

225
cboInfoType.Clear Select Case (cboInfoTable.ListIndex) Case 0: 'Inpatient Information With cboInfoType .AddItem "Patient ID", 0 .AddItem "First Name", 1 .AddItem "Surname", 2 .AddItem "NIC Number", 3 .AddItem "Account Type", 4 .AddItem "Company ID", 5 .AddItem "Company Name", 6 End With strTitle = cboInfoTable.List(0) & " Table" Set dgrdInformation.DataSource = rsInpatientMaintenance txtSearchData.Text = "" 'Clearing the textfield Case 1: 'Outpatient Information With cboInfoType .AddItem "Patient ID", 0 .AddItem "First Name", 1 .AddItem "Surname", 2 .AddItem "NIC Number", 3 .AddItem "Account Type", 4 .AddItem "Company ID", 5 .AddItem "Company Name", 6 End With strTitle = cboInfoTable.List(1) & " Table" Set dgrdInformation.DataSource = rsOutpatientsMaintenance txtSearchData.Text = "" 'Clearing the textfield Case 2: 'Inpatient Payments With cboInfoType .AddItem "Patient ID", 0 .AddItem "Patient Name", 1 End With strTitle = cboInfoTable.List(2) & " Table" Set dgrdInformation.DataSource = rsInpatientBilling txtSearchData.Text = "" 'Clearing the textfield Case 3: 'Outpatient Payments With cboInfoType .AddItem "Patient ID", 0 .AddItem "Patient Name", 1 End With strTitle = cboInfoTable.List(3) & " Table" Set dgrdInformation.DataSource = rsOutpatientBilling txtSearchData.Text = "" 'Clearing the textfield Case 4: 'Doctors Maintenance With cboInfoType .AddItem "Doctor ID", 0 .AddItem "First Name", 1 .AddItem "Surname", 2 .AddItem "Gender", 3 .AddItem "NIC Number", 4 .AddItem "License Number", 5 .AddItem "Specialization", 6 End With strTitle = cboInfoTable.List(4) & " Table" Set dgrdInformation.DataSource = rsDoctorsMaintenance txtSearchData.Text = "" 'Clearing the textfield Case 5: 'Doctors Channeling Schedule With cboInfoType

226
.AddItem "Doctor ID", 0 End With strTitle = cboInfoTable.List(5) & " Table" Set dgrdInformation.DataSource = rsDoctorSchedule txtSearchData.Text = "" 'Clearing the textfield End Select cboInfoType.Text = "--------------------SELECT-------------------" cboInfoType.Enabled = True dgrdInformation.Caption = strTitle End Sub Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub Form_Load() Call Connection Call Inpatients_Maintenance Call Outpatients_Maintenance Call Inpatient_Billing Call Outpatient_Billing Call Doctors_Maintenance Call Doctor_Schedule End Sub Private Sub txtSearchData_Change() On Error GoTo backload If cboInfoType.ListIndex <> -1 Then If cboInfoTable.ListIndex = 0 Then 'Inpatients Information If Len(txtSearchData.Text) > 0 Then '-----Select the Type of search and filter the record Select Case (cboInfoType.ListIndex) Case 0: rsInpatientMaintenance.Filter = "PatientID Like '" & txtSearchData.Text & "%" & "'" Case 1: rsInpatientMaintenance.Filter = "FirstName Like '" & txtSearchData.Text & "%" & "'" Case 2: rsInpatientMaintenance.Filter = "Surname Like '" & txtSearchData.Text & "%" & "'" Case 3: rsInpatientMaintenance.Filter = "NICNumber Like '" & txtSearchData.Text & "%" & "'" Case 4: rsInpatientMaintenance.Filter = "AccountType Like '" & txtSearchData.Text & "%" & "'" Case 5: rsInpatientMaintenance.Filter = "CompanyID Like '" & txtSearchData.Text & "%" & "'" Case 6: rsInpatientMaintenance.Filter = "CompanyName Like '" & txtSearchData.Text & "%" & "'" End Select Else Call Inpatients_Maintenance Set dgrdInformation.DataSource = rsInpatientMaintenance End If ElseIf cboInfoTable.ListIndex = 1 Then 'Outpatients Information If Len(txtSearchData.Text) > 0 Then '-----Select the Type of search and filter the record Select Case (cboInfoType.ListIndex) Case 0: rsOutpatientsMaintenance.Filter = "PatientID Like '" & txtSearchData.Text & "%" & "'" Case 1:

227
rsOutpatientsMaintenance.Filter = "FirstName Like '" & txtSearchData.Text & "%" & "'" Case 2: rsOutpatientsMaintenance.Filter = "Surname Like '" & txtSearchData.Text & "%" & "'" Case 3: rsOutpatientsMaintenance.Filter = "NICNumber Like '" & txtSearchData.Text & "%" & "'" Case 4: rsOutpatientsMaintenance.Filter = "AccountType Like '" & txtSearchData.Text & "%" & "'" Case 5: rsOutpatientsMaintenance.Filter = "CompanyID Like '" & txtSearchData.Text & "%" & "'" Case 6: rsOutpatientsMaintenance.Filter = "CompanyName Like '" & txtSearchData.Text & "%" & "'" End Select Else Call Outpatients_Maintenance Set dgrdInformation.DataSource = rsOutpatientsMaintenance End If ElseIf cboInfoTable.ListIndex = 2 Then 'Inpatient Payments If Len(txtSearchData.Text) > 0 Then '-----Select the Type of search and filter the record Select Case (cboInfoType.ListIndex) Case 0: rsInpatientBilling.Filter = "PatientID Like '" & txtSearchData.Text & "%" & "'" Case 1: rsInpatientBilling.Filter = "PatientName Like '" & txtSearchData.Text & "%" & "'" End Select Else Call Inpatient_Billing Set dgrdInformation.DataSource = rsInpatientBilling End If ElseIf cboInfoTable.ListIndex = 3 Then 'Outpatient Payments If Len(txtSearchData.Text) > 0 Then '-----Select the Type of search and filter the record Select Case (cboInfoType.ListIndex) Case 0: rsOutpatientBilling.Filter = "PatientID Like '" & txtSearchData.Text & "%" & "'" Case 1: rsOutpatientBilling.Filter = "PatientName Like '" & txtSearchData.Text & "%" & "'" End Select Else Call Outpatient_Billing Set dgrdInformation.DataSource = rsOutpatientBilling End If ElseIf cboInfoTable.ListIndex = 4 Then 'Doctors Information If Len(txtSearchData.Text) > 0 Then '-----Select the Type of search and filter the record Select Case (cboInfoType.ListIndex) Case 0: rsDoctorsMaintenance.Filter = "DoctorID Like '" & txtSearchData.Text & "%" & "'" Case 1: rsDoctorsMaintenance.Filter = "FirstName Like '" & txtSearchData.Text & "%" & "'" Case 2: rsDoctorsMaintenance.Filter = "Surname Like '" & txtSearchData.Text & "%" & "'" Case 3: rsDoctorsMaintenance.Filter = "Gender Like '" & txtSearchData.Text & "%" & "'" Case 4: rsDoctorsMaintenance.Filter = "NICNumber Like '" & txtSearchData.Text & "%" & "'" Case 5: rsDoctorsMaintenance.Filter = "LicenseNo Like '" & txtSearchData.Text & "%" & "'" Case 6:

228
rsDoctorsMaintenance.Filter = "Specialization Like '" & txtSearchData.Text & "%" & "'" End Select Else Call Doctors_Maintenance Set dgrdInformation.DataSource = rsDoctorsMaintenance End If ElseIf cboInfoTable.ListIndex = 5 Then 'Doctor's Channeling Schedule If Len(txtSearchData.Text) > 0 Then '-----Select the Type of search and filter the record Select Case (cboInfoType.ListIndex) Case 0: rsDoctorSchedule.Filter = "DoctorID Like '" & txtSearchData.Text & "%" & "'" End Select Else Call Doctor_Schedule Set dgrdInformation.DataSource = rsDoctorSchedule End If End If Else If txtSearchData = "" Then MsgBox "Please Select A Search Criteria!", vbExclamation, "No Search Criteria!" End If txtSearchData = "" End If Exit Sub backload: Call Form_Load End Sub

FormSearchMedsWizard:FormSearchOutpatientPayments:'------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Payments Search Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Outpatient_Billing '-------------------------------------------------------------------------------Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub Form_Load() Call Outpatient_Billing Set dgrdOutpatientsBillingInfo.DataSource = rsOutpatientBilling End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsOutpatientBilling 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0:

229
.Filter = "[InvoiceID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[PatientName] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" End Select End With Else Call Outpatient_Billing Set dgrdOutpatientsBillingInfo.DataSource = rsOutpatientBilling End If End Sub

FormSearchPayments:'------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Search Payments Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Inpatient_Billing '-------------------------------------------------------------------------------Private Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub Private Sub Form_Load() Call Inpatient_Billing Set dgrdInpatientsBillingInfo.DataSource = rsInpatientBilling End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientBilling 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[InvoiceID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[AdmissionID] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[PatientName] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" End Select End With Else Call Inpatient_Billing Set dgrdInpatientsBillingInfo.DataSource = rsInpatientBilling End If

230
End Sub

FormSearchServicesWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Services_Maintenance 'Calling the Services_Maintenance Procedure to interact with the recordset Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdServicesInformation_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsServicesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[ServiceID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[ServiceName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsServicesMaintenance.RecordCount > 0 Then With rsServicesMaintenance 'Reset the textfields with the selected record frmServiceTreatmentsOut.txtServiceID.Text = .Fields(0).Value frmServiceTreatmentsOut.txtServiceName.Text = .Fields(1).Value frmServiceTreatmentsOut.txtServiceCharge.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

Form Select A Day:-

231
Private Sub Form_Load() If frmChannelingAppointments.txtChosenDay.Text = "Monday" Then optMonday.Value = True ElseIf frmChannelingAppointments.txtChosenDay.Text = "Tuesday" Then optTuesday.Value = True ElseIf frmChannelingAppointments.txtChosenDay.Text = "Wednesday" Then optWednesday.Value = True ElseIf frmChannelingAppointments.txtChosenDay.Text = "Thursday" Then optThursday.Value = True ElseIf frmChannelingAppointments.txtChosenDay.Text = "Friday" Then optFriday.Value = True ElseIf frmChannelingAppointments.txtChosenDay.Text = "Saturday" Then optSaturday.Value = True ElseIf frmChannelingAppointments.txtChosenDay.Text = "Sunday" Then optSunday.Value = True End If Call Connection 'Call Connection Procedure To Establish Connection With The Database Call Doctor_Schedule 'Calling the Doctor_Schedule Procedure To Interact With The Recordset With rsDoctorSchedule .MoveFirst 'Move To The First Record While .EOF = False 'Running Through All The Records 'Here, I Am Checking The Doctor ID In Order To I Find A Match If .Fields(1).Value = frmChannelingAppointments.txtDoctorID.Text Then 'In The Following Blocks Of If Else Conditions, I am enabling 'the DateTime Pickers if the times have already been set. 'Therefore for a new doctor, none of the DateTime Pickers 'will be enabled. If .Fields(2).Value <> "" Then chkMonday.Value = 1 dtpMondayStartTime.Enabled = True dtpMondayEndTime.Enabled = True dtpMondayStartTime.Value = .Fields(2).Value dtpMondayEndTime.Value = .Fields(3).Value End If If .Fields(4).Value <> "" Then chkTuesday.Value = 1 dtpTuesdayStartTime.Enabled = True dtpTuesdayEndTime.Enabled = True dtpTuesdayStartTime.Value = .Fields(4).Value dtpTuesdayEndTime.Value = .Fields(5).Value End If If .Fields(6).Value <> "" Then chkWednesday.Value = 1 dtpWednesdayStartTime.Enabled = True dtpWednesdayEndTime.Enabled = True dtpWednesdayStartTime.Value = .Fields(6).Value dtpWednesdayEndTime.Value = .Fields(7).Value End If If .Fields(8).Value <> "" Then chkThursday.Value = 1 dtpThursdayStartTime.Enabled = True dtpThursdayEndTime.Enabled = True dtpThursdayStartTime.Value = .Fields(8).Value dtpThursdayEndTime.Value = .Fields(9).Value End If If .Fields(10).Value <> "" Then chkFriday.Value = 1 dtpFridayStartTime.Enabled = True dtpFridayEndTime.Enabled = True

232
dtpFridayStartTime.Value = .Fields(10).Value dtpFridayEndTime.Value = .Fields(11).Value End If If .Fields(12).Value <> "" Then chkSaturday.Value = 1 dtpSaturdayStartTime.Enabled = True dtpSaturdayEndTime.Enabled = True dtpSaturdayStartTime.Value = .Fields(12).Value dtpSaturdayEndTime.Value = .Fields(13).Value End If If .Fields(14).Value <> "" Then chkSunday.Value = 1 dtpSundayStartTime.Enabled = True dtpSundayEndTime.Enabled = True dtpSundayStartTime.Value = .Fields(14).Value dtpSundayEndTime.Value = .Fields(15).Value End If End If .MoveNext 'Moving to the next record Wend End With If chkMonday.Value = 1 Then optMonday.Enabled = True End If If chkTuesday.Value = 1 Then optTuesday.Enabled = True End If If chkWednesday.Value = 1 Then optWednesday.Enabled = True End If If chkThursday.Value = 1 Then optThursday.Enabled = True End If If chkFriday.Value = 1 Then optFriday.Enabled = True End If If chkSaturday.Value = 1 Then optSaturday.Enabled = True End If If chkSunday.Value = 1 Then optSunday.Enabled = True End If End Sub Private Sub chkMonday_Click() 'Enabling the DateTime Pickers If chkMonday.Value = 1 Then dtpMondayStartTime.Enabled = True dtpMondayEndTime.Enabled = True Else dtpMondayStartTime.Enabled = False dtpMondayEndTime.Enabled = False End If End Sub Private Sub chkTuesday_Click() 'Enabling the DateTime Pickers If chkTuesday.Value = 1 Then dtpTuesdayStartTime.Enabled = True dtpTuesdayEndTime.Enabled = True Else dtpTuesdayStartTime.Enabled = False dtpTuesdayEndTime.Enabled = False

233
End If End Sub Private Sub chkWednesday_Click()

'Enabling the DateTime Pickers

If chkWednesday.Value = 1 Then dtpWednesdayStartTime.Enabled = True dtpWednesdayEndTime.Enabled = True Else dtpWednesdayStartTime.Enabled = False dtpWednesdayEndTime.Enabled = False End If End Sub Private Sub chkThursday_Click() 'Enabling the DateTime Pickers If chkThursday.Value = 1 Then dtpThursdayStartTime.Enabled = True dtpThursdayEndTime.Enabled = True Else dtpThursdayStartTime.Enabled = False dtpThursdayEndTime.Enabled = False End If End Sub Private Sub chkFriday_Click() 'Enabling the DateTime Pickers If chkFriday.Value = 1 Then dtpFridayStartTime.Enabled = True dtpFridayEndTime.Enabled = True Else dtpFridayStartTime.Enabled = False dtpFridayEndTime.Enabled = False End If End Sub Private Sub chkSaturday_Click() 'Enabling the DateTime Pickers If chkSaturday.Value = 1 Then dtpSaturdayStartTime.Enabled = True dtpSaturdayEndTime.Enabled = True Else dtpSaturdayStartTime.Enabled = False dtpSaturdayEndTime.Enabled = False End If End Sub Private Sub chkSunday_Click() 'Enabling the DateTime Pickers If chkSunday.Value = 1 Then dtpSundayStartTime.Enabled = True dtpSundayEndTime.Enabled = True Else dtpSundayStartTime.Enabled = False dtpSundayEndTime.Enabled = False End If End Sub Private Sub cmdOK_Click() Dim checkFlag As Boolean 'This variable wil help me to decide if any of the option buttons have been selected checkFlag = False Dim ctrl As Control 'This is a control variable which I will be using to run through all the option buttons On Error Resume Next For Each ctrl In Controls 'This is a For loop that will check if any of the option buttons have been selected If TypeOf ctrl Is OptionButton Then If ctrl.Value = True Then checkFlag = True

234
Exit For End If End If Next If checkFlag = False Then 'Display Error Message MsgBox "Error! You have Not Selected An Option Button!", vbCritical, "Error! No Selection!" Exit Sub End If 'Enabling relevant components on the Channeling form frmChannelingAppointments.txtChosenDay.Enabled = True frmChannelingAppointments.dtpChosenDate.Enabled = True 'Setting the relevant start times and end times on the channeling form If optMonday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Monday" frmChannelingAppointments.dtpStartTime.Value = dtpMondayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpMondayEndTime.Value End If If optTuesday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Tuesday" frmChannelingAppointments.dtpStartTime.Value = dtpTuesdayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpTuesdayEndTime.Value End If If optWednesday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Wednesday" frmChannelingAppointments.dtpStartTime.Value = dtpWednesdayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpWednesdayEndTime.Value End If If optThursday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Thursday" frmChannelingAppointments.dtpStartTime.Value = dtpThursdayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpThursdayEndTime.Value End If If optFriday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Friday" frmChannelingAppointments.dtpStartTime.Value = dtpFridayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpFridayEndTime.Value End If If optSaturday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Saturday" frmChannelingAppointments.dtpStartTime.Value = dtpSaturdayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpSaturdayEndTime.Value End If If optSunday.Value = True Then frmChannelingAppointments.txtChosenDay.Text = "Sunday" frmChannelingAppointments.dtpStartTime.Value = dtpSundayStartTime.Value frmChannelingAppointments.dtpEndTime.Value = dtpSundayEndTime.Value End If Unload Me End Sub Private Sub cmdClose_Click() 'Closing the Wizard Unload Me End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub Label1_Click(Index As Integer) End Sub

FormServicesSearchAndFind:-

235
'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Services_Maintenance 'Calling the Services_Maintenance Procedure to interact with the recordset Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdServicesInformation_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub lblWizardHeader_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsServicesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[ServiceID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[ServiceName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsServicesMaintenance.RecordCount > 0 Then With rsServicesMaintenance 'Reset the textfields with the selected record frmAddServiceTreatmentsIn.txtServiceID.Text = .Fields(0).Value frmAddServiceTreatmentsIn.txtServiceName.Text = .Fields(1).Value frmAddServiceTreatmentsIn.txtServiceCharge.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormServicesSearchWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean

236
Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Services_Maintenance 'Calling the Services_Maintenance Procedure to interact with the recordset Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdServicesInformation_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgbg2_Click(Index As Integer) End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsServicesMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[ServiceID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[ServiceName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdServicesInformation.DataSource = rsServicesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsServicesMaintenance.RecordCount > 0 Then With rsServicesMaintenance 'Reset the textfields with the selected record frmServiceTreatmentsMaintenance.txtServiceID.Text = .Fields(0).Value frmServiceTreatmentsMaintenance.txtServiceName.Text = .Fields(1).Value frmServiceTreatmentsMaintenance.txtServiceCharge.Text = .Fields(2).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormServiceTreatmentsOut:'-------------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Service Treatments Maintenance Interface 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10

237
'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Service_Treatments_Out Table '-------------------------------------------------------------------------------Option Explicit Dim eachField As Control 'Declaring a Control Variable for all Fields Dim eachButton As Control 'Declaring a Control Variable fot all Command Buttons 'The Following Boolean Variable is being used to determine 'if the data the user enters is valid or not Dim Flag As Boolean 'The following variables will be used to autogenerate the Treatment ID to be 'displayed on the Service Treatments Maintenance form on form load Dim iNumOfTreatments As Integer 'This variable holds the number of records in the table Dim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogenerated Private Sub cmdPatientSearchWizard_Click() frmOPTSearchTreatments.Show End Sub Private Sub cmdServicesSearchWizard_Click() frmSearchServicesWizard.Show End Sub Private Sub cmdUpdate_Click() 'This function will update a record after the user has edited it 'Checking the return value of the function that validates the user's data If textfieldsValidations = False Then With rsServiceTreatmentsOut 'Making sure that the user wants to update the record If MsgBox("Are You Sure You Wish To Update This Record?", vbYesNo + vbQuestion, "Update This Record?") = vbYes Then 'Save the user-entered data into the recordset .Fields(0) = txtTreatmentID.Text .Fields(1) = txtPatientID.Text .Fields(2) = txtFirstName.Text .Fields(3) = txtSurname.Text .Fields(4) = txtServiceID.Text .Fields(5) = txtServiceName.Text .Fields(6) = txtServiceCharge.Text .Fields(7) = txtTreatmentDate.Text .Update 'Display Success Message MsgBox "The Record Was Updated Successfully!", vbInformation, "Succesful Update Procedure" Form_Load 'Calling the Form_Load Procedure clearAllFields 'Calling a Private Function To Clear All Fields Else 'Display 'No Modifications' Message MsgBox "No Modifications Have Taken Place!", vbInformation, "No Modifications!" .CancelUpdate 'Cancel the Update Procedure Form_Load 'Calling the Form_Load Procedure End If .Requery 'Requerying the Table End With End If End Sub Private Sub dgrdServiceTreatments_Click() 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the Navigation Buttons cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = True cmdLast.Enabled = True

238
'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdServicesSearchWizard.Enabled = True With rsServiceTreatmentsOut 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtServiceID.Text = .Fields(4).Value txtServiceName.Text = .Fields(5).Value txtServiceCharge.Text = .Fields(6).Value txtTreatmentDate.Text = .Fields(7).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Public Sub Form_Load() Call Connection 'Calling the Connection Procedure Call Service_Treatments_Out 'Calling the Service_Treatments_Out Procedure disableAllFields 'Calling a Private Function To Disable All Fields disableAllButtons 'Calling a Private Function To Disable All Command Buttons 'Enabling the First Button and the Last Button cmdFirst.Enabled = True cmdLast.Enabled = True 'Enabling the Add New Button cmdClose.Enabled = True 'Enabling the Search Frame lblCriteria.Enabled = True cboSearchType.Enabled = True lblSearchText.Enabled = True txtSearch.Enabled = True dgrdServiceTreatments.Enabled = True Set dgrdServiceTreatments.DataSource = rsServiceTreatmentsOut 'Setting the DataSource of the DataGrid End Sub Public Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = False End If Next End Function Public Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all TextBoxes and ComboBoxes If TypeOf eachField Is TextBox Or TypeOf eachField Is ComboBox Then eachField.Enabled = True End If Next End Function Public Function disableAllButtons() 'This function will disable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If

239
Next End Function Public Function enableAllButtons() 'This function will enable all command buttons on the interface On Error Resume Next For Each eachButton In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will enable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = True End If Next End Function Public Function clearAllFields() 'This function will clear all fields on the interface On Error Resume Next For Each eachField In Me.Controls 'Running a Loop through all the Controls 'The following If Condition will clear all TextBoxes If TypeOf eachField Is TextBox Then eachField.Text = "" End If Next End Function Private Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False cmdLast.Enabled = True cmdPrevious.Enabled = False cmdNext.Enabled = True 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdServicesSearchWizard.Enabled = True With rsServiceTreatmentsOut .MoveFirst 'Moving to the first record 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtServiceID.Text = .Fields(4).Value txtServiceName.Text = .Fields(5).Value txtServiceCharge.Text = .Fields(6).Value txtTreatmentDate.Text = .Fields(7).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdPrevious_Click() 'This function will Navigate to the Previous Record With rsServiceTreatmentsOut .MovePrevious 'Moving to the previous record 'If the user reaches the first record, display a message box 'to inform the user of this If .BOF Then MsgBox "This is the first record!", vbInformation, "First Record" .MoveFirst End If 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value

240
txtSurname.Text = .Fields(3).Value txtServiceID.Text = .Fields(4).Value txtServiceName.Text = .Fields(5).Value txtServiceCharge.Text = .Fields(6).Value txtTreatmentDate.Text = .Fields(7).Value End With cmdNext.Enabled = True 'Enabling the Next Button cmdLast.Enabled = True 'Enabling the Last Button 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdServicesSearchWizard.Enabled = True 'Enabling the Update Button cmdUpdate.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsServiceTreatmentsOut .MoveNext 'Moving to the Next Record 'If the user reaches the last record, display a message box 'to inform the user of this If .EOF Then MsgBox "This is the last record!", vbInformation, "Last Record" .MoveLast End If 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtServiceID.Text = .Fields(4).Value txtServiceName.Text = .Fields(5).Value txtServiceCharge.Text = .Fields(6).Value txtTreatmentDate.Text = .Fields(7).Value End With cmdPrevious.Enabled = True 'Enabling the Previous Button cmdFirst.Enabled = True 'Enabling the First Button 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdServicesSearchWizard.Enabled = True enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Sub cmdLast_Click() 'This function will Navigate to the Last Record 'Enabling / Diabling the Navigation Buttons as necessary cmdLast.Enabled = False cmdFirst.Enabled = True cmdPrevious.Enabled = True cmdNext.Enabled = False 'Enabling the Update Button cmdUpdate.Enabled = True 'Enabling the Wizard Buttons cmdPatientSearchWizard.Enabled = True cmdServicesSearchWizard.Enabled = True With rsServiceTreatmentsOut .Requery .MoveLast 'Moving to the last record 'Entering the values in the particular record into the fields on the interface txtTreatmentID.Text = .Fields(0).Value

241
txtPatientID.Text = .Fields(1).Value txtFirstName.Text = .Fields(2).Value txtSurname.Text = .Fields(3).Value txtServiceID.Text = .Fields(4).Value txtServiceName.Text = .Fields(5).Value txtServiceCharge.Text = .Fields(6).Value txtTreatmentDate.Text = .Fields(7).Value End With enableAllFields 'Calling a Private Function To Enable All Fields End Sub Private Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True 'Checking if the Patient ID textfield is empty If txtPatientID.Text = "" Then txtPatientID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtFirstName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtSurname.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtPatientID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtFirstName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtSurname.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Checking if the Sevice ID textfield is empty If txtServiceID.Text = "" Then txtServiceID.BackColor = &H80000018 'Highlighting the textfield in a different colour txtServiceName.BackColor = &H80000018 'Highlighting the textfield in a different colour txtServiceCharge.BackColor = &H80000018 'Highlighting the textfield in a different colour Flag = False 'Setting the Flag variable to False to indicate invalid data Else txtServiceID.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtServiceName.BackColor = &H80000004 'Bringing the textfield BackColour back to normal txtServiceCharge.BackColor = &H80000004 'Bringing the textfield BackColour back to normal End If 'Here, I am checking the state of the Flag variable and if it is False, I am displaying a 'Message Box to instruct the user to enter data into all highlighted textfields. 'The Save procedure will also be cancelled If Flag = False Then MsgBox "Error! Please Fill-in The Highlighted Textfields! They Are Compulsory!", vbCritical, "Please Fill Highlighted Textfields" textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End If End Function Private Sub txtSearch_Change() If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsServiceTreatmentsOut 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[TreatmentID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'"

242
End Select End With Else clearAllFields 'Calling a Private Function To Clear All Fields disableAllFields 'Calling the disableAllFields procedure 'Disabling the Update Button cmdUpdate.Enabled = False 'Enable the Search Frame cboSearchType.Enabled = True txtSearch.Enabled = True Call Service_Treatments_Out Set dgrdServiceTreatments.DataSource = rsServiceTreatmentsOut End If End Sub Private Sub cmdClose_Click() 'This function will close the interface if the user wishes to do so. If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End If End Sub

FormSetUpSchedule:'--------------------------------------------------------------------------'Hospital Management System - Extended Edition 'Form Name: Setup Channeling Schedule Wizard 'Programmer: Bhaskar BDPS 'Quality Assurance Engineer (Testing): Bhaskar BDPS 'Start Date: 17/04/10 'Date Of Last Modification: 17/04/10 'The Name Of The Database Being Accessed: sdp 'The Name/s Of The Database Table/s Being Accessed: Channeling_Appointments Table '--------------------------------------------------------------------------Private Sub Form_Load() Call Connection 'Call Connection Procedure To Establish Connection With The Database Call Doctor_Schedule 'Calling the Doctor_Schedule Procedure To Interact With The Recordset With rsDoctorSchedule .MoveFirst 'Move To The First Record While .EOF = False 'Running Through All The Records 'Here, I Am Checking The Doctor ID In Order To I Find A Match If .Fields(1).Value = frmDoctorScheduleMaintenance.txtDoctorID.Text Then 'In The Following Blocks Of If Else Conditions, I am enabling 'the DateTime Pickers if the times have already been set. 'Therefore for a new doctor, none of the DateTime Pickers 'will be enabled. If .Fields(2).Value <> "" Then chkMonday.Value = 1 dtpMondayStartTime.Enabled = True dtpMondayEndTime.Enabled = True dtpMondayStartTime.Value = .Fields(2).Value dtpMondayEndTime.Value = .Fields(3).Value End If If .Fields(4).Value <> "" Then chkTuesday.Value = 1 dtpTuesdayStartTime.Enabled = True dtpTuesdayEndTime.Enabled = True

243
dtpTuesdayStartTime.Value = .Fields(4).Value dtpTuesdayEndTime.Value = .Fields(5).Value End If If .Fields(6).Value <> "" Then chkWednesday.Value = 1 dtpWednesdayStartTime.Enabled = True dtpWednesdayEndTime.Enabled = True dtpWednesdayStartTime.Value = .Fields(6).Value dtpWednesdayEndTime.Value = .Fields(7).Value End If If .Fields(8).Value <> "" Then chkThursday.Value = 1 dtpThursdayStartTime.Enabled = True dtpThursdayEndTime.Enabled = True dtpThursdayStartTime.Value = .Fields(8).Value dtpThursdayEndTime.Value = .Fields(9).Value End If If .Fields(10).Value <> "" Then chkFriday.Value = 1 dtpFridayStartTime.Enabled = True dtpFridayEndTime.Enabled = True dtpFridayStartTime.Value = .Fields(10).Value dtpFridayEndTime.Value = .Fields(11).Value End If If .Fields(12).Value <> "" Then chkSaturday.Value = 1 dtpSaturdayStartTime.Enabled = True dtpSaturdayEndTime.Enabled = True dtpSaturdayStartTime.Value = .Fields(12).Value dtpSaturdayEndTime.Value = .Fields(13).Value End If If .Fields(14).Value <> "" Then chkSunday.Value = 1 dtpSundayStartTime.Enabled = True dtpSundayEndTime.Enabled = True dtpSundayStartTime.Value = .Fields(14).Value dtpSundayEndTime.Value = .Fields(15).Value End If End If .MoveNext 'Moving to the next record Wend End With End Sub Private Sub chkMonday_Click() 'Enabling the DateTime Pickers If chkMonday.Value = 1 Then dtpMondayStartTime.Enabled = True dtpMondayEndTime.Enabled = True Else dtpMondayStartTime.Enabled = False dtpMondayEndTime.Enabled = False End If End Sub Private Sub chkTuesday_Click() 'Enabling the DateTime Pickers If chkTuesday.Value = 1 Then dtpTuesdayStartTime.Enabled = True dtpTuesdayEndTime.Enabled = True Else dtpTuesdayStartTime.Enabled = False dtpTuesdayEndTime.Enabled = False

244
End If End Sub Private Sub chkWednesday_Click() 'Enabling the DateTime Pickers If chkWednesday.Value = 1 Then dtpWednesdayStartTime.Enabled = True dtpWednesdayEndTime.Enabled = True Else dtpWednesdayStartTime.Enabled = False dtpWednesdayEndTime.Enabled = False End If End Sub Private Sub chkThursday_Click() 'Enabling the DateTime Pickers If chkThursday.Value = 1 Then dtpThursdayStartTime.Enabled = True dtpThursdayEndTime.Enabled = True Else dtpThursdayStartTime.Enabled = False dtpThursdayEndTime.Enabled = False End If End Sub Private Sub chkFriday_Click() 'Enabling the DateTime Pickers If chkFriday.Value = 1 Then dtpFridayStartTime.Enabled = True dtpFridayEndTime.Enabled = True Else dtpFridayStartTime.Enabled = False dtpFridayEndTime.Enabled = False End If End Sub Private Sub chkSaturday_Click() 'Enabling the DateTime Pickers If chkSaturday.Value = 1 Then dtpSaturdayStartTime.Enabled = True dtpSaturdayEndTime.Enabled = True Else dtpSaturdayStartTime.Enabled = False dtpSaturdayEndTime.Enabled = False End If End Sub Private Sub chkSunday_Click() 'Enabling the DateTime Pickers If chkSunday.Value = 1 Then dtpSundayStartTime.Enabled = True dtpSundayEndTime.Enabled = True Else dtpSundayStartTime.Enabled = False dtpSundayEndTime.Enabled = False End If End Sub Private Sub cmdClose_Click() 'Closing the Wizard Unload Me End Sub Private Sub cmdSave_Click() 'If the Save Button is Clicked With rsDoctorSchedule .MoveFirst 'Moving to the first record While .EOF = False 'Running Through All The Records 'Here, I Am Checking The Doctor ID In Order To Find A Match. 'When I Find A Match, I Will Be Setting The Values Of The DateTime 'Pickers Accordingly. If .Fields(1).Value = frmDoctorScheduleMaintenance.txtDoctorID.Text Then

245
'Monday If chkMonday.Value = 0 Then .Fields(2).Value = Null .Fields(3).Value = Null Else .Fields(2).Value = dtpMondayStartTime.Hour & ":" & dtpMondayStartTime.Minute & ":" & dtpMondayStartTime.Second .Fields(3).Value = dtpMondayEndTime.Hour & ":" & dtpMondayEndTime.Minute & ":" & dtpMondayEndTime.Second End If 'Tuesday If chkTuesday.Value = 0 Then .Fields(4).Value = Null .Fields(5).Value = Null Else .Fields(4).Value = dtpTuesdayStartTime.Hour & ":" & dtpTuesdayStartTime.Minute & ":" & dtpTuesdayStartTime.Second .Fields(5).Value = dtpTuesdayEndTime.Hour & ":" & dtpTuesdayEndTime.Minute & ":" & dtpTuesdayEndTime.Second End If 'Wednesday If chkWednesday.Value = 0 Then .Fields(6).Value = Null .Fields(7).Value = Null Else .Fields(6).Value = dtpWednesdayStartTime.Hour & ":" & dtpWednesdayStartTime.Minute & ":" & dtpWednesdayStartTime.Second .Fields(7).Value = dtpWednesdayEndTime.Hour & ":" & dtpWednesdayEndTime.Minute & ":" & dtpWednesdayEndTime.Second End If 'Thursday If chkThursday.Value = 0 Then .Fields(8).Value = Null .Fields(9).Value = Null Else .Fields(8).Value = dtpThursdayStartTime.Hour & ":" & dtpThursdayStartTime.Minute & ":" & dtpThursdayStartTime.Second .Fields(9).Value = dtpThursdayEndTime.Hour & ":" & dtpThursdayEndTime.Minute & ":" & dtpThursdayEndTime.Second End If 'Friday If chkFriday.Value = 0 Then .Fields(10).Value = Null .Fields(11).Value = Null Else .Fields(10).Value = dtpFridayStartTime.Hour & ":" & dtpFridayStartTime.Minute & ":" & dtpFridayStartTime.Second .Fields(11).Value = dtpFridayEndTime.Hour & ":" & dtpFridayEndTime.Minute & ":" & dtpFridayEndTime.Second End If 'Saturday If chkSaturday.Value = 0 Then .Fields(12).Value = Null .Fields(13).Value = Null Else .Fields(12).Value = dtpSaturdayStartTime.Hour & ":" & dtpSaturdayStartTime.Minute & ":" & dtpSaturdayStartTime.Second .Fields(13).Value = dtpSaturdayEndTime.Hour & ":" & dtpSaturdayEndTime.Minute & ":" & dtpSaturdayEndTime.Second

246
End If 'Sunday If chkSunday.Value = 0 Then .Fields(14).Value = Null .Fields(15).Value = Null Else .Fields(14).Value = dtpSundayStartTime.Hour & ":" & dtpSundayStartTime.Minute & ":" & dtpSundayStartTime.Second .Fields(15).Value = dtpSundayEndTime.Hour & ":" & dtpSundayEndTime.Minute & ":" & dtpSundayEndTime.Second End If .Update 'Updating the Recordset Unload Me Exit Sub End If .MoveNext 'Moving To The Next Record Wend 'The Adding of a New Record Obviously Takes Place Only If There Is 'No Matching Doctor ID To Be Found, Which Would Mean That The Doctor 'Is New .AddNew 'Adding a New Record 'Adding the Doctor ID Into The Relevant Field .Fields(1).Value = frmDoctorScheduleMaintenance.txtDoctorID.Text 'Monday If chkMonday.Value = 0 Then .Fields(2).Value = Null .Fields(3).Value = Null Else .Fields(2).Value = dtpMondayStartTime.Hour & ":" & dtpMondayStartTime.Minute & ":" & dtpMondayStartTime.Second .Fields(3).Value = dtpMondayEndTime.Hour & ":" & dtpMondayEndTime.Minute & ":" & dtpMondayEndTime.Second End If 'Tuesday If chkTuesday.Value = 0 Then .Fields(4).Value = Null .Fields(5).Value = Null Else .Fields(4).Value = dtpTuesdayStartTime.Hour & ":" & dtpTuesdayStartTime.Minute & ":" & dtpTuesdayStartTime.Second .Fields(5).Value = dtpTuesdayEndTime.Hour & ":" & dtpTuesdayEndTime.Minute & ":" & dtpTuesdayEndTime.Second End If 'Wednesday If chkWednesday.Value = 0 Then .Fields(6).Value = Null .Fields(7).Value = Null Else .Fields(6).Value = dtpWednesdayStartTime.Hour & ":" & dtpWednesdayStartTime.Minute & ":" & dtpWednesdayStartTime.Second .Fields(7).Value = dtpWednesdayEndTime.Hour & ":" & dtpWednesdayEndTime.Minute & ":" & dtpWednesdayEndTime.Second End If 'Thursday If chkThursday.Value = 0 Then .Fields(8).Value = Null .Fields(9).Value = Null Else

247
.Fields(8).Value = dtpThursdayStartTime.Hour & ":" & dtpThursdayStartTime.Minute & ":" & dtpThursdayStartTime.Second .Fields(9).Value = dtpThursdayEndTime.Hour & ":" & dtpThursdayEndTime.Minute & ":" & dtpThursdayEndTime.Second End If 'Friday If chkFriday.Value = 0 Then .Fields(10).Value = Null .Fields(11).Value = Null Else .Fields(10).Value = dtpFridayStartTime.Hour & ":" & dtpFridayStartTime.Minute & ":" & dtpFridayStartTime.Second .Fields(11).Value = dtpFridayEndTime.Hour & ":" & dtpFridayEndTime.Minute & ":" & dtpFridayEndTime.Second End If 'Saturday If chkSaturday.Value = 0 Then .Fields(12).Value = Null .Fields(13).Value = Null Else .Fields(12).Value = dtpSaturdayStartTime.Hour & ":" & dtpSaturdayStartTime.Minute & ":" & dtpSaturdayStartTime.Second .Fields(13).Value = dtpSaturdayEndTime.Hour & ":" & dtpSaturdayEndTime.Minute & ":" & dtpSaturdayEndTime.Second End If 'Sunday If chkSunday.Value = 0 Then .Fields(14).Value = Null .Fields(15).Value = Null Else .Fields(14).Value = dtpSundayStartTime.Hour & ":" & dtpSundayStartTime.Minute & ":" & dtpSundayStartTime.Second .Fields(15).Value = dtpSundayEndTime.Hour & ":" & dtpSundayEndTime.Minute & ":" & dtpSundayEndTime.Second End If .Update 'Updating The Record End With Unload Me 'Closing the form End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub lblWizardHeader_Click() End Sub

FormSplash:Option Explicit Private Sub Form_KeyPress(KeyAscii As Integer) Unload Me End Sub Private Sub Form_Load() ' lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision ' lblProductName.Caption = App.Title End Sub Private Sub Frame1_Click() Unload Me End Sub Private Sub Timer1_Timer() Static ictr As Integer

248
'Run the timer and check the condition 'when the condition is false 'stop the timer and disply the login form If ictr <= 100 Then ProgressBar1.Value = ictr ictr = ictr + 1 Else frmLogin.Show 'frmLogin.Show Unload Me End If End Sub

FormTurnOff:Private Sub cmdCancel_Click() Unload Me End Sub Private Sub cmdLogOff_Click() frmLogin.Show Unload Me Unload frmMDI End Sub Private Sub cmdTurnoff_Click() End End Sub

FormUltimateInpatientSearch:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Dim strPatientID As String 'This variable will hold the Patient ID of the patient Dim strCorporateID As String 'This variable will hold the Corporate ID of the patient Dim totalWithoutDiscount As Double 'This variable will hold the addition of the Total and The VAT Dim totalWithDiscount As Double 'This variable will hold the Total after subtracting the discount Dim checkBillingFlag As Boolean 'This variable will help me to find out if the patient has settled his bill or not. Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdInpatientsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsInpatientMaintenance 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0:

249
.Filter = "[PatientID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[FirstName] Like '" & txtSearch.Text & "%" & "'" Case 2: .Filter = "[Surname] Like '" & txtSearch.Text & "%" & "'" Case 3: .Filter = "[NICNumber] Like '" & txtSearch.Text & "%" & "'" Case 4: .Filter = "[AccountType] Like '" & txtSearch.Text & "%" & "'" Case 5: .Filter = "[CompanyID] Like '" & txtSearch.Text & "%" & "'" Case 6: .Filter = "[CompanyName] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdInpatientsInfoTable.DataSource = rsInpatientMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button checkBillingFlag = False 'Initializing the value of this variable On Error GoTo error_handler 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsInpatientMaintenance.RecordCount > 0 Then strPatientID = rsInpatientMaintenance.Fields(0).Value 'Here, I am checking if the patient has already settled his / her bill Call Inpatient_Billing With rsInpatientBilling .MoveFirst Do While .EOF = False If .Fields(3).Value = strPatientID And .Fields(12).Value = "PAID" Then checkBillingFlag = True Exit Do Else .MoveNext End If Loop End With 'Checking the status of the checkBillingFlag variable If checkBillingFlag = True Then MsgBox "This Patient Has Already Settled All Payments!", vbCritical, "Bill Settled In Full!" Exit Sub End If 'Here, I am including relevant inpatient information onto to the parent form With rsInpatientMaintenance frmIPDOverallBilling.txtPatientID.Text = .Fields(0).Value frmIPDOverallBilling.txtFirstName.Text = .Fields(1).Value frmIPDOverallBilling.txtSurname.Text = .Fields(2).Value frmIPDOverallBilling.txtAccountType.Text = .Fields(11).Value strCorporateID = .Fields(12).Value End With 'Here, I am including the corporate discount if the patient is a corporate patient If frmIPDOverallBilling.txtAccountType.Text = "Corporate" Then Call Companies_Maintenance 'Calling the Companies_Maintenance recordset With rsCompaniesMaintenance .MoveFirst Do While .EOF = False

250
If .Fields(0).Value = strCorporateID Then frmIPDOverallBilling.txtDiscount = .Fields(6).Value Exit Do Else .MoveNext End If Loop End With Else frmIPDOverallBilling.txtDiscount.Text = "" End If 'Here, I am going to add all relevant Patient Admission Details Call Inpatients_Admission With rsInpatientsAdmission .MoveFirst Do While .EOF = False If .Fields(1).Value = frmIPDOverallBilling.txtPatientID.Text Then frmIPDOverallBilling.txtAdmissionID.Text = .Fields(0).Value frmIPDOverallBilling.txtDepartmentID.Text = .Fields(11).Value frmIPDOverallBilling.txtDepartmentName.Text = .Fields(12).Value frmIPDOverallBilling.txtWardNo.Text = .Fields(14).Value frmIPDOverallBilling.txtRoomID.Text = .Fields(15).Value frmIPDOverallBilling.dtpAdmissionDate.Value = .Fields(3).Value frmIPDOverallBilling.txtAssignedDoctorID.Text = .Fields(9).Value Exit Do Else .MoveNext End If Loop End With 'The following line of code will calculate the number of day the patient has been in hospital frmIPDOverallBilling.txtNoOfDays.Text = (Val(frmIPDOverallBilling.dtpTodaysDate.Day) Val(frmIPDOverallBilling.dtpAdmissionDate.Day)) + 1 'Here, I am calculating the Doctor's Charges Call Doctors_Maintenance With rsDoctorsMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = frmIPDOverallBilling.txtAssignedDoctorID.Text Then frmIPDOverallBilling.txtDoctorsCharges.Text = .Fields(12).Value * Val(frmIPDOverallBilling.txtNoOfDays) Exit Do Else .MoveNext End If Loop End With 'Here, I am calculating the total Medical Treatment Charges Call TotalMedicalTreatments Set frmIPDOverallBilling.dgrdTotalMedicalTreatments.DataSource = rsTotalMedicalTreatments frmIPDOverallBilling.txtMedicalTreatmentCharges.Text = frmIPDOverallBilling.dgrdTotalMedicalTreatments.Columns(0).Value 'Here, I am calculating the total Service Treatment Charges Call TotalServiceTreatments Set frmIPDOverallBilling.dgrdTotalServiceTreatments.DataSource = rsTotalServiceTreatments frmIPDOverallBilling.txtServiceTreatmentCharges.Text = frmIPDOverallBilling.dgrdTotalServiceTreatments.Columns(0).Value 'Here, I am calculating the Room Charges

251
Call Rooms_Maintenance With rsRoomsMaintenance .MoveFirst Do While .EOF = False If .Fields(0).Value = frmIPDOverallBilling.txtRoomID.Text Then frmIPDOverallBilling.txtRoomCharges.Text = .Fields(6).Value * Val(frmIPDOverallBilling.txtNoOfDays.Text) Exit Do Else .MoveNext End If Loop End With 'Here, I am calculating the Hospital Charges frmIPDOverallBilling.txtHospitalCharges.Text = Val(frmIPDOverallBilling.txtNoOfDays) * 1000 'Here, I am calculating the total of all costs frmIPDOverallBilling.txtTotal.Text = Val(frmIPDOverallBilling.txtDoctorsCharges.Text) + Val(frmIPDOverallBilling.txtMedicalTreatmentCharges.Text) + Val(frmIPDOverallBilling.txtServiceTreatmentCharges.Text) + Val(frmIPDOverallBilling.txtRoomCharges.Text) + Val(frmIPDOverallBilling.txtHospitalCharges.Text) 'Here, I am calculating the VAT amount frmIPDOverallBilling.txtVAT.Text = Val(frmIPDOverallBilling.txtTotal.Text) * 0.15 'Here, I am calculating the NETT TOTAL If frmIPDOverallBilling.txtDiscount.Text = "" Then frmIPDOverallBilling.txtNettTotal.Text = Val(frmIPDOverallBilling.txtTotal.Text) + Val(frmIPDOverallBilling.txtVAT.Text) Else totalWithoutDiscount = Val(frmIPDOverallBilling.txtTotal.Text) + Val(frmIPDOverallBilling.txtVAT.Text) totalWithDiscount = totalWithoutDiscount - ((Val(frmIPDOverallBilling.txtDiscount.Text) / 100) * totalWithoutDiscount) frmIPDOverallBilling.txtNettTotal.Text = totalWithDiscount End If Unload Me 'Unloading the form Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If Exit Sub error_handler: MsgBox "You Cannot Continue Because You Have Not Added Either Medical Treatments Or Medical Services For This Patient!", vbCritical, "Patient Records Missing!" Unload Me Unload frmIPDOverallBilling Exit Sub End Sub

FormWardSearchWizard:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call RelevantWard_Selection 'Calling the RelevantWard_Selection Procedure to interact with the recordset Set dgrdWardsInfoTable.DataSource = rsWardsSelection 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard

252
End Sub Private Sub dgrdWardsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsWardsSelection 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[WardID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[WardNo] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdWardsInfoTable.DataSource = rsWardsSelection 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsWardsSelection.RecordCount > 0 Then With rsWardsSelection 'Reset the textfields with the selected record frmRoomsMaintenance.txtWardID.Text = .Fields(0).Value frmRoomsMaintenance.txtWardNumber.Text = .Fields(1).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

FormWardsSearchWizardAdmit:'This variable will determine if the DataGrid has been clicked or not Dim Flag As Boolean Private Sub Form_Load() 'Form Load Procedure Flag = False 'The Flag variable is being initialized to False Call Relevant_Ward_Selection 'Calling the Relevant_Ward_Selection Procedure to interact with the recordset Set dgrdWardsInfoTable.DataSource = rsRelevantWardsSelection 'Setting the DataSource of the DataGrid End Sub Private Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End Sub Private Sub dgrdWardsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid 'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End Sub

253
Private Sub imgCenter_Click(Index As Integer) End Sub Private Sub txtSearch_Change() 'This is executed when the user types in the Search textfield If Len(txtSearch.Text) > 0 Then 'Checking if the user has typed in the textfield With rsRelevantWardsSelection 'Filter the Records As The User Types, According to the Criteria Select Case (cboSearchType.ListIndex) Case 0: .Filter = "[WardID] Like '" & txtSearch.Text & "%" & "'" Case 1: .Filter = "[WardNo] Like '" & txtSearch.Text & "%" & "'" End Select End With Set dgrdWardsInfoTable.DataSource = rsRelevantWardsSelection 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End If End Sub Private Sub cmdApply_Click() 'This code is executed when the user clicks the Apply Button 'Here, I am checkin to see if the user has chosen a record If Flag = True And rsRelevantWardsSelection.RecordCount > 0 Then With rsRelevantWardsSelection 'Reset the textfields with the selected record frmAdmitPatient.txtWardID.Text = .Fields(0).Value frmAdmitPatient.txtWardNo.Text = .Fields(1).Value Unload Me 'Unload the Wizard End With Else 'Displaying an error message, asking the user to choose a record MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End If End Sub

You might also like