Form

332
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 1

Transcript of Form

Page 1: Form

Forms:-

Form About:-

Private Sub cmdClose_Click()Unload MeEnd SubPrivate 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 ExplicitDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate 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

1

Page 2: Form

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 IfEnd SubPrivate 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 WithEnd FunctionPrivate 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

2

Page 3: Form

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 WithEnd SubPrivate 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 IfEnd SubPrivate Sub cmdMedicineSearchWizard_Click() frmSearchMedsWizard.Show End SubPrivate Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmInpatientsSearchMedicals.Show End SubPrivate 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 SubPrivate Sub Form_Load() txtDateOfIssue.Text = DateTime.Date 'Displaying the date in the DateOfIssue textfield. End SubPrivate 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 SubPrivate 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 IfEnd Sub

3

Page 4: Form

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 IfEnd SubPrivate 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 IfEnd Function

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

4

Page 5: Form

'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 ExplicitDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate 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

5

Page 6: Form

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 IfEnd SubPrivate 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 FunctionPrivate 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

6

Page 7: Form

End SubPrivate 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 IfEnd SubPrivate Sub cmdMedicineSearchWizard_Click() frmMedicinesWizardOut.ShowEnd SubPrivate Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmOutpatientSearchMeds.Show End SubPrivate 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 IfEnd SubPrivate Sub Form_Load() txtDateOfIssue.Text = DateTime.Date 'Displaying the date in the DateOfIssue textfield.End SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

7

Page 8: Form

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 IfEnd FunctionFormAddMedicalTreatmentsOut:-

FormAddNewDepartment:-

FormAddNewDoctor:-

FormAddNewHospitalService:-

FormAddNewMedicine:-FormAddNewOutPatient:-FormAddNewPatient:-FormAddNewRoom:-FormAddNewWard:-FormAddRooms:-FormAddServiceTreatment:-FormAddServiceTreatmentsIn:-

'--------------------------------------------------------------------------------

8

Page 9: Form

'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 ExplicitDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate 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

9

Page 10: Form

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 IfEnd SubPrivate 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 WithEnd FunctionPrivate 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 WithEnd SubPrivate 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

10

Page 11: Form

Unload Me End IfEnd SubPrivate Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmInpatientsSearchAndFind.Show End SubPrivate Sub cmdServiceSearchWizard_Click() frmServicesSearchAndFind.ShowEnd SubPrivate 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 IfEnd SubPrivate Sub Form_Load() txtTreatmentDate.Text = DateTime.Date 'Displaying the Date in the Treatment Date textfield.End SubPrivate 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 IfEnd Function

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

11

Page 12: Form

'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 ExplicitDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate 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

12

Page 13: Form

'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 IfEnd SubPrivate 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 WithEnd FunctionPrivate 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 WithEnd SubPrivate 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

13

Page 14: Form

End SubPrivate Sub cmdPatientSearchWizard_Click() 'On click of the Inpatients Search Wizard Button frmOutpatientsSearchAndFind.ShowEnd SubPrivate Sub cmdServiceSearchWizard_Click() frmServicesSearchNFind.ShowEnd SubPrivate 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 IfEnd SubPrivate Sub Form_Load() txtTreatmentDate.Text = DateTime.Date 'Displaying the Date in the Treatment Date textfield.End SubPrivate 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 IfEnd Function

FormAdmitPatient:-

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

14

Page 15: Form

'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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As BooleanPrivate Sub cmdAssignedDoctorWizardButton_Click() frmAssignedDocSelectionWizard.ShowEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate Sub cmdDepartmentIDWizardButton_Click() frmDepartmentsSearchWizardAdmit.ShowEnd SubPrivate 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 WizardEnd SubPrivate Sub cmdReferredDoctorIDWizardButton_Click() frmReferringDoctorWizard.ShowEnd SubPrivate Sub cmdRoomIDWizardButton_Click() frmRoomsSearchWizard.ShowEnd SubPrivate 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

15

Page 16: Form

.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 IfEnd SubPrivate 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

16

Page 17: Form

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.ShowEnd SubPrivate 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.ShowEnd SubPrivate 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

17

Page 18: Form

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 IfEnd SubPrivate Sub cmdWardIDWizardButton_Click() frmWardsSearchWizardAdmit.ShowEnd SubPublic 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

18

Page 19: Form

cmdClose.Enabled = True 'Enabling the LaunchDoctorSearch Wizard Button cmdLaunchInpatientSearch.Enabled = TrueEnd SubPrivate 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic 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 = FalseEnd FunctionPublic 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 FunctionPrivate 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

19

Page 20: Form

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 FieldsEnd SubPrivate 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

20

Page 21: Form

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 FieldsEnd SubPrivate 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

21

Page 22: Form

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 FieldsEnd SubPrivate 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

22

Page 23: Form

End With enableAllFields 'Calling a Private Function To Enable All FieldsEnd SubPrivate 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

23

Page 24: Form

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 IfEnd FunctionPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubFormAssignedDocSelectionWizard:-'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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

24

Page 25: Form

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 IfEnd SubPrivate 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 IfEnd Sub

FormAssignedDocWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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

25

Page 26: Form

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 IfEnd SubPrivate 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 IfEnd 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 ExplicitDim FileSystemObject As ObjectDim strfilename As StringPrivate Sub cmdBackup_Click()On Error GoTo e 'set the copying functionality strfilename = "" + txtPath.Text + "\" + txtFile.Text + ".mdb" 'Set the object contractions

26

Page 27: Form

Set FileSystemObject = CreateObject("Scripting.FileSystemObject") 'Copy the file according the path settings FileSystemObject.copyfile App.Path & "\sdp.mdb", strfilename PrgBar.Visible = True timPrgBar.Enabled = TrueExit Sube:MsgBox "Invalid Path Setting, Please Try Again", vbCritical, "Invalid Path Setting!"End SubPrivate Sub Dir_Click() txtPath.Text = "" & Dir.PathEnd SubPrivate 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 IfEnd SubPrivate Sub Form_Load() 'Display Today 's date txtFile.Text = FormatDateTime(Now, vbLongDate)End SubPrivate 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 IfEnd SubPrivate 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 IfEnd 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

27

Page 28: Form

End SubPrivate Sub Form_Load() cldrSystemCalendar.TodayEnd 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 textfieldEnd SubPrivate 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

28

Page 29: Form

Wend Unload Me End WithEnd SubPrivate 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 IfEnd 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 doctorDim datagridText As String 'This variable will hold the appointment end time of the last patient in the datagridPrivate Sub cmdCheckChannelingDays_Click() frmSelectADay.ShowEnd SubPrivate 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 IfEnd SubPrivate Sub cmdLaunchDocSearch_Click() frmDoctorSearchChanneling.ShowEnd SubPrivate 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 Sube: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End IfEnd SubPrivate Sub cmdSave_Click() Call All_Appointments With rsAllAppointments 'Making sure that the user wants to save the record

