using System;
using System.Collections;
using BP.DA;
using BP.En;
namespace BP.Sys
{
///
/// 属性
///
public class SerialAttr
{
///
/// 属性Key
///
public const string EnsName = "EnsName";
///
/// 工作人员
///
public const string CfgKey = "CfgKey";
///
/// 序列号
///
public const string IntVal = "IntVal";
}
///
/// 序列号
///
public class Serial: Entity
{
#region 基本属性
///
/// 序列号
///
public string IntVal
{
get
{
return this.GetValStringByKey(SerialAttr.IntVal ) ;
}
set
{
this.SetValByKey(SerialAttr.IntVal,value) ;
}
}
///
/// 操作员ID
///
public string CfgKey
{
get
{
return this.GetValStringByKey(SerialAttr.CfgKey ) ;
}
set
{
this.SetValByKey(SerialAttr.CfgKey,value) ;
}
}
#endregion
#region 构造方法
///
/// 序列号
///
public Serial()
{
}
///
/// map
///
public override Map EnMap
{
get
{
if (this._enMap!=null) return this._enMap;
Map map = new Map("Sys_Serial", "序列号");
map.EnType=EnType.Sys;
map.DepositaryOfEntity=Depositary.None;
map.AddTBStringPK(SerialAttr.CfgKey,"OID","CfgKey",false,true,1,100,10);
map.AddTBInt(SerialAttr.IntVal,0,"属性",true,false);
this._enMap=map;
return this._enMap;
}
}
#endregion
public int Gener(string CfgKey)
{
Paras ps = new Paras();
ps.Add("p", CfgKey);
string sql = "SELECT IntVal Sys_Serial WHERE CfgKey="+BP.Difference.SystemConfig.AppCenterDBVarStr+"p";
int val = DBAccess.RunSQLReturnValInt(sql, 0,ps);
if (val == 0)
{
sql = "INSERT INTO Sys_Serial VALUES(" + BP.Difference.SystemConfig.AppCenterDBVarStr + "p,1)";
DBAccess.RunSQLReturnVal(sql, ps);
return 1;
}
else
{
val++;
ps.Add("intV", val);
sql = "UPDATE Sys_Serial SET IntVal="+BP.Difference.SystemConfig.AppCenterDBVarStr+"intV WHERE CfgKey=" + BP.Difference.SystemConfig.AppCenterDBVarStr + "p";
DBAccess.RunSQLReturnVal(sql);
return val;
}
}
}
///
/// 序列号s
///
public class Serials : Entities
{
///
/// 序列号s
///
public Serials()
{
}
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new Serial();
}
}
#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((Serial)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}