Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 31

HOSPITAL MANAGEMENT SYSTEM

CODING

46

HOSPITAL MANAGEMENT SYSTEM

CODING

6. CODING
LOGIN FORM: Dim temp As Integer Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset Private Sub Combo1_Click() Text1.SetFocus End Sub Private Sub Command1_Click() temp = 0 rs.MoveFirst While Not rs.EOF If rs(1) = Combo1.Text And rs(2) = Text1.Text Then MDIForm1.Show login.Hide MsgBox "SYSTEM SUCCESSFULLY LOGGED ON ...", vbInformation, "LOGIN SUCCESSFULLY DONE" temp = 1 End If rs.MoveNext Wend

47

HOSPITAL MANAGEMENT SYSTEM

CODING

If temp = 0 Then MsgBox "SYSTEM CANNOT LOG U ON ,MAKE SURE THAT UR PASSWORD IS CORRECET & THEN TYPE THE PASSWORD AGAIN", vbCritical + vbOKOnly, "INCORRECT PASSWORD" Text1.Text = "" Text1.SetFocus End If End Sub Private Sub Form_Activate() Text1.SetFocus Command1.Enabled = False End Sub Private Sub Form_Load() Text3.Enabled = False OLE2.BackColor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255) dn = (Right(Now, 2)) Timer1.Enabled = True Frame2.Enabled = False Calendar1.Day = Day(Now) Calendar1.Month = Month(Now) Calendar1.Year = Year(Now) + 2 h = Hour(Now) m = Minute(Now) s = Second(Now)

48

HOSPITAL MANAGEMENT SYSTEM

CODING

If h > 12 Then h = h - 12 End If If m > 59 Then m = m - 59 h=h+1 End If If s > 59 Then s = s - 59 m=m+1 Else s=s+1 End If Text3.Text = h & ":" & m & " " & dn Frame1.Enabled = True Call open_db rs.CursorLocation = adUseClient rs.Open "select * from user_table", cn, adOpenDynamic, adLockOptimistic rs1.CursorLocation = adUseClient rs1.Open "select u_name from user_table", cn, adOpenDynamic, adLockOptimistic If rs1.RecordCount > 0 Then rs1.MoveFirst
49

HOSPITAL MANAGEMENT SYSTEM

CODING

While Not rs1.EOF Combo1.AddItem rs1(0) rs1.MoveNext Wend End If End Sub Private Sub Form_Unload(Cancel As Integer) rs.Close rs1.Close End Sub Private Sub Text1_Change() If Len(Text1.Text) > 0 Then Command1.Enabled = True End If End Sub Private Sub Text1_keypress(KeyAscii As Integer) If KeyAscii = 13 Then If Text1.Text = "" Then Command1.Enabled = False Else Command1.SetFocus End If End If End Sub

50

HOSPITAL MANAGEMENT SYSTEM

CODING

Private Sub Text3_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Timer1_Timer() OLE2.BackColor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255) dn = (Right(Now, 2)) h = Hour(Now) m = Minute(Now) s = Second(Now) If h > 12 Then h = h - 12 End If If m > 59 Then m = m - 59 h=h+1 End If If s > 59 Then s = s - 59 m=m+1 Else s=s+1 End If Text3.Text = h & ":" & m & " " & dn End Sub
51

HOSPITAL MANAGEMENT SYSTEM

CODING

REGISTRATION: Dim temp As Integer Dim rs1 As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim rs As New ADODB.Recordset Dim rs3 As New ADODB.Recordset

Private Sub Combo1_Click() If rs.RecordCount > 0 Then temp = 0 rs.MoveFirst While Not rs.EOF If rs(0) = Combo1.Text Then puts temp = 1 End If rs.MoveNext Wend If temp = 0 Then MsgBox "No Matching Record" End If
52

HOSPITAL MANAGEMENT SYSTEM

CODING

Else MsgBox "No record to view", vbInformation End If End Sub Private Sub Command1_Click() rs.AddNew gets rs.update MSRDC1.Refresh MsgBox "Record Successfully Added" Combo1.clear If rs.RecordCount > 0 Then rs.MoveFirst While Not rs.EOF Combo1.AddItem rs(0) rs.MoveNext Wend End If clear Call auto_patid MSRDC1.Refresh End Sub
53

