285 lines
7.0 KiB
C#
285 lines
7.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Data;
|
|
using System.Transactions;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using DeiNiu.wms.Logical;
|
|
using DeiNiu.Utils;
|
|
|
|
public partial class RoleAuth : PageBase
|
|
{
|
|
private LRoleAuthority _logic;
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
_logic = new LRoleAuthority();
|
|
Databound();
|
|
bindAuth();
|
|
bindRoles();
|
|
|
|
}
|
|
SessionSeting();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// bound the query list.
|
|
/// </summary>
|
|
private void Databound()
|
|
{
|
|
// bindAuth();
|
|
// bindRoles();
|
|
|
|
bindGV();
|
|
UpdateSession();
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// °ó¶¨È¨ÏÞ
|
|
/// </summary>
|
|
void bindAuth()
|
|
{
|
|
treeAuth.Nodes.Clear();
|
|
BindAuthTree("0", treeAuth.SelectedNode, _logic.QueryNonePublicAuthority().DefaultView);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///°ó¶¨½ÇÉ«
|
|
/// </summary>
|
|
private void bindRoles()
|
|
{
|
|
DataView dv = _logic.GetAllRoles().DefaultView;
|
|
dv.RowFilter = "role_4Approve =0";
|
|
listRoles.DataSource =dv;
|
|
listRoles.DataTextField = "role_name";
|
|
listRoles.DataValueField = "ID";
|
|
listRoles.DataBind();
|
|
}
|
|
|
|
|
|
|
|
public void BindAuthTree(string id, TreeNode pNode, DataView dv )
|
|
{
|
|
|
|
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
|
foreach (DataRowView row in dv)
|
|
{
|
|
TreeNode node = new TreeNode();
|
|
string authLink = row["auth_link"].ToString();
|
|
string authForm = row["auth_class"].ToString();
|
|
node.Value = row["ID"].ToString();
|
|
node.Expanded = true;
|
|
string authLevel = row["auth_uplevel"].ToString();
|
|
// if (authForm == string.Empty && (authLink == string.Empty || authLink.Trim().Length < 6)) //not *.aspx
|
|
if (authLevel.Equals("0"))
|
|
{
|
|
node.Text = "<strong>" + row["auth_name"] + "</strong>";
|
|
node.SelectAction = TreeNodeSelectAction.None;
|
|
// node.ShowCheckBox = false;
|
|
} else
|
|
|
|
{
|
|
node.Text = row["auth_name"].ToString() ;
|
|
|
|
}
|
|
|
|
|
|
if (pNode == null)
|
|
//˵Ã÷ÊǸù½Úµã
|
|
{
|
|
|
|
treeAuth.Nodes.Add(node);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
pNode.ChildNodes.Add(node);
|
|
|
|
}
|
|
BindAuthTree(node.Value, node, new DataView(dv.Table));
|
|
|
|
}
|
|
}
|
|
private void SessionSeting()
|
|
{
|
|
if (IsPostBack)
|
|
{
|
|
_logic = (LRoleAuthority)Session[appScope.PagelevelObj];
|
|
}
|
|
}
|
|
|
|
private void UpdateSession()
|
|
{
|
|
Session[appScope.PagelevelObj] = _logic;
|
|
}
|
|
|
|
|
|
/************************************** protected methods (event listeners) ********************************/
|
|
|
|
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
lbmsg.Text = " ";
|
|
if (listRoles.SelectedValue == string.Empty) return;
|
|
//½ÇÉ«£¬È¨ÏÞ
|
|
ArrayList al = new ArrayList();
|
|
GetCheckedNode(treeAuth.Nodes, al);
|
|
_logic.Initialize();
|
|
// using (TransactionScope trans = new TransactionScope())
|
|
{
|
|
try
|
|
{
|
|
|
|
_logic.GetRoleAuthority.Delete(Convert.ToInt32(listRoles.SelectedValue));
|
|
// _logic.Initialize();
|
|
foreach (string id in al)
|
|
{
|
|
_logic.GetRoleAuthority.ra_role = Convert.ToInt32(listRoles.SelectedValue);
|
|
_logic.GetRoleAuthority.ra_authority = Convert.ToInt32(id);
|
|
_logic.GetRoleAuthority.Add();
|
|
}
|
|
lbmsg.Text = "±£´æ³É¹¦£¡";
|
|
// trans.Complete();
|
|
}
|
|
catch (MyException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw new Exception("³öÏÖÒì³££¬±£´æÊ§°Ü¡£");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Databound();
|
|
}
|
|
|
|
|
|
//reset the page
|
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
_logic.Initialize();
|
|
Page_Load(this, e);
|
|
ClearDetail();
|
|
}
|
|
|
|
/***************************************** internal methods ********************************************/
|
|
|
|
/// <summary>
|
|
/// set data from page to shift object
|
|
/// </summary>
|
|
private void SetDataBack()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues)
|
|
{
|
|
foreach (TreeNode node in tnc)
|
|
{
|
|
if (node.Checked)
|
|
{
|
|
checkedvalues.Add(node.Value);
|
|
|
|
}
|
|
GetCheckedNode(node.ChildNodes, checkedvalues);
|
|
}
|
|
|
|
}
|
|
|
|
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
|
{
|
|
foreach (TreeNode node in tnc)
|
|
{
|
|
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(node.Value));
|
|
|
|
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
|
}
|
|
}
|
|
|
|
|
|
private void chgOperTxt(bool addNew)
|
|
{
|
|
|
|
btnSubmit.Enabled = true;
|
|
|
|
}
|
|
|
|
private void ClearDetail()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
protected void listRoles_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
lbmsg.Text = " ";
|
|
/*
|
|
if (treeAuth.SelectedNode != null) treeAuth.SelectedNode.Selected = false;
|
|
lbAuthRole.Text = "ȨÏÞ½ÇÉ«Çåµ¥" ;
|
|
GvRole.DataSource = null;
|
|
GvRole.DataBind();
|
|
*/
|
|
|
|
//--ÖØÖÃȨÏÞÊ÷µÄÑ¡Ôñ
|
|
ArrayList autList = new ArrayList();
|
|
DataView dv = _logic.GetRoleAuthority.QueryActived().Tables[0].DefaultView;
|
|
dv.RowFilter = "ra_role ='" + listRoles.SelectedValue + "'";
|
|
foreach (DataRowView drv in dv)
|
|
{
|
|
autList.Add(drv["ra_authority"]);
|
|
}
|
|
SetCheckedNode(treeAuth.Nodes, autList);
|
|
|
|
bindGV();
|
|
|
|
}
|
|
|
|
|
|
protected void treeAuth_SelectedNodeChanged(object sender, EventArgs e)
|
|
{
|
|
bindGV();
|
|
|
|
}
|
|
|
|
void bindGV()
|
|
{
|
|
//½ÇÉ«¶ÔÓ¦µÄÈËÔ±Çåµ¥
|
|
if (listRoles.SelectedItem != null)
|
|
{
|
|
|
|
lbRoleEm.Text = listRoles.SelectedItem.Text + " ½ÇÉ«ÈËÔ±Çåµ¥";
|
|
GvEm.DataSource = _logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue));
|
|
}
|
|
GvEm.DataBind();
|
|
|
|
|
|
//ȨÏÞ¶ÔÓ¦µÄ½ÇÉ«,ÈËÔ±Çåµ¥
|
|
if (treeAuth.SelectedNode != null)
|
|
{
|
|
lbAuthEm.Text = treeAuth.SelectedNode.Text + " ȨÏÞÈËÔ±Çåµ¥";
|
|
GvAuthEm.DataSource = _logic.GetEmListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
|
|
lbAuthRole.Text = treeAuth.SelectedNode.Text + " ȨÏÞ½ÇÉ«Çåµ¥";
|
|
GvRole.DataSource = _logic.GetRoleListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
|
|
|
|
}
|
|
GvAuthEm.DataBind();
|
|
GvRole.DataBind();
|
|
}
|
|
|
|
} |