29

Page 30: Form

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 = TrueEnd SubPrivate Sub dgrdChannelingInfo_Click()End SubPrivate 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

30

Page 31: Form

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 Suberror_handler: 'If dtpAppointmentStartTime.Value = DateTime.Time Then dtpAppointmentEndTime.Minute = "00" dtpAppointmentEndTime.Hour = dtpAppointmentEndTime.Hour + 1 End SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

31

Page 32: Form

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

FormCompaniesSearchWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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

32

Page 33: Form

MsgBox "Please Select a Record First!", vbExclamation, "No Record Selected!" Exit Sub End IfEnd SubFormCreateDoctorSchedule:-FormCredits:-

Private Sub cmdClose_Click() Unload MeEnd SubPrivate Sub Form_Load()End Sub

FormDepartmentSearchWizard Ward:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 IfEnd SubPrivate 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

33

Page 34: 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 IfEnd Sub

FormDepartmentSearchWizardRooms:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

34

Page 35: Form

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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean'The following variables will be used to autogenerate the Service IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Service ID to be autogeneratedPrivate 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

35

Page 36: Form

.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 SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate 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 IfEnd SubPrivate Sub dgrdDepartmentsInformation_Click() 'Enabling the Update Button & the Delete Button

36

Page 37: Form

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 FieldsEnd SubPrivate 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 DataGridEnd SubPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPrivate Function enableAllFields() 'This function will enable all fields on the interface On Error Resume Next

37

Page 38: Form

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 NextEnd 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 NextEnd FunctionPrivate 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 FieldsEnd SubPrivate 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

38

Page 39: Form

End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All FieldsEnd 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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate Sub tmrErrMsg_Timer() Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidKeypressMsg.Visible = False

39

Page 40: Form

picInvalidDataMsg.Visible = False tmrErrMsg.Enabled = False Else i = i + 1 End IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

40

Page 41: Form

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 IfEnd SubPrivate 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

41

Page 42: Form

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 IfEnd FunctionPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

FormDepartmentsSearchWizardAdmit:-

42

Page 43: Form

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

FormDischargeDetails Maintenance:-

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

43

Page 44: Form

'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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim eachButton As Control 'Declaring a Control Variable fot all Command Buttons'This variable will hold the Room ID of the patient being dischargedDim strRoomIDStore As String'This variable will help me to decide if the patient has settled the bill in fullDim 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 loadDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim 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 IfEnd SubPrivate Sub cmdInpatientSearchWizard_Click() frmInpatientSearchDischarge.ShowEnd SubPrivate 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

44

Page 45: Form

.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 WithEnd SubPrivate 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

45

Page 46: Form

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 WithEnd SubPrivate 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 FieldsEnd SubPrivate 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

46

Page 47: Form

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 textfieldEnd SubPublic 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

47

Page 48: Form

dgrdDischargeInfo.Enabled = True Set dgrdDischargeInfo.DataSource = rsDischargeMaintenance 'Setting the DataSource of the DataGridEnd SubPublic 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 FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPrivate 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

48

Page 49: Form

'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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

49

Page 50: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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:

50

Page 51: Form

.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 IfEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd Sub

FormDoctorSearchChanneling:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub Label1_Click(Index As Integer)End SubPrivate 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:

51

Page 52: Form

.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 IfEnd SubPrivate 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 IfEnd Sub

FormDoctorSearchWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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_LoadEnd SubPrivate 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 = TrueEnd SubPrivate 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

52

Page 53: Form

End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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

53

Page 54: Form

'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 IfEnd Sub FormDoctorSearchWizardSchedule:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanDim rsClearRecord As ADODB.Recordset 'This will be used to create a virtual recordsetPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate 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:

54

Page 55: Form

.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 IfEnd SubPrivate 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 IfEnd Sub

FormDoctorSpecializationWizard:-

Private Sub cmdCancel_Click() Unload MeEnd Sub

55

Page 56: Form

Private Sub cmdOK_Click() frmDoctorsMaintenance.txtDoctorSpecialization.Text = lstSpecializations.Text Unload MeEnd SubPrivate Sub Form_Load() cmdOK.Enabled = False 'Disabling the OK ButtonEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate Sub lstSpecializations_Click() cmdOK.Enabled = TrueEnd 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

56

Page 57: Form

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 WithEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

57

Page 58: Form

End SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub cmdClose_Click() 'Closing the Wizard Unload MeEnd SubPrivate 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

58

Page 59: Form

'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

59

Page 60: Form

.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

60

Page 61: Form

.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 MeEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate 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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean'The following variables will be used to autogenerate the Service IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Service ID to be autogeneratedPrivate 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

61

Page 62: Form

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 = strCodeEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate 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

62

Page 63: Form

.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 IfEnd SubPrivate 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 FieldsEnd SubPrivate 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

63

Page 64: Form

lblSearchFor.Enabled = True txtSearch.Enabled = True 'Enabling the DataGrid dgrdCompanyInformation.Enabled = True Set dgrdCompanyInformation.DataSource = rsCompaniesMaintenance 'Setting the DataSource of the DataGridEnd SubPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPublic 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 NextEnd FunctionPrivate 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

64

Page 65: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

65

Page 66: Form

End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

66

Page 67: Form

Else picInvalidKeypressMsg.Top = 6480 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End IfEnd SubPrivate 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 IfEnd SubPrivate 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

67

Page 68: Form

.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 IfEnd SubPrivate 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

68

Page 69: Form

'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 IfEnd FunctionPrivate 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

FormEditDepartmentsFormEditDischargeDetailsFormEditDoctors:-

'----------------------------------------------------------------------------'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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean'The following Boolean Variable will determine if the Doctor's Date Of Birth'entered by the user is valid

69

Page 70: Form

Dim dateFlag As Boolean'The following variables will be used to autogenerate the Doctor IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Doctor ID to be autogeneratedPrivate 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 IfEnd SubPrivate 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

70

Page 71: Form

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 = strCodeEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate 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

71

Page 72: Form

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 IfEnd SubPrivate 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 WizardEnd SubPrivate 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

72

Page 73: Form

'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 IfEnd SubPrivate Sub cmdSetUpDocSchedule_Click() 'Opens up the Wizard to set up the Doctor's Visiting Days Schedule. frmDoctorVisitingDaysWizard.ShowEnd SubPrivate Sub cmdSpecializationWizard_Click() frmDoctorSpecializationWizard.ShowEnd SubPrivate 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

73

Page 74: Form

'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

74

Page 75: Form

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 IfEnd SubPrivate Sub dtpDateOfBirth_CloseUp() dtpDateOfBirth.MaxDate = DateTime.DateEnd SubPublic 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 SubPrivate Function disableAllFields() 'This function will disable all fields on the interface On Error Resume Next

75

Page 76: Form

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 ButtonEnd FunctionPrivate 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 = TrueEnd FunctionPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPublic 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 FunctionPrivate 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

