-
Notifications
You must be signed in to change notification settings - Fork 0
/
EthicsHOSMain.aspx.cs
95 lines (86 loc) · 4.13 KB
/
EthicsHOSMain.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Web.UI.HtmlControls;
/**
* The Head od School main page.
* Displays a list of submitted applicationthe requiring HOS endorsement.
*/
public partial class EthicsHOSMain : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MySqlConnection mySqlConnection = new Connector().MySQLConnect();
MySqlCommand command = mySqlConnection.CreateCommand();
int staffID = Convert.ToInt32(Context.Request["StaffID"]);
//Populate labels.
command.CommandText = "SELECT * FROM Staff LEFT JOIN AccountTypeList ON Staff.AccountType = AccountTypeList.ID WHERE StaffID = " + staffID;
MySqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
reader.Read();
lblWelcome.InnerText = "Welcome " + reader["NameFirst"].ToString() + " " + reader["NameLast"].ToString();
LblAccnt.InnerText = "Account Type: " + reader["AccntType"].ToString();
}
else
divMsg.InnerText = "Error: Could not find staff member in database";
reader.Dispose();
//Populate table.
command.CommandText = @"SELECT Application.AppID, Application.a1_ProjTitle, StatusList.AppStatus, RiskLow_Bool, RiskNonLow_Bool
FROM Application LEFT JOIN StatusList ON Application.AppStatus = StatusList.ID
WHERE g_HOS_StaffID = " + staffID + " AND Application.AppStatus = 1";
reader = command.ExecuteReader();
if (reader.HasRows) //Build table entries.
{
while (reader.Read()) //Build a table row for each row of query.
{
HtmlTableRow row = new HtmlTableRow();
//Build buttons.
HtmlInputButton btnView = new HtmlInputButton();
btnView.ID = "ViewPI" + reader["AppID"].ToString();
btnView.Value = "View";
btnView.ServerClick += btnView_ServerClick;
HtmlInputButton btnEndorse = new HtmlInputButton();
btnEndorse.ID = "Endorse" + reader["AppID"].ToString();
btnEndorse.Value = "Endorse";
btnEndorse.ServerClick += btnEndorse_ServerClick;
row.Cells.Add(HTMLFactory.buildCell("50", "left", reader["AppID"].ToString()));
row.Cells.Add(HTMLFactory.buildCell("400", "left", reader["a1_ProjTitle"].ToString()));
row.Cells.Add(HTMLFactory.buildCell("200", "left", reader["AppStatus"].ToString()));
row.Cells.Add(HTMLFactory.buildCell("97", "center", btnView));
row.Cells.Add(HTMLFactory.buildCell("97", "center", btnEndorse));
tblUnsubmitted.Rows.Add(row);
}
}
else //Else display none.
{
if (tblUnsubmitted.Rows.Count != 0)
{
HtmlTableRow blnkRow = new HtmlTableRow();
HtmlTableCell blnk = new HtmlTableCell();
blnk.InnerText = "None";
blnk.ColSpan = 5;
blnkRow.Cells.Add(blnk);
tblUnsubmitted.Rows.Add(blnkRow);
}
}
reader.Dispose(); //Cleanup.
command.Dispose();
mySqlConnection.Close();
}
//Button click handlers, redirect to new page.
public void btnView_ServerClick(object sender, EventArgs e)
{
HtmlInputButton source = (HtmlInputButton)sender;
Response.Redirect("EthicsEditAppTriage.aspx?Mode=R&AppID=" + source.ID.Remove(0, 6) + "&StaffID=" + Context.Request["StaffID"] + "&Type=" + Context.Request["Type"]);
}
public void btnEndorse_ServerClick(object sender, EventArgs e)
{
HtmlInputButton source = (HtmlInputButton)sender;
Response.Redirect("EthicsHOSEndorse.aspx?AppID=" + source.ID.Remove(0, 7) + "&StaffID=" + Context.Request["StaffID"] + "&Type=" + Context.Request["Type"]);
}
}