309 lines
7.8 KiB
Plaintext
309 lines
7.8 KiB
Plaintext
|
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 DeptEmp : PageBase
|
|||
|
{
|
|||
|
private LEmployee _logic;
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
_logic = new LEmployee();
|
|||
|
|
|||
|
Databound();
|
|||
|
|
|||
|
//<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()
|
|||
|
{
|
|||
|
bindGV();
|
|||
|
UpdateSession();
|
|||
|
bindDept();
|
|||
|
bindDeptEmp();
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><EFBFBD><F3B6A8B2><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private void bindDept()
|
|||
|
{
|
|||
|
TreeDept.Nodes.Clear();
|
|||
|
BindTree(TreeDept, "0", TreeDept.SelectedNode, _logic.GetDepartments().DefaultView);
|
|||
|
SetTreeDeptChecked();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><EFBFBD><F3B6A8B2>ż<EFBFBD><C5BC>û<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private void bindDeptEmp()
|
|||
|
{
|
|||
|
TreeDeptEmp.Nodes.Clear();
|
|||
|
BindEmpTree(TreeDeptEmp, "0", TreeDeptEmp.SelectedNode, _logic.GetDepartments().DefaultView, _logic.GetActivedEmpDept().DefaultView);
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void BindEmpTree(TreeView tree, 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>" ;
|
|||
|
node.Value = row["pk_department"].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["pk_employee"].ToString());
|
|||
|
node.ChildNodes.Add(tnEmp);
|
|||
|
}
|
|||
|
if (pNode == null)
|
|||
|
//˵<><CBB5><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
tree.Nodes.Add(node);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
pNode.ChildNodes.Add(node);
|
|||
|
|
|||
|
}
|
|||
|
BindEmpTree(tree,node.Value, node, new DataView(deptdv.Table), new DataView(empdv.Table));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void BindTree(TreeView tree, string id, TreeNode pNode, DataView deptdv )
|
|||
|
{
|
|||
|
|
|||
|
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
|||
|
foreach (DataRowView row in deptdv)
|
|||
|
{
|
|||
|
TreeNode node = new TreeNode();
|
|||
|
node.Text = "<Strong>" + row["dep_name"].ToString() + "</Strong>";
|
|||
|
node.Value = row["pk_department"].ToString();
|
|||
|
node.SelectAction = TreeNodeSelectAction.None;
|
|||
|
node.ShowCheckBox = true;
|
|||
|
node.Expanded = true;
|
|||
|
|
|||
|
if (pNode == null)
|
|||
|
//˵<><CBB5><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
tree.Nodes.Add(node);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
pNode.ChildNodes.Add(node);
|
|||
|
|
|||
|
}
|
|||
|
BindTree(tree, node.Value, node, new DataView(deptdv.Table));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void SessionSeting()
|
|||
|
{
|
|||
|
if (IsPostBack)
|
|||
|
{
|
|||
|
_logic = (LEmployee)Session[appScope.PagelevelObj];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void UpdateSession()
|
|||
|
{
|
|||
|
Session[appScope.PagelevelObj] = _logic;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/************************************** protected methods (event listeners) ********************************/
|
|||
|
|
|||
|
|
|||
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (TreeDeptEmp.SelectedNode== null) return;
|
|||
|
ArrayList al = new ArrayList();
|
|||
|
|
|||
|
GetCheckedNode(TreeDept.Nodes, al);
|
|||
|
_logic.Initialize();
|
|||
|
// using (TransactionScope trans = new TransactionScope())
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
_logic.GetDeptEmp.Delete(Convert.ToInt32(TreeDeptEmp.SelectedValue));
|
|||
|
|
|||
|
foreach (string id in al)
|
|||
|
{
|
|||
|
_logic.GetDeptEmp.de_dept = Convert.ToInt32(id);
|
|||
|
_logic.GetDeptEmp.de_employee = Convert.ToInt32(TreeDeptEmp.SelectedValue);
|
|||
|
_logic.GetDeptEmp.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);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** 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;
|
|||
|
|
|||
|
}
|
|||
|
void SetTreeDeptChecked()
|
|||
|
{
|
|||
|
if( TreeDeptEmp.SelectedNode ==null) return;
|
|||
|
ArrayList deptList = new ArrayList();
|
|||
|
DataTable dt = _logic.GetDepartments(Convert.ToInt32(TreeDeptEmp.SelectedValue));
|
|||
|
foreach (DataRow dr in dt.Rows)
|
|||
|
{
|
|||
|
deptList.Add(dr["pk_department"]);
|
|||
|
}
|
|||
|
SetCheckedNode(TreeDept.Nodes, deptList);
|
|||
|
}
|
|||
|
|
|||
|
protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
GvDept.SelectedIndex = -1;
|
|||
|
SetTreeDeptChecked();
|
|||
|
bindGV();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void bindGV( )
|
|||
|
{
|
|||
|
//<2F><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>嵥
|
|||
|
string nodevalue = TreeDeptEmp.SelectedValue;
|
|||
|
if (nodevalue.Length >0 && nodevalue != "0") //selected node is an employee
|
|||
|
{
|
|||
|
|
|||
|
lbEmDept.Text = TreeDeptEmp.SelectedNode.Text + " <20><>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>嵥";
|
|||
|
GvDept.DataSource = _logic.GetDepartments(Convert.ToInt32(nodevalue));
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
GvDept.DataBind();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void GvDept_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
|||
|
{
|
|||
|
if (GvDept.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GvDept.DataKeys[e.RowIndex].Value.ToString();
|
|||
|
|
|||
|
_logic.GetDeptEmp.ID = Convert.ToInt32(id);
|
|||
|
_logic.GetDeptEmp.getModel();
|
|||
|
|
|||
|
_logic.GetDeptEmp.de_title = ((TextBox)GvDept.Rows[e.RowIndex].Cells[3].Controls[1]).Text;
|
|||
|
|
|||
|
//_logic.GetTrainingDetail.operater =
|
|||
|
_logic.GetDeptEmp.Update();
|
|||
|
}
|
|||
|
GvDept.EditIndex = -1;
|
|||
|
GvDept.SelectedIndex = e.RowIndex;
|
|||
|
bindGV();
|
|||
|
}
|
|||
|
protected void GvDept_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
|||
|
{
|
|||
|
GvDept.EditIndex = -1;
|
|||
|
GvDept.SelectedIndex = e.RowIndex;
|
|||
|
bindGV();
|
|||
|
}
|
|||
|
protected void GvDept_RowEditing(object sender, GridViewEditEventArgs e)
|
|||
|
{
|
|||
|
GvDept.EditIndex = e.NewEditIndex;
|
|||
|
GvDept.SelectedIndex = e.NewEditIndex;
|
|||
|
bindGV();
|
|||
|
}
|
|||
|
}
|