76

Page 77: Form

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" doctorEnd SubPublic 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 IfEnd FunctionPublic 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

77

Page 78: Form

txtReferringCharges.Enabled = True End IfEnd FunctionPrivate 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" doctorEnd SubPrivate 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

78

Page 79: Form

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" doctorEnd SubPrivate 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

79

Page 80: Form

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" doctorEnd SubPrivate 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

80

Page 81: Form

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

81

Page 82: Form

'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 IfEnd FunctionPrivate 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 IfEnd SubPrivate Sub txtChannelingCharges_GotFocus() If txtChannelingCharges.Text = "-" Then txtChannelingCharges.Text = "" End IfEnd SubPrivate Sub txtServiceCharges_GotFocus() If txtServiceCharges.Text = "-" Then txtServiceCharges.Text = "" End IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtServiceCharges_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then

82

Page 83: Form

ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidKeyMsg.Top = 3960 'Validation Note View picInvalidKeyMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End IfEnd SubPrivate Sub txtChannelingCharges_LostFocus() If txtChannelingCharges.Text = "" Then txtChannelingCharges.Text = "-" End IfEnd SubPrivate Sub txtServiceCharges_LostFocus() If txtServiceCharges.Text = "" Then txtServiceCharges.Text = "-" End IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtMobPhone_GotFocus() If txtMobPhone.Text = "-" Then txtMobPhone.Text = "" End IfEnd SubPrivate Sub txtMobPhone_LostFocus() If txtMobPhone.Text = "" Then txtMobPhone.Text = "-" End IfEnd SubPrivate 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

83

Page 84: Form

Else picInvalidKeypressMsg.Top = 7680 'Validation Note View picInvalidKeypressMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtNICNumber_LostFocus() If txtNICNumber.Text = "" Then txtNICNumber.Text = "-" End IfEnd SubPrivate Sub txtReferringCharges_GotFocus() If txtReferringCharges.Text = "-" Then txtReferringCharges.Text = "" End IfEnd SubPrivate 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 SubPrivate 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 IfEnd SubPrivate Sub txtReferringCharges_LostFocus() If txtReferringCharges.Text = "" Then txtReferringCharges.Text = "-" End IfEnd SubPrivate Sub txtSurname_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only alphabets

84

Page 85: Form

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 SubPrivate 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 IfEnd 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 IfEnd SubPrivate Sub cmdDoctorSearchWizard_Click() frmDoctorSearchWizardSchedule.ShowEnd SubPrivate Sub cmdSetUpChannelingTimes_Click() frmSetUpChannelingSchedule.ShowEnd SubPrivate 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

85

Page 86: Form

'The Name/s Of The Database Table/s Being Accessed: Guardians_Maintenance Table'-------------------------------------------------------------------------------

Option ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean'The following variables will be used to autogenerate the Admission ID to be'displayed on the Admit Patient form on form loadDim iNumOfInpatients As Integer 'This variable holds the number of records in the tableDim strDisplayAdmissionID As String 'This variable will eventually hold the Admission ID to be autogeneratedPrivate 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

86

Page 87: Form

.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 IfEnd SubPrivate 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

87

Page 88: Form

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.TimeEnd FunctionPrivate 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

88

Page 89: Form

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.ShowEnd SubPrivate 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

89

Page 90: Form

.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 IfEnd SubPrivate 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 FieldsEnd SubPrivate 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

90

Page 91: Form

End SubPublic 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 NextEnd FunctionPublic 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 FunctionPublic 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 FunctionPublic 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 = FalseEnd FunctionPublic 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 FunctionPrivate 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

91

Page 92: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

92

Page 93: Form

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 FieldsEnd 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 FieldsEnd SubPrivate Function textfieldsValidations() As Boolean 'This function will validate all fields Flag = True 'Setting the Flag variable to True

93

Page 94: Form

'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 IfEnd FunctionPrivate 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

94

Page 95: Form

Else i = i + 1 End IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 SubPrivate 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 IfEnd 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtPhoneHome_KeyPress(KeyAscii As Integer) 'Keypress Validation to allow only digits If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then

95

Page 96: Form

ElseIf KeyAscii = vbKeySpace Then ElseIf KeyAscii = vbKeyBack Then Else picInvalidTypingMsg.Top = 6960 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

96

Page 97: Form

End IfEnd SubPrivate 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 IfEnd SubPrivate 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

97

Page 98: Form

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.ShowEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd 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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean'The following variables will be used to autogenerate the Service IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Service ID to be autogeneratedPrivate 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

98

Page 99: Form

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 = strCodeEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate 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

99

Page 100: Form

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 IfEnd SubPrivate 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 FieldsEnd SubPrivate 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 DataGridEnd SubPrivate 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

100

Page 101: Form

eachField.Enabled = False End If NextEnd FunctionPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPublic 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 NextEnd FunctionPrivate 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 FieldsEnd SubPrivate 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

101

Page 102: Form

'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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

102

Page 103: Form

.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 FieldsEnd 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

103

Page 104: Form

'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 IfEnd SubPrivate 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"

104

Page 105: Form

textfieldsValidations = True 'Passing values to the Save procedure Else textfieldsValidations = False 'Passing values to the Save procedure End IfEnd FunctionPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

FormEditMedicalTreatment:-

105

Page 106: Form

'--------------------------------------------------------------------------------'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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate Sub cmdMedicineSearchWizard_Click() frmMedicinesSearchMeds.ShowEnd SubPrivate Sub cmdPatientSearchWizard_Click() frmInpatientsWizardMedicals.ShowEnd SubPrivate 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 End With

106

Page 107: Form

End IfEnd SubPrivate 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 FieldsEnd SubPrivate 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 FieldsEnd SubPublic 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 cmdLast.Enabled = True

107

Page 108: Form

'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 DataGridEnd SubPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic Function enableAllButtons() 'This function will enable all command buttons on the interfaceOn 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 NextEnd FunctionPublic 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 NextEnd FunctionPrivate Sub cmdFirst_Click() 'This function will Navigate to the First Record 'Enabling / Diabling the Navigation Buttons as necessary cmdFirst.Enabled = False

108

Page 109: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate Sub cmdNext_Click() 'This function will Navigate to the Next Record With rsMedicalTreatments .MoveNext 'Moving to the Next Record

109

Page 110: Form

'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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

110

Page 111: Form

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 IfEnd FunctionPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtQty_KeyPress(KeyAscii As Integer)

111

Page 112: Form

'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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd 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'----------------------------------------------------------------------------

Option Explicit

112

Page 113: Form

Dim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean

'The following variables will be used to autogenerate the Medicine IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Medicine ID to be autogeneratedPrivate 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 = strCodeEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then

113

Page 114: Form

Unload Me End IfEnd SubPrivate 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 IfEnd SubPrivate 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 'Entering the values in the particular record into the fields on the interface txtMedicineID.Text = .Fields(0).Value

114

