-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewInstructions.aspx.cs
121 lines (106 loc) · 3.24 KB
/
ViewInstructions.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
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
public partial class ViewInstructions : System.Web.UI.Page
{
String a = "";
String S = "";
CodeClass Ws = new CodeClass();
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
LblDisp.Text = Session["UN"].ToString();
Session["UN"] = LblDisp.Text;
Disp();
Panel1.Visible = true;
Panel2.Visible = false;
}
}
private void Disp()
{
DG.DataSource = null;
DG.DataBind();
SqlConnection Cn = new SqlConnection(Ws.Con);
Cn.Open();
SqlCommand Cmd = default(SqlCommand);
SqlDataReader dr = default(SqlDataReader);
DataTable dt = new DataTable();
DataRow row = null;
dt.Columns.Add("a");
dt.Columns.Add("b");
dt.Columns.Add("c");
dt.Columns.Add("d");
S = "Select AlID,Subj,Alert,DT From Alert Where Active=1 And StaffMail=@M1";
Cmd = new SqlCommand(S, Cn);
Cmd.Parameters.Add(new SqlParameter("@M1", LblDisp.Text));
dr = Cmd.ExecuteReader();
while (dr.Read())
{
row = dt.NewRow();
row[0] = dr["AlID"].ToString();
row[1] = dr["Subj"].ToString();
row[2] = dr["Alert"].ToString();
row[3] = dr["DT"].ToString();
dt.Rows.Add(row);
}
dr.Close();
Cmd.Dispose();
DG.DataSource = dt;
DG.DataBind();
int Flg = 0;
int i = 0;
String Msg="";
for (i = 0; i <= dt.Rows.Count - 1; i++)
{
Msg = dt.Rows[i][2].ToString();
if (Msg.Length >= 50)
{
Msg = Msg.Substring(0, 49).ToString() + "...";
}
DG.Rows[i].Cells[0].Text = dt.Rows[i][0].ToString();
DG.Rows[i].Cells[1].Text = dt.Rows[i][1].ToString();
DG.Rows[i].Cells[2].Text = Msg;
DG.Rows[i].Cells[3].Text = dt.Rows[i][3].ToString();
}
DG.Columns[0].Visible = false;
Cn.Close();
}
protected void DG_RowCommand(object sender, GridViewCommandEventArgs e)
{
long ID = 0;
ID = Convert.ToInt32(Convert.ToString(DG.Rows[Convert.ToInt16(e.CommandArgument)].Cells[0].Text));
Disp1(ID);
Panel1.Visible = false;
Panel2.Visible = true;
}
private void Disp1(long AID)
{
SqlConnection Cn = new SqlConnection(Ws.Con);
Cn.Open();
SqlCommand Cmd = default(SqlCommand);
SqlDataReader dr = default(SqlDataReader);
S = "Select * From Alert Where AlID=" + AID + "";
Cmd = new SqlCommand(S, Cn);
dr = Cmd.ExecuteReader();
if (dr.Read())
{
TxtSubject.Text = dr["Subj"].ToString();
TxtInfm.Text = dr["Alert"].ToString();
}
dr.Close();
Cmd.Dispose();
Cn.Close();
}
}