@{ string className=Model.tabname +"Info"; string tabname=(Model.tabname.Trim()==string.Empty)?"请输入表名称!":Model.tabname; className = className.Substring(0, 1).ToUpper() + className.Substring(1); }
实体类:
using System; using PlugNT.Cms.Custom; namespace PlugNT.Cms.Model { [Table("@Model.tabname", Key_Flags.NoPrefix)] public class @(className) { @foreach(DataRow row in Model.dtList.Rows){ if(row["类型"].ToString().EndsWith("datetime")) { @: private DateTime _@(row["表列名"]); }else if(row["类型"].ToString().EndsWith("char")){ @: private string _@(row["表列名"]); } else if(row["类型"].ToString().EndsWith("numeric")){ @: private decimal _@(row["表列名"]); } else if(row["类型"].ToString().EndsWith("decimal")){ @: private decimal _@(row["表列名"]); } else if(row["类型"].ToString().EndsWith("float")){ @: private float _@(row["表列名"]); } else { @: private int _@(row["表列名"]); } } @foreach(DataRow row in Model.dtList.Rows){ if(row["value"].ToString().Trim()!=""){ @: ///
@: ///@(row["value"]) @: ///
} if(row["类型"].ToString().EndsWith("datetime")) { @: public DateTime @(row["表列名"]) }else if(row["类型"].ToString().EndsWith("char")){ @: public string @(row["表列名"]) } else if(row["类型"].ToString().EndsWith("numeric")){ @: public decimal @(row["表列名"]) } else if(row["类型"].ToString().EndsWith("decimal")){ @: public decimal @(row["表列名"]) } else if(row["类型"].ToString().EndsWith("float")){ @: public float @(row["表列名"]) } else{ @: public int @(row["表列名"]) } @: { @: get { return _@(row["表列名"]); } @: set { _@(row["表列名"])= value; } @: } } } }
添加表单:
@{int index=0;} @foreach(DataRow row in Model.dtList.Rows){ @if(index % 2==0){ @("
\n")
@(row["value"].ToString()+":")
}else{
@(row["value"].ToString()+":")
@("
\n") } index++; } @if(Model.dtList.Rows.Count % 2!=0){
@("
\n") } 修改表单:
@{index=0;} @foreach(DataRow row in Model.dtList.Rows){ if(index % 2==0){ @("
\n")
@(row["value"].ToString()+":")
}else{
@(row["value"].ToString()+":")
@("
\n") } index++; } @if(Model.dtList.Rows.Count % 2!=0){
@(" \n") }
表单列表:
@foreach(DataRow row in Model.dtList.Rows){
@(row["value"])
}
操作
@(" @foreach(DataRow row in Model.DtList.Rows){")
@foreach(DataRow row in Model.dtList.Rows){
@@row["@(row["表列名"])"]
}
编辑
删除
@(" }")