HOSPITAL MANAGEMENT SYSTEM

CODING

Private Sub Command2_Click() rs2.AddNew gets1 rs2.update rs3.MoveFirst While Not rs3.EOF If rs3(0) = Combo1.Text Then rs3.Delete MsgBox "SUCCESSFULLY DELETED", vbInformation End If rs3.MoveNext Wend Call clear End Sub Private Sub Command3_Click() temp = 0 rs3.MoveFirst While Not rs3.EOF If rs3(0) = Text1.Text Then gets3 temp = 1
54

HOSPITAL MANAGEMENT SYSTEM

CODING

rs3.update End If rs3.MoveNext Wend temp = 0 rs.MoveFirst While Not rs.EOF If rs(0) = Text1.Text Then gets temp = 1 rs.update MsgBox "Suceessfully Updated" End If rs.MoveNext Wend If temp = 0 Then MsgBox "No Matching Record" End If MSRDC1.Refresh End Sub Private Sub Command4_Click() rs2.AddNew
55

HOSPITAL MANAGEMENT SYSTEM

CODING

gets3 rs2.update temp = 0 rs3.MoveFirst While Not rs3.EOF If rs3(0) = Combo1.Text Then rs3.Delete MSRDC1.Resultset.Delete MsgBox "Successfully deleted", vbInformation temp = 1 clear End If rs3.MoveNext Wend Combo1.clear If rs3.RecordCount > 0 Then rs3.MoveFirst While Not rs3.EOF Combo1.AddItem rs3(0) rs3.MoveNext Wend End If
56

HOSPITAL MANAGEMENT SYSTEM

CODING

MSRDC1.Refresh End Sub Private Sub Command5_Click() Call clear Call auto_patid Text2.SetFocus End Sub Private Sub Form_Load() Call open_db rs.CursorLocation = adUseClient rs.Open "select * from pat_det", cn, adOpenDynamic, adLockOptimistic rs2.CursorLocation = adUseClient rs2.Open "select * from pat_his", cn, adOpenDynamic, adLockOptimistic rs3.CursorLocation = adUseClient rs3.Open "select * from pat_vir_det", cn, adOpenDynamic, adLockOptimistic Call auto_patid If rs3.RecordCount > 0 Then rs3.MoveFirst While Not rs3.EOF Combo1.AddItem rs3(0) rs3.MoveNext Wend
57

HOSPITAL MANAGEMENT SYSTEM

CODING

End If MSRDC1.Visible = False End Sub Public Sub auto_patid() If rs1.State = 1 Then rs1.Close rs1.CursorLocation = adUseClient rs1.Open "select max(p_id) from pat_det", cn, adOpenDynamic, adLockOptimistic If rs.RecordCount = 0 Then Text1.Text = 1 Else Text1.Text = rs1(0) Text1.Text = Text1.Text + 1 End If End Sub Public Sub gets() rs(0) = Text1.Text rs(1) = Text2.Text If Option1.Value = True Then rs(2) = "Male" Else rs(2) = "Female" End If rs(3) = Text3.Text rs(4) = Text4.Text
58

HOSPITAL MANAGEMENT SYSTEM

CODING

rs(5) = Text5.Text rs(6) = Text6.Text rs(7) = Text7.Text rs(8) = Text8.Text End Sub Public Sub gets3() rs2(0) = Text1.Text rs2(1) = Text2.Text If Option1.Value = True Then rs2(2) = "Male" Else rs2(2) = "Female" End If rs2(3) = Text3.Text rs2(4) = Text4.Text rs2(5) = Text5.Text rs2(6) = Text6.Text rs2(7) = Text7.Text rs2(8) = Text8.Text End Sub Public Sub puts() Text1.Text = rs(0) Text2.Text = rs(1) If rs(2) = "Male" Then Option1.Value = True
59

HOSPITAL MANAGEMENT SYSTEM

CODING

Else Option2.Value = True End If Text3.Text = rs(3) Text4.Text = rs(4) Text5.Text = rs(5) Text6.Text = rs(6) Text7.Text = rs(7) Text8.Text = rs(8) End Sub Public Sub clear() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" Text8.Text = "" Option1.Value = True End Sub Sub puts1() Text1.Text = rs(1) End Sub

60

HOSPITAL MANAGEMENT SYSTEM

