Exemple #1
0
 protected void cblProblems_PreRender(object sender, EventArgs e)
 {
     try
     {
         long           p_id      = long.Parse(txtId.Text.ToString());
         DataTable      dtChecked = objProbInContest.LoadByContestID(p_id);
         List <DataRow> list      = dtChecked.AsEnumerable().ToList();
         foreach (ListEditItem item in cblProblems.Items)
         {
             long id = long.Parse(item.Value.ToString());
             for (int i = 0; i < list.Count; i++)
             {
                 long selected = long.Parse(list[i].ItemArray[0].ToString());
                 if (id == selected)
                 {
                     item.Selected = true;
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objContest       = new BUS.BUS_Contests(dao);
            objProbInContest = new BUS.BUS_ProblemsInContest(dao);

            try
            {
                dao.BeginTransaction();
                HELPER.CWebPage.BindProperty(objContest, pnEdit);
                try
                {
                    //objContest.StartTime = objContest.StartTime.Date.AddMinutes(txtStartTime.DateTime.TimeOfDay.TotalMinutes);
                    //objContest.EndTime = objContest.EndTime.Date.AddMinutes(txtEndTime.DateTime.TimeOfDay.TotalMinutes);

                    if (txtIsLimitTime.Checked)
                    {
                        objContest.StartTime = dteStartTime.Date.AddMinutes(txtStartTime.DateTime.TimeOfDay.TotalMinutes);
                        objContest.EndTime   = dteEndTime.Date.AddMinutes(txtEndTime.DateTime.TimeOfDay.TotalMinutes);

                        if (objContest.StartTime > objContest.EndTime)
                        {
                            HELPER.Client.Alert(this, "Thời gian bắt đầu phải trước thời gian kết thúc!");
                            return;
                        }
                    }
                    else
                    {
                        objContest.StartTime = DateTime.MinValue;
                        objContest.EndTime   = DateTime.MinValue;
                    }
                }
                catch (Exception)
                {
                    objContest.StartTime = DateTime.MinValue;
                    objContest.EndTime   = DateTime.MinValue;
                }

                FMode = getMode();

                long id = 0;
                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    id = objContest.Insert();
                    setHdf(hdfID, id);
                    objProbInContest.ContestsId = id;
                }
                else if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    id            = getHdf(hdfID);
                    objContest.Id = id;
                    objProbInContest.ContestsId = id;

                    objContest.Update();
                    objProbInContest.DeleteByContest();
                }

                DataTable      dtChecked = objProbInContest.LoadByContestID(id);
                List <DataRow> list      = dtChecked.AsEnumerable().ToList();

                foreach (ListEditItem item in cblProblems.Items)
                {
                    if (item.Selected)
                    {
                        objProbInContest.ProblemsId = long.Parse(item.Value.ToString());
                        objProbInContest.Insert();
                    }
                }
                dao.EndTransaction();

                setMode(CGlobal.FunctionMode.SearchMode);
                initFuncMode();
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.CError.ErrorType err = HELPER.CError.Parse(ex.Message);
                if (err == CError.ErrorType.Duplicate)
                {
                    HELPER.Client.Alert(this, "Dữ liệu đã tồn tại!");
                }
                else
                {
                    HELPER.Client.Alert(this, "Lỗi cấp nhật CSDL!" + err.ToString());
                }
            }
        }