You are on page 1of 59

1.

INTRODUCTION
The purpose of this document to give a general information about the project
and emphasizes the important parts that interacts with the main system.
This report will be read by the manager of the dental hospital and board of
management. This report will provide managers to see the interaction between dentists
and the patients as well as the information they will share. Project will help the dental
hospital to reach their potential patients.
While preparing the Project, firstly, the requirements were considered and
design of the Project was completed. In the design part, all the operations were shown
step by step. After the completion of the design, the code of the Project was written
and implementation part was carried out.

2. CORPORATE OVERVIEW
This system provides patients to see the information and the schedule of the
dentists in order to choose their own dentist for any operation. Also, in the system,
both patients and the dentists can see the former operations, that had been done to the
patients, on the reports which are prepared by the dentists.
3.

SYSTEM REQUEST
Project Sponsor: Mehmet Sapmaz, Manager of the Dental Hospital
Business Need: This project has been initiated to reach new patients via Internet, to

increase the potential of preferability and to provide an effective way to monitor the existing
patients.
Business Requirements: Using the web, patients should be able to register to the
system, list dentists and reach their schedules, select their own dentists, update or delete their
own appointments. They should be able to search a specific dentist or time to get an
appointment. if they choose a dentist that is very busy, the system reserves its rights to assign
the patient to another dentist. Dentists should be able to upload their schedules, update or
delete appointments. They should also be able to list and reach all information of their own
patients. Finally, admin(s) should be able to add dentists with their information, update or
delete them. The admin(s) should be able to list all dentists and patients and reach their
information.
1

System will assign patients automatically one by one to the dentists if they do not
choose a specific dentist. Therefore, equal distribution of the patients will be provided by the
system.
The functionality that the system will have is as follows:
-

Capture patients information.


Keep the dental processes made to patients.
Produce dental control reports to patients.
Show the available times of dentists.
Provide information about dentists.
Search for a dentist by a patient.
An appointment is possible to be gotten both manually or automatically.
Business Value: We expect that Hospidental will increase the average number of

patients that come to the hospital in a year. In this way, annual earning will increase about
%20 per year. We also expect via the online appointment system, patient complaints will
decrease because more than %40 of the all patients reproach from hardship of getting an
appointment at any time they want.
Conservative estimates of tangible value to the hospital include:
-

$240,000 (%20 of $1,200,000) from new customers.


$400,000 (%20 of $2,000,000) from existing customers.
Special Issues or Constraints:

In the future, the appointments may want to be gotten only online.


The system should be completed before the end of May 2012.

4. REQUIREMENTS SPECIFICATION
a. Nonfunctional Requirements
1. Operational Requirements
1.1. The record logging option of the application includes ability to record modifications
with user identification and date & time.
1.2. The system should be able to work on any web browser.
1.3. The system should be able to work on every screen resolutions.
1.4. If a dentist quits the job or takes time off from work, then his/her patients will
automatically be assigned to other dentists and patients will be informed by an
automatic e-mail that system sends.
2. Performance Requirements
2.1. The system should be able to give response to user less than 2 seconds.
2.2. The system should be available for use 24 hours per day, 365 days per year.
2.3. The system should have less than 1 day downtime per year.
2.4. The system should have capacity of at least 200.000 users at the beginning.
3. Security Requirements
3.1. The passwords and user names should be stored in encrypted format to protect
patients' privacy.
3.2. A dentist should not be able to reach the information of a patient who is not his/her
own patient.
3.3. The system should be able to provide datacenter security, database security and
privacy of users information.
3.4. A patient should not be able to see the information of other patients.
3.5. User access to data should be controlled at various levels.
4. Cultural and Political Requirements
No special cultural and political requirements are anticipated.

b. Functional Requirements
1. Maintain Database Information
1.1.
The system will need a database that keeps all patients and dentists
information. (e.g. TCid, name, surname, age, special professions of dentists etc.)
The system must receive updates instantly, especially the moment that an

1.2.

appointment occurs.
1.3.
The system must keep dentists daily schedules.
3

1.4.

The system must keep the dental processes made to patients at Hospidental
and print their reports showing id, name, surname, age, gender and previous dental
processes.

2. Maintain User Functions


1.1.
The system must have a registration function for the first entrance of patients.
1.2.
All information and functions, except registration, that system provides must
be available after logging in the system.
1.3.
The system must list schedules of dentists and show their available times to
patients.
The system must provide ability to search for a specific dentist or patient.
There must be a control panel for admin.

1.4.
1.5.

5. FUNCTIONAL MODEL
a) Use Case Diagram

Figure1. Use Case Diagram

b) Use Case Descriptions

Get an appointment - Use Case


Flow of Events
Use Case Descriptions
Main.
Scope
Level
Primary Actor
Stakeholders and
Interests

Online Dental Hospidental Appointment System


User goal
Patient
Patient - want to get an appointment fast and easier.
Admin - want to monitor appointments easier and provide alternatives to patients.

Brief Description
Preconditions
Post-conditions
Flow of Events

Alternative-1
Scope
Level
Primary Actor
Preconditions
Post-conditions
Flow of Events

Patients can get an appointment from any dentist instantly using the system.
Login the system.
The system updates changes on a schedule immediately.
Actor Input
System Response
1
Actor clicks on "Get an
appointment" tab
2
The system displays
"get_appointment" page
3
Actor enters time and clicks OK
button
4
The system checks if any dentist is
available at the entered time
5
The system shows the dentists that
are available at the entered time
6
Actor selects a dentist
7
The system displays selected
dentist's schedule on
"approve_appointment" page and
signs the entered time on the
schedule
8
The system enables "Approve" and
"Cancel" buttons
9
Actor clicks "Approve" button
10
The system receives the
appointment and update the chosen
dentist's schedule
11
The system displays main page
Online Dental Hospidental Appointment System
Alternative of user goal
Patient
Login the system
1

Actor Input
Actor clicks on "Get an
appointment" tab

2
3

System Response
The system displays
"get_appointment" page

