public bool HasPermission(enumPermission permissionEnumID) { bool permissionOK = false; if (base.ValidateKeyField(this._userID)) { try { PermissionCollection permissions = this.GetPermissions(); permissionOK = permissions.Contains((int)permissionEnumID); } catch (Exception ex) { HandleException(ex); } } return(permissionOK); }
public void GenerateReport() { StringBuilder SQL_DataSource = new StringBuilder(); SQL_DataSource.Append("select a.nodecode as foldercode,b.description as foldername,c.nodecode as modulecode,d.description as modulename,d.id "); SQL_DataSource.Append("from sys_engs_ItemInfo as b,"); SQL_DataSource.Append("(SELECT NodeCode,ralationid FROM sys_engs_Tree "); SQL_DataSource.Append("WHERE (SUBSTRING(NodeCode, 0, 13) IN"); SQL_DataSource.Append("(SELECT NodeCode FROM sys_engs_Tree AS sys_engs_Tree_1 WHERE (NodeType = '@unit_施工单位'))) and nodetype = '@folder') as a,"); SQL_DataSource.Append("(SELECT NodeCode,ralationid FROM sys_engs_Tree "); SQL_DataSource.Append("WHERE (SUBSTRING(NodeCode, 0, 13) IN (SELECT NodeCode FROM sys_engs_Tree AS sys_engs_Tree_1 WHERE (NodeType = '@unit_施工单位'))) and nodetype = '@module') as c,"); //增加查询条件 Scdel=0 2013-10-17 SQL_DataSource.Append("sys_biz_Module as d where b.Scdel=0 and b.id = a.ralationid and c.ralationid = d.id and c.nodecode like a.nodecode + '%' order by a.nodecode,c.nodecode"); DataTable DataSource = GetDataTable(SQL_DataSource.ToString()); DataTable DataResule = new DataTable(); DataColumn Column = new DataColumn("CompanyName"); Column.DataType = typeof(String); DataResule.Columns.Add(Column); Column = new DataColumn("CompanyCode"); Column.DataType = typeof(String); DataResule.Columns.Add(Column); Column = new DataColumn("ModelCode"); Column.DataType = typeof(String); DataResule.Columns.Add(Column); Column = new DataColumn("FolderName"); Column.DataType = typeof(String); DataResule.Columns.Add(Column); Column = new DataColumn("ModuleName"); Column.DataType = typeof(String); DataResule.Columns.Add(Column); Column = new DataColumn("PXRate"); Column.DataType = System.Type.GetType("System.Decimal"); DataResule.Columns.Add(Column); Column = new DataColumn("YZRate"); Column.DataType = System.Type.GetType("System.Decimal"); DataResule.Columns.Add(Column); Column = new DataColumn("SelectTable"); Column.DataType = typeof(String); DataResule.Columns.Add(Column); foreach (DataRow Row in DataSource.Rows) { String TableName = "biz_norm_extent_" + Row["id"].ToString(); StringBuilder SQL_Company = new StringBuilder(); SQL_Company.Append("select a.Description,b.NodeCode from sys_engs_CompanyInfo as a,sys_engs_Tree as b"); //增加查询条件 Scdel=0 2013-10-17 SQL_Company.Append("where a.Scdel=0 and"); SQL_Company.Append("b.NodeCode ='"); SQL_Company.Append(Row["foldercode"].ToString().Substring(0, 12)); SQL_Company.Append("' and a.id = b.ralationid"); DataTable CompanyInfo = GetDataTable(SQL_Company.ToString()); DataRow newRow = DataResule.NewRow(); newRow["CompanyName"] = CompanyInfo.Rows[0]["Description"].ToString(); newRow["CompanyCode"] = CompanyInfo.Rows[0]["NodeCode"].ToString(); newRow["FolderName"] = Row["FolderName"].ToString(); newRow["ModuleName"] = Row["ModuleName"].ToString(); newRow["SelectTable"] = TableName; newRow["ModelCode"] = Row["modulecode"].ToString(); DataResule.Rows.Add(newRow); } StringBuilder Sql_Select = new StringBuilder(); Sql_Select.Append("select code from sys_auth_Organization where type = '"); Sql_Select.Append("监理单位"); Sql_Select.Append("'"); DataTable Organization = GetDataTable(Sql_Select.ToString()); if (Organization != null && Organization.Rows.Count > 0) { PermissionCollection Permissions = new PermissionCollection(); foreach (DataRow Row in Organization.Rows) { int PXCount; int JZCount; int AllCount; Sql_Select = new StringBuilder(); //增加查询条件 Scdel=0 2013-10-17 Sql_Select.Append("select * from sys_auth_Users where Scdel=0 and code like '"); Sql_Select.Append(Row["code"].ToString()); Sql_Select.Append("%'"); DataTable Users = GetDataTable(Sql_Select.ToString()); if (Users != null && Users.Rows.Count > 0) { foreach (DataRow UserRow in Users.Rows) { RoleCollection Roles = RoleManager.InitRoleInformation(UserRow["ID"].ToString()); foreach (Role role in Roles) { PermissionCollection _Permissions = PermissionManager.InitPermissions(role.Index); foreach (Permission Permission in _Permissions) { if (!Permissions.Contains(Permission)) { Permissions.Add(Permission); } } } } } IAuthPolicy AuthPolicy = AuthManager.GetTreeAuth(TreeID, Permissions); DataTable SelectData = new DataTable(); SelectData = DataResule.Clone(); StringBuilder Sql_JLSelect = new StringBuilder(); Sql_JLSelect.Append("select NodeCode from sys_engs_Tree where nodetype ='@unit_监理单位'"); DataTable JLData = GetDataTable(Sql_Select.ToString()); foreach (DataRow JLRow in JLData.Rows) { if (AuthPolicy.HasAuth(JLRow["NodeCode"].ToString())) { foreach (DataRow SelectRow in DataResule.Rows) { if (AuthPolicy.HasAuth(SelectRow["NodeCode"].ToString())) { StringBuilder SQL_PXCount = new StringBuilder(); SQL_PXCount.Append("select count(id) from "); SQL_PXCount.Append(SelectRow["SelectTable"].ToString()); SQL_PXCount.Append("where trytype = '"); SQL_PXCount.Append("平行 and scpt ='"); SQL_PXCount.Append(JLRow["NodeCode"].ToString()); SQL_PXCount.Append("' and scct in (select id from "); SQL_PXCount.Append(SelectRow["SelectTable"].ToString()); SQL_PXCount.Append(" where scpt ='"); SQL_PXCount.Append(SelectRow["modulecode"].ToString()); SQL_PXCount.Append("')"); PXCount = Convert.ToInt32(ExcuteScalar(SQL_PXCount.ToString())); StringBuilder SQL_JZCount = new StringBuilder(); SQL_JZCount.Append("select count(id) from "); SQL_JZCount.Append(SelectRow["SelectTable"].ToString()); SQL_JZCount.Append("where trytype = '"); SQL_JZCount.Append("见证 and scpt ='"); SQL_JZCount.Append(JLRow["NodeCode"].ToString()); SQL_JZCount.Append("' and scct in (select id from "); SQL_JZCount.Append(SelectRow["SelectTable"].ToString()); SQL_JZCount.Append(" where scpt ='"); SQL_JZCount.Append(SelectRow["modulecode"].ToString()); SQL_JZCount.Append("')"); JZCount = Convert.ToInt32(ExcuteScalar(SQL_JZCount.ToString())); StringBuilder SQL_ALLCount = new StringBuilder(); SQL_ALLCount.Append("select count(id) from "); SQL_ALLCount.Append(SelectRow["SelectTable"].ToString()); SQL_ALLCount.Append("where scpt ='"); SQL_ALLCount.Append(SelectRow["modulecode"].ToString()); SQL_ALLCount.Append("'"); AllCount = Convert.ToInt32(ExcuteScalar(SQL_ALLCount.ToString())); SelectRow["PXRate"] = PXCount / AllCount; SelectRow["YZRate"] = JZCount / AllCount; SelectData.ImportRow(SelectRow); } } DrawSupervisionReport(SelectData, Row["Description"].ToString()); } } } } }