CODING

Private Sub Timer1_Timer() Label2.ForeColor = RGB(Rnd() * 255, Rnd() * 255, Rnd() * 255) End Sub Private Sub Form_Unload(Cancel As Integer) Call close_db End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii >= 65 And KeyAscii <= 122 Or KeyAscii = 46 Or KeyAscii = 8 Or KeyAscii = 13 Then Text2.SetFocus Else MsgBox "ONLY ALPHABETIC DATA", vbInformation KeyAscii = 0 End If If KeyAscii = 13 Then If Text2.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text3.SetFocus End If End If End Sub
61

HOSPITAL MANAGEMENT SYSTEM

CODING

Private Sub Text3_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii = 13 Then Text3.SetFocus Else MsgBox "ONLY NUMERIC DATA", vbInformation KeyAscii = 0 End If If KeyAscii = 13 Then If Text3.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text4.SetFocus End If End If End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text4.Text = "" Then

62

HOSPITAL MANAGEMENT SYSTEM

CODING

MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text5.SetFocus End If End If End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text5.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text6.SetFocus End If End If End Sub Private Sub Text6_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then
63

HOSPITAL MANAGEMENT SYSTEM

CODING

If Text6.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text7.SetFocus End If End If End Sub Private Sub Text7_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii = 13 Then Text7.SetFocus Else MsgBox "ONLY NUMERIC DATA", vbInformation KeyAscii = 0 End If If KeyAscii = 13 Then If Text7.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text8.SetFocus End If

64

HOSPITAL MANAGEMENT SYSTEM

CODING

End If End Sub Private Sub Text8_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Text8.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Command1.SetFocus End If End If End Sub Public Sub gets1() rs2(0) = Text1.Text rs2(1) = Text2.Text If Option1.Value = True Then rs2(2) = "Male" Else rs2(2) = "Female" End If
65

HOSPITAL MANAGEMENT SYSTEM

CODING

rs2(3) = Text3.Text rs2(4) = Text4.Text rs2(5) = Text5.Text rs2(6) = Text6.Text rs2(7) = Text7.Text rs2(8) = Text8.Text End Sub

APPOINTMENT: Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim rs3 As New ADODB.Recordset Dim rs4 As New ADODB.Recordset Dim rs5 As New ADODB.Recordset Dim rs6 As New ADODB.Recordset Dim temp As Variant Dim temp1 As Integer Private Sub Combo1_Click() rs.MoveFirst While Not rs.EOF
66

HOSPITAL MANAGEMENT SYSTEM

CODING

If rs(0) = Combo1.Text Then puts End If rs.MoveNext Wend End Sub Private Sub Combo2_Click() rs1.MoveFirst While Not rs1.EOF If rs1(0) = Combo2.Text Then puts1 End If rs1.MoveNext Wend End Sub Private Sub Combo3_Click() rs2.MoveFirst While not rs2.EOF
67

HOSPITAL MANAGEMENT SYSTEM

CODING

If rs2 (0) = Combo3.Text Then puts3 End If rs2.MoveNext Wend End Sub Private Sub Command1_Click () rs2.MoveFirst While Not rs2.EOF If rs2(0) = Text10.Text Then MsgBox ("This Appointment ID already exists, if you want to modify this record user MODIFY button..."), vbInformation Call clear Call auto_patid Text2.SetFocus Exit Sub End If rs2.MoveNext Wend rs2.AddNew
68

HOSPITAL MANAGEMENT SYSTEM

CODING

gets2 rs2.update MsgBox "Record Succesfully Added", vbInformation MSRDC1.Refresh End Sub Private Sub Command2_Click () rs.MoveFirst While Not rs.EOF If rs(0) = Combo1.Text Then gets rs.update MsgBox "Suceessfully Updated" End If rs.MoveNext Wend End Sub Private Sub Command3_Click () Call clear Call auto_patid End Sub Private Sub Form_Load () MSRDC1.Visible = False
69

HOSPITAL MANAGEMENT SYSTEM

CODING

