Professional Documents
Culture Documents
Designing and Interfacing A Hospital-Based Database System: B.SC Engineering Thesis Paper On " " (A Case Study of BIRDEM)
Designing and Interfacing A Hospital-Based Database System: B.SC Engineering Thesis Paper On " " (A Case Study of BIRDEM)
On
Dhaka, Bangladesh.
Submitted By:-
ii
Certification
We also declare that neither this nor any part thereof has been
submitted elsewhere for the award of any degree.
-------------------- -------------------
Jahid Hasan
Supervised By:
-------------------
iii
CONTENTS AT A GLANCE
PREFACE
ABSTRACT
1. Introduction
.NET framework
iv
Acknowledgement
Authors would like to express their sincere and hearty gratitude and profound
indebtedness to their respectful teacher Ms Rosina Surovi Khan, Assistant
Professor, AUST, for her constant timely and appropriate guidance, helpful
advice, invaluable assistance and endless patience throughout the progress of
their work, without which the work could not have been completed.
Authors also acknowledge with hearty thanks to all the members of the
BIRDEM hospital for their important information and cooperation.
Finally, authors acknowledge all cooperation of their friends, who helped them
through giving their important time, their knowledge and their best advice.
Special thanks to our parents and elders for their help and support.
v
Table of Contents
PREFACE ………………………………………………………………………………ix
ABSTRACT …………………………………………………………………………… x
1. INTRODUCTION………………………………………………………… 1
vi
2.5 Implementation in SQL Server ……………………………49
vii
4. CONCLUSION & FUTURE WORK ……………115
REFERENCES……………………………………………………………………133
viii
PREFACE
To start with the system study we visited Bangladesh Institute of Research and
Rehabilitation for Diabetes, Endocrine and Metabolic Disorders (BIRDEM). We
saw their system, studied it and tried to develop a better system. Our system is
an automated system for Hospital Management. This gave us the idea of the
different fields that ought to be in a Hospital Management System such as
patient registration, his/her advance payment, the records, the details etc. and
also how a software system can make the work easy both for the hospital staff
and the patients. Moreover, the evaluation helped us to arrive at the conclusion
that the automated software is far more superior to the manual ones.
ix
ABSTRACT
Our motive is to develop a software that is very much user friendly and easy to
gather information in a very short time. We try to make our software reliable
and comfortable.
Chapter 1 Introduction
In this chapter we describe the entities and attributes. We draw the Entity
Relationship Diagram (ERD) and Tables. We determine the attributes of tables
and its data types. We also find functional dependencies and normalize all the
tables. Then we implement our database in SQL Server and finally we execute
some complex queries on the system.
We made a research on Interface Design Guidelines and designed our front end
in C#. We applied some of the guidelines in our front end.
We control our software security using C#. We Insert Delete, Update and
Search data from the database in our software. We used a DLL file so that we
x
can easily access to any Operating System and we don’t need to load our
database.
We tried to Save, Delete and Update data using Data Grid view and we also
tried to use Trigger in SQL Server but we cannot complete them. So we include
it as a part of future work.
xi
C H A P T E R 1
INTRODUCTION
What is a Database?
Databases collect items on which the user can carry out various
operations such as viewing, navigating, creating tables, and
searching. Databases can be seen as a symbolic form of the
computer age. [2]
Advantages of Database
1
Improved data access to users through use of host and query
languages.
Designing &
Interfacing
Our Thesis Teacher Ms. Rosina Surovi Khan decided that we have to complete
the design part in semester 4/1 and interfacing part in semester 4/2. In the
introductory class of the thesis our respected madam suggested to select a
specific database system to work on.
Banking System
Computer Sales Management System
Hospital Management System
We saw the demos of the respective systems from different sources and all the
group members decided to do the thesis on Hospital Management System (A
Case Study of BIRDEM) because the system is less complex and easy to study.
Most Banking Systems and Computer Sales Management Systems are controlled
using online based software where users can access from any part of the
country. But we are determined to make desktop based software. So we decided
2
to choose Hospital Management System based on a Case Study of BIRDEM. We
try our best to make the system efficient and user friendly with the help of our
database and front end software.
# Thesis Overview
DATABASE
DESIGNING INTERFACING
3
C H A P T E R 2
Entity
4
Attribute
Data Type
5
Fig1: Determining Entities and Attributes.
6
2.2 Entity Relationship Diagram (ERD):
7
2.3 Relational Model:
After completing the ERD successfully we made the relational model
(table schemas) taking into account all the entities and the relationships.
Patient Table:-
Room Table:-
Receptionist Table:-
Admission Table:-
Doctor Table:-
8
Appointment Table:-
Bill Table:-
Accountant Table:-
Payment Table:-
Medicine Table:-
Prescription Table: -
9
Test Table:-
Assist Table:-
OT Table:-
Ot_id Ot_room_no
Operation Table:-
Department Table:-
Doctor_from_Department Table:-
Nurse Table:-
10
Nursing_Service Table:-
This is a junction table between Patient, Room & Ward Boy tables.
Driver Table:-
Ambulance Table:-
Carriers Table:-
11
Carrying Service Table:-
Patient table
Room table
12
Receptionist table
Admission table
13
Doctor table:
Appointment table
14
Bill table
Accountant table
15
Payment table
Medicine table
16
Prescription table
Test table
17
Assist table
OT table
18
Operation table
Department table
19
Doctor_from_Department table
Nurse table
20
Nursing_Service table
Ward_boy table
21
Cleaning_Service table
Driver table
22
Ambulance table
Ambulance_Service table
23
Carriers table
Carrying_Service table
24
2.3.2 Explanation of Relational Model
25
# Relational model for Receptionist, Patient and Room Entities:
Receptionist, Patient and Room Entities become Receptionist, Patient and Room
tables.
Patient Table:-
Room Table:-
Receptionist Table:-
Admission Table:-
Primary Key of the Patient Table goes to Admission Table as Foreign Key.
Primary Key of the Room Table goes to Admission Table as Foreign Key.
Primary Key of the Receptionist Table goes to Admission Table as Foreign
Key.
26
admsn_id is a Primary key in the Admission Table. Pat_id from Patient Table,
Room_id from Room Table and Rcp_id from Receptionist Table become Foreign
Keys in the Admission Table.
27
# Relational model for Doctor and Department Entities:
Doctor Table:-
Department Table:-
Since the Cardinality Ratio from Doctor to Department is Many to Many, Dfd_id
is a part of Primary key in the Doctor_from_Department Table. Doc_id from
Doctor Table and Dept_id from Department Table become parts of Primary Key
in the Doctor_from_Department Table.
28
# Relationship between Patient, Doctor and Medicine Entities in the ER Model:
29
# Relational model for Patient, Doctor and Medicine Entities:
Patient, Doctor and Medicine Entities become Patient, Doctor and Medicine
tables.
Patient Table:-
Doctor Table:-
Medicine Table:-
Prescription Table: -
30
Doc_id from Doctor Table and Mdcn_id from Medicine Table become Foreign
Keys in the Admission Table.
31
#Relational model between Patient, Nurse and Room Entities:-
Patient Table:-
Room Table:-
Nurse Table:-
Since the Cardinality Ratio from Room to Patient to Nurse is 1to M to M. Ns_id
is a Primary key in the Nursing Service Table. Pat_id from Patient Table, Nrs_id
32
from Nurse Table become parts of Primary Key in the Nursing Service Table.
Room_id from Room Table becomes Foreign Key in the Nursing Service Table.
In a similar way relational tables are created for Patient-Room-Wardboy
relationship with cardinality ratio 1 to M to M.
1. Functional Dependency
2. Normalization
Example:
Student (matNr, name):
{matNr} -> {name}
33
Y is said to be fully functionally dependent of X, if there is no proper subset X’
⊂ X,
Where X’ -> Y.
Notation: X => Y.
Example:
A University Database:-
Class (classId, room, day, pName)
{classId, room} -> {pName}
{classId, day, pName} -> {room}
{classId} => {pName}
{classId} => {room} [7]
2.4.2 Normalization
Normalization is the process of organizing data in a database. This includes
creating tables and establishing relationships between those tables according to
rules designed both to protect the data and to make the database more flexible
by eliminating redundancy and inconsistent dependency.
It has mainly two goals:-
For example, storing the same data in more than one table
Benefits of Normalization:
Quicker updates
34
Easier to add data
Flexible Structure
1NF, 2NF, 3NF, BCNF are some of the early forms in the list that address this
problem.
Definition:
A relation is in first normal form if it contains only simple, atomic values for
attributes, no sets. Example:
Child Age
Peter 10
Iris 9
Rainer 18
35
The value of an attribute can be a relation by itself.
=> Operations in the model are much more complicated
=> In order to keep the model simple: 1NF
First attempt:
Person (name, place, child1, child2, child3)
=> Not good. Reason: either not enough available columns for some data records
(How many children can a person have??) Or, if there are enough columns to
provide for all thinkable cases, waste of much space (many NULL values).
Second attempt:
Person:-
pName place
Muller Stuggart
Schmidt Trir
Child:-
Muller Christa 12
Muller Peter 10
Muller Iris 9
Schmidt Martin 17
Schmidt Rainer 18
36
Advantage:
This requires just the right amount of space that is actually needed.
Disadvantage:
It requires an additional table. pName is redundantly stored.
Example:-
A University Database:
37
Redundancy since the name is repeated for every occurrence of the same
Matrikel Number.
Solution:
. A chain Exists.
.X->Z->Y
. X->Z-> Y
Example:-
38
Functional dependencies:
{matNr, classId} => {hours}
{matNr, classId} => {taSalary}
Assumption:
{hours} => {taSalary}
There is the following transitive dependency:
{matNr, classId} => {hours} => {taSalary}
Since taSalary is not an attribute in a candidate key and hours is not a superkey,
TA is not in 3NF.
There is unnecessary redundancy since taSalary is repeated for each
occurrence of the same value of hours.
Solution:
BCNF is a little stronger than 3NF. In most cases, relations in 3NF are also in
BCNF.
The alternative definition of BCNF shows in comparison to the 3NF definition
how the two differ: in BCNF, X must always be a super key; in 3NF it does not
need to be a super key if A is part of a candidate key.
39
No part of the primary key is Fully Functional Dependent on the
non primary key.
Example:-
Candidate keys:
• (town, streetSegment)
• (postCode, streetSegment)
Speedlimits is in 3NF:
• 1NF by definition
2NF since all non-primary-key attributes are fully functionally dependent on the
primary Key. For the extended definition: speed is the only attribute that is not
part of a Candidate key, and it is fully functionally dependent not only on the
primary key, but also on the other candidate.
• 3NF since the only non-candidate-key attribute is speed, and the only
transitive Dependencies ending in speed would be from one of the keys to the
other and then to speed. However, transitive dependencies where the middle
set is a candidate key do not violate the definition of 3NF.
40
Redundancy: postCode implies the town => unnecessary repetition
Transforming to BCNF:
1. Attempt:
Speedlimit (town, streetSegment, speed)
Codes (postCode, town)
2. Attempt:
Speedlimit (town, streetSegment, speed)
PostCodes (streetsegement, postCode)
BCNF
But:
• The dependency {town, streetSegment} => {postCode} is again not recognizable.
• The decomposition is lossy again!
3. Attempt:
Speedlimit (postCode, streetSegment, speed)
Codes (postCode, town)
Now both relations are in BCNF, and the decomposition is lossless.
However, the dependencies {town, streetSegment} => {postCode} and {town,
street-
Segment} => {speed} are lost.
It is possible to show:
41
FULFILMENT OF NORMAL FORMS:
Room Table:-
1NF:-
2NF:-
Every non primary key is Fully Functional Dependent on the primary key.
42
So the relation is in 2NF.
3NF:-
No chain Exists.
BCNF:-
No part of the primary key is Fully Functional Dependent on the non primary
keys. So the relation is in BCNF.
Bill Table:-
43
1NF:-
2NF:-
Every non primary key is Fully Functional Dependent on the primary key.
3NF:-
No chain Exists.
BCNF:-
No part of the primary key is Fully Functional Dependent on the non primary
key. So the relation is in BCNF.
JUNCTION TABLES:
44
{admsn_id} => {Time} Functional Dependency Exist
1NF:-
2NF:-
Every non primary key is Fully Functional Dependent on the primary key.
3NF:-
No chain Exists.
BCNF:-
No part of the primary key is Fully Functional Dependent on the non primary
keys. So the relation is in BCNF.
In a similar way Ambulance Service and Appointment Tables fulfill all the normal
forms.
Prescription Table:-
45
Full Functional Dependencies:
1NF:-
2NF:-
Every non primary key is Fully Functional Dependent on the primary key.
3NF:-
No chain Exists.
BCNF:-
No part of the primary key is Fully Functional Dependent on the non primary
keys. So the relation is in BCNF.
46
In a similar way Assist, Carrying Service, Cleaning Service, Operation and
Nursing Service tables fulfill all normal forms.
Payment Table:-
Two different patient ids, payment dates and payment types cannot correspond
to the same payment id. So Pay_Type, Pay-date and Pat_id are fully functionally
dependent on Pay_id.
Similarly two different accountant ids and patient ids cannot correspond to the
same bill id. So Acct_Id and Pat_id are fully functionally dependent on Bill_id.
The relation is not in 2NF because all non-primary keys are not fully functionally
dependent on the primary key (Pay_id, Bill_id). So we split the relation to make
it 2NF.
47
Payment2 (Bill_id, Acct_id, Pat_id)
3NF:
There is no chain.
BCNF:
48
Fig: Relational model Implementation on SQL Server.
49
2.5.1 Creation of Tables and Insertion of Data:
In our thesis we create tables and insert data using SQL server and
SQL Language.
MAIN TABLE
50
Insert Values into Patient Table
In this way we create all the main tables and insert data in them.
Junction Table
51
Insert Values into Admission Table
In this way we create all the junction tables and insert data in them.
Room table
52
Receptionist table
Doctor table
Appointment table
Bill table
53
Accountant table
BillPay table
Payment Table
Medicine table
54
Prescription table
Test table
Assist table
OT table
55
Operation table
Department table
Doctor_form_department table
Nurse table
56
Nursing service table
Ward_boy table
Driver table
57
Ambulance table
Carriers table
58
2.6 Complex Queries
After completing the implementation we retrieved different
information from the system by joining 2 or more tables of the
system. Sample Examples are given below:
Question 1
Query 1:
Output:
Question 2
Query 2:
59
Output 2:
Question 3:
Which Doctors are from which Department and they passed from which college
Query 3
Output 3:
Question-4
Which doctor conducted the Urine Test for which Patient at 11.00 AM?
Query -4
60
Output 4:-
Question 5:
Query -5:
Output 5 :-
Question 6:
Query 6:
Output 6:
61
C H A P T E R 3
User Interface
Objectives
• To suggest some general design principles for user interface design.
62
User Interface Design Principle
Principle Description
User The interface should use terms and concepts
familiarity which are drawn from the experience of the
people who will make most use of the system.
Minimal Users should never be surprised by the behavior
Surprise of a system.
Recoverability The interface should include mechanisms to allow
users to recover from errors.
User Guidance The interface should provide meaningful
feedback when errors occur and provide context-
sensitive user help facilities.
User diversity The interface should provide appropriate
interaction facilities for different types of
system users.
1. Consistency
63
2. Simplicity
64
5. Display issues
6. Error prevention
65
o Any such information should be easy to search, focused on
the user's task, list concrete steps to be carried out, and
not be too large.[9]
8. System messages:
9. Attention
66
o Don't use more than 4 different colors on a screen
o Don't use blue for text (hard to read), blue is a good
background color.
10. Anthropomorphization
67
12. Provide selectable areas to allow users to access
information
68
Human Factors in Interface Design
Sample of Interfaces
69
Here we show some samples of Interfaces:
SAMPLE-1
DOS-Based Q&A[16]
SAMPLE-2
70
SAMPLE-3:
#Usability Attributes:
Source: [16]
71
Summary
Introduction:
Front end and Back End are generalized terms that refer to the initial
and the end stages of a process. The front end is responsible for
collecting input in various forms from the user and processing it to
conform to a specification the back end can use. The front end is an
interface between the user and the back end.
72
We have completed the backend design using SQL Server and now
we have designed the front end using .NET Framework/(C#).
Login Form
Form Menu
Admin Part
Accountant Form
Receptionist Form
Nurse Form
Room Form
Ward boy Form
Ambulance Form
Carrier Form
Driver Form
Bill Form
Admission Form
Appointment Form
Ambulance Service Form
Carrying Service Form
Nursing Service Form
Cleaning Service Form
Payment Form
73
Medical Part
Patient Form
Doctor Form
Department From
Medicine Form
Test Form
Operation Theater Form
Doctor’s from Department Form
Prescription Form
Assist Form
Operation Form
Search Option
Login Form:
74
Fig: Login page
Form Menu:
75
In this form we can see a menu strip and there are many menu options like
Entry, Search, View, Tools, Windows, Help and other icons.
ADMINISTRATION PART
76
Room Form:
77
Bill Form:
Accountant Form:
78
Receptionist Form:
Driver Form
79
Ambulance Form
80
Carriers Form
Nurse Form
81
Ward boy Form
Admission Form
82
Appointment Form
83
Nursing Service Form
84
Carrying Service Form
Payment Form
85
MEDICAL PART
Doctor Form
86
OT Form
Medicine Form
87
Department Form
Test Form
88
Patient Form
89
DFD Form
Prescription Form
Assist Form
90
Operation Form
Search Form
91
In this form we can search different information of our software
according to search criteria.
92
3.2.2 Relating Interface Design Guidelines to our
Front end Design:
In our front end we refer to the User Interface Guidelines
that we researched
93
3. Attention
o Don't use more than 4 different font sizes per
screen.[9]
94
o Don't use blue for text (hard to read), blue is a good
background color.
Summary
We try our level best to follow the guidelines which were very helpful for
us in our form design. We hope a user friendly and efficient interface has
been developed.
95
Security has to be compared to related concepts: Safety,
continuity, reliability. The key difference between security and
reliability is that security must take into account the actions of
people attempting to cause destruction.
96
Features of Database Administrator:-
1. Administrator,
2. Receptionist,
3. Accountant.
97
Fig : Login page of our software.
98
Fig: Administrator option is selected and password is entered
99
Fig: When the password is matched we can switch to the Form Menu
100
Fig: The password is matched
101
Fig: When the password is matched we can switch to the Form Menu
102
Fig: The password Matched.
Fig: When the password is matched we can switch to the Form Menu.
103
Fig: If the password does not match Error Message is showed.
Security Code:
MessageBox.Show("Password Matched");
f.Show();
MessageBox.Show("Password Matched");
f.Show();
104
else if (DesignationText.Text == "Receiptionist" &&
password == 62444)
MessageBox.Show("Password Matched");
f.Show();
else
MessageBox.Show("Invalid Password");
105
elements on the screen will depend on the available
screen real estate and the function of the selectable
areas.
Summary:
106
Security is very important in software development. We apply
security in our software so that any user cannot access the information,
entered by the input users. We control the security from the front end.
It works efficiently.
In our software save, delete and update buttons are very common
features and search option is a special feature. These buttons carry out
the actions as their names imply, Search option helps to search info
according to selections of id and table name.
Software Overview
LOGIN
Part
107
Login Form
Action:
Form Menu
Action:
Administration part:
a. Room Form
b. Bill Form
c. Accountant Form
d. Receptionist Form
e. Driver Form
f. Ambulance Form
g. Carriers Form
h. Nurse Form
i. WardBoy Form
j. Admission Service Form
k. Appointment Service Form
l. Ambulance Service Form
m. Nursing Service Form
n. Cleaning Service Form
o. Carrying Service Form
p. Payment Form
108
Medical Part:
i. Doctor Form
ii. OT Form
iii. Medicine From
iv. Department Form
v. Test Form
vi. Patient Form
vii. DFD Form
viii. Prescription Form
ix. Assist Form
x. Operation Form
Save, Delete, Update and Search codes are similar for all the forms.
Code
private void btSave_Click(object sender, EventArgs e)
{
if (!Validation()) return;
SetRoomInstant();
roomInstant.Save();
dataGridView1.DataSource = roomInstant.GetAllData();
ClearTextBox();
ButtonControl(false);
}
109
a. Validation()
This function checks all the insert data in the form is valid or not.
b. SetRoomInstant();
c. ClearTextBox()
This function clears all the textbox of the form after Save button is
clicked.
110
private void ClearTextBox()
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
Code
private void btDelete_Click(object sender, EventArgs e)
{
if (!Validation()) return;
SetRoomInstant();
roomInstant.Delete();
dataGridView1.DataSource = roomInstant.GetAllData();
ClearTextBox();
a. Validation()
b. SetRoomInstant();
c. ClearTextBox()
Code
private void btUpdate_Click(object sender, EventArgs e)
{
if (!Validation()) return;
SetRoomInstant();
roomInstant.Update();
dataGridView1.DataSource = roomInstant.GetAllData();
ClearTextBox();
}
111
We can also see three functions
a. Validation()
b. SetRoomInstant();
c. ClearTextBox()
Search Action
In the search form combobox2 we can select a form’s data grid view as
shown as page 104. Then we can search id from the combobox1 as shown
as page 104. Accordingly single row is displayed. The code is given below:
Code
• RoomDataAccess.cs
• RoomDataObject.cs
• RoomService.cs
112
3.5 Usage of DLL file
DLL File
113
Fig: the DLL file used in our Software
Source: [22]
• Using DLL file we can easily carry our database with our software.
• We don’t need to load the database first.
• The software becomes more efficient and user friendly.
• After using DLL file we do not need to load the database to
interface with the front end in different PC s.
114
C H A P T E R 4
4.1 Conclusion
By the glace of Allah, the Almighty we have come to the end of our
thesis report. It is not the work of one day. In fact it took us a year to
complete. The group members worked hard to make it a good and
improvised thesis.
The second part of the thesis involved developing a user friendly and
efficient interface to the backend database in SQL Server. We
researched User Interface Guidelines and applied some of those to our
front end forms design. We have taken into account issues of security
too.
115
4.2.1 Data GridView:
When working with very large amounts of data, you can set the
VirtualMode property to true to display a subset of the available
data. Virtual mode requires the implementation of a data cache
from which the DataGridView control is populated. [23]
116
Use Data Gridview in .NET FRAMEWORK
117
Fig: When we run the form, GridView retrieves data from the
database.
118
See the recently entered data:
Fig: Inserting New Data in the form and clicking the Save Button.
119
Fig: Confirmation of Data Insertion in the Database
120
Delete Data from the DataGridView:
121
Fig: Confirmation that the information or data is deleted successfully.
122
Edit and Update Data from the DataGridView:
Fig: When the Edit Button is clicked the data is seen in the form. The
Save Button is changed to Update Button.
123
Fig: After Edit the data Update button is clicked.
124
Fig: The Picture of the DataGridView after data update.
Code_OT Class:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace OperationTheature
{
public partial class OT : Form
{
public OT()
{
InitializeComponent();
}
125
public int otid;
OperationBasic ob = new OperationBasic();
OTGateway og = new OTGateway();
OTManager om = new OTManager();
bool isTrue = false;
public string msg = null;
this.AddColumns();
126
ob.ot_id = Convert.ToInt32(operationidText.Text);
ob.ot_room_no = otroomnoText.Text;
if (this.otid == 0)
{
msg = om.SaveOperation(ob);
MessageBox.Show(msg);
this.OTDataGridView.Columns.Remove("Edit");
this.OTDataGridView.Columns.Remove("Delete");
}
else
{
OTGateway og = new OTGateway();
og.UpdateOperation(ob);
MessageBox.Show("Updated Successfully");
this.OTDataGridView.Columns.Remove("Edit");
this.OTDataGridView.Columns.Remove("Delete");
}
Clear();
OT_Load(null, null);
}
ob = new OperationBasic();
om = new OTManager();
int operationcode = ob.ot_id =
Convert.ToInt32(OTDataGridView.Rows[OTDataGridView.SelectedCells[0].RowIndex].Cells["Ot
_id"].Value.ToString());
OTDataGridView.Rows[OTDataGridView.SelectedCells[0].RowIndex].Cells["Ot_id"].Value.ToStri
ng();
msg = om.DeleteOperation(operationcode);
Close();
MessageBox.Show(msg);
}
127
}
}
this.operationidText.Text=otid.ToString();
this.otroomnoText.Text=this.OTDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
this.Save_Button.Text = "Update";
}
OT_Load(null, null);
}
}
}
Difficulties:
128
4.2.2 TRIGGER Features:
We can write triggers that fire whenever one of the following operations
occurs:
129
Fig: Triggers
Trigger Structure:
130
Sample Code:
create trigger overdraft-trigger after update on account
referencing new row as nrow
for each row
when nrow.balance < 0
begin atomic
insert into borrower
(select customer-name, account-number
from depositor
where nrow.account-number =
depositor.account-number);
insert into loan values
(n.row.account-number, nrow.branch-name,
– nrow.balance);
update account set balance = 0
where account.account-number = nrow.account-number
end
Source: [25]
The trigger we may apply in our database is similar for all tables. So
trigger applied on Room Table and Admission Table can be given as
an example:
begin
131
where Admission.Room_no=:new.Room_no);
end;
Source: [25]
Difficulties:
The triggers are created but when we insert values it does not work
properly.
Summary
132
REFERENCES
1. http://www.blurtit.com/q959542.html
2. http://en.wikipedia.org/wiki/Database#Applications
3. http://www.cl500.net/pros_cons.html
4. http://en.wikipedia.org/wiki/Entity
5. http:/en.wikipedia.org/wiki/Attribute_%28computing%29
6. http://en.wikipedia.org/wiki/Data_type
(Chapter-26)
9. http://ergo.human.cornell.edu/ahtutorials/interface.html
11. Nicol, A. (1990). Interfaces for learning: What do good teachers know that
don't? In B. Laurel (Ed.), the art of human-computer interface design. (pp. 113-
123). Maidenhead Birkshire: Pergammon Infotech Limited.
12. Reingold, H. (1990). An interview with Don Norman. In B. Laurel (Ed.), the art
of human-computer interface design. (pp. 113-123). Maidenhead Birkshire:
Pergammon Infotech Limited.
133
13. Laurel, B. (1991). Computer as theatre. Menlo Park, CA: Addison Wesley;
Laurel, B. (Ed.). (1991). the art of human-computer interface design. Menlo Park,
CA: Addison Wesley.
14. Laurel, B, Oren, T., & Don, A. (1992). Issues in multimedia design: Media
integration and interface agents. In M. M. Blattner & R. B. Dannenberg (Eds.),
Multimedia interface design. (pp. 53-64), ACM Press.
15. Jones, M.G. (1993). Guidelines for screen design and user-interface design in
computer-based learning environments. (Doctoral Dissertation, The University
of Georgia, 1993). Dissertation Abstracts International, 54 (9), 308a - 309a.
16. Presentation Slide (Judical Database System) by Kipp Scott and Michael
Sinks
17. http://en.wikipedia.org/wiki/Front_and_back_ends
18. http://en.wikipedia.org/wiki/Security
19. http://en.wikipedia.org/wiki/Computer_Security
20. http://en.wikipedia.org/wiki/Database_Security
21. http://en.wikipedia.org/wiki/dba
22. http://en.wikipedia.org/wiki/Dynamic-link_library
23.http://msdn.microsoft.com/enus/library/system.windows.forms.
datagridview.aspx
24. http://en.wikipedia.org/wiki/Database_trigger
25. http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/
triggers.htm#CNCPT017
134
APPENDIX
Login Form:
public LOGIN()
{
InitializeComponent();
this.DesignationCombo.DataSource =
Enum.GetNames(typeof(Designation));
135
else if (DesignationText.Text == "Accountant" && password ==
62436)
{
MessageBox.Show("Password Matched");
frmMenubar f = new frmMenubar();
f.Show();
else
{
MessageBox.Show("Invalid Password");
}
//this.Close();
}
case Designation.Accountant:
DesignationText.Text = "Accountant";
break;
case Designation.Receiptionist:
DesignationText.Text = "Receiptionist";
break;
}
}
}
}
136
Form Menu:
namespace WindowsFormsbirdem.UI
{
public partial class frmMenubar : Form
{
private int childFormNumber = 0;
public frmMenubar()
{
InitializeComponent();
}
137
}
}
138
Show(new frmAboutDeveloper());
}
frm.MdiParent = this;
frm.Show();
}
Show(new Form1(this.menuStrip,this.toolStrip));
BackColor = Color.Lavender;
}
private void accountantToolStripMenuItem_Click(object sender,
EventArgs e)
{
Show(new frmAccountant());
}
139
Show(new frmAmbulance());
}
140
private void dFDToolStripMenuItem_Click(object sender, EventArgs e)
{
Show(new frmDFD());
}
}
}
Room Form:
namespace WindowsFormsbirdem.UI
{
public partial class frmRoom : Form
{
public static RoomDataObject roomInstant = new RoomDataObject();
public frmRoom()
{
InitializeComponent();
dataGridView1.DataSource = roomInstant.GetAllData();
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
ClearTextBox();
ButtonControl(false);
}
141
{
MASICEIU.MessageShow.Information("Select Item from room
list.");
return false;
}
else if (textBox2.Text == "")
{
MASICEIU.MessageShow.Information("Room No");
textBox2.Focus();
return false;
}
else if (textBox3.Text == "")
{
MASICEIU.MessageShow.Information("Room Type");
textBox3.Focus();
return false;
}
else if (textBox4.Text == "")
{
MASICEIU.MessageShow.Information("Room Cost");
textBox4.Focus();
return false;
}
return true;
}
142
}
}
private void frmRoom_Load(object sender, EventArgs e)
{
btSave.Enabled = false;
}
}
}
Actions:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MASICEIU.BaseDataLayer;
using WindowsFormsbirdem.DAL.DOL;
namespace WindowsFormsbirdem.DAL
{
143
public class RoomDataObject:DataObject
{
RoomService service = new RoomService();
private int Room_id;
private string Room_no;
private string Room_type;
private int Room_cost;
service.Delete(WindowsFormsbirdem.UI.frmRoom.roomInstant.Room_id1.ToString(
));
}
}
}
Actions:
144
Code of RoomService.cs Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MASICEIU.BaseDataLayer;
using MASICEIU;
using System.Data;
namespace WindowsFormsbirdem.DAL.DOL
{
public class RoomService : Service
{
RoomDataAccess dataAccess = new RoomDataAccess();
145
Actions:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MASICEIU.BaseDataLayer;
using System.Data;
using System.Data.SqlClient;
namespace WindowsFormsbirdem.DAL
{
public class RoomDataAccess: DataAccess
{
public override DataTable GetAllData()
{
return ConnectionManager.DatabaseInstant.GetTable("Select *from
tbl_Room");
}
146
}
}
}
Actions:
All sql queries like Save, Delete, Update are done here.
THE END
147