Exemple #1
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!");
                    }
                }
            }
        }