Vous êtes sur la page 1sur 37

7.

CODE

MAIN FORM

Private Sub Command1_Click()


return_to_main = 1
Reception.Show
Me.Hide
End Sub

Private Sub Command2_Click()


Set_Emp_reg = 0
Emp_Reg.Show
Me.Hide
End Sub

Private Sub Command3_Click()


MaterDataForm.Show
Me.Hide
End Sub

Private Sub Command4_Click()


pat = 0
Appointment.Show
Me.Hide
End Sub

Private Sub Command5_Click()


Set_Emp_reg = emp
Emp_Reg.Show
Me.Hide
End Sub

Private Sub Command6_Click()


Login.Show
Unload Me
End Sub

Private Sub Command7_Click()


Appt_doc.Show
Me.Hide
End Sub

Private Sub Command8_Click()


Pharmacy.Show
Unload Me
End Sub
MASTER DATA FORM
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sqlcmd As String

Private Sub Add_Click()


Dim i As Integer
On Error GoTo errdesc
sqlcmd = "insert into department38 values ('" & Text1.Text & "')"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Text1.Text = ""
Call DepMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Add_DesM_Click()


Dim dept_id, job_id, des_id As Integer
Dim r As ADODB.Recordset
On Error GoTo errdesc

If Text3.Text = "" Then


MsgBox ("Please enter Designation Name!!")
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox ("Please enter Department Name!!")
Exit Sub
End If
If Combo2.Text = "" Then
MsgBox ("Please enter Job Type Name!!")
Exit Sub
End If

Set r = New ADODB.Recordset


sqlcmd = "select id from designation38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic

If (r.BOF = True) Then


des_id = 1
Else
r.Close
sqlcmd = "select max(id) from designation38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
des_id = r.Fields(0).Value + 1
End If
r.Close

sqlcmd = "insert into designation38 values (" & des_id & ", '" & Text3.Text & "','" & Combo2.Text & "','"
& Combo1.Text & "')"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Text3.Text = ""
Call DesgMaster_Click
Exit Sub
errdesc:
dept_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Add_JTM_Click()


Dim i As Integer
On Error GoTo errdesc
sqlcmd = "insert into job_type38 values ('" & Text2.Text & "')"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Text2.Text = ""
Call JobTypeMas_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub Add_RM_Click()
Dim i As Integer
Dim room_id As Integer
Dim r As ADODB.Recordset
On Error GoTo errdesc

If Text5.Text = "" Then


MsgBox ("Please enter Bed/Room Number!!")
Exit Sub
End If
If Combo3.Text = "" Then
MsgBox ("Please enter Bed/Room Type!!")
Exit Sub
End If
If Text4.Text = "" Then
MsgBox ("Please enter Daily Charges!!")
Exit Sub
End If

Set r = New ADODB.Recordset


sqlcmd = "select id from rooms38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic

If (r.BOF = True) Then


room_id = 1
Else
r.Close
sqlcmd = "select max(id) from rooms38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
room_id = r.Fields(0).Value + 1
End If
r.Close
sqlcmd = "insert into rooms38 values (" & room_id & "," & Text5.Text & ",'" & Combo3.Text & "'," &
Text4.Text & ",-1,NULL)"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Text5.Text = ""
Text4.Text = ""
Combo3.Text = ""
Call RoomsMaster_Click
Exit Sub
errdesc:
room_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Add_Store_Click()


Dim i As Integer
Dim item_id As Integer
Dim r As ADODB.Recordset
On Error GoTo errdesc

If Text6.Text = "" Then


MsgBox ("Please enter Item Name!!")
Exit Sub
End If
If Combo4.Text = "" Then
MsgBox ("Please choose ed/Room Type!!")
Exit Sub
End If
If Text8.Text = "" Then
MsgBox ("Please enter Cost!!")
Exit Sub
End If
If Text7.Text = "" Then
MsgBox ("Please enter Total Available Quantity!!")
Exit Sub
End If
Set r = New ADODB.Recordset
sqlcmd = "select id from items38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic

If (r.BOF = True) Then


item_id = 1
Else
r.Close
sqlcmd = "select max(id) from items38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
item_id = r.Fields(0).Value + 1
End If
r.Close

sqlcmd = "insert into items38 values (" & item_id & ",'" & Text6.Text & "','" & Combo4.Text & "','" &
Text7.Text & "'," & Text8.Text & "," & Text8.Text & ")"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Text6.Text = ""
Combo4.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Call StoreMaster_Click
Exit Sub
errdesc:
item_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub ApptMater_Click()


Frame9.Visible = True
Frame3.Visible = True
Frame5.Visible = False
Frame6.Visible = False
Frame7.Visible = False
Frame4.Visible = False
Frame8.Visible = False
Frame10.Visible = False
Frame3.Caption = "Appointment Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from appt38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
Frame9.Visible = False
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
End If
End Sub

Private Sub BillsMaster_Click()


Frame8.Visible = True
Frame3.Visible = True
Frame5.Visible = False
Frame6.Visible = False
Frame7.Visible = False
Frame4.Visible = False
Frame9.Visible = False
Frame10.Visible = False
Frame3.Caption = "Bills Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from bills38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
Frame8.Visible = False
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
End If
End Sub

Private Sub Command1_Click()


Main.Show
Unload Me
End Sub

Private Sub Del_appt_Click()


Dim pat_id, emp_id As Integer
Dim dn, da As Date
Dim rs As ADODB.Recordset
DataGrid1.Col = 0
pat_id = DataGrid1.Text
DataGrid1.Col = 1
emp_id = DataGrid1.Text
DataGrid1.Col = 2
da = CDate(DataGrid1.Text)
sqlcmd = "delete from appt38 where pat_id = " & Str(emp_id) & " and emp_id = " & Str(pat_id) & " and
appt_date = to_date('" & da & "','mm/dd/yy')"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Appointment Deleted Successfully!!"
Call ApptMater_Click
Exit Sub
errdesc:
pat_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub del_billsM_Click()


