home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / po7_win / object10 / boundval.cpp < prev    next >
C/C++ Source or Header  |  1995-03-20  |  4KB  |  208 lines

  1. /* Copyright (c) Oracle Corporation 1994.  All Rights Reserved */
  2.  
  3. /*
  4.   DESCRIPTION
  5.         A class to bind OValues.  This allows an OValue to automatically
  6.       track the value of a dynaset field.
  7.   MODIFIED
  8.       kwhitley    10/24/94    Created
  9.       RWOOLARD    MODIFIED    03/20/95
  10.                 bug#    262749    Changed returns oresult and not oboolean
  11. */
  12.  
  13. #ifdef _MSC_VER
  14. #include <afxwin.h>         // MFC core and standard components
  15. #include <afxext.h>         // MFC extensions (including VB)
  16. #endif
  17.  
  18. #include "windows.h"
  19.  
  20. #ifndef BOUNDVAL_ORACLE 
  21. #include "boundval.h"
  22. #endif
  23.  
  24. OBoundVal::OBoundVal()
  25. {
  26.    m_mode = OBOUND_READWRITE;
  27. }
  28.  
  29. OBoundVal::~OBoundVal()
  30. {
  31. }
  32.  
  33. oresult OBoundVal::SetProperty(BOOL mode/* =OBOUND_READWRITE */)
  34. {
  35.     m_mode = mode;    
  36.     return OSUCCESS;
  37. }
  38.  
  39. oresult OBoundVal::Refresh(const OValue &val)
  40. {
  41.     OValue::operator=(val);  // use OValue assignment to get new value
  42.     
  43.     return(OSUCCESS);
  44. }
  45.  
  46. oresult OBoundVal::SaveChange(void)
  47. {
  48.     return(OBound::SetValue(*this));
  49. }
  50.  
  51. oresult OBoundVal::Clear(void)
  52. // BUG# 262749
  53.     if (m_mode == OBOUND_READONLY || Changed() != OSUCCESS)
  54.         return(OFAILURE); // couldn't start change
  55.     OValue::Clear();
  56.     
  57.     return(OSUCCESS);
  58. }
  59.  
  60. oresult OBoundVal::SetValue(int val) 
  61. {
  62. // BUG# 262749
  63.     if (m_mode == OBOUND_READONLY || Changed() != OSUCCESS)
  64.         return(OFAILURE); // couldn't start change
  65.     OValue::SetValue(val);
  66.     return(OSUCCESS);
  67. }
  68.  
  69. oresult OBoundVal::SetValue(long val)
  70. {
  71. // BUG# 262749
  72.     if (m_mode == OBOUND_READONLY || Changed() != OSUCCESS)
  73.         return(OFAILURE); // couldn't start change
  74.     OValue::SetValue(val);
  75.     return(OSUCCESS);
  76. }
  77.  
  78. oresult OBoundVal::SetValue(double val)
  79. {
  80. // BUG# 262749
  81.     if (m_mode == OBOUND_READONLY || Changed() != OSUCCESS)
  82.         return(OFAILURE); // couldn't start change
  83.     OValue::SetValue(val);
  84.     return(OSUCCESS);
  85. }
  86.  
  87. oresult OBoundVal::SetValue(const char *val)
  88. {
  89. // BUG# 262749
  90.     if (m_mode == OBOUND_READONLY || Changed() != OSUCCESS)
  91.         return(OFAILURE); // couldn't start change
  92.     OValue::SetValue(val);
  93.     return(OSUCCESS);
  94. }
  95.  
  96. oresult OBoundVal::SetValue(const OValue &val)
  97. {
  98. // BUG# 262749
  99.     if (m_mode == OBOUND_READONLY || Changed() != OSUCCESS)
  100.         return(OFAILURE); // couldn't start change
  101.     OValue::operator=(val);
  102.     return(OSUCCESS);
  103. }
  104.  
  105. OBoundVal &OBoundVal::operator=(const OBoundVal &other)
  106. {
  107.     if (&other == this)
  108.         return(*this); // self assignment - do nothing
  109.  
  110. // BUG# 262749
  111.     if (m_mode == OBOUND_READWRITE && Changed() == OSUCCESS)
  112.     { // we are able to change the value
  113.         OValue::operator=(other); // just copy the value
  114.     }
  115.     return(*this);    
  116. }
  117.  
  118. OBoundVal &OBoundVal::operator=(const OValue &val)
  119. {
  120. // BUG# 262749
  121.     if (m_mode == OBOUND_READWRITE && Changed() == OSUCCESS)
  122.     { // we are able to change the value
  123.         OValue::operator=(val);
  124.     }
  125.     return(*this);
  126. }
  127.     
  128. OBoundVal &OBoundVal::operator=(const int val)    
  129. {
  130.     SetValue(val);  // if we can't StartEdit on dynaset, this does nothing
  131.     return(*this);
  132. }
  133.     
  134. OBoundVal &OBoundVal::operator=(const long val)    
  135. {
  136.     SetValue(val);  // if we can't StartEdit on dynaset, this does nothing
  137.     return(*this);
  138. }
  139.     
  140. OBoundVal &OBoundVal::operator=(const double val)    
  141. {
  142.     SetValue(val);  // if we can't StartEdit on dynaset, this does nothing
  143.     return(*this);
  144. }
  145.     
  146. OBoundVal &OBoundVal::operator=(const char *val)
  147. {
  148.     SetValue(val);  // if we can't StartEdit on dynaset, this does nothing
  149.     return(*this);
  150. }
  151.    
  152. oresult OBoundVal::Startup ()
  153. {
  154.     return OSUCCESS;
  155. }
  156. oresult OBoundVal::PreQuery ()
  157. {
  158.     return OSUCCESS;
  159. }
  160. oresult OBoundVal::PostQuery ()
  161. {
  162.     return RefreshBound();
  163. }
  164. oresult OBoundVal::PreMove ()
  165. {
  166.     return OSUCCESS;
  167. }
  168. oresult OBoundVal::PostMove ()
  169. {
  170.     return RefreshBound();
  171. }
  172. oresult OBoundVal::PreAdd ()
  173. {
  174.     return RefreshBound();
  175. }
  176. oresult OBoundVal::PostAdd ()
  177. {
  178.     return OSUCCESS;
  179. }
  180. oresult OBoundVal::PreUpdate ()
  181. {
  182.     return OSUCCESS;
  183. }
  184. oresult OBoundVal::PostUpdate ()
  185. {
  186.     return OSUCCESS;
  187. }
  188. oresult OBoundVal::PreDelete ()
  189. {
  190.     return OSUCCESS;
  191. }
  192. oresult OBoundVal::PostDelete ()
  193. {
  194.     return OSUCCESS;
  195. }
  196. oresult OBoundVal::PreRollback ()
  197. {
  198.     return OSUCCESS;
  199. }
  200. oresult OBoundVal::PostRollback ()
  201. {
  202.     return RefreshBound();
  203. }
  204. oresult OBoundVal::Shutdown ()
  205. {
  206.     return OSUCCESS;
  207. }