1 using System;
2 using
System.Collections;
3 using
System.Configuration;
4 using
System.Data;
5 using
System.Linq;
6 using
System.Web;
7 using
System.Web.Security;
8 using
System.Web.UI;
9 using
System.Web.UI.WebControls;
10 using
System.Web.UI.WebControls.WebParts;
11 using
System.Web.UI.HtmlControls;
12 using
System.Xml.Linq;
13
14 namespace
TestOnline.hy.vn
15 {
16     
public partial class thitructuyen : System.Web.UI.Page
17     {
18         
protected void Page_Load(object sender, EventArgs e)
19         {
20             
if (Session.Contents["login"].ToString() == "0")
21             {
22                 Response.Redirect(
"HomePage.aspx");
23             }
24             
else
25             {
26                 
if (!IsPostBack)
27                 {
28                     LinkButton1.Visible =
false;
29                     
string SubjectID = Request.QueryString["SubjectID"];
30                     loadngaythi(SubjectID);
31                 }
32             }
33         }
34         TestOnlineDataContext dc;
35         
void loadngaythi(string SubjectID)
36         {
37             dc =
new TestOnlineDataContext();
38             
string s="";
39             tblThread a = dc.tblThreads.SingleOrDefault(p => p.SubjectID == SubjectID && p.Status==
2);
40             
if (a == null)
41             {
42                  s =
"<div>Hiện tại không có cuộc thi trắc nghiệm online nào</div>";
43             }
44             
else
45             {
46                 DateTime t = DateTime.Now;
47                 DateTime t1 =Convert.ToDateTime(a.DateTest);
48                 DateTime t2 = t1.AddMinutes(
90);
49                 
int tmp = DateTime.Compare(t, t1);
50                 
int tmp2 = DateTime.Compare(t2, t);
51                     
if (tmp>=0)
52                     {
53                         
if (tmp2 == 1)
54                         {
55                             LinkButton1.Visible =
true;
56                             
string threadID = a.ThreadsID.ToString();
57                             s =
"<div>Nhấn nút Enter để vào thi </div>";
58                             LinkButton1.PostBackUrl =
"~/HomeTest.aspx?threadid=" + threadID;
59                         }
60                         
if (tmp2 <= 0)
61                         {
62                             s =
"<div>Qúa giờ thi</div>";
63                         }
64                     }
65                     
else
66                         s =
"<div>Chưa đến giờ thi </div>";
67             }
68             Label1.Text = s;
69         }
70     }
71 }



Quản lý website hổ trợ ôn thi trắc nghiệp ASP.net 21.761 lượt xem

Gõ tìm kiếm nhanh...