-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppointmentDetails.aspx.cs
123 lines (101 loc) · 4.32 KB
/
AppointmentDetails.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace HospitalsDashboard
{
public partial class AppointmentDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BindAppointments();
}
}
private void BindAppointments()
{
DataTable Dt = new DataTable();
Dt.Columns.Add("AppointmentId");
Dt.Columns.Add("PatientId");
Dt.Columns.Add("PatientName");
Dt.Columns.Add("AppointmentDate");
Dt.Columns.Add("AppointmentTime");
Dt.Columns.Add("PatientVisit");
Dt.Columns.Add("Icompany");
Dt.Columns.Add("Cost");
Dt.Columns.Add("Doctor");
Dt.Columns.Add("FirstVisit");
Dt.Rows.Add();
gvAppointments.DataSource = Dt;
gvAppointments.DataBind();
}
[WebMethod]
public static string GetAppointments()
{
string query = "select AppointmentId,PatientId, PatientName,AppointmentDate,AppointmentTime,PatientVisit,Cost,Doctor,FirstVisit,Icompany FROM dbo.AppointmentDetails";
using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString))
{
SqlCommand cmd = new SqlCommand(query);
using(SqlDataAdapter Da = new SqlDataAdapter())
{
cmd.Connection = conn;
Da.SelectCommand = cmd;
using (DataSet ds = new DataSet())
{
Da.Fill(ds);
return ds.GetXml();
}
}
}
}
[WebMethod]
public static string UpdateAppointment(int AppointmentId, string PatientName, string AppointmentDate,string AppointmentTime,string PatientVisit, int Cost, string Doctor, string FirstVisit,string icompany)
{
string constr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
using (SqlConnection conn = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("UPDATE dbo.AppointmentDetails SET PatientName = @Name,AppointmentDate=@AppDate,AppointmentTime=@AppTime,PatientVisit=@PatientVisit,Icompany=@icompany, Cost=@Cost,Doctor = @Doctor,FirstVisit=@FirstVisit WHERE AppointmentId = @AppointmentId"))
{
cmd.Parameters.AddWithValue("@AppointmentId",AppointmentId);
cmd.Parameters.AddWithValue("@Name", PatientName);
cmd.Parameters.AddWithValue("@AppDate",AppointmentDate);
cmd.Parameters.AddWithValue("@AppTime", AppointmentTime);
cmd.Parameters.AddWithValue("@PatientVisit",PatientVisit);
cmd.Parameters.AddWithValue("@Cost", Cost);
cmd.Parameters.AddWithValue("@Doctor", Doctor);
cmd.Parameters.AddWithValue("@FirstVisit", FirstVisit);
cmd.Parameters.AddWithValue("@icompany", icompany);
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
return "success";
}
[WebMethod]
public static string DeleteAppointment(int AppointmentId)
{
string constr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
using (SqlConnection conn = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("DELETE FROM dbo.AppointmentDetails WHERE AppointmentId = @AppointmentId"))
{
cmd.Parameters.AddWithValue("@AppointmentId", AppointmentId);
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
return "success";
}
}
}