Next Chapter 51 Prescription
Prescription
Dim rst As New ADODB.Recordset
Private Sub chameleonButton1_Click()
Unload Me
End Sub
Private Sub chameleonButton10_Click()
Text3 = Text3 + Combo8 + " TDS" + vbCrLf
End Sub
Private Sub chameleonButton2_Click()
DTPicker1 = Date
DTPicker2 = Date
Combo7 = ""
Combo8 = ""
Text3 = ""
Text6 = ""
Text1 = ""
chameleonButton4.Caption = "Edit"
chameleonButton5.Enabled = True
End Sub
Private Sub chameleonButton3_Click()
On Error GoTo ErHand
If Text2.Text = "" Then Exit Sub
If List1 = "" Then
MsgBox "Please Select the Date", vbInformation
List1.SetFocus
Exit Sub
End If
i = MsgBox("Are you sure to delete the record", vbQuestion + vbYesNo)
If i = 6 Then
Conn.Execute "delete from prescription where refno = " & Text2.Text & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'", i
List1.RemoveItem List1.ListIndex
Call chameleonButton2_Click
If i > 0 Then MsgBox "Record Deleted", vbInformation: Exit Sub
MsgBox "No Record Found For Registration Number [ " & Text2.Text & " ] Date [" & List1.Text & " ] ", vbExclamation, App.Title
End If
ErHand:
ErrHandler "Prescription.chameleonButton3_Click()"
End Sub
Private Sub chameleonButton4_Click()
On Error GoTo ErHand
If chameleonButton4.Caption = "Update" Then
Call Update
Call chameleonButton2_Click
Exit Sub
End If
If List1 = "" Then
MsgBox "First select the Desired Date", vbInformation
List1.SetFocus
Exit Sub
End If
i = MsgBox("Are you sure to Modify the record", vbQuestion + vbYesNo)
If i = 7 Then Exit Sub
chameleonButton4.Caption = "Update"
chameleonButton5.Enabled = False
ErHand:
ErrHandler "Prescription.chameleonButton4_Click()"
End Sub
Private Sub Update()
On Error GoTo ErHand
Conn.Execute "update prescription set age=" & Text4 & " where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set doctorname='" & combo6 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set sex='" & Combo5 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set diseasename='" & Combo7 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set title_head='" & Combo8 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set bp= '" & Text6 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set prescription='" & Text3 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set name='" & Text5 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set weight=" & Text1 & " where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set cdate='" & DTPicker1 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
Conn.Execute "update prescription set dateofmarriage='" & DTPicker2 & "' where refno=" & Text2 & " and cdate ='" & Format(List1, "dd-mmm-yy") & "'"
MsgBox "Record Modified", vbInformation
chameleonButton4.Caption = "Edit"
chameleonButton5.Enabled = True
ErHand:
ErrHandler "Prescription.Update()"
End Sub
Private Sub chameleonButton5_Click()
On Error GoTo ErHand
Set rst = New ADODB.Recordset
rst.Open "select * from prescription where refno=" & Text2.Text & " and cdate ='" & Format(DTPicker1, "dd-mmm-yy") & "'", Conn, adOpenDynamic, adLockBatchOptimistic
If rst.EOF Then
rst.AddNew: List1.AddItem Format(DTPicker1, "dd-MMM-yyyy")
Else
i = MsgBox("You Are Going To Modify Record For Registration Number [ " & Text2.Text & " ] Date [" & List1.Text & " ] ,Are You Sure ", vbYesNo + vbExclamation, App.Title)
If i = vbNo Then Exit Sub
End If
rst.Fields("weight") = Text1.Text
rst.Fields("RefNo") = Text2.Text
rst.Fields("prescription") = Text3.Text
rst.Fields("Age") = Text4.Text
rst.Fields("Name") = Text5.Text
rst.Fields("BP") = Text6.Text
rst.Fields("Sex") = Combo5.Text
rst.Fields("DoctorName") = combo6.Text
rst.Fields("diseasename") = Combo7.Text
rst.Fields("title_Head") = Combo8.Text
rst.Fields("CDate") = Format(DTPicker1, "dd-MMM-yyyy")
rst.Fields("dateofmarriage") = Format(DTPicker2, "dd-MMM-yyyy")
rst.UpdateBatch
MsgBox "Record ! Saved...."
List1.Text = Format(DTPicker1, "dd-MMM-yyy")
List1.SetFocus
Call chameleonButton2_Click
Exit Sub
ErHand:
ErrHandler "Prescription.chameleonButton5_Click()"
End Sub
Private Sub chameleonButton6_Click()
If List1 = "" Then
MsgBox "Please Select the Date", vbInformation
List1.SetFocus
Exit Sub
End If
On Error Resume Next
DataEnvironment1.Recordsets.Item("command5").Close
DataEnvironment1.Recordsets.Item("Command5").Open "select * from prescription where refno= " & Val(Text2) & " and cdate = '" & Format(List1, "dd/mmm/yy") & "' ", Conn, adOpenDynamic, adLockOptimistic
PrescriptionReport.Sections(1).Controls.Item("label57").Caption = hos_name
PrescriptionReport.Sections(1).Controls.Item("label58").Caption = hos_add
PrescriptionReport.Show
End Sub
Private Sub chameleonButton7_Click()
Text3 = Text3 + "Your next visit date is : " + STR(DTPicker3) + vbCrLf
End Sub
Private Sub chameleonButton8_Click()
Text3 = Text3 + Combo8 + " OD" + vbCrLf
End Sub
Private Sub chameleonButton9_Click()
Text3 = Text3 + Combo8 + " BD" + vbCrLf
End Sub
Private Sub Form_Load()
On Error GoTo ErHand
Me.Top = (MDIForm1.ScaleHeight - Me.Height) / 2
Me.Left = (MDIForm1.ScaleWidth - Me.Width) / 2
Dim s As Integer
s = 0
Me.Text5 = registration.TxtTitle + " " + registration.txtfirst + " " + registration.txtmiddle + " " + registration.txtlast
Me.Text4 = registration.TxtAge
Me.Text2 = registration.txtRegNo
Me.DTPicker1 = registration.TxtRegDate
Me.Combo5 = registration.TxtSex
Me.combo6 = registration.TxtDoctorIncharge
Set rst = New ADODB.Recordset
rst.Open "select cdate,weight,bp,dateofmarriage from prescription where refno =" & Val(registration.txtRegNo) & " order by cdate", Conn, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
List1.Clear
Else
Text6 = rst!Weight & ""
Text1 = rst!bp & ""
DTPicker2 = rst!dateofmarriage
Do While Not rst.EOF = True
List1.List(s) = Format(rst!CDate & " ", "dd-MMM-yyyy")
s = s + 1
rst.MoveNext
Loop
End If
combo6.Text = registration.TxtDoctorIncharge
Set rst = New ADODB.Recordset
rst.Open "select diname from dimast ", Conn, adOpenDynamic, adLockOptimistic
If rst.EOF Then
rst.Close
Else
Do While Not rst.EOF = True
Combo7.AddItem rst.Fields(0) & ""
rst.MoveNext
Loop
End If
DTPicker3 = Date
Set rst = New ADODB.Recordset
rst.Open "select [item Name] + space(3) + Packing from ItemDetails where [Group]='Medicine'", Conn, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
rst.Close
Exit Sub
End If
Do While Not rst.EOF = True
Combo8.AddItem rst.Fields(0)
rst.MoveNext
Loop
rst.Close
ErHand:
ErrHandler "Prescription.Form_Load()"
End Sub
Private Sub Form_Unload(Cancel As Integer)
registration.Enabled = True
End Sub
Private Sub List1_Click()
On Error Resume Next
Set rst = New ADODB.Recordset
rst.Open "select * from prescription where refno=" & Text2 & " and cdate = '" & Format(List1, "dd-MMM-yy") & "'", Conn, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
Exit Sub
Else
Text3 = rst!Prescription
DTPicker1 = rst!CDate
DTPicker2 = rst!dateofmarriage
Text4 = rst!Age
Text2 = rst!refno
combo6 = rst!doctorname
Combo5 = rst!sex
Combo7 = rst!diseasename
Combo8 = rst!title_head
Text6 = rst!bp
Text5 = rst!Name
Text1 = rst!Weight
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
On Error GoTo ErHand
If Text2 = "" Then
MsgBox "Please Enter RegNo.!", vbInformation
Exit Sub
End If
If KeyAscii = vbKeyReturn Then
Set rst = New ADODB.Recordset
rst.Open "select title,first_name,middle_name,last_name,doctor_incharge from hospital where registration=" & Val(Text2) & "", Conn, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
MsgBox "No record Found!", vbInformation
Exit Sub
End If
Text5 = rst!Title + " " + rst!first_name + " " + rst!middle_name + " " + rst!last_name
combo6 = rst!Doctor_incharge
End If
ErHand:
ErrHandler "Prescription.Text2_KeyPress()"
End Sub
Private Sub Text3_LostFocus()
chameleonButton5.SetFocus
End Sub