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") { try { objUser.Delete(id); setMode(CGlobal.FunctionMode.SearchMode); initFuncMode(); } catch (Exception ex) { 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!"); } } } }
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()); } } }
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!"); } } } }
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()); } } }
protected void grvContests_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e) { long id = long.Parse(grvContests.GetRowValues(e.VisibleIndex, grvContests.KeyFieldName).ToString()); if (e.ButtonID == "GridEdit") { setHdf(hdfID, id); setMode(CGlobal.FunctionMode.EditMode); if (!string.IsNullOrEmpty(CGlobal.getDataByColumn(id, "StartTime", "Contests"))) { txtIsLimitTime.Checked = true; txtIsLimitTime_CheckedChanged(new object(), new EventArgs()); } initFuncMode(); } else if (e.ButtonID == "GridDelete") { try { objContest.Delete(id); setMode(CGlobal.FunctionMode.SearchMode); initFuncMode(); } catch (Exception ex) { 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!"); } } } }
protected void grvData_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridViewCustomButtonCallbackEventArgs e) { long myNotiID = long.Parse(grvData.GetRowValues(e.VisibleIndex, grvData.KeyFieldName).ToString()); if (e.ButtonID == "GridDelete") { try { objMyNoti.Delete(myNotiID); } catch (Exception ex) { 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!"); } } } }
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()); } } }
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()); } } }