using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Business = SuperMap.RealEstate.WorkFlow.Support.Business; namespace Personnel.WebSite.Modules.Process { public partial class UserRole : BasePage { Business.UserRole _UserRole = new Business.UserRole(); protected void Page_Load(object sender, EventArgs e) { //this.Master_SizeBox.ContentPlaceHolder_SideBar.Width = "50%"; //this.Master_SizeBox.ContentPlaceHolder_ToolBar.ContentPlaceHolder_Center.TextAlign // = Web.UI.SizeBoxMasterPages.TextAlign.Center; //this.Master_SizeBox.ContentPlaceHolder_Footer.ContentPlaceHolder_Center.TextAlign // = Web.UI.SizeBoxMasterPages.TextAlign.Center; if (IsPostBack) return; _UserRole.Open(); TreeViewBinding_RoleType(); _UserRole.Close(); this.FixTreeViewDoubleClick(MyTreeView, false); this.FixTreeViewNodeChecked(MyTreeView); } #region User_ID private int User_ID { get { return Request["ID"].ToDecryptInt32(); } } #endregion //绑定数据源 private void TreeViewBinding_RoleType() { MyTreeView.Nodes.Clear(); _UserRole.BindingTreeView_RoleType("-1", MyTreeView.Nodes, false); } protected void MyTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e) { _UserRole.Open(); _UserRole.BindingTreeView_RoleType(e.Node.Value, e.Node.ChildNodes, e.Node.Checked); _UserRole.Close(); } protected void ButtonSave_Click(object sender, EventArgs e) { try { _UserRole = new Business.UserRole(Transaction); SaveUserRole(MyTreeView.Nodes); this.Refresh("Dialog.PopDialogOpenerWindow(\"SupportUserRole\")"); this.Alert("授权成功!",5); //this.ClosePopDialog("SupportUserRole"); } catch (Exception ex) { this.Transaction.Rollback(); throw ex; } finally { //Transaction.Release(); } } private void SaveUserRole(TreeNodeCollection treeNodeCollection) { foreach (TreeNode _Node in treeNodeCollection) { if (!_Node.Checked) { _Node.Checked = false; continue; } if (_Node.ImageToolTip == "RoleType") { if (_Node.PopulateOnDemand) { _Node.PopulateOnDemand = false; _UserRole.BindingTreeView_RoleType(_Node.Value, _Node.ChildNodes, _Node.Checked); } SaveUserRole(_Node.ChildNodes); _Node.Checked = false; continue; } _UserRole.ResetProperty(); _UserRole.AddSearchParameter("User_ID", User_ID); _UserRole.AddSearchParameter("Role_ID", int.Parse(_Node.Value.Replace("Role|", ""))); //是否存在 if (!_UserRole.Search()) { _UserRole.ResetProperty(); _UserRole.User_ID = User_ID; _UserRole.Role_ID = int.Parse(_Node.Value.Replace("Role|", "")); _UserRole.Insert(); } _Node.Checked = false; } } } }