public static void InitPermission() { try { #region 初始 for (int i = 0; i < permission.GetUpperBound(0); i++) { permission[i] = new sModel(); } #endregion DataTable tb; string s_SQL; DBHelper DB = new DBHelper(0); // string s_temp1, s_temp2, s_temp3, s_temp4; #region 说明 // 窗口主体的AccessibleName 为模块ID // 主体中的控件AccessibleName 为功能英文名称 // // #endregion #region 获取 #region SQL语法 //s_SQL = @" //select * // from ( // select '用户' as Category, // tf1.UP_MODULE_ID as UP_ID, // tf1.MODULE_ID as ID, // t1.sort as sort, // '' as UP_ENGLISH, // tf1.MODULE_ENGLISH as ENGLISH, // tf1.MODULE_NAME as [NAME], // tf1.MODULE_DESC as [DESC], // t1.PERMISSION as PERMISSION // from FOUNDERPCB_USER t with (nolock) // inner join FOUNDERPCB_USER_PERMISSION t1 with (nolock) on t.rkey = t1.PRO_RKEY // inner join FOUNDERPCB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = t1.SRCE_PTR // where t1.SORT = 1 // and t.LOGIN_ID = '" + GlobalVal.UserInfo.LoginName.Trim() + @"' // // union all // // select '用户' as Category, // tf1.MODULE_ID as UP_ID, // tf1.MODULE_ID as ID, // t1.sort as sort, // '' as UP_ENGLISH, // tf2.OPERATION_ENGLISH as ENGLISH, // tf2.OPERATION_NAME as [NAME], // tf2.OPERATION_DESC as [DESC], // t1.PERMISSION as PERMISSION // from FOUNDERPCB_USER t with (nolock) // inner join FOUNDERPCB_USER_PERMISSION t1 with (nolock) on t.rkey = t1.PRO_RKEY // inner join FOUNDERPCB_FRIGHTE_02 tf2 with (nolock) on tf2.rkey = t1.SRCE_PTR // inner join FOUNDERPCB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = tf2.PRO_RKEY // where t1.SORT = 2 // and t.LOGIN_ID = '" + GlobalVal.UserInfo.LoginName.Trim() + @"' // // union all // // select '用户' as Category, // tf1.MODULE_ID as UP_ID, // tf1.MODULE_ID as ID, // t1.sort as sort, // tf2.OPERATION_ENGLISH as UP_ENGLISH, // tf3.FIELD_ENGLISH as ENGLISH, // tf3.FIELD_NAME as [NAME], // tf3.FIELD_DESC as [DESC], // t1.PERMISSION as PERMISSION // from FOUNDERPCB_USER t with (nolock) // inner join FOUNDERPCB_USER_PERMISSION t1 with (nolock) on t.rkey = t1.PRO_RKEY // inner join FOUNDERPCB_FRIGHTE_03 tf3 with (nolock) on tf3.rkey = t1.SRCE_PTR // inner join FOUNDERPCB_FRIGHTE_02 tf2 with (nolock) on tf2.rkey = tf3.PRO2_RKEY // inner join FOUNDERPCB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = tf2.PRO_RKEY // where t1.SORT = 3 // and t.LOGIN_ID = '" + GlobalVal.UserInfo.LoginName.Trim() + @"' // ) mx //order by UP_ID, ID, sort //"; //使用权限组,关联 s_SQL = @"with tb_role as ( select max(aa.sort) sort, MAX(aa.srce_ptr) srce_ptr, aa.permission from ( select isNull(a.rkey,0) as rkey, isNull(a.pro_rkey,0) as pro_rkey, isNull(a.sort,0) as sort, isNull(a.srce_ptr,'') as srce_ptr, isNull(a.permission,'') as permission from FOUNDERPCB_USER_PERMISSION a with(nolock) where a.PERMISSION!='00' and PRO_RKEY={0} union all select isNull(a.rkey,0) as rkey, isNull(a.pro_rkey,0) as pro_rkey, isNull(a.sort,0) as sort, isNull(a.srce_ptr,'') as srce_ptr, isNull(a.permission,'') as permission from FOUNDERPCB_GROUP_D a with(nolock) left join FOUNDERPCB_GROUP_M with(nolock) on a.PRO_RKEY=FOUNDERPCB_GROUP_M.RKEY left join FOUNDERPCB_USER with(nolock) on FOUNDERPCB_USER.PRO_RKEY=FOUNDERPCB_GROUP_M.RKEY where a.PERMISSION!='00' and FOUNDERPCB_USER.RKEY={0} ) aa group by aa.sort,aa.srce_ptr,aa.permission ) select '用户' as Category, tf1.UP_MODULE_ID as UP_ID, tf1.MODULE_ID as ID, t.sort as sort, '' as UP_ENGLISH, tf1.MODULE_ENGLISH as ENGLISH, tf1.MODULE_NAME as [NAME], tf1.MODULE_DESC as [DESC], t.PERMISSION as PERMISSION from tb_role t inner join FOUNDERPCB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = t.SRCE_PTR and t.sort=1 union all select '用户' as Category, tf1.MODULE_ID as UP_ID, tf1.MODULE_ID as ID, t.sort as sort, '' as UP_ENGLISH, tf2.OPERATION_ENGLISH as ENGLISH, tf2.OPERATION_NAME as [NAME], tf2.OPERATION_DESC as [DESC], t.PERMISSION as PERMISSION from tb_role t inner join FOUNDERPCB_FRIGHTE_02 tf2 with (nolock) on tf2.rkey = t.SRCE_PTR and t.SORT = 2 inner join FOUNDERPCB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = tf2.PRO_RKEY union all select '用户' as Category, tf1.MODULE_ID as UP_ID, tf1.MODULE_ID as ID, t.sort as sort, tf2.OPERATION_ENGLISH as UP_ENGLISH, tf3.FIELD_ENGLISH as ENGLISH, tf3.FIELD_NAME as [NAME], tf3.FIELD_DESC as [DESC], t.PERMISSION as PERMISSION from tb_role t inner join FOUNDERPCB_FRIGHTE_03 tf3 with (nolock) on tf3.rkey = t.SRCE_PTR and t.SORT = 3 inner join FOUNDERPCB_FRIGHTE_02 tf2 with (nolock) on tf2.rkey = tf3.PRO2_RKEY inner join FOUNDERPCB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = tf2.PRO_RKEY "; #endregion tb = DB.GetDataSet(string.Format(s_SQL, GlobalVal.UserInfo.UserRkey)); //用户大于组 //s_temp1 = ""; s_temp2 = ""; s_temp3 = ""; s_temp4 = ""; //for (int i = 0; i < tb.Rows.Count; i++) //{ // if (s_temp1 != tb.Rows[i]["Category"].ToString().Trim() && s_temp2 == tb.Rows[i]["UP_ID"].ToString().Trim() && s_temp3 == tb.Rows[i]["ID"].ToString().Trim() && s_temp4 == tb.Rows[i]["UP_ENGLISH"].ToString().Trim()) // { // if (tb.Rows[i]["Category"].ToString().Trim() == "组") // { // tb.Rows.RemoveAt(i); // i--; // } // if (s_temp1 == "组") // { // tb.Rows.RemoveAt(i - 1); // i--; // } // } // s_temp1 = tb.Rows[i]["Category"].ToString().Trim(); // s_temp2 = tb.Rows[i]["UP_ID"].ToString().Trim(); // s_temp3 = tb.Rows[i]["ID"].ToString().Trim(); // s_temp4 = tb.Rows[i]["UP_ENGLISH"].ToString().Trim(); //} for (int i = 0; i < tb.Rows.Count; i++) { permission[i].UP_ID = tb.Rows[i]["UP_ID"].ToString().Trim(); permission[i].ID = tb.Rows[i]["ID"].ToString().Trim(); permission[i].NAME = tb.Rows[i]["NAME"].ToString().Trim(); permission[i].UP_ENGLISH = tb.Rows[i]["UP_ENGLISH"].ToString().Trim(); permission[i].ENGLISH = tb.Rows[i]["ENGLISH"].ToString().Trim(); permission[i].DESC = tb.Rows[i]["DESC"].ToString().Trim(); permission[i].PERMISSION = tb.Rows[i]["PERMISSION"].ToString().Trim(); permission[i].SORT = int.Parse(tb.Rows[i]["SORT"].ToString().Trim()); } #endregion DB.CloseConnection(); } catch (Exception e1) { log.PrintInfo(e1); System.Environment.Exit(0); } }
public static void InitPermission() { try { #region 初始 for (int i = 0; i < permission.GetUpperBound(0); i++) { permission[i] = new sModel(); } #endregion DataTable tb; string s_SQL; DBHelper DB = new DBHelper(0); // string s_temp1, s_temp2, s_temp3, s_temp4; #region 说明 // 窗口主体的AccessibleName 为模块ID // 主体中的控件AccessibleName 为功能英文名称 // // #endregion #region 获取 #region SQL语法 s_SQL = @"with tb_role as ( select max(aa.sort) sort, MAX(aa.srce_ptr) srce_ptr, aa.permission from ( select isNull(a.rkey,0) as rkey, isNull(a.pro_rkey,0) as pro_rkey, isNull(a.sort,0) as sort, isNull(a.srce_ptr,'') as srce_ptr, isNull(a.permission,'') as permission from GREEKB_USER_PERMISSION a with(nolock) where a.PERMISSION!='00' and PRO_RKEY={0} union all select isNull(a.rkey,0) as rkey, isNull(a.pro_rkey,0) as pro_rkey, isNull(a.sort,0) as sort, isNull(a.srce_ptr,'') as srce_ptr, isNull(a.permission,'') as permission from GREEKB_GROUP_D a with(nolock) left join GREEKB_GROUP_M with(nolock) on a.PRO_RKEY=GREEKB_GROUP_M.RKEY left join GREEKB_USER with(nolock) on GREEKB_USER.PRO_RKEY=GREEKB_GROUP_M.RKEY where a.PERMISSION!='00' and GREEKB_USER.RKEY={0} ) aa group by aa.sort,aa.srce_ptr,aa.permission ) select '用户' as Category, tf1.UP_MODULE_ID as UP_ID, tf1.MODULE_ID as ID, t.sort as sort, '' as UP_ENGLISH, tf1.MODULE_ENGLISH as ENGLISH, tf1.MODULE_NAME as [NAME], tf1.MODULE_DESC as [DESC], t.PERMISSION as PERMISSION from tb_role t inner join GREEKB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = t.SRCE_PTR and t.sort=1 union all select '用户' as Category, tf1.MODULE_ID as UP_ID, tf1.MODULE_ID as ID, t.sort as sort, '' as UP_ENGLISH, tf2.OPERATION_ENGLISH as ENGLISH, tf2.OPERATION_NAME as [NAME], tf2.OPERATION_DESC as [DESC], t.PERMISSION as PERMISSION from tb_role t inner join GREEKB_FRIGHTE_02 tf2 with (nolock) on tf2.rkey = t.SRCE_PTR and t.SORT = 2 inner join GREEKB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = tf2.PRO_RKEY union all select '用户' as Category, tf1.MODULE_ID as UP_ID, tf1.MODULE_ID as ID, t.sort as sort, tf2.OPERATION_ENGLISH as UP_ENGLISH, tf3.FIELD_ENGLISH as ENGLISH, tf3.FIELD_NAME as [NAME], tf3.FIELD_DESC as [DESC], t.PERMISSION as PERMISSION from tb_role t inner join GREEKB_FRIGHTE_03 tf3 with (nolock) on tf3.rkey = t.SRCE_PTR and t.SORT = 3 inner join GREEKB_FRIGHTE_02 tf2 with (nolock) on tf2.rkey = tf3.PRO2_RKEY inner join GREEKB_FRIGHTE_01 tf1 with (nolock) on tf1.rkey = tf2.PRO_RKEY "; #endregion tb = DB.GetDataSet(string.Format(s_SQL, GlobalVal.UserInfo.UserRkey)); for (int i = 0; i < tb.Rows.Count; i++) { permission[i].UP_ID = tb.Rows[i]["UP_ID"].ToString().Trim(); permission[i].ID = tb.Rows[i]["ID"].ToString().Trim(); permission[i].NAME = tb.Rows[i]["NAME"].ToString().Trim(); permission[i].UP_ENGLISH = tb.Rows[i]["UP_ENGLISH"].ToString().Trim(); permission[i].ENGLISH = tb.Rows[i]["ENGLISH"].ToString().Trim(); permission[i].DESC = tb.Rows[i]["DESC"].ToString().Trim(); permission[i].PERMISSION = tb.Rows[i]["PERMISSION"].ToString().Trim(); permission[i].SORT = int.Parse(tb.Rows[i]["SORT"].ToString().Trim()); } #endregion DB.CloseConnection(); } catch (Exception e1) { log.PrintInfo(e1); System.Environment.Exit(0); } }