ProductInfo.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // ProductInfo.h : CProductInfo 类的实现
  2. // CProductInfo 实现
  3. // 代码生成在 2016年9月30日, 14:30
  4. #include "stdafx.h"
  5. #include "ProductInfo.h"
  6. IMPLEMENT_DYNAMIC(CProductInfo, CRecordset)
  7. CProductInfo::CProductInfo(CDatabase* pdb): CRecordset(pdb)
  8. {
  9. m_AutoID = 0;
  10. m_StudioID = _T("");
  11. m_ProductSN = _T("");
  12. m_ProductName = _T("");
  13. m_ProductCost = 0.0;
  14. m_ProductPrice = 0.0;
  15. m_ProductTypes = _T("");
  16. m_ProductUnit = _T("");
  17. m_ProductShelves = FALSE;
  18. m_ProductNote = _T("");
  19. m_nFields = 10;
  20. m_nDefaultType = dynaset;
  21. }
  22. //#error 安全问题:连接字符串可能包含密码。
  23. // 此连接字符串中可能包含明文密码和/或其他重要
  24. // 信息。请在查看完此连接字符串并找到所有与安全
  25. // 有关的问题后移除 #error。可能需要将此密码存
  26. // 储为其他格式或使用其他的用户身份验证。
  27. CString CProductInfo::GetDefaultConnect()
  28. {
  29. return _T("DSN=EasySelection;Description=EasySelection;Trusted_Connection=Yes;APP=Microsoft\x00ae Visual Studio\x00ae 2010;WSID=IT-PC;DATABASE=EasySelection;");
  30. }
  31. CString CProductInfo::GetDefaultSQL()
  32. {
  33. return _T("[dbo].[ProductInfo]");
  34. }
  35. void CProductInfo::DoFieldExchange(CFieldExchange* pFX)
  36. {
  37. pFX->SetFieldType(CFieldExchange::outputColumn);
  38. // RFX_Text() 和 RFX_Int() 这类宏依赖的是
  39. // 成员变量的类型,而不是数据库字段的类型。
  40. // ODBC 尝试自动将列值转换为所请求的类型
  41. RFX_Long(pFX, _T("[AutoID]"), m_AutoID);
  42. RFX_Text(pFX, _T("[StudioID]"), m_StudioID);
  43. RFX_Text(pFX, _T("[ProductSN]"), m_ProductSN);
  44. RFX_Text(pFX, _T("[ProductName]"), m_ProductName);
  45. RFX_Double(pFX, _T("[ProductCost]"), m_ProductCost);
  46. RFX_Double(pFX, _T("[ProductPrice]"), m_ProductPrice);
  47. RFX_Text(pFX, _T("[ProductTypes]"), m_ProductTypes);
  48. RFX_Text(pFX, _T("[ProductUnit]"), m_ProductUnit);
  49. RFX_Bool(pFX, _T("[ProductShelves]"), m_ProductShelves);
  50. RFX_Text(pFX, _T("[ProductNote]"), m_ProductNote);
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CProductInfo 诊断
  54. #ifdef _DEBUG
  55. void CProductInfo::AssertValid() const
  56. {
  57. CRecordset::AssertValid();
  58. }
  59. void CProductInfo::Dump(CDumpContext& dc) const
  60. {
  61. CRecordset::Dump(dc);
  62. }
  63. #endif //_DEBUG
  64. //////////////////////////////////////////////////////////////////////////
  65. IMPLEMENT_SERIAL(CProductInfoObj, CObject, 0)
  66. CProductInfoObj::CProductInfoObj()
  67. {
  68. m_AutoID = 0;
  69. m_StudioID = _T("");
  70. m_ProductSN = _T("");
  71. m_ProductName = _T("");
  72. m_ProductCost = 0.0;
  73. m_ProductPrice = 0.0;
  74. m_ProductTypes = _T("");
  75. m_ProductUnit = _T("");
  76. m_ProductShelves = TRUE;
  77. m_ProductNote = _T("");
  78. }
  79. CProductInfoObj& CProductInfoObj::operator=(const CProductInfoObj& member)
  80. {
  81. m_AutoID = member.m_AutoID;
  82. m_StudioID = member.m_StudioID;
  83. m_ProductSN = member.m_ProductSN;
  84. m_ProductName = member.m_ProductName;
  85. m_ProductCost = member.m_ProductCost;
  86. m_ProductPrice = member.m_ProductPrice;
  87. m_ProductTypes = member.m_ProductTypes;
  88. m_ProductUnit = member.m_ProductUnit;
  89. m_ProductShelves = member.m_ProductShelves;
  90. m_ProductNote = member.m_ProductNote;
  91. return *this;
  92. }
  93. void CProductInfoObj::Serialize(CArchive& ar)
  94. {
  95. try
  96. {
  97. CObject::Serialize(ar);
  98. if( ar.IsStoring() )
  99. {
  100. ar << m_AutoID;
  101. ar << m_StudioID;
  102. ar << m_ProductSN;
  103. ar << m_ProductName;
  104. ar << m_ProductCost;
  105. ar << m_ProductPrice;
  106. ar << m_ProductTypes;
  107. ar << m_ProductUnit;
  108. ar << m_ProductShelves;
  109. ar << m_ProductNote;
  110. }
  111. else
  112. {
  113. ar >> m_AutoID;
  114. ar >> m_StudioID;
  115. ar >> m_ProductSN;
  116. ar >> m_ProductName;
  117. ar >> m_ProductCost;
  118. ar >> m_ProductPrice;
  119. ar >> m_ProductTypes;
  120. ar >> m_ProductUnit;
  121. ar >> m_ProductShelves;
  122. ar >> m_ProductNote;
  123. }
  124. }
  125. catch (CMemoryException* e)
  126. {
  127. #if _DEBUG
  128. e->ReportError();
  129. #endif
  130. }
  131. }