Call open_db rs.CursorLocation = adUseClient rs.Open "select * from pat_det", cn, adOpenDynamic, adLockOptimistic rs1.CursorLocation = adUseClient rs1.Open "select * from DOC_det", cn, adOpenDynamic, adLockOptimistic rs2.CursorLocation = adUseClient rs2.Open "select * from out_det", cn, adOpenDynamic, adLockOptimistic rs3.CursorLocation = adUseClient rs3.Open "select p_id from out_det", cn, adOpenDynamic, adLockOptimistic rs6.CursorLocation = adUseClient rs6.Open "select max(a_id) from out_det", cn, adOpenDynamic, adLockOptimistic rs5.CursorLocation = adUseClient rs5.Open "select a_id from out_det", cn, adOpenDynamic, adLockOptimistic rs4.CursorLocation = adUseClient rs4.Open "select * from pat_vir_det", cn, adOpenDynamic, adLockOptimistic Call auto_patid If rs4.RecordCount > 0 Then rs4.MoveFirst While Not rs4.EOF Combo1.AddItem rs4(0)
70

HOSPITAL MANAGEMENT SYSTEM

CODING

rs4.MoveNext Wend End If If rs1.RecordCount > 0 Then rs1.MoveFirst While Not rs1.EOF Combo2.AddItem rs1(0) rs1.MoveNext Wend End If Text6.Text = Date If rs5.RecordCount > 0 Then rs5.MoveFirst While Not rs5.EOF Combo3.AddItem rs5(0) rs5.MoveNext Wend End If End Sub Public Sub puts() Text1.Text = rs(1) Text2.Text = rs(4) Text3.Text = rs(5) Text4.Text = rs(6)
71

HOSPITAL MANAGEMENT SYSTEM

CODING

Text5.Text = rs(7) End Sub Public Sub puts4() Text6.Text = rs2(4) Text7.Text = rs2(5) Text8.Text = rs2(2) Text9.Text = rs2(3) End Sub Public Sub gets() rs2(0) = Combo1.Text rs2(1) = Combo2.Text rs2(2) = Text8.Text rs2(3) = Text9.Text rs2(4) = Text6.Text temp = Date + Text7.Text MsgBox (temp) rs2(5) = temp End Sub Public Sub gets2() Dim temp As Variant rs2(0) = Text10.Text rs2(1) = Combo1.Text rs2(2) = Combo2.Text rs2(3) = Text8.Text rs2(4) = Text9.Text rs2(5) = Text6.Text temp = Date + Day(Text7.Text)
72

HOSPITAL MANAGEMENT SYSTEM

CODING

MsgBox (temp) rs2(6) = temp End Sub

Public Sub puts1() Text11.Text = rs1(1) End Sub Private Sub Form_Unload(Cancel As Integer) Call close_db End Sub Public Sub clear() Combo1.Text = "Select" Combo2.Text = "Select" Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text7.Text = "" Text8.Text = "" Text9.Text = "" Text11.Text = "" End Sub Public Sub puts3() Text10.Text = rs2(0)
73

HOSPITAL MANAGEMENT SYSTEM

CODING

Text6.Text = rs2(5) Text7.Text = rs2(6) Text8.Text = rs2(3) Text9.Text = rs2(4) End Sub

Public Sub auto_patid() If rs5.RecordCount = 0 Then Text10.Text = 1 Else Text10.Text = rs6(0) Text10.Text = Text10.Text + 1 End If End Sub Private Sub Text1_keypress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Text10_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Text11_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub

74

HOSPITAL MANAGEMENT SYSTEM

CODING

Private Sub Text2_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Text5_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub Private Sub Text7_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Or KeyAscii = 13 Then Text7.SetFocus Else MsgBox "ONLY NUMERIC DATA", vbInformation KeyAscii = 0 End If If KeyAscii = 13 Then Text8.SetFocus End If End Sub
75

HOSPITAL MANAGEMENT SYSTEM

CODING

Private Sub Text8_KeyPress(KeyAscii As Integer) If KeyAscii >= 65 And KeyAscii <= 122 Or KeyAscii = 46 Or KeyAscii = 8 Or KeyAscii = 13 Then Text8.SetFocus Else MsgBox "ONLY ALPHABETIC DATA", vbInformation KeyAscii = 0 End If If KeyAscii = 13 Then If Text8.Text = "" Then MsgBox "PLEASE ENTER ANY VALUE DONT LEAVE AS NULL", vbInformation Else Text9.SetFocus End If End If End Sub

76

You might also like