using System;
using System.Data;
using System.Collections;
using BP.DA;
using BP.En;
using System.IO;
using BP.Pub;
namespace BP.Sys
{
///
/// 实体属性
///
public class MapAttrAttr : EntityMyPKAttr
{
///
/// 实体标识
///
public const string FK_MapData = "FK_MapData";
///
/// 物理表
///
public const string KeyOfEn = "KeyOfEn";
///
/// 实体名称
///
public const string Name = "Name";
///
/// 默认值
///
public const string DefVal = "DefVal";
///
/// 字段
///
public const string Field = "Field";
///
/// 最大长度
///
public const string MaxLen = "MaxLen";
///
/// 最小长度
///
public const string MinLen = "MinLen";
///
/// 绑定的值
///
public const string UIBindKey = "UIBindKey";
///
/// 空件类型
///
public const string UIContralType = "UIContralType";
///
/// 宽度
///
public const string UIWidth = "UIWidth";
///
/// UIHeight
///
public const string UIHeight = "UIHeight";
///
/// 是否只读
///
public const string UIIsEnable = "UIIsEnable";
///
/// 关联的表的Key
///
public const string UIRefKey = "UIRefKey";
///
/// 关联的表的Lab
///
public const string UIRefKeyText = "UIRefKeyText";
///
/// 是否可见的
///
public const string UIVisible = "UIVisible";
///
/// 是否单独行显示
///
public const string UIIsLine = "UIIsLine";
///
/// 序号
///
public const string Idx = "Idx";
///
/// 标识(存放临时数据)
///
public const string Tag = "Tag";
///
/// 扩展字段1
///
public const string Tag1 = "Tag1";
///
/// 扩展字段2
///
public const string Tag2 = "Tag2";
///
/// 扩展字段3
///
public const string Tag3 = "Tag3";
///
/// MyDataType
///
public const string MyDataType = "MyDataType";
///
/// 逻辑类型
///
public const string LGType = "LGType";
///
/// 编辑类型
///
public const string EditType = "EditType";
///
/// 自动填写内容
///
public const string AutoFullDoc = "AutoFullDoc";
///
/// 自动填写方式
///
public const string AutoFullWay = "AutoFullWay";
///
/// GroupID
///
public const string GroupID = "GroupID";
///
/// 图标
///
public const string ICON = "ICON";
///
/// 是否是签字
///
public const string IsSigan = "IsSigan";
///
/// 字体大小
///
public const string FontSize = "FontSize";
///
/// TabIdx
///
public const string TabIdx = "TabIdx";
///
/// GUID
///
public const string GUID = "GUID";
///
/// 合并单元格数
///
public const string ColSpan = "ColSpan";
///
/// 文本合并单元格数
///
public const string LabelColSpan = "LabelColSpan";
///
/// 合并行数
///
public const string RowSpan = "RowSpan";
///
/// 签名字段
///
public const string SiganField = "SiganField";
///
/// 操作提示
///
public const string Tip = "Tip";
///
/// 是否自动签名
///
public const string PicType = "PicType";
///
/// 是否是img字段
///
public const string IsImgField = "IsImgField";
///
/// 类型
///
public const string TBModel = "TBModel";
public const string CSSCtrl = "CSSCtrl";
public const string CSSLabel = "CSSLabel";
#region 参数属性.
///
/// 是否必填
///
public const string UIIsInput = "UIIsInput";
#endregion 参数属性.
///
/// 数值字段是否合计
///
public const string IsSum = "IsSum";
///
/// 列求和
///
public const string ExtIsSum = "ExtIsSum";
///
/// 在手机端是否显示
///
public const string IsEnableInAPP = "IsEnableInAPP";
public const string IsSupperText = "IsSupperText";
///
/// 默认值设置方式
///
public const string DefValType = "DefValType";
public const string DefaultVal = "";
public const string TextModel = "TextModel";
}
///
/// 实体属性
///
public class MapAttr : EntityMyPK
{
#region 文本字段参数属性.
///
/// 是否是超大文本?
///
public int IsSupperText
{
get
{
return this.GetValIntByKey(MapAttrAttr.IsSupperText, 0);
}
set
{
this.SetValByKey(MapAttrAttr.IsSupperText, value);
}
}
public int TextModel
{
get
{
return this.GetValIntByKey(MapAttrAttr.TextModel);
}
set
{
this.SetValByKey(MapAttrAttr.TextModel, value);
}
}
///
/// 是否启用二维码?
///
public bool IsEnableQrCode
{
get
{
return this.GetParaBoolen("IsEnableQrCode", false);
}
set
{
this.SetPara("IsEnableQrCode", value);
}
}
#endregion
#region 数值字段参数属性,2017-1-9,liuxc
///
/// 数值字段是否合计(默认true)
///
public bool IsSum
{
get
{
return this.GetParaBoolen(MapAttrAttr.IsSum, true);
}
set
{
this.SetPara(MapAttrAttr.IsSum, value);
}
}
public bool ExtIsSum
{
get
{
return this.GetParaBoolen(MapAttrAttr.ExtIsSum, true);
}
set
{
this.SetPara(MapAttrAttr.ExtIsSum, value);
}
}
#endregion
#region 参数属性.
///
/// 是否必填字段
///
public bool UIIsInput
{
get
{
return this.GetValBooleanByKey(MapAttrAttr.UIIsInput, false);
}
set
{
this.SetValByKey(MapAttrAttr.UIIsInput, value);
}
}
///
/// 在手机端中是否显示
///
public bool IsEnableInAPP
{
get
{
return this.GetValBooleanByKey(MapAttrAttr.IsEnableInAPP, true);
}
set
{
this.SetValByKey(MapAttrAttr.IsEnableInAPP, value);
}
}
///
/// 是否启用高级JS设置
///
public bool IsEnableJS
{
get
{
return this.GetParaBoolen("IsEnableJS", false);
}
set
{
this.SetPara("IsEnableJS", value);
}
}
#endregion
#region 属性
public EntitiesNoName _ens = null;
///
/// 实体类
///
public EntitiesNoName HisEntitiesNoName
{
get
{
if (this.UIBindKey.Contains("."))
{
EntitiesNoName ens = (EntitiesNoName)BP.En.ClassFactory.GetEns(this.UIBindKey);
if (ens == null)
return null;
ens.RetrieveAll();
return ens;
}
if (_ens == null)
{
SFTable sf = new SFTable(this.UIBindKey);
if (sf.FK_SFDBSrc == "local")
{
GENoNames myens = new GENoNames(this.UIBindKey, this.Name);
if (sf.SrcType == DictSrcType.SQL)
{
//此种类型时,没有物理表或视图,从SQL直接查出数据
DataTable dt = sf.GenerHisDataTable();
EntityNoName enn = null;
foreach (DataRow row in dt.Rows)
{
enn = myens.GetNewEntity as EntityNoName;
enn.No = row["No"] as string;
enn.Name = row["Name"] as string;
myens.AddEntity(enn);
}
}
else
{
myens.RetrieveAll();
}
_ens = myens;
}
else
{
GENoNames myens = new GENoNames(this.UIBindKey, this.Name);
_ens = myens;
//throw new Exception("@非实体类实体不能获取EntitiesNoName。");
}
}
return _ens;
}
}
private DataTable _dt = null;
///
/// 外部数据表
///
public DataTable HisDT
{
get
{
if (_dt == null)
{
if (DataType.IsNullOrEmpty(this.UIBindKey))
throw new Exception("@属性:" + this.MyPK + " 丢失属性 UIBindKey 字段。");
SFTable sf = new SFTable(this.UIBindKey);
_dt = sf.GenerHisDataTable();
}
return _dt;
}
}
///
/// 是否是导入过来的字段
///
public bool IsTableAttr
{
get
{
return DataType.IsNumStr(this.KeyOfEn.Replace("F", ""));
}
}
///
/// 转换成属性.
///
public Attr HisAttr
{
get
{
Attr attr = new Attr();
attr.Key = this.KeyOfEn;
attr.Desc = this.Name;
string s = this.DefValReal;
if (DataType.IsNullOrEmpty(s))
attr.DefaultValOfReal = null;
else
attr.DefaultValOfReal = this.DefValReal;
attr.DefValType = this.DefValType;
attr.Field = this.Field;
attr.MaxLength = this.MaxLen;
attr.MinLength = this.MinLen;
attr.UIBindKey = this.UIBindKey;
attr.UIIsLine = this.UIIsLine;
attr.UIHeight = 0;
if (this.UIHeight > 30)
attr.UIHeight = (int)this.UIHeight;
attr.UIWidth = this.UIWidth;
attr.MyDataType = this.MyDataType;
attr.UIRefKeyValue = this.UIRefKey;
attr.UIRefKeyText = this.UIRefKeyText;
attr.UIVisible = this.UIVisible;
attr.MyFieldType = FieldType.Normal; //普通类型的字段.
if (this.IsPK)
attr.MyFieldType = FieldType.PK;
attr.IsSupperText = this.IsSupperText;
switch (this.LGType)
{
case FieldTypeS.Enum:
attr.UIContralType = this.UIContralType;
attr.MyFieldType = FieldType.Enum;
attr.UIIsReadonly = this.UIIsEnable;
break;
case FieldTypeS.FK:
attr.UIContralType = this.UIContralType;
attr.MyFieldType = FieldType.FK;
//attr.UIRefKeyValue = "No";
//attr.UIRefKeyText = "Name";
attr.UIIsReadonly = this.UIIsEnable;
break;
default:
if (this.IsPK)
attr.MyFieldType = FieldType.PK;
attr.UIIsReadonly = !this.UIIsEnable;
switch (this.MyDataType)
{
case DataType.AppBoolean:
attr.UIContralType = UIContralType.CheckBok;
attr.UIIsReadonly = this.UIIsEnable;
break;
case DataType.AppDate:
if (this.Tag == "1")
attr.DefaultVal = DataType.CurrentDate;
break;
case DataType.AppDateTime:
if (this.Tag == "1")
attr.DefaultVal = DataType.CurrentDate;
break;
default:
attr.UIContralType = this.UIContralType;
break;
}
break;
}
return attr;
}
}
///
/// 是否主键
///
public bool IsPK
{
get
{
switch (this.KeyOfEn)
{
case "OID":
case "No":
case "MyPK":
case "NodeID":
case "WorkID":
return true;
default:
return false;
}
}
}
///
/// 编辑类型
///
public EditType HisEditType
{
get
{
return (EditType)this.GetValIntByKey(MapAttrAttr.EditType);
}
set
{
this.SetValByKey(MapAttrAttr.EditType, (int)value);
}
}
public void setEditType(EditType val)
{
this.SetValByKey(MapAttrAttr.EditType, (int)val);
}
///
/// 表单ID
///
public string FK_MapData
{
get
{
return this.GetValStrByKey(MapAttrAttr.FK_MapData);
}
}
public void setFK_MapData(string val)
{
this.SetValByKey(MapAttrAttr.FK_MapData, val);
}
///
/// 字段名
///
public string KeyOfEn
{
get
{
return this.GetValStrByKey(MapAttrAttr.KeyOfEn);
}
}
public void setKeyOfEn(string val)
{
this.SetValByKey(MapAttrAttr.KeyOfEn, val);
}
public FieldTypeS LGType
{
get
{
return (FieldTypeS)this.GetValIntByKey(MapAttrAttr.LGType);
}
set
{
this.SetValByKey(MapAttrAttr.LGType, (int)value);
}
}
public void setLGType(FieldTypeS val)
{
this.SetValByKey(MapAttrAttr.LGType, (int)val);
}
public string LGTypeT
{
get
{
return this.GetValRefTextByKey(MapAttrAttr.LGType);
}
}
///
/// 描述
///
public string Name
{
get
{
string s = this.GetValStrByKey(MapAttrAttr.Name);
if (DataType.IsNullOrEmpty(s) == true)
return this.KeyOfEn;
return s;
}
set
{
this.SetValByKey(MapAttrAttr.Name, value);
}
}
public void setName(string val)
{
this.SetValByKey(MapAttrAttr.Name, val);
}
public bool IsNum
{
get
{
switch (this.MyDataType)
{
case DataType.AppString:
case DataType.AppDate:
case DataType.AppDateTime:
case DataType.AppBoolean:
return false;
default:
return true;
}
}
}
public decimal DefValDecimal
{
get
{
return decimal.Parse(this.DefVal);
}
}
public string DefValReal
{
get
{
return this.GetValStrByKey(MapAttrAttr.DefVal);
}
}
public void setDefValReal(string val)
{
this.SetValByKey(MapAttrAttr.DefVal, val);
}
public int DefValType
{
get
{
return this.GetValIntByKey(MapAttrAttr.DefValType);
}
set
{
this.SetValByKey(MapAttrAttr.DefValType, value);
}
}
public void setDefValType(int val)
{
this.SetValByKey(MapAttrAttr.DefValType, val);
}
///
/// 合并单元格数
///
public int ColSpan
{
get
{
int i = this.GetValIntByKey(MapAttrAttr.ColSpan);
if (this.UIIsLine && i == 1)
return 3;
if (i == 0)
return 1;
return i;
}
set
{
this.SetValByKey(MapAttrAttr.ColSpan, value);
}
}
///
/// 默认值
///
public string DefVal
{
get
{
string s = this.GetValStrByKey(MapAttrAttr.DefVal);
if (this.IsNum)
{
if (s == "")
return "0";
}
switch (this.MyDataType)
{
case DataType.AppDate:
if (this.Tag == "1" || s == "@RDT")
return DataType.CurrentDate;
else
return " ";
break;
case DataType.AppDateTime:
if (this.Tag == "1" || s == "@RDT")
return DataType.CurrentDateTime;
else
return " ";
//return " - - : ";
break;
default:
break;
}
if (s.Contains("@") == false)
return s;
switch (s.ToLower())
{
case "@webuser.no":
return BP.Web.WebUser.No;
case "@webuser.name":
return BP.Web.WebUser.Name;
case "@webuser.fk_dept":
return BP.Web.WebUser.FK_Dept;
case "@webuser.fk_deptname":
return BP.Web.WebUser.FK_DeptName;
case "@webuser.fk_deptfullname":
return BP.Web.WebUser.FK_DeptNameOfFull;
case "@fk_ny":
return DataType.CurrentYearMonth;
case "@fk_nd":
return DataType.CurrentYear;
case "@fk_yf":
return DataType.CurrentMonth;
case "@rdt":
if (this.MyDataType == DataType.AppDate)
return DataType.CurrentDate;
else
return DataType.CurrentDateTime;
case "@rd":
if (this.MyDataType == DataType.AppDate)
return DataType.CurrentDate;
else
return DataType.CurrentDateTime;
case "@yyyy年MM月dd日":
return DataType.CurrentDateCNOfLong;
case "@yyyy年MM月dd日hh时mm分":
return DateTime.Now.ToString("yyyy年MM月dd日HH时mm分");
case "@yy年MM月dd日":
return DataType.CurrentDateCNOfShort;
case "@yy年MM月dd日hh时mm分":
return DateTime.Now.ToString("yy年MM月dd日HH时mm分");
default:
return s;
//throw new Exception("没有约定的变量默认值类型" + s);
}
return this.GetValStrByKey(MapAttrAttr.DefVal);
}
set
{
this.SetValByKey(MapAttrAttr.DefVal, value);
}
}
public void setDefVal(object val)
{
this.GetValStrByKey(MapAttrAttr.DefVal, val.ToString());
}
public bool DefValOfBool
{
get
{
return this.GetValBooleanByKey(MapAttrAttr.DefVal, false);
}
}
///
/// 字段
///
public string Field
{
get
{
return this.KeyOfEn;
}
}
public int MyDataType
{
get
{
return this.GetValIntByKey(MapAttrAttr.MyDataType);
}
set
{
this.SetValByKey(MapAttrAttr.MyDataType, value);
}
}
public void setMyDataType(int val)
{
this.SetValByKey(MapAttrAttr.MyDataType, val);
}
public string MyDataTypeS
{
get
{
switch (this.MyDataType)
{
case DataType.AppString:
return "String";
case DataType.AppInt:
return "Int";
case DataType.AppFloat:
return "Float";
case DataType.AppMoney:
return "Money";
case DataType.AppDate:
return "Date";
case DataType.AppDateTime:
return "DateTime";
case DataType.AppBoolean:
return "Bool";
default:
throw new Exception("没有判断。");
}
}
set
{
switch (value)
{
case "String":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppString);
break;
case "Int":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppInt);
break;
case "Float":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppFloat);
break;
case "Money":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppMoney);
break;
case "Date":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppDate);
break;
case "DateTime":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppDateTime);
break;
case "Bool":
this.SetValByKey(MapAttrAttr.MyDataType, DataType.AppBoolean);
break;
default:
throw new Exception("sdsdsd");
}
}
}
public string MyDataTypeStr
{
get
{
return DataType.GetDataTypeDese(this.MyDataType);
}
}
///
/// 最大长度
///
public int MaxLen
{
get
{
switch (this.MyDataType)
{
case DataType.AppDate:
return 100;
case DataType.AppDateTime:
return 100;
default:
break;
}
int i = this.GetValIntByKey(MapAttrAttr.MaxLen);
if (i > 4000)
i = 4000;
if (i == 0)
return 50;
return i;
}
}
public void setMaxLen(int val)
{
this.SetValByKey(MapAttrAttr.MaxLen, val);
}
///
/// 最小长度
///
public int MinLen
{
get
{
return this.GetValIntByKey(MapAttrAttr.MinLen);
}
}
public void setMinLen(int val)
{
this.SetValByKey(MapAttrAttr.MinLen, val);
}
///
/// 是否可以为空, 对数值类型的数据有效.
///
public bool IsNull
{
get
{
if (this.MinLen == 0)
return false;
else
return true;
}
}
///
/// 所在的分组
///
public int GroupID
{
get
{
string str = this.GetValStringByKey(MapAttrAttr.GroupID);
if (str == "无" || str == "")
return 1;
return int.Parse(str);
}
set
{
this.SetValByKey(MapAttrAttr.GroupID, value);
}
}
public void setGroupID(int val)
{
this.SetValByKey(MapAttrAttr.GroupID, val);
}
///
/// 是否是大块文本?
///
public bool IsBigDoc
{
get
{
if (this.UIRows > 1 && this.MyDataType == DataType.AppString)
return true;
//if (this.ColSpan == 4 && this.MyDataType == DataType.AppString)
// return true;
return false;
}
}
///
/// textbox控件的行数.
///
public int UIRows
{
get
{
if (this.UIHeight < 40)
return 1;
decimal d = decimal.Parse(this.UIHeight.ToString()) / 23;
return (int)Math.Round(d, 0);
}
}
///
/// 高度
///
public int UIHeightInt
{
get
{
return (int)this.UIHeight;
}
set
{
this.UIHeight = value;
}
}
///
/// 高度
///
public float UIHeight
{
get
{
return this.GetValFloatByKey(MapAttrAttr.UIHeight);
}
set
{
this.SetValByKey(MapAttrAttr.UIHeight, value);
}
}
public void setUIHeight(float val)
{
this.SetValByKey(MapAttrAttr.UIHeight, val);
}
///
/// 宽度
///
public int UIWidthInt
{
get
{
return (int)this.UIWidth;
}
}
///
/// 宽度
///
public float UIWidth
{
get
{
return this.GetValFloatByKey(MapAttrAttr.UIWidth);
}
set
{
this.SetValByKey(MapAttrAttr.UIWidth, value);
}
}
public void setUIWidth(float val)
{
this.SetValByKey(MapAttrAttr.UIWidth, val);
}
public int UIWidthOfLab
{
get
{
return 0;
}
}
///
/// 是否是否可见?
///
public bool UIVisible
{
get
{
return this.GetValBooleanByKey(MapAttrAttr.UIVisible);
}
set
{
this.SetValByKey(MapAttrAttr.UIVisible, value);
}
}
public void setUIVisible(bool val)
{
this.SetValByKey(MapAttrAttr.UIVisible, val);
}
///
/// 是否可用
///
public bool UIIsEnable
{
get
{
return this.GetValBooleanByKey(MapAttrAttr.UIIsEnable);
}
}
public void setUIIsEnable(bool val)
{
this.SetValByKey(MapAttrAttr.UIIsEnable, val);
}
///
/// 是否单独行显示
///
public bool UIIsLine
{
get
{
return this.GetValBooleanByKey(MapAttrAttr.UIIsLine);
}
set
{
this.SetValByKey(MapAttrAttr.UIIsLine, value);
}
}
public void setUIIsLine(bool val)
{
this.SetValByKey(MapAttrAttr.UIIsLine, val);
}
///
/// 是否数字签名
///
public bool IsSigan
{
get
{
if (this.UIIsEnable)
return false;
return this.GetValBooleanByKey(MapAttrAttr.IsSigan);
}
set
{
this.SetValByKey(MapAttrAttr.IsSigan, value);
}
}
///
/// 签名类型
///
public SignType SignType
{
get
{
//if (this.UIIsEnable)
// return SignType.None;
return (SignType)this.GetValIntByKey(MapAttrAttr.IsSigan);
}
set
{
this.SetValByKey(MapAttrAttr.IsSigan, (int)value);
}
}
public int Para_FontSize
{
get
{
return this.GetParaInt(MapAttrAttr.FontSize);
}
set
{
this.SetPara(MapAttrAttr.FontSize, value);
}
}
///
/// radiobutton的展现方式
///
public int RBShowModel
{
get
{
return this.GetParaInt("RBShowModel");
}
set
{
this.SetPara("RBShowModel", value);
}
}
public void setRBShowModel(int val)
{
this.SetPara("RBShowModel", val);
}
///
/// 操作提示
///
public string Para_Tip
{
get
{
return this.GetParaString(MapAttrAttr.Tip);
}
set
{
this.SetPara(MapAttrAttr.Tip, value);
}
}
///
/// 是否数字签名
///
public string Para_SiganField
{
get
{
if (this.UIIsEnable)
return "";
return this.GetParaString(MapAttrAttr.SiganField);
}
set
{
this.SetPara(MapAttrAttr.SiganField, value);
}
}
///
/// 签名类型
///
public PicType PicType
{
get
{
if (this.UIIsEnable)
return PicType.Auto;
return (PicType)this.GetParaInt(MapAttrAttr.PicType);
}
set
{
this.SetPara(MapAttrAttr.PicType, (int)value);
}
}
///
/// TextBox类型
///
public TBModel TBModel
{
get
{
return (TBModel)this.GetParaInt(MapAttrAttr.TBModel);
}
set
{
this.SetPara(MapAttrAttr.TBModel, (int)value);
}
}
///
/// 绑定的值
///
public string UIBindKey
{
get
{
return this.GetValStrByKey(MapAttrAttr.UIBindKey);
}
set
{
string val = BP.Sys.Base.Glo.DealClassEntityName(value);
this.SetValByKey(MapAttrAttr.UIBindKey, val);
}
}
public void setUIBindKey(string val)
{
string myval = BP.Sys.Base.Glo.DealClassEntityName(val);
this.SetValByKey(MapAttrAttr.UIBindKey, myval);
}
///
/// 关联的表的Key
///
public string UIRefKey
{
get
{
string s = this.GetValStrByKey(MapAttrAttr.UIRefKey);
if (DataType.IsNullOrEmpty(s) == true)
s = "No";
return s;
}
set
{
this.SetValByKey(MapAttrAttr.UIRefKey, value);
}
}
///
/// 关联的表的Lab
///
public string UIRefKeyText
{
get
{
string s = this.GetValStrByKey(MapAttrAttr.UIRefKeyText);
if (DataType.IsNullOrEmpty(s) == true)
s = "Name";
return s;
}
set
{
this.SetValByKey(MapAttrAttr.UIRefKeyText, value);
}
}
///
/// 标识
///
public string Tag
{
get
{
return this.GetValStrByKey(MapAttrAttr.Tag);
}
set
{
this.SetValByKey(MapAttrAttr.Tag, value);
}
}
///
/// 控件类型
///
public UIContralType UIContralType
{
get
{
return (UIContralType)this.GetValIntByKey(MapAttrAttr.UIContralType);
}
set
{
this.SetValByKey(MapAttrAttr.UIContralType, (int)value);
}
}
public void setUIContralType(UIContralType val)
{
this.SetValByKey(MapAttrAttr.UIContralType, (int)val);
}
///
/// TabIdx
///
public int TabIdx
{
get
{
return this.GetValIntByKey(MapAttrAttr.TabIdx);
}
set
{
this.SetValByKey(MapAttrAttr.TabIdx, value);
}
}
///
/// 序号
///
public int Idx
{
get
{
return this.GetValIntByKey(MapAttrAttr.Idx);
}
set
{
this.SetValByKey(MapAttrAttr.Idx, value);
}
}
public void setIdx(int val)
{
this.SetValByKey(MapAttrAttr.Idx, val);
}
#endregion
#region 构造方法b
///
/// 实体属性
///
public MapAttr()
{
}
public MapAttr(string mypk)
{
this.setMyPK(mypk);
this.Retrieve();
}
public MapAttr(string fk_mapdata, string key)
{
this.SetValByKey(MapAttrAttr.FK_MapData, fk_mapdata);
this.SetValByKey(MapAttrAttr.KeyOfEn, key);
this.Retrieve(MapAttrAttr.FK_MapData, this.FK_MapData, MapAttrAttr.KeyOfEn, this.KeyOfEn);
}
///
/// EnMap
///
public override Map EnMap
{
get
{
if (this._enMap != null)
return this._enMap;
Map map = new Map("Sys_MapAttr", "实体属性");
map.AddMyPK();
map.AddTBString(MapAttrAttr.FK_MapData, null, "实体标识", true, true, 1, 100, 20);
map.AddTBString(MapAttrAttr.KeyOfEn, null, "属性", true, true, 1, 200, 20);
map.AddTBString(MapAttrAttr.Name, null, "描述", true, false, 0, 200, 20);
map.AddTBString(MapAttrAttr.DefVal, null, "默认值", false, false, 0, 400, 20);
map.AddTBInt(MapAttrAttr.DefValType, 1, "默认值类型", true, false);
map.AddTBInt(MapAttrAttr.UIContralType, 0, "控件", true, false);
map.AddTBInt(MapAttrAttr.MyDataType, 1, "数据类型", true, false);
map.AddDDLSysEnum(MapAttrAttr.LGType, 0, "逻辑类型", true, false, MapAttrAttr.LGType,
"@0=普通@1=枚举@2=外键@3=打开系统页面");
map.AddTBFloat(MapAttrAttr.UIWidth, 100, "宽度", true, false);
map.AddTBFloat(MapAttrAttr.UIHeight, 23, "高度", true, false);
map.AddTBInt(MapAttrAttr.MinLen, 0, "最小长度", true, false);
map.AddTBInt(MapAttrAttr.MaxLen, 300, "最大长度", true, false);
map.AddTBString(MapAttrAttr.UIBindKey, null, "绑定的信息", true, false, 0, 100, 20);
map.AddTBString(MapAttrAttr.UIRefKey, null, "绑定的Key", true, false, 0, 30, 20);
map.AddTBString(MapAttrAttr.UIRefKeyText, null, "绑定的Text", true, false, 0, 30, 20);
map.AddTBInt(MapAttrAttr.ExtIsSum, 0, "是否显示合计(对从表有效)", true, true);
map.AddTBInt(MapAttrAttr.UIVisible, 1, "是否可见", true, true);
map.AddTBInt(MapAttrAttr.UIIsEnable, 1, "是否启用", true, true);
map.AddTBInt(MapAttrAttr.UIIsLine, 0, "是否单独栏显示", true, true);
map.AddTBInt(MapAttrAttr.UIIsInput, 0, "是否必填字段", true, true);
map.AddTBInt(MapAttrAttr.TextModel, 0, "TextModel", true, true);
map.AddTBInt(MapAttrAttr.IsSupperText, 0, "是否是大文本", true, true);
map.AddTBInt(MapAttrAttr.FontSize, 0, "字体大小", true, true);
// 是否是签字,操作员字段有效。2010-09-23 增加。 @0=无@1=图片签名@2=CA签名.
map.AddTBInt(MapAttrAttr.IsSigan, 0, "签字?", true, false);
map.AddTBString(MapAttrAttr.GUID, null, "GUID", true, false, 0, 128, 20);
map.AddTBInt(MapAttrAttr.EditType, 0, "编辑类型", true, false);
map.AddTBString(MapAttrAttr.Tag, null, "标识", true, false, 0, 100, 20);
map.AddTBString(MapAttrAttr.Tag1, null, "标识1", true, false, 0, 100, 20);
map.AddTBString(MapAttrAttr.Tag2, null, "标识2", true, false, 0, 100, 20);
map.AddTBString(MapAttrAttr.Tag3, null, "标识3", true, false, 0, 100, 20);
map.AddTBString(MapAttrAttr.Tip, null, "激活提示", false, true, 0, 200, 20);
//单元格数量。2013-07-24 增加。
// map.AddTBString(MapAttrAttr.ColSpan, "1", "单元格数量", true, false, 0, 3, 3);
map.AddTBInt(MapAttrAttr.ColSpan, 1, "单元格数量", true, false);
//文本占单元格数量
map.AddTBInt(MapAttrAttr.LabelColSpan, 1, "文本单元格数量", true, false);
//文本跨行
map.AddTBInt(MapAttrAttr.RowSpan, 1, "行数", true, false);
//显示的分组.
map.AddTBString(MapAttrAttr.GroupID, null, "显示的分组", false, true, 0, 20, 20);
map.AddBoolean(MapAttrAttr.IsEnableInAPP, true, "是否在移动端中显示", true, true);
// xxx 新增的样式.
map.AddTBString(MapAttrAttr.CSSCtrl, "0", "CSSCtrl自定义样式", true, false, 0, 50, 20);
map.AddTBString(MapAttrAttr.CSSLabel, "0", "CSSLabel标签样式", true, false, 0, 50, 20);
map.AddTBInt(MapAttrAttr.Idx, 0, "序号", true, false);
map.AddTBString(MapAttrAttr.ICON, "0", "ICON", true, false, 0, 50, 20);
//参数属性.
map.AddTBAtParas(4000); //
map.AddLang(); //增加多语言.
this._enMap = map;
return this._enMap;
}
}
#endregion
///
/// 移动插入
///
///
///
public string InsertTo(string insertPK)
{
this.DoOrderInsertTo("Idx", insertPK, MapAttrAttr.GroupID);
return "执行成功.";
}
///
/// 保存大块html文本
///
///
public string SaveBigNoteHtmlText(string text)
{
string file = BP.Difference.SystemConfig.PathOfDataUser + "CCForm/BigNoteHtmlText/" + this.FK_MapData + ".htm";
//若文件夹不存在,则创建
string folder = System.IO.Path.GetDirectoryName(file);
if (System.IO.Directory.Exists(folder) == false)
System.IO.Directory.CreateDirectory(folder);
DataType.WriteFile(file, text);
return "保存成功!";
}
//删除大块文本信息
public string DeleteBigNoteHtmlText()
{
string file = BP.Difference.SystemConfig.PathOfDataUser + "CCForm/BigNoteHtmlText/" + this.FK_MapData + ".htm";
if (System.IO.File.Exists(file) == true)
System.IO.File.Delete(file);
this.Delete();
return "删除成功!";
}
///
/// 读取大块html文本
///
///
public string ReadBigNoteHtmlText()
{
string doc = "";
string file = BP.Difference.SystemConfig.PathOfDataUser + "CCForm/BigNoteHtmlText/" + this.FK_MapData + ".htm";
string folder = System.IO.Path.GetDirectoryName(file);
if (System.IO.Directory.Exists(folder) != false)
{
if (File.Exists(file))
{
doc = DataType.ReadTextFile(file);
}
}
return doc;
}
public void DoDownTabIdx()
{
this.DoOrderDown(MapAttrAttr.FK_MapData, this.FK_MapData, MapAttrAttr.Idx);
}
public void DoUpTabIdx()
{
this.DoOrderUp(MapAttrAttr.FK_MapData, this.FK_MapData, MapAttrAttr.Idx);
}
public string DoUp()
{
this.DoOrderUp(MapAttrAttr.GroupID, this.GroupID.ToString(), MapAttrAttr.Idx);
MapAttr attr = new MapAttr();
attr.setMyPK(this.FK_MapData + "_Title");
if (attr.RetrieveFromDBSources() == 1)
{
// attr.Idx = -1;
attr.Update("Idx", -1);
}
return "执行成功";
}
//字段插队
public string DoInsertTo(string entityPK)
{
this.DoOrderInsertTo(MapAttrAttr.Idx, entityPK, MapAttrAttr.GroupID);
MapAttr attr = new MapAttr();
attr.setMyPK(this.FK_MapData + "_Title");
if (attr.RetrieveFromDBSources() == 1)
{
attr.Update("Idx", -1);
}
return "执行成功!";
}
///
/// 生成他的外键字典数据,转化为json.
///
///
public string GenerHisFKData()
{
SFTable sf = new SFTable(this.UIBindKey);
return BP.Tools.Json.ToJson(sf.GenerHisDataTable());
}
///
/// 下移
///
public string DoDown()
{
this.DoOrderDown(MapAttrAttr.GroupID, this.GroupID.ToString(), MapAttrAttr.Idx);
MapAttr attr = new MapAttr();
attr.setMyPK(this.FK_MapData + "_Title");
if (attr.RetrieveFromDBSources() == 1)
{
attr.Update("Idx", -1);
}
return "执行成功";
}
///
/// 上移for 明细表.
///
public string DoUpForMapDtl()
{
//规整groupID.
GroupField gf = new GroupField();
gf.Retrieve(GroupFieldAttr.FrmID, this.FK_MapData);
DBAccess.RunSQL("UPDATE Sys_MapAttr SET GroupID=" + gf.OID + " WHERE FK_MapData='" + this.FK_MapData + "'");
this.DoOrderUp(MapAttrAttr.FK_MapData, this.FK_MapData, MapAttrAttr.UIVisible, "1", MapAttrAttr.Idx);
MapAttr attr = new MapAttr();
attr.setMyPK(this.FK_MapData + "_Title");
if (attr.RetrieveFromDBSources() == 1)
{
// attr.Idx = -1;
attr.Update("Idx", -1);
}
return "执行成功";
}
///
/// 下移 for 明细表.
///
public string DoDownForMapDtl()
{
//规整groupID.
GroupField gf = new GroupField();
gf.Retrieve(GroupFieldAttr.FrmID, this.FK_MapData);
DBAccess.RunSQL("UPDATE Sys_MapAttr SET GroupID=" + gf.OID + " WHERE FK_MapData='" + this.FK_MapData + "'");
this.DoOrderDown(MapAttrAttr.FK_MapData, this.FK_MapData, MapAttrAttr.UIVisible, "1", MapAttrAttr.Idx);
MapAttr attr = new MapAttr();
attr.setMyPK(this.FK_MapData + "_Title");
if (attr.RetrieveFromDBSources() == 1)
{
attr.Update("Idx", -1);
}
return "执行成功";
}
public void DoJump(MapAttr attrTo)
{
if (attrTo.Idx <= this.Idx)
this.DoJumpUp(attrTo);
else
this.DoJumpDown(attrTo);
}
private string DoJumpUp(MapAttr attrTo)
{
string sql = "UPDATE Sys_MapAttr SET Idx=Idx+1 WHERE Idx <=" + attrTo.Idx + " AND FK_MapData='" + this.FK_MapData + "' AND GroupID=" + this.GroupID;
DBAccess.RunSQL(sql);
this.Idx = attrTo.Idx - 1;
this.SetValByKey(MapAttrAttr.GroupID, attrTo.GroupID);
this.Update();
return null;
}
private string DoJumpDown(MapAttr attrTo)
{
string sql = "UPDATE Sys_MapAttr SET Idx=Idx-1 WHERE Idx <=" + attrTo.Idx + " AND FK_MapData='" + this.FK_MapData + "' AND GroupID=" + this.GroupID;
DBAccess.RunSQL(sql);
this.Idx = attrTo.Idx + 1;
this.SetValByKey(MapAttrAttr.GroupID, attrTo.GroupID);
this.Update();
return null;
}
protected override bool beforeUpdateInsertAction()
{
//if (this.LGType == FieldTypeS.Normal)
// if (this.UIIsEnable == true &&this.DefVal !=null && this.DefVal.Contains("@") == true)
// throw new Exception("@不能在非只读(不可编辑)的字段设置具有@的默认值. 您设置的默认值为:" + this.DefVal);
//if (this.UIContralType == En.UIContralType.DDL && this.LGType == FieldTypeS.Normal)
//added by liuxc,2016-12-2
//判断当前属性是否有分组,没有分组,则自动创建一个分组,并关联
if (this.GroupID.ToString() == "1")
{
//查找分组,查找到的第一个分组,关联当前属性
GroupField group = new GroupField();
if (group.Retrieve(GroupFieldAttr.FrmID, this.FK_MapData) > 0)
{
this.SetValByKey(MapAttrAttr.GroupID, group.OID);
}
else
{
group.FrmID = this.FK_MapData;
group.Lab = "基础信息";
group.Idx = 1;
group.Insert();
this.SetValByKey(MapAttrAttr.GroupID, group.OID);
}
}
if (this.LGType == FieldTypeS.Enum && this.UIContralType == UIContralType.RadioBtn)
{
string sql = "UPDATE Sys_FrmRB SET UIIsEnable=" + this.GetValIntByKey(MapAttrAttr.UIIsEnable) + " WHERE FK_MapData='" + this.FK_MapData + "' AND KeyOfEn='" + this.KeyOfEn + "'";
DBAccess.RunSQL(sql);
}
//为日期类型固定宽度.
if (this.MyDataType == DataType.AppDate)
this.UIWidth = 125;
if (this.MyDataType == DataType.AppDateTime)
this.UIWidth = 165;
if(this.MyDataType == DataType.AppString)
{
MapAttr attr = new MapAttr();
attr.setMyPK(this.MyPK);
attr.RetrieveFromDBSources();
if (this.TextModel == 2 || this.TextModel == 3)
{
//attr.setMaxLen(4000);
this.SetValByKey(MapAttrAttr.MaxLen, 4000);
}
//自动扩展字段长度. 需要翻译.
if (attr.MaxLen < this.MaxLen && DataType.IsNullOrEmpty(this.Field)==false)
{
string sql = "";
MapData md = new MapData();
md.No = this.FK_MapData;
if (md.RetrieveFromDBSources() == 1)
{
if (DBAccess.IsExitsTableCol(md.PTable, this.KeyOfEn) == true)
{
switch (BP.Difference.SystemConfig.AppCenterDBType)
{
case DBType.MSSQL:
sql = "ALTER TABLE " + md.PTable + " ALTER column " + this.Field + " NVARCHAR(" + this.MaxLen + ")";
break;
case DBType.MySQL:
sql = "ALTER table " + md.PTable + " modify " + this.Field + " NVARCHAR(" + this.MaxLen + ")";
break;
case DBType.Oracle:
case DBType.DM:
sql = "ALTER table " + md.PTable + " modify " + this.Field + " VARCHAR2(" + this.MaxLen + ")";
break;
case DBType.KingBaseR3:
case DBType.KingBaseR6:
sql = "ALTER table " + md.PTable + " ADD COLUMN " + this.Field + " Type NVARCHAR2(" + this.MaxLen + ")";
break;
case DBType.PostgreSQL:
case DBType.UX:
sql = "ALTER table " + md.PTable + " alter " + this.Field + " type character varying(" + this.MaxLen + ")";
break;
default:
throw new Exception("err@没有判断的数据库类型.");
}
DBAccess.RunSQL(sql); //如果是oracle如果有nvarchar与varchar类型,就会出错.
}
}
}
}
return base.beforeUpdateInsertAction();
}
protected override bool beforeUpdate()
{
switch (this.MyDataType)
{
case DataType.AppDateTime:
this.SetValByKey(MapAttrAttr.MaxLen, 20);
break;
case DataType.AppDate:
this.SetValByKey(MapAttrAttr.MaxLen, 10);
break;
default:
break;
}
if (string.IsNullOrWhiteSpace(this.KeyOfEn))
this.setMyPK(this.FK_MapData);
else
this.setMyPK(this.FK_MapData + "_" + this.KeyOfEn);
return base.beforeUpdate();
}
///
/// 插入之间需要做的事情.
///
///
protected override bool beforeInsert()
{
if (DataType.IsNullOrEmpty(this.Name))
throw new Exception("@请输入字段名称。");
if (this.KeyOfEn == null || this.KeyOfEn.Trim() == "")
{
try
{
this.SetValByKey(MapAttrAttr.KeyOfEn, CCFormAPI.ParseStringToPinyinField(this.Name, true, true, 100));
if (this.KeyOfEn.Length > 20)
this.SetValByKey(MapAttrAttr.KeyOfEn, CCFormAPI.ParseStringToPinyinField(this.Name, false, true, 20));
if (this.KeyOfEn == null || this.KeyOfEn.Trim() == "")
throw new Exception("@请输入字段描述或者字段名称。");
}
catch (Exception ex)
{
throw new Exception("@请输入字段描述或字段名称,异常信息:" + ex.Message);
}
}
else
{
this.SetValByKey(MapAttrAttr.KeyOfEn, BP.Pub.PubClass.DealToFieldOrTableNames(this.KeyOfEn));
}
string keyofenC = this.KeyOfEn.Clone() as string;
keyofenC = keyofenC.ToLower();
string keyFields = PubClass.KeyFields;
if (keyFields != null && keyFields.Contains("," + keyofenC + ",") == true)
throw new Exception("@错误:[" + this.KeyOfEn + "]是字段关键字,您不能用它做字段。");
if (this.IsExit(MapAttrAttr.KeyOfEn, this.KeyOfEn,
MapAttrAttr.FK_MapData, this.FK_MapData))
{
return false;
throw new Exception("@在[" + this.MyPK + "]已经存在字段名称[" + this.Name + "]字段[" + this.KeyOfEn + "]");
}
if (this.Idx == 0)
this.Idx = DBAccess.RunSQLReturnValInt("SELECT MAX(Idx) FROM Sys_MapAttr WHERE FK_MapData='" + this.FK_MapData + "'", 0) + 1;
//
if (this.GroupID == 0)
this.GroupID = DBAccess.RunSQLReturnValInt("SELECT MAX(GroupID) FROM Sys_MapAttr WHERE FK_MapData='" + this.FK_MapData + "'", 0);
this.setMyPK(this.FK_MapData + "_" + this.KeyOfEn);
return base.beforeInsert();
}
protected override void afterInsert()
{
if (this.KeyOfEn.Equals("Tel") || this.Name.Contains("电话") || this.Name.Contains("手机"))
{
DBAccess.RunSQL("UPDATE Sys_MapAttr SET ICON='icon-phone' WHERE MyPK='" + this.MyPK + "'");
}
else if (this.KeyOfEn.Contains("Email") || this.Name.Contains("邮件") || this.Name.Contains("手机"))
{
DBAccess.RunSQL("UPDATE Sys_MapAttr SET ICON='icon-envelope-letter' WHERE MyPK='" + this.MyPK + "'");
}
else if (this.KeyOfEn.Contains("Addr") || this.Name.Contains("地址"))
{
DBAccess.RunSQL("UPDATE Sys_MapAttr SET ICON='icon-location-pin' WHERE MyPK='" + this.MyPK + "'");
}
else if (this.MyDataType == DataType.AppMoney)
{
DBAccess.RunSQL("UPDATE Sys_MapAttr SET ICON='fa-cny' WHERE MyPK='" + this.MyPK + "'");
}
base.afterInsert();
}
protected override void afterUpdate()
{
//调用frmEditAction, 完成其他的操作.
BP.Sys.CCFormAPI.AfterFrmEditAction(this.FK_MapData);
base.afterUpdate();
}
///
/// 删除之前
///
///
protected override bool beforeDelete()
{
string sqls = "DELETE FROM Sys_MapExt WHERE (AttrOfOper='" + this.KeyOfEn + "' OR AttrsOfActive='" + this.KeyOfEn + "' ) AND (FK_MapData='" + this.FK_MapData + "')";
//删除权限管理字段.
sqls += "@DELETE FROM Sys_FrmSln WHERE KeyOfEn='" + this.KeyOfEn + "' AND FK_MapData='" + this.FK_MapData + "'";
//如果外部数据,或者ws数据,就删除其影子字段.
if (this.UIContralType == UIContralType.DDL && this.LGType == FieldTypeS.Normal)
sqls += "@DELETE FROM Sys_MapAttr WHERE KeyOfEn='" + this.KeyOfEn + "T' AND FK_MapData='" + this.FK_MapData + "'";
DBAccess.RunSQLs(sqls);
return base.beforeDelete();
}
protected override void afterDelete()
{
if (this.UIContralType == UIContralType.AthShow)
{
//删除附件
FrmAttachment ath = new FrmAttachment();
ath.setMyPK(this.MyPK);
ath.Delete();
}
base.afterDelete();
}
}
///
/// 实体属性s
///
public class MapAttrs : EntitiesMyPK
{
#region 构造
///
/// 实体属性s
///
public MapAttrs()
{
}
///
/// 实体属性s
///
public MapAttrs(string frmID)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(MapAttrAttr.FK_MapData, frmID);
qo.addOrderBy(MapAttrAttr.Idx);
qo.DoQuery();
}
public int SearchMapAttrsYesVisable(string fk_map)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(MapAttrAttr.FK_MapData, fk_map);
qo.addAnd();
qo.AddWhere(MapAttrAttr.UIVisible, 1);
qo.addOrderBy(MapAttrAttr.Idx);
// qo.addOrderBy(MapAttrAttr.Idx);
return qo.DoQuery();
}
///
/// 查询日期+日期时间类型的
/// 代码移动.
///
///
///
public string SearchMapAttrsDateAndDateTime(string fk_map)
{
QueryObject qo = new QueryObject(this);
qo.AddWhere(MapAttrAttr.FK_MapData, fk_map);
qo.addAnd();
qo.AddWhere(MapAttrAttr.MyDataType, " IN ", "(6,7)");
qo.addOrderBy(MapAttrAttr.Idx);
qo.DoQuery();
return this.ToJson();
}
///
/// 得到它的 Entity
///
public override Entity GetNewEntity
{
get
{
return new MapAttr();
}
}
public int WithOfCtl
{
get
{
int i = 0;
foreach (MapAttr item in this)
{
if (item.UIVisible == false)
continue;
i += item.UIWidthInt;
}
return i;
}
}
#endregion
#region 业务方法.
#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((MapAttr)this[i]);
}
return list;
}
#endregion 为了适应自动翻译成java的需要,把实体转换成List.
}
}