Code Behind Page Page /Controls/ViewQuestionsCompletedGrid.ascx.cs (C#)
Used by Page /Controls/ViewQuestionsCompletedGrid.ascx (C#)
1: using System;  
2: using System.Globalization;  
3: using System.Web.UI;  
4: using System.Web.UI.WebControls;  
5: using QuizNetOnline.Logic;  
6: using Microsoft.ApplicationBlocks.Data;  
7:   
8: namespace QuiznetOnline.Web.UI  
9: {  
10:     public partial class ucViewQuestionsCompletedGrid : System.Web.UI.UserControl  
11:     {  
12:         private int MinutesToGMT;  
13:         private DateTime ClientTime;  
14:   
15:         public int NumberOfRecords;  
16:   
17:         protected void Page_Load(object sender, EventArgs e)  
18:         {  
19:             if (!Page.IsPostBack)  
20:             {  
21:             }  
22:   
23:             PopulateClientTimeZoneUTCMinutes();  
24:             LoadData();  
25:         }  
26:   
27:         private void PopulateClientTimeZoneUTCMinutes()  
28:         {  
29:             System.Web.HttpCookie httpCookie;  
30:             if(Request.Cookies["TimeZoneOffset"] != null)  
31:             {  
32:                 httpCookie = Request.Cookies["TimeZoneOffset"];  
33:                 if (httpCookie != null)  
34:                 {  
35:                     MinutesToGMT = Convert.ToInt32(httpCookie.Value);  
36:                 }  
37:             }  
38:   
39:             if (Request.Cookies["ClientTime"] != null)  
40:             {  
41:                 httpCookie = Request.Cookies["ClientTime"];  
42:                 if (httpCookie != null)  
43:                 {  
44:                     CultureInfo provider = CultureInfo.InvariantCulture;  
45:                     string format = "dd/MM/yyyy HH:mm:ss";  
46:                     string date = httpCookie.Value;  
47:                     date=date.Replace("%20", " ");  
48:                     date = date.Replace("%3A", ":");  
49:                     DateTime dt = DateTime.ParseExact(date, format, provider);  
50:                     ClientTime = Convert.ToDateTime(dt);  
51:                 }  
52:             }  
53:         }  
54:   
55:         protected void QuestionLogRepeater_ItemDataBound(Object Sender, RepeaterItemEventArgs e)  
56:         {  
57:             DateTime CalculatedClientTime;  
58:             if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)  
59:             {  
60:                 HiddenField IsUserGuest = (HiddenField)e.Item.FindControl("HiddenIsUserGuest");  
61:                 HiddenField HiddenQuestionNumber = (HiddenField)e.Item.FindControl("HiddenQuestionNumber");  
62:                 HiddenField HiddenQuestionID = (HiddenField)e.Item.FindControl("HiddenQuestionID");  
63:                 Label lblQuestionDateTime = (Label)e.Item.FindControl("lblQuestionDateTime");  
64:                 Label lblAnswer = (Label)e.Item.FindControl("lblAnswer");  
65:                 Label lblLocation = (Label)e.Item.FindControl("lblLocation");  
66:                 Label lblQuestion = (Label)e.Item.FindControl("lblQuestion");  
67:   
68:                   
69:   
70:                 int totalMinutesToAdd = (MinutesToGMT*-1) + (6*60);  
71:                 CalculatedClientTime = Convert.ToDateTime(lblQuestionDateTime.Text).AddMinutes(totalMinutesToAdd);  
72:                 lblQuestionDateTime.Text = ClientTime.IsDaylightSavingTime() ? CalculatedClientTime.AddHours(2).ToString(): CalculatedClientTime.AddHours(1).ToString();  
73:   
74:                 if (((UserWeb)Session["userWeb"]).UserName == "??????????????????????")  
75:                     lblQuestion.Text = "<a href='Question.aspx?QuestionID=" + HiddenQuestionID.Value + "' target='_blank' style='font-weight: bold;color: white;font-size: 12pt;'>" + HiddenQuestionNumber.Value + "</a> - " + lblQuestion.Text;  
76:                 else  
77:                     lblQuestion.Text = "<a href='Question.aspx?QuestionID=" + Crypto.Encrypt(HiddenQuestionID.Value, new Crypto()) + "' target='_blank' style='font-weight: bold;color: white;font-size: 12pt;'>" + HiddenQuestionNumber.Value + "</a> - " + lblQuestion.Text;  
78:   
79:                 lblLocation.Text = UserLocation.TidyUpLocation(lblLocation.Text);  
80:                 if(IsUserGuest!=null && Convert.ToBoolean(IsUserGuest.Value)==false)  
81:                 {  
82:                     lblLocation.Text += " *";  
83:                 }  
84:   
85:   
86:                 HiddenField hiddenLink = (HiddenField)e.Item.FindControl("hiddenLink");  
87:                 if(!string.IsNullOrEmpty(hiddenLink.Value))  
88:                 {  
89:                     lblAnswer.Text += string.Empty + @"<a href='" + hiddenLink.Value + @"' target='popup' onClick=""wopen('" + hiddenLink.Value + @"', 'popup'); return false;""><img src='Images/QuestionMark.png' align='right' border='0' title='View external explanation'></a>";  
90:                 }  
91:             }  
92:         }  
93:   
94:         public void LoadData()  
95:         {  
96:             QuestionLog questionLog=new QuestionLog();  
97:             QuestionLogRepeater.DataSource = questionLog.Load(NumberOfRecords, new SqlWrapper());  
98:             QuestionLogRepeater.DataBind();  
99:         }  
100:     }  
101: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.