Dim pat_id, item_id As Integer
On Error GoTo errdesc
DataGrid1.Col = 0
pat_id = DataGrid1.Text
DataGrid1.Col = 1
item_id = DataGrid1.Text
If MsgBox("Are you Sure you want to delete the selected entry from bill?", vbOKCancel, "Delete?") =
vbOK Then
sqlcmd = "delete from bills38 where pat_id = " & Str(pat_id) & " AND item_id = " & Str(item_id)
cn.Execute sqlcmd
End If
rs.Close
Call BillsMaster_Click
Exit Sub
errdesc:
pat_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Del_Click()


Dim a As String
Dim i As Integer
On Error GoTo errdesc
DataGrid1.Col = 0
a = DataGrid1.Text
If MsgBox("Are you Sure you want to delete Department '" & a & "' ?", vbOKCancel, "Delete?") = vbOK
Then
sqlcmd = "delete from department38 where name = '" & a & "'"
cn.Execute sqlcmd
End If
rs.Close
Call DepMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Del_DesM_Click()


Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
i = CInt(DataGrid1.Text)
DataGrid1.Col = 1
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
If MsgBox("Are you Sure you want to Delete Designation Name '" & a & "' ?", vbOKCancel, "Update?") =
vbOK Then
sqlcmd = "delete from designation38 where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Call DesgMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Del_JTM_Click()


Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
DataGrid1.Col = 0
a = DataGrid1.Text
If MsgBox("Are you Sure you want to delete Job Type '" & a & "' ?", vbOKCancel, "Delete?") = vbOK
Then
sqlcmd = "delete from job_type38 where name = '" & a & "'"
cn.Execute sqlcmd
End If
rs.Close
Call JobTypeMas_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Del_RM_Click()


Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
i = CInt(DataGrid1.Text)
DataGrid1.Col = 1
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
If MsgBox("Are you Sure you want to Delete Room Number '" & a & "' ?", vbOKCancel, "Update?") =
vbOK Then
sqlcmd = "delete from rooms38 where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Call RoomsMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Del_Store_Click()


Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
i = CInt(DataGrid1.Text)
DataGrid1.Col = 1
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
If MsgBox("Are you Sure you want to Delete Item '" & a & "' ?", vbOKCancel, "Update?") = vbOK Then
sqlcmd = "delete from items38 where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Call StoreMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub DepMaster_Click()


Frame4.Visible = True
Frame3.Visible = True
Frame5.Visible = False
Frame6.Visible = False
Frame7.Visible = False
Frame8.Visible = False
Frame9.Visible = False
Frame10.Visible = False
Frame3.Caption = "Departments Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from department38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
End If
End Sub

Private Sub DesgMaster_Click()


Dim r As ADODB.Recordset
Dim i As Integer
Frame3.Visible = True
Frame6.Visible = True
Frame4.Visible = False
Frame5.Visible = False
Frame7.Visible = False
Frame8.Visible = False
Frame9.Visible = False
Frame10.Visible = False
'For DataGrid 1
Frame3.Caption = "Designation Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from designation38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh

'For ComboBox 1
Set r = New ADODB.Recordset
sqlcmd = "select name from department38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
Combo1.Clear
If r.EOF And r.BOF Then
MsgBox "No Department Found!"
Else
r.MoveFirst
For i = 1 To r.RecordCount
Combo1.AddItem r.Fields(0).Value
r.MoveNext
Next
End If
r.Close

'For ComboBox 2
Set r = New ADODB.Recordset
sqlcmd = "select name from job_type38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
Combo2.Clear
If r.EOF And r.BOF Then
MsgBox "No Job Type Found!"
Else
r.MoveFirst
For i = 1 To r.RecordCount
Combo2.AddItem r.Fields(0).Value
r.MoveNext
Next
End If
r.Close
End Sub

Private Sub Form_Load()


Set cn = New ADODB.Connection
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Frame3.Visible = False
End Sub

Private Sub JobTypeMas_Click()


Frame3.Visible = True
Frame5.Visible = True
Frame4.Visible = False
Frame6.Visible = False
Frame7.Visible = False
Frame8.Visible = False
Frame9.Visible = False
Frame10.Visible = False
Frame3.Caption = "Job Type Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from job_type38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
End Sub

Private Sub RoomsMaster_Click()


Frame3.Visible = True
Frame7.Visible = True
Frame5.Visible = False
Frame4.Visible = False
Frame6.Visible = False
Frame8.Visible = False
Frame9.Visible = False
Frame10.Visible = False
Frame3.Caption = "Rooms Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from rooms38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
End Sub

Private Sub StoreMaster_Click()


Frame3.Visible = True
Frame10.Visible = True
Frame5.Visible = False
Frame4.Visible = False
Frame6.Visible = False
Frame8.Visible = False
Frame9.Visible = False
Frame7.Visible = False
Frame3.Caption = "Store Master Table"
Set rs = New ADODB.Recordset
sqlcmd = "select * from items38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid1.Visible = False
MsgBox "No Record Found!!"
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
End Sub

Private Sub Upd_Click()


Dim i, ind As Integer
Dim a, b As String
On Error GoTo errdesc
DataGrid1.Col = 0
a = DataGrid1.Text
If MsgBox("Are you Sure you want to update Department Name '" & a & "' ?", vbOKCancel, "Update?") =
vbOK Then
b = InputBox("Enter new name : ", "Update")
sqlcmd = "update department38 set NAME = '" & b & "' where name = '" & a & "'"
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Call DepMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub Upd_DesM_Click()
Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
i = CInt(DataGrid1.Text)
DataGrid1.Col = 1
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
If MsgBox("Are you Sure you want to update Designation Name '" & a & "' ?", vbOKCancel, "Update?") =
vbOK Then
a = InputBox("Enter new name : ", "Update")
sqlcmd = "update designation38 set NAME = '" & a & "' where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Call DesgMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Upd_JTM_Click()


