using System;
using System.Data;
using System.Collections;
using BP.DA;
using BP.Sys.Base;
using BP.En;
using System.Collections.Generic;
using System.IO;
using BP.Pub;
namespace BP.Sys
{
///
/// 表单模板版本管理
///
public class MapDataVerAttr : EntityNoNameAttr
{
///
/// 表单ID
///
public const string FrmID = "FrmID";
///
/// 版本号
///
public const string Ver = "Ver";
///
/// 日期
///
public const string RDT = "RDT";
///
/// 记录人
///
public const string Rec = "Rec";
///
/// 记录人名称
///
public const string RecName = "RecName";
///
/// 备注
///
public const string RecNote = "RecNote";
public const string IsRel = "IsRel";
///
/// 行数
///
public const string RowNum = "RowNumExt";
public const string AttrsNum = "AttrsNum";
public const string DtlsNum = "DtlsNum";
public const string AthsNum = "AthsNum";
public const string ExtsNum = "ExtsNum";
}
///
/// 表单模板版本管理
///
public class MapDataVer : EntityMyPK
{
#region 属性
public int Ver
{
get
{
return this.GetValIntByKey(MapDataVerAttr.Ver);
}
set
{
this.SetValByKey(MapDataVerAttr.Ver, value);
}
}
public int IsRel
{
get
{
return this.GetValIntByKey(MapDataVerAttr.IsRel);
}
set
{
this.SetValByKey(MapDataVerAttr.IsRel, value);
}
}
public int RowNum
{
get
{
return this.GetValIntByKey(MapDataVerAttr.RowNum);
}
set
{
this.SetValByKey(MapDataVerAttr.RowNum, value);
}
}
public string FrmID
{
get
{
return this.GetValStringByKey(MapDataVerAttr.FrmID);
}
set
{
this.SetValByKey(MapDataVerAttr.FrmID, value);
}
}
public string Rec
{
get
{
return this.GetValStringByKey(MapDataVerAttr.Rec);
}
set
{
this.SetValByKey(MapDataVerAttr.Rec, value);
}
}
public string RecName
{
get
{
return this.GetValStringByKey(MapDataVerAttr.RecName);
}
set
{
this.SetValByKey(MapDataVerAttr.RecName, value);
}
}
public string RecNote
{
get
{
return this.GetValStringByKey(MapDataVerAttr.RecNote);
}
set
{
this.SetValByKey(MapDataVerAttr.RecNote, value);
}
}
public string RDT
{
set
{
this.SetValByKey(MapDataVerAttr.RDT, value);
}
}
public int AttrsNum
{
set
{
this.SetValByKey(MapDataVerAttr.AttrsNum, value);
}
}
public int DtlsNum
{
set
{
this.SetValByKey(MapDataVerAttr.DtlsNum, value);
}
}
public int AthsNum
{
set
{
this.SetValByKey(MapDataVerAttr.AthsNum, value);
}
}
public int ExtsNum
{
set
{
this.SetValByKey(MapDataVerAttr.ExtsNum, value);
}
}
#endregion
#region 构造方法
///
/// 模板版本管理
///
public MapDataVer()
{
}
public MapDataVer(string mypk)
{
this.MyPK = mypk;
this.Retrieve();
}
///
/// EnMap
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("Sys_MapDataVer", "表单模板版本管理");
map.AddMyPK();
map.AddTBInt(MapDataVerAttr.Ver, 0, "版本号", true, false);
map.AddTBInt(MapDataVerAttr.IsRel, 0, "是否主版本?", true, false);
map.AddTBInt(MapDataVerAttr.RowNum, 0, "行数", true, false);
map.AddTBString(MapDataVerAttr.FrmID, null, "表单ID", true, false, 0, 50, 20);
map.AddTBInt(MapDataVerAttr.AttrsNum, 0, "字段数", true, true);
map.AddTBInt(MapDataVerAttr.DtlsNum, 0, "从表数", true, true);
map.AddTBInt(MapDataVerAttr.AthsNum, 0, "附件数", true, true);
map.AddTBInt(MapDataVerAttr.ExtsNum, 0, "逻辑数", true, true);
map.AddTBString(MapDataVerAttr.Rec, null, "记录人ID", true, false, 0, 50, 20);
map.AddTBString(MapDataVerAttr.RecName, null, "记录人名称", true, false, 0, 50, 20);
map.AddTBString(MapDataVerAttr.RecNote, null, "备注", true, false, 0, 500, 20);
map.AddTBDateTime(MapDataVerAttr.RDT, null, "记录时间", true, false);
this._enMap = map;
return this._enMap;
}
}
#endregion
protected override bool beforeInsert()
{
this.SetValByKey("RDT", DataType.CurrentDateTime);
return base.beforeInsert();
}
protected override bool beforeDelete()
{
//如果改版本的数据已经在存储表中使用,则不能删除
MapData md = new MapData(this.FrmID);
int count = DBAccess.RunSQLReturnValInt("SELECT Count(*) From " + md.PTable + " WHERE AtPara like '%@FrmVer=" + this.Ver + "%'");
if (count > 0)
{
throw new Exception("表单" + md.Name + "版本" + this.Ver + "已经被使用,不能删除");
return false;
}
return base.beforeDelete();
}
protected override void afterDelete()
{
//删除版本需要删除相关的表单信息
MapData md = new MapData(this.FrmID+"."+this.Ver);
md.Delete();
base.afterDelete();
}
}
///
/// 表单模板版本管理s
///
public class MapDataVers : EntitiesMyPK
{
#region 构造
///
/// 模板版本管理s
///
public MapDataVers()
{
}
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new MapDataVer();
}
}
#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((MapDataVer)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}