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!"); } } } }
void clickMulti(int clickType) { List <Object> selectItemsID = new List <object>(); selectItemsID = grvData.GetSelectedFieldValues(grvData.KeyFieldName); DatabaseDAO dao = new DatabaseDAO(); objUser = new BUS.BUS_Users(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 người dùng nào!"); } else { long idNoti = 0; switch (clickType) { case 1: // del , xóa break; case 2: // accept, kích hoạt idNoti = objNoti.Insert(acceptBy, "Đã kích hoạt tài khoản của bạn", 3); break; case 3: // un accept, bỏ kích hoạt break; case 4: // to Usertype 1, sinh viên idNoti = objNoti.Insert(acceptBy, "Đã chuyển tài khoản của bạn thành tài khoản Sinh Viên", 3); break; case 5: // to Usertype 2. Giáo viên idNoti = objNoti.Insert(acceptBy, "Đã chuyển tài khoản của bạn thành tài khoản Giáo Viên", 3); break; default: break; } foreach (object selectItemId in selectItemsID) { long userId = long.Parse(selectItemId.ToString()); switch (clickType) { case 1: // del , xóa objUser.Delete(userId); break; case 2: // accept, kích hoạt objUser.UpdateByAdminEnable(userId, 1); objMyNoti.Insert(idNoti, userId); break; case 3: // un accept, bỏ kích hoạt objUser.UpdateByAdminEnable(userId, 0); break; case 4: // to Usertype 1, sinh viên objUser.UpdateByAdminType(userId, 1); objMyNoti.Insert(idNoti, userId); break; case 5: // to Usertype 2. Giáo viên objUser.UpdateByAdminType(userId, 2); objMyNoti.Insert(idNoti, userId); break; default: break; } } Response.Redirect(Request.RawUrl, false); } } catch (Exception ex) { HELPER.Client.Alert(this, "Lỗi cập nhật CSDL! " + ex.Message); } }