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
1
delete them. The admin(s) should be able to list all dentists and patients and reach their
information.
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.
2
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 user’s 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.
3
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.)
1.2. The system must receive updates instantly, especially the moment that an
appointment occurs.
1.3. The system must keep dentists’ daily schedules.
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.
1.4. The system must provide ability to search for a specific dentist or patient.
1.5. There must be a control panel for admin.
4
5. FUNCTIONAL MODEL
a) Use Case Diagram
Figure1. Use Case Diagram
5
b) Use Case Descriptions
Get an appointment - Use CaseFlow of Events
Use Case DescriptionsMain.Scope Online Dental Hospidental Appointment SystemLevel User goalPrimary Actor PatientStakeholders and Interests
Patient - want to get an appointment fast and easier.
Admin - want to monitor appointments easier and provide alternatives to patients.
Brief Description Patients can get an appointment from any dentist instantly using the system.Preconditions Login the system.Post-conditions The system updates changes on a schedule immediately.Flow of Events 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 dentist7 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" button10 The system receives the
appointment and update the chosen dentist's schedule
11 The system displays main pageAlternative-1Scope Online Dental Hospidental Appointment SystemLevel Alternative of user goalPrimary Actor PatientPreconditions Login the systemPost-conditionsFlow of Events 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
6
is available at the entered time5 The system gives a warning that
there is no available dentists at the entered time
6 The system displays "get_appointment" page
Alternative-2.Scope Online Dental Hospidental Appointment SystemLevel Alternative of user goalPrimary Actor PatientPreconditions Login the systemPost-conditionsFlow of Events 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 dentist7 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 "Cancel" button10 The system cancels the
appointment11 The system displays
"get_appointment" page
Figure 2. Get an Appointment Use Case Description
7
List dentists - Use CaseFlow of Events
Use Case DescriptionsMain.Scope Online Dental Hospidental Appointment SystemLevel User goalPrimary actor PatientSecondary Actors Dentist and adminStakeholders and Interests
Patient - want to see all the dentists.
Admin - want to see all the dentists. Brief Description Dentists can be listed.PreconditionsPost-conditionsFlow of Events Actor Input System Response
1 Actor clicks on the "Dentists" tab
2 The system displays "Dentists" page
3 Actor clicks "List Dentists" button
4 The system shows all the dentists' profile pictures and names
5 Actor clicks on a picture to see information of a dentist
6 The system displays "Dentist_Info" page
7 The system shows the chosen dentist's information
Figure 3. List Dentists Use Case Description
8
Search a dentist - Use CaseFlow of Events
Use Case DescriptionsMain.Scope Online Dental Hospidental Appointment SystemLevel User goalPrimary actor PatientSecondary Actors Dentist and adminStakeholders and Interests
Patient - want to look for a dentist
Admin - want to look for a dentist Brief Description Looking for a specific dentist is possiblePreconditionsPost-conditionsFlow of Events Actor Input System Response
1 Actor clicks on the "Dentists" tab2 The system displays "Dentists"
page3 Actor clicks "Search dentist"
button4 The system enables a text box
and "OK" button5 Actor writes the name of the
dentist that he/she wants to see6 Actor clicks "OK" button.7 The system shows the chosen
dentist's schedule.Alternative.Scope Online Dental Hospidental Appointment SystemLevel Alternative of user goalPrimary actor PatientSecondary actors Dentist and adminBrief Description Actor can search for a dentist who does not work at Hospidental.PreconditionsPost-conditionsFlow of Events Actor Input System Response
1 Actor clicks on the "Dentists" tab
2 The system displays "Dentists" page
3 Actor clicks "Search dentist" button
4 The system enables a text box and "OK" button
5 Actor writes the name of the dentist that he/she wants to see
6 Actor clicks "OK" button7 The system gives a warning that
there is not a dentist with the entered name working at Hospidental
8 The system returns "Dentists" page
Figure 4. Search a Dentist Use Case Description
9
Insert Schedule - Use CaseFlow of Events
Use Case DescriptionsMain.Scope Online Dental Hospidental Appointment SystemLevel User goalPrimary actor DentistStakeholders and Interests
Dentist - want to publish his/her schedule on the system
Patient - want to reach dentists' schedules using by the system
Brief Description Dentists must add their schedules in the system.Preconditions Login the system.Post-conditionsFlow of Events Actor Input System Response
1 Actor clicks on "MyProfile" tab2 The system displays "MyProfile"
page3 The system shows the actor's
information4 Actor clicks on "Insert Schedule"
button5 The system displays
"add_schedule" page6 Actor inserts his/her schedule and
clicks OK button7 The system receives the added
schedule8 The system displays "MyProfile"
pageAlternative.Scope Online Dental Hospidental Appointment SystemLevel Alternative of user goalBrief Description Some information can be missing in the schedule that a dentist wants to insert.Preconditions Login the systemPost-conditionsFlow of Events Actor Input System Response
1 Actor clicks on "MyProfile" tab2 The system displays "MyProfile"
page3 The system shows the actor's
information4 Actor clicks on "Insert Schedule"
button5 The system displays
"add_schedule" page6 Actor inserts his/her schedule and
clicks OK button7 The system gives a warning that
there is missing information on the schedule wanted to be added.
8 The system display "myProfile" page
Figure 5. Insert Schedule Use Case Description
10
Monitor Patients - Use CaseFlow of Events
Use Case DescriptionsMain.Scope Online Dental Hospidental Appointment SystemBrief Description Dentists are able to monitor their own patients.Preconditions Login the system.Post-conditionsFlow of Events Actor Input System Response
1 Actor clicks on "Dentists" tab2 The system displays "Dentists"
page3 Actor clicks on "List Patients"
button4 The system displays Patients
page5 The system lists actor's own
patients.6 Actor clicks the name of the
patient that wanted to be monitored
7 The system displays a page for the chosen patient.
Figure 6. Monitor Patients Use Case Description
11
Update Dentist - Use CaseUse Case Descriptions
Main.Scope Online Dental Hospidental Appointment SystemLevel User goalPrimary Actor AdminStakeholders and Interests
Admin - want to update dentists' information frequently
Dentist - want admin to be enabled to add information about himself/herself anytime
Brief Description Admin can update a dentist's informationPreconditions Login the systemPost-conditions The system must receive the updates instantlyFlow of Events Actor Input System Response
1 Actor clicks "MyProfile" tab2 The system displays "MyProfile"
page3 Actor clicks "Update a dentist"
button4 The system lists dentists' profile
pictures and names5 Actor clicks on the picture of the
dentist that he/she wants to update6 The system displays the chosen
dentist's information7 Actor updates any parts of dentist's
information and clicks OK button8 The system receives updates and
displays actor's profileAlternative.Scope Online Dental Hospidental Appointment SystemLevel Alternative of user goalPrimary actor AdminBrief Description There can be missing information in tupdated part.Preconditions Login the systemPost-conditionsFlow of Events Actor Input System Response
1 Actor clicks "MyProfile" tab2 The system displays "MyProfile"
page3 Actor clicks "Update a dentist"
button4 The system lists dentists' profile
pictures and names5 Actor clicks on the picture of the
dentist that he/she wants to update6 The system displays the chosen
dentist's information7 Actor updates any parts of dentist's
information and clicks OK button8 The system gives a warning that
there is missing information in the updated parts
9 The system displays "MyProfile" page
Figure 7. Update Dentist Use Case Description
12
Login the system - Use CaseFlow of Events
Use Case DescriptionsMainScope Online Dental Hospidental Appointment SystemLevel EssentialPrimary actor AdminSecondary actors Patient and dentistStakeholders and Interests
Patient - dentist - admin : need to login system first to do specific processes
Brief Description The system includes a login system to identify users.Extension Point Register to the system.Flow of Events Actor Input System Response
1 Actor clicks "Login" button on main page
2 The system displays "login" page3 ---Extension Point---4 Actor enters TCid and password
and clicks OK button5 The system checks if entered
TCid and password are valid6 The system displays actor's
profileAlternative.Scope Online Dental Hospidental Appointment SystemLevel EssentialBrief Description Wrong TCid or passwordPreconditionsPost-conditionsFlow of Events Actor Input System Response
1 Actor clicks "Login" button on main page
2 The system displays "login" page3 Actor enters TCid and password
and clicks OK button4 The system checks if entered
TCid and password are valid5 The system gives a warning that
password is wrong6 The system displays
"new_password" page and asks the e-mail address of the actor to send a new password
7 Actor enters his/her mail address and clicks OK button
8 The system displays "login" page9 The system sends a new
password to actor's e-mail10 Actor enters TCid and new
password and clicks OK button11 The system displays actor's
profile
Figure 8. Login the System Use Case Description
13
Register to the system - Use CaseUse Case Descriptions
Main Yer işareti tanımlanmamış.Scope Online Dental Hospidental Appointment SystemLevel ExtensionBrief Description Registration is necessary before login the systemFlow of Events Actor Input System Response
1 Actor clicks "Register" button2 The system displays "register"
page3 Actor fills a form with his/her
personal information4 The system checks if the
information is valid5 The system accepts the
registration6 The system displays "login" page
AlternativeHata! Yer işareti tanımlanmamış.Scope Online Dental Hospidental Appointment SystemLevel ExtensionBrief Description Alternative of Register to the system.Flow of Events Actor Input System Response
1 Actor clicks "Register" button2 The system displays "register"
page3 Actor fills a form with his/her
personal information4 The system checks if the
information is valid5 The system gives a warning that
some information is invalid6 The system displays main page
Figure 9. Register to the System Use Case Description
14
c) Activity Diagrams
Login the System
Figure 10. Login the System Activity Diagram
Get an appointment
Figure 11. Get an Appointment Activity Diagram
15
Insert Schedule
Figure 12. Insert Schedule Activity Diagram
Update Dentist
Figure 13. Update Dentist Activity Diagram
16
List Dentists
Figure 14. List Dentist Activity Diagram
Search a Dentist
Figure 15. Search a Dentist Activity Diagram
17
d) System Sequence Diagrams
Login the system
Figure 16. Login the System System Sequence Diagram
Register to the system
Figure 17. Register to the System System Sequence Diagram
18
Get an appointment
Figure 18. Get an Appointment System Sequence Diagram
19
Insert Schedule
Figure 19. Insert Schedule System Sequence Diagram
Update Dentist
Figure 20. Update Dentist System Sequence Diagram
20
Search a Dentist
Figure 21. Search a Dentist System Sequence Diagram
List Dentists
Figure 22. List Dentist System Sequence Diagram
21
6. ANALYSIS CLASS DIAGRAM
Figure 23. Analysis Class Diagram
7. SYSTEM OPERATIONS
Figure 24. System Operations
22
8. DESIGN CLASS DIAGRAM
Figure 25. Design Class Diagram
9. INTERACTION DIAGRAMS
GetAppointment(date : Date)
23
Figure 26. Get Appointment Interaction Diagram
ListDentists()
Figure 27. List Dentists Interaction Diagram
SearchDentists(searchby : String)
24
Figure 28. Search Dentists Interaction Diagram
InsertSchedule(id : int, date : Date, value : boolean)
Figure 29. Insert Schedule Interaction Diagram
25
InsertReport(id : int, diagnosis : String)
Figure 30. Insert Report Interaction Diagram
MonitorReport(id : int)
Figure 31. Monitor Report Interaction Diagram
26
AddDentist(id : int, name : String, surname : String, age : int, sex : char, telephone : number, info : String)
Figure 32. Add Dentist Interaction DiagramCalculateTotalPrice(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.csusing 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> </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.csusing 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.csusing 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.Substring(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.csusing 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.csusing 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>Kullanıcı 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.csusing 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 = "Böyle bir kullanıcı 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