Actor enters time and clicks OK


button

The system checks if any dentist is


available at the entered time
The system gives a warning that

there is no available dentists at the


entered time
The system displays
"get_appointment" page

6
Alternative-2.
Scope
Level
Primary Actor
Preconditions
Post-conditions
Flow of Events

Online Dental Hospidental Appointment System


Alternative of user goal
Patient
Login the system
1

Actor Input
Actor clicks on "Get an
appointment" tab

2
3

The system displays


"get_appointment" page
Actor enters time and clicks OK
button

The system checks if any dentist is


available at the entered time
The system shows the dentists that
are available at the entered time

5
6
7

Actor selects a dentist


The system displays selected
dentist's schedule on
"approve_appointment" page and
signs the entered time on the
schedule
The system enables "Approve" and
"Cancel" buttons

8
9
10

System Response

Actor clicks "Cancel" button


The system cancels the
appointment
The system displays
"get_appointment" page

11

Figure 2. Get an Appointment Use Case Description

List dentists - Use Case


Flow of Events
Use Case Descriptions
Main.
Scope
Level
Primary actor
Secondary Actors
Stakeholders and
Interests
Brief Description
Preconditions
Post-conditions
Flow of Events

Online Dental Hospidental Appointment System


User goal
Patient
Dentist and admin
Patient - want to see all the dentists.
Admin - want to see all the dentists.
Dentists can be listed.

1
2

Actor Input
Actor clicks on the "Dentists" tab

System Response
The system displays "Dentists"
page

3
4

Actor clicks "List Dentists" button

Actor clicks on a picture to see


information of a dentist

The system shows all the dentists'


profile pictures and names

The system displays


"Dentist_Info" page
The system shows the chosen
dentist's information

Figure 3. List Dentists Use Case Description

Search a dentist - Use Case


Flow of Events
Use Case Descriptions
Main.
Scope
Level
Primary actor
Secondary Actors
Stakeholders and
Interests
Brief Description
Preconditions
Post-conditions
Flow of Events

Online Dental Hospidental Appointment System


User goal
Patient
Dentist and admin
Patient - want to look for a dentist
Admin - want to look for a dentist
Looking for a specific dentist is possible

1
2
3

Actor Input
Actor clicks on the "Dentists" tab

The system displays "Dentists"


page
Actor clicks "Search dentist"
button

4
5
6
7
Alternative.
Scope
Level
Primary actor
Secondary actors
Brief Description
Preconditions
Post-conditions
Flow of Events

System Response

The system enables a text box and


"OK" button
Actor writes the name of the
dentist that he/she wants to see
Actor clicks "OK" button.
The system shows the chosen
dentist's schedule.

Online Dental Hospidental Appointment System


Alternative of user goal
Patient
Dentist and admin
Actor can search for a dentist who does not work at Hospidental.

1
2
3

Actor Input
Actor clicks on the "Dentists" tab

The system displays "Dentists"


page
Actor clicks "Search dentist"
button

4
5
6
7

System Response

The system enables a text box and


"OK" button
Actor writes the name of the
dentist that he/she wants to see
Actor clicks "OK" button
The system gives a warning that
there is not a dentist with the
entered name working at
Hospidental
The system returns "Dentists" page

Figure 4. Search a Dentist Use Case Description

Insert Schedule - Use Case


Flow of Events
Use Case Descriptions
Main.
Scope
Level
Primary actor
Stakeholders and
Interests

Online Dental Hospidental Appointment System


User goal
Dentist
Dentist - want to publish his/her schedule on the system
Patient - want to reach dentists' schedules using by the system

Brief Description
Preconditions
Post-conditions
Flow of Events

Dentists must add their schedules in the system.


Login the system.
1
2

Actor Input
Actor clicks on "MyProfile" tab

The system displays "MyProfile"


page
The system shows the actor's
information

3
4

Actor clicks on "Insert Schedule"


button

5
6

The system displays


"add_schedule" page
Actor inserts his/her schedule and
clicks OK button

The system receives the added


schedule
The system displays "MyProfile"
page

8
Alternative.
Scope
Level
Brief Description
Preconditions
Post-conditions
Flow of Events

System Response

Online Dental Hospidental Appointment System


Alternative of user goal
Some information can be missing in the schedule that a dentist wants to insert.
Login the system
1
2

Actor Input
Actor clicks on "MyProfile" tab

The system displays "MyProfile"


page
The system shows the actor's
information

3
4

Actor clicks on "Insert Schedule"


button

5
6

System Response

The system displays


"add_schedule" page
Actor inserts his/her schedule and
clicks OK button

The system gives a warning that


there is missing information on
the schedule wanted to be added.
The system display "myProfile"
page

Figure 5. Insert Schedule Use Case Description

10

Monitor Patients - Use Case


Flow of Events
Use Case Descriptions
Main.
Scope
Brief Description
Preconditions
Post-conditions
Flow of Events

Online Dental Hospidental Appointment System


Dentists are able to monitor their own patients.
Login the system.
1
2
3

Actor Input
Actor clicks on "Dentists" tab

The system displays "Dentists"


page
Actor clicks on "List Patients"
button

4
5
6

System Response

The system displays Patients page


The system lists actor's own
patients.
Actor clicks the name of the
patient that wanted to be
monitored

The system displays a page for the


chosen patient.

Figure 6. Monitor Patients Use Case Description

11

Update Dentist - Use Case


Use Case Descriptions
Main.
Scope
Level
Primary Actor
Stakeholders and
Interests

Online Dental Hospidental Appointment System


User goal
Admin
Admin - want to update dentists' information frequently
Dentist - want admin to be enabled to add information about himself/herself anytime

Brief Description
Preconditions
Post-conditions
Flow of Events

Admin can update a dentist's information


Login the system
The system must receive the updates instantly
Actor Input
1
Actor clicks "MyProfile" tab
2
3

The system lists dentists' profile


pictures and names
Actor clicks on the picture of the
dentist that he/she wants to update

6
7

The system displays the chosen


