161 lines
5.6 KiB
C#
161 lines
5.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using SuperMap.RealEstate.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Business = SuperMap.RealEstate.FrameWork.Business;
|
|
using HZQR.Common;
|
|
|
|
namespace Personnel.WebSite.Modules.Roles
|
|
{
|
|
public partial class RoleUserTree : BasePage
|
|
{
|
|
Business.UserRole _UserRole = null;
|
|
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
_UserRole = new Business.UserRole(Transaction);
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.Master_SizeBox.SideBar.Width = "45%";
|
|
if (IsPostBack)
|
|
return;
|
|
TreeViewBinding_UserType();
|
|
this.FixTreeViewDoubleClick(MyTreeView, false);
|
|
this.FixTreeViewDoubleClick(TreeViewUserRole, false);
|
|
this.FixTreeViewNodeChecked(MyTreeView);
|
|
this.FixTreeViewNodeChecked(TreeViewUserRole);
|
|
SetControlClientAction(ButtonRemove, false, true, true);
|
|
SetControlClientAction(ButtonSave, false, true, true);
|
|
SetControlClosePopDialog(buttonClose);
|
|
}
|
|
|
|
#region Role_ID
|
|
private int Role_ID
|
|
{
|
|
get
|
|
{
|
|
return Request["ID"].ToDecryptInt32();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
//绑定数据源
|
|
private void TreeViewBinding_UserType()
|
|
{
|
|
MyTreeView.Nodes.Clear();
|
|
BindingSystemTreeView(Transaction, MyTreeView.Nodes, Role_ID, -1, null, null, false);
|
|
//_UserRole.BindingTreeView_UserType("-1", MyTreeView.Nodes, false);
|
|
TreeViewBinding_RoleUser();
|
|
}
|
|
private void TreeViewBinding_RoleUser()
|
|
{
|
|
TreeViewUserRole.Nodes.Clear();
|
|
BindingTreeView_BusinessSystem(Transaction, TreeViewUserRole.Nodes, Role_ID, -1, null, null, false);
|
|
}
|
|
|
|
protected void MyTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e)
|
|
{
|
|
_UserRole.BindingTreeView_UserType(e.Node.Value, e.Node.ChildNodes, e.Node.Checked);
|
|
}
|
|
protected void ButtonSave_Click(object sender, EventArgs e)
|
|
{
|
|
_UserRole = new Business.UserRole(Transaction);
|
|
//_UserRolePopedom = new Business.UserRolePopedom(Transaction);
|
|
//SaveUserRole(MyTreeView.Nodes);
|
|
foreach (TreeNode _TreeNode in MyTreeView.CheckedNodes)
|
|
{
|
|
if (_TreeNode.ImageToolTip == "User")
|
|
{
|
|
_UserRole.ResetProperty();
|
|
_UserRole.User_ID = _TreeNode.Value.TryParseToInt();
|
|
_UserRole.Role_ID = Role_ID;
|
|
_UserRole.Insert();
|
|
}
|
|
}
|
|
|
|
TreeViewBinding_UserType();
|
|
}
|
|
|
|
private void SaveUserRole(TreeNodeCollection treeNodeCollection)
|
|
{
|
|
foreach (TreeNode _Node in treeNodeCollection)
|
|
{
|
|
if (!_Node.Checked)
|
|
{
|
|
_Node.Checked = false;
|
|
continue;
|
|
}
|
|
if (_Node.ImageToolTip == "UserType")
|
|
{
|
|
if (_Node.PopulateOnDemand)
|
|
{
|
|
_Node.PopulateOnDemand = false;
|
|
_UserRole.BindingTreeView_UserType(_Node.Value, _Node.ChildNodes, _Node.Checked);
|
|
}
|
|
SaveUserRole(_Node.ChildNodes);
|
|
_Node.Checked = false;
|
|
continue;
|
|
}
|
|
|
|
_UserRole.ResetProperty();
|
|
_UserRole.AddSearchParameter("Role_ID", Role_ID);
|
|
_UserRole.AddSearchParameter("User_ID", int.Parse(_Node.Value.Replace("User|", "")));
|
|
//是否存在
|
|
if (!_UserRole.Search())
|
|
{
|
|
_UserRole.ResetProperty();
|
|
_UserRole.Role_ID = Role_ID;
|
|
_UserRole.User_ID = int.Parse(_Node.Value.Replace("User|", ""));
|
|
_UserRole.Insert();
|
|
}
|
|
_Node.Checked = false;
|
|
}
|
|
}
|
|
protected void ButtonRemove_Click(object sender, EventArgs e)
|
|
{
|
|
_UserRole = new Business.UserRole(Transaction);
|
|
//_UserRolePopedom = new Business.UserRolePopedom(Transaction);
|
|
//DeleteUserRole(TreeViewUserRole.Nodes);
|
|
foreach (TreeNode _TreeNode in TreeViewUserRole.CheckedNodes)
|
|
{
|
|
if (_TreeNode.ImageToolTip == "User")
|
|
{
|
|
_UserRole.ResetProperty();
|
|
_UserRole.AddSearchParameter("User_ID", _TreeNode.Value.TryParseToInt());
|
|
_UserRole.AddSearchParameter("Role_ID", Role_ID);
|
|
if (_UserRole.Search())
|
|
{
|
|
_UserRole.Delete();
|
|
}
|
|
}
|
|
}
|
|
|
|
TreeViewBinding_UserType();
|
|
}
|
|
|
|
private void DeleteUserRole(TreeNodeCollection treeNodeCollection)
|
|
{
|
|
foreach (TreeNode _Node in treeNodeCollection)
|
|
{
|
|
if (_Node.ImageToolTip == "UserType")
|
|
{
|
|
DeleteUserRole(_Node.ChildNodes);
|
|
continue;
|
|
}
|
|
if (_Node.ImageToolTip == "UserRole")
|
|
{
|
|
if (!_Node.Checked)
|
|
{
|
|
_UserRole.ResetProperty();
|
|
_UserRole.Delete(int.Parse(_Node.Value));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|