BaoKai_202508_Wms_Jingwang_.../WMS.SqlServerData/BaseData/SystemMenuData.cs
2025-08-24 21:52:42 +08:00

225 lines
8.7 KiB
C#

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
{
/// <summary>
/// 系统菜单
/// </summary>
public class SystemMenuData : ISystemMenu
{
#region menu数据
/// <summary>
/// 获取menu数据
/// </summary>
/// <returns></returns>
public List<BaseMenuModel> GetMenuData(string roleId)
{
List<BaseMenuModel> listMenuFrm = new List<BaseMenuModel>();
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<BaseMenuModel>.ConvertToList(table);
listMenuFrm = listMenuFrm.OrderBy(r => r.MENU_SORT).ToList();
}
}
catch (Exception ex)
{
return null;
}
return listMenuFrm;
}
#endregion
#region
/// <summary>
/// 获取窗体的功能
/// </summary>
/// <param name="menuid"></param>
/// <returns></returns>
public List<MenuFuctionModel> GetMenuFuntion(string menuid)
{
List<MenuFuctionModel> listMenuFrm = new List<MenuFuctionModel>();
// 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<MenuFuctionModel>.ConvertToList(table);
}
}
catch (Exception ex)
{
return null;
}
return listMenuFrm;
}
#endregion
#region menu数据
/// <summary>
/// 添加menu数据
/// </summary>
/// <returns></returns>
public void AddMenuData(BaseMenuModel menuModel,List<MenuFuctionModel> listFucModel)
{
List<string> etsql = new List<string>();
List<OracleParameter[]> lo = new List<OracleParameter[]>();
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
/// <summary>
/// 获取MenuDataTable
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 根据窗体Model 获得菜单
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
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());
}
}
}