dentist's information
Actor updates any parts of dentist's
information and clicks OK button

8
Alternative.
Scope
Level
Primary actor
Brief Description
Preconditions
Post-conditions
Flow of Events

The system displays "MyProfile"


page

Actor clicks "Update a dentist"


button

4
5

System Response

The system receives updates and


displays actor's profile

Online Dental Hospidental Appointment System


Alternative of user goal
Admin
There can be missing information in tupdated part.
Login the system
1
2
3

Actor Input
Actor clicks "MyProfile" tab

The system displays "MyProfile"


page
Actor clicks "Update a dentist"
button

4
5

The system lists dentists' profile


pictures and names
Actor clicks on the picture of the
dentist that he/she wants to update

6
7

System Response

The system displays the chosen


dentist's information
Actor updates any parts of dentist's
information and clicks OK button

The system gives a warning that


there is missing information in the
updated parts
The system displays "MyProfile"
page

Figure 7. Update Dentist Use Case Description


12

Login the system - Use Case


Flow of Events
Use Case Descriptions
Main
Scope
Level
Primary actor
Secondary actors
Stakeholders and
Interests
Brief Description
Extension Point
Flow of Events

Alternative.
Scope
Level
Brief Description
Preconditions
Post-conditions
Flow of Events

Online Dental Hospidental Appointment System


Essential
Admin
Patient and dentist
Patient - dentist - admin : need to login system first to do specific processes
The system includes a login system to identify users.
Register to the system.
Actor Input
System Response
1
Actor clicks "Login" button on
main page
2
The system displays "login" page
3
---Extension Point--4
Actor enters TCid and password
and clicks OK button
5
The system checks if entered TCid
and password are valid
6
The system displays actor's profile
Online Dental Hospidental Appointment System
Essential
Wrong TCid or password

1
2
3

Actor Input
Actor clicks "Login" button on
main page

The system displays "login" page


Actor enters TCid and password
and clicks OK button

The system checks if entered TCid


and password are valid
The system gives a warning that
password is wrong
The system displays
"new_password" page and asks the
e-mail address of the actor to send
a new password

5
6

Actor enters his/her mail address


and clicks OK button

8
9
10

System Response

The system displays "login" page


The system sends a new password
to actor's e-mail
Actor enters TCid and new
password and clicks OK button

11

The system displays actor's profile

Figure 8. Login the System Use Case Description

Register to the system - Use Case


13

Use Case Descriptions


Main Yer iareti tanmlanmam.
Scope
Online Dental Hospidental Appointment System
Level
Extension
Brief Description
Registration is necessary before login the system
Flow of Events
Actor Input
System Response
1
Actor clicks "Register" button
2
The system displays "register"
page
3
Actor fills a form with his/her
personal information
4
The system checks if the
information is valid
5
The system accepts the registration
6
The system displays "login" page
AlternativeHata! Yer iareti tanmlanmam.
Scope
Online Dental Hospidental Appointment System
Level
Extension
Brief Description
Alternative of Register to the system.
Flow of Events
Actor Input
System Response
1
Actor clicks "Register" button
2
The system displays "register"
page
3
Actor fills a form with his/her
personal information
4
The system checks if the
information is valid
5
The system gives a warning that
some information is invalid
6
The system displays main page

Figure 9. Register to the System Use Case Description

c) Activity Diagrams
Login the System

14

Figure 10. Login the System Activity Diagram


Get an appointment

Figure 11. Get an Appointment Activity Diagram


Insert Schedule

15

Figure 12. Insert Schedule Activity Diagram


Update Dentist

Figure 13. Update Dentist Activity Diagram


List Dentists
16

Figure 14. List Dentist Activity Diagram


Search a Dentist

Figure 15. Search a Dentist Activity Diagram


d) System Sequence Diagrams
17

Login the system

Figure 16. Login the System System Sequence Diagram


Register to the system

Figure 17. Register to the System System Sequence Diagram


Get an appointment
18

Figure 18. Get an Appointment System Sequence Diagram


Insert Schedule
19

Figure 19. Insert Schedule System Sequence Diagram


Update Dentist

Figure 20. Update Dentist System Sequence Diagram


Search a Dentist
20

Figure 21. Search a Dentist System Sequence Diagram


List Dentists

Figure 22. List Dentist System Sequence Diagram


6. ANALYSIS CLASS DIAGRAM
21

Figure 23. Analysis Class Diagram


7. SYSTEM OPERATIONS

Figure 24. System Operations


8. DESIGN CLASS DIAGRAM

22

Figure
25.
Design
Class

Diagram

9. INTERACTION

DIAGRAMS
GetAppointment(date :

Figure 26. Get

Date)

Appointment Interaction Diagram

ListDentists()

23

Figure 27. List Dentists Interaction Diagram


SearchDentists(searchby : String)

Figure 28. Search Dentists Interaction Diagram


InsertSchedule(id : int, date : Date, value : boolean)
24

Figure 29. Insert Schedule Interaction Diagram

InsertReport(id : int, diagnosis : String)


25

Figure 30. Insert Report Interaction Diagram


MonitorReport(id : int)

Figure 31. Monitor Report Interaction Diagram


AddDentist(id : int, name : String, surname : String, age : int, sex : char, telephone :
number, info : String)

26

Figure 32. Add Dentist Interaction Diagram


CalculateTotalPrice(id : int)

Figure 33. Calculate Total Price Interaction Diagram


System Initialization Diagram

27

Figure 34. System Initialization Diagram


10. IMPLEMENTATION
Patient.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"
AutoEventWireup="true" CodeBehind="Patient.aspx.cs" Inherits="DentalHospital.Patient"
%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Get
Appointment</asp:LinkButton> /
<asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click"
>Logout</asp:LinkButton>
<br />
<asp:Label ID="LabelName" runat="server" Text="Label"></asp:Label><br />
Report =
<asp:Label ID="LabelReport" runat="server" Text="You have no report."></asp:Label>
</asp:Content>
Patient.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
28