Dim i, ind As Integer
Dim a, b As String
On Error GoTo errdesc
DataGrid1.Col = 0
a = DataGrid1.Text
If MsgBox("Are you Sure you want to update Job Type Name '" & a & "' ?", vbOKCancel, "Update?") =
vbOK Then
b = InputBox("Enter new name : ", "Update")
sqlcmd = "update job_type38 set NAME = '" & b & "' where name = '" & a & "'"
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Call JobTypeMas_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Upd_RM_Click()


Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
i = CInt(DataGrid1.Text)
DataGrid1.Col = 1
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
If MsgBox("Are you Sure you want to update Room Number '" & a & "' ?", vbOKCancel, "Update?") =
vbOK Then
sqlcmd = "update rooms38 set R_NO = " & Text5.Text & ", TYPE='" & Combo3.Text & "', CHARGES
= " & Text4.Text & " where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
rs.Close
Text5.Text = ""
Text4.Text = ""
Combo3.Text = ""
Call RoomsMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Upd_Store_Click()


Dim i, ind As Integer
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
i = CInt(DataGrid1.Text)
DataGrid1.Col = 1
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
ind = MsgBox("Do you Want to update QUANTITY Only...Press No to update whole Record?",
vbYesNoCancel, "UPDATE")
If ind = 6 Then
sqlcmd = "update items38 set TOT_QTY = " & Text9.Text & " where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
Text5.Text = ""
Text4.Text = ""
Combo3.Text = ""
ElseIf ind = 7 Then
sqlcmd = "update items38 set NAME = '" & Text6.Text & "', TYPE='" & Combo4.Text &
"',DESCRIPTION = '" & Text7.Text & "', COST = " & Text8.Text & ", TOT_QTY = " & Text9.Text & "
where id = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
Text5.Text = ""
End If
rs.Close
Call StoreMaster_Click
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
EMPLOYEE REGISTRATION FORM
Option Explicit
Dim sqlcmd As String
Dim cn As ADODB.Connection

Private Sub Add_Click()


Dim r As ADODB.Recordset
Dim emp_id, des_id As Integer
On Error GoTo errdesc

If Combo6.Text = "" Then


MsgBox "Please enter the Department Name"
Exit Sub
End If

If Combo5.Text = "" Then


MsgBox "Please enter the Job-Type Name"
Exit Sub
End If

If Combo7.Text = "" Then


MsgBox "Please enter the Designation Name"
Exit Sub
End If

Set r = New ADODB.Recordset


sqlcmd = "select max(emp_id) from employee38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
emp_id = r.Fields(0).Value + 1
r.Close

Set r = New ADODB.Recordset


sqlcmd = "select id from designation38 where dept_name = '" & Combo6.Text & "' AND job_name = '" &
Combo5.Text & "' AND name = '" & Combo7.Text & "'"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
r.MoveFirst
des_id = r.Fields(0).Value
r.Close

sqlcmd = "insert into employee38 values (" & emp_id & ", '" & Combo1.Text & "','" & Text1.Text & "','" &
Text2.Text & "','" & Text3.Text & "','" & Combo2.Text & "','" & Combo8.Text & "-" & Combo9.Text & "-"
& Combo10.Text & "','" & Combo3.Text & "','" & Combo4.Text & "'," & Text4.Text & ",'" & Text5.Text &
"','" & Text6.Text & "'," & Text7.Text & "," & Text8.Text & "," & Text9.Text & ",'" & Text10.Text & "'," &
Text11.Text & "," & des_id & "," & Text20.Text & "," & Text20.Text & ",'" & Combo13.Text & "-" &
Combo12.Text & "-" & Combo11.Text & "',NULL,1,1,123456)"
MsgBox sqlcmd

cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Call clear_form
Exit Sub
errdesc:
des_id = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub Combo7_DropDown()
Dim i As Integer
Dim r As ADODB.Recordset
Set r = New ADODB.Recordset

If Combo6.Text = "" Then


MsgBox "Please enter the Department Name"
Exit Sub
End If

If Combo5.Text = "" Then


MsgBox "Please enter the Job-Type Name"
Exit Sub
End If
sqlcmd = "Select name from designation38 where dept_name = '" & Combo6.Text & "' AND job_name = '"
& Combo5.Text & "'"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic

Combo7.Clear
If r.EOF And r.BOF Then
MsgBox "No Designation Found!"
Else
r.MoveFirst
For i = 0 To r.RecordCount - 1
Combo7.AddItem r.Fields(0).Value
r.MoveNext
Next i
End If
r.Close
End Sub

Private Sub Command1_Click()


Main.Show
Unload Me
End Sub

Private Sub Del_Click()


Dim i As Integer
Dim a As String
On Error GoTo errdesc
If Label24.Caption = "" Then
MsgBox "Please select an Employee"
Exit Sub
End If
i = Label24.Caption
a = Text1.Text + Text2.Text + Text3.Text
If MsgBox("Are you Sure you want to delete Employee '" & a & "' ?", vbOKCancel, "Delete?") = vbOK
Then
sqlcmd = "delete from employee38 where emp_id = " & CInt(i)
cn.Execute sqlcmd
MsgBox "Employee Successfully deleted."
Call clear_form
End If
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Form_Load()


Dim r, k As ADODB.Recordset
Dim i As Integer
On Error GoTo errdesc
Set cn = New ADODB.Connection
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Call clear_form
Frame7.Visible = True
Add.Enabled = True
View.Enabled = True
del.Enabled = True
If Set_Emp_reg = 0 Then
'For ComboBox 6
Set r = New ADODB.Recordset
sqlcmd = "select name from department38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
Combo6.Clear
If r.EOF And r.BOF Then
MsgBox "No Department Found!"
Else
r.MoveFirst
For i = 1 To r.RecordCount
Combo6.AddItem r.Fields(0).Value
r.MoveNext
Next
End If
r.Close

