⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmadddoctordetails.frm

📁 国外的医院管理系统。基于水晶报表。Crystal Hospital Management System
💻 FRM
📖 第 1 页 / 共 3 页
字号:
      ForeColor       =   &H00FFFFFF&
      Height          =   255
      Index           =   0
      Left            =   240
      TabIndex        =   0
      Top             =   780
      Width           =   1815
   End
End
Attribute VB_Name = "frmAddDoctorDetails"
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 cmbDoctorType_Click()

If cmbDoctorType = "Permanent Doctor" Then
    txtFields(14).Locked = False
    
End If
If cmbDoctorType = "Visiting Doctor" Then
    txtFields(14).Locked = True
    txtFields(14) = ""
End If


End Sub



Private Sub cmdViewAll_Click()
frmDoctorDetails.Show
End Sub

Private Sub Form_Load()


Call Functions.DisableMenu
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select Doctor_ID,Doctor_FName,Doctor_LName,Doctor_Sex,Doctor_NID,Doctor_Address,Doctor_HPhone,Doctor_MPhone,Doctor_Qualfication,Doctor_Specialization,Doctor_Type,Doctor_VCharge,Doctor_CCharge,Doctor_Notes,Doctor_Basic_Sal from Doctor_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
  
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 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()
  Dim DocID As String
  Dim oText As TextBox
  Dim rsDocs As Recordset
  Set rsDocs = New ADODB.Recordset
  
  'On Error GoTo AddErr
  
        DocID = Functions.UID(6, "DocID_")
        rsDocs.Open "Select * from Doctor_Details", cnPatients, adOpenKeyset, adLockPessimistic
              
            While rsDocs.EOF = False
                If rsDocs(0) = DocID Then
                    DocID = Functions.UID(6, "DocID_")
                    flag = True
                    rsDocs.MoveFirst
                Else
                    flag = False
                End If
                rsDocs.MoveNext
            Wend
            
  
            rsDocs.Close
  cmbDoctorType_Click
  
  With adoPrimaryRS
    If Not (.BOF And .EOF) Then
      mvBookMark = .Bookmark
    End If
    .AddNew
    
    For Each oText In Me.txtFields
        oText.Enabled = True
        oText.Locked = False
    Next
    cmbDoctorType.Visible = True
    cmbDoctorType.Text = cmbDoctorType.List(0)
    txtFields(10) = cmbDoctorType.Text
    
    txtFields(0).Text = DocID
    txtFields(0).Enabled = False
    txtFields(10).Enabled = False
    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()
  Dim oText As TextBox
  On Error GoTo EditErr
  

  lblStatus.Caption = "Edit record"
  mbEditFlag = True
  SetButtons False
  

  'Bind the text boxes to the data provider
    For Each oText In Me.txtFields
        oText.Enabled = True
        oText.Locked = False
    Next
    txtFields(0).Enabled = False
    txtFields(10).Enabled = False
    cmbDoctorType.Visible = True
    cmbDoctorType.Text = txtFields(10)
    cmbDoctorType_Click
  Exit Sub
    

EditErr:
  MsgBox Err.Description
End Sub
Private Sub cmdCancel_Click()
  Dim oText As TextBox
  On Error Resume Next

  SetButtons True
  mbEditFlag = False
  mbAddNewFlag = False
  adoPrimaryRS.CancelUpdate
  If mvBookMark > 0 Then
    adoPrimaryRS.Bookmark = mvBookMark
  Else
    adoPrimaryRS.MoveFirst
  End If
  
  
    For Each oText In Me.txtFields
        oText.Locked = True
    Next
    
    cmbDoctorType.Visible = False
    mbDataChanged = False
End Sub

Private Sub cmdUpdate_Click()
  Dim oText As TextBox
  On Error GoTo UpdateErr

  txtFields(10) = cmbDoctorType.Text
  txtFields(3) = cmbGender
  
  If txtFields(0) = "" Or txtFields(2) = "" Or txtFields(3) = "" Or txtFields(4) = "" Or txtFields(5) = "" Or txtFields(8) = "" Or txtFields(9) = "" Or txtFields(10) = "" Or txtFields(11) = "" Or txtFields(12) = "" Then
    MsgBox "Some of the required fields are missing", vbCritical, "Error Occured"
    Exit Sub
  End If
  
  
  adoPrimaryRS.UpdateBatch adAffectAll

  If mbAddNewFlag Then
    adoPrimaryRS.MoveLast              'move to the new record
  End If

  mbEditFlag = False
  mbAddNewFlag = False
  SetButtons True
  mbDataChanged = False
  
   For Each oText In Me.txtFields
    oText.Enabled = False
    oText.Locked = True
  Next
  cmbDoctorType.Visible = False
  

  Exit Sub
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
  cmdViewAll.Visible = bVal
  
  cmbGender.Visible = Not bVal
  
  txtFields(14).Visible = Not bVal
  lblLabels(15).Visible = Not bVal
  


End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -