<#@ template language="c#" HostSpecific="True" #> <#@ output extension= ".cs" #> <# TableHost host = (TableHost)(Host); host.Fieldlist.Sort(CodeCommon.CompareByintOrder); #> #pragma once // header.h #ifndef __TBL_<#= host.GetModelClass(host.TableName).ToString().ToUpper() #>__ #define __TBL_<#= host.GetModelClass(host.TableName).ToString().ToUpper() #>__ class CTbl_<#= host.GetModelClass(host.TableName) #> : public CRecordset { public: CTbl_<#= host.GetModelClass(host.TableName) #>(CDatabase *pDatabase = NULL); DECLARE_DYNAMIC(CTbl_<#= host.GetModelClass(host.TableName) #>) public: <# foreach (ColumnInfo c in host.Fieldlist) { #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="long"|| CodeCommon.DbTypeToCS(c.TypeName)=="decimal") {#> LONG m_n<#= c.ColumnName.ToString() #>; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="string" || CodeCommon.DbTypeToCS(c.TypeName)=="DateTime") {#> CString m_str<#= c.ColumnName.ToString() #>; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="bool" ) {#> BOOL m_b<#= c.ColumnName.ToString() #>; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="float" ) {#> FLOAT m_f<#= c.ColumnName.ToString() #>; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="int" ) {#> INT m_n<#= c.ColumnName.ToString() #>; <# } #> <# } #> public: virtual CString GetDefaultConnect(); virtual CString GetDefaultSQL(); virtual void DoFieldExchange(CFieldExchange* pFX); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; #endif ////////////////////////////////////////////////////////////////////////////////////////////////////// // .cpp #include "stdafx.h" #include "Tbl<#= host.GetModelClass(host.TableName) #>.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif IMPLEMENT_DYNAMIC(CTbl_<#= host.GetModelClass(host.TableName) #>, CRecordset) CTbl_<#= host.GetModelClass(host.TableName) #>::CTbl_<#= host.GetModelClass(host.TableName) #>(CDatabase* pdb): CRecordset(pdb) { <# foreach (ColumnInfo c in host.Fieldlist) { #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="long"|| CodeCommon.DbTypeToCS(c.TypeName)=="decimal") {#> m_dw<#= c.ColumnName.ToString() #> = 0; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="string" || CodeCommon.DbTypeToCS(c.TypeName)=="DateTime") {#> m_str<#= c.ColumnName.ToString() #> = _T(""); <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="bool" ) {#> m_b<#= c.ColumnName.ToString() #> = FALSE; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="float" ) {#> m_f<#= c.ColumnName.ToString() #> = 0.0; <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="int" ) {#> m_n<#= c.ColumnName.ToString() #> = 0; <# } #> <# } #> m_nFields = <#=host.Fieldlist.Count#>; m_nDefaultType = forwardOnly; } CString CTbl_<#= host.GetModelClass(host.TableName) #>::GetDefaultConnect() { return _T("ODBC;DSN="); } CString CTbl_<#= host.GetModelClass(host.TableName) #>::GetDefaultSQL() { return _T("[<#= host.GetModelClass(host.TableName) #>]"); } void CTbl_<#= host.GetModelClass(host.TableName) #>::DoFieldExchange(CFieldExchange* pFX) { pFX->SetFieldType(CFieldExchange::outputColumn); <# foreach (ColumnInfo c in host.Fieldlist) { #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="long"|| CodeCommon.DbTypeToCS(c.TypeName)=="decimal") {#> RFX_Long(pFX, _T("[<#= c.ColumnName.ToString()#>]"), m_dw<#= c.ColumnName.ToString() #> ); <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="string" || CodeCommon.DbTypeToCS(c.TypeName)=="DateTime") {#> RFX_Text(pFX, _T("[<#= c.ColumnName.ToString()#>]"), m_str<#= c.ColumnName.ToString() #> ); <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="bool" ) {#> RFX_Bool(pFX, _T("[<#= c.ColumnName.ToString()#>]"), m_b<#= c.ColumnName.ToString() #> ); <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="float" ) {#> RFX_Single(pFX, _T("[<#= c.ColumnName.ToString()#>]"), m_f<#= c.ColumnName.ToString() #> ); <# } #> <# if ( CodeCommon.DbTypeToCS(c.TypeName)=="int" ) {#> RFX_Int(pFX, _T("[<#= c.ColumnName.ToString()#>]"), m_n<#= c.ColumnName.ToString() #> ); <# } #> <# } #> } ///////////////////////////////////////////////////////////////////////////// // CTbl_<#= host.GetModelClass(host.TableName) #> diagnostics #ifdef _DEBUG void CTbl_<#= host.GetModelClass(host.TableName) #>::AssertValid() const { CRecordset::AssertValid(); } void CTbl_<#= host.GetModelClass(host.TableName) #>::Dump(CDumpContext& dc) const { CRecordset::Dump(dc); } #endif //_DEBUG