Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

IDBrunnote.cxx

Go to the documentation of this file.
00001 //
00002 // $Id: IDBrunnote.cxx,v 1.5 2000/02/29 12:46:39 mueller Exp $
00003 //
00004 
00005 #include "CTB.hxx"
00006 #include "CTBodbc.hxx"
00007 #include "CTBodbcConnect.hxx"
00008 #include "CTBodbcStatement.hxx"
00009 #include "CTBodbcTime.hxx"
00010 
00011 #include "IDB.hxx"
00012 #include "IDBrunnote.hxx"
00013 
00019 //------------------------------------------+-----------------------------------
00021 
00022 IDBrunnote::IDBrunnote()
00023   : m_idbc(IDBconnect::Default()),
00024     mp_stmt(0),
00025     mb_select_urn(false),
00026     mb_fetch_ok(false)
00027 {}
00028 
00029 //------------------------------------------+-----------------------------------
00031 
00032 IDBrunnote::IDBrunnote(IDBconnect& idbc)
00033   : m_idbc(idbc),
00034     mp_stmt(0),
00035     mb_select_urn(false),
00036     mb_fetch_ok(false)
00037 {}
00038 
00039 //------------------------------------------+-----------------------------------
00041 
00042 IDBrunnote::~IDBrunnote()
00043 {
00044   if (mp_stmt != 0) delete mp_stmt;
00045 }
00046 
00047 //------------------------------------------+-----------------------------------
00049 
00050 bool IDBrunnote::SelectUrn(int i_urn)
00051 {
00052   mb_fetch_ok   = false;
00053   mb_select_urn = true;
00054   mi_urnbeg_sel = i_urn;                    // do a validity check here ???
00055   mi_urnend_sel = i_urn;
00056   return true;
00057 }
00058 
00059 //------------------------------------------+-----------------------------------
00061 
00062 bool IDBrunnote::SelectUrn(const CTBrange& urns)
00063 {
00064   mb_fetch_ok   = false;
00065   mb_select_urn = true;
00066   mi_urnbeg_sel = urns.Begin();             // do a validity check here ???
00067   mi_urnend_sel = urns.End();
00068   return true;
00069 }
00070 
00071 //------------------------------------------+-----------------------------------
00073 
00074 bool IDBrunnote::SelectUrn()
00075 {
00076   mb_fetch_ok   = false;
00077   mb_select_urn = false;
00078   return true;
00079 }
00080 
00081 //------------------------------------------+-----------------------------------
00083 
00084 bool IDBrunnote::Execute()
00085 {
00086   CTBcstring<512> c_sql;
00087   
00088   mb_fetch_ok = false;
00089 
00090   if (mp_stmt == 0) {
00091     mp_stmt = new CTBodbcStatement(m_idbc.Dbc());
00092   } else {
00093     mp_stmt->Close();
00094     mp_stmt->UnbindParameter();
00095   }
00096   
00097   c_sql = "SELECT note_id,urn_beg,urn_end,date_create,date_revoke,"
00098                   "username,note"
00099           " FROM runnote";
00100 
00101   if (mb_select_urn) {
00102     c_sql += " WHERE ? <= urn_end AND ? >= urn_beg";
00103     mp_stmt->BindIParameter( 1,SQL_INTEGER,mi_urnbeg_sel);
00104     mp_stmt->BindIParameter( 2,SQL_INTEGER,mi_urnend_sel);
00105   }
00106 
00107   c_sql += " ORDER BY urn_beg,urn_end,date_create";
00108 
00109   return mp_stmt->Prepare(c_sql) && mp_stmt->Execute();
00110 }
00111 
00112 //------------------------------------------+-----------------------------------
00114 
00115 bool IDBrunnote::Fetch()
00116 {
00117   bool        b_null;
00118   int         i_urnbeg = -1;
00119   int         i_urnend = -1;
00120   CTBodbcTime date;
00121   
00122   mb_fetch_ok = false;
00123   if (mp_stmt == 0 || ! mp_stmt->Fetch()) return false;
00124 
00125   if(!mp_stmt->GetData(1,mi_id,b_null)) return false;
00126 
00127   if(!mp_stmt->GetData(2,i_urnbeg,b_null)) return false;
00128   if(!mp_stmt->GetData(3,i_urnend,b_null)) return false;
00129   m_urn_valid.Begin(i_urnbeg);
00130   m_urn_valid.End(i_urnend);
00131 
00132   if(!mp_stmt->GetData(4,date,b_null)) return false;
00133   mi_datecreate = date.ToUTime();
00134 
00135   if(!mp_stmt->GetData(5,date,b_null)) return false;
00136   mi_daterevoke = (b_null) ? -1 : date.ToUTime();
00137 
00138   if(!mp_stmt->GetData(6,mc_user,mc_user.Size(),b_null)) return false;
00139 
00140   if(!mp_stmt->GetData(7,mc_note,mc_note.Size(),b_null)) return false;
00141 
00142   mb_fetch_ok = true;
00143   return true;
00144 }
00145 
00146 //------------------------------------------+-----------------------------------
00148 
00149 bool IDBrunnote::GetID(int& i_id)
00150 {
00151   if (!mb_fetch_ok) return false;
00152   i_id = mi_id;
00153   return true;
00154 }
00155 
00156 //------------------------------------------+-----------------------------------
00158 
00159 bool IDBrunnote::GetUrn(CTBrange& urns)
00160 {
00161   if (!mb_fetch_ok) return false;
00162   urns = m_urn_valid;
00163   return true;
00164 }
00165 
00166 //------------------------------------------+-----------------------------------
00168 
00169 bool IDBrunnote::GetDateCreate(int& i_datecreate)
00170 {
00171   if (!mb_fetch_ok) return false;
00172   i_datecreate = mi_datecreate;
00173   return true;
00174 }
00175 
00176 //------------------------------------------+-----------------------------------
00178 
00179 bool IDBrunnote::GetDateRevoke(int& i_daterevoke)
00180 {
00181   if (!mb_fetch_ok || i_daterevoke == -1) return false;
00182   i_daterevoke = mi_daterevoke;
00183   return true;
00184 }
00185 
00186 //------------------------------------------+-----------------------------------
00188 
00189 bool IDBrunnote::GetUser(const char*& c_user)
00190 {
00191   if (!mb_fetch_ok) return false;
00192   c_user = mc_user;
00193   return true;
00194 }
00195 
00196 //------------------------------------------+-----------------------------------
00198 
00199 bool IDBrunnote::GetNote(const char*& c_note)
00200 {
00201   if (!mb_fetch_ok) return false;
00202   c_note = mc_note;
00203   return true;
00204 }
00205 
00206 //------------------------------------------+-----------------------------------
00208 
00209 bool IDBrunnote::Add(const CTBrange& , const char* )
00210 {
00211   cerr << "IDBrunnote::Add not yet implemented" << endl;
00212   return false;
00213   
00214 }
00215 
00216 //------------------------------------------+-----------------------------------
00218 
00219 bool IDBrunnote::Revoke(int )
00220 {
00221   cerr << "IDBrunnote::Revoke not yet implemented" << endl;
00222   return false;
00223   
00224 }
00225 

Generated at Fri Oct 24 18:17:34 2003 for IDBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001