190 lines
8.4 KiB
C#
190 lines
8.4 KiB
C#
using SuperMap.RealEstate.Web.UI.WebControls;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Business = SuperMap.RealEstate.WorkFlow.Support.Business;
|
|
|
|
namespace Personnel.WebSite.Modules.Process
|
|
{
|
|
public partial class UserPage : BasePage
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack)
|
|
return;
|
|
InitDataTable();
|
|
LiteralProDef.Text= GetProDefTypeString("-1","");
|
|
//LiteralRole.Text += GetRoleTypeString("-1");
|
|
}
|
|
|
|
#region User_ID
|
|
private int User_ID
|
|
{
|
|
get
|
|
{
|
|
return Request["ID"].ToDecryptInt32();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
DataTable DataTable_ProDefType;
|
|
DataTable DataTable_ProDef;
|
|
DataTable DataTable_Role;
|
|
DataTable DataTable_UserRole;
|
|
DataTable DataTable_RoleType;
|
|
Business.UserRole _Object;
|
|
private void InitDataTable()
|
|
{
|
|
_Object = new Business.UserRole(this.Transaction);
|
|
DataTable_ProDefType = _Object.ExecuteDataTable("select ProDefType_ID,ProDefType_Name,ProDefType_PID" +
|
|
" from T_ProDefType order by ProDefType_PID,ProDefType_Index,ProDefType_ID");
|
|
DataTable_RoleType = _Object.ExecuteDataTable("select RoleType_ID,RoleType_Name,RoleType_PID" +
|
|
" from T_RoleType order by RoleType_PID,RoleType_Index,RoleType_ID");
|
|
DataTable_ProDef = _Object.ExecuteDataTable("select ProDef_ID,ProDef_Name,ProDefType_ID" +
|
|
" from T_ProDef order by ProDef_Index,ProDef_ID");
|
|
DataTable_Role = _Object.ExecuteDataTable("Select Role_ID,Role_Name,ProDef_ID,RoleType_ID " +
|
|
"from T_Role order by Role_Index,ActDef_ID");
|
|
DataTable_UserRole =_Object.ExecuteDataTable("Select UserRole_ID,Role_ID "+
|
|
"from T_UserRole where User_ID=" + User_ID);
|
|
}
|
|
|
|
string GetRoleTypeString(string PID)
|
|
{
|
|
StringBuilder _StringBuilder = new StringBuilder();
|
|
DataRow[] _DataRowNodes = DataTable_RoleType.Select("RoleType_PID=" + PID);
|
|
foreach (DataRow _DataRow in _DataRowNodes)
|
|
{
|
|
_StringBuilder.Append(string.Format(_Container,
|
|
_DataRow["RoleType_Name"].ToString(),
|
|
GetRoleString(_DataRow["RoleType_ID"].ToString(), "RoleType_ID"),
|
|
GetRoleTypeString(_DataRow["RoleType_ID"].ToString()), ""));//" Hidden"));
|
|
}
|
|
return _StringBuilder.ToString();
|
|
}
|
|
|
|
string GetProDefTypeString(string PID, string Hidden)
|
|
{
|
|
StringBuilder _StringBuilder = new StringBuilder();
|
|
string _IsHidden = Hidden;
|
|
DataRow[] _DataRowNodes = DataTable_ProDefType.Select("ProDefType_PID=" + PID);
|
|
//if (_DataRowNodes.Length > 3 && PID != "-1")
|
|
if (PID == "-1" && (DataTable_ProDef.Rows.Count > 10 || DataTable_ProDefType.Rows.Count > 10))
|
|
_IsHidden = " Hidden";
|
|
foreach (DataRow _DataRow in _DataRowNodes)
|
|
{
|
|
_StringBuilder.Append(string.Format(_Container,
|
|
_DataRow["ProDefType_Name"].ToString(),
|
|
GetProDefString(_DataRow["ProDefType_ID"].ToString(), _IsHidden),
|
|
GetProDefTypeString(_DataRow["ProDefType_ID"].ToString(), _IsHidden), Hidden));//" Hidden"));
|
|
}
|
|
return _StringBuilder.ToString();
|
|
}
|
|
|
|
string GetProDefString(string PID, string Hidden)
|
|
{
|
|
StringBuilder _StringBuilder = new StringBuilder();
|
|
//string _IsHidden = "";
|
|
//if (DataTable_ProDef.Rows.Count > 3)
|
|
// _IsHidden = " Hidden";
|
|
DataRow[] _DataRowNodes = DataTable_ProDef.Select("ProDefType_ID=" + PID);
|
|
string _IsHidden = "";
|
|
if (_DataRowNodes.Length > 3)
|
|
_IsHidden = " Hidden";
|
|
foreach (DataRow _DataRow in _DataRowNodes)
|
|
{
|
|
_StringBuilder.Append(string.Format(_ProDef,
|
|
_DataRow["ProDef_Name"].ToString(),
|
|
GetRoleString(_DataRow["ProDef_ID"].ToString(), "ProDef_ID"), Hidden, _IsHidden));//" Hidden"));
|
|
}
|
|
return _StringBuilder.ToString();
|
|
}
|
|
string GetRoleString(string PID, string Key)
|
|
{
|
|
StringBuilder _StringBuilder = new StringBuilder();
|
|
DataRow[] _DataRowNodes = DataTable_Role.Select(Key + "=" + PID);
|
|
if ((Key == "RoleType_ID") && (_DataRowNodes.Length > 0))
|
|
_StringBuilder.Append("<div class=\"Process Hidden\">");
|
|
foreach (DataRow _DataRow in _DataRowNodes)
|
|
{
|
|
CheckBox _CheckBox = new CheckBox();
|
|
_CheckBox.ID = "Role_ID_" + _DataRow["Role_ID"].ToString();
|
|
_StringBuilder.Append(string.Format(_Role,
|
|
_CheckBox.ClientID, _CheckBox.UniqueID,
|
|
_DataRow["Role_Name"].ToString(), GetUSerRoleString(_DataRow["Role_ID"].ToString())));
|
|
}
|
|
if ((Key == "RoleType_ID") && (_DataRowNodes.Length > 0))
|
|
_StringBuilder.Append("</div>");
|
|
return _StringBuilder.ToString();
|
|
}
|
|
string GetUSerRoleString(string PID)
|
|
{
|
|
StringBuilder _StringBuilder = new StringBuilder();
|
|
DataRow[] _DataRowNodes = DataTable_UserRole.Select("Role_ID=" + PID);
|
|
|
|
foreach (DataRow _DataRow in _DataRowNodes)
|
|
{
|
|
TextBoxEx1.Text += "Role_ID_"+ _DataRow["Role_ID"].ToString() + ":" + _DataRow["UserRole_ID"].ToString() +",";
|
|
_StringBuilder.Append("checked=\"checked\"");// value=\"" + _DataRow["Role_ID"].ToString()+"\"");
|
|
}
|
|
return _StringBuilder.ToString();
|
|
}
|
|
string _Container = "<div class=\"Container {3}\">\r\n<div class=\"TextTitle\">{0}</div>\r\n{1}\r\n{2}</div>";
|
|
string _ProDef = "<div class=\"Process {2}\"><div class=\"TextTitle\">{0}</div><div class=\"{3}\">{1}</div></div>";
|
|
string _Role = "<span><input id=\"{0}\" name={1} type=\"checkbox\" {3}/><label for=\"{0}\">{2}</label></span>";
|
|
|
|
protected void CallBackButton1_CallBackClick(object sender, ClientSetEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
IEnumerator _IEnumerator = this.Request.Form.GetEnumerator();
|
|
_Object = new Business.UserRole(Transaction);
|
|
Dictionary<string, string> _Dictionary = new Dictionary<string, string>();
|
|
while (_IEnumerator.MoveNext())
|
|
{
|
|
if (_IEnumerator.Current.ToString().IndexOf("Role_ID_") > -1)
|
|
_Dictionary.Add(_IEnumerator.Current.ToString(), "");
|
|
}
|
|
string[] _List = TextBoxEx1.Text.Split(',');
|
|
foreach (string str in _List)
|
|
{
|
|
if (str.IndexOf(":") < 0)
|
|
continue;
|
|
string[] _KeyValue = str.Split(':');
|
|
if (_Dictionary.ContainsKey(_KeyValue[0]))
|
|
_Dictionary[_KeyValue[0]] = _KeyValue[1];
|
|
else //删除
|
|
_Object.Delete(int.Parse(_KeyValue[1]));
|
|
}
|
|
string _Result = "";
|
|
foreach (KeyValuePair<string, string> _KeyValuePair in _Dictionary)
|
|
{
|
|
if (string.IsNullOrEmpty(_KeyValuePair.Value))
|
|
{
|
|
_Object.ResetProperty();
|
|
_Object.User_ID = User_ID;
|
|
_Object.Role_ID = int.Parse(_KeyValuePair.Key.Replace("Role_ID_",""));
|
|
_Object.Insert();
|
|
_Result += _KeyValuePair.Key + ":" + _Object.KeyID + ",";
|
|
}
|
|
else
|
|
_Result += _KeyValuePair.Key + ":" + _KeyValuePair.Value + ",";
|
|
}
|
|
|
|
e.SetValue(TextBoxEx1, _Result);
|
|
e.ClientScript=this.GetAlertStr("保存成功!",3);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Transaction.Rollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
} |