This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fyp.aspx.cs
126 lines (101 loc) · 4.1 KB
/
Fyp.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
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;
public partial class Fyp : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Load dashboard data when the page loads for the first time
dashboardButtonClick();
PopulateTokenDropdown();
}
}
// Function to load dashboard data
// {tokenDeg.Token_id} {tokenDeg.form_id} {tokenDeg.fyp_decision} {tokenDeg.fyp_comment}
protected void dashboardButtonClick()
{
// Access the controller class instance and fetch TokenDeg data
var controller = FypController.GetInstance();
var tokenDegList = controller.GetTokenDegList();
if (tokenDegList.Count > 0)
{
// Get the first TokenDeg object from the list
var tokenDeg = tokenDegList[0];
// Update the labels with TokenDeg details
Label1.Text = tokenDeg.Token_id;
Label2.Text = tokenDeg.form_id;
Label3.Text = tokenDeg.fyp_decision;
TextBox1.Text = tokenDeg.fyp_comment;
}
else
{
// If no pending requests, display a message
CardPlaceholder.Controls.Add(new LiteralControl("<p>No Degree Issuance Pending Requests.</p>"));
}
}
protected void PopulateTokenDropdown()
{
var controller = FypController.GetInstance();
var tokenDegList = controller.GetTokenDegList();
// Clear existing items from the dropdown menu
tokenDropdown.Items.Clear();
// Add a default option
tokenDropdown.Items.Add(new ListItem("Select Token", ""));
// Add tokens from the database to the dropdown menu
foreach (var tokenDeg in tokenDegList)
{
tokenDropdown.Items.Add(new ListItem(tokenDeg.Token_id, tokenDeg.Token_id));
}
}
protected void tokenDropdown_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedTokenID = tokenDropdown.SelectedValue;
// Fetch token details based on the selectedTokenID
var controller = FypController.GetInstance();
var tokenDetails = controller.GetTokenDetails(selectedTokenID);
// Update UI with fetched token details
if (tokenDetails != null)
{
// Update UI controls with token details
Label1.Text = tokenDetails.Token_id;
Label2.Text = tokenDetails.form_id;
Label3.Text = tokenDetails.fyp_decision;
TextBox1.Text = tokenDetails.fyp_comment;
// Show the card with fetched details
CardPlaceholder.Visible = true;
}
else
{
// If no token details found, hide the card
CardPlaceholder.Visible = false;
}
}
protected void AcceptButton_Click(object sender, EventArgs e)
{
// Get the token ID associated with the clicked button
var tokenID = Label1.Text;
// Get the comment from the corresponding text box
var comment = TextBox1.Text;
// Update the database with the new comment and decision
var controller = FypController.GetInstance();
controller.UpdateTokenDegDecision(tokenID, "accepted", comment);
// Refresh the token dropdown to reflect the changes
PopulateTokenDropdown();
}
protected void RejectButton_Click(object sender, EventArgs e)
{
// Get the token ID associated with the clicked button
var tokenID = Label1.Text;
// Get the comment from the corresponding text box
var comment = TextBox1.Text;
// Update the database with the new comment and decision
var controller = FypController.GetInstance();
controller.UpdateTokenDegDecision(tokenID, "rejected", comment);
// Refresh the token dropdown to reflect the changes
PopulateTokenDropdown();
}
}