Page 115: Form

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 FieldsEnd SubPrivate 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 DataGridEnd SubPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPublic 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

115

Page 116: Form

'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 FunctionPrivate 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 FieldsEnd SubPrivate 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 cmdUpdate.Enabled = True cmdDelete.Enabled = True

116

Page 117: Form

enableAllFields 'Calling a Private Function To Enable All FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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 FieldsEnd Sub

117

Page 118: Form

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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 .Fields(2) = cboDosageForm.Text .Fields(3) = txtUnitPrice.Text

118

Page 119: Form

.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 IfEnd SubPrivate 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

119

Page 120: Form

'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 IfEnd FunctionPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 KeyAscii = 0 End If

120

Page 121: Form

End SubPrivate 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 IfEnd 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 ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim Flag As Boolean'The following Boolean Variable will determine if the Doctor's Date Of Birth'entered by the user is validDim dateFlag As Boolean'The following variables will be used to autogenerate the Doctor IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Doctor ID to be autogeneratedPrivate 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 IfEnd SubPrivate Sub cmdAddNew_Click() 'This function adds a new recordset into the database

121

Page 122: Form

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 SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate Sub cmdCompanySearchWizard_Click() frmCompaniesSearchWizard.ShowEnd SubPrivate Sub cmdDelete_Click() 'This function will delete a record from the database 'Check for the record selection If txtPatientID.Text = "" Then

122

Page 123: Form

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 IfEnd SubPrivate Sub cmdDoctorSearchWizard_Click() frmAssignedDocWizard.ShowEnd SubPrivate 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 WizardEnd SubPrivate 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

123

Page 124: Form

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 .Fields(6) = txtAddress.Text .Fields(7) = txtPhoneHome.Text

124

Page 125: Form

.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 IfEnd SubPrivate 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 txtPhoneHome.BackColor = &H80000004 End If

125

Page 126: Form

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 .Fields(13) = txtCompanyName.Text .Fields(14) = txtAssignedDoctorID.Text

126

Page 127: Form

.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 IfEnd SubPrivate Sub dtpDateOfBirth_CloseUp() dtpDateOfBirth.MaxDate = DateTime.DateEnd SubPublic 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 = TrueEnd SubPrivate 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 PickerEnd FunctionPublic 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 PickerEnd FunctionPrivate 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

127

Page 128: Form

'The following If Condition will disable all Command Buttons If TypeOf eachButton Is CommandButton Then eachButton.Enabled = False End If NextEnd FunctionPrivate 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 NextEnd FunctionPublic 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 FunctionPrivate 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 txtPatientOccupation.Text = .Fields(9).Value cboCivilStatus.Text = .Fields(10).Value

128

Page 129: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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 cboGender.Text = .Fields(3).Value dtpDateOfBirth.Value = .Fields(4).Value

129

Page 130: Form

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 FieldsEnd SubPrivate 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 End With

130

Page 131: Form

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 'Checking if the user has made a selection in the Civil Status ComboBox

131

Page 132: Form

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 IfEnd FunctionPrivate 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 End Sub

132

Page 133: Form

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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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

133

Page 134: Form

End SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 SubPrivate 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 IfEnd Sub

FormEditPatientDetails:-

134

Page 135: Form

'----------------------------------------------------------------------------'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 FieldsDim 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 notDim Flag As Boolean'The following Boolean Variable will determine if the Doctor's Date Of Birth'entered by the user is validDim dateFlag As Boolean'The following variables will be used to autogenerate the Doctor IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim 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 loadDim iNumOfGuardians As Integer 'This variable holds the number of records in the tableDim strDisplayID As String 'This variable will eventually hold the Guardian ID to be autogeneratedPrivate 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 IfEnd SubPrivate 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 'Disabling the Company Related Records

135

Page 136: Form

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 = strCodeEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate Sub cmdCompanySearchWizard_Click() frmCompanySearchWizard.ShowEnd SubPrivate 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 Else

136

Page 137: Form

'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 IfEnd SubPrivate 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 = FalseEnd SubPrivate 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

137

Page 138: Form

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!"

138

Page 139: Form

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 IfEnd SubPrivate 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

139

Page 140: Form

.Requery 'Requerying the Table .AddNew 'Adding a new recordset 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 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

140

Page 141: Form

'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

141

Page 142: Form

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

142

Page 143: Form

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 'Requerying the Table 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

143

Page 144: Form

'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

144

Page 145: Form

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

145

Page 146: Form

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

146

Page 147: Form

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

147

Page 148: Form

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

148

Page 149: Form

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

149

Page 150: Form

'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

150

Page 151: Form

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() '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

151

Page 152: Form

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 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

152

Page 153: Form

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 SubFormEditRooms

153

Page 154: Form

FormEditServiceTreatmentFormEditWardsFormInpatientSearchDischarge:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanDim checkBillingFlag As Boolean 'This variable will check if the user has settled the bill in full or notDim 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 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 & "%" & "'"

154

Page 155: Form

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

155

Page 156: Form

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 notDim 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

156

Page 157: Form

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 & "%" & "'" 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

157

Page 158: Form

'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 notDim 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

158

Page 159: Form

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 & "%" & "'" 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 IfEnd SubPrivate 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

159

Page 160: Form

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 IfEnd Sub

FormInpatientsSearchAndFind:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

160

Page 161: Form

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 IfEnd SubPrivate 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 IfEnd Sub FormInpatientsSearchMedicals:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

161

Page 162: Form

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 IfEnd SubPrivate 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 IfEnd Sub FormInpatientsWizardMedTreatments:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

162

Page 163: Form

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 IfEnd SubPrivate 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 IfEnd Sub

FormInpatientsWizardService:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

163

Page 164: Form

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 IfEnd SubPrivate 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 IfEnd 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 notDim Flag As Boolean'This variable will hold the invoice ID when saving for the purpose of report generation.Dim invoiceid As StringPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd Sub

164

Page 165: Form

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 = FalseEnd SubPrivate 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 = FalseEnd SubPrivate Sub cmdPrint_Click() 'For Reports On Error GoTo e DataEnvironment1.Commands("InpatientReceipt").Parameters(0) = invoiceid RptInpatientReceipt.Show DataEnvironment1.rsInpatientReceipt.Close Unload Me Exit Sube: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End IfEnd SubPrivate 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

165

Page 166: Form

'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 buttonEnd SubPrivate Sub Form_Load()End Sub

166

Page 167: Form

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 SubPrivate 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 = TrueEnd SubPrivate 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 SubPublic 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 FunctionPrivate Sub txtAmountPaid_GotFocus() txtAmountPaid.Text = ""End SubPrivate Sub txtAmountPaid_LostFocus() If txtAmountPaid.Text = "" Then txtAmountPaid.Text = "0" End If End SubPrivate Sub tmrErrMsg_Timer()

167

Page 168: Form

