platform/Dict/.svn/text-base/RoleAuth.aspx.cs.svn-base

279 lines
6.7 KiB
Plaintext
Raw Normal View History

2024-02-18 23:33:54 +08:00
using System;
using System.Collections;
using System.Data;
using System.Transactions;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZhangPu.Gov.Logical;
using Tracen.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>
/// <20><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
/// </summary>
void bindAuth()
{
treeAuth.Nodes.Clear();
BindAuthTree("0", treeAuth.SelectedNode, _logic.QueryNonePublicAuthority().DefaultView);
}
/// <summary>
///<2F>󶨽<EFBFBD>ɫ
/// </summary>
private void bindRoles()
{
DataView dv = _logic.GetAllRoles().DefaultView;
dv.RowFilter = "role_4Approve =0";
listRoles.DataSource =dv;
listRoles.DataTextField = "role_name";
listRoles.DataValueField = "pk_role";
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();
node.Value = row["pk_authority"].ToString();
node.Expanded = true;
if (authLink == string.Empty || authLink.Trim().Length < 6) //not *.aspx
{
node.Text = "<strong>" + row["auth_name"] + "</strong>";
node.SelectAction = TreeNodeSelectAction.None;
node.ShowCheckBox = false;
} else
{
node.Text = row["auth_name"].ToString() ;
}
if (pNode == null)
//˵<><CBB5><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
{
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)
{
if (listRoles.SelectedValue == string.Empty) return;
//<2F><>ɫ<EFBFBD><C9AB>Ȩ<EFBFBD><C8A8>
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();
}
// trans.Complete();
}
catch (MyException)
{
throw;
}
catch (Exception)
{
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>");
}
}
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)
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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)
{
/*
if (treeAuth.SelectedNode != null) treeAuth.SelectedNode.Selected = false;
lbAuthRole.Text = "Ȩ<>޽<EFBFBD>ɫ<EFBFBD>嵥" ;
GvRole.DataSource = null;
GvRole.DataBind();
*/
//--<2D><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
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()
{
//<2F><>ɫ<EFBFBD><C9AB>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ա<EFBFBD>
if (listRoles.SelectedItem != null)
{
lbRoleEm.Text = listRoles.SelectedItem.Text + " <20><>ɫ<EFBFBD><C9AB>Ա<EFBFBD>嵥";
GvEm.DataSource = _logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue));
}
GvEm.DataBind();
//Ȩ<>޶<EFBFBD>Ӧ<EFBFBD>Ľ<EFBFBD>ɫ,<2C><>Ա<EFBFBD>
if (treeAuth.SelectedNode != null)
{
lbAuthEm.Text = treeAuth.SelectedNode.Text + " Ȩ<><C8A8><EFBFBD><EFBFBD>Ա<EFBFBD>嵥";
GvAuthEm.DataSource = _logic.GetEmListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
lbAuthRole.Text = treeAuth.SelectedNode.Text + " Ȩ<>޽<EFBFBD>ɫ<EFBFBD>嵥";
GvRole.DataSource = _logic.GetRoleListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
}
GvAuthEm.DataBind();
GvRole.DataBind();
}
}