using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace DentalHospital
{
public partial class Patient : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ //login check starts
if (Session["loginName"] != null && Session["loginPass"] != null &&
Convert.ToInt32(Session["userType"]) == 3)
{ //session control
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
com.Parameters.AddWithValue("@Password", Session["loginPass"]);
com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
//if session is empty, does it!
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{ //if input info is correct, getting patient id
SqlConnection connn = new SqlConnection(Tools.localConnString);
SqlCommand comm = new SqlCommand("Select UserId from Userr where
UserName = '" + Session["loginName"].ToString() + "' and Password = '" +
Session["loginPass"].ToString() + "' and UserTypeId = '" + Session["userType"].ToString() +
"'", connn);
connn.Open();
string UserrrrId = comm.ExecuteScalar().ToString();
connn.Close();
SqlDataAdapter dap = new SqlDataAdapter("Select * from Patient where
UserrId=" + UserrrrId.ToString(), new SqlConnection(Tools.localConnString));
DataTable dt = new DataTable();
dap.Fill(dt);
string PatientId = dt.Rows[0]["PatientId"].ToString();
string Name = dt.Rows[0]["Name"].ToString();
string Surname = dt.Rows[0]["Surname"].ToString();
string ReportId = dt.Rows[0]["ReportId"].ToString();
LabelName.Text=Name+" "+Surname;
if (ReportId.Equals(""))
29

{
return;
}
else
{
SqlConnection co = new SqlConnection(Tools.localConnString);
SqlCommand c = new SqlCommand("Select Diagnosis from Patient inner join
Report on Report.ReportId ="+ReportId , co);
co.Open();
string Diagnosis = c.ExecuteScalar().ToString();
co.Close();
LabelReport.Text = Diagnosis;
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
//login check finishes
protected void LinkButton3_Click(object sender, EventArgs e)
{ //logout
Session["loginName"] = null;
Session["loginPass"] = null;
Session["userType"] = null;
Response.Redirect(ResolveUrl("~/Default.aspx"));
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect(ResolveUrl("~/Appointment.aspx"));
30

}
}
}
Appointment.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"
AutoEventWireup="true"
CodeBehind="Appointment.aspx.cs" Inherits="DentalHospital.Appointment" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Get
Appointment</asp:LinkButton>
/
<asp:LinkButton ID="LinkButton3" runat="server"
OnClick="LinkButton3_Click">Logout</asp:LinkButton><br />
<table>
<tr>
<th>
Doctor Name
</th>
<th>
Date
</th>
<th>
Hours
</th>
</tr>
<asp:ListView ID="ListView1" runat="server"
onitemcommand="ListView1_ItemCommand">
<ItemTemplate>
<tr>
<td><%# Eval("Name").ToString()%> <%# Eval("Surname").ToString()%>
</td>
<td><%# Eval("StartDate").ToString().Substring(0,10)%>
</td>
<td><%# Eval("StartDate").ToString().Substring(11,5)%>-<%#
Eval("EndDate").ToString().Substring(11,5) %></td>
<td>
<asp:LinkButton ID="LinkButtonGetAppointment"
CommandName="GetAppointment" CommandArgument='<%#
Eval("ScheduleId").ToString() + ";" + Eval("StartDate").ToString() %> '
runat="server">Register</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
31

<tr><td>&nbsp;</td></tr>
<tr><th colspan="3">My Appointments</th></tr>
<asp:ListView ID="ListView2" runat="server">
<ItemTemplate>
<tr>
<td><%# Eval("Name").ToString()%> <%# Eval("Surname").ToString()%>
</td>
<td><%# Eval("StartDate").ToString().Substring(0,10)%>
</td>
<td><%# Eval("StartDate").ToString().Substring(11,5)%>-<%#
Eval("EndDate").ToString().Substring(11,5) %></td>
</tr>
</ItemTemplate>
</asp:ListView>
</table>
</asp:Content>
Appointment.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace DentalHospital
{
public partial class Appointment : System.Web.UI.Page
{
public string PatientId;
protected void Page_Load(object sender, EventArgs e)
{ //login check starts
if (Session["loginName"] != null && Session["loginPass"] != null &&
Convert.ToInt32(Session["userType"]) == 3)
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
com.Parameters.AddWithValue("@Password", Session["loginPass"]);
com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
32

{ //get user if login is correct


SqlConnection connn = new SqlConnection(Tools.localConnString);
SqlCommand comm = new SqlCommand("Select UserId from Userr where
UserName = '" + Session["loginName"].ToString() + "' and Password = '" +
Session["loginPass"].ToString() + "' and UserTypeId = '" + Session["userType"].ToString() +
"'", connn);
connn.Open();
string UserrrrId = comm.ExecuteScalar().ToString();
connn.Close();
SqlDataAdapter dap = new SqlDataAdapter("Select * from Patient where
UserrId=" + UserrrrId.ToString(), new SqlConnection(Tools.localConnString));
DataTable dt = new DataTable();
dap.Fill(dt);
PatientId = dt.Rows[0]["PatientId"].ToString();
string Name = dt.Rows[0]["Name"].ToString();
string Surname = dt.Rows[0]["Surname"].ToString();
string ReportId = dt.Rows[0]["ReportId"].ToString();
public void getDate(Date date){
SqlDataAdapter daap = new SqlDataAdapter("Select StartDate, EndDate,
Name, Surname, Schedule.DentistId As DentistId, ScheduleId from Schedule inner join
Dentist on Schedule.DentistId = Dentist.DentistId where PatientId IS NULL Order BY
StartDate DESC", new SqlConnection(Tools.localConnString));
DataTable dat = new DataTable();
daap.Fill(dat);
ListView1.DataSource = dat;
ListView1.DataBind();
// get appointment date
SqlDataAdapter daapp = new SqlDataAdapter("Select StartDate, EndDate,
Name, Surname, Schedule.DentistId As DentistId, ScheduleId from Schedule inner join
Dentist on Schedule.DentistId = Dentist.DentistId where PatientId="+PatientId, new
SqlConnection(Tools.localConnString));
DataTable datt = new DataTable();
daapp.Fill(datt);
ListView2.DataSource = datt;
ListView2.DataBind();
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{

33

throw;
}
finally
{
conn.Close();
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
}
protected void LinkButton3_Click(object sender, EventArgs e)
{ //logout
Session["loginName"] = null;
Session["loginPass"] = null;
Session["userType"] = null;
Response.Redirect(ResolveUrl("~/Default.aspx"));
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect(ResolveUrl("~/Appointment.aspx"));
}
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs)
{
//according to schedule id, time is specified.
string ScheduleId = e.CommandArgument.ToString().Split(';')[0].ToString();
string sd = e.CommandArgument.ToString().Split(';')[1].ToString();
int day = Convert.ToInt32(sd.Split(' ')[0].Split('.')[0].ToString());
int month = Convert.ToInt32(sd.Split(' ')[0].Split('.')[1].ToString());
int year = Convert.ToInt32(sd.Split(' ')[0].Split('.')[2].ToString());
int hour = Convert.ToInt32(sd.Split(' ')[1].Split(':')[0].ToString());
int min = Convert.ToInt32(sd.Split(' ')[1].Split(':')[1].ToString());
int sec = Convert.ToInt32(sd.Split(' ')[1].Split(':')[2].ToString());
DateTime StartDate = new DateTime(year, month, day, hour, min, sec);
SqlConnection ccon = new SqlConnection(Tools.localConnString);
SqlCommand ccom = new SqlCommand("Insert Into Appointment (PatientId,Date)
values (@PatientId,@StartDate)", ccon);
ccom.Parameters.AddWithValue("@PatientId", PatientId);
ccom.Parameters.AddWithValue("@StartDate",StartDate);
34

ccon.Open();
int aa = ccom.ExecuteNonQuery();
ccon.Close();
//insert appointment in database
SqlConnection con = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("update Schedule set PatientId="+PatientId+"
where ScheduleId="+ScheduleId,con);
con.Open();
int a = com.ExecuteNonQuery();
con.Close();
//update schedule according to patient id
Response.Redirect(ResolveUrl("~/Patient.aspx"));
}
}
}

Dentist.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"
AutoEventWireup="true" CodeBehind="Dentist.aspx.cs" Inherits="DentalHospital.Dentist"
%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" >My
Details</asp:LinkButton> /
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Give
Report</asp:LinkButton> /
<asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click"
>Logout</asp:LinkButton>
<table style="text-align: left" cellpadding="3px" cellspacing="1px">
<thead>
<tr>
<th class="header" colspan="5">
List Of Dentists
</th>
</tr>
<tr>
<th>
Name Surname
</th>
<th>
Age
</th>
<th>
35

Sex
</th>
<th>
Telephone
</th>
<th>
Operations
</th>
</tr>
</thead>
<tbody>
<asp:ListView runat="server" ID="ListView1"
OnItemCommand="ListView1_ItemCommand">
<ItemTemplate>
<tr class="non-alternate">
<td>
<%# Eval("Name").ToString() %>
<%# Eval("Surname").ToString() %>
</td>
<td>
<%# Eval("Age").ToString() %>
</td>
<td>
<%# Eval("Sex").ToString() %>
</td>
<td>
<%# Eval("Telephone").ToString() %>
</td>
<td>
<asp:LinkButton ID="LinkButtonDentistDelete" CommandName="detail"
CommandArgument='<%# Eval("DentistId").ToString() %>'
runat="server">Details</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="alternate">
<td>
<%# Eval("Name").ToString() %>
<%# Eval("Surname").ToString() %>
</td>
<td>
<%# Eval("Age").ToString() %>
</td>
<td>
<%# Eval("Sex").ToString() %>
</td>
<td>
<%# Eval("Telephone").ToString() %>
</td>
36

<td>
<asp:LinkButton ID="LinkButtonDentistDelete" CommandName="detail"
CommandArgument='<%# Eval("DentistId").ToString() %>'
runat="server">Details</asp:LinkButton>
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
</tbody>
<tfoot>
</tfoot>
</table>
</asp:Content>
Dentist.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace DentalHospital
{
public partial class Dentist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ //login check
if (Session["loginName"] != null && Session["loginPass"] != null &&
Convert.ToInt32(Session["userType"]) == 2)
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
com.Parameters.AddWithValue("@Password", Session["loginPass"]);
com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{ //get dentist list
SqlDataAdapter dap = new SqlDataAdapter("select * from Dentist", new
SqlConnection(Tools.localConnString));
37

DataTable dt = new DataTable();


dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs
e)
{
if (e.CommandName == "detail")
{ //get schedule list
Response.Redirect("DentistDetails.aspx?
DentistId="+e.CommandArgument.ToString());
}
}
private void FillDentists()
{ //get all dentists
SqlDataAdapter dap = new SqlDataAdapter("Select * from Dentist",
Tools.localConnString);
DataTable dt = new DataTable();
dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
}
protected void LinkButton3_Click(object sender, EventArgs e)
38

{ //logout
Session["loginName"] = null;
Session["loginPass"] = null;
Session["userType"] = null;
Response.Redirect(ResolveUrl("~/Default.aspx"));
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect(ResolveUrl("~/DentistDetails.aspx"));
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect(ResolveUrl("~/GiveReport.aspx"));
}
}
}
DentistDetails.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"
AutoEventWireup="true"
CodeBehind="DentistDetails.aspx.cs" Inherits="DentalHospital.DentistDetails" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
/<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">Give
Report</asp:LinkButton> /
<asp:LinkButton ID="LinkButton1" runat="server"
PostBackUrl="~/Dentist.aspx">Dentist</asp:LinkButton><br />
<table>
<tr>
<td>
Date
</td>
<td colspan="3">
Hour
</td>
<td>
Patient
</td>
</tr>
<asp:ListView ID="ListView1" runat="server"
onitemcommand="ListView1_ItemCommand">
<ItemTemplate>
<tr>
<td>
<%# Eval("StartDate").ToString().Substring(0,10) %>
39

</td>
<td>
<%# Eval("StartDate").ToString().Substring(11,5)%>
</td>
<td>
</td>
<td>
<%# Eval("EndDate").ToString().Substring(11,5)%>
</td>
<td>
<%# Eval("Name").ToString()%>
<%# Eval("Surname").ToString()%>
</td>
<td>
<asp:LinkButton ID="LinkButtonDelete" CommandName="ddelete"
CommandArgument='<%# Eval("ScheduleId").ToString()%>'
runat="server">Delete</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td>
<%# Eval("StartDate").ToString().Substring(0,10) %>
</td>
<td>
<%# Eval("StartDate").ToString().Substring(11,5)%>
</td>
<td>
</td>
<td>
<%# Eval("EndDate").ToString().Substring(11,5)%>
</td>
<td>
<%# Eval("Name").ToString()%>
<%# Eval("Surname").ToString()%>
</td>
<td>
<asp:LinkButton ID="LinkButtonDelete" CommandName="ddelete"
CommandArgument='<%# Eval("ScheduleId").ToString()%>'
runat="server">Delete</asp:LinkButton>
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
<tr>
<td>

40

<asp:TextBox ID="TextBoxDay" Width="80" Visible="false"


runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBoxStartHour" Width="40" Visible="false"
runat="server"></asp:TextBox>
</td>
<td>
</td>
<td>
<asp:TextBox ID="TextBoxEndHour" Width="40" Visible="false"
runat="server"></asp:TextBox>
<asp:HiddenField ID="HiddenField1" runat="server" />
</td>
<td>
<asp:LinkButton ID="LinkButtonInsert" Visible="false" runat="server"
OnClick="LinkButtonInsert_Click">Insert Schedule</asp:LinkButton>
</td>
</tr>
</table>
</asp:Content>
DentistDetails.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace DentalHospital
{
public partial class DentistDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ //login check
if (Session["loginName"] != null && Session["loginPass"] != null &&
Convert.ToInt32(Session["userType"]) == 2)
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
com.Parameters.AddWithValue("@Password", Session["loginPass"]);
41

com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{ //get schedule
FillSchedule();
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
private void FillSchedule()
{
if (Request.QueryString["DentistId"] == null)
{
SqlConnection connn = new SqlConnection(Tools.localConnString);
SqlCommand comm = new SqlCommand("Select UserId from Userr where
UserName = '" + Session["loginName"].ToString() + "' and Password = '" +
Session["loginPass"].ToString() + "' and UserTypeId = '" + Session["userType"].ToString() +
"'", connn);
//get user info
connn.Open();
string UserrrrId = comm.ExecuteScalar().ToString();
connn.Close();

42

SqlConnection co = new SqlConnection(Tools.localConnString);


SqlCommand c = new SqlCommand("Select DentistId from Dentist where
UserrId=" + UserrrrId.ToString(), co);
co.Open();
string DentisId = c.ExecuteScalar().ToString();
co.Close();
//accoding to patient and dentist id, get schedules
SqlDataAdapter dap = new SqlDataAdapter("Select * from Schedule left outer join
Patient on Schedule.PatientId = Patient.PatientId where DentistId=" + DentisId.ToString(),
Tools.localConnString);
DataTable dt = new DataTable();
dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
//get dentist related to dentist id
HiddenField1.Value = dt.Rows[0]["DentistId"].ToString();
TextBoxDay.Visible = true;
TextBoxStartHour.Visible = true;
TextBoxEndHour.Visible = true;
LinkButtonInsert.Visible = true;
}
else
{
SqlDataAdapter dap = new SqlDataAdapter("Select * from Schedule left outer join
Patient on Schedule.PatientId = Patient.PatientId where DentistId=" +
Request.QueryString["DentistId"].ToString(), Tools.localConnString);
DataTable dt = new DataTable();
dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
}
}

protected void LinkButtonInsert_Click(object sender, EventArgs e)


{ //insert into schedule
SqlConnection con = new SqlConnection(Tools.localConnString.ToString());
SqlCommand com = new SqlCommand("Insert into Schedule
(StartDate,EndDate,DentistId) values (@StartDate,@EndDate,@DentistId)",con);
int day = Convert.ToInt32(TextBoxDay.Text.Substring(0,2));
int month = Convert.ToInt32(TextBoxDay.Text.Substring(3,2));
int year = Convert.ToInt32(TextBoxDay.Text.Substring(6, 4));
string sHour = TextBoxStartHour.Text;
string eHour = TextBoxEndHour.Text;
string DentistId = HiddenField1.Value.ToString();
43

//string StartDate = day + " " + sHour;


//string EndDate = day + " " + eHour;
DateTime StartDate = new
DateTime(year,month,day,Convert.ToInt32(sHour.Substring(0,2)),Convert.ToInt32(sHour.Sub
string(3,2)),0);
DateTime EndDate = new DateTime(year, month, day,
Convert.ToInt32(eHour.Substring(0, 2)), Convert.ToInt32(eHour.Substring(3, 2)), 0);
com.Parameters.AddWithValue("@StartDate", StartDate);
com.Parameters.AddWithValue("@EndDate", EndDate);
com.Parameters.AddWithValue("@DentistId", DentistId);
con.Open();
var count = com.ExecuteNonQuery();
con.Close();
FillSchedule();
}
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs
e)
{ //delete schedule
if (e.CommandName.Equals("ddelete"))
{
SqlConnection con = new SqlConnection(Tools.localConnString.ToString());
SqlCommand com = new SqlCommand("Delete from Schedule where
ScheduleId=@ScheduleId", con);
com.Parameters.AddWithValue("@ScheduleId",e.CommandArgument.ToString());
con.Open();
var count = com.ExecuteNonQuery();
con.Close();
}
FillSchedule();
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
Response.Redirect(ResolveUrl("~/GiveReport.aspx"));
}
}
}
Report.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"
AutoEventWireup="true"
CodeBehind="GiveReport.aspx.cs" Inherits="DentalHospital.GiveReport" %>

44

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">My
Details</asp:LinkButton>
/
<asp:LinkButton ID="LinkButton3" runat="server"
OnClick="LinkButton3_Click">Logout</asp:LinkButton><br />
<asp:ListView ID="ListView1" runat="server"
onitemcommand="ListView1_ItemCommand"
onselectedindexchanged="ListView1_SelectedIndexChanged">
<ItemTemplate>
<asp:LinkButton CssClass="patient" ID="LinkButton2" CommandName="report"
CommandArgument='<%# Eval("PatientId").ToString() %>' runat="server"><%#
Eval("Name").ToString() %> <%# Eval("Surname").ToString() %></asp:LinkButton><br />
</ItemTemplate>
</asp:ListView>
</asp:Content>

Report.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace DentalHospital
{
public partial class GiveReport : System.Web.UI.Page
{
public string DentisId;
protected void Page_Load(object sender, EventArgs e)
{ //login check
if (Session["loginName"] != null && Session["loginPass"] != null &&
Convert.ToInt32(Session["userType"]) == 2)
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
com.Parameters.AddWithValue("@Password", Session["loginPass"]);
com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
45

try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{
if (Request.QueryString["DentistId"] == null)
{ //get user info
SqlConnection connn = new SqlConnection(Tools.localConnString);
SqlCommand comm = new SqlCommand("Select UserId from Userr where
UserName = '" + Session["loginName"].ToString() + "' and Password = '" +
Session["loginPass"].ToString() + "' and UserTypeId = '" + Session["userType"].ToString() +
"'", connn);
connn.Open();
string UserrrrId = comm.ExecuteScalar().ToString();
connn.Close();
SqlConnection co = new SqlConnection(Tools.localConnString);
SqlCommand c = new SqlCommand("Select DentistId from Dentist where
UserrId=" + UserrrrId.ToString(), co);
co.Open();
DentisId = c.ExecuteScalar().ToString();
co.Close();
SqlDataAdapter dap = new SqlDataAdapter("Select
Name,Surname,Patient.PatientId as PatientId from Schedule inner join Patient on
Schedule.PatientId = Patient.PatientId where Schedule.DentistId = @DentistId and
Patient.ReportId IS NULL",new SqlConnection(Tools.localConnString));
dap.SelectCommand.Parameters.AddWithValue("@DentistId",DentisId);
DataTable dt = new DataTable();
dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
} //see patients that can be given report
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{
throw;
46

}
finally
{
conn.Close();
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
protected void LinkButton3_Click(object sender, EventArgs e)
{ //logout
Session["loginName"] = null;
Session["loginPass"] = null;
Session["userType"] = null;
Response.Redirect(ResolveUrl("~/Default.aspx"));
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect(ResolveUrl("~/DentistDetails.aspx"));
}
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs
e)
{ //according to patient id, getting report id
SqlConnection con = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select ReportId from Patient where
PatientId=@PatientId",con);
com.Parameters.AddWithValue("@PatientId", e.CommandArgument.ToString());
con.Open();
object reportId = com.ExecuteScalar();
string r = Convert.ToString(reportId);
con.Close();
if(r == "")
Response.Redirect(ResolveUrl("~/ReportToPatient.aspx?
PatientId="+e.CommandArgument.ToString()+"&DentistId="+DentisId));
}
}
}
Admin.aspx
47

<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"


AutoEventWireup="true"
CodeBehind="Administration.aspx.cs" Inherits="DentalHospital.Administration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click"
>Logout</asp:LinkButton>
<table style="text-align: left" cellpadding="3px" cellspacing="1px">
<thead>
<tr>
<th class="header" colspan="5">
List Of Dentists
</th>
</tr>
<tr>
<th>
Name Surname
</th>
<th>
Age
</th>
<th>
Sex
</th>
<th>
Telephone
</th>
<th>
Operations
</th>
</tr>
</thead>
<tbody>
<asp:ListView runat="server" ID="ListView1"
OnItemCommand="ListView1_ItemCommand">
<ItemTemplate>
<tr class="non-alternate">
<td>
<%# Eval("Name").ToString() %>
<%# Eval("Surname").ToString() %>
</td>
<td>
<%# Eval("Age").ToString() %>
</td>
<td>
<%# Eval("Sex").ToString() %>
</td>
<td>
48

<%# Eval("Telephone").ToString() %>


</td>
<td>
<asp:LinkButton ID="LinkButtonDentistDelete" CommandName="deletee"
CommandArgument='<%# Eval("DentistId").ToString() %>'
runat="server">Delete</asp:LinkButton>
<asp:LinkButton ID="LinkButtonDentistUpdate"
CommandName="updatee" CommandArgument='<%# Eval("DentistId").ToString() %>'
runat="server">Update</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="alternate">
<td>
<%# Eval("Name").ToString() %>
<%# Eval("Surname").ToString() %>
</td>
<td>
<%# Eval("Age").ToString() %>
</td>
<td>
<%# Eval("Sex").ToString() %>
</td>
<td>
<%# Eval("Telephone").ToString() %>
</td>
<td>
<asp:LinkButton ID="LinkButtonDentistDelete" CommandName="deletee"
CommandArgument='<%# Eval("DentistId").ToString() %>'
runat="server">Delete</asp:LinkButton>
<asp:LinkButton ID="LinkButtonDentistUpdate"
CommandName="updatee" CommandArgument='<%# Eval("DentistId").ToString() %>'
runat="server">Update</asp:LinkButton>
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
</tbody>
<tfoot>
<tr class="alternate">
<td>
<asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBoxSurname" runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBoxAge" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBoxSex" runat="server"></asp:TextBox>
</td>
49

<td>
<asp:TextBox ID="TextBoxTelephone" runat="server"></asp:TextBox>
</td>
<td>
<asp:LinkButton ID="LinkButtonDentistInsert"
runat="server"
onclick="LinkButtonDentistInsert_Click">Insert</asp:LinkButton>
</td>
</tr>
</tfoot>
</table>
</asp:Content>
Admin.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace DentalHospital
{
public partial class Administration : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ //login check
if (Session["loginName"] != null && Session["loginPass"] != null &&
Convert.ToInt32(Session["userType"]) == 1)
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
com.Parameters.AddWithValue("@Password", Session["loginPass"]);
com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{ //see dentists
SqlDataAdapter dap = new SqlDataAdapter("select * from Dentist", new
SqlConnection(Tools.localConnString));
50

DataTable dt = new DataTable();


dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
else
{
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs
e)
{ //delete dentist
if (e.CommandName == "deletee")
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Delete from Dentist where DentistId =
@DentistId", conn);
com.Parameters.AddWithValue("@DentistId", e.CommandArgument.ToString());
try
{
conn.Open();
int result = com.ExecuteNonQuery();
FillDentists();
}
catch (Exception ex)
{
throw;
}
51

finally
{
conn.Close();
}
}
if (e.CommandName == "updatee")
{
//Response.Redirect("DentistUpdate.aspx?DentistId=" +
e.CommandArgument.ToString());
return;
}
}
private void FillDentists()
{ //get dentist
SqlDataAdapter dap = new SqlDataAdapter("Select * from Dentist",
Tools.localConnString);
DataTable dt = new DataTable();
dap.Fill(dt);
ListView1.DataSource = dt;
ListView1.DataBind();
}
protected void LinkButtonDentistInsert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Insert into
Dentist(Name,Surname,Age,Sex,Telephone)
values(@Name,@Surname,@Age,@Sex,@Telephone)", con);
com.Parameters.AddWithValue("@Name", TextBoxName.Text.ToString());
com.Parameters.AddWithValue("@Surname", TextBoxSurname.Text.ToString());
com.Parameters.AddWithValue("@Age", TextBoxAge.Text.ToString());
com.Parameters.AddWithValue("@Sex", TextBoxSex.Text.ToString());
com.Parameters.AddWithValue("@Telephone",
TextBoxTelephone.Text.ToString());
try
{
con.Open();
if (1 == com.ExecuteNonQuery())
{
}
else
{
}
}
catch (Exception exception)
52

{
throw;
}
finally
{
con.Close();
Response.Redirect(ResolveUrl("~/Administration.aspx"));
}
}
protected void LinkButton3_Click(object sender, EventArgs e)
{ //logout
Session["loginName"] = null;
Session["loginPass"] = null;
Session["userType"] = null;
Response.Redirect(ResolveUrl("~/Default.aspx"));
}
}
}
Login.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/DentalMaster.Master"
AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="DentalHospital.Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table>
<tr>
<td>
<b>Kullanc Ad</b>
</td>
<td>
<b>:</b>
</td>
<td>
<asp:TextBox ID="txtLgn" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<b>ifre</b>
</td>
<td>
<b>:</b>
</td>
<td>
<asp:TextBox ID="txtPass" runat="server"
TextMode="Password"></asp:TextBox>
</td>
53

</tr>
<tr>
<td colspan="3">Login As;
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Text="Admin" Value="1"></asp:ListItem>
<asp:ListItem Text="Dentist" Value="2"></asp:ListItem>
<asp:ListItem Text="Patient" Value="3"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td colspan="3">
<asp:LinkButton ID="LinkButton1" runat="server"
OnClick="LinkButton1_Click"><b>Go !</b></asp:LinkButton>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblError" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:Content>
Login.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace DentalHospital
{
public partial class Login : System.Web.UI.Page
{
string loginName;
string loginPass;
int userType;
protected void Page_Load(object sender, EventArgs e)
{ //login checks
if (Session["loginName"] != null && Session["loginPass"] != null &&
Session["loginPass"] != null)
{
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", Session["loginName"]);
54

com.Parameters.AddWithValue("@Password", Session["loginPass"]);
com.Parameters.AddWithValue("@UserTypeId", Session["userType"]);
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{
switch (Convert.ToInt32(Session["userType"]))
{
case 1:
Response.Redirect(ResolveUrl("~/Administration.aspx"), false);
break;
case 2:
Response.Redirect(ResolveUrl("~/Dentist.aspx"), false);
break;
case 3:
Response.Redirect(ResolveUrl("~/Patient.aspx"), false);
break;
}
}
else
{
return;
}
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
}
else
{
return;
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
loginName = txtLgn.Text.Trim();
55

loginPass = txtPass.Text.Trim();
userType = Convert.ToInt32(RadioButtonList1.SelectedValue);
SqlConnection conn = new SqlConnection(Tools.localConnString);
SqlCommand com = new SqlCommand("Select Count(*) from Userr where
UserName = @UserName and Password = @Password and UserTypeId = @UserTypeId",
conn);
com.Parameters.AddWithValue("@UserName", loginName);
com.Parameters.AddWithValue("@Password", loginPass);
com.Parameters.AddWithValue("@UserTypeId", userType);
try
{
conn.Open();
if ((int)com.ExecuteScalar() == 1)
{
Session["loginName"] = loginName;
Session["loginPass"] = loginPass;
Session["userType"] = userType;
switch (userType)
{
case 1:
Response.Redirect(ResolveUrl("~/Administration.aspx"), false);
break;
case 2:
Response.Redirect(ResolveUrl("~/Dentist.aspx"), false);
break;
case 3:
Response.Redirect(ResolveUrl("~/Patient.aspx"), false);
break;
}
}
else
{
lblError.Text = "Byle bir kullanc ad veya ifre ikilisi bulunmuyor";
Response.Redirect(ResolveUrl("~/Login.aspx"));
}
}
catch (Exception)
{
throw;
}
finally
{
conn.Close();
}
56

}
}
}
Note: Classes and functions that have high importance have been implemented.
11. SCREENSHOTS
Login:

----------------------------------------------------------------------------------------------------------Patient:

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

Dentist:

57

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------

Admin:

58

Figure 35. Screenshots

59

You might also like