Static i As Integer If i < 200000 Then 'Validation Msg Viewing Time Period picInvalidTypingMsg.Visible = False tmrErrMsg.Enabled = False Else i = i + 1 End IfEnd SubPrivate 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 SubPrivate Sub txtBankName_LostFocus() If txtBankName.Text = "" Then txtBankName.Text = "-" End If End SubPrivate Sub txtCardNo_GotFocus() txtCardNo.Text = "" End SubPrivate Sub txtCardNo_LostFocus() If txtCardNo.Text = "" Then txtCardNo.Text = "-" End If End SubPrivate Sub txtChequeNo_GotFocus() txtChequeNo.Text = "" End SubPrivate Sub txtChequeNo_LostFocus() If txtChequeNo.Text = "" Then txtChequeNo.Text = "-" End If End SubPrivate Sub txtTotalRecieved_GotFocus() txtTotalRecieved.Text = "" End SubPrivate Sub txtTotalRecieved_LostFocus() If txtTotalRecieved.Text = "" Then txtTotalRecieved.Text = "0" End If End SubPrivate 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

168

Page 169: Form

picInvalidTypingMsg.Top = 6600 'Validation Note View picInvalidTypingMsg.Visible = True tmrErrMsg.Enabled = True KeyAscii = 0 End IfEnd SubPublic 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

169

Page 170: Form

textfieldsValidations = False 'Passing values to the Save procedure End IfEnd 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 IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Invoice ID to be autogeneratedDim iNumberOfRecords As Integer 'This variable will hold the number of records in the Inpatient_Payment_Details tableDim strDisplay As String 'This variable will eventually display the OverallInBillID in the invisible textfieldDim iTotalPayable As Double 'This variable will hold the value of the Total PayableDim billID As String 'This variable will hold the Billing ID of the patientPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate 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

170

Page 171: Form

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 Suberror_handler: frmIPDCreateBill.txtTotalPaidSoFar.Text = "0" frmIPDCreateBill.txtBalanceOwing.Text = frmIPDCreateBill.txtTotalPayable.Text Unload MeEnd SubPrivate Sub cmdInpatientSearchWizard_Click() frmInpatientSearchBilling.ShowEnd SubPrivate 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 Sube: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End IfEnd SubPrivate 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!"

171

Page 172: Form

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

172

Page 173: Form

.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 buttonEnd SubPrivate Sub Form_Load() 'Displaying the system date in the Today's Date textfield dtpTodaysDate.Value = DateTime.DateEnd 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 ExplicitDim rsLogin As ADODB.Recordset 'Creating a Recordset VariableDim 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 SubPrivate 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 IfEnd SubPrivate 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

173

Page 174: Form

KeyAscii = 0 ElseIf KeyAscii = 13 Then 'This is for using the Enter key KeyAscii = 0 SendKeys "{Tab}" End IfEnd SubPrivate 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 IfEnd SubPrivate 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

174

Page 175: Form

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 IfEnd SubPrivate 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 IfEnd 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 FieldsDim eachButton As Control 'Declaring a Control Variable fot all Command Buttons'The Following Boolean Variable is being used to determine

175

Page 176: Form

'if the data the user enters is valid or notDim 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 IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the User ID to be autogeneratedDim rsSelectionOfFields As ADODB.Recordset 'This will limit the fields I show in the gridPrivate 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 = strCodeEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate Sub cmdUpdate_Click() 'This function will update a record after the user has edited it.

176

Page 177: Form

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!"

177

Page 178: Form

.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 WithEnd SubPrivate 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 FieldsEnd SubPrivate 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 DataGridEnd Sub'This function will interact with the UserAccount table, whilst hiding'sensitive information from the userPrivate Function Selection_Of_Fields() Set rsSelectionOfFields = New ADODB.Recordset With rsSelectionOfFields .CursorType = adOpenDynamic .LockType = adLockOptimistic .ActiveConnection = conn

178

Page 179: Form

.Source = "Select [UserID],[FirstName],[LastName],[EMail],[Designation] from UserAccount" .CursorLocation = adUseClient .Open End With End FunctionPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPrivate 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 NextEnd FunctionPublic 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 NextEnd FunctionPrivate 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

179

Page 180: Form

End With 'Enabling the Update Button and the Delete Button cmdUpdate.Enabled = True cmdDelete.Enabled = True enableAllFields 'Calling a Private Function To Enable All FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate Sub cmdLast_Click() 'This function will Navigate to the Last Record

180

Page 181: Form

'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 SubPrivate 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 IfEnd SubPrivate 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

181

Page 182: Form

Set dgrdUserAccount.DataSource = rsSelectionOfFields 'Setting the DataSource of the DataGrid End IfEnd SubPrivate 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 IfEnd Sub

182

Page 183: Form

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 IfEnd FunctionPrivate 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!"

183

Page 184: Form

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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtEmail_KeyPress(KeyAscii As Integer) 'Counting the number of times the "@" symbol was pressed If KeyAscii = Asc("@") Then iNumOfSymbols = iNumOfSymbols + 1 End IfEnd Sub

FormMDI:-

'---------------------------------------------------------------------'Hospital Management System - Extended Edition

184

Page 185: Form

'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 ExplicitDim iExitReply As Integer 'This variable will hold the user's choice, once he has been asked whether he wants to exit or notDim iLogOutReply As Integer 'This variable will hold the user's choice, once he has been asked whether he wants to log out or notPrivate 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

185

Page 186: Form

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 SubPrivate 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 FunctionPrivate 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

186

Page 187: Form

End If End SubPrivate 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

187

Page 188: Form

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

188

Page 189: Form

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

189

Page 190: Form

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 SelectEnd SubPrivate 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

190

Page 191: Form

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 SubPrivate 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 SubPrivate Sub mnuAbout_Click() frmAbout.ShowEnd SubPrivate Sub mnuAddMedicalTreatment_Click() frmAddMedicalTreatmentsOut.ShowEnd SubPrivate Sub mnuAddMedicalTreatments_Click() frmAddMedicalTreatmentsIn.ShowEnd SubPrivate Sub mnuAddServiceTreatment_Click() frmAddServiceTreatmentsOut.ShowEnd SubPrivate Sub mnuAddServiceTreatments_Click()

191

Page 192: Form

frmAddServiceTreatmentsIn.ShowEnd SubPrivate Sub mnuBackupDatabase_Click() frmBackupDatabase.ShowEnd SubPrivate Sub mnuCalendar_Click() frmCalendar.ShowEnd SubPrivate Sub mnuCascade_Click() Me.Arrange vbCascadeEnd SubPrivate Sub mnuCloseAll_Click() Me.Arrange vbCascadeEnd SubPrivate Sub mnuCorporateMaintenance_Click() frmCompaniesMaintenance.ShowEnd SubPrivate Sub mnuCredits_Click() frmCredits.ShowEnd SubPrivate Sub mnuEditMedicalTreatment_Click() frmMedicalTreatmentsOut.ShowEnd SubPrivate Sub mnuEditMedicalTreatmentRecords_Click() frmMedicalTreatmentsMaintenance.ShowEnd SubPrivate Sub mnuEditServiceTreatmentRecord_Click() frmServiceTreatmentsMaintenance.ShowEnd SubPrivate Sub mnuEditServiceTreatmentRecords_Click() frmServiceTreatmentsOut.ShowEnd SubPrivate 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 Sube: MsgBox Err.Description 'MsgBox "Error! The Help Guide does not exist!", vbCritical, "Help File Does Not Exist!"End SubPrivate 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 SubPrivate 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 Suberrcode: MsgBox "Unable to run Microsoft Magnifier on your computer", vbError, "Error Loading Microsoft Magnifier!"

