Ejemplo n.º 1
0
 private void initFuncMode()
 {
     FMode = getMode();
     HELPER.CWebPage.ResetPanel(pnEdit);
     if (FMode == CGlobal.FunctionMode.AddMode || FMode == CGlobal.FunctionMode.EditMode)
     {
         pnMain.Visible = false;
         pnEdit.Visible = true;
         if (FMode == CGlobal.FunctionMode.EditMode)
         {
             DataTable dt = objUser.LoadByID(getHdf(hdfID));
             HELPER.CWebPage.BindPanel(pnEdit, dt);
             txtUserName.ReadOnly = true;
             trPass.Visible       = false;
             trPassAgain.Visible  = false;
         }
         else //AddMode
         {
             txtUserName.ReadOnly = false;
             trPass.Visible       = true;
             trPassAgain.Visible  = true;
         }
     }
     else if (FMode == CGlobal.FunctionMode.CloseMode || FMode == CGlobal.FunctionMode.SearchMode)
     {
         pnMain.Visible = true;
         pnEdit.Visible = false;
         Response.Redirect(Request.RawUrl);
     }
 }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            if (!string.IsNullOrWhiteSpace(txtPassword.Text))
            {
                if (txtPassword.Text != txtPasswordAgain.Text)
                {
                    HELPER.Client.Alert(this, "Mật khẩu không trùng khớp!");
                    return;
                }
            }

            objUser = new BUS.BUS_Users(dao);
            try
            {
                HELPER.CWebPage.BindProperty(objUser, pnEdit);

                FMode = getMode();
                dao.BeginTransaction();

                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    objUser.Password = txtPassword.Text;
                    objUser.InsertByAdmin();
                }
                else if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    objUser.Id = getHdf(hdfID);
                    objUser.UpdateByAdmin();
                }


                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());
                }
            }
        }
Ejemplo n.º 3
0
        private void initFuncMode()
        {
            FMode = getMode();
            HELPER.CWebPage.ResetPanel(pnEdit);
            if (FMode == CGlobal.FunctionMode.AddMode || FMode == CGlobal.FunctionMode.EditMode)
            {
                pnMain.Visible = false;
                pnEdit.Visible = true;
                if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    long      id = getHdf(hdfID);
                    DataTable dt = objContest.LoadByID(id);

                    HELPER.CWebPage.BindPanel(pnEdit, dt);
                    try
                    {
                        if (!string.IsNullOrEmpty(CGlobal.getDataByColumn(id, "StartTime", "Contests")))
                        {
                            DateTime start = DateTime.Parse(CGlobal.getDataByColumn(id, "StartTime", "Contests"));
                            DateTime end   = DateTime.Parse(CGlobal.getDataByColumn(id, "EndTime", "Contests"));
                            txtStartTime.Value = start;
                            dteStartTime.Value = start;
                            txtEndTime.Value   = end;
                            dteEndTime.Value   = end;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                else //AddMode
                {
                    chkIsVisible.Checked = true;
                }
                objProb.LoadToCheckList(cblProblems);
            }
            else if (FMode == CGlobal.FunctionMode.CloseMode || FMode == CGlobal.FunctionMode.SearchMode)
            {
                pnMain.Visible = true;
                pnEdit.Visible = false;
                Response.Redirect(Request.RawUrl);
            }
        }
Ejemplo n.º 4
0
        private void initFuncMode()
        {
            FMode = getMode();
            HELPER.CWebPage.ResetPanel(pnEdit);
            if (FMode == CGlobal.FunctionMode.AddMode || FMode == CGlobal.FunctionMode.EditMode)
            {
                pnMain.Visible = false;
                pnEdit.Visible = true;
                validateInitTableTestCase();
                initTableTestCase();

                if (FMode == CGlobal.FunctionMode.EditMode)
                {
                    btnEditTestCases.Visible = true;
                    DataTable dt = obj.LoadByID(getHdf(hdfID));
                    HELPER.CWebPage.BindPanel(pnEdit, dt);
                    try
                    {
                        ASPxRichEdit1.Open(
                            Server.MapPath(CConstant.C_WORK_DIRECTORY_PROBLEMS + txtURL_Content.Text)
                            );
                    }
                    catch (Exception)
                    {
                        HELPER.Client.Alert(this, "Không tìm thấy file nội dung!");
                    }
                }
                else // add mode
                {
                    btnEditTestCases.Visible = false;
                }
            }
            else if (FMode == CGlobal.FunctionMode.CloseMode || FMode == CGlobal.FunctionMode.SearchMode)
            {
                //pnMain.Visible = true;
                //pnEdit.Visible = false;
                //pnTestCase.Visible = false;
                Response.Redirect(Request.RawUrl);
            }
        }
Ejemplo n.º 5
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         HELPER.CWebPage.BindProperty(obj, pnEdit);
         string path = ASPxRichEdit1.DocumentId;
         obj.URL_Content = path.Substring(path.LastIndexOf("\\") + 1);
         FMode           = getMode();
         if (FMode == CGlobal.FunctionMode.AddMode)
         {
             setHdf(hdfID, obj.Insert());
             btnEditTestCases.Visible = true;
             pnTestCase.Visible       = true;
             validateInitTableTestCase();
             initTableTestCase();
             setMode(CGlobal.FunctionMode.EditMode);
         }
         else if (FMode == CGlobal.FunctionMode.EditMode)
         {
             obj.Id = getHdf(hdfID);
             obj.Update();
             setMode(CGlobal.FunctionMode.SearchMode);
             initFuncMode();
         }
     }
     catch (Exception ex)
     {
         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());
         }
     }
 }
