-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDoctorsPage.aspx.cs
164 lines (150 loc) · 4.05 KB
/
DoctorsPage.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//-----------------------------------------------------------------------
// Copyright (c) 2009 Navya Jammula.
// This file is part of HealthMonitoringSystem.
// HealthMonitoringSystem is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// HealthMonitoringSystem is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with HealthMonitoringSystem. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
namespace HealthMonitorSystem
{
public partial class DoctorsPage : BasePage
{
private static string _strSort;
private int SelectedPId
{
get
{
if(ViewState["SelectedPId"] != null)
{
return Convert.ToInt32(ViewState["SelectedPId"]);
}
return 0;
}
set
{
ViewState["SelectedPId"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if(this.UserId<=0)
{
this.ErrorMessage = "Please login to the System";
Response.Redirect("Default.aspx", true);
}
if(!IsPostBack)
{
phRemarks.Visible = false;
}
}
protected override void OnPreRender(EventArgs e)
{
try{
base.OnPreRender(e);
DataTable dt = this.RefreshData();
if(dt!= null)
{
if (!string.IsNullOrEmpty(_strSort))
{
DataView dv = dt.DefaultView;
dv.Sort = _strSort;
dt = dv.ToTable();
}
if(dt.Rows.Count > 0)
{
gv.DataSource = dt;
gv.DataBind();
}
else
{
this.ErrorMessage = "Sorry you donot have any patients Assigned. <br />" +
"You can go on a vacation.";
}
}
}catch(Exception ex)
{
this.ErrorMessage = ex.Message;
}
}
private DataTable RefreshData()
{
string strSql = " select dr.*, l.*, l.lastname || ' ' || l.firstname as name" +
" from doctorpatient dr " +
" inner join login l on dr.patientid=l.id " +
" where dr.doctorid = " + this.UserId;
DataSet ds = BaseDA.ExecuteDataSet(strSql);
if(ds!= null && ds.Tables.Count > 0)
{
return ds.Tables[0];
}
return null;
}
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "View")
{
Response.Redirect("PatientHist.aspx?id="+e.CommandArgument , true);
}
else if(e.CommandName == "Remarks")
{
this.SelectedPId = Convert.ToInt32(e.CommandArgument);
this.ShowRemarks();
}
}
private void ShowRemarks()
{
phRemarks.Visible = true;
txtRemarks.Text = string.Empty;
}
protected void gv_Sorting(object sender, GridViewSortEventArgs e)
{
_strSort = e.SortExpression;
if (e.SortDirection == SortDirection.Descending)
{
_strSort += " " + "DESC";
}
}
protected void btnCancel_Click (object sender, System.EventArgs e)
{
phRemarks.Visible = false;
}
protected void btnRemarks_Click (object sender, System.EventArgs e)
{
try
{
if(string.IsNullOrEmpty(txtRemarks.Text.Trim()))
{
this.ErrorMessage += "Remarks is Required <br />";
}
else
{
//Save Remarks
string strSql = string.Format("Update doctorpatient set doctorremarks='{0}' where " +
"doctorid = {1} and patientid = {2} ",
BaseDA.Escape(txtRemarks.Text.Trim()),
this.UserId, this.SelectedPId);
BaseDA.ExecuteNonQuery(strSql);
phRemarks.Visible = false;
this.SelectedPId = 0;
}
}
catch(Exception ex)
{
this.ErrorMessage = ex.Message;
}
}
}
}