using System;
using System.Collections;
using BP.DA;
using BP.En;
using BP.Sys;
namespace BP.GPM
{
///
/// 系统类别
///
public class AppSortAttr : EntityNoNameAttr
{
public const string Idx = "Idx";
///
/// 关联的菜单编号
///
public const string RefMenuNo = "RefMenuNo";
}
///
/// 系统类别
///
public class AppSort : EntityNoName
{
#region 属性
///
/// RefMenuNo
///
public string RefMenuNo
{
get
{
return this.GetValStrByKey(AppSortAttr.RefMenuNo);
}
set
{
this.SetValByKey(AppSortAttr.RefMenuNo, value);
}
}
#endregion
#region 按钮权限控制
public override UAC HisUAC
{
get
{
UAC uac = new UAC();
uac.OpenForAppAdmin();
return uac;
}
}
#endregion
#region 构造方法
///
/// 系统类别
///
public AppSort()
{
}
///
/// 系统类别
///
///
public AppSort(string no)
{
this.No = no;
this.Retrieve();
}
///
/// EnMap
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("GPM_AppSort", "系统类别");
map.setEnType(EnType.App);
map.setIsAutoGenerNo(false);
map.AddTBStringPK(AppSortAttr.No, null, "编号", true, true, 1, 200, 20);
map.AddTBString(AppSortAttr.Name, null, "名称", true, false, 0, 300, 20);
map.AddTBInt(AppSortAttr.Idx, 0, "显示顺序", true, false);
map.AddTBString(AppSortAttr.RefMenuNo, null, "关联的菜单编号", false, false, 0, 300, 20);
this._enMap = map;
return this._enMap;
}
}
#endregion
protected override bool beforeDelete()
{
Apps pps = new Apps();
pps.Retrieve(AppAttr.FK_AppSort, this.No);
if (pps.Count != 0)
throw new Exception("err@该类别下有系统,您不能删除,请把该系统类别下的系统移除或者删除,您才能删除该类别。");
Menu root = new Menu();
root.No = this.RefMenuNo;
if (root.RetrieveFromDBSources() > 0)
root.Delete();
return base.beforeDelete();
}
public void CheckIt()
{
AppSort sort = new AppSort();
sort.CheckPhysicsTable();
App app = new App();
app.CheckPhysicsTable();
Menu en = new Menu();
en.CheckPhysicsTable();
}
protected override bool beforeUpdate()
{
CheckIt();
Menu root = new Menu();
root.No = this.RefMenuNo;
if (root.RetrieveFromDBSources() > 0)
{
root.Name = this.Name;
root.Update();
}
return base.beforeUpdate();
}
protected override bool beforeInsert()
{
CheckIt();
// 求root.
Menu root = new Menu();
root.No = "1000";
if (root.RetrieveFromDBSources() == 0)
{
/*如果没有root.*/
root.ParentNo = "0";
root.Name = BP.Difference.SystemConfig.SysName;
root.FK_App = BP.Difference.SystemConfig.SysNo;
root.HisMenuType = MenuType.Root;
root.Idx = 0;
root.Insert();
}
// 创建系统类别做为二级菜单.
Menu sort1 = root.DoCreateSubNode() as Menu;
sort1.Name = this.Name;
sort1.HisMenuType = MenuType.AppSort;
sort1.FK_App = "AppSort";
sort1.Update();
this.No = sort1.No;
this.RefMenuNo = sort1.No;
return true;
}
}
///
/// 系统类别s
///
public class AppSorts : EntitiesNoName
{
#region 构造
///
/// 系统类别s
///
public AppSorts()
{
}
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new AppSort();
}
}
#endregion
#region 为了适应自动翻译成java的需要,把实体转换成List.
///
/// 转化成 java list,C#不能调用.
///
/// List
public System.Collections.Generic.IList ToJavaList()
{
return (System.Collections.Generic.IList)this;
}
///
/// 转化成list
///
/// List
public System.Collections.Generic.List Tolist()
{
System.Collections.Generic.List list = new System.Collections.Generic.List();
for (int i = 0; i < this.Count; i++)
{
list.Add((AppSort)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}