📄 frminpatientdetails.frm
字号:
ScreenHeight = 1024
ScreenWidth = 1280
ScreenHeightDT = 1024
ScreenWidthDT = 1280
FormHeightDT = 10740
FormWidthDT = 10260
FormScaleHeightDT= 10230
FormScaleWidthDT= 10140
ResizeFormBackground= -1 'True
ResizePictureBoxContents= -1 'True
End
Begin VB.Label lblLabels
AutoSize = -1 'True
BackColor = &H00FF8080&
Caption = "IN PATIENT DETAILS"
BeginProperty Font
Name = "Verdana"
Size = 18
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 435
Index = 13
Left = 3120
TabIndex = 50
Top = 360
Width = 4245
End
Begin VB.Label lblLabels
BackColor = &H00FF8080&
Caption = "Patient ID:"
BeginProperty Font
Name = "Verdana"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 255
Index = 0
Left = 480
TabIndex = 0
Top = 1380
Width = 1695
End
End
Attribute VB_Name = "frmInPatientDetails"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents adoPrimaryRS As Recordset
Attribute adoPrimaryRS.VB_VarHelpID = -1
Dim mbChangedByCode As Boolean
Dim mvBookMark As Variant
Dim mbEditFlag As Boolean
Dim mbAddNewFlag As Boolean
Dim mbDataChanged As Boolean
Private Sub cmdAddGuard_Click()
Unload Me
frmGuardianDetails.Show
End Sub
Private Sub cmdViewAll_Click()
frmDisplayInPatient.Show
End Sub
Private Sub Form_Load()
Call Functions.DisableMenu
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select Patient_ID,Patient_FName,Patient_LName,Patient_DOB,Patient_Sex,Patient_Weight,Patient_Height,Patient_Blood_Group,Patient_NID,Patient_Address,Patient_HPhone,Patient_MPhone,Patient_Notes from In_Patient_Details", cnPatients, adOpenStatic, adLockOptimistic
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
Set oText.DataSource = adoPrimaryRS
oText.Locked = True
Next
mbDataChanged = False
cmbBloodGroup.Text = cmbBloodGroup.List(0)
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 22 Then KeyAscii = 0: Exit Sub
KeyAscii = DataEntryValidation(KeyAscii, ActiveControl.Tag)
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If mbEditFlag Or mbAddNewFlag Then Exit Sub
Select Case KeyCode
Case vbKeyEscape
cmdClose_Click
Case vbKeyEnd
cmdLast_Click
Case vbKeyHome
cmdFirst_Click
Case vbKeyUp, vbKeyPageUp
If Shift = vbCtrlMask Then
cmdFirst_Click
Else
cmdPrevious_Click
End If
Case vbKeyDown, vbKeyPageDown
If Shift = vbCtrlMask Then
cmdLast_Click
Else
cmdNext_Click
End If
End Select
End Sub
Private Sub OptGender_Click(Index As Integer)
Select Case (Index)
Case "0" ' Male
txtFields(4) = "Male"
Case "1" 'Female
txtFields(4) = "FeMale"
Case Else 'None
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
Screen.MousePointer = vbDefault
Call Functions.EnableMenu
End Sub
Private Sub adoPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This will display the current record position for this recordset
lblStatus.Caption = "Record: " & CStr(adoPrimaryRS.AbsolutePosition)
End Sub
Private Sub adoPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'This is where you put validation code
'This event gets called when the following actions occur
Dim bCancel As Boolean
Select Case adReason
Case adRsnAddNew
Case adRsnClose
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Case adRsnUndoUpdate
Case adRsnUpdate
End Select
If bCancel Then adStatus = adStatusCancel
End Sub
Private Sub cmdAdd_Click()
'On Error GoTo AddErr
Dim rsAddPatient As Recordset
Dim PID As String
Set rsAddPatient = New ADODB.Recordset
PID = Functions.UID(6, "IPID_")
rsAddPatient.Open " Select * from In_Patient_Details", cnPatients, adOpenKeyset, adLockPessimistic
While rsAddPatient.EOF = False
If rsAddPatient(0) = PID Then
ID = True
PID = Functions.UID(6, "IPID_")
rsAddPatient.MoveFirst
Else
ID = False
End If
rsAddPatient.MoveNext
Wend
rsAddPatient.Close
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
oText.Locked = False
Next
txtFields(0).Locked = True
With adoPrimaryRS
If Not (.BOF And .EOF) Then
mvBookMark = .Bookmark
End If
.AddNew
txtFields(0).Text = PID
lblStatus.Caption = "Add record"
mbAddNewFlag = True
SetButtons False
End With
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
If MsgBox("Are you sure you want to delete this record?", vbQuestion + vbYesNo, "Confirm Delete") = vbNo Then
Exit Sub
End If
With adoPrimaryRS
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
Exit Sub
DeleteErr:
MsgBox Err.Description
End Sub
Private Sub cmdRefresh_Click()
'This is only needed for multi user apps
On Error GoTo RefreshErr
adoPrimaryRS.Requery
Exit Sub
RefreshErr:
MsgBox Err.Description
End Sub
Private Sub cmdEdit_Click()
On Error GoTo EditErr
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
oText.Locked = False
Next
txtFields(0).Locked = True
lblStatus.Caption = "Edit record"
mbEditFlag = True
SetButtons False
Exit Sub
EditErr:
MsgBox Err.Description
End Sub
Private Sub cmdCancel_Click()
On Error Resume Next
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
oText.Locked = True
Next
txtFields(0).Locked = True
SetButtons True
mbEditFlag = False
mbAddNewFlag = False
adoPrimaryRS.CancelUpdate
If mvBookMark > 0 Then
adoPrimaryRS.Bookmark = mvBookMark
Else
adoPrimaryRS.MoveFirst
End If
mbDataChanged = False
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
oText.Locked = True
Next
txtFields(0).Locked = True
txtFields(3) = DTPDate.Value
txtFields(7) = cmbBloodGroup.Text
fl = 0
If txtFields(1) = "" Then
MsgBox "Please Enter Patient First Name"
txtFields(1).SetFocus
fl = 1
ElseIf txtFields(2) = "" Then
MsgBox "Please Enter Patient Last Name"
fl = 1
txtFields(2).SetFocus
ElseIf txtFields(5) = "" Then
MsgBox "Please Enter Address"
fl = 1
txtFields(5).SetFocus
ElseIf txtFields(4) = "" Then
MsgBox "Please Enter Contact Number"
fl = 1
txtFields(4).SetFocus
ElseIf txtFields(6) = "" Then
MsgBox "Please Enter Patient Status"
fl = 1
txtFields(6).SetFocus
ElseIf txtFields(0) = "" Then
MsgBox "Please Enter Patient ID"
fl = 1
End If
If OptGender(0).Value = True Then
txtFields(4) = "Male"
ElseIf OptGender(1).Value = True Then
txtFields(4) = "FeMale"
End If
If fl <> 1 Then
adoPrimaryRS.UpdateBatch adAffectAll
If mbAddNewFlag Then
adoPrimaryRS.MoveLast 'move to the new record
End If
mbEditFlag = False
mbAddNewFlag = False
SetButtons True
mbDataChanged = False
Exit Sub
ElseIf fl = 1 Then
For Each oText In Me.txtFields
oText.Locked = False
Next
txtFields(0).Locked = True
Exit Sub
End If
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdFirst_Click()
On Error GoTo GoFirstError
adoPrimaryRS.MoveFirst
mbDataChanged = False
Exit Sub
GoFirstError:
MsgBox Err.Description
End Sub
Private Sub cmdLast_Click()
On Error GoTo GoLastError
adoPrimaryRS.MoveLast
mbDataChanged = False
Exit Sub
GoLastError:
MsgBox Err.Description
End Sub
Private Sub cmdNext_Click()
On Error GoTo GoNextError
If Not adoPrimaryRS.EOF Then adoPrimaryRS.MoveNext
If adoPrimaryRS.EOF And adoPrimaryRS.RecordCount > 0 Then
Beep
'moved off the end so go back
adoPrimaryRS.MoveLast
End If
'show the current record
mbDataChanged = False
Exit Sub
GoNextError:
MsgBox Err.Description
End Sub
Private Sub cmdPrevious_Click()
On Error GoTo GoPrevError
If Not adoPrimaryRS.BOF Then adoPrimaryRS.MovePrevious
If adoPrimaryRS.BOF And adoPrimaryRS.RecordCount > 0 Then
Beep
'moved off the end so go back
adoPrimaryRS.MoveFirst
End If
'show the current record
mbDataChanged = False
Exit Sub
GoPrevError:
MsgBox Err.Description
End Sub
Private Sub SetButtons(bVal As Boolean)
cmdAdd.Visible = bVal
cmdEdit.Visible = bVal
cmdUpdate.Visible = Not bVal
cmdCancel.Visible = Not bVal
cmdDelete.Visible = bVal
cmdClose.Visible = bVal
cmdRefresh.Visible = bVal
cmdNext.Enabled = bVal
cmdFirst.Enabled = bVal
cmdLast.Enabled = bVal
cmdPrevious.Enabled = bVal
DTPDate.Visible = Not bVal
cmbBloodGroup.Visible = Not bVal
Frame4.Visible = Not bVal
cmdViewAll.Visible = bVal
cmdAddGuard.Visible = bVal
End Sub
Private Sub MSComm1_OnComm()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -