-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathViewPatientHealthReport.aspx.cs
More file actions
150 lines (129 loc) · 4.8 KB
/
ViewPatientHealthReport.aspx.cs
File metadata and controls
150 lines (129 loc) · 4.8 KB
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
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;
using System.Configuration;
using System.IO;
public partial class ViewPatientHealthReport : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader rs;
SqlDataAdapter adp;
DataTable dt;
void bindgrid()
{
cmd = new SqlCommand("select pkey from ptable where pid=@pid", con);
cmd.Parameters.AddWithValue("pid", TextBox2.Text);
rs = cmd.ExecuteReader();
string pkey = "";
if (rs.Read())
{
pkey = rs["pkey"].ToString();
rs.Close();
cmd.Dispose();
}
else
{
rs.Close();
cmd.Dispose();
Label1.Text = "Patient ID Not Found.Check Ptable....";
return;
}
char[] c = pkey.ToCharArray();
byte b = (byte)c[3];
DirectoryInfo d1 = new DirectoryInfo(Server.MapPath("Temp"));
FileInfo[] f1 = d1.GetFiles();
foreach (FileInfo f2 in f1)
f2.Delete();
adp = new SqlDataAdapter("select * from hrtable where pid=@pid", con);
adp.SelectCommand.Parameters.AddWithValue("pid", TextBox2.Text);
dt = new DataTable();
adp.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
string xrayfname = dt.Rows[i]["xrayfname"].ToString();
byte[] xraycontent = (byte[])dt.Rows[i]["xraycontent"];
int j = 0;
for (j = 0; j < xraycontent.Length; j++)
{
xraycontent[j] = (byte)(xraycontent[j] - b);
}
FileStream fs = new FileStream(Server.MapPath("Temp/") + xrayfname, FileMode.Create, FileAccess.Write);
fs.Write(xraycontent, 0, xraycontent.Length);
fs.Close();
string scanfname = dt.Rows[i]["scanfname"].ToString();
byte[] scancontent = (byte[])dt.Rows[i]["scancontent"];
for (j = 0; j < scancontent.Length; j++)
{
scancontent[j] = (byte)(scancontent[j] - b);
}
fs = new FileStream(Server.MapPath("Temp/") + scanfname, FileMode.Create, FileAccess.Write);
fs.Write(scancontent, 0, scancontent.Length);
fs.Close();
string ecgfname = dt.Rows[i]["ecgfname"].ToString();
byte[] ecgcontent = (byte[])dt.Rows[i]["ecgcontent"];
for (j = 0; j < ecgcontent.Length; j++)
{
ecgcontent[j] = (byte)(ecgcontent[j] - b);
}
fs = new FileStream(Server.MapPath("Temp/") + ecgfname, FileMode.Create, FileAccess.Write);
fs.Write(ecgcontent, 0, ecgcontent.Length);
fs.Close();
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
Label1.Text = "";
Menu m3 = (Menu)Master.FindControl("Menu3");
m3.Visible = true;
con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
con.Open();
if (!IsPostBack)
{
if (Session["DID"] != null && Request.QueryString.Get("ReqID") != null && Request.QueryString.Get("PID") != null)
{
TextBox1.Text = Session["DID"].ToString(); TextBox2.Text = Request.QueryString.Get("PID");
bindgrid();
}
}
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
try
{
//ReqID,PID;
cmd = new SqlCommand("Select * from hrtable where did=@did and pid=@pid and rid=@rid", con);
cmd.Parameters.AddWithValue("did", TextBox1.Text);
cmd.Parameters.AddWithValue("pid", Request.QueryString.Get("PID"));
cmd.Parameters.AddWithValue("rid", Request.QueryString.Get("ReqID"));
rs = cmd.ExecuteReader();
bool b = rs.Read();
rs.Close();
cmd.Dispose();
if (b)
{
Label1.Text = "This Request Based Health Report Details Already Inserted......";
return;
}
Response .Redirect ("AddPatientHealthDetails.aspx?ReqID="+Request.QueryString.Get("ReqID")+"&PID="+Request.QueryString.Get("PID"));
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
}