コード例 #1
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());
                }
            }
        }
コード例 #2
0
        protected void grvData_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e)
        {
            long id = long.Parse(grvData.GetRowValues(e.VisibleIndex, grvData.KeyFieldName).ToString());

            if (e.ButtonID == "GridEdit")
            {
                setHdf(hdfID, id);
                setMode(CGlobal.FunctionMode.EditMode);
                initFuncMode();
            }
            else if (e.ButtonID == "GridDelete")
            {
                DatabaseDAO dao = new DatabaseDAO();
                objProblemsTestCase = new BUS.BUS_ProblemsTestCases(dao);
                obj = new BUS.BUS_Problems(dao);

                BUS.BUS_ProblemsInContest objProblemsInContest = new BUS.BUS_ProblemsInContest(dao);

                try
                {
                    dao.BeginTransaction();

                    objProblemsTestCase.ProblemId = id;
                    objProblemsTestCase.DeleteByProblemId();
                    objProblemsInContest.DeleteByProblem(id);

                    obj.Delete(id);

                    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.InUse)
                    {
                        HELPER.Client.Alert(this, "Dữ liệu đã được sử dụng. Không thể xóa được!");
                    }
                    else
                    {
                        HELPER.Client.Alert(this, "Lỗi xóa dữ liệu!");
                    }
                }
            }
        }
コード例 #3
0
        protected void btnSaveTestCase_Click(object sender, EventArgs e)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objProblemsTestCase           = new BUS.BUS_ProblemsTestCases(dao);
            objProblemsTestCase.ProblemId = getHdf(hdfID);
            dao.BeginTransaction();

            long maxPoint = long.Parse(txtMaximumPoints.Text);

            try
            {
                long sumPoin = 0;
                objProblemsTestCase.DeleteByProblemId();
                for (int i = 1; i < tbTestCase.Rows.Count; i++)
                {
                    DevExpress.Web.ASPxCheckBox ckb = (DevExpress.Web.ASPxCheckBox)tbTestCase.Rows[i].Cells[0].Controls[0];
                    DevExpress.Web.ASPxSpinEdit spn = (DevExpress.Web.ASPxSpinEdit)tbTestCase.Rows[i].Cells[1].Controls[0];
                    if (ckb.Checked)
                    {
                        objProblemsTestCase.FileName = ckb.Text;
                        objProblemsTestCase.Point    = long.Parse(spn.Value.ToString());
                        objProblemsTestCase.Insert();
                        sumPoin += objProblemsTestCase.Point;
                    }
                }
                if (sumPoin != maxPoint)
                {
                    //dao.RollBack();
                    HELPER.Client.Alert(this, "Tổng điểm các bộ test (" + sumPoin + ") không bằng số điểm tối đa (" + maxPoint + ")!");
                }

                //HELPER.Client.Alert(this, "Soos bộ test: " + tbTestCase.Rows.Count);
                dao.EndTransaction();
                // initTableTestCase();
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.Client.Alert(this, "Lỗi cập nhật bộ test: " + ex.ToString());
            }
        }
コード例 #4
0
        void accept(List <Object> selectItemsID)
        {
            DatabaseDAO dao = new DatabaseDAO();

            objMyContest = new BUS.BUS_MyContest(dao);
            BUS.BUS_Notification   objNoti   = new BUS.BUS_Notification(dao);
            BUS.BUS_MyNotification objMyNoti = new BUS.BUS_MyNotification(dao);
            try
            {
                long acceptBy = CGlobal.GetUserID();

                if (selectItemsID.Count <= 0)
                {
                    HELPER.Client.Alert(this, "Bạn chưa chọn đơn nào!");
                }
                else
                {
                    dao.BeginTransaction();
                    long idNoti = objNoti.Insert(acceptBy, "Đã phê duyệt đơn xin vào khóa học của bạn", 3);
                    foreach (object selectItemId in selectItemsID)
                    {
                        string[] re          = selectItemId.ToString().Split('|');
                        long     idMyContest = long.Parse(re[0]);
                        long     userId      = long.Parse(re[1]);
                        objMyContest.UpdateAcepted(idMyContest, acceptBy);
                        objMyNoti.Insert(idNoti, userId);
                    }
                    dao.EndTransaction();

                    Response.Redirect(Request.RawUrl, false);
                }
            }
            catch (Exception ex)
            {
                dao.RollBack();
                HELPER.Client.Alert(this, "Lỗi cập nhật CSDL! " + ex.Message);
            }
        }
コード例 #5
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());
                }
            }
        }
コード例 #6
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());
                }
            }
        }