'For ComboBox 5
Set r = New ADODB.Recordset
sqlcmd = "select name from job_type38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
Combo5.Clear
If r.EOF And r.BOF Then
MsgBox "No Job Type Found!"
Else
r.MoveFirst
For i = 1 To r.RecordCount
Combo5.AddItem r.Fields(0).Value
r.MoveNext
Next
End If
r.Close
Else
Call clear_form
Frame7.Visible = False
Add.Enabled = False
View.Enabled = False
del.Enabled = False
Set r = New ADODB.Recordset
sqlcmd = "select
EMP_ID,TITLE,F_NAME,M_NAME,L_NAME,SEX,DOB,MARRIED,BLOOD_GRP,H_NO,STREET,CI
TY,PIN_CODE,PHONE,MOBILE,E_MAIL,FAX,DESIG_ID,SALARY,REDUCED_SAL,DOC,CALC_D
ATE,PERMISSION,STATUS from employee38 where emp_id = " & CInt(Set_Emp_reg)
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If r.EOF And r.BOF Then
MsgBox "No Such Employee Exists!"
Else
Label24.Caption = r.Fields(0).Value
Combo1.Text = r.Fields(1).Value
Text1.Text = r.Fields(2).Value
Text2.Text = r.Fields(3).Value
Text3.Text = r.Fields(4).Value
Combo2.Text = r.Fields(5).Value
Label29.Caption = r.Fields(6).Value
Combo3.Text = r.Fields(7).Value
Combo4.Text = r.Fields(8).Value
Text4.Text = r.Fields(9).Value
Text5.Text = r.Fields(10).Value
Text6.Text = r.Fields(11).Value
Text7.Text = r.Fields(12).Value
Text8.Text = r.Fields(13).Value
Text9.Text = r.Fields(14).Value
Text10.Text = r.Fields(15).Value
Text11.Text = r.Fields(16).Value

Set k = New ADODB.Recordset


sqlcmd = "select dept_name,job_name,name from designation38 where id = " & CInt(r.Fields(17).Value)
k.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
Combo5.Text = k.Fields(1).Value
Combo6.Text = k.Fields(0).Value
Combo7.Text = k.Fields(2).Value
k.Close

Text20.Text = r.Fields(18).Value
Label27.Caption = r.Fields(19).Value
Label30.Caption = r.Fields(20).Value
End If
End If
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Upd_Click()


Dim i, des_id As Integer
Dim a As String
Dim r As ADODB.Recordset
On Error GoTo errdesc
If Label24.Caption = "" Then
MsgBox "Please select an Employee"
Exit Sub
End If
If Combo6.Text = "" Then
MsgBox "Please enter the Department Name"
Exit Sub
End If

If Combo5.Text = "" Then


MsgBox "Please enter the Job-Type Name"
Exit Sub
End If

If Combo7.Text = "" Then


MsgBox "Please enter the Designation Name"
Exit Sub
End If
i = Label24.Caption
a = Text1.Text + Text2.Text + Text3.Text

Set r = New ADODB.Recordset


sqlcmd = "select id from designation38 where dept_name = '" & Combo6.Text & "' AND job_name = '" &
Combo5.Text & "' AND name = '" & Combo7.Text & "'"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
r.MoveFirst
des_id = r.Fields(0).Value
r.Close

