Académique Documents
Professionnel Documents
Culture Documents
Objective
Introduction And
Objective
This software “CLINIC MANAGEMENT SYSTEM” is being built for managing
and maintaining patients’ records at any small hospital or clinic at a lower level
by the Doctor or any Administrator and thus to solve the problem on daily basis.
• The system supports keyboard functions and is not solely depended upon
mouse.
• The system is so made that it is easy for a naïve user to work upon.
• New information is fed into the system with ease and any changes or
modifications can be performed without any difficulty.
• The system is fully functional on any version of Windows operating
system.
• The system is capable of handling all types of errors and faults on its
own.
Scope Of Project
Clinic Management System for managing a Clinic is a Computer Based
Management System, which is being designed to cover whole
functioning of any small Hospital or a Clinic. It covers details of all the
patient related activities like there registration , allotment of medicine in the
clinic, fixing appointment with the Doctors and all transaction of the medicine
that takes place in Clinic’s Medical store. The basic idea behind the
development of the Clinic Management System is that there all the activities
related with Patient care and clinic should come under certain framework
and that framework must provide a smooth effective and better co-
coordinated working among various constituent of the clinic.
System
Analysis
Identification Of Need
Analysis Of Project
This Software package Clinic Management System is developed for managing
a Clinic or a small hospital.
Descripti
on
Patient Registration Process:
When a patient enters in a clinic, he enquires for the specified doctor then
looks for an appointment with the same doctor. When a patient gets an
appointment he registers himself with the Clinic/Hospital. Here our system
records all details of the patient. The first module registration starts working
from here.
Registration: The registration process has sub-parts:
• Candidate Name, Age, Address, Sex, Telephone No., E-mail ID, Fees
details, Picture if available.
Data
Flow
Diagrams
Context Level DFD
First Level Of Registration Process
Prescription Process
Patient History In Database
Proposed System
As the alternative of existing system, an updated system is proposed.
Proposed System is developed in Oracle 8 and Visual Basic 6.0.
Overview of Oracle:
Oracle is an object-relational database. A relational database is an
extremely simple way of thinking about and managing the data used in a
business. It is nothing more than a collection of tables of data.
A relational database management system such as Oracle
gives you a way of doing things in an understandable and reasonably
uncompelled way. Oracle basically does three things:
Lets you put data into it.
Keeps the data.
Lets you get the data out and work with it.
The information stored in Oracle is kept in tables. There are three major
characteristics of the tables.
Columns
Rows
Name
Tables of Information:
Oracle stores information in tables. These tables have one or more columns.
The columns heading describe the kind of information kept in the column.
The information is stored row after row. Each unique set of data gets is own
row.
Even though the tables are independent, we can easily see that they are
related. A column in one table is related to a column in the other table. This
relationship is the basis for the name relational database. This is the basic
idea of a relational (sometimes called a relational model). Data is stored in
tables. Tables have columns, rows, and names. Tables can be related to
each other if each has a column with a common type of information.
The retrieval of data from a database can be faster with primary key. A
primary key is a field that uniquely identifies each record in a table is called a
foreign key.
Oracle 8 :
It is used as a back end tool. It is a RDBMS (Relational Data Base
Management System). Operating with in the framework of Network
Computing Architecture (NCA), it provides maximum performance and
scalability through its unique design. In addition Oracle 8 for windows
has been optimized to take full advantage of multitasking and input
output capabilities. The oracle database system provides a number of
benefits, some of which can also be found in other relational database
systems .
Oracle and its components run on more than 100 different hardware and
operating System platform (including all the different versions of unix from
the many different vendors). Oracle Corporation also provides a full suite of
development tools, end user tools, applications and utilities.
Technical Feasibility
This type of feasibility checks proposed system can be technically built of
not. It also focuses on the technical needs of the system, which can be
included.
Operational Feasibility
This type of feasibility is mainly related to human organization and political
aspects. The new skills required in existing staff members is also
considered.
Economic Feasibility
This type of analysis is the most frequently used technique for evaluating the
effectiveness of a proposed system. This procedure determines the benefit
and saving that are expected from proposed system and compare them with
cost.
Social Feasibility:
This type of feasibility analysis determines whether a proposed project will
be acceptable to the people or not . This determination typically examines
the probability of the project being accepted by the group directly affected by
the proposed system change.
Management Feasibility
This is a study of determination of whether a proposed project will be
acceptable to management .If management does not accept a project or
gives a negligible support to it, the project is considered as a non-feasible
one.
Legal Feasibility:
This analysis is a determination of whether a proposed system infringes on
known acts, statuses as well as penalty legislation.
Time Feasibility:
This feasibility study determines whether a proposed project can be
implemented fully within a stipulated time frame.
Considering all above aspects it was decided to go ahead with the proposed
system. The various clinic activities are categorized in to several groups
according to the nature of activities like Reception, ward, Pharmacy etc. This
categorization has been done in such a way that all the groups when
integrated form the completed Clinic Management System. These groups
have been named as Modules.
Scope of further
enhancement
Following modules can be added to this software for its enhancement
Billing :
The billing module facilitates cashier and billing operations for different
categories of patients, providing automatic posting of charges related to
different services like bed charges, lab tests conducted, medicines issued,
consultant's fee, food and beverage charges etc. This module provides for
credit party billing and can be integrated with the financial accounting
module if need be
Stores:
This module caters to the needs of a full-fledged Inventory Management
System. The activities include generating and raising purchase requisitions,
receiving quotations, raising recommendations, raising of purchase order
and much more. With the help of the enquiries provided, one can also keep
a track of stock balance, items below safety stock, items with due expiry
date, excess stock of items, etc
Laboratory:
This module allows for maintenance of investigation requests by patient and
results for various available services such as clinical pathology, X-ray, Ultra
sound etc. Requests can be made from various points including wards,
billing, sample collection point, or the laboratory receiving point. The
laboratory module is integrated with the IP/OP Registration, Wards and
Billing modules
Operation Theater:
This module deals with the operation theater activities such as pre-
anesthetic check-ups, pre-anesthetic notes generation, recording the
anesthesia details, maintaining the list of procedures for various operations,
recording operation details and maintaining the OT scheduling
Blood Bank:
The Blood Bank module provides information on collection and stock of
blood and its components and on results of tests, cross matching
identifications and transfusion reaction. It also keeps information on donors’
mailing list and donation ledgers.
Financial Accounting:
This module deals with cash/bank, receipts/payments, and journal vouchers
etc. Various books of accounts are maintained using this module. Books like
cash book, bank book and ledgers can be generated. This module also
generates reports like trial balance, balance sheet and profit and loss
statement
Payroll:
This module deals with pay (and deductions) calculations, printing of salary
slip, salary certificates, PF statements and also provides a monthly analysis
Medical Records:
This module keeps an abstract of clinical data about patients. It allows easy
retrieval of medical records on patients. A facility exists to maintain the ICD
and CPT information. Data can be analyzed and reports generated on
various parameters like ICD, CPT, age, sex and duration of stay
Other Software
Packages Used
1. RFShape: In preparation of Data flow diagrams ( DFD ) and Entity
Hardware Requirements
Processor - Pentium I (min.)
Speed - 133 MHz (min.)
RAM - 32 MB RAM
Hard Disc capacity - 1.2 GB
Monitor - SVGA color monitor
Printer - Dot Matrix / HP Laser Jet
Software Requirements
Operating System - Windows NT 4.0
Front End - Visual Basic 6.0
Back End -Oracle 8.0
Web Browser - Internet Explorer 5.0
Project
Coding
MODULE
Public conn As New ADODB.Connection
Public Sub main()
If conn.State = adStateOpen Then conn.Close
conn.CursorLocation = adUseClient
conn.Open "provider=msdaora.1;user id=siddharth/sidd"
frmLogin.Show
'frmMDI.Show
End Sub
Public Sub OpenDataConnection(con As ADODB.Connection)
End Sub
Public Sub CloseDataConnection(conn As Object)
End Sub
Public Function LoadNoPicture(PictControl As Object) As Boolean
Dim sTempFile As String
On Error GoTo ErrorHandler
sTempFile = App.Path & "\NoPicture.jpg"
PictControl.Picture = LoadPicture(sTempFile)
LoadNoPicture = True
ErrorHandler:
End Function
Public Function LoadPictureFromDB(PictControl As Object, _
rs As Object, FieldName As String) As Boolean
Dim sTempFile As String
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
On Error GoTo ErrorHandler
sTempFile = App.Path & "\TempPic.jpg"
If Len(Dir$(sTempFile)) > 0 Then
Kill sTempFile
End If
iFileNum = FreeFile
Open sTempFile For Binary As #iFileNum
lFileLength = LenB(rs(FieldName))
abBytes = rs(FieldName).GetChunk(lFileLength)
Put #iFileNum, , abBytes()
Close #iFileNum
PictControl.Picture = LoadPicture(sTempFile)
Kill sTempFile
LoadPictureFromDB = True
ErrorHandler:
End Function
Public Function SavePictureToDB(PictControl As Object, _
rs As Object, FieldName As String) As Boolean
Dim oPict As StdPicture
Dim sTempFile As String
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
On Error GoTo ErrorHandler
Set oPict = PictControl.Picture
sTempFile = App.Path & "\TempPic.jpg"
SavePicture oPict, sTempFile
iFileNum = FreeFile
ErrorHandler:
End Function
WELLCOME
SCREEN
Option Explicit
Private Sub Form_KeyPress(KeyAscii As Integer)
Unload Me
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
End Sub
Private Sub Frame1_Click()
Unload Me
End Sub
Private Sub Timer1_Timer()
If Pb.Value < 100 Then
Pb.Value = Pb.Value + 10
End If
If Pb.Value > 0 And Pb.Value < 20 Then
Label2.Caption = "Checking System...."
End If
If Pb.Value > 20 And Pb.Value < 60 Then
Label2.Caption = "Loading Database...."
End If
If Pb.Value > 60 And Pb.Value < 80 Then
Label2.Caption = "Loading Settings...."
End If
If Pb.Value > 80 Then
Label2.Caption = "Starting...."
Unload Me
frmMDI.Show
End If
End Sub
MDI FORM
Private Sub MDIForm_Load()
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
Dim cn As New ADODB.Connection
Set cn = Nothing
End
End Sub
Private Sub mnuAbout_Click()
frmAbout.Show
End Sub
Private Sub mnuAppointments_Click()
frmAppointments.Show
End Sub
Private Sub mnuBackup_Click()
If MsgBox("Do you want to create a Backup copy of your Database", vbYesNo, "Create Backup?") = vbYes Then
On Error Resume Next
frmThemePath.Show
End If
End Sub
Private Sub mnuCascade_Click()
frmMDI.Arrange vbCascade
End Sub
Private Sub mnuCollection_Click()
frmCollectionReport.Show
End Sub
Private Sub mnuCollectionRep_Click()
frmCollectionRep.Show
End Sub
Private Sub mnuExit_Click()
If MsgBox("Are You Sure?", vbYesNo) = vbYes Then
Dim cn As New ADODB.Connection
Set cn = Nothing
End
End If
End Sub
Private Sub mnuFeesMaster_Click()
frmFeesMaster.Show
End Sub
Private Sub mnuFeesMasterRep_Click()
frmFeesMaster.Show
End Sub
Private Sub mnuModify_Click()
frmModifyRegistration.Show
End Sub
Private Sub mnuNewReg_Click()
frmAddPatient.Show
End Sub
Private Sub mnuOpenPrescription_Click()
frmOpenPrescription.Show
End Sub
Private Sub mnuPassword_Click()
frmConfirmPass.Show
End Sub
Private Sub mnuPatientHistory_Click()
frmModifyRegistration.Show
End Sub
Private Sub mnuPatientMasterRep_Click()
Form1.Show
End Sub
Private Sub mnuPatientReg_Click()
frmPatientReg.Show
End Sub
Private Sub mnuPrinterOption_Click()
CDl.ShowPrinter
End Sub
Private Sub mnuPurchaseEntry_Click()
frmPurchaseEntry.Show
End Sub
Private Sub mnuPurchaseRep_Click()
frmPurchaseRep.Show
End Sub
Private Sub mnuRegister_Click()
frmRegister.Show vbModal
End Sub
Private Sub mnuSearchHelp_Click()
frmSearchHelp.Show
End Sub
Private Sub mnuTiles_Click()
frmMDI.Arrange vbTileHorizontal
End Sub
Private Sub StatusBar1_PanelClick(ByVal Panel As MSComctlLib.Panel)
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If Button.Description = "Exit" Then
Dim cn As New ADODB.Connection
Call CloseDataConnection(conn)
Set cn = Nothing
If MsgBox("Are You Sure?", vbYesNo) = vbYes Then
End
End If
End If
If Button.Description = "About" Then
frmAbout.Show
End If
If Button.Description = "Check Connectivity" Then
Call OpenDataConnection(conn)
If conn.State = adStateOpen Then
Dim strmsg As String
strmsg = "Connection to database available."
MsgBox strmsg, vbInformation, "Success"
Call CloseDataConnection(conn)
Else
strmsg = "Connection to database failed."
MsgBox strmsg, vbExclamation, "Error"
End If
Set cn = Nothing
End If
If Button.Description = "Collection" Then
Screen.MousePointer = vbHourglass
frmCollectionRep.Show
End If
If Button.Description = "Existing Patient" Then
Screen.MousePointer = vbHourglass
frmPatientReg.Show
End If
If Button.Description = "Help" Then
frmSearchHelp.Show
End If
If Button.Description = "Modify Registration" Then
frmModifyRegistration.Show
End If
If Button.Description = "New Patient" Then
Screen.MousePointer = vbHourglass
frmAddPatient.Show
End If
If Button.Description = "Printer Setup" Then
CDl.ShowPrinter
End If
End Sub
ADD PATIENT
Dim cn As New ADODB.Connection
Dim rstData As New ADODB.Recordset
Private Sub Combo1_Click()
If Combo1.Text <> " " Then
Call OpenDataConnection(cn)
Dim rstData As New ADODB.Recordset
SQLstm = "Select * from FeesMaster where FeesID like " & Combo1.Text & " order by FeesID"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
Text6.Text = rstData.Fields("Description").Value
Text7.Text = rstData.Fields("Amount").Value
rstData.MoveNext
Loop
rstData.Close
Else
Text6.Text = "" 'Description
Text7.Text = "" 'Amount
End If
End Sub
Private Sub Command1_Click()
Dim sConn As String
Dim updateData As Boolean
Dim netAmount As Integer
Dim expiryDate As Date
updateData = False
If IsNumeric(Text8.Text) = False Then ' Discount
Text8.Text = 0
End If
If IsNumeric(Text9.Text) = False Then ' Age
Text9.Text = 0
End If
If Text1.Text <> "" Then 'Name must be entered
If Text2.Text <> "" Then 'Address must be entered
If Text9.Text > 0 Then 'Valid Age
If Text8.Text >= 0 Then 'Valid Discount
If optSex(0).Value = False Or optSex(1).Value = False Then
If Combo1.Text <> " " And Combo1.Text <> "" Then
netAmount = Text7.Text - Text8.Text
If netAmount >= 0 Then
PatientSex = ""
If optSex(0).Value = True Then
PatientSex = "M"
Else
PatientSex = "F"
End If
expiryDate = DateAdd("yyyy", 1, Date)
updateData = True
Else
strmsg = "Please give valid 'Discount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text8.SetFocus
End If
Else
strmsg = "Please select 'Fees ID' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.SetFocus
End If
Else
strmsg = "Please select 'Sex' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.SetFocus
End If
Else
strmsg = "Please give valid 'Discount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text8.SetFocus
End If
Else
strmsg = "Please enter valid 'Age' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.SetFocus
End If
Else
strmsg = "Please enter 'Address' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please enter 'Name' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text1.SetFocus
End If
If updateData = True Then
Dim rstData As New ADODB.Recordset
rstData.Open "select * from patientmaster", conn, adOpenKeyset, adLockOptimistic
rstData.AddNew
rstData!patientid = Text5.Text
rstData!patientname = Text1.Text
rstData!age = Text9.Text
If optSex(0).Value = True Then
rstData!sex = "M"
Else
rstData!sex = "F"
End If
rstData!patientaddress = Text2.Text
rstData!telephone = Text3.Text
rstData!emailid = Text4.Text
rstData!regdate = Date
rstData!ExpDate = expiryDate
rstData!Image = cmdlg.FileName
rstData.Update
rstData.Close
If rstData.State = 1 Then Set rstData = Nothing
rstData.Open "select * from fees", conn, adOpenKeyset, adLockOptimistic
rstData.AddNew
rstData!patientid = UCase(Text5.Text)
rstData!dateid = Date
rstData!feesid = (Combo1.Text)
rstData!amount = UCase(Text7.Text)
rstData!discount = Text8.Text
rstData.Update
rstData.Close
strmsg = "Record has been added."
MsgBox strmsg, vbInformation, "Success"
Text1.Text = "" 'Patient Name
Text2.Text = "" 'Patient Address
Text3.Text = "" 'Telephone
Text4.Text = "" 'Email
Text8.Text = "" 'Discount
Text9.Text = "" 'Age
Text5.Text = "" 'Patient ID
optSex(0).Value = False 'Sex Option - Male
optSex(1).Value = False 'Sex Option - Female
picTmp.Picture = LoadPicture()
Combo1.Text = " " 'Fees ID
Text6.Text = "" 'Description
Text7.Text = "" 'Amount
Text10.Text = Date 'Today's date
End If
End Sub
Private Sub Command2_Click()
Set cn = Nothing
Unload Me
End Sub
Private Sub Command3_Click()
On Error Resume Next
With Me.cmdlg
.Filter = "All Graphic Files |*.Gif;*.Jpg;*.Bmp;*.Wmf;"
.DialogTitle = "Select Patient Photo"
.ShowOpen
Me.picTmp.Picture = LoadPicture(Me.cmdlg.FileName)
End With
End Sub
Private Sub Form_Load()
Dim patientid As Integer
Text10.Text = Date
On Error GoTo ErrHandler
Me.Width = 11185
Me.Height = 6130
Combo1.AddItem " "
rstData.Open "select * from feesmaster order by feesid", conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
Combo1.AddItem rstData.Fields("FeesID").Value
rstData.MoveNext
Loop
rstData.Close
Screen.MousePointer = vbDefault
Exit Sub
ErrHandler:
Screen.MousePointer = vbDefault
Debug.Print Err.Description
Resume Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call CloseDataConnection(cn)
Set cn = Nothing
End Sub
Private Sub Text1_LostFocus()
Dim pattern As Boolean
Dim rstData As New ADODB.Recordset
pattern = False
SQLstm = "Select PatientID from PatientMaster where PatientID like '" & Left(Text1.Text, 1) & "%'"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
patientid = rstData.Fields("PatientID").Value
pattern = True
rstData.MoveNext
Loop
If pattern = True Then
split_patient = Right(patientid, Len(patientid) - 2)
split_patient = CInt(split_patient)
split_patient = split_patient + 1
split_len = Len(split_patient)
Text5.Text = UCase(Left(Text1.Text, 1)) & "-"
For i = 1 To 5 - split_len
Text5.Text = Text5.Text & "0"
Next
Text5.Text = Text5.Text & split_patient
Else
Text5.Text = UCase(Left(Text1.Text, 1)) & "-00100"
End If
End Sub
Private Sub Text8_LostFocus()
Dim netAmount As Integer
If IsNumeric(Text7.Text) = False Then ' Amount
Text7.Text = 0
End If
If IsNumeric(Text8.Text) = False Then ' Discount
Text8.Text = 0
End If
netAmount = Text7.Text - Text8.Text
If netAmount < 0 Then
strmsg = "Please give valid 'Discount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text8.SetFocus
End If
End Sub
ADD FEES
Dim cn As New ADODB.Connection
Dim expiryDate As Date
Dim rstData As New ADODB.Recordset
Private Sub Command3_Click()
Dim rstData As New ADODB.Recordset
Dim SQLstm As String
Text7 = 0
Text6 = ""
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
If List1.Selected(i) = True Then
SQLstm = "Select * from FeesMaster where FeesID like '" & i + 1 & "'"
If rstData.State = 1 Then Set rstData = Nothing
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
If List1.SelCount = 1 Then
Text6.Text = rstData.Fields("Description").Value
Else
Text6.Text = Text6 & "," & rstData.Fields("Description").Value
End If
Text7.Text = Val(Text7.Text) + rstData.Fields("Amount").Value
End If
Next
List1.ListIndex = List1.Selected(List1.ListIndex)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
End Sub
Private Sub List1_Click()
List1.ListIndex = List1.ListIndex
End Sub
Private Sub Combo2_Click()
FillData
End Sub
Private Sub FillData()
Dim sConn As String
Dim rstData As New ADODB.Recordset
Dim rstData1 As New ADODB.Recordset
Dim dt As Date
Dim SQLstm As String
SQLstm = "Select * from Fees where PatientID like '" & Combo2.Text & "' and DateID ='" & dt & "'"
rstData1.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
If rstData1.EOF = True Then 'Payment not recd. for today
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo2.Text & "'"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
expiryDate = rstData.Fields("ExpDate").Value
VerifyExpiration
Text3.Text = rstData.Fields("PatientName").Value
Text2.Text = rstData.Fields("PatientAddress").Value
If IsNull(rstData.Fields("Image")) Then
Set picDBImage.Picture = Nothing
picDBImage.Picture = LoadPicture("")
Else
picDBImage.Picture = LoadPicture(rstData.Fields("image"))
End If
Else
Dim strmsg As String
strmsg = "Payment has already been made by this patient for '" & dt & "'."
MsgBox strmsg, vbInformation, "MESSAGE"
ResetFields
End If
End Sub
Private Sub VerifyExpiration()
Dim dt As Date
If expiryDate < dt Then
Dim strmsg As String
strmsg = "Registration for this patient has been 'EXPIRED' on " & expiryDate
strmsg = strmsg & vbCrLf & "Please proceed with caution."
MsgBox strmsg, vbExclamation, "Error"
RegistrationStatus.Caption = "Reg. Expired"
Else
End If
End Sub
Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
FillData
End If
End Sub
Private Sub Command1_Click()
Dim updateData As Boolean
Dim netAmount As Integer
updateData = False
If IsNumeric(Text8.Text) = False Then
Text8.Text = 0
End If
If Combo2.Text <> "" Then
If List1.Text <> "" Or List1.ListCount <> 0 Then
If Text8 >= 0 Then
netAmount = Text7.Text - Text8.Text
If netAmount >= 0 Then
updateData = True
Else
strmsg = "Please give valid 'Discount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text8.SetFocus
End If
Else
strmsg = "Please give valid 'Discount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text8.SetFocus
End If
Else
strmsg = "Please enter valid 'Fees ID' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
End If
Else
strmsg = "Please enter valid 'Patient ID' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
End If
If updateData = True Then
Dim rstData As New ADODB.Recordset
rstData.Open "select * from fees", conn, adOpenKeyset, adLockOptimistic
rstData.AddNew
rstData!patientid = UCase(Combo2.Text)
rstData!dateid = Date
rstData!feesid = (List1.Text)
rstData!amount = UCase(Text7.Text)
rstData!discount = Text8.Text
rstData.Update
rstData.Close
If expiryDate < Date Then
Dim rstData1 As New ADODB.Recordset
SQLstm = "Update PatientMaster Set ExpDate='" & DateAdd("yyyy", 1, Date) & "' where PatientID like '" &
UCase(Combo2.Text) & "'"
Set rstData1 = conn.Execute(SQLstm)
End If
strmsg = "Record has been added."
MsgBox strmsg, vbInformation, "Success"
ResetFields
End If
End Sub
Private Sub ResetFields()
Combo2.Text = ""
Combo2.Text = ""
Text3.Text = ""
Text2.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
End Sub
Private Sub Command2_Click()
Set cn = Nothing
Unload Me
End Sub
Private Sub Form_Load()
Me.Width = 7155
Me.Height = 6630
Call OpenDataConnection(conn)
Dim SQLstm As String
SQLstm = "Select FeesID,description from FeesMaster order by FeesID"
Dim rstData As New ADODB.Recordset
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
List1.AddItem rstData.Fields("FeesID").Value & " " & rstData!Description
rstData.MoveNext
Loop
rstData.Close
SQLstm = "Select PatientID from PatientMaster order by PatientID"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
Combo2.AddItem rstData.Fields("PatientID").Value
rstData.MoveNext
Loop
Dim dt As Date
Text4.Text = Date
Screen.MousePointer = vbDefault
End Sub
Private Sub Text1_Change()
Text1.Text = UCase(Text1.Text)
End Sub
Private Sub Text8_LostFocus()
Dim netAmount As Integer
If IsNumeric(Text8.Text) = False Then ' Discount
Text8.Text = 0
End If
netAmount = Val(Text7.Text) - Val(Text8.Text)
If netAmount < 0 Then
strmsg = "Please give valid 'Discount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text8.SetFocus
End If
End Sub
MEDICINE
PRESCRIPTION
PROCESS
Dim cn As New ADODB.Connection
Dim pat_id As String
Dim expiryDate As Date
Dim date_list As Date
Dim rstData As New ADODB.Recordset
Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
End Sub
Private Sub Combo1_Click()
FillData
End Sub
Private Sub FillData()
On Error Resume Next
Dim rstData As New ADODB.Recordset
Dim rstData1 As New ADODB.Recordset
Dim sConn As String
Dim acceptData As Boolean
SQLstm = "Select * from Fees where PatientID like '" & Combo1.Text & "' and DateID like '" & Date & "'"
Set rstData1 = conn.Execute(SQLstm)
acceptData = True
If rstData1.EOF = True Then 'Payment not recd.
If MsgBox("No Payment Has been Made For This Patient. Continue?", vbYesNo) = vbNo Then
acceptData = False
Combo1.Text = ""
Combo1.SetFocus
End If
End If
If acceptData = True Then
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
expiryDate = rstData.Fields("ExpDate").Value
If expiryDate < Date Then
strmsg = "Registration for this patient has been 'EXPIRED' on " & expiryDate
strmsg = strmsg & vbCrLf & "Please proceed with caution."
MsgBox strmsg, vbExclamation, "Error"
RegistrationStatus.Caption = "Reg. Expired"
Else
RegistrationStatus.Caption = ""
End If
Text1.Text = rstData.Fields("PatientName").Value
Text2.Text = rstData.Fields("Age").Value
Text7.Text = rstData.Fields("Sex").Value
Text5.Text = rstData.Fields("LastVisit").Value
Text4.Text = rstData.Fields("RegDate").Value
Text3.Text = rstData.Fields("History").Value
DTPicker1 = rstData.Fields("NextVisit").Value
If IsNull(rstData.Fields("Image")) Then
Set picDBImage.Picture = Nothing
LoadNoPicture picDBImage
Else
LoadPictureFromDB picDBImage, rstData, "Image"
End If
SQLstm = "Select * from Treatment where PatientID like '" & Combo1.Text & "' order by DateID desc"
Set rstData = conn.Execute(SQLstm)
List1.Clear
Do While Not rstData.EOF
problemid = rstData.Fields("Treatment").Value
problemid = Replace(problemid, vbCrLf, ", ")
If Len(problemid) > 35 Then
problemid = Left(problemid, 35) & "..."
End If
List1.AddItem rstData.Fields("DateID").Value & " | " & problemid
rstData.MoveNext
Loop
pat_id = Combo1.Text
End If
End Sub
Private Sub Command1_Click()
Call CloseDataConnection(cn)
Set cn = Nothing
Unload Me
End Sub
Private Sub Command2_Click()
If Combo1.Text <> "" Then
If Text6.Text <> "" Then
Dim rstData As New ADODB.Recordset
SQLstm = "Select * from Treatment where DateID='" & Date & "' and PatientID like '" & pat_id & "'"
Set rstData = conn.Execute(SQLstm)
If Not rstData.EOF Then
strmsg = "Prescription for the date selected is already present."
strmsg = strmsg & vbCrLf & vbCrLf & "Please change the prescription in 'Prescription...' box and"
strmsg = strmsg & vbCrLf & "click on 'Save' button to update."
MsgBox strmsg, vbExclamation, "Error"
Exit Sub
End If
SQLstm = "Update PatientMaster Set LastVisit='" & Date & "' where PatientID like '" & pat_id & "'"
Set rstData = conn.Execute(SQLstm)
SQLstm = "Update PatientMaster Set NextVisit='" & DTPicker1 & "' where PatientID like '" & pat_id & "'"
Set rstData = conn.Execute(SQLstm)
SQLstm = "Update PatientMaster Set ExpDate='" & DateAdd("yyyy", 1, Date) & "' where PatientID like '" & pat_id & "'"
Set rstData = conn.Execute(SQLstm)
SQLstm = "Insert Into Treatment(PatientID, DateID, Treatment) "
SQLstm = SQLstm & " values('" & pat_id & "',"
SQLstm = SQLstm & "'" & Date & "',"
SQLstm = SQLstm & "'" & Text6.Text & "')"
Set rstData = conn.Execute(SQLstm)
strmsg = "Treatment Has Been Added For " & Date
MsgBox strmsg, vbInformation, "Success"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
DTPicker1 = Date
Combo1.Text = ""
List1.Clear
Combo1.Clear
RegistrationStatus.Caption = ""
DTPicker1 = DateAdd("d", Date, 15)
picDBImage.Picture = LoadPicture()
SQLstm = "Select PatientID from PatientMaster order by PatientID"
Set rstData = conn.Execute(SQLstm)
Do While Not rstData.EOF
Combo1.AddItem rstData.Fields("PatientID").Value
rstData.MoveNext
Loop
Else
strmsg = "Please enter 'Treatment/Prescription' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text6.SetFocus
End If
Else
strmsg = "Please enter valid 'Patient ID' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.Text = ""
Combo1.SetFocus
End If
End Sub
Private Sub Command3_Click()
Text6.Text = ""
Dim date_list As Date
End Sub
Private Sub Command4_Click()
If Text6.Text <> "" Then
Dim rstData As New ADODB.Recordset
SQLstm = "Update PatientMaster Set NextVisit='" & DTPicker1 & "' where PatientID like '" & pat_id & "'"
Set rstData = conn.Execute(SQLstm)
SQLstm = "update Treatment Set Treatment='" & Text6.Text & "' where DateID like '" & date_list & "' and PatientID like '" & pat_id
& "'"
Set rstData = conn.Execute(SQLstm)
Text6.Text = ""
List1.Clear
SQLstm = "Select * from Treatment where PatientID like '" & Combo1.Text & "' order by DateID desc"
Set rstData = conn.Execute(SQLstm)
Do While Not rstData.EOF
problemid = rstData.Fields("Treatment").Value
problemid = Replace(problemid, vbCrLf, ", ")
If Len(problemid) > 35 Then
problemid = Left(problemid, 35) & "..."
End If
List1.AddItem rstData.Fields("DateID").Value & " | " & problemid
rstData.MoveNext
Loop
strmsg = "Treatment Has Been Saved For " & Time
MsgBox strmsg, vbInformation, "Success"
Else
strmsg = "Please enter valid 'Treatment' before saving the record."
MsgBox strmsg, vbExclamation, "Error"
End If
End Sub
Private Sub Command5_Click()
On Error GoTo errRep
List_split = Split(List1.Text, " | ")
SQLstm = "Delete from TreatmentRep"
cn.Execute (SQLstm)
SQLstm = "Insert Into TreatmentRep(PatientID,PatientName,Age,Sex,RegDate,ExpDate,NextVisit,DateID,Treatment) "
SQLstm = SQLstm & "Values ("
SQLstm = SQLstm & "'" & pat_id & "',"
SQLstm = SQLstm & "'" & Text1.Text & "',"
SQLstm = SQLstm & "'" & Text2.Text & "',"
SQLstm = SQLstm & "'" & Text7.Text & "',"
SQLstm = SQLstm & "'" & Text4.Text & "',"
SQLstm = SQLstm & "'" & expiryDate & "',"
SQLstm = SQLstm & "'" & DTPicker1 & "',"
SQLstm = SQLstm & "'" & CDate(List_split(0)) & "',"
SQLstm = SQLstm & "'" & Text6.Text & "')"
cn.Execute (SQLstm)
drTreatmentRep.Refresh
drTreatmentRep.Show
Unload deClinic
Exit Sub
errRep:
If Err.Number = 9 Then
MsgBox ("Kindly select a treatment history for printing.")
End If
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
Me.Width = 10335
Me.Height = 6660
Label3.Caption = Label3.Caption & " " & Date
DTPicker1 = DateAdd("d", Date, 15)
SQLstm = "Select PatientID from PatientMaster order by PatientID"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
MsgBox " Total Patient" & "=" & " " & rstData.RecordCount
Do While Not rstData.EOF
Combo1.AddItem rstData.Fields("PatientID").Value
rstData.MoveNext
Loop
rstData.Close
Screen.MousePointer = vbDefault
Exit Sub
ErrHandler:
Screen.MousePointer = vbDefault
Debug.Print Err.Description
End Sub
Private Sub List1_Click()
Dim rstData As New ADODB.Recordset
List_split = Split(List1.Text, " | ")
SQLstm = "Select * from Treatment where PatientID like '" & pat_id & "' and DateID like #" & CDate(List_split(0)) & "#"
Set rstData = cn.Execute(SQLstm)
Do While Not rstData.EOF
problemid = rstData.Fields("Treatment").Value
Text6.Text = problemid
rstData.MoveNext
Loop
date_list = CDate(List_split(0))
End Sub
MODIFY PATIENT
RECORD
Dim cn As New ADODB.Connection
Dim rstData As New ADODB.Recordset
Private Sub Command1_Click()
Dim sConn As String
Dim updateData As Boolean
updateData = False
If IsNumeric(Text9.Text) = False Then
Text9.Text = 0
End If
If Combo1.Text <> " " And Combo1.Text <> "" Then 'Patient ID entered
If Text1.Text <> "" Then 'Name check
If Text2.Text <> "" Then 'Address check
If Text9.Text > 0 Then 'Valid Age
If Left(Combo1.Text, 1) = UCase(Left(Text1.Text, 1)) Then
updateData = True
Else
strmsg = "First Character of 'Name' and Patient ID mismatch."
MsgBox strmsg, vbExclamation, "Error"
Text1.Text = Left(Combo1.Text, 1) & Text1.Text
Text1.SetFocus
End If
Else
strmsg = "Please enter valid 'Age' before updating the record."
MsgBox strmsg, vbExclamation, "Error"
Text9.SetFocus
End If
Else
strmsg = "Please enter 'Address' before updating the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please enter 'Name' before updating the record."
MsgBox strmsg, vbExclamation, "Error"
Text1.SetFocus
End If
Else
strmsg = "Please enter 'Patient ID' before updating the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.SetFocus
End If
If updateData = True Then
PatientSex = ""
If optSex(0) = True Then
PatientSex = "M"
Else
PatientSex = "F"
End If
Dim rstData As New ADODB.Recordset
SQLstm = "Update PatientMaster set PatientName='" & Text1.Text & "' where PatientID like '" & Combo1.Text & "'"
conn.Execute (SQLstm)
SQLstm = "Update PatientMaster set PatientAddress='" & Text2.Text & "' where PatientID like '" & Combo1.Text & "'"
conn.Execute (SQLstm)
SQLstm = "Update PatientMaster set Telephone='" & Text3.Text & "' where PatientID like '" & Combo1.Text & "'"
conn.Execute (SQLstm)
SQLstm = "Update PatientMaster set EmailID='" & Text4.Text & "' where PatientID like '" & Combo1.Text & "'"
conn.Execute (SQLstm)
SQLstm = "Update PatientMaster set Age='" & Text9.Text & "' where PatientID like '" & Combo1.Text & "'"
conn.Execute (SQLstm)
SQLstm = "Update PatientMaster set Sex='" & PatientSex & "' where PatientID like '" & Combo1.Text & "'"
conn.Execute (SQLstm)
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
SavePictureToDB picTmp, rstData, "Image"
rstData.Update
rstData.Close
strmsg = "The Record Has Been Updated For '" & Combo1.Text & "'"
MsgBox strmsg, vbInformation, "Success"
Combo1.Text = " "
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text9.Text = ""
optSex(0) = False
optSex(1) = False
picTmp.Picture = LoadPicture()
End If
End Sub
Private Sub Command2_Click()
Set cn = Nothing
Unload Me
End Sub
Private Sub Command3_Click()
On Error Resume Next
With Me.cmDlg
.Filter = "All Graphic Files |*.Gif;*.Jpg;*.bmp;*.wmf;"
.DialogTitle = "Find Patient Photo"
.ShowOpen
Me.picTmp.Picture = LoadPicture(Me.cmDlg.FileName)
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
Me.Width = 7440
Me.Height = 6015
SQLstm = "Select PatientID from PatientMaster order by PatientID"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
Combo1.AddItem rstData.Fields("PatientID").Value
rstData.MoveNext
Loop
rstData.Close
Exit Sub
ErrHandler:
Debug.Print Err.Description
End Sub
Private Sub Combo1_Click()
On Error Resume Next
Dim rstData As New ADODB.Recordset
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Text1.Text = rstData.Fields("PatientName").Value
Text2.Text = rstData.Fields("PatientAddress").Value
Text3.Text = rstData.Fields("Telephone").Value
Text4.Text = rstData.Fields("EmailID").Value
Text9.Text = rstData.Fields("Age").Value
If rstData.Fields("Sex").Value = "M" Then
optSex(0) = True
Else
optSex(1) = True
End If
If IsNull(rstData.Fields("Image")) Then
Set picTmp.Picture = Nothing
Else
picTmp.Picture = LoadPicture(rstData!Image)
End If
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then 'Enter Pressed
Dim rstData As New ADODB.Recordset
Dim sConn As String
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
Set rstData = cn.Execute(SQLstm)
If rstData.EOF = True Then 'Patient Code not found
strmsg = "Please enter valid 'Patient ID' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.Text = ""
Combo1.SetFocus
Else
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
cn.Open sConn
rstData.Open SQLstm, cn, adOpenKeyset, adLockOptimistic
Text1.Text = rstData.Fields("PatientName").Value
Text2.Text = rstData.Fields("PatientAddress").Value
Text3.Text = rstData.Fields("Telephone").Value
Text4.Text = rstData.Fields("Email").Value
Text9.Text = rstData.Fields("Age").Value
If rstData.Fields("Sex").Value = "M" Then
optSex(0) = True
Else
optSex(1) = True
End If
LoadPictureFromDB picTmp, rstData, "Image"
End If
End If
End Sub
Private Function LoadPictureFromDB(PictControl As Object, _
rs As Object, FieldName As String) As Boolean
Dim sTempFile As String
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
On Error GoTo ErrorHandler
sTempFile = App.Path & "\TempPic.jpg"
If Len(Dir$(sTempFile)) > 0 Then
Kill sTempFile
End If
iFileNum = FreeFile
Open sTempFile For Binary As #iFileNum
lFileLength = LenB(rs(FieldName))
abBytes = rs(FieldName).GetChunk(lFileLength)
Put #iFileNum, , abBytes()
Close #iFileNum
PictControl.Picture = LoadPicture(sTempFile)
Kill sTempFile
LoadPictureFromDB = True
ErrorHandler:
End Function
Private Function SavePictureToDB(PictControl As Object, _
rs As Object, FieldName As String) As Boolean
Dim oPict As StdPicture
Dim sTempFile As String
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
On Error GoTo ErrorHandler
Set oPict = PictControl.Picture
sTempFile = App.Path & "\TempPic.jpg"
SavePicture oPict, sTempFile
iFileNum = FreeFile
Open sTempFile For Binary Access Read As #iFileNum
lFileLength = LOF(iFileNum)
ReDim abBytes(lFileLength)
Get #iFileNum, , abBytes()
rs.Fields(FieldName).AppendChunk abBytes()
Close #iFileNum
On Error Resume Next
Kill sTempFile
SavePictureToDB = True
ErrorHandler:
End Function
DELETE PATIENT
RECORD
Dim cn As New ADODB.Connection
Dim rstData As New ADODB.Recordset
Private Sub Command1_Click()
Dim sConn As String
Dim updateData As Boolean
updateData = False
If IsNumeric(Text9.Text) = False Then
Text9.Text = 0
End If
If Combo1.Text <> " " And Combo1.Text <> "" Then
If Text1.Text <> "" Then
If Text2.Text <> "" Then
If Text9.Text > 0 Then
If Left(Combo1.Text, 1) = UCase(Left(Text1.Text, 1)) Then
updateData = True
Else
strmsg = "First Character of 'Name' and Patient ID mismatch."
MsgBox strmsg, vbExclamation, "Error"
Text1.Text = Left(Combo1.Text, 1) & Text1.Text
Text1.SetFocus
End If
Else
strmsg = "Please enter valid 'Age' before deleting the record."
MsgBox strmsg, vbExclamation, "Error"
Text9.SetFocus
End If
Else
strmsg = "Please enter 'Address' before deleting the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please enter 'Name' before deleting the record."
MsgBox strmsg, vbExclamation, "Error"
Text1.SetFocus
End If
Else
strmsg = "Please enter 'Patient ID' before deleting the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.SetFocus
End If
If updateData = True Then
PatientSex = ""
If optSex(0) = True Then
PatientSex = "M"
Else
PatientSex = "F"
End If
rstData.Open "select * from patientmaster where patientid='" & Combo1.Text & "'", conn, adOpenKeyset, adLockOptimistic
If rstData.RecordCount > 0 Then
If MsgBox(" Are You Sure?", vbYesNo) = vbYes Then
rstData.Delete
rstData.Close
conn.Execute "delete from collectionrep where patientid='" & Combo1.Text & "'"
Combo1.RemoveItem Combo1.ListIndex
Combo1.Text = " "
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text9.Text = ""
optSex(0) = False
optSex(1) = False
picTmp.Picture = LoadPicture()
End If
End If
End If
End Sub
Private Sub Command2_Click()
Set cn = Nothing
Unload Me
End Sub
Private Sub Command3_Click()
On Error Resume Next
With Me.cmDlg
.Filter = "All Graphic Files |*.Gif;*.Jpg;*.bmp;*.wmf;"
.DialogTitle = "Find Patient Photo"
.ShowOpen
Me.picTmp.Picture = LoadPicture(Me.cmDlg.FileName)
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
Me.Width = 7440
Me.Height = 6015
SQLstm = "Select PatientID from PatientMaster order by PatientID"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
Combo1.AddItem rstData.Fields("PatientID").Value
rstData.MoveNext
Loop
rstData.Close
Exit Sub
ErrHandler:
Debug.Print Err.Description
End Sub
Private Sub Combo1_Click()
On Error Resume Next
Dim rstData As New ADODB.Recordset
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Text1.Text = rstData.Fields("PatientName").Value
Text2.Text = rstData.Fields("PatientAddress").Value
Text3.Text = rstData.Fields("Telephone").Value
Text4.Text = rstData.Fields("EmailID").Value
Text9.Text = rstData.Fields("Age").Value
If rstData.Fields("Sex").Value = "M" Then
optSex(0) = True
Else
optSex(1) = True
End If
If IsNull(rstData.Fields("Image")) Then
Set picTmp.Picture = Nothing
Else
picTmp.Picture = LoadPicture(rstData!Image)
End If
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
If KeyCode = 13 Then
Dim rstData As New ADODB.Recordset
Dim sConn As String
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
Set rstData = cn.Execute(SQLstm)
If rstData.EOF = True Then
strmsg = "Please enter valid 'Patient ID' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.Text = ""
Combo1.SetFocus
Else
SQLstm = "Select * from PatientMaster where PatientID like '" & Combo1.Text & "'"
cn.Open sConn
rstData.Open SQLstm, cn, adOpenKeyset, adLockOptimistic
Text1.Text = rstData.Fields("PatientName").Value
Text2.Text = rstData.Fields("PatientAddress").Value
Text3.Text = rstData.Fields("Telephone").Value
Text4.Text = rstData.Fields("EmailID").Value
Text9.Text = rstData.Fields("Age").Value
If rstData.Fields("Sex").Value = "M" Then
optSex(0) = True
Else
optSex(1) = True
End If
LoadPictureFromDB picTmp, rstData, "Image"
End If
End If
End Sub
Private Function LoadPictureFromDB(PictControl As Object, _
rs As Object, FieldName As String) As Boolean
Dim sTempFile As String
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
On Error GoTo ErrorHandler
sTempFile = App.Path & "\TempPic.jpg"
If Len(Dir$(sTempFile)) > 0 Then
Kill sTempFile
End If
iFileNum = FreeFile
Open sTempFile For Binary As #iFileNum
lFileLength = LenB(rs(FieldName))
abBytes = rs(FieldName).GetChunk(lFileLength)
Put #iFileNum, , abBytes()
Close #iFileNum
PictControl.Picture = LoadPicture(sTempFile)
Kill sTempFile
LoadPictureFromDB = True
ErrorHandler:
End Function
Private Function SavePictureToDB(PictControl As Object, _
rs As Object, FieldName As String) As Boolean
Dim oPict As StdPicture
Dim sTempFile As String
Dim iFileNum As Integer
Dim lFileLength As Long
Dim abBytes() As Byte
On Error GoTo ErrorHandler
Set oPict = PictControl.Picture
sTempFile = App.Path & "\TempPic.jpg"
SavePicture oPict, sTempFile
iFileNum = FreeFile
Open sTempFile For Binary Access Read As #iFileNum
lFileLength = LOF(iFileNum)
ReDim abBytes(lFileLength)
Get #iFileNum, , abBytes()
rs.Fields(FieldName).AppendChunk abBytes()
Close #iFileNum
On Error Resume Next
Kill sTempFile
SavePictureToDB = True
ErrorHandler:
End Function
FEES MASTER
TABLE
Dim cn As New ADODB.Connection
Dim rstData As New ADODB.Recordset
Private Sub Command1_Click()
Dim addFeesData As Boolean
addFeesData = False
If Text3.Text <> "" Then
If IsNumeric(Text2.Text) = True Then
If Text2.Text >= 0 Then
addFeesData = True
Else
strmsg = "Please give valid 'Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please give valid 'Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please give valid 'Description' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text3.SetFocus
End If
If addFeesData = True Then
Dim rstData As New ADODB.Recordset
SQLstm = "Insert into FeesMaster(feesid,Description, Amount) "
SQLstm = SQLstm & "values ('" & Text1.Text & "','" & Text3.Text & "',"
SQLstm = SQLstm & Text2.Text & ")"
conn.Execute (SQLstm)
strmsg = "Record has been added."
MsgBox strmsg, vbInformation, "Success"
Text3.Text = ""
Text2.Text = ""
Text1.Text = Text1.Text + 1
End If
End Sub
Private Sub Command2_Click()
frmModifyFees.Show
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
Set rstData = Nothing
End Sub
Private Sub Form_Load()
Dim feesid As Integer
On Error GoTo ErrHandler
Me.Width = 4125
Me.Height = 2970
Dim rstData As New ADODB.Recordset
SQLstm = "Select FeesID from FeesMaster order by FeesID"
rstData.Open SQLstm, conn, adOpenKeyset, adLockOptimistic
Do While Not rstData.EOF
feesid = rstData.Fields("FeesID").Value
rstData.MoveNext
Loop
rstData.Close
Text1.Text = feesid + 1
Exit Sub
ErrHandler:
Screen.MousePointer = vbDefault
Debug.Print Err.Description
Resume Next
End Sub
MODIFY FEES
Dim cn As New ADODB.Connection
Private Sub Form_Unload(Cancel As Integer)
Call CloseDataConnection(cn)
Set cn = Nothing
End Sub
Private Sub Combo1_Click()
Call OpenDataConnection(cn)
Dim rstData As New ADODB.Recordset
SQLstm = "Select * from FeesMaster where Description like '" & Combo1.Text & "' order by FeesID"
Set rstData = conn.Execute(SQLstm)
Do While Not rstData.EOF
Text2.Text = rstData.Fields("FeesID").Value
Text1.Text = rstData.Fields("Amount").Value
rstData.MoveNext
Loop
rstData.Close
Call CloseDataConnection(cn)
End Sub
Private Sub Command1_Click()
Dim modifyData As Boolean
modifyData = False
If Combo1.Text <> "" Then
If IsNumeric(Text1.Text) = True Then
If Text1.Text >= 0 Then
modifyData = True
Else
strmsg = "Please give valid 'Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text1.SetFocus
End If
Else
strmsg = "Please give valid 'Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text1.SetFocus
End If
Else
strmsg = "Please give valid 'Description' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Combo1.SetFocus
End If
If modifyData = True Then
Call OpenDataConnection(cn)
Dim rstData As New ADODB.Recordset
SQLstm = "Update FeesMaster set Description='" & Combo1.Text & "' where FeesID = " & Text2.Text & ""
Set rstData = conn.Execute(SQLstm)
SQLstm = "Update FeesMaster set Amount=" & Text1.Text & " where FeesID like " & Text2.Text
Set rstData = conn.Execute(SQLstm)
Call CloseDataConnection(cn)
strmsg = "Record has been modified."
MsgBox strmsg, vbInformation, "Success"
Combo1.Text = ""
Text1.Text = ""
Text2.Text = ""
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
If IsNumeric(Text2.Text) = True Then
Call OpenDataConnection(cn)
Dim rstData As New ADODB.Recordset
Dim rstData1 As New ADODB.Recordset
SQLstm = "Select * from Fees where FeesID like " & Text2.Text
Set rstData = conn.Execute(SQLstm)
SQLstm = "Delete From FeesMaster where FeesID like " & Text2.Text
Set rstData1 = conn.Execute(SQLstm)
strmsg = "The Record Has Been Deleted."
Text1.Text = ""
Combo1.RemoveItem Combo1.ListIndex
Text2.Text = ""
MsgBox strmsg, vbInformation, "Success"
Combo1.SetFocus
Combo1.SetFocus
End If
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
Me.Width = 4440
Me.Height = 2985
Dim rstData As New ADODB.Recordset
SQLstm = "Select Description from FeesMaster order by FeesID"
Set rstData = conn.Execute(SQLstm)
Do While Not rstData.EOF
Combo1.AddItem rstData.Fields("Description").Value
rstData.MoveNext
Loop
rstData.Close
Exit Sub
ErrHandler:
Screen.MousePointer = vbDefault
Debug.Print Err.Description
End Sub
MEDICINE
PURCHASE
Dim cn As New ADODB.Connection
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
End Sub
Private Sub Command1_Click()
Dim updateData As Boolean
updateData = False
If Text1.Text <> "" Then
If IsNumeric(Text2.Text) = True Then
If Text2.Text > 0 Then
If IsNumeric(Text3.Text) = True Then
If Text3.Text > 0 Then
updateData = True
Else
strmsg = "Please enter 'Correct Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text3.SetFocus
End If
Else
strmsg = "Please enter 'Correct Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text3.SetFocus
End If
Else
strmsg = "Please enter 'Correct Quantity' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please enter 'Correct Quantity' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please enter 'Medicine Name' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text1.SetFocus
End If
If updateData = True Then
Dim rstData As New ADODB.Recordset
SQLstm = "Insert into PurchaseRegister(MedicineName, QuantityPurchased, Amount, DateID) "
SQLstm = SQLstm & "values ('" & Text1.Text & "',"
SQLstm = SQLstm & Text2.Text & ","
SQLstm = SQLstm & Text3.Text & ","
SQLstm = SQLstm & "'" & DTPicker1 & "')"
Set rstData = conn.Execute(SQLstm)
strmsg = "Record has been added."
MsgBox strmsg, vbInformation, "Success"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
End Sub
Private Sub Command2_Click()
Set cn = Nothing
Unload Me
End Sub
Private Sub Command3_Click()
frmModifyPurchase.Show
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
DTPicker1 = Date
Dim feesid As Integer
Me.Width = 4575
Me.Height = 3510
Exit Sub
ErrHandler:
Debug.Print Err.Description
Resume Next
End Sub
MODIFY
MEDICINE
PURCHASE
Dim cn As New ADODB.Connection
Dim list_nam As String
Private Sub Form_Unload(Cancel As Integer)
Set cn = Nothing
End Sub
Private Sub Command1_Click()
Dim updateData As Boolean
updateData = False
If IsNumeric(Text2.Text) = True Then
If Text2.Text > 0 Then
If IsNumeric(Text3.Text) = True Then
If Text3.Text > 0 Then
strmsg = "Please enter 'Correct Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text3.SetFocus
End If
Else
strmsg = "Please enter 'Correct Amount' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text3.SetFocus
End If
Else
strmsg = "Please enter 'Correct Quantity' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
Else
strmsg = "Please enter 'Correct Quantity' before adding the record."
MsgBox strmsg, vbExclamation, "Error"
Text2.SetFocus
End If
If updateData = True Then
Dim rstData As New ADODB.Recordset
split_list = Split(list_nam, ", ")
SQLstm = "update PurchaseRegister set MedicineName='" & Text1.Text & "' where MedicineName like '" & split_list(0) & "' and
QuantityPurchased like " & CInt(split_list(1)) & " and Amount like " & CInt(split_list(2)) & " and DateID like #" & DTPicker1 & "#"
cn.Execute (SQLstm)
SQLstm = "update PurchaseRegister set QuantityPurchased=" & Text2.Text & " where MedicineName like '" & split_list(0) & "' and
QuantityPurchased like " & CInt(split_list(1)) & " and Amount like " & CInt(split_list(2)) & " and DateID like #" & DTPicker1 & "#"
cn.Execute (SQLstm)
SQLstm = "update PurchaseRegister set Amount=" & Text3.Text & " where MedicineName like '" & split_list(0) & "' and
QuantityPurchased like " & CInt(split_list(1)) & " and Amount like " & CInt(split_list(2)) & " and DateID like #" & DTPicker1 & "#"
cn.Execute (SQLstm)
FillTable
strmsg = "The Record Has Been Updated."
MsgBox strmsg, vbInformation, "Success"
End If
End Sub
Private Sub Command2_Click()
Set cn = Nothing
Unload Me
End Sub
Private Sub Command3_Click()
If MsgBox("Are You Sure?", vbOKCancel, "Delete This Entry?") = vbOK Then
Dim rstData As New ADODB.Recordset
split_list = Split(list_nam, ", ")
SQLstm = "delete from PurchaseRegister where MedicineName like '" & Text1 & "' and QuantityPurchased like " & Text2 & " and
Amount like " & Text3 & " and DateID like '" & DTPicker1 & "'"
conn.Execute (SQLstm)
strmsg = "The Record Has Been Deleted."
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
List1.Clear
MsgBox strmsg, vbInformation, "Success"
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Dim patientid As Integer
Me.Width = 9030
Me.Height = 5520
Text1.Text = ""
DTPicker1 = Date
FillTable
On Error GoTo ErrHandler
Exit Sub
ErrHandler:
Debug.Print Err.Description
Resume Next
End Sub
Private Sub List1_Click()
list_nam = List1.Text
List_split = Split(List1.Text, ", ")
Text1.Text = List_split(0)
Text2.Text = List_split(1)
Text3.Text = List_split(2)
End Sub
Private Sub DTPicker1_Change()
FillTable
End Sub
Private Sub FillTable()
Dim rstData As New ADODB.Recordset
If Text1.Text <> "" Then
SQLstm = "Select * from PurchaseRegister where DateID like '" & DTPicker1 & "' and MedicineName like '" & Text1.Text & "%'"
Else
SQLstm = "Select * from PurchaseRegister where DateID like '" & DTPicker1 & "'"
End If
Set rstData = conn.Execute(SQLstm)
List1.Clear
Do While Not rstData.EOF
List1.AddItem (rstData.Fields("MedicineName").Value & ", " & rstData.Fields("QuantityPurchased").Value & ", " &
rstData.Fields("Amount").Value)
rstData.MoveNext
Loop
End Sub
FORM ABOUT
Option Explicit
Const READ_CONTROL = &H20000
Const KEY_QUERY_VALUE = &H1
Const KEY_SET_VALUE = &H2
Const KEY_CREATE_SUB_KEY = &H4
Const KEY_ENUMERATE_SUB_KEYS = &H8
Const KEY_NOTIFY = &H10
Const KEY_CREATE_LINK = &H20
Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL