using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SuperMap.RealEstate.Web.Utility;
using HWSB = SuperMap.RealEstate.HighWay.Storage.Business;
using SuperMap.RealEstate.CoreFrameWork.Dictionary.Business;
using SuperMap.RealEstate.CoreFrameWork;
namespace SuperMap.RealEstate.Personnel.Modules.Staff
{
public partial class ObjectTreeNew : BasePage
{
private Storage.Business.DEPARTMENT _DEPARTMENT = null;
private HWSB.SERVERPART _SERVERPART = null;
string FieldExplain_ID
{
get
{
FieldExplain _FieldExplain = new FieldExplain(this.Transaction);
_FieldExplain.AddSearchParameter("FieldExplain_Field", "DIVISION_CODE");
if (_FieldExplain.Search())
{
return _FieldExplain.FieldExplain_ID.ToString();
}
else
{
throw new Exception("未配置对应的服务区数据!");
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack) return;
try
{
ButtonAddType.OnClientClick = GetOpenPopDialogClientScript("StaffPageGs.aspx", "StaffPage", 950, 800, true, false, true);
ButtonBatchAdd.OnClientClick = GetOpenPopDialogClientScript("ImportStaff.aspx", "ImportStaff", 1200, 800, true, false, true);
this.FixTreeViewDoubleClick(MyTreeView, true);
SetControlClientAction(ButtonSearch);
TreeViewBinding(false);
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
private void TreeViewBinding(bool withChildNodes)
{
_SERVERPART = new HWSB.SERVERPART(this.Transaction);
string PartString = "";
string ProwerString = "";
foreach (string _str in PassportInfo.CityAuthority.Split(','))
{
PartString += PartString == string.Empty ? "'" + _str + "'" : ",'" + _str + "'";
}
foreach (FieldEnum _FieldEnum in (new FieldEnum(this.Transaction)).FillCollection("where FieldEnum_Value in(" + PartString + ")"))
{
ProwerString += ProwerString == "" ? _FieldEnum.FieldEnum_ID.ToString() : "," + _FieldEnum.FieldEnum_ID;
}
string serverPartWhere = " AND FIELDENUM_ID IN (" + ProwerString + ") AND STATISTICS_TYPE IN (1000,2000,1001)";
MyTreeView.Nodes.Clear();
if (string.IsNullOrWhiteSpace(PassportInfo.ProvinceCode))
{
DataTable UserTable = new FrameWork.Business.User(Transaction).ExecuteDataTable(
"SELECT USER_MOBILEPHONE,USER_PROVINCE,PROVINCE_UNIT FROM T_USER WHERE User_ID = " + PassportInfo.ID);
if (UserTable.Rows.Count > 0)
{
PassportInfo.UserMobilephone = UserTable.Rows[0]["USER_MOBILEPHONE"].ToString();
PassportInfo.ProvinceCode = UserTable.Rows[0]["USER_PROVINCE"].ToString();
}
}
TreeNode _Node = new TreeNode();
_Node.Text = "全部";
_Node.ImageToolTip = "FieldEnum";
_Node.ImageUrl = TreeNodeImageUrl.FieldEnum;
_Node.NavigateUrl = "StaffListGs.aspx";
MyTreeView.Nodes.Add(_Node);
if (!string.IsNullOrWhiteSpace(PassportInfo.ProvinceCode))
{
FieldEnum _FieldEnum = DictionaryHelper.GetFieldEnum("DIVISION_CODE", PassportInfo.ProvinceCode, Transaction);
BindingTreeView_Enum(FieldExplain_ID, _FieldEnum.FieldEnum_ID.ToString(), _Node.ChildNodes,
TextBoxSearch.Text, withChildNodes, "12", "", null, null, true, "StaffListGs.aspx", true, serverPartWhere,"");
}
else
{
BindingTreeView_Enum(FieldExplain_ID, (GoodsProvinceCode == "" ? "620000" : GoodsProvinceCode), _Node.ChildNodes,
TextBoxSearch.Text, withChildNodes, "12", "", null, null, true, "StaffListGs.aspx", true, serverPartWhere, "");
}
MyTreeView.ExpandAll();
}
protected void MyTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
if (_SERVERPART == null)
{
_SERVERPART = new HWSB.SERVERPART(this.Transaction);
}
string PartString = "";
string ProwerString = "";
foreach (string _str in PassportInfo.CityAuthority.Split(','))
{
PartString += PartString == string.Empty ? "'" + _str + "'" : ",'" + _str + "'";
}
foreach (FieldEnum _FieldEnum in (new FieldEnum(this.Transaction)).FillCollection("where FieldEnum_Value in(" + PartString + ")"))
{
ProwerString += ProwerString == "" ? _FieldEnum.FieldEnum_ID.ToString() : "," + _FieldEnum.FieldEnum_ID;
}
string serverPartWhere = " AND FIELDENUM_ID IN (" + ProwerString + ") AND STATISTICS_TYPE IN (1000,2000,1001)";
BindingTreeView_Enum(FieldExplain_ID, e.Node.Value, e.Node.ChildNodes,TextBoxSearch.Text,
true,"12", "", null, null, true, "StaffListGs.aspx", true, serverPartWhere,"");
}
protected void ButtonSearch_Click(object sender, EventArgs e)
{
TreeViewBinding(true);
}
protected void Expand_Click(object sender, EventArgs e)
{
if (Expand.Text == "收起↑")
{
//foreach (TreeNode _TreeNode in MyTreeView.Nodes)
//{
// _TreeNode.Expanded = false;
//}
MyTreeView.CollapseAll();
Expand.Text = "展开↓";
}
else if (Expand.Text == "展开↓")
{
MyTreeView.ExpandAll();
Expand.Text = "收起↑";
}
}
#region
///
/// 绑定服务区树(根据服务区枚举值进行绑定)
///
/// 服务区枚举类别内码
/// 父级内码
/// 树节点
/// 查询条件:服务区名称
/// 是否展示子节点
/// 是否加密显示节点值域
/// 加密内码参数
/// 其他查询条件
/// 服务区枚举列表
/// 服务区数据列表,用于判断对应枚举是否为服务区,跳转页面时可传递服务区参数
/// 跳转页面是否编辑服务区
/// 树节点跳转地址
/// 是否移除无服务区节点枚举值
/// 服务区查询条件
/// 树节点跳转参数
public void BindingTreeView_Enum(string Typeid, string Pid, TreeNodeCollection Nodes, string ObscureName, bool WithChildNodes,
string ID_Encrypt, string OtherCondition, DataTable _DataAll, DataTable ServerPartTable, bool EditType, string _NavigateUrl,
bool RemoveNoChild, string ServerPartWhereSQL, string OtherRequest)
{
string _ServerpartID = ""; //服务区内码
DataRow[] _DataRowList = null; //服务区枚举集合
_SERVERPART = new HWSB.SERVERPART(Transaction);
if (_DataAll == null)
{
//查询服务区枚举列表
_DataAll = GetBindingDataSource(Typeid, "", string.Empty, OtherCondition);
}
if (EditType && ServerPartTable == null)
{
//查询服务区列表
ServerPartTable = _SERVERPART.FillDataTable("WHERE 1 = 1 " + ServerPartWhereSQL);
}
_DataRowList = _DataAll.Select("FieldEnum_PID = " + Pid);
foreach (DataRow _DataRow in _DataRowList)
{
TreeNode _Node = new TreeNode();
_Node.Text = "【" + _DataRow["FieldEnum_Value"].ToString() + "】" + _DataRow["FieldEnum_Name"].ToString();
_Node.Value = _DataRow["FieldEnum_ID"].ToString();
_Node.ImageToolTip = "FieldEnum";
_Node.ImageUrl = TreeNodeImageUrl.FieldEnum;
_Node.Expanded = Pid == "-1" ? true : false;
_Node.SelectAction = TreeNodeSelectAction.None;
#region 获取服务区内码,用于树节点传递参数
if (ServerPartTable != null && ServerPartTable.Select("FIELDENUM_ID=" + _DataRow["FieldEnum_ID"].ToString()).Length > 0)
{
_ServerpartID = ServerPartTable.Select("FIELDENUM_ID=" + _DataRow["FieldEnum_ID"].ToString())[0]["SERVERPART_ID"].ToString();
_Node.Value = _ServerpartID;
_Node.ImageToolTip = "ServerPart";
_Node.ImageUrl = TreeNodeImageUrl.FieldEnum;
_Node.Expanded = false;
_Node.SelectAction = TreeNodeSelectAction.Expand;
}
else
{
_ServerpartID = "0";
}
#endregion
#region 绑定树节点跳转地址
_Node.NavigateUrl = _NavigateUrl + (_NavigateUrl.Contains("?") ? "&" : "?") + "SERVERPART_ID=" + _ServerpartID.ToEncrypt() + OtherRequest;
#endregion
Nodes.Add(_Node);
_Node.PopulateOnDemand = true;
if (!string.IsNullOrEmpty(ObscureName) || WithChildNodes)
{
//循环绑定子节点
BindingTreeView_Enum(Typeid, _DataRow["FieldEnum_ID"].ToString(), _Node.ChildNodes,
ObscureName, WithChildNodes, ID_Encrypt, OtherCondition, _DataAll, ServerPartTable,
EditType, _NavigateUrl, RemoveNoChild, ServerPartWhereSQL, OtherRequest);
_Node.PopulateOnDemand = false;
}
}
}
public DataTable GetBindingDataSource(string fieldExplain_ID, string pid, string obscureName,
string OtherCondition, string orderindex = " ASC")
{
FieldEnum _FieldEnum = new FieldEnum(this.Transaction);
string _SQLStr1 = "SELECT FIELDENUM_ID,FIELDENUM_VALUE,FIELDENUM_NAME,FIELDENUM_STATUS,FIELDENUM_PID" +
" FROM T_FIELDENUM A WHERE FIELDEXPLAIN_ID = {0} {1} {2} {3} ORDER BY FIELDENUM_PID,FIELDENUM_INDEX" + orderindex;
string _SQLStr2 = string.IsNullOrEmpty(pid) ? "" : "AND FIELDENUM_PID = " + pid;
string _SQLStr3 = string.IsNullOrEmpty(obscureName) ? "" : "AND FIELDENUM_NAME LIKE '%" + obscureName + "%'";
string _SQLStr4 = string.IsNullOrEmpty(OtherCondition) ? "" : "AND " + OtherCondition;
string _SQLStr = string.Format(_SQLStr1, fieldExplain_ID, _SQLStr2, _SQLStr3, _SQLStr4);
return _FieldEnum.ExecuteDataTable(_SQLStr);
}
#endregion
}
}