-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_competition.aspx.cs
134 lines (122 loc) · 4.46 KB
/
manage_competition.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class manage_competition : System.Web.UI.Page
{
private const Int16 _DEFAULTPAGESIZE = 10;
protected string _pageName = common.GetPageName(HttpContext.Current.Request.ServerVariables.Get("PATH_INFO")).ToUpper();
protected void Page_Load(object sender, EventArgs e)
{
try
{
grdRpResults.PageSize = _DEFAULTPAGESIZE;
DataSet dsGridResults;
dsGridResults = this.Summary_Queue();
this.PopulateDataGrid(dsGridResults);
}
catch (Exception exp)
{
Response.Write(exp.Message.ToString());
}
}
#region UI Methods
public string ShowEditImage(object CompID)
{
return "<a ID='ViewNotes' href=\"javascript:ShowEdit('" + CompID.ToString().Trim() + "');\"" + ">" +
"<img src='" + Page.ResolveUrl("assets/img/edit.gif") + "' align='absmiddle' border='0' ID='ImageCheckBox'/></a>";
}
#endregion
#region Datagrid common Functions
public void PageResultGrid(object sender, DataGridPageChangedEventArgs e)
{
DataSet dsGridResults;
grdRpResults.CurrentPageIndex = e.NewPageIndex;
dsGridResults = dsGridResults = this.Summary_Queue();
PopulateDataGrid(dsGridResults);
}
private DataSet Summary_Queue()
{
DataSet dsRpAdvances = new DataSet();
try
{
Whitfieldcore _wc = new Whitfieldcore();
dsRpAdvances = _wc.GetCompetitors();
}
catch (Exception exp)
{
Response.Write(exp.Message.ToString());
}
return dsRpAdvances;
}
public void ResultGridItemCreated(object sender, DataGridItemEventArgs e)
{
ListItemType elemType = e.Item.ItemType;
TableCell pager = (TableCell)e.Item.Controls[0];
// Check to see if the item is the Pager Bar
if (elemType == ListItemType.Pager)
{
for (int i = 0; i < pager.Controls.Count; i += 2)
{
Object objControl = pager.Controls[i];
if (objControl is LinkButton)
{
LinkButton linkBtn = (LinkButton)objControl;
linkBtn.Text = " [" + linkBtn.Text + "] ";
}
else //Can only be a label
{
Label linkLabel = (Label)objControl;
linkLabel.Text = "Page " + linkLabel.Text;
linkLabel.CssClass = "Status";
}
}
}
}
private void PopulateDataGrid(DataSet dsGridResults)
{
Int32 resultCount = 0;
if (dsGridResults.Tables.Count > 0)
resultCount = dsGridResults.Tables[0].Rows.Count;
Int32 maxResultItemInPage = 0;
Int32 minResultItemInPage = 0;
try
{
if (resultCount > 0)
{
DataTable tblInstallments = dsGridResults.Tables[0];
//Display results in Grid
if (resultCount > (grdRpResults.CurrentPageIndex + 1) * grdRpResults.PageSize)
maxResultItemInPage = (grdRpResults.CurrentPageIndex + 1) * grdRpResults.PageSize;
else
maxResultItemInPage = resultCount;
if (maxResultItemInPage - (grdRpResults.PageSize - 1) > 1)
minResultItemInPage = maxResultItemInPage - (grdRpResults.PageSize - 1);
else
minResultItemInPage = 1;
grdRpResults.Visible = true;
grdRpResults.DataSource = tblInstallments;
grdRpResults.DataBind();
//Display the results message line
txtSelectionResultsMSG.Text = "Your selection found " + dsGridResults.Tables[0].Rows.Count + " Competition(s). Displaying users " + minResultItemInPage.ToString() + " - " + maxResultItemInPage.ToString() + ".";
}
else
{
txtSelectionResultsMSG.Text = "No Competitions Setup yet.";
grdRpResults.Visible = false;
}
}
catch (Exception exp)
{
Response.Write(exp.Message.ToString());
}
}
#endregion
protected void btnnew_Click(object sender, EventArgs e)
{
Response.Redirect("compmain.aspx?IsNew=Y");
}
}