protected void Page_Load(object sender, EventArgs e) { //Methods m = new Methods(); //m.CheckUserLoged(); if (!IsPostBack) { // fill data treeview var dsNhom = _entities.NhomQuyens; RadTreeViewNhomQuyen.DataSource = dsNhom; RadTreeViewNhomQuyen.DataBind(); var TreeData = from k in _entities.ChucNangs select k; RadTreeViewChucNang.DataFieldParentID = "IDParent"; RadTreeViewChucNang.DataTextField = "TenChucNang"; RadTreeViewChucNang.DataValueField = "IDChucNang"; RadTreeViewChucNang.DataSource = TreeData; RadTreeViewChucNang.DataBind(); cblQuyen.DataValueField = "IDQuyen"; cblQuyen.DataSource = _entities.Quyens; cblQuyen.DataBind(); //RadTreeView1.Nodes[0].Selected = true; //RadTreeNodeEventArgs tne = new RadTreeNodeEventArgs(RadTreeView1.Nodes[0]); //RadTreeView1_Nodeclick(sender, tne); RadTreeViewNhomQuyen.Nodes[0].Selected = true; RadTreeViewChucNang.Nodes[0].Selected = true; RadTreeNode treenode = RadTreeViewNhomQuyen.SelectedNode; RadTreeNodeEventArgs ne = new RadTreeNodeEventArgs(treenode); RadTreeViewNhomQuyen_Nodeclick(sender, ne); //fill ds user GridUserQuyen.DataSource = _entities.GetUserByIdNhomQuyen(Int32.Parse(RadTreeViewNhomQuyen.Nodes[0].Value)); GridUserQuyen.DataBind(); if (GridUserQuyen.Items.Count > 0) { GridUserQuyen.Items[0].Selected = true; GridDataItem item = GridUserQuyen.Items[0]; Session["idNvPq"] = Int32.Parse(item["IDNhanVien"].Text); } } }
protected void AjaxManager_Request(object sender, AjaxRequestEventArgs e) { switch (e.Argument) { case "removeUser": Int32 idNV = (Int32)Session["idNvPq"]; Int32 nhomQuyen = Int32.Parse(Session["nhomQuyen"].ToString()); var dt = _entities.NhanVien_NhomQuyen.Where(x => x.IDNhanVien == idNV && x.IDNhomQuyen == nhomQuyen).First(); _entities.NhanVien_NhomQuyen.DeleteObject(dt); _entities.SaveChanges(); GridUserQuyen.Rebind(); break; case "RebindGrid": GridUserQuyen.Rebind(); var dsNhom = _entities.NhomQuyens; RadTreeViewNhomQuyen.DataSource = dsNhom; RadTreeViewNhomQuyen.DataBind(); break; default: break; } }