Esempio n. 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>");
            }
        }
Esempio n. 2
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();
     }
 }
Esempio n. 3
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();
        }