function jsEntity()
{

};
jsEntity.CreateEntity=function(BillInfoDataObject,_KeyField)
{
    var obj=new Object();
    var KeyField="ID";
    if(typeof(_KeyField)!="undefined")
    {
        KeyField=_KeyField;
    }
    var DataObj=null;
    var DataObjStruct=null;
    try
    {
        var strTableName=unescape(BillInfoDataObject.Fields("TableName").Value);
        var strGetDataSQLString=unescape(BillInfoDataObject.Fields("GetDataSQLString").Value)+" WHERE 1=2 ";
        DataObj=DBReader.selectSql(strGetDataSQLString,strTableName);
        
        if(DBReader.DObjectIsNull(DataObj)==false)
        {
            var GetStructSql="exec eOA_CMB_GetTableStruct '"+strTableName+"'";
            DataObjStruct=DBReader.selectSql(GetStructSql,"TableStruct");
            
            eval("obj.ItemEntityCount = 0;");
            eval("obj.TableName='"+strTableName+"';");
            var sbColumnGroup=new Array();
            var sbColumnSetGroup=new Array();
            var sbColumnGroupTemp=new Array();
            
            var fieldsCount=DataObj.Fields.Count;
            var TableColumnCount=DataObjStruct.RecordCount;
            
            for (var i=0;i<fieldsCount;i++)
            {
                var strDataType = "";
                var ColumnName=DataObj.Fields(i).Name;
                var FieldDataType=DataObj.Fields(i).Type;
                switch (FieldDataType)
                {
                    case 200:/*"varchar":*/
                    case 129:/*"char":*/
                    case 130:/*"nchar":*/
                    case 203:/*"ntext":*/
                    case 202:/*"nvarchar":*/
                    case 201:/*"text":*/
                        strDataType = "App.DataType.ftString";
                        break;
                    case 20:/*bigint*/
                    case 3:/*int*/
                        strDataType = "App.DataType.ftInteger";
                        break;
                    case 131:/*"decimal":*/
                    case 5:/*"float":*/
                    case 6:/*"money":*/
                        strDataType = "App.DataType.ftFloat";
                        break;
                    case 135:/*"datetime":*/
                        strDataType = "App.DataType.ftDateTime";
                        break;
                    case 11:/*"bit":*/
                        strDataType = "App.DataType.ftBoolean";
                        break;
                    case 204:/*"varbinary":*/
                    case 205:/*"image":*/
                        strDataType = "App.DataType.ftBytes";
                        break;
                    case 72:/*"uniqueidentifier":*/
                        strDataType = "App.DataType.ftGuid";
                        break;
                    default:
                        break;
                }
                
                var IsHaved=false;
                if(TableColumnCount>0)
                {
                    DataObjStruct.MoveFirst();
                }
                for(var n=0;n<TableColumnCount;n++)
                {
                    if(DataObjStruct.Fields("Column_name").Value==ColumnName)
                    {
                        IsHaved=true;
                        break;
                    }
                    DataObjStruct.MoveNext ();
                }
                var columnNametemp="";
                var columnGroupTemp="";
                var columnNameItems="";
                
                columnNameItems=ColumnName+":null";
                /*if (ColumnName == "id" || ColumnName == "ID" || IsHaved==true)*/
                if(ColumnName.toUpperCase()==KeyField.toUpperCase() || IsHaved==true)
                {
                    columnNametemp+="\""+ColumnName+"\"";
                    columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"column\"";
                }
                else
                {
                    columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"\"";
                }

                if (i < (parseInt(fieldsCount) - 1))
                {
                    columnNameItems+="|";
                    columnNametemp+=",";
                    columnGroupTemp+=",";
                }
                sbColumnGroup.push(columnNameItems);
                sbColumnSetGroup.push(columnNametemp);
                sbColumnGroupTemp.push(columnGroupTemp);
                columnNameItems=null;
                columnNametemp=null;
                columnGroupTemp=null;
                /*
//                if (i < (parseInt(fieldsCount) - 1))
//                {
//                    sbColumnGroup.push(ColumnName+":null|");

//                    if (ColumnName == "id" || ColumnName == "ID" || IsHaved==true)
//                    {
//                        sbColumnSetGroup.push("\""+ColumnName+"\",");
//                        sbColumnGroupTemp.push("\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"column\",");
//                    }
//                    else
//                    {
//                        sbColumnGroupTemp.push("\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"\",");
//                    }
//                }
//                else if (i == (parseInt(fieldsCount) - 1))
//                {
//                    sbColumnGroup.push(ColumnName+":null");

//                    if (ColumnName == "id" || ColumnName == "ID" || IsHaved==true)
//                    {
//                        sbColumnSetGroup.push("\""+ColumnName+"\"");
//                        sbColumnGroupTemp.push("\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"column\"");
//                    }
//                    else
//                    {
//                        sbColumnGroupTemp.push("\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"\"");
//                    }
//                }
*/
            }
            var ColumnsSetString="obj.ColumnsSet=["+sbColumnGroupTemp.join("")+"];";
            eval(ColumnsSetString);
            
            var strLinkFields=unescape(BillInfoDataObject.Fields("LinkFields").Value);
            var strLinkTableName=unescape(BillInfoDataObject.Fields("LinkTableName").Value);
            var LinkFieldsString="";
            if(strLinkTableName!="" && strLinkTableName!=null)
            {
                LinkFieldsString=strLinkFields+":\""+strLinkTableName+"\"+App.Config.split+\"ID\"";
            }
            eval("obj.LinkFields={"+LinkFieldsString+"};");
            
            var FieldsString="";
            var strColumnString=sbColumnGroup.join("");
            var arrColumn=strColumnString.split('|');
            for(var i=0;i<arrColumn.length;i++)
            {                
                if (i < (parseInt(arrColumn.length) - 1))
                {
                    FieldsString+=arrColumn[i]+",";
                }
                else if (i == (parseInt(arrColumn.length) - 1))
                {
                    FieldsString+=arrColumn[i];
                }
            }
            eval("obj.Fields={"+FieldsString+"};");
            
            eval("obj.KeyField=\""+KeyField+"\";");
            eval("obj.FieldsSet=["+sbColumnSetGroup.join("")+"];");
            eval("obj.Sort=\"\";");
            eval("obj.Where=\"\";");
            eval("obj.WhereValue=[];");
            eval("obj.WhereValueXML=\"\";");
            eval("obj.DataXML=\"\";");
            eval("obj.FieldXML=\"\";");
            eval("obj.ItemEntityFieldXML=\"\";");
            eval("obj.appendEntity=function(_entity,_Action){this.ItemEntityFieldXML+=DBReader.resolutionItemEntityXML(_entity,this.ItemEntityCount,this.TableName,_Action);this.ItemEntityFieldXML+=_entity.ItemEntityFieldXML;this.ItemEntityCount++;};");
            eval("obj.SelectOne=function(_entity){return DBReader.SelectOne(_entity);};");
            eval("obj.SelectList=function(_entity){return DBReader.prototype.SelectList(_entity);};");
            eval("obj.Insert=function(_entity){return DBReader.Insert(_entity);};");
            eval("obj.Update=function(_entity){return DBReader.Update(_entity);};");
            eval("obj.Delete=function(_entity){return DBReader.Delete(_entity);};");
            
            sbColumnGroupTemp=null;
            sbColumnGroup=null;
            sbColumnSetGroup=null;
        }
    }
    catch(e)
    {
        alert(e.message);
    }
    GetDataSql=null;
    DBReader.Dispose(DataObj);
    DBReader.Dispose(DataObjStruct);
    CollectGarbage();
    
    return obj;
};
jsEntity.FillEntity=function(_entity,strGetDataSQL)
{
    var DataObj=null;
    var strErrorFieldName="";
    try
    {
        DataObj=DBReader.selectSql(strGetDataSQL,"");
        if(DBReader.DObjectIsNull(DataObj)==false)
        {
            var fieldsCount=DataObj.Fields.Count;
            for (var n=0;n<fieldsCount;n++)
            {
                var ColumnName=DataObj.Fields(n).Name;
                strErrorFieldName=ColumnName;
                var FieldValue=DataObj.Fields(ColumnName).value;
                if(DataObj.Fields(n).Type==135)
                {
                    var dt=new Date(FieldValue);
                    FieldValue=dt.Format("yyyy-MM-dd hh:mm:ss");
                }
                var SetValueString="_entity.Fields."+ColumnName+"='"+(FieldValue!=null?FieldValue:'')+"';";
                eval(SetValueString);
            }
        }
    }
    catch(e)
    {
        alert(strErrorFieldName+":"+e.message);
    }
    CollectGarbage();
    DBReader.Dispose(DataObj);
};
/*根据表结构进行生成实体*/
/*
TableID：数据表ID
DataViewID：数据视图ID
*/
jsEntity.CreateEntityByStruct=function(TableID,DataViewID,LinkFields,LinkTableName,TableField,_KeyField)
{
    var obj=new Object();
    var KeyField="ID";
    if(typeof(_KeyField)!="undefined")
    {
        KeyField=_KeyField;
    }
    
    var DataObj=null;
    var DataObjStruct=null;
    try
    {
        var getTableDataSql="exec eOA_CMB_GetTableData 'eOA_cmbDataTable',' AND ID="+TableID+"','DataTableName'";
        var tableObj=DBReader.selectSql(getTableDataSql,"eOA_CMB_GetTableData");
        getTableDataSql=null;
        
        if(DBReader.DObjectIsNull(tableObj)==false && parseInt(tableObj.RecordCount)>0)
        {
            var strTableName=tableObj.Fields("DataTableName").Value;
            
            if(typeof(DataViewID)!="undefined" && DataViewID!="")
            {
                var DataViewObj=DBReader.selectSql("exec eOA_CMB_GetTableData 'eOA_cmbDataSource',' AND ID="+DataViewID+"','SQLContent'","eOA_CMB_GetTableData");

                if(DBReader.DObjectIsNull(DataViewObj)==false && parseInt(DataViewObj.RecordCount)>0)
                {
                    var strGetDataSQLString=unescape(DataViewObj.Fields("SQLContent").Value);/*+" WHERE 1=2 ";*/
/*                    alert(strGetDataSQLString);*/
                    DataObj=DBReader.selectSql(strGetDataSQLString,strTableName);
                    strGetDataSQLString=null;
                }
                DBReader.Dispose(DataViewObj);
            }
            else            
            {
                var strGetDataSQLString="select * from "+strTableName+" where 1=2";
                DataObj=DBReader.selectSql(strGetDataSQLString,strTableName);
                strGetDataSQLString=null;
            }
            
            if(DBReader.DObjectIsNull(DataObj)==false)
            {
                var GetStructSql="exec eOA_CMB_GetTableStruct '"+strTableName+"'";
                DataObjStruct=DBReader.selectSql(GetStructSql,"TableStruct");

                eval("obj.ItemEntityCount = 0;");
                eval("obj.TableName='"+strTableName+"';");
                var sbColumnGroup=new Array();
                var sbColumnSetGroup=new Array();
                var sbColumnGroupTemp=new Array();
                
                var fieldsCount=DataObj.Fields.Count;
                var TableColumnCount=DataObjStruct.RecordCount;
                
                for (var i=0;i<fieldsCount;i++)
                {
                    var strDataType = "";
                    var ColumnName=DataObj.Fields(i).Name;
                    var FieldDataType=DataObj.Fields(i).Type;
                    switch (FieldDataType)
                    {
                        case 200:/*"varchar":*/
                        case 129:/*"char":*/
                        case 130:/*"nchar":*/
                        case 203:/*"ntext":*/
                        case 202:/*"nvarchar":*/
                        case 201:/*"text":*/
                            strDataType = "App.DataType.ftString";
                            break;
                        case 20:/*bigint*/
                        case 3:/*int*/
                            strDataType = "App.DataType.ftInteger";
                            break;
                        case 131:/*"decimal":*/
                        case 5:/*"float":*/
                        case 6:/*"money":*/
                            strDataType = "App.DataType.ftFloat";
                            break;
                        case 135:/*"datetime":*/
                            strDataType = "App.DataType.ftDateTime";
                            break;
                        case 11:/*"bit":*/
                            strDataType = "App.DataType.ftBoolean";
                            break;
                        case 204:/*"varbinary":*/
                        case 205:/*"image":*/
                            strDataType = "App.DataType.ftBytes";
                            break;
                        case 72:/*"uniqueidentifier":*/
                            strDataType = "App.DataType.ftGuid";
                            break;
                        default:
                            break;
                    }
                    
                    var IsHaved=false;
                    if(TableColumnCount>0)
                    {
                        DataObjStruct.MoveFirst();
                    }
                    for(var n=0;n<TableColumnCount;n++)
                    {
                        if(DataObjStruct.Fields("Column_name").Value==ColumnName)
                        {
                            IsHaved=true;
                            break;
                        }
                        DataObjStruct.MoveNext ();
                    }
                    var columnNametemp="";
                    var columnGroupTemp="";
                    var columnNameItems="";
                    
                    columnNameItems=ColumnName+":null";
                    /*if (ColumnName == "id" || ColumnName == "ID" || IsHaved==true)*/
                    if(ColumnName.toUpperCase()==KeyField.toUpperCase() || IsHaved==true)
                    {
                        columnNametemp+="\""+ColumnName+"\"";
                        columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"column\"";
                    }
                    else
                    {
                        columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"\"";
                    }

                    if (i < (parseInt(fieldsCount) - 1))
                    {
                        columnNameItems+="|";
                        columnNametemp+=",";
                        columnGroupTemp+=",";
                    }
                    sbColumnGroup.push(columnNameItems);
                    sbColumnSetGroup.push(columnNametemp);
                    sbColumnGroupTemp.push(columnGroupTemp);
                    columnNameItems=null;
                    columnNametemp=null;
                    columnGroupTemp=null;
                }
                var ColumnsSetString="obj.ColumnsSet=["+sbColumnGroupTemp.join("")+"];";
                eval(ColumnsSetString);
                ColumnsSetString=null;
                
                var LinkFieldsString="";
                if(typeof(LinkFields)!="undefined" && typeof(LinkTableName)!="undefined"  && typeof(TableField)!="undefined" 
                && LinkFields!="" && LinkTableName!="" && TableField!="")
                {
                    LinkFieldsString=TableField+":\""+LinkTableName+"\"+App.Config.split+\""+LinkFields+"\"";
                }
                
                eval("obj.LinkFields={"+LinkFieldsString+"};");
                LinkFieldsString=null;
                
                var FieldsString="";
                var strColumnString=sbColumnGroup.join("");
                var arrColumn=strColumnString.split('|');
                for(var i=0;i<arrColumn.length;i++)
                {                
                    if (i < (parseInt(arrColumn.length) - 1))
                    {
                        FieldsString+=arrColumn[i]+",";
                    }
                    else if (i == (parseInt(arrColumn.length) - 1))
                    {
                        FieldsString+=arrColumn[i];
                    }
                }
                eval("obj.Fields={"+FieldsString+"};");
                FieldsString=null;
                
                eval("obj.KeyField=\""+KeyField+"\";");
                eval("obj.FieldsSet=["+sbColumnSetGroup.join("")+"];");
                eval("obj.Sort=\"\";");
                eval("obj.Where=\"\";");
                eval("obj.WhereValue=[];");
                eval("obj.WhereValueXML=\"\";");
                eval("obj.DataXML=\"\";");
                eval("obj.FieldXML=\"\";");
                eval("obj.ItemEntityFieldXML=\"\";");
                eval("obj.appendEntity=function(_entity,_Action){this.ItemEntityFieldXML+=DBReader.resolutionItemEntityXML(_entity,this.ItemEntityCount,this.TableName,_Action);this.ItemEntityFieldXML+=_entity.ItemEntityFieldXML;this.ItemEntityCount++;};");
                eval("obj.SelectOne=function(_entity){return DBReader.SelectOne(_entity);};");
                eval("obj.SelectList=function(_entity){return DBReader.prototype.SelectList(_entity);};");
                eval("obj.Insert=function(_entity){return DBReader.Insert(_entity);};");
                eval("obj.Update=function(_entity){return DBReader.Update(_entity);};");
                eval("obj.Delete=function(_entity){return DBReader.Delete(_entity);};");
                
                sbColumnGroupTemp=null;
                sbColumnGroup=null;
                sbColumnSetGroup=null;
            }
            
        }
        DBReader.Dispose(tableObj);
        GetDataSql=null;
    }
    catch(e)
    {
        alert(e.message);
    }
    DBReader.Dispose(DataObj);
    DBReader.Dispose(DataObjStruct);
    CollectGarbage();
    
    return obj;
};
jsEntity.FillEntityByDataViewID=function(_entity,DataViewID)
{
    var DataObj=null;
    var strErrorFieldName="";
    try
    {
        DataObj=DBReader.selectSql(strGetDataSQL,"");
        if(DBReader.DObjectIsNull(DataObj)==false)
        {
            var fieldsCount=DataObj.Fields.Count;
            for (var n=0;n<fieldsCount;n++)
            {
                var ColumnName=DataObj.Fields(n).Name;
                strErrorFieldName=ColumnName;
                var FieldValue=DataObj.Fields(ColumnName).value;
                if(DataObj.Fields(n).Type==135)
                {
                    var dt=new Date(FieldValue);
                    FieldValue=dt.Format("yyyy-MM-dd hh:mm:ss");
                }
                var SetValueString="_entity.Fields."+ColumnName+"='"+(FieldValue!=null?FieldValue:'')+"';";
                eval(SetValueString);
            }
        }
    }
    catch(e)
    {
        alert(strErrorFieldName+":"+e.message);
    }
    CollectGarbage();
    DBReader.Dispose(DataObj);
};
/*根据表名创建实体对象*/
jsEntity.CreateEntityByTableName=function(TableName,strSql,LinkFields,LinkTableName,TableField,_KeyField)
{
    var obj=new Object();
    
    var KeyField="ID";
    if(typeof(_KeyField)!="undefined")
    {
        KeyField=_KeyField;
    }
    var DataObj=null;
    var DataObjStruct=null;
    try
    {
        var strTableName=TableName;
        if(typeof(strSql)=="undefined" || strSql=="")
        {
            strSql="exec eOA_Sys_Select '"+TableName+"','*',' AND 1=2'";
        }
        var strGetDataSQLString=unescape(strSql);
        DataObj=DBReader.selectSql(strGetDataSQLString,strTableName);
        
        if(DBReader.DObjectIsNull(DataObj)==false)
        {
            var GetStructSql="exec eOA_CMB_GetTableStruct '"+strTableName+"'";
            DataObjStruct=DBReader.selectSql(GetStructSql,"TableStruct");
            
            eval("obj.ItemEntityCount = 0;");
            eval("obj.TableName='"+strTableName+"';");
            var sbColumnGroup=new Array();
            var sbColumnSetGroup=new Array();
            var sbColumnGroupTemp=new Array();
            
            var fieldsCount=DataObj.Fields.Count;
            var TableColumnCount=DataObjStruct.RecordCount;
            
            for (var i=0;i<fieldsCount;i++)
            {
                var strDataType = "";
                var ColumnName=DataObj.Fields(i).Name;
                var FieldDataType=DataObj.Fields(i).Type;
                switch (FieldDataType)
                {
                    case 200:/*"varchar":*/
                    case 129:/*"char":*/
                    case 130:/*"nchar":*/
                    case 203:/*"ntext":*/
                    case 202:/*"nvarchar":*/
                    case 201:/*"text":*/
                        strDataType = "App.DataType.ftString";
                        break;
                    case 20:/*bigint*/
                    case 3:/*int*/
                        strDataType = "App.DataType.ftInteger";
                        break;
                    case 131:/*"decimal":*/
                    case 5:/*"float":*/
                    case 6:/*"money":*/
                        strDataType = "App.DataType.ftFloat";
                        break;
                    case 135:/*"datetime":*/
                        strDataType = "App.DataType.ftDateTime";
                        break;
                    case 11:/*"bit":*/
                        strDataType = "App.DataType.ftBoolean";
                        break;
                    case 204:/*"varbinary":*/
                    case 205:/*"image":*/
                        strDataType = "App.DataType.ftBytes";
                        break;
                    case 72:/*"uniqueidentifier":*/
                        strDataType = "App.DataType.ftGuid";
                        break;
                    default:
                        break;
                }
                
                var IsHaved=false;
                if(TableColumnCount>0)
                {
                    DataObjStruct.MoveFirst();
                }
                for(var n=0;n<TableColumnCount;n++)
                {
                    if(DataObjStruct.Fields("Column_name").Value==ColumnName)
                    {
                        IsHaved=true;
                        break;
                    }
                    DataObjStruct.MoveNext ();
                }
                var columnNametemp="";
                var columnGroupTemp="";
                var columnNameItems="";
                
                columnNameItems=ColumnName+":null";
                /*if (ColumnName == "id" || ColumnName == "ID" || IsHaved==true)*/
                if(ColumnName.toUpperCase()==KeyField.toUpperCase() || IsHaved==true)
                {
                    columnNametemp+="\""+ColumnName+"\"";
                    columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"column\"";
                }
                else
                {
                    columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"\"";
                }

                if (i < (parseInt(fieldsCount) - 1))
                {
                    columnNameItems+="|";
                    columnNametemp+=",";
                    columnGroupTemp+=",";
                }
                sbColumnGroup.push(columnNameItems);
                sbColumnSetGroup.push(columnNametemp);
                sbColumnGroupTemp.push(columnGroupTemp);
                columnNameItems=null;
                columnNametemp=null;
                columnGroupTemp=null;
            }
            var ColumnsSetString="obj.ColumnsSet=["+sbColumnGroupTemp.join("")+"];";
            eval(ColumnsSetString);
            ColumnsSetString=null;
            
            var LinkFieldsString="";
            if(typeof(LinkFields)!="undefined" && typeof(LinkTableName)!="undefined"  && typeof(TableField)!="undefined" 
            && LinkFields!="" && LinkTableName!="" && TableField!="")
            {
                LinkFieldsString=TableField+":\""+LinkTableName+"\"+App.Config.split+\""+LinkFields+"\"";
            }
            eval("obj.LinkFields={"+LinkFieldsString+"};");
            
            var FieldsString="";
            var strColumnString=sbColumnGroup.join("");
            var arrColumn=strColumnString.split('|');
            for(var i=0;i<arrColumn.length;i++)
            {                
                if (i < (parseInt(arrColumn.length) - 1))
                {
                    FieldsString+=arrColumn[i]+",";
                }
                else if (i == (parseInt(arrColumn.length) - 1))
                {
                    FieldsString+=arrColumn[i];
                }
            }
            eval("obj.Fields={"+FieldsString+"};");
            
            eval("obj.KeyField=\""+KeyField+"\";");
            eval("obj.FieldsSet=["+sbColumnSetGroup.join("")+"];");
            eval("obj.Sort=\"\";");
            eval("obj.Where=\"\";");
            eval("obj.WhereValue=[];");
            eval("obj.WhereValueXML=\"\";");
            eval("obj.DataXML=\"\";");
            eval("obj.FieldXML=\"\";");
            eval("obj.ItemEntityFieldXML=\"\";");
            eval("obj.appendEntity=function(_entity,_Action){this.ItemEntityFieldXML+=DBReader.resolutionItemEntityXML(_entity,this.ItemEntityCount,this.TableName,_Action);this.ItemEntityFieldXML+=_entity.ItemEntityFieldXML;this.ItemEntityCount++;};");
            eval("obj.SelectOne=function(_entity){return DBReader.SelectOne(_entity);};");
            eval("obj.SelectList=function(_entity){return DBReader.prototype.SelectList(_entity);};");
            eval("obj.Insert=function(_entity){return DBReader.Insert(_entity);};");
            eval("obj.Update=function(_entity){return DBReader.Update(_entity);};");
            eval("obj.Delete=function(_entity){return DBReader.Delete(_entity);};");
            
            sbColumnGroupTemp=null;
            sbColumnGroup=null;
            sbColumnSetGroup=null;
        }
    }
    catch(e)
    {
        alert(e.message);
    }
    GetDataSql=null;
    DBReader.Dispose(DataObj);
    DBReader.Dispose(DataObjStruct);
    CollectGarbage();
    
    return obj;
};
/*根据表名创建实体对象*/
jsEntity.CreateEntityByTableName_access=function(TableName,LinkFields,LinkTableName,TableField,_KeyField)
{
    var obj=new Object();
    
    var KeyField="ID";
    if(typeof(_KeyField)!="undefined")
    {
        KeyField=_KeyField;
    }
    var DataObj=null;
    try
    {
        var strTableName=TableName;
        var strSql=" select * from "+TableName+" where 1=2";
        var strGetDataSQLString=unescape(strSql);
     
        strSql=null;
        var DataJson=DBReader.selectSqlForJson(strGetDataSQLString);
        
        strGetDataSQLString=null;
        
        if(DataJson!="null")
        {
            DataObj=eval("[{"+DataJson+"}]");
        }
        DataJson=null;
        
        if(DataObj!=null && DataObj[0].result!=-1)
        {
            eval("obj.ItemEntityCount = 0;");
            eval("obj.TableName='"+strTableName+"';");
            var sbColumnGroup=new Array();
            var sbColumnSetGroup=new Array();
            var sbColumnGroupTemp=new Array();
            
            var fieldsCount=parseInt(DataObj[0].colcount);
            
            for (var i=0;i<fieldsCount;i++)
            {
                var strDataType = "";
                var ColumnName=DataObj[0].col[i].FieldName;
                strDataType='"'+DataObj[0].col[i].FieldType+'"';
                
                var columnNametemp="";
                var columnGroupTemp="";
                var columnNameItems="";
                
                columnNameItems=ColumnName+":null";
                
                columnNametemp+="\""+ColumnName+"\"";
                columnGroupTemp+="\""+ColumnName+"\"+App.Config.split+"+strDataType+"+App.Config.split+\"column\"";

                if (i < (parseInt(fieldsCount) - 1))
                {
                    columnNameItems+="|";
                    columnNametemp+=",";
                    columnGroupTemp+=",";
                }
                sbColumnGroup.push(columnNameItems);
                sbColumnSetGroup.push(columnNametemp);
                sbColumnGroupTemp.push(columnGroupTemp);
                columnNameItems=null;
                columnNametemp=null;
                columnGroupTemp=null;
            }
            var ColumnsSetString="obj.ColumnsSet=["+sbColumnGroupTemp.join("")+"];";
            eval(ColumnsSetString);
            ColumnsSetString=null;
            
            var LinkFieldsString="";
            if(typeof(LinkFields)!="undefined" && typeof(LinkTableName)!="undefined"  && typeof(TableField)!="undefined" 
            && LinkFields!="" && LinkTableName!="" && TableField!="")
            {
                LinkFieldsString=TableField+":\""+LinkTableName+"\"+App.Config.split+\""+LinkFields+"\"";
            }
            eval("obj.LinkFields={"+LinkFieldsString+"};");
            
            var FieldsString="";
            var strColumnString=sbColumnGroup.join("");
            var arrColumn=strColumnString.split('|');
            for(var i=0;i<arrColumn.length;i++)
            {                
                if (i < (parseInt(arrColumn.length) - 1))
                {
                    FieldsString+=arrColumn[i]+",";
                }
                else if (i == (parseInt(arrColumn.length) - 1))
                {
                    FieldsString+=arrColumn[i];
                }
            }
            eval("obj.Fields={"+FieldsString+"};");
            
            eval("obj.KeyField=\""+KeyField+"\";");
            eval("obj.FieldsSet=["+sbColumnSetGroup.join("")+"];");
            eval("obj.Sort=\"\";");
            eval("obj.Where=\"\";");
            eval("obj.WhereValue=[];");
            eval("obj.WhereValueXML=\"\";");
            eval("obj.DataXML=\"\";");
            eval("obj.FieldXML=\"\";");
            eval("obj.ItemEntityFieldXML=\"\";");
            eval("obj.appendEntity=function(_entity,_Action){this.ItemEntityFieldXML+=DBReader.resolutionItemEntityXML(_entity,this.ItemEntityCount,this.TableName,_Action);this.ItemEntityFieldXML+=_entity.ItemEntityFieldXML;this.ItemEntityCount++;};");
            eval("obj.SelectOne=function(_entity){return DBReader.SelectOne(_entity);};");
            eval("obj.SelectList=function(_entity){return DBReader.prototype.SelectList(_entity);};");
            eval("obj.Insert=function(_entity){return DBReader.Insert(_entity);};");
            eval("obj.Update=function(_entity){return DBReader.Update(_entity);};");
            eval("obj.Delete=function(_entity){return DBReader.Delete(_entity);};");
            
            sbColumnGroupTemp=null;
            sbColumnGroup=null;
            sbColumnSetGroup=null;
        }
    }
    catch(e)
    {
        alert(e.message);
    }
    DataObj=null;
    CollectGarbage();
    
    return obj;
};