示例#1
0
        private void Page_Load(object sender, EventArgs e)
        {
            ArrayList tids = new ArrayList();
            BaseDb    db   = DbFactory.ConstructDatabase();

            if (now)
            {
                int[] nowtids = db.GetNowTids();
                foreach (int tid in nowtids)
                {
                    tids.Add(tid);
                }
            }
            if (old)
            {
                int[] oldtids = db.GetOldTids();
                foreach (int tid in oldtids)
                {
                    tids.Add(tid);
                }
            }
            if (future)
            {
                int[] futuretids = db.GetFutureTids();
                foreach (int tid in futuretids)
                {
                    tids.Add(tid);
                }
            }

            Contest t;
            string  str = "";

            foreach (int tid in tids)
            {
                if (!IsPostBack)
                {
                    t = db.GetContest(tid);
                    selContests.Items.Add(new ListItem(t.Name, tid.ToString()));
                }
                foreach (Problem p in db.GetProblems(tid))
                {
                    str += "new Problem(\"Задача " + p.ShortName + ". " + p.Name + "\"," + p.PID + "," + tid + "),";
                }
            }
            db.Close();

            Page.RegisterArrayDeclaration("arr", (str.Length != 0) ? str.Substring(0, str.Length - 1) : str);
            Page.RegisterArrayDeclaration("hi", ctrlsl2hide);

            if (!Page.IsStartupScriptRegistered("Startup"))
            {
                Page.RegisterStartupScript("Startup", "<script>Init()</script>");
            }
        }
示例#2
0
        private void Page_Init(object sender, EventArgs e)
        {
            noSuchProb.Visible = false;
            if (!Page.IsPostBack)
            {
                BaseDb db = DbFactory.ConstructDatabase();
                if (!BaseDb.IsJudge(Page.User))
                {
                    userTd.Visible = false;
                }
                else
                {
                    userDropDownList.Items.Add(new ListItem("--Ыўсющ--", "0"));
                    foreach (User u in db.GetUsers())
                    {
                        userDropDownList.Items.Add(new ListItem(u.Fullname,
                                                                db.GetUid(u.Username).ToString()));
                    }
                }

                snameDropDownList.Items.Add(new ListItem("--Ыўсрџ--", "ALL"));
                for (char c = 'A'; c <= 'Z'; c++)
                {
                    snameDropDownList.Items.Add(new ListItem(c.ToString(), c.ToString()));
                }

                int[]   old_tids = db.GetOldTids();
                int[]   now_tids = db.GetNowTids();
                Contest t        = null;
                for (int i = 0; i < old_tids.Length; i++)
                {
                    t = db.GetContest(old_tids[i]);
                    contestDropDownList.Items.Add(new ListItem(t.Name, old_tids[i].ToString()));
                }
                for (int i = 0; i < now_tids.Length; i++)
                {
                    t = db.GetContest(now_tids[i]);
                    contestDropDownList.Items.Add(new ListItem(t.Name, now_tids[i].ToString()));
                }

                resultDropDownList.Items.Add(new ListItem("--Ыўсющ--", "ALL"));
                foreach (Result r in Enum.GetValues(typeof(Result)))
                {
                    SubmissionResult res = new SubmissionResult(r);
                    resultDropDownList.Items.Add(new ListItem(res.ToString(), r.ToString()));
                }
                userDropDownList.SelectedIndex        = resultDropDownList.SelectedIndex =
                    contestDropDownList.SelectedIndex = snameDropDownList.SelectedIndex = 0;
            }
        }
