-
Notifications
You must be signed in to change notification settings - Fork 0
/
Inbox.aspx.cs
168 lines (141 loc) · 5.33 KB
/
Inbox.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
165
166
167
168
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Inbox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = ConfigurationManager.AppSettings["title"];
if (string.IsNullOrEmpty(Session["HRS_USER_ID"] as string))
{
Response.Redirect("Login.aspx", true);
}
if (!IsPostBack)
{
addInboxData();
}
}
private void addInboxData()
{
OracleConnection oc = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
OracleCommand cmd = new OracleCommand
{
Connection = oc
};
try
{
oc.Open();
cmd.CommandText = @" SELECT TD.*, e.NAME AS INITIATOR_NAME
FROM VISAFORM.VFF_TRIP_DETAILS TD
JOIN VISAFORM.MR_HRS_EMPLOYEE e ON PNO=(SELECT PNO FROM VISAFORM.VFF_TRAVEL_REQUEST WHERE TRAVEL_REQUEST_ID=TD.TRAVEL_REQUEST_ID)
WHERE TD.TRAVEL_REQUEST_ID IN
(SELECT i.REQ_ID
FROM VISAFORM.ATF_WF_INSTANCE_STEPS i
WHERE i.APPROVER_ID = :PNO
AND i.APP_ID=2
AND i.APPROVED IS NULL
AND (i.STEP_SORT_NO =
( (SELECT COUNT (*)
FROM ATF_WF_INSTANCE_STEPS
WHERE APPROVED = 'Y'
AND REQ_ID = i.REQ_ID)
+ 1)))
ORDER BY TRAVEL_REQUEST_ID";
cmd.Parameters.Add(new OracleParameter(":PNO", Session["PNO"].ToString()));
OracleDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
// Load the data from the reader into the DataTable
dt.Load(reader);
reader.Close();
InboxTransferRequests.DataSource = dt;
InboxTransferRequests.DataBind();
}
catch (Exception ex)
{
lblRedBottom.Text = "There was an error while fetching your pending requests. Please contact IT if issue persists. Error: " + ex.Message;
}
finally
{
oc.Close();
oc.Dispose();
}
}
public void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("./Menu.aspx", true);
}
protected void GridViewInboxTransferRequests_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Check if the current row is a data row
//if (e.Row.RowType == DataControlRowType.DataRow)
//{
// InboxTransferRequests.Columns[9].Visible = false;// Index 6 corresponds to the reinitiated column (0-based index)
//}
}
public void btnDetails_Click(object sender, EventArgs e)
{
ClearMessages();
bool atLeastOneRowSelected = false;
// Loop through each row in the GridView
foreach (GridViewRow row in InboxTransferRequests.Rows)
{
// Find the CheckBox control in the current row
CheckBox chk = (CheckBox)row.FindControl("CheckBoxInbox");
// Check if the CheckBox is checked
if (chk != null && chk.Checked)
{
atLeastOneRowSelected = true;
string reqID = row.Cells[1].Text;
Session["APPROVAL_REQ_ID"] = reqID; // 1st column of the gridview is set to REQ_ID on the aspx page.
break; // Exit loop if at least one CheckBox is checked
}
}
if (atLeastOneRowSelected)
{
Response.Redirect("./VisaForm.aspx", true);
}
else
{
lblRedBottom.Text = "You need to select a request to proceed*";
}
}
//public void btnDetails_Click(object sender, EventArgs e)
//{
// ClearMessages();
// bool atLeastOneRowSelected = false;
// // Loop through each row in the GridView
// foreach (GridViewRow row in InboxTransferRequests.Rows)
// {
// // Find the CheckBox control in the current row
// CheckBox chk = (CheckBox)row.FindControl("CheckBoxInbox");
// // Check if the CheckBox is checked
// if (chk != null && chk.Checked)
// {
// atLeastOneRowSelected = true;
// string reqID = row.Cells[1].Text;
// Session["APPROVAL_REQ_ID"] = reqID; // 1st column of the gridview is set to REQ_ID on the aspx page.
// break; // Exit loop if at least one CheckBox is checked
// }
// }
// if (atLeastOneRowSelected)
// {
// // Redirect to VisaFormDetails.aspx where the request details will be displayed
// Response.Redirect("./VisaFormDetails.aspx", true);
// }
// else
// {
// lblRedBottom.Text = "You need to select a request to proceed*";
// }
//}
public void ClearMessages()
{
lblGreenBottom.Text = "";
lblRedBottom.Text = "";
}
}