192

Page 193: Form

Resume NextEnd SubPrivate 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 Suberrcode: MsgBox "Unable to run Microsoft Narrator on your computer", vbError, "Error Loading Microsoft Narrator!" Resume NextEnd SubPrivate Sub mnuRoomsMaintenance_Click() frmRoomsMaintenance.ShowEnd SubPrivate Sub mnuSearchEngine_Click() frmSearchEngine.ShowEnd SubPrivate 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 Suberrcode: MsgBox "Unable to run the Calculator Utility on your computer", vbError, "Error Loading Calculator!" Resume NextEnd SubPrivate 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 Suberrcode: MsgBox "Unable to run System Media Player on your computer", vbError, "Error Loading System Media Player!" Resume NextEnd SubPrivate 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 Suberrcode: MsgBox "Unable to run the Notepad Utility on your computer", vbError, "Error Loading Notepad!" Resume NextEnd SubPrivate Sub mnuTileHorizontally_Click() Me.Arrange vbTileHorizontalEnd SubPrivate Sub mnuTileVertically_Click() Me.Arrange vbTileVerticalEnd SubPrivate 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

193

Page 194: Form

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 = FalseEnd SubPrivate 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 SubPrivate Sub mnuChangePassword_Click() frmChangePassword.ShowEnd Sub

194

Page 195: Form

Private Sub mnuCompanyMaintenance_Click() frmCompaniesMaintenance.ShowEnd SubPrivate Sub mnuDepartmentsMaintenance_Click() frmDepartmentsMaintenance.ShowEnd SubPrivate Sub mnuDischargePatient_Click() frmDischargeDetailsMaintenance.ShowEnd SubPrivate Sub mnuDoctorScheduleMaintenance_Click() frmDoctorScheduleMaintenance.ShowEnd SubPrivate Sub mnuDoctorsMaintenance_Click() frmDoctorsMaintenance.ShowEnd SubPrivate Sub mnuDoctorsVisitMaintenance_Click() frmDoctorVisitsMaintenance.ShowEnd SubPrivate Sub mnuDoctorVisitMaintenance_Click() frmDoctorVisitsMaintenance.ShowEnd SubPrivate 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 SubPrivate Sub mnuGuardiansMaintenance_Click() Call Guardians_Maintenance Set frmGuardiansMaintenance.dgrdGuardiansInfo.DataSource = rsGuardiansMaintenance frmGuardiansMaintenance.ShowEnd SubPrivate Sub mnuHopitalServicesMaintenance_Click() frmServicesMaintenance.ShowEnd SubPrivate Sub mnuInpatientsMaintenance_Click() Call Inpatients_Maintenance 'Calling the Inpatients_Maintenance Procedure to interact with the recordset frmInpatientsMaintenance.ShowEnd SubPrivate Sub mnuManageAppointments_Click() frmChannelingAppointments.ShowEnd SubPrivate Sub mnuManagePatientBill_Click() frmIPDOverallBilling.ShowEnd SubPrivate Sub mnuManagePatientsBill_Click() frmOPDOverallBilling.ShowEnd SubPrivate Sub mnuManageUserAccounts_Click() frmManageUserAccounts.ShowEnd SubPrivate Sub mnuMedicinesMaintenance_Click() frmMedicinesMaintenance.ShowEnd SubPrivate Sub mnuOSearchPayments_Click() frmSearchOutpatientPayments.ShowEnd SubPrivate Sub mnuOutpatientsMaintenance_Click() frmOutpatientsMaintenance.Show

195

Page 196: Form

End SubPrivate Sub mnuRegisterAdmitPatient_Click() Call Inpatients_Admission frmAdmitPatient.ShowEnd SubPrivate Sub mnuSearchPayments_Click() frmSearchPayments.ShowEnd SubPrivate Sub mnuViewOverallPatientBill_Click() frmOPDOverallBilling.cmdSave.Enabled = False frmOPDOverallBilling.cmdGoToPayments.Enabled = False frmOPDOverallBilling.ShowEnd SubPrivate Sub mnuViewOveralPatientBill_Click() frmIPDOverallBilling.cmdSave.Enabled = False frmIPDOverallBilling.cmdGoToPayments.Enabled = False frmIPDOverallBilling.ShowEnd SubPrivate Sub mnuWardsMaintenance_Click() frmWardsMaintenance.ShowEnd Sub

'----------------------------REPORTS MDI---------------------------------------------------

Private Sub mnuAllCompaniesMasterReport_Click() RptAllCompaniesMaster.ShowEnd SubPrivate Sub mnuAllDoctors_Click() RptDoctorsMaster.ShowEnd SubPrivate Sub mnuAllDoctorsSchedulesMasterReport_Click() RptAllDoctorsShedule.ShowEnd SubPrivate Sub mnuChannelingPatientsMasterReport_Click() frmReportChannelingMaster.ShowEnd SubPrivate Sub mnuDepartmentsMasterReport_Click() RptDepartmentMaster.ShowEnd SubPrivate Sub mnuDoctorsVisitsMasterReport_Click() RptVisitingDoctorsShedule.ShowEnd SubPrivate Sub mnuIndividualDoctorsScheduleReport_Click() RptAllDoctorsShedule.ShowEnd SubPrivate Sub mnuInpatientsInvoice_Click() frmReportInpatientInvoice.ShowEnd SubPrivate Sub mnuInpatientsMasterReport_Click() frmReportInpatientMaster.ShowEnd SubPrivate Sub mnuMedicalServicesMasterReport_Click() RptMedicalServicesMaster.ShowEnd SubPrivate Sub mnuMedicinesMasterReport_Click() RptMedicinesMaster.ShowEnd SubPrivate Sub mnuOutpatientsMasterReport_Click() frmReportOutpatientMaster.Show

196

Page 197: Form

