using System; using System.Collections.Generic; using System.Linq; using System.Text; using WMS.DBUtility; using System.Data; using WMS.Common; using WMS.IData.IBase; using WMS.Model.Base; using WMS.IData;using Oracle.ManagedDataAccess.Client; namespace WMS.SqlServerData.BaseData { /// /// 系统菜单 /// public class SystemMenuData : ISystemMenu { #region 获取menu数据 /// /// 获取menu数据 /// /// public List GetMenuData(string roleId) { List listMenuFrm = new List(); string sqlStr = @" select 'true' as IsCheckRec , a.* ,b.MENU_NAME as p_menu_name from T_BASE_MENU a left join (select menu_id,menu_name from T_BASE_MENU t where t.MENU_LEVEL='1' and status='1' ) b on b.menu_id =a.p_menu_id where a.status='1' and a.menu_id in (select menu_id from T_BASE_MENUROLE where ROLE_ID='" + roleId + "') " + @" union select 'false' as IsCheckRec , a.* ,b.MENU_NAME as p_menu_name from T_BASE_MENU a left join (select menu_id,menu_name from T_BASE_MENU t where t.MENU_LEVEL='1' and status='1' ) b on b.menu_id =a.p_menu_id where a.status='1' and a.menu_id not in (select menu_id from T_BASE_MENUROLE where ROLE_ID='" + roleId + "')"; // +"order by P_MENU_ID, a.menu_sort "; try { DataTable table = SystemDataObject.Instance.GetDataTable(sqlStr); if (table != null) { listMenuFrm = ConvertHelper.ConvertToList(table); listMenuFrm = listMenuFrm.OrderBy(r => r.MENU_SORT).ToList(); } } catch (Exception ex) { return null; } return listMenuFrm; } #endregion #region 获取窗体的功能 /// /// 获取窗体的功能 /// /// /// public List GetMenuFuntion(string menuid) { List listMenuFrm = new List(); // string sqlStr =@" select a.*,decode(b.menu_name,'','wms管理系统',b.menu_name) as P_MENU_NAME from T_BASE_MENU a, // (select menu_id,menu_name from T_BASE_MENU t) b where b.menu_id(+) =a.p_menu_id // order by a.p_menu_id,a.menu_sort "; string sqlStr =@"select a.*,-- (case b.menu_name when '' then 'wms管理系统' else b.menu_name end ) as P_MENU_NAME --- from T_BASE_MENU a right join (select menu_id,menu_name from T_BASE_MENU t) b --- on b.menu_id =a.p_menu_id order by a.menu_sort"; try { DataTable table = SystemDataObject.Instance.GetDataTable(sqlStr); if (table != null) { listMenuFrm = ConvertHelper.ConvertToList(table); } } catch (Exception ex) { return null; } return listMenuFrm; } #endregion #region 添加menu数据 /// /// 添加menu数据 /// /// public void AddMenuData(BaseMenuModel menuModel,List listFucModel) { List etsql = new List(); List lo = new List(); string sqlstr = ""; if (menuModel != null) { sqlstr = string.Format(@"insert into t_base_menu ( p_menu_id , menu_id , menu_name , menu_level , remark , menu_form , menu_tag , menu_image , menu_sort , frm_type , vc_eidt ) values ( '{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}' ) ", menuModel.P_MENU_ID, menuModel.MENU_ID, menuModel.MENU_NAME, menuModel.MENU_LEVEL, menuModel.REMARK, menuModel.MENU_FORM, menuModel.MENU_TAG, menuModel.MENU_IMAGE, menuModel.MENU_SORT, menuModel.FRM_TYPE, menuModel.VC_EIDT); etsql.Add(sqlstr); if (listFucModel.Count > 0) { foreach (MenuFuctionModel fuc in listFucModel) { sqlstr = string.Format(@"insert into t_base_functioninfo(FUN_NAME,FUN_DICTORY,FUN_TAG,FUN_IMAGE,FUN_METHOD,MENU_ID,FUN_SORT,FUN_ID) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", fuc.FUN_NAME, fuc.FUN_DICTORY, fuc.FUN_NAME, fuc.FUN_IMAGE, "1", fuc.MENU_ID, fuc.FUN_SORT, fuc.FUN_ID); etsql.Add(sqlstr); } } //sqlstr = string.Format(@"insert into t_base_functionrole // ( // menu_id, // fun_id, // role_id, // user_id // ) // ( // select distinct '{0}' as menu_id,fun_id,b.role_id,b.user_id from t_base_FunctionInfo a,t_base_userinfo b // ) // ", menuModel.MENU_ID); //etsql.Add(sqlstr); //lo.Add(new OracleParameter[] { }); } SystemDataObject.Instance.ExecuteList(etsql); } #endregion /// /// 获取MenuDataTable /// /// public DataTable GetMenuDataTable() { string strSQL = "select MENU_ID,MENU_NAME,P_MENU_ID,'0' as ISCHECK from T_BASE_MENU"; DataTable dt = SystemDataObject.Instance.GetDataTable(strSQL); return dt; } /// /// 根据窗体Model 获得菜单 /// /// /// public DataTable GetMenuDataByModel(BaseMenuModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select p_menu_id, menu_id, menu_name, menu_level, remark, menu_form, menu_tag, menu_image, menu_sort, frm_type, vc_eidt, status from t_base_menu where 1 =1 "); if (!string.IsNullOrEmpty(model.MENU_FORM)) { strSql.Append(" and menu_form = '" + model.MENU_FORM + "'"); } return SystemDataObject.Instance.GetDataTable(strSql.ToString()); } } }