If MsgBox("Are you Sure you want to update Employee '" & a & "' ?", vbOKCancel, "Delete?") = vbOK
Then
sqlcmd = "update employee38 set TITLE ='" & Combo1.Text & "',F_NAME = '" & Text1.Text &
"',M_NAME ='" & Text2.Text & "',L_NAME='" & Text3.Text & "',SEX='" & Combo2.Text & "',DOB='"
& Combo8.Text & "-" & Combo9.Text & "-" & Combo10.Text & "',MARRIED='" & Combo3.Text &
"',BLOOD_GRP='" & Combo4.Text & "',H_NO=" & Text4.Text & ",STREET='" & Text5.Text &
"',CITY='" & Text6.Text & "',PIN_CODE=" & Text7.Text & ",PHONE=" & Text8.Text & ",MOBILE=" &
Text9.Text & ",E_MAIL='" & Text10.Text & "',FAX=" & Text11.Text & ",DESIG_ID=" & des_id &
",SALARY=" & Text20.Text & ",DOC='" & Combo13.Text & "-" & Combo12.Text & "-" &
Combo11.Text & "' where emp_id = " & CInt(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
MsgBox ("Employee Successfully Updated")
If Set_Emp_reg = 0 Then
Call clear_form
Else
Call Form_Load
End If
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub View_Click()


Dim i As Integer
Dim r, k As ADODB.Recordset
On Error GoTo errdesc
Call clear_form
i = InputBox("Enter Employee Registration Number :- ", "Show Employee")
Set r = New ADODB.Recordset
sqlcmd = "select
EMP_ID,TITLE,F_NAME,M_NAME,L_NAME,SEX,DOB,MARRIED,BLOOD_GRP,H_NO,STREET,CI
TY,PIN_CODE,PHONE,MOBILE,E_MAIL,FAX,DESIG_ID,SALARY,REDUCED_SAL,DOC,CALC_D
ATE,PERMISSION,STATUS from employee38 where emp_id = " & CInt(i)
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If r.EOF And r.BOF Then
MsgBox "No Such Employee Exists!"
Else
Label24.Caption = r.Fields(0).Value
Combo1.Text = r.Fields(1).Value
Text1.Text = r.Fields(2).Value
Text2.Text = r.Fields(3).Value
Text3.Text = r.Fields(4).Value
Combo2.Text = r.Fields(5).Value
Label29.Caption = r.Fields(6).Value
Combo3.Text = r.Fields(7).Value
Combo4.Text = r.Fields(8).Value
Text4.Text = r.Fields(9).Value
Text5.Text = r.Fields(10).Value
Text6.Text = r.Fields(11).Value
Text7.Text = r.Fields(12).Value
Text8.Text = r.Fields(13).Value
Text9.Text = r.Fields(14).Value
Text10.Text = r.Fields(15).Value
Text11.Text = r.Fields(16).Value

Set k = New ADODB.Recordset


sqlcmd = "select dept_name,job_name,name from designation38 where id = " & CInt(r.Fields(17).Value)
k.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
Combo5.Text = k.Fields(1).Value
Combo6.Text = k.Fields(0).Value
Combo7.Text = k.Fields(2).Value
k.Close

Text20.Text = r.Fields(18).Value
Label27.Caption = r.Fields(19).Value
Label30.Caption = r.Fields(20).Value
If (r.Fields(22).Value = 1) Then
Option1.Value = True
ElseIf (r.Fields(22).Value = 2) Then
Option2.Value = True
Else
Option3.Value = True
End If
End If
r.Close
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
End Sub
RECEPTION FORM
Option Explicit
Dim e As Integer
Dim sqlcmd As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Add_Click()


Dim r As ADODB.Recordset
Dim pat_id As Integer
On Error GoTo errdesc
Set r = New ADODB.Recordset
sqlcmd = "select pat_id from patient38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic

If (r.BOF = True) Then


pat_id = 1
Else
r.Close
sqlcmd = "select max(pat_id) from patient38"
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
pat_id = r.Fields(0).Value + 1
End If
r.Close
sqlcmd = "insert into patient38 values (" & pat_id & ", '" & Combo1.Text & "','" & Text1.Text & "','" &
Text2.Text & "','" & Text3.Text & "','" & Combo2.Text & "','" & Combo8.Text & "-" & Combo9.Text & "-"
& Combo10.Text & "','" & Combo3.Text & "','" & Combo4.Text & "'," & Text4.Text & ",'" & Text5.Text &
"','" & Text6.Text & "'," & Text7.Text & "," & Text8.Text & "," & Text9.Text & ",'" & Text10.Text & "'," &
Text11.Text & ",'" & Text12.Text & "','" & Text15.Text & "'," & Text13.Text & ",'" & Text18.Text & "')"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Record Successfully Added!!"
Call clear_form
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command1_Click()


On Error GoTo errdesc
If Option3.Value = True Then
sqlcmd = "select * from patient38 where m_name = '" & Text14.Text & "'"
End If
If Option4.Value = True Then
sqlcmd = "select * from employee38 where m_name = '" & Text14.Text & "' and TITLE = 'Dr.'"
End If
MsgBox sqlcmd
Set rs = New ADODB.Recordset
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "No Record Found!!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command2_Click()


pat = Label24.Caption
Appointment.Show
Me.Hide
End Sub

Private Sub Command3_Click()


Dim r As ADODB.Recordset
Dim ad, cd As Date
Dim hr, charge, room_id As Integer
Dim desc, typ As String
On Error GoTo errdesc:
If Label24.Caption = "" Then
MsgBox "Please select a patient."
Exit Sub
End If

If (Command3.Caption = "Allocate Bed") Then


If (Label24.Caption <> "") Then
temp = Label24.Caption
Bed.Show
Me.Hide
End If
ElseIf Command3.Caption = "Deallocate Bed" Then
cd = Now
sqlcmd = "select to_char(ALLOC_DATE,'MM/DD/YYYY HH:MI:SS AM'),charges,id,r_no,type from
rooms38 where PAT_ID = " & Str(Label24.Caption)
Set r = New ADODB.Recordset
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If r.EOF And r.BOF Then
MsgBox "Unexpected Error!!"
Exit Sub
Else
ad = r.Fields(0).Value
charge = r.Fields(1).Value
room_id = r.Fields(2).Value
desc = "Room No. : " & Str(r.Fields(3).Value)
typ = r.Fields(4).Value
End If
r.Close
hr = DateTime.DateDiff("h", ad, cd)
charge = charge * hr
If (charge <> 0) Then
If MsgBox("For using bed/room(for " & Str(hr) & " hr) the patient will be charged Rs." & Str(charge),
vbOKCancel, "Deallocate Bed?") = vbOK Then
sqlcmd = "insert into bills38 values (" & Label24.Caption & "," & room_id & ",'" & typ & "',to_date('"
& cd & "','MM/DD/YYYY HH:MI:SS AM'),'" & desc & "'," & charge & ",'U')"
MsgBox sqlcmd
cn.Execute sqlcmd
sqlcmd = "Update rooms38 set PAT_ID = -1,ALLOC_DATE = NULL where PAT_ID = " &
Str(Label24.Caption)
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Bed/Room has been deallocated!"
End If
Else
sqlcmd = "Update rooms38 set PAT_ID = -1,ALLOC_DATE = NULL where PAT_ID = " &
Str(Label24.Caption)
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Bed/Room has been deallocated!"
End If
End If
Call clear_form
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command4_Click()


pat = Label24.Caption
bills.Show
Me.Hide
End Sub

Private Sub Command5_Click()


On Error GoTo errdesc
If Option3.Value = True Then
sqlcmd = "select * from patient38 where f_name = '" & Text14.Text & "'"
End If
If Option4.Value = True Then
sqlcmd = "select * from employee38 where f_name = '" & Text14.Text & "' and TITLE = 'Dr.'"
End If
MsgBox sqlcmd
Set rs = New ADODB.Recordset
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "No Record Found!!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command6_Click()


On Error GoTo errdesc
If Option3.Value = True Then
sqlcmd = "select * from patient38 where l_name = '" & Text14.Text & "'"
End If
If Option4.Value = True Then
sqlcmd = "select * from employee38 where l_name = '" & Text14.Text & "' and TITLE = 'Dr.'"
End If
MsgBox sqlcmd
Set rs = New ADODB.Recordset
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "No Record Found!!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command7_Click()


On Error GoTo errdesc
If Option3.Value = True Then
sqlcmd = "select * from patient38 where pat_id = " & Text14.Text
End If
If Option4.Value = True Then
sqlcmd = "select * from employee38 where emp_id = " & Text14.Text & " and TITLE = 'Dr.'"
End If
MsgBox sqlcmd
Set rs = New ADODB.Recordset
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "No Record Found!!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command9_Click()


Main.Show
Unload Me
End Sub

Private Sub Del_Click()


Dim a As String
Dim i As Integer
On Error GoTo errdesc
If Label24.Caption = "" Then
MsgBox "Please select a patient."
Exit Sub
End If
i = Label24.Caption
a = Text1.Text + Text2.Text + Text3.Text
If MsgBox("Warning : All corressponding records from ROOMS and BILL would be deleted. Are you Sure
you want to delete Patient '" & a & "' ?", vbOKCancel, "Delete?") = vbOK Then
sqlcmd = "update rooms38 set pat_id = NULL where pat_id = " & CInt(i)
cn.Execute sqlcmd
sqlcmd = "delete from bills38 where pat_id = " & CInt(i)
cn.Execute sqlcmd
sqlcmd = "delete from patient38 where pat_id = " & CInt(i)
cn.Execute sqlcmd
MsgBox "Patient successfully deleted."
End If
Call clear_form
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub Form_Load()
Dim r As ADODB.Recordset
On Error GoTo errdesc
Set cn = New ADODB.Connection
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Frame7.Visible = False
Call clear_form
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub clear_form()


Label24.Caption = ""
Combo1.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text15.Text = ""
Text13.Text = ""
Text18.Text = ""
Label26.Caption = ""

End Sub

Private Sub Option3_Click()


On Error GoTo errdesc
Set rs = New ADODB.Recordset
sqlcmd = "select * from patient38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "No Record Found!!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Command8.Enabled = True
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Option4_Click()


On Error GoTo errdesc
Set rs = New ADODB.Recordset
sqlcmd = "select * from employee38"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "No Record Found!!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Command8.Enabled = False
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Upd_Click()


Dim i, des_id As Integer
Dim a As String
Dim r As ADODB.Recordset
On Error GoTo errdesc
If Label24.Caption = "" Then
MsgBox "Please select a patient."
Exit Sub
End If
i = Label24.Caption
a = Text1.Text + Text2.Text + Text3.Text
If MsgBox("Are you Sure you want to update Patient '" & a & "' ?", vbOKCancel, "Delete?") = vbOK Then
sqlcmd = "update patient38 set TITLE ='" & Combo1.Text & "',F_NAME = '" & Text1.Text &
"',M_NAME ='" & Text2.Text & "',L_NAME='" & Text3.Text & "',SEX='" & Combo2.Text & "',DOB='"
& Combo8.Text & "-" & Combo9.Text & "-" & Combo10.Text & "',MARRIED='" & Combo3.Text &
"',BLOOD_GRP='" & Combo4.Text & "',H_NO=" & Text4.Text & ",STREET='" & Text5.Text &
"',CITY='" & Text6.Text & "',PIN_CODE=" & Text7.Text & ",PHONE=" & Text8.Text & ",MOBILE=" &
Text9.Text & ",E_MAIL='" & Text10.Text & "',FAX=" & Text11.Text & ",NAME_KIN ='" & Text12.Text
& "',RELATION_KIN ='" & Text15.Text & "',PHONE_KIN =" & Text13.Text & ",E_MAIL_KIN ='" &
Text18.Text & "' where pat_id = " & CInt(i)
MsgBox sqlcmd
cn.Execute sqlcmd
End If
MsgBox ("Patient Successfully Updated")
Call clear_form
Exit Sub
errdesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub View_Click()


Dim i As Integer
Dim r As ADODB.Recordset
On Error GoTo errdesc
Call clear_form
Frame7.Visible = True
i = InputBox("Enter Patient Registration Number :- ", "Show Patient")
Set r = New ADODB.Recordset
sqlcmd = "select * from patient38 where pat_id = " & CInt(i)
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If r.EOF And r.BOF Then
MsgBox "No Such Patient Exists!"
Else
Label24.Caption = r.Fields(0).Value
Combo1.Text = r.Fields(1).Value
Text1.Text = r.Fields(2).Value
Text2.Text = r.Fields(3).Value
Text3.Text = r.Fields(4).Value
Combo2.Text = r.Fields(5).Value
Label28.Caption = r.Fields(6).Value
Combo3.Text = r.Fields(7).Value
Combo4.Text = r.Fields(8).Value
Text4.Text = r.Fields(9).Value
Text5.Text = r.Fields(10).Value
Text6.Text = r.Fields(11).Value
Text7.Text = r.Fields(12).Value
Text8.Text = r.Fields(13).Value
Text9.Text = r.Fields(14).Value
Text10.Text = r.Fields(15).Value
Text11.Text = r.Fields(16).Value
Text12.Text = r.Fields(17).Value
Text15.Text = r.Fields(18).Value
Text13.Text = r.Fields(19).Value
Text18.Text = r.Fields(20).Value
Label26.Caption = ""

End If
r.Close
Set r = New ADODB.Recordset
sqlcmd = "select * from rooms38 where pat_id = " & CInt(i)
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If r.EOF And r.BOF Then
Label26.Caption = "The Patient Is Not Admitted."
Command3.Caption = "Allocate Bed"
Else
Label26.Caption = "The Patient Is Admitted in : " & r.Fields(2).Value & " Numbered : " &
Str(r.Fields(1).Value)
Command3.Caption = "Deallocate Bed"
End If
r.Close
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
VIEW APPOINTMENT FORM
Dim k As ADODB.Recordset
Dim cn As ADODB.Connection

Private Sub Command1_Click()


On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
pat = CInt(DataGrid1.Text)
return_to_main = 0
Appointment.Show
Me.Hide
Exit Sub
errdesc:
pat_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command3_Click()


Dim pat_id, emp_id, ind As Integer
Dim d As Date
Dim a As String
On Error GoTo errdesc
ind = DataGrid1.Col
DataGrid1.Col = 0
emp_id = CInt(DataGrid1.Text)
DataGrid1.Col = 1
pat_id = CInt(DataGrid1.Text)
DataGrid1.Col = 2
a = DataGrid1.Text
If ind <> -1 Then
DataGrid1.Col = ind
End If
If Text4.Text <> "" Then
If MsgBox("Are you Sure you want to set prescription for Patient '" & Str(pat_id) & "' ?", vbOKCancel,
"Update?") = vbOK Then
sqlcmd = "update appt38 set prescription = '" & Text4.Text & "' where pat_id = " & Str(pat_id) & " and
emp_id = " & Str(emp_id) & " and appt_date = to_date('" & a & "','mm/dd/yy')"
MsgBox sqlcmd
cn.Execute sqlcmd
Text4.Text = ""
End If
End If
Call refresh_grid1
Exit Sub
errdesc:
pat_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command5_Click()


return_to_main = 0
Main.Show
Unload Me
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
On Error GoTo errordesc
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Text4.Text = ""
Call refresh_grid1
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub refresh_grid1()
Dim da As Date
da = Format(Now, "mm/dd/yy")
Set k = New ADODB.Recordset
sqlcmd = "select * from appt38 where emp_id = " & Str(emp) & " and APPT_DATE = to_date('" & da &
"','mm/dd/yy')"
k.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If k.EOF And k.BOF Then
MsgBox "You do not have any appointments today!"
DataGrid1.Visible = False
Text4.Visible = False
Command3.Visible = False
Command1.Visible = False
k.Close
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = k
DataGrid1.Refresh
End If
End Sub
SET APPOINTMENT FORM
Option Explicit
Dim sqlcmd As String
Dim k, l As ADODB.Recordset
Private Sub Command1_Click()
Dim i As Integer
Dim dn, da As Date
Dim rs As ADODB.Recordset
On Error GoTo errdesc

da = Format(DTPicker1.Value, "mm/dd/yy")
dn = Format(Now, "mm/dd/yy")
If Text1.Text = "" Then
MsgBox ("Please enter Doctor's Employee ID!!")
Exit Sub
End If
If Text2.Text = "" Then
MsgBox ("Please enter Patient's ID!!")
Exit Sub
End If
If da < dn Then
MsgBox ("Please enter a valid appiontment date!!")
Exit Sub
End If

sqlcmd = "insert into appt38 values (" & Text1.Text & "," & Text2.Text & ", to_date('" & da &
"','mm/dd/yy'),'" & Text3.Text & "',NULL)"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Appointment Successfully Added!!"
Text1.Text = ""
If (pat = 0) Then
Text2.Text = ""
End If
Text3.Text = ""
Call refresh_grid2
Exit Sub
errdesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command2_Click()


Dim pat_id, emp_id As Integer
Dim dn, da As Date
Dim rs As ADODB.Recordset
If (DataGrid2.Visible = True) Then
DataGrid2.Col = 0
pat_id = DataGrid2.Text
DataGrid2.Col = 1
emp_id = DataGrid2.Text
DataGrid2.Col = 2
da = CDate(DataGrid2.Text)
sqlcmd = "delete from appt38 where pat_id = " & Str(emp_id) & " and emp_id = " & Str(pat_id) & " and
appt_date = to_date('" & da & "','mm/dd/yy')"
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Appointment Deleted Successfully!!"
Text1.Text = ""
Text3.Text = ""
Call refresh_grid2
Else
MsgBox "There are no appointments to Delete."
End If
Exit Sub
errdesc:
pat_id = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command5_Click()


If return_to_main = 1 Then
Reception.Show
Else
Appt_doc.Show
End If
Unload Me
End Sub

Private Sub DataGrid1_Click()


DataGrid1.Col = 0
Text2.Locked = False
Text1.Text = DataGrid1.Text
Text1.Locked = True
End Sub

Private Sub Form_Load()


Dim i As Integer
Set cn = New ADODB.Connection
On Error GoTo errordesc
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Call clear_form
If pat <> 0 Then
Text2.Locked = False
Text2.Text = Str(pat)
Text2.Locked = True
End If
Set l = New ADODB.Recordset
sqlcmd = "select emp_id,title,f_name,m_name,l_name from employee38 where title = 'Dr.'"
l.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If l.EOF And l.BOF Then
MsgBox "No Doctor Found!!"
l.Close
Else
Set DataGrid1.DataSource = l
End If
DataGrid1.Refresh
Text2.Locked = False
Call refresh_grid2
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub clear_form()
Text1.Text = ""
Text3.Text = ""
End Sub

Private Sub refresh_grid2()


Set k = New ADODB.Recordset
sqlcmd = "select * from appt38 where pat_id = " & Str(pat)
k.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If k.EOF And k.BOF Then
DataGrid2.Visible = False
k.Close
Else
DataGrid2.Visible = True
Set DataGrid2.DataSource = k
End If
DataGrid2.Refresh
End Sub
BED ALLOCATION FORM
Dim rs As ADODB.Recordset
Dim sqlcmd As String

Private Sub Combo3_Click()


Dim i As Integer
On Error GoTo errordesc
Set rs = New ADODB.Recordset
sqlcmd = "select * from rooms38 where TYPE = '" & Combo3.Text & "' and pat_id = -1"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "Sorry...No such rooms/beds are empty!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command1_Click()


Dim i, ind As Integer
Dim ad As Date
On Error GoTo errordesc
ind = DataGrid1.Col
DataGrid1.Col = 0
ad = Now
If (ind <> -1) Then
DataGrid1.Col = ind
End If
i = DataGrid1.Text
If i <> -1 Then
If MsgBox("Are you Sure you want to allocate Bed/Room '" & Str(i) & "' ?", vbOKCancel, "Update?") =
vbOK Then
sqlcmd = "Update rooms38 set PAT_ID = " & Str(temp) & ",ALLOC_DATE=to_date('" & ad &
"','mm/dd/yyyy hh:mi:ss am') where ID = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Bed/Room has been alloted!"
Reception.Show
Unload Me
End If
End If
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command9_Click()


Reception.Show
Unload Me
End Sub
BILLS FORM
Dim rs As ADODB.Recordset
Dim sqlcmd As String

Private Sub Combo3_Click()


Dim i As Integer
On Error GoTo errordesc
Set rs = New ADODB.Recordset
sqlcmd = "select * from rooms38 where TYPE = '" & Combo3.Text & "' and pat_id = -1"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
MsgBox "Sorry...No such rooms/beds are empty!"
Else
Set DataGrid1.DataSource = rs
End If
DataGrid1.Refresh
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command1_Click()


Dim i, ind As Integer
Dim ad As Date
On Error GoTo errordesc
ind = DataGrid1.Col
DataGrid1.Col = 0
ad = Now
If (ind <> -1) Then
DataGrid1.Col = ind
End If
i = DataGrid1.Text
If i <> -1 Then
If MsgBox("Are you Sure you want to allocate Bed/Room '" & Str(i) & "' ?", vbOKCancel, "Update?") =
vbOK Then
sqlcmd = "Update rooms38 set PAT_ID = " & Str(temp) & ",ALLOC_DATE=to_date('" & ad &
"','mm/dd/yyyy hh:mi:ss am') where ID = " & Str(i)
MsgBox sqlcmd
cn.Execute sqlcmd
MsgBox "Bed/Room has been alloted!"
Reception.Show
Unload Me
End If
End If
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command9_Click()


Reception.Show
Unload Me
End Sub

Private Sub Form_Load()


Set cn = New ADODB.Connection
On Error GoTo errordesc
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Exit Sub
errordesc:
i = MsgBox(Err.Description, vbCritical)
End Sub
PHARMACY FORM
Option Explicit
Dim cn As ADODB.Connection
Dim rs, k As ADODB.Recordset
Dim sqlcmd As String
Dim e As Integer

Private Sub Command1_Click()


On Error GoTo errordesc
Set k = New ADODB.Recordset
sqlcmd = "select * from appt38 where pat_id = " & Text1.Text
k.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If k.EOF And k.BOF Then
DataGrid1.Visible = False
k.Close
Else
DataGrid1.Visible = True
Set DataGrid1.DataSource = k
End If
DataGrid1.Refresh
Exit Sub
errordesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command2_Click()


On Error GoTo errordesc
Set rs = New ADODB.Recordset
sqlcmd = "select * from items38 where TYPE = 'Medicine' and NAME = '" & Text2.Text & "'"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid2.Visible = False
rs.Close
Else
DataGrid2.Visible = True
Set DataGrid2.DataSource = rs
End If
DataGrid2.Refresh
Exit Sub
errordesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Command3_Click()


Call fill_grid2
End Sub

Private Sub Command5_Click()


Main.Show
Unload Me
End Sub

Private Sub DataGrid2_Click()


Dim cd As Date
Dim item_id, i, qty, charge As Integer
Dim desc As String
Dim r As ADODB.Recordset
On Error GoTo errordesc
If (Text1.Text = "") Then
MsgBox "Enter Patient ID"
Exit Sub
End If
i = InputBox("Enter Quantity", "SELL")
If (1) Then
Set r = New ADODB.Recordset
sqlcmd = "select * from patient38 where pat_id =" & Text1.Text
r.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If (r.BOF = True) Then
MsgBox "No such patient exists."
Else
r.Close
cd = Now
DataGrid2.Col = 5
qty = DataGrid2.Text
If (i <= qty) Then
DataGrid2.Col = 0
item_id = DataGrid2.Text
DataGrid2.Col = 1
desc = DataGrid2.Text
DataGrid2.Col = 4
charge = DataGrid2.Text
charge = charge * i
sqlcmd = "insert into bills38 values (" & Text1.Text & "," & item_id & ",'Medicine',to_date('" & cd
& "','MM/DD/YYYY HH:MI:SS AM'),'" & desc & "'," & charge & ",'U')"
MsgBox sqlcmd
cn.Execute sqlcmd
qty = qty - i
sqlcmd = "update items38 set TOT_QTY = " & Str(qty) & " where id = " & Str(item_id)
MsgBox sqlcmd
cn.Execute sqlcmd
Call fill_grid2
MsgBox "Medicine Sold!"
Else
MsgBox "Insufficient Quantity"
End If
End If
End If
Exit Sub
errordesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Private Sub Form_Load()


On Error GoTo errordesc
Set cn = New ADODB.Connection
With cn
.ConnectionString = cmd1
.CursorLocation = adUseClient
.Open
End With
Set rs = New ADODB.Recordset
sqlcmd = "select * from items38 where TYPE = 'Medicine'"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid2.Visible = False
rs.Close
Else
DataGrid2.Visible = True
Set DataGrid2.DataSource = rs
End If
DataGrid2.Refresh
Exit Sub
errordesc:
e = MsgBox(Err.Description, vbCritical)
End Sub
Private Sub fill_grid2()
On Error GoTo errordesc
Set rs = New ADODB.Recordset
sqlcmd = "select * from items38 where TYPE = 'Medicine'"
rs.Open sqlcmd, cn, adOpenStatic, adLockOptimistic
If rs.EOF And rs.BOF Then
DataGrid2.Visible = False
rs.Close
Else
DataGrid2.Visible = True
Set DataGrid2.DataSource = rs
End If
DataGrid2.Refresh
Exit Sub
errordesc:
e = MsgBox(Err.Description, vbCritical)
End Sub

Vous aimerez peut-être aussi