123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <#@ 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
|