public void AccessGroupModule_Sua(int idModule, int idGroupUser, bool active) { admin_AccessGroupUserModule update = db.admin_AccessGroupUserModules.Where(x => x.module_id == idModule && x.groupuser_id == idGroupUser).FirstOrDefault(); update.gum_active = active; try { db.SubmitChanges(); } catch { } }
public void AccessGroupModule_Them(int idModule, int idGroupUser) { admin_AccessGroupUserModule insert = new admin_AccessGroupUserModule(); insert.groupuser_id = idGroupUser; insert.module_id = idModule; insert.gum_active = true; db.admin_AccessGroupUserModules.InsertOnSubmit(insert); try { db.SubmitChanges(); } catch { } }
protected void btnLuuM_Click(object sender, EventArgs e) { int _idGUser = Convert.ToInt32(grvGUser.GetRowValues(grvGUser.FocusedRowIndex, new string[] { "groupuser_id" })); //Lấy idModule string checkid = txtDanhSachChecked.Value; string[] getcheckid = checkid.Split(','); foreach (var item in getcheckid) { var checkGUM = from tb in db.admin_AccessGroupUserModules where tb.groupuser_id == _idGUser && tb.module_id == Convert.ToInt32(item) select tb; if (checkGUM.Count() > 0) { admin_AccessGroupUserModule update = checkGUM.FirstOrDefault(); if (update.gum_active == true) { update.gum_active = false; } else { update.gum_active = true; } } else { admin_AccessGroupUserModule insert = new admin_AccessGroupUserModule(); insert.groupuser_id = _idGUser; insert.module_id = Convert.ToInt32(item); insert.gum_active = true; db.admin_AccessGroupUserModules.InsertOnSubmit(insert); } try { db.SubmitChanges(); ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "swal('Cập nhật thành công','','success').then(function(){rptModule.Refresh();})", true); } catch { ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "swal('Cập nhật thất bại','','error')", true); } } txtDanhSachChecked.Value = ""; txtCountChecked.Value = "0"; }