示例#3
0
 private void Page_Init(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BaseDb  db = DbFactory.ConstructDatabase();
         Contest t;
         if (now)
         {
             int[] nowtids = db.GetNowTids();
             for (int i = 0; i < nowtids.Length; i++)
             {
                 t = db.GetContest(nowtids[i]);
                 tidDropDownList.Items.Add(new ListItem(t.Name, nowtids[i].ToString()));
             }
         }
         if (old)
         {
             int[] oldtids = db.GetOldTids();
             for (int i = 0; i < oldtids.Length; i++)
             {
                 t = db.GetContest(oldtids[i]);
                 tidDropDownList.Items.Add(new ListItem(t.Name, oldtids[i].ToString()));
             }
         }
         if (future)
         {
             int[] futuretids = db.GetFutureTids();
             for (int i = 0; i < futuretids.Length; i++)
             {
                 t = db.GetContest(futuretids[i]);
                 tidDropDownList.Items.Add(new ListItem(t.Name, futuretids[i].ToString()));
             }
         }
         db.Close();
     }
 }
示例#4
0
        private void Bind()
        {
            DataTable dt = new DataTable("Соревнования");

            dt.Columns.Add("TID");
            dt.Columns.Add("Name");
            dt.Columns.Add("Monitor");
            dt.Columns.Add("Beginning", typeof(DateTime));
            dt.Columns.Add("Ending", typeof(DateTime));
            dt.Columns.Add("Status");
            DataRow dr;
            Contest t;

            using (BaseDb db = DbFactory.ConstructDatabase())
            {
                int[] oldtids = db.GetOldTids();
                int[] nowtids = db.GetNowTids();
                int[] futtids = db.GetFutureTids();

                foreach (int tid in nowtids)
                {
                    t     = db.GetContest(tid);
                    dr    = dt.NewRow();
                    dr[0] = tid;
                    if (t.Future && !BaseDb.IsAdmin(Page.User))
                    {
                        dr[1] = t.Name;
                    }
                    else
                    {
                        dr[1] = "<a href='contest.aspx?tid=" + tid + "'>" + t.Name + "</a>";
                    }
                    if (!t.Future || BaseDb.IsAdmin(Page.User))
                    {
                        dr[2] = "<a href='monitor.aspx?tid=" + tid + "'>Ссылка</a>";
                    }
                    dr[3] = t.Beginning;
                    dr[4] = t.Ending;
                    dr[5] = "Идет";
                    dt.Rows.Add(dr);
                }
                foreach (int tid in futtids)
                {
                    t     = db.GetContest(tid);
                    dr    = dt.NewRow();
                    dr[0] = tid;
                    if (t.Future && !BaseDb.IsAdmin(Page.User))
                    {
                        dr[1] = t.Name;
                    }
                    else
                    {
                        dr[1] = "<a href='contest.aspx?tid=" + tid + "'>" + t.Name + "</a>";
                    }
                    if (!t.Future || BaseDb.IsAdmin(Page.User))
                    {
                        dr[2] = "<a href='monitor.aspx?tid=" + tid + "'>Ссылка</a>";
                    }
                    dr[3] = t.Beginning;
                    dr[4] = t.Ending;
                    dr[5] = "Ещё не начиналось ( начнется через " + HtmlFunctions.BeautifyTimeSpan(db.GetContest(tid).Beginning - DateTime.Now, false) + " )";
                    dt.Rows.Add(dr);
                }
                foreach (int tid in oldtids)
                {
                    t     = db.GetContest(tid);
                    dr    = dt.NewRow();
                    dr[0] = tid;
                    if (t.Future && !BaseDb.IsAdmin(Page.User))
                    {
                        dr[1] = t.Name;
                    }
                    else
                    {
                        dr[1] = "<a href='contest.aspx?tid=" + tid + "'>" + t.Name + "</a>";
                    }
                    if (!t.Future || BaseDb.IsAdmin(Page.User))
                    {
                        dr[2] = "<a href='monitor.aspx?tid=" + tid + "'>Ссылка</a>";
                    }
                    dr[3] = t.Beginning;
                    dr[4] = t.Ending;
                    dr[5] = "Закончилось";
                    dt.Rows.Add(dr);
                }
            }
            DataGrid1.DataSource = dt;
            DataGrid1.DataBind();
        }