Ejemplo n.º 6
0
 private void initFuncMode()
 {
     FMode = getMode();
     HELPER.CWebPage.ResetPanel(pnEdit);
     if (FMode == CGlobal.FunctionMode.AddMode || FMode == CGlobal.FunctionMode.EditMode)
     {
         pnMain.Visible = false;
         pnEdit.Visible = true;
         if (FMode == CGlobal.FunctionMode.EditMode)
         {
             //DataTable dt = objContest.LoadByID(getHdf(hdfID));
             // HELPER.CWebPage.BindPanel(pnEdit, dt);
         }
         else //AddMode
         {
         }
     }
     else if (FMode == CGlobal.FunctionMode.CloseMode || FMode == CGlobal.FunctionMode.SearchMode)
     {
         pnMain.Visible = true;
         pnEdit.Visible = false;
         //Response.Redirect(Request.RawUrl);
     }
 }
Ejemplo n.º 7
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());
                }
            }
        }
Ejemplo n.º 8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objNoti = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                dao.BeginTransaction();
                HELPER.CWebPage.BindProperty(objNoti, pnEdit);
                objNoti.NotiType = int.Parse(cboNotiType.Value.ToString());
                FMode            = getMode();

                long NotiID = 0;
                if (FMode == CGlobal.FunctionMode.AddMode)
                {
                    NotiID = objNoti.Insert();
                    setHdf(hdfID, NotiID);
                    objMyNoti.NotificationID = NotiID;
                    switch (objNoti.NotiType)
                    {
                    case 1:    //khoa hoc
                        foreach (ListEditItem item in cblContestID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.ContestID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    case 2:    //bt
                        foreach (ListEditItem item in cblProblemID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.ProblemID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    case 3:     // user
                        foreach (ListEditItem item in cblUserID.Items)
                        {
                            if (item.Selected)
                            {
                                objMyNoti.UserID = long.Parse(item.Value.ToString());
                                objMyNoti.Insert();
                            }
                        }
                        break;

                    default:
                        throw new Exception("Chọn loại thông báo!");
                        break;
                    }
                }


                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());
                }
            }
        }