176 lines
6.7 KiB
C#
176 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SuperMap.RealEstate.Web.Utility;
|
|
|
|
namespace SuperMap.RealEstate.Personnel.Modules.Statistics
|
|
{
|
|
public partial class ObjectTree : SuperMap.RealEstate.Web.UI.PageValid
|
|
{
|
|
private Storage.Business.DEPARTMENT _DEPARTMENT = null; public string DEPARTMENT_ID = "";
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack) return;
|
|
|
|
try
|
|
{
|
|
//this.FixTreeViewDoubleClick(MyTreeView, true);
|
|
SetControlClientAction(ButtonSearch);
|
|
TreeViewBinding(false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
}
|
|
}
|
|
|
|
private void TreeViewBinding(bool withChildNodes)
|
|
{
|
|
_DEPARTMENT = new Storage.Business.DEPARTMENT(this.Transaction);
|
|
MyTreeView.Nodes.Clear();
|
|
TreeNode treeNode = new TreeNode();
|
|
treeNode.Text = "全部";
|
|
MyTreeView.Nodes.AddAt(0, treeNode);
|
|
BindingTreeView("-1", treeNode.ChildNodes, this.TextBoxSearch.Text, false, "1234",
|
|
"StaffList.aspx", "", 0, "", false, false);
|
|
}
|
|
|
|
protected void MyTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e)
|
|
{
|
|
if (_DEPARTMENT == null)
|
|
_DEPARTMENT = new Storage.Business.DEPARTMENT(this.Transaction);
|
|
BindingTreeView(e.Node.Value, e.Node.ChildNodes, this.TextBoxSearch.Text, false, "1234",
|
|
"StaffList.aspx", "", 0, "", false, false);
|
|
}
|
|
|
|
#region BindingTreeView
|
|
public void BindingTreeView(string pid, TreeNodeCollection nodes, string obscureName, bool withChildNodes,
|
|
string ID_Encrypt, string NodeUrl = "", string NodeUrlParam = "", int Seller_ID = 0, string AUTOTYPE_TYPEID = "0",
|
|
bool ShowCheckBoxes = false, bool IsValid = false)
|
|
{
|
|
DataTable bindingDataSource = this.GetBindingDataSource(pid, string.Empty, IsValid, Seller_ID, AUTOTYPE_TYPEID);
|
|
for (int i = bindingDataSource.Rows.Count - 1; i >= 0; i--)
|
|
{
|
|
DataRow dataRow = bindingDataSource.Rows[i];
|
|
TreeNode treeNode = new TreeNode();
|
|
treeNode.Text = " " + dataRow["DEPARTMENT_NAME"].ToString();
|
|
//(dataRow["TYPE_STATE"].ToString() == "1" ? "有效" : "无效") + dataRow["TYPE_NAME"].ToString();
|
|
//if (NodeUrl != "")
|
|
//{
|
|
// treeNode.NavigateUrl = UriHelper.AddRequestToUrl(NodeUrl + "?ID=" +
|
|
// dataRow["DEPARTMENT_ID"].ToEncrypt() + NodeUrlParam, "Module_ID", ID_Encrypt);
|
|
//}
|
|
//else
|
|
//{
|
|
// treeNode.NavigateUrl = "javascript:void(0)";
|
|
//}
|
|
|
|
treeNode.Value = dataRow["DEPARTMENT_ID"].ToString();
|
|
treeNode.ImageToolTip = "DEPARTMENT_NAME";
|
|
treeNode.ImageUrl = "/Portal/Icons/16/Department.png";
|
|
treeNode.Expanded = true;
|
|
|
|
nodes.AddAt(0, treeNode);
|
|
treeNode.PopulateOnDemand = true;
|
|
|
|
//有查询,则查询所有
|
|
if (!string.IsNullOrEmpty(obscureName) || withChildNodes)
|
|
{
|
|
this.BindingTreeView(dataRow["DEPARTMENT_ID"].ToString(), treeNode.ChildNodes, obscureName, withChildNodes,
|
|
ID_Encrypt, NodeUrl, NodeUrlParam, Seller_ID, AUTOTYPE_TYPEID, ShowCheckBoxes, IsValid);
|
|
treeNode.PopulateOnDemand = false;
|
|
}
|
|
if (!string.IsNullOrEmpty(obscureName))
|
|
{
|
|
if (treeNode.ChildNodes.Count == 0)
|
|
{
|
|
if (treeNode.Text.IndexOf(obscureName, StringComparison.CurrentCultureIgnoreCase) < 0)
|
|
{
|
|
nodes.Remove(treeNode);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
treeNode.Expanded = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region GetBindingDataSource
|
|
/// <summary>
|
|
/// 从数据库中检索数据
|
|
/// </summary>
|
|
public DataTable GetBindingDataSource(string pid, string obscureName, bool JudgeValid = false,
|
|
int SELLER_ID = 0, string AUTOTYPE_TYPEID = "0")
|
|
{
|
|
string format = "select * from PERSONNEL_STORAGE.T_DEPARTMENT where {0} {1} order by DEPARTMENT_PID,TO_NUMBER(DEPARTMENT_INDEX)";
|
|
|
|
string arg = string.IsNullOrEmpty(pid) ? " 1=1 " : (" DEPARTMENT_PID = " + pid);
|
|
string arg2 = string.IsNullOrEmpty(obscureName) ? "" : ("and DEPARTMENT_NAME like '%" + obscureName + "%'");
|
|
string fullSQLString = string.Format(format, arg, arg2);
|
|
_DEPARTMENT = new Storage.Business.DEPARTMENT(this.Transaction);
|
|
return _DEPARTMENT.ExecuteDataTable(fullSQLString, null, 0, 0);
|
|
}
|
|
#endregion
|
|
|
|
protected void ButtonSearch_Click(object sender, EventArgs e)
|
|
{
|
|
TreeViewBinding(false);
|
|
}
|
|
|
|
protected void Expand_Click(object sender, EventArgs e)
|
|
{
|
|
if (Expand.Text == "收起↑")
|
|
{
|
|
foreach (TreeNode _TreeNode in MyTreeView.Nodes)
|
|
{
|
|
_TreeNode.Expanded = false;
|
|
}
|
|
Expand.Text = "展开↓";
|
|
}
|
|
else if (Expand.Text == "展开↓")
|
|
{
|
|
MyTreeView.ExpandAll();
|
|
Expand.Text = "收起↑";
|
|
}
|
|
}
|
|
|
|
protected void Sure_Click(object sender, EventArgs e)
|
|
{
|
|
Session["DEPARTMENT_ID"] = GetTreeNodeValue(MyTreeView.Nodes);
|
|
if (!string.IsNullOrEmpty(DEPARTMENT_ID))
|
|
{
|
|
Alert("选择成功!");
|
|
}
|
|
else
|
|
{
|
|
Alert("请选择要查询的部门!");
|
|
}
|
|
}
|
|
|
|
public string GetTreeNodeValue(TreeNodeCollection tn)
|
|
{
|
|
foreach (TreeNode _TreeNode in tn)
|
|
{
|
|
if (_TreeNode.Checked)
|
|
{
|
|
DEPARTMENT_ID += (string.IsNullOrEmpty(DEPARTMENT_ID) ? "" : ",") + _TreeNode.Value;
|
|
}
|
|
if (_TreeNode.ChildNodes != null)
|
|
{
|
|
GetTreeNodeValue(_TreeNode.ChildNodes);
|
|
}
|
|
}
|
|
return DEPARTMENT_ID;
|
|
}
|
|
}
|
|
} |