284 lines
7.2 KiB
C#
284 lines
7.2 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 RoleEmp : PageBase
|
|||
|
{
|
|||
|
private LRoleAuthority _logic;
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
_logic = new LRoleAuthority();
|
|||
|
Databound();
|
|||
|
bindRoles();
|
|||
|
bindDeptEmp(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫʱ<C9AB><CAB1>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>
|
|||
|
}
|
|||
|
SessionSeting();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// bound the query list.
|
|||
|
/// </summary>
|
|||
|
private void Databound()
|
|||
|
{
|
|||
|
// bindAuth();
|
|||
|
// bindRoles();
|
|||
|
// if (!isRoleAuth) bindDeptEmp(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫʱ<C9AB><CAB1>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>
|
|||
|
bindGV();
|
|||
|
UpdateSession();
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><EFBFBD><F3B6A8B2>ż<EFBFBD><C5BC>û<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private void bindDeptEmp()
|
|||
|
{
|
|||
|
TreeDeptEmp.Nodes.Clear();
|
|||
|
BindTree("0", TreeDeptEmp.SelectedNode, new LEmployee().GetDepartments().DefaultView, new LEmployee().GetActivedEmpDept().DefaultView);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
///<2F><EFBFBD>ɫ
|
|||
|
/// </summary>
|
|||
|
private void bindRoles()
|
|||
|
{
|
|||
|
|
|||
|
listRoles.DataSource = _logic.GetAllRoles();
|
|||
|
listRoles.DataTextField = "role_name";
|
|||
|
listRoles.DataValueField = "ID";
|
|||
|
listRoles.DataBind();
|
|||
|
}
|
|||
|
|
|||
|
public void BindTree(string id, TreeNode pNode, DataView deptdv,DataView empdv)
|
|||
|
{
|
|||
|
|
|||
|
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
|||
|
foreach (DataRowView row in deptdv)
|
|||
|
{
|
|||
|
TreeNode node = new TreeNode();
|
|||
|
node.Text = "<em>" + row["dep_name"] + "</em>" +" "+ row["ID"];
|
|||
|
node.Value = row["ID"].ToString();
|
|||
|
node.SelectAction = TreeNodeSelectAction.None;
|
|||
|
node.ShowCheckBox = false;
|
|||
|
node.Expanded = true;
|
|||
|
empdv.RowFilter = "de_dept=" + node.Value;
|
|||
|
foreach (DataRowView emrow in empdv)
|
|||
|
{
|
|||
|
TreeNode tnEmp = new TreeNode("<Strong>" + emrow["em_name"] + "</Strong>" ,
|
|||
|
emrow["DE_EMPLOYEE"].ToString() + ";" + emrow["WAREHOUSE"].ToString());
|
|||
|
node.ChildNodes.Add(tnEmp);
|
|||
|
}
|
|||
|
if (pNode == null)
|
|||
|
//˵<><CBB5><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
TreeDeptEmp.Nodes.Add(node);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
pNode.ChildNodes.Add(node);
|
|||
|
|
|||
|
}
|
|||
|
BindTree(node.Value, node, new DataView(deptdv.Table), new DataView(empdv.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(TreeDeptEmp.Nodes, al);
|
|||
|
_logic.Initialize();
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
using (TransactionScope trans = new TransactionScope())
|
|||
|
{
|
|||
|
int roleId = Convert.ToInt32(listRoles.SelectedValue);
|
|||
|
_logic.GetRoleEmp.Delete(roleId);
|
|||
|
|
|||
|
foreach (string id in al)
|
|||
|
{
|
|||
|
string[] ls= id.Split(';');
|
|||
|
_logic.GetRoleEmp.re_role = roleId;
|
|||
|
_logic.GetRoleEmp.re_employee = Convert.ToInt32(ls[0]) ;
|
|||
|
if (ls.Length > 1)
|
|||
|
{
|
|||
|
_logic.GetRoleEmp.warehouse = Convert.ToInt32(ls[1]);
|
|||
|
}
|
|||
|
_logic.GetRoleEmp.Add();
|
|||
|
}
|
|||
|
|
|||
|
trans.Complete();
|
|||
|
}
|
|||
|
lbmsg.Text = "<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>";
|
|||
|
}
|
|||
|
catch (MyException)
|
|||
|
{
|
|||
|
throw;
|
|||
|
}
|
|||
|
catch (Exception er)
|
|||
|
{
|
|||
|
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);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** 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)
|
|||
|
{
|
|||
|
string[] ls = node.Value.Split(';');
|
|||
|
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(ls[0]));
|
|||
|
|
|||
|
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private void chgOperTxt(bool addNew)
|
|||
|
{
|
|||
|
|
|||
|
btnSubmit.Enabled = true;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
protected void listRoles_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
//--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
/*
|
|||
|
if (TreeDeptEmp.SelectedNode != null) TreeDeptEmp.SelectedNode.Selected = false;
|
|||
|
|
|||
|
lbAuthRole.Text = "<22><>Ա<EFBFBD><D4B1>ɫ<EFBFBD>嵥";
|
|||
|
GvRole.DataSource = null;
|
|||
|
GvRole.DataBind();
|
|||
|
* */
|
|||
|
//--ѡ<><D1A1><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|||
|
|
|||
|
ArrayList empList = new ArrayList();
|
|||
|
DataTable dt =_logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue)) ;
|
|||
|
foreach (DataRow dr in dt.Rows)
|
|||
|
{
|
|||
|
empList.Add(dr["ID"]);
|
|||
|
}
|
|||
|
SetCheckedNode(TreeDeptEmp.Nodes, empList);
|
|||
|
|
|||
|
bindGV();
|
|||
|
|
|||
|
}
|
|||
|
protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
bindGV();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void bindGV( )
|
|||
|
{
|
|||
|
//<2F><>Ա<EFBFBD><D4B1>ɫ<EFBFBD><C9AB>Ȩ<EFBFBD><C8A8><EFBFBD>嵥
|
|||
|
string nodevalue = TreeDeptEmp.SelectedValue;
|
|||
|
nodevalue = nodevalue.Split(';')[0];
|
|||
|
if (nodevalue.Length >0 && nodevalue != "0") //selected node is an employee
|
|||
|
{
|
|||
|
|
|||
|
lbEmRole.Text = TreeDeptEmp.SelectedNode.Text;// +" <20><>Ա<EFBFBD><D4B1>ɫ<EFBFBD>嵥";
|
|||
|
GvRole.DataSource = _logic.GetRoleByEm(Convert.ToInt32(nodevalue));
|
|||
|
|
|||
|
lbEmAuth.Text = TreeDeptEmp.SelectedNode.Text;// +" <20><>ԱȨ<D4B1><C8A8><EFBFBD>嵥";
|
|||
|
GVauth.DataSource = _logic.GetAuthByEm(Convert.ToInt32(nodevalue));
|
|||
|
|
|||
|
}
|
|||
|
GvRole.DataBind();
|
|||
|
GVauth.DataBind();
|
|||
|
|
|||
|
//<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();
|
|||
|
}
|
|||
|
|
|||
|
}
|