using System;
using System.Data;
using System.Collections;
using BP.DA;
using BP.En;
using BP.Port;
using BP.Sys;
namespace BP.Cloud.Template
{
///
/// 属性
///
public class FrmTreeAttr : EntityTreeAttr
{
///
/// 数据源
///
public const string DBSrc = "DBSrc";
///
/// 是否是目录
///
public const string IsDir = "IsDir";
///
/// 组织
///
public const string OrgNo = "OrgNo";
}
///
/// 独立表单树
///
public class FrmTree : EntityTree
{
#region 属性.
///
/// 是否是目录
///
public bool IsDir
{
get
{
return this.GetValBooleanByKey(FrmTreeAttr.IsDir);
}
set
{
this.SetValByKey(FrmTreeAttr.IsDir, value);
}
}
public string OrgNo
{
get
{
return this.GetValStringByKey(FrmTreeAttr.OrgNo);
}
set
{
this.SetValByKey(FrmTreeAttr.OrgNo, value);
}
}
#endregion 属性.
#region 构造方法
///
/// 独立表单树
///
public FrmTree()
{
}
///
/// 独立表单树
///
///
public FrmTree(string _No) : base(_No) { }
#endregion
#region 系统方法.
///
/// 独立表单树Map
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("Sys_FormTree", "表单树");
map.CodeStruct="2";
map.AddTBStringPK(FrmTreeAttr.No, null, "编号", true, true, 1, 50, 40);
map.AddTBString(FrmTreeAttr.Name, null, "名称", true, false, 0, 100, 30);
map.AddTBString(FrmTreeAttr.ParentNo, null, "父节点No", false, false, 0, 100, 40);
map.AddTBString(FrmTreeAttr.OrgNo, null, "OrgNo", false, false, 0, 100, 30);
map.AddTBInt(FrmTreeAttr.Idx, 0, "Idx", false, false);
this._enMap = map;
return this._enMap;
}
}
#endregion 系统方法.
protected override bool beforeInsert()
{
//this.OrgNo = BP.Web.WebUser.FK_Dept;
return base.beforeInsert();
}
protected override bool beforeDelete()
{
if (!DataType.IsNullOrEmpty(this.No))
DeleteChild(this.No);
return base.beforeDelete();
}
///
/// 删除子项
///
///
private void DeleteChild(string parentNo)
{
FrmTrees formTrees = new FrmTrees();
formTrees.RetrieveByAttr(FrmTreeAttr.ParentNo, parentNo);
foreach (FrmTree item in formTrees)
{
MapData md = new MapData();
md.FK_FormTree = item.No;
md.Delete();
DeleteChild(item.No);
}
}
public string DoCreateSameLevelNodeIt(string name)
{
FrmTree en = new FrmTree();
en.Copy(this);
en.No = DBAccess.GenerGUID(10);
en.Name = name;
en.Insert();
return en.No;
}
public string DoCreateSubNodeIt(string name)
{
FrmTree en = new FrmTree();
en.Copy(this);
en.No = DBAccess.GenerGUID(10);
en.ParentNo = this.No;
en.Name = name;
en.Insert();
return en.No;
}
// public void DoUp()
//{
// this.DoOrderUp(FrmTreeAttr.ParentNo, this.ParentNo, FrmTreeAttr.Idx);
//}
//public void DoDown()
//{
// this.DoOrderDown(FrmTreeAttr.ParentNo, this.ParentNo, FrmTreeAttr.Idx);
//}
}
///
/// 独立表单树
///
public class FrmTrees : EntitiesTree
{
///
/// 独立表单树s
///
public FrmTrees() { }
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new FrmTree();
}
}
public override int RetrieveAll()
{
int i = base.Retrieve("OrgNo", BP.Web.WebUser.OrgNo);
if (i == 0)
{
FrmTree fs = new FrmTree();
fs.Name = "公文类";
fs.No = "01";
fs.Insert();
fs = new FrmTree();
fs.Name = "办公类";
fs.No = "02";
fs.Insert();
i = base.RetrieveAll("OrgNo", BP.Web.WebUser.OrgNo);
}
return i;
}
#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((FrmTree)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}