End SubPrivate Sub mnuPatientAdmissionMasterReport_Click() frmReportPatientAdmission.ShowEnd SubPrivate Sub mnuPatientDischargeMasterReport_Click() frmReportPatientDischarge.ShowEnd SubPrivate Sub mnuRoomsMasterReport_Click() RptRoomsMaster.ShowEnd SubPrivate Sub mnuInpatientMedicines_Click() frmReportInpatientMedicalTreatment.ShowEnd SubPrivate Sub mnuOutpatientsMedicines_Click() frmReportOutpatientMedicalTreatments.ShowEnd SubPrivate Sub mnuInpatientsServices_Click() frmReportInpatientServiceTreatments.ShowEnd SubPrivate Sub mnuOutpatientsServices_Click() frmReportOutPatientPatientServiceTreatements.ShowEnd SubPrivate Sub mnuDoctorsChannelingSchedule_Click() RptAllDoctorsShedule.ShowEnd SubPrivate Sub mnuIndividualCompanyOutpatients_Click() RptIndividualCompanyOutpatients.ShowEnd SubPrivate Sub mnuIndividualCompanyInpatients_Click() RptIndividualCompanyInpatients.ShowEnd SubPrivate Sub mnuInpatientsRevenueReports_Click() frmReportInpatientRevenue.ShowEnd SubPrivate Sub mnuOutpatientsRevenueReports_Click() frmReportOutpatientRevenue.ShowEnd SubPrivate Sub mnuDoctorEarningsReports_Click() frmReportDoctorsEarnings.ShowEnd SubPrivate Sub mnuBillStatusReport_Click() frmReportAging.ShowEnd 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

197

Page 198: Form

Dim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate Sub cmdMedicineSearchWizard_Click() frmMedsSearchMeds.ShowEnd SubPrivate Sub cmdPatientSearchWizard_Click() frmOutpatientsSearchMeds.ShowEnd SubPrivate 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 IfEnd SubPrivate 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

198

Page 199: Form

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 FieldsEnd SubPrivate 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 SubPublic 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 SubPublic 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

199

Page 200: Form

'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 FunctionPublic 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 FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPublic 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 NextEnd FunctionPrivate 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

200

Page 201: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

201

Page 202: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

202

Page 203: Form

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 IfEnd FunctionPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate 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)

203

Page 204: Form

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 IfEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd Sub

FormMedicinesSearchMeds:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub lblWizardHeader_Click(Index As Integer)End SubPrivate 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:

204

Page 205: Form

.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 IfEnd SubPrivate 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 notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

205

Page 206: Form

End Select End With Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End IfEnd SubPrivate 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 IfEnd Sub

FormMedsSearchMeds:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate Sub lblWizardHeader_Click(Index As Integer)End SubPrivate 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

206

Page 207: Form

Set dgrdMedicinesInfoTable.DataSource = rsMedicinesMaintenance 'Setting the DataSource of the DataGrid Else Form_Load 'Calling the Form_Load Procedure End IfEnd SubPrivate 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 IfEnd 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 notDim Flag As Boolean'This variable will hold the invoice ID when saving for the purpose of report generation.Dim invoiceid As StringPrivate 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 SubPrivate 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 = FalseEnd Sub

207

Page 208: Form

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 = FalseEnd SubPrivate Sub cmdPrint_Click() On Error GoTo e DataEnvironment1.Commands("OutpatientReceipt").Parameters(0) = invoiceid RptOutpatientReceipt.Show DataEnvironment1.rsOutpatientReceipt.Close Unload Me Exit Sube: If Err.Number <> 3704 Then MsgBox Err.Description & "" & Err.Number, vbCritical End IfEnd SubPrivate 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

208

Page 209: Form

.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 buttonEnd SubPrivate Sub Form_Load()End SubPrivate 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 = TrueEnd SubPrivate 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 = TrueEnd Sub

209

Page 210: Form

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 = TrueEnd SubPublic 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 = FalseEnd FunctionPrivate Sub txtAmountPaid_GotFocus() txtAmountPaid.Text = ""End SubPrivate Sub txtAmountPaid_LostFocus() If txtAmountPaid.Text = "" Then txtAmountPaid.Text = "0" End IfEnd SubPrivate 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 IfEnd SubPrivate 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 IfEnd SubPrivate Sub txtTotalRecieved_GotFocus() txtTotalRecieved.Text = ""End SubPrivate Sub txtTotalRecieved_LostFocus() If txtTotalRecieved.Text = "" Then txtTotalRecieved.Text = "0"

210

Page 211: Form

End IfEnd SubPrivate 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 IfEnd SubPublic 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

211

Page 212: Form

'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 IfEnd 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 IDDim iNumOfRecords As Integer 'This variable holds the number of records in the tableDim strCode As String 'This variable will eventually hold the Invoice ID to be autogeneratedDim iNumberOfRecords As Integer 'This variable will hold the number of records in the Inpatient_Payment_Details tableDim strDisplay As String 'This variable will eventually display the OverallInBillID in the invisible textfieldDim iTotalPayable As Double 'This variable will hold the value of the Total PayableDim 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 IfEnd SubPrivate 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

212

Page 213: Form

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 SubEnd SubPrivate Sub cmdOutpatientSearchWizard_Click() frmOutpatientSearchBilling.ShowEnd SubPrivate 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 IfEnd SubPrivate 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

213

Page 214: Form

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

214

Page 215: Form

End With cmdPrint.Enabled = True 'Enabling the Print buttonEnd SubPrivate Sub Form_Load()End Sub

FormOPTSearchTreatments:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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

215

Page 216: Form

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 IfEnd Sub FormOutpatientSearchBilling:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanDim strCorporateID As String 'This variable will hold the Corporate ID of the sponsoring companyDim strDoctorID As String 'This variable will hold the Assigned Doctor's IDDim totalWithoutDiscount As Double 'This variable will hold the addition of the Total and The VATDim totalWithDiscount As Double 'This variable will hold the Total after subtracting the discountPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 SubPrivate 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 DataGridEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

216

Page 217: Form

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 IfEnd SubPrivate 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

217

Page 218: Form

'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 notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End SubPrivate 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 SubPrivate 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 SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate Sub lblWizardHeader_Click(Index As Integer)End SubPrivate 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:

218

Page 219: Form

.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 IfEnd SubPrivate 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 IfEnd Sub FormOutpatientsSearchAndFind:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 & "%" & "'"

219

Page 220: Form

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 IfEnd SubPrivate 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 IfEnd Sub FormOutpatientsSearchMeds:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate 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 DataGridEnd SubPrivate Sub lblWizardHeader_Click(Index As Integer)End SubPrivate 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

220

Page 221: Form

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 IfEnd SubPrivate 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 IfEnd Sub FormOutpatientsSearchWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 SubPrivate 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 SubPrivate 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

221

Page 222: Form

Set dgrdOutpatientsInfoTable.DataSource = rsOutpatientsMaintenance 'Setting the DataSource of the DataGrid End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 SubPrivate 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

222

Page 223: Form

FormPaymentOptions:-

Private Sub cmdInpatient_Click() frmIPDOverallBilling.Show Unload MeEnd SubPrivate Sub cmdOutpatient_Click() frmOPDOverallBilling.Show Unload MeEnd SubPrivate Sub cmdClose_Click() Unload MeEnd SubPrivate Sub imgbg2_Click(Index As Integer)End Sub

FormQuickLaunch:-

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

FormReferringDoctorWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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)

223

Page 224: Form

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 IfEnd SubPrivate 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 IfEnd Sub

Form ReportsQuickLaunchFormRoomBookingsFormRoomsSearchWizardFormSearchEngine:-

'-------------------------------------------------------------------------------'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 ExplicitPrivate Sub cboInfoTable_Click() Dim strTitle As String

224

Page 225: Form

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

225

Page 226: Form

.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 = strTitleEnd SubPrivate Sub cmdClose_Click() If MsgBox(userName & ", Are You Sure You Wish To Close This Interface?", vbYesNo + vbQuestion, "Close Interface?") = vbYes Then Unload Me End IfEnd SubPrivate Sub Form_Load()Call ConnectionCall Inpatients_MaintenanceCall Outpatients_MaintenanceCall Inpatient_BillingCall Outpatient_BillingCall Doctors_MaintenanceCall Doctor_ScheduleEnd SubPrivate 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:

226

Page 227: Form

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:

227

Page 228: Form

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 Subbackload: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 IfEnd SubPrivate Sub Form_Load() Call Outpatient_Billing Set dgrdOutpatientsBillingInfo.DataSource = rsOutpatientBillingEnd SubPrivate 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:

228

Page 229: Form

.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 IfEnd 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 IfEnd SubPrivate Sub Form_Load() Call Inpatient_Billing Set dgrdInpatientsBillingInfo.DataSource = rsInpatientBillingEnd SubPrivate 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

229

Page 230: Form

End Sub

FormSearchServicesWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End SubPrivate 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 SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

Form Select A Day:-

230

Page 231: Form

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

231

Page 232: Form

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 SubPrivate 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 SubPrivate 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

232

Page 233: Form

End If End SubPrivate 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 SubPrivate 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 SubPrivate 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 SubPrivate 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 SubPrivate 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 SubPrivate 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

233

Page 234: Form

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 MeEnd SubPrivate Sub cmdClose_Click() 'Closing the Wizard Unload Me End SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub Label1_Click(Index As Integer)End Sub

FormServicesSearchAndFind:-

234

Page 235: Form

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End SubPrivate 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 SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate Sub lblWizardHeader_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

FormServicesSearchWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As Boolean

235

Page 236: Form

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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the Wizard End SubPrivate 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 SubPrivate Sub imgbg2_Click(Index As Integer)End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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 IfEnd 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

236

Page 237: Form

'The Name Of The Database Being Accessed: sdp'The Name/s Of The Database Table/s Being Accessed: Service_Treatments_Out Table'--------------------------------------------------------------------------------

Option ExplicitDim eachField As Control 'Declaring a Control Variable for all FieldsDim 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 notDim 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 loadDim iNumOfTreatments As Integer 'This variable holds the number of records in the tableDim strDisplay As String 'This variable will eventually hold the Treatment ID to be autogeneratedPrivate Sub cmdPatientSearchWizard_Click() frmOPTSearchTreatments.Show End SubPrivate Sub cmdServicesSearchWizard_Click() frmSearchServicesWizard.ShowEnd SubPrivate 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 IfEnd SubPrivate 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

237

Page 238: Form

'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 FieldsEnd SubPublic 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 SubPublic 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 FunctionPublic 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 FunctionPublic 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

238

Page 239: Form

NextEnd FunctionPublic 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 FunctionPublic 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 NextEnd FunctionPrivate 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 FieldsEnd SubPrivate 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

239

Page 240: Form

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 FieldsEnd SubPrivate 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 FieldsEnd SubPrivate 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

240

Page 241: Form

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 FieldsEnd SubPrivate 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 IfEnd FunctionPrivate 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 & "%" & "'"

241

Page 242: Form

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 SubPrivate 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 IfEnd 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 dtpTuesdayStartTime.Value = .Fields(4).Value

242

Page 243: Form

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 SubPrivate 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 SubPrivate 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 End If

243

Page 244: Form

End SubPrivate 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 IfEnd SubPrivate 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 SubPrivate 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 SubPrivate 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 IfEnd SubPrivate 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 SubPrivate Sub cmdClose_Click() 'Closing the Wizard Unload MeEnd SubPrivate 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 'Monday

244

Page 245: Form

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 End If

245

Page 246: Form

'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 .Fields(8).Value = dtpThursdayStartTime.Hour & ":" & dtpThursdayStartTime.Minute & ":" & dtpThursdayStartTime.Second

246

Page 247: Form

.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 SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate Sub lblWizardHeader_Click()End Sub

FormSplash:-

Option ExplicitPrivate Sub Form_KeyPress(KeyAscii As Integer) Unload MeEnd SubPrivate Sub Form_Load()' lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision' lblProductName.Caption = App.TitleEnd SubPrivate Sub Frame1_Click() Unload MeEnd SubPrivate Sub Timer1_Timer() Static ictr As Integer 'Run the timer and check the condition 'when the condition is false

247

Page 248: Form

'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 IfEnd Sub

FormTurnOff:-

Private Sub cmdCancel_Click() Unload MeEnd SubPrivate Sub cmdLogOff_Click() frmLogin.Show Unload Me Unload frmMDIEnd SubPrivate Sub cmdTurnoff_Click() EndEnd Sub

FormUltimateInpatientSearch:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanDim strPatientID As String 'This variable will hold the Patient ID of the patientDim strCorporateID As String 'This variable will hold the Corporate ID of the patientDim totalWithoutDiscount As Double 'This variable will hold the addition of the Total and The VATDim totalWithDiscount As Double 'This variable will hold the Total after subtracting the discountDim 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 WizardEnd SubPrivate 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 SubPrivate 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 SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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:

248

Page 249: Form

.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 IfEnd SubPrivate 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 If .Fields(0).Value = strCorporateID Then frmIPDOverallBilling.txtDiscount = .Fields(6).Value

249

Page 250: Form

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 Call Rooms_Maintenance With rsRoomsMaintenance

250

Page 251: Form

.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 Suberror_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 SubEnd Sub FormWardSearchWizard:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate Sub dgrdWardsInfoTable_Click() 'This procedure is executed if the user clicks the DataGrid

251

Page 252: Form

'Setting the Flag variable to True, to indicate that the user 'has clicked the DataGrid Flag = True End SubPrivate Sub imgCenter_Click(Index As Integer)End SubPrivate 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 IfEnd SubPrivate 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 IfEnd Sub

FormWardsSearchWizardAdmit:-

'This variable will determine if the DataGrid has been clicked or notDim Flag As BooleanPrivate 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 DataGridEnd SubPrivate Sub cmdClose_Click() 'This procedure will close the Wizard Unload Me 'Unloading the WizardEnd SubPrivate 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 = TrueEnd SubPrivate Sub imgCenter_Click(Index As Integer)End Sub

252

Page 253: Form

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 SubPrivate 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

253