wx_Sqlite: Main Page

  • Main Page
  • Namespaces
  • Classes
  • Files

wx_Sqlite Documentation

Generated on Fri Aug 4 18:17:15 2006 for wx_Sqlite by doxygen 1.4.6-NO


wx_Sqlite: Class List

  • Files
  • Class List
  • Class Hierarchy
  • Class Members

wx_Sqlite Class List

Here are the classes, structs, unions and interfaces with brief descriptions:
wx_SQL
wx_SQL::F_FILE


wx_Sqlite: wx_SQL Class Reference

  • Class Members

wx_SQL Class Reference

List of all members.

Public Member Functions

wx_SQL ()
-----ajout include perso------------------------------------------------------------------
virtual | ~wx_SQL ()
bool | F_Berr ()
const wxString | F_Merr ()
void | F_Field (int nField, wxString nameField, wxString valeurField, int typeField, int lenField, int entierField=0, int precisionField=0, bool keyField=false, int ordrefield=0)
void | F_Index (int nField, wxString nameField, wxString valeurField, bool keyField, int ordrefield)
void | L_Index (int nField, wxString nameField, wxString valeurField, bool keyField, int ordrefield)
void | L_ValLGF (int i, const wxString V_field=wxT(""))
const wxString | F_GetDDS (int i)
void | F_SetDDS (int i, const wxString V_field)
void | F_OpnDDS (wxString Fpath)
wxString | F_CrtDDS (wxString Fname)
const wxString | F_IdxDDS (wxString Fname)
bool | F_CrtTable (wxString Fname, bool index=false)
bool | F_WrtDDS (wxString Fname)
bool | F_UpdDDS (wxString Fname)
bool | F_UpdDDSx (wxString Fname, unsigned int x)
bool | F_DltDDS (wxString Fname)
bool | F_ChainDDS (wxString Fname)
bool | L_RallDDS (wxString Fname)
bool | L_ReadGeDDS (wxString Fname)
bool | L_ReadpLeDDS (wxString Fname)

Classes

struct | F_FILE

Detailed Description

Definition at line 22 of file wx_SQLite.h.

The documentation for this class was generated from the following files:
  • C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.h
  • C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.cpp


wx_Sqlite: Member List

wx_SQL Member List

This is the complete list of members for wx_SQL, including all inherited members.

F_Berr() | wx_SQL | [inline]
F_ChainDDS(wxString Fname) | wx_SQL |
F_CrtDDS(wxString Fname) | wx_SQL |
F_CrtTable(wxString Fname, bool index=false) | wx_SQL |
F_DltDDS(wxString Fname) | wx_SQL |
F_Field(int nField, wxString nameField, wxString valeurField, int typeField, int lenField, int entierField=0, int precisionField=0, bool keyField=false, int ordrefield=0) | wx_SQL |
F_GetDDS(int i) | wx_SQL |
F_IdxDDS(wxString Fname) | wx_SQL |
F_Index(int nField, wxString nameField, wxString valeurField, bool keyField, int ordrefield) | wx_SQL |
F_Merr() | wx_SQL | [inline]
F_OpnDDS(wxString Fpath) | wx_SQL |
F_SetDDS(int i, const wxString V_field) | wx_SQL |
F_UpdDDS(wxString Fname) | wx_SQL |
F_UpdDDSx(wxString Fname, unsigned int x) | wx_SQL |
F_WrtDDS(wxString Fname) | wx_SQL |
L_Index(int nField, wxString nameField, wxString valeurField, bool keyField, int ordrefield) | wx_SQL |
L_RallDDS(wxString Fname) | wx_SQL |
L_ReadGeDDS(wxString Fname) | wx_SQL |
L_ReadpLeDDS(wxString Fname) | wx_SQL |
L_ValLGF(int i, const wxString V_field=wxT("")) | wx_SQL |
wx_SQL() | wx_SQL |
~wx_SQL() | wx_SQL | [virtual]


wx_Sqlite: File Index

  • Files

wx_Sqlite File List

Here is a list of all documented files with brief descriptions:
C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.cpp [code]
C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.h [code]


wx_Sqlite: Class Members

  • All
  • Functions
  • Variables
  • b
  • d
  • f
  • k
  • l
  • o
  • q
  • s
  • t
  • w
  • ~

Here is a list of all documented class members with links to the class documentation for each member:

- b -

  • BD : wx_SQL::F_FILE

- d -

  • db : wx_SQL::F_FILE
  • ds : wx_SQL::F_FILE

- f -

  • F_Berr() : wx_SQL
  • F_ChainDDS() : wx_SQL
  • F_CrtDDS() : wx_SQL
  • F_CrtTable() : wx_SQL
  • F_DltDDS() : wx_SQL
  • F_Field() : wx_SQL
  • F_GetDDS() : wx_SQL
  • F_IdxDDS() : wx_SQL
  • F_Index() : wx_SQL
  • F_Merr() : wx_SQL
  • F_OpnDDS() : wx_SQL
  • F_SetDDS() : wx_SQL
  • F_UpdDDS() : wx_SQL
  • F_UpdDDSx() : wx_SQL
  • F_WrtDDS() : wx_SQL

- k -

  • ki : wx_SQL::F_FILE
  • klg : wx_SQL::F_FILE

- l -

  • L_Index() : wx_SQL
  • L_RallDDS() : wx_SQL
  • L_ReadGeDDS() : wx_SQL
  • L_ReadpLeDDS() : wx_SQL
  • L_ValLGF() : wx_SQL
  • lg : wx_SQL::F_FILE

- o -

  • OpnBD : wx_SQL::F_FILE

- q -

  • qry : wx_SQL::F_FILE

- s -

  • slg : wx_SQL::F_FILE
  • stm : wx_SQL::F_FILE

- t -

  • tbl : wx_SQL::F_FILE

- w -

  • wx_SQL() : wx_SQL

- ~ -

  • ~wx_SQL() : wx_SQL


wx_Sqlite: Class Members - Functions

  • All
  • Functions
  • Variables

  • F_Berr() : wx_SQL
  • F_ChainDDS() : wx_SQL
  • F_CrtDDS() : wx_SQL
  • F_CrtTable() : wx_SQL
  • F_DltDDS() : wx_SQL
  • F_Field() : wx_SQL
  • F_GetDDS() : wx_SQL
  • F_IdxDDS() : wx_SQL
  • F_Index() : wx_SQL
  • F_Merr() : wx_SQL
  • F_OpnDDS() : wx_SQL
  • F_SetDDS() : wx_SQL
  • F_UpdDDS() : wx_SQL
  • F_UpdDDSx() : wx_SQL
  • F_WrtDDS() : wx_SQL
  • L_Index() : wx_SQL
  • L_RallDDS() : wx_SQL
  • L_ReadGeDDS() : wx_SQL
  • L_ReadpLeDDS() : wx_SQL
  • L_ValLGF() : wx_SQL
  • wx_SQL() : wx_SQL
  • ~wx_SQL() : wx_SQL


wx_Sqlite: Class Members - Variables

  • All
  • Functions
  • Variables

  • BD : wx_SQL::F_FILE
  • db : wx_SQL::F_FILE
  • ds : wx_SQL::F_FILE
  • ki : wx_SQL::F_FILE
  • klg : wx_SQL::F_FILE
  • lg : wx_SQL::F_FILE
  • OpnBD : wx_SQL::F_FILE
  • qry : wx_SQL::F_FILE
  • slg : wx_SQL::F_FILE
  • stm : wx_SQL::F_FILE
  • tbl : wx_SQL::F_FILE


wx_Sqlite: Hierarchical Index

wx_Sqlite Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically:
  • wx_SQL
  • wx_SQL::F_FILE


wx_Sqlite: Namespace Index

  • Files

wx_Sqlite Namespace List

Here is a list of all documented namespaces with brief descriptions:
std -----ajout include perso------------------------------------------------------------------


wx_Sqlite: std Namespace Reference

  • Files

std Namespace Reference

-----ajout include perso------------------------------------------------------------------ More...

Detailed Description

-----ajout include perso------------------------------------------------------------------


wx_Sqlite: wx_SQL::F_FILE Struct Reference

wx_SQL::F_FILE

wx_SQL::F_FILE Struct Reference

List of all members.

Public Attributes

wxSQLite3Database | db
wxSQLite3ResultSet | qry
wxSQLite3Statement | stm
wxSQLite3Table | tbl
std::vector< DDS > | ds
std::vector< KID > | ki
std::vector< KLF > | lg
int | slg [10]
int | klg [10]
wxString | BD
bool | OpnBD

Detailed Description

Definition at line 74 of file wx_SQLite.h.

The documentation for this struct was generated from the following file:
  • C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.h


wx_Sqlite: Member List

wx_SQL::F_FILE Member List

This is the complete list of members for wx_SQL::F_FILE, including all inherited members.

BD | wx_SQL::F_FILE
db | wx_SQL::F_FILE
ds | wx_SQL::F_FILE
ki | wx_SQL::F_FILE
klg | wx_SQL::F_FILE
lg | wx_SQL::F_FILE
OpnBD | wx_SQL::F_FILE
qry | wx_SQL::F_FILE
slg | wx_SQL::F_FILE
stm | wx_SQL::F_FILE
tbl | wx_SQL::F_FILE


wx_Sqlite: C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.cpp Source File

  • Files

C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.cpp

00001 #ifndef WX_SQLITE_CCP_INCLUDED
00002 #define WX_SQLITE_CCP_INCLUDED
00003
00004 #include <string.h>
00005 #include <cstring>
00006 #include <cstdlib>
00007 #include <ctime>
00008 #include <vector>
00009 #include <algorithm>
00010 #include <iostream>
00011
00012 #include <wx/wxSqlite/wx_SQLite.h>
00013 #include <wx/wxSqlite/wxsqlite3.cpp>
00014 //------------------------
00015 // procedure acces DDS
00016 //------------------------
00017
00018 wx_SQL::wx_SQL() {}; //initalisation
00019 wx_SQL::~wx_SQL(){};
00020
00021
00022 // Initialisation Field
00023 void wx_SQL::F_Field(int nField, wxString nameField,wxString valeurField,
00024 int typeField, int lenField,   int entierField, int precisionField ,
00025 bool keyField , int ordrefield){
00026
00027 // si nombre    donné la longeur entierField voir la precision aussi
00028 // si keyField  donné N° ordrefield
00029 DDS_FILE.ds.push_back(DDS(nField, nameField,valeurField,typeField,lenField,entierField,precisionField,keyField,ordrefield));
00030 };
00031
00032 // Initialisation Index
00033 void wx_SQL::F_Index(int nField, wxString nameField,wxString valeurField,
00034 bool keyField , int ordrefield){
00035 // si keyField  donné N° ordrefield
00036 DDS_FILE.ki.push_back(KID(nField,nameField,valeurField,keyField,ordrefield));
00037 };
00038
00039
00040 // Initialisation Index pour lecture Logique
00041 void wx_SQL::L_Index(int nField, wxString nameField,wxString valeurField,
00042 bool keyField , int ordrefield){
00043 DDS_FILE.lg.push_back(KLF(nField,nameField,valeurField,keyField,ordrefield));
00044 };
00045
00046 // initialisation des Logiques
00047
00048 void  wx_SQL::L_ValLGF( int i ,const wxString V_field ) {
00049        DDS_FILE.lg[i].wxVal = V_field;
00050 };
00051
00052 // lecture des fields pour wxString
00053 const wxString  wx_SQL::F_GetDDS( int i ) {
00054 return DDS_FILE.ds[i].wxVal;
00055 };
00056
00057
00058 // initialisation des fields pour wxString
00059 void wx_SQL::F_SetDDS( int i ,const wxString V_field ) {
00060         DDS_FILE.ds[i].wxVal = V_field ;
00061
00062   if (DDS_FILE.ds[i].Key == true) DDS_FILE.ki[DDS_FILE.ds[i].Ord].wxVal = V_field;
00063 };
00064
00065 void wx_SQL::F_OpnDDS(wxString Fpath)
00066 {
00067
00068  if  (DDS_FILE.OpnBD == false ) {
00069     DDS_FILE.BD = Fpath ;
00070 //    remove(DDS_FILE.BD);
00071     DDS_FILE.db.Open(DDS_FILE.BD);
00072     DDS_FILE.OpnBD = true;
00073  }
00074 };
00075
00076
00077 // fonction de creation Sqlite File  Formatage
00078 wxString wx_SQL::F_CrtDDS(wxString Fname)
00079 {
00080
00081    wxString Csql ;
00082
00083    Csql.Clear();
00084    Xsql.Clear();
00085
00086    Xsql =  _T("CREATE TABLE  ") + Fname  +  _T("(");
00087
00088    Csql += Xsql;
00089
00090
00091     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ds.size() ; i++, f++)
00092   {
00093   Xsql.Clear();
00094   Xsql += DDS_FILE.ds[f].Name ;
00095
00096       switch (DDS_FILE.ds[f].Type)
00097      {
00098       case xText : Xsql +=_T(" CHAR(") ;
00099                    Xsql += wxString::Format("%d", DDS_FILE.ds[f].Lng ) ;
00100                    break;
00101
00102       case xInt  : Xsql +=  _T(" INTG(");
00103                    Xsql += wxString::Format("%d", DDS_FILE.ds[f].Lng );
00104                    break;
00105       case xDbl  : Xsql +=  _T(" REAL(") ;
00106       Xsql += wxString::Format("%d.%d", DDS_FILE.ds[f].Ent,DDS_FILE.ds[f].Prs ) ;
00107                    break;
00108      case xDate : Xsql +=  _T("  DATE(") ;
00109                   Xsql += wxString::Format("%d", DDS_FILE.ds[f].Lng ) ;
00110                   break;
00111       case xBlod : Xsql +=  _T(" BLOD ") ; break;
00112      }
00113
00114       if ( i < DDS_FILE.ds.size()) {
00115       if (DDS_FILE.ds[f].Type != xBlod)  Xsql += ")  ,";
00116      else Xsql +=  "  ,";
00117                                    }
00118
00119       if ( i == DDS_FILE.ds.size()) {
00120       if (DDS_FILE.ds[f].Type != xBlod)  Xsql += ")  ";
00121
00122                                   }
00123
00124
00125  Csql += Xsql;
00126   }
00127   Xsql.Clear();
00128       if (DDS_FILE.ds[DDS_FILE.ds.size()].Type != xBlod) Xsql = "  );";
00129      else Xsql =  "  ;";
00130
00131  Csql += Xsql;
00132
00133  Xsql =Csql.Trim();
00134   return  Xsql ;
00135 };
00136
00137
00138 // fonction de creation Sqlite File  Index
00139
00140 const wxString  wx_SQL::F_IdxDDS(wxString Fname)
00141 {
00142   Xsql.Clear();
00143 // create unique index Key ON bd(Nom ASC , Prenom ASC)
00144  Xsql = "CREATE UNIQUE INDEX Key ON  " + Fname + " (";
00145     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ki.size() ; i++, f++)
00146   {
00147       Xsql += DDS_FILE.ki[f].Name  ;
00148
00149       if ( i < DDS_FILE.ki.size())   Xsql += " ASC , ";
00150       else Xsql += " ASC  );";
00151
00152   }
00153   return Xsql;
00154 };
00155
00156
00157 // initialisation  de la base de données
00158 bool  wx_SQL::F_CrtTable(wxString Fname, bool index )
00159 {
00160    Xsql.Clear();
00161   try
00162   {
00163     if(false == DDS_FILE.db.TableExists(Fname)){
00164     Xsql = F_CrtDDS (Fname);
00165     DDS_FILE.db.ExecuteQuery(Xsql.c_str());
00166
00167      if ( index == true ) {
00168                          Xsql = F_IdxDDS (Fname);
00169                          DDS_FILE.db.ExecuteQuery(Xsql);
00170                          }
00171      }
00172     Xsql.Clear();
00173     return Berr = false ;
00174
00175     }
00176   catch (wxSQLite3Exception& e)
00177   {
00178   Merr =   _T(e.GetMessage());
00179   return Berr = true ;
00180   }
00181
00182 };
00183
00184
00185 //  INSERT BD
00186 bool wx_SQL::F_WrtDDS(wxString Fname) {
00187  Xsql.Clear();
00188    Xsql = "insert into " + Fname + " values (";
00189     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ds.size() ; i++, f++)
00190   {
00191       if ( i < DDS_FILE.ds.size())  Xsql += "?,";
00192      else Xsql +=  "?);";
00193
00194   }
00195
00196   try
00197   {
00198
00199     DDS_FILE.stm = DDS_FILE.db.PrepareStatement(Xsql);
00200     DDS_FILE.db.Begin();
00201     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ds.size() ; i++, f++)
00202     {
00203       DDS_FILE.stm.Bind(i,DDS_FILE.ds[f].wxVal);
00204
00205     }
00206      DDS_FILE.stm.ExecuteUpdate();
00207      DDS_FILE.db.Commit();
00208      DDS_FILE.stm.Finalize();
00209      return Berr = false ;
00210
00211     }
00212   catch (wxSQLite3Exception& e)
00213   {  DDS_FILE.db.Commit();
00214      DDS_FILE.stm.Finalize();
00215   Merr =   _T(e.GetMessage());Merr +=   _T("AJout Enregistrement Berr");
00216   return Berr = true ;
00217   }
00218
00219 };
00220 //  UPDATE BD
00221 bool wx_SQL::F_UpdDDS(wxString Fname) {
00222 int nerr ;
00223  Xsql.Clear();
00224      Xsql = "UPDATE " + Fname + "  SET ";
00225
00226     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ds.size() ; i++, f++)
00227   {
00228       if ( i < DDS_FILE.ds.size())  Xsql += DDS_FILE.ds[f].Name + "=?,";
00229      else Xsql += DDS_FILE.ds[f].Name+ "=?  ";
00230
00231   }
00232
00233
00234      Xsql += " WHERE " ;
00235     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ki.size() ; i++, f++)
00236   {
00237       if ( i < DDS_FILE.ki.size()) Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal.Trim()+ "'  and " ;
00238      else Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal.Trim() + "'  ";
00239
00240  }
00241
00242        Xsql +=  " ;" ;
00243
00244
00245 // debug
00246 //   Merr = Xsql;  return Berr = true ;
00247   try
00248   {
00249
00250    DDS_FILE.stm = DDS_FILE.db.PrepareStatement(Xsql);
00251    DDS_FILE.db.Begin();
00252     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ds.size() ; i++, f++)
00253     {
00254       DDS_FILE.stm.Bind(i,DDS_FILE.ds[f].wxVal);
00255
00256     }
00257   nerr = DDS_FILE.stm.ExecuteUpdate();
00258    DDS_FILE.db.Commit();
00259    DDS_FILE.stm.Finalize();
00260  if (nerr > 0 )  return Berr = false ;
00261  else { Merr =   _T("Aucune Mise a jour");  return Berr = true ;}
00262     }
00263   catch (wxSQLite3Exception& e)
00264   {  DDS_FILE.db.Commit();
00265      DDS_FILE.stm.Finalize();
00266   Merr =   _T(e.GetMessage());Merr += _T("Aucune Mise a jour");
00267   return Berr = true ;
00268   }
00269
00270 };
00271
00272
00273 //  UPDATE BD ( 1 Field)
00274 bool wx_SQL::F_UpdDDSx(wxString Fname,unsigned int x) {
00275  int nerr;
00276
00277  Xsql.Clear();
00278     Xsql = "UPDATE " + Fname + "  SET ";
00279     Xsql += DDS_FILE.ds[x].Name  +  " =? ";
00280      Xsql += " WHERE " ;
00281     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ki.size() ; i++, f++)
00282   {
00283       if ( i < DDS_FILE.ki.size()) Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal.Trim()+ "'  and " ;
00284      else Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal.Trim() + "'  ";
00285
00286  }
00287       Xsql +=  " ;" ;
00288 //if( DDS_FILE.db.CheckSyntax(Xsql)== false) {Merr = _T(Xsql); return Berr = true ;  }
00289
00290
00291   try
00292   {
00293      DDS_FILE.stm = DDS_FILE.db.PrepareStatement(Xsql);
00294     DDS_FILE.db.Begin();
00295           DDS_FILE.stm.Bind(1,DDS_FILE.ds[x].wxVal);
00296   nerr = DDS_FILE.stm.ExecuteUpdate();
00297    DDS_FILE.db.Commit();
00298    DDS_FILE.stm.Finalize();
00299
00300  if (nerr > 0 )  return Berr = false ;
00301  else { Merr =   _T("Aucune Mise a jour"); Merr = Xsql; return Berr = true ;}
00302
00303     }
00304   catch (wxSQLite3Exception& e)
00305   {  DDS_FILE.db.Commit();
00306        DDS_FILE.stm.Finalize();
00307   Merr =   _T(e.GetMessage()); Merr += _T("Aucune Mise a jour");
00308   return Berr = true ;
00309   }
00310
00311 };
00312
00313 //DELETE DB
00314 bool wx_SQL::F_DltDDS(wxString Fname) {
00315 int nerr;
00316  Xsql.Clear();
00317    Xsql = "DELETE FROM  " + Fname + " WHERE " ;
00318
00319     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ki.size() ; i++, f++)
00320   {
00321       if ( i < DDS_FILE.ki.size()) Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal + "'  and " ;
00322      else Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal + "' ";
00323
00324   }
00325       Xsql +=  " ;" ;
00326 // Merr = Xsql;  return valide = true ;
00327   try
00328   {
00329      DDS_FILE.stm = DDS_FILE.db.PrepareStatement(Xsql);
00330     DDS_FILE.db.Begin();
00331   nerr = DDS_FILE.stm.ExecuteUpdate();
00332    DDS_FILE.db.Commit();
00333    DDS_FILE.stm.Finalize();
00334
00335  if (nerr > 0 )  return Berr = false ;
00336  else { Merr =   _T("Aucune Suppression");  return Berr = true ;}
00337
00338     }
00339   catch (wxSQLite3Exception& e)
00340   {  DDS_FILE.db.Commit();
00341   Merr =   _T(e.GetMessage());  Merr = Xsql;
00342   return Berr = true ;
00343   }
00344
00345 };
00346
00347
00348 // Stell Index Unique
00349 bool wx_SQL::F_ChainDDS(wxString Fname) {
00350  Xsql.Clear();
00351    Xsql = "SELECT * from  " + Fname + " WHERE " ;
00352
00353     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ki.size() ; i++, f++)
00354   {
00355       if ( i < DDS_FILE.ki.size()) Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal + "'  and " ;
00356      else Xsql += DDS_FILE.ki[f].Name  +  " ='" +DDS_FILE.ki[f].wxVal + "'  ORDER BY  ";
00357
00358   }
00359      for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ki.size() ; i++, f++)
00360   {
00361       if ( i < DDS_FILE.ki.size()) Xsql += DDS_FILE.ki[f].Name   + "  , " ;
00362      else Xsql += DDS_FILE.ki[f].Name   + " ";
00363
00364   }
00365        Xsql +=  " ;" ;
00366 //debug
00367 // Merr = Xsql;
00368   try
00369   {
00370
00371      DDS_FILE.tbl= DDS_FILE.db.GetTable(Xsql);
00372
00373     for ( unsigned int i = 1,f =0 ; i <= DDS_FILE.ds.size() ; i++, f++)
00374     {
00375      F_SetDDS( f ,DDS_FILE.tbl.GetAsString(f) )  ;
00376     }
00377
00378
00379     return Berr = false ;
00380     }
00381   catch (wxSQLite3Exception& e)
00382   {
00383   Merr =   _T(e.GetMessage());  Merr = Xsql;
00384   return Berr= true ;
00385   }
00386
00387 };
00388
00389
00390
00391
00392
00393
00394 //*********************************************************
00395 //*********************************************************
00396 // Gestion Lecture sur logique
00397 //*********************************************************
00398 //*********************************************************
00399
00400
00401
00402 // Setll read *all
00403 bool wx_SQL::L_RallDDS(wxString Fname) {
00404  Xsql.Clear();
00405 unsigned int knbr;
00406 unsigned int kx;
00407    Xsql = "SELECT * from  " + Fname + " ORDER BY " ;
00408
00409 for( kx=0 , knbr = 0; DDS_FILE.klg[kx]  <99; kx++) knbr ++;
00410
00411     for ( unsigned int i = 1,f =0 ; i <= knbr ; i++, f++)
00412   {
00413       if ( i < knbr) {
00414 if (DDS_FILE.lg[DDS_FILE.klg[f]].Desc == 1 )  Xsql +=  DDS_FILE.lg[DDS_FILE.klg[f]].Name   + " DESC, ";
00415 else Xsql += DDS_FILE.lg[DDS_FILE.klg[f]].Name   + " , " ;
00416                      }
00417      else { Xsql += DDS_FILE.lg[DDS_FILE.klg[f]].Name   + "  ";
00418             if (DDS_FILE.lg[DDS_FILE.klg[f]].Desc == 1 )  Xsql += " DESC ";
00419           }
00420   }
00421       Xsql +=  " ;" ;
00422 // Merr = Xsql;  return valide = true ;
00423   try
00424   {
00425
00426      DDS_FILE.qry= DDS_FILE.db.ExecuteQuery(Xsql);
00427     return Berr = false ;
00428     }
00429   catch (wxSQLite3Exception& e)
00430   {
00431   Merr =   _T(e.GetMessage());  Merr = Xsql;
00432   return Berr = true ;
00433   }
00434
00435 };
00436
00437
00438 // Setll  read *GE
00439 bool wx_SQL::L_ReadGeDDS(wxString Fname ) {
00440  Xsql.Clear();
00441 unsigned int knbr;
00442 unsigned int kx;
00443
00444 for( kx=0 , knbr = 0; DDS_FILE.slg[kx]  <99; kx++) knbr ++;
00445
00446    Xsql = "SELECT * from  " + Fname ;
00447 //==========================================================================================
00448 // debut WHERE
00449 //==========================================================================================
00450
00451        if (  knbr >= 1) Xsql += " WHERE " ;
00452       if (  knbr == 1) {
00453            Xsql += DDS_FILE.lg[DDS_FILE.slg[0]].Name ;
00454            if ( DDS_FILE.lg[DDS_FILE.slg[0]].Sel == 1) Xsql += " ='" ; else Xsql += " >='";
00455            Xsql += DDS_FILE.lg[DDS_FILE.slg[0]].wxVal + "'    " ;
00456       }
00457
00458
00459
00460       if (  knbr > 1){
00461     for ( unsigned int i = 1,f =0 ; i <=  knbr    ; i++, f++)
00462   {  if ( i < knbr) {
00463             Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].Name ;
00464             if ( DDS_FILE.lg[DDS_FILE.slg[f]].Sel == 1) Xsql += " ='" ; else Xsql += " >='";
00465             Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].wxVal + "'  and " ;
00466      }
00467      else { Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].Name ;
00468             if ( DDS_FILE.lg[DDS_FILE.slg[f]].Sel == 1) Xsql += " ='" ; else Xsql += " >='";
00469             Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].wxVal + "'     ";
00470      }
00471   }
00472                      }
00473 //==========================================================================================
00474 // debut ORDER BY
00475 //==========================================================================================
00476
00477 for( kx=0 , knbr = 0; DDS_FILE.klg[kx]  <99; kx++) knbr ++;
00478
00479       Xsql +=  "  ORDER BY  ";
00480
00481
00482     for ( unsigned int i = 1,f =0 ; i <= knbr ; i++, f++)
00483   {
00484       if ( i < knbr) {
00485 if (DDS_FILE.lg[DDS_FILE.klg[f]].Desc == 1 )  Xsql +=  DDS_FILE.lg[DDS_FILE.klg[f]].Name   + " DESC , ";
00486 else Xsql += DDS_FILE.lg[DDS_FILE.klg[f]].Name   + " , " ;
00487                      }
00488      else { Xsql += DDS_FILE.lg[DDS_FILE.klg[f]].Name   + "  ";
00489             if (DDS_FILE.lg[DDS_FILE.klg[f]].Desc == 1 )  Xsql += " DESC ";
00490           }
00491   }
00492
00493     Xsql +=  " ;" ;
00494 // Merr = Xsql;   // return valide = true ;
00495   try
00496   {
00497
00498      DDS_FILE.qry= DDS_FILE.db.ExecuteQuery(Xsql);
00499
00500     return Berr = false ;
00501     }
00502   catch (wxSQLite3Exception& e)
00503   {
00504   Merr =   _T(e.GetMessage());  Merr = Xsql;
00505   return Berr = true ;
00506   }
00507
00508 };
00509
00510
00511
00512
00513
00514 // Setll  readp *LE
00515 bool wx_SQL::L_ReadpLeDDS(wxString Fname) {
00516  Xsql.Clear();
00517    Xsql = "SELECT * from  " + Fname ;
00518 unsigned int knbr;
00519 unsigned int kx;
00520
00521 for( kx=0 , knbr = 0; DDS_FILE.slg[kx]  <99; kx++) knbr ++;
00522
00523 //==========================================================================================
00524 // debut WHERE
00525 //==========================================================================================
00526
00527        if (  knbr >= 1) Xsql += " WHERE " ;
00528       if (  knbr == 1) {
00529            Xsql += DDS_FILE.lg[DDS_FILE.slg[0]].Name ;
00530            if ( DDS_FILE.lg[DDS_FILE.slg[0]].Sel == 1) Xsql += " ='" ; else Xsql += " <='";
00531            Xsql += DDS_FILE.lg[DDS_FILE.slg[0]].wxVal + "'    " ;
00532       }
00533
00534
00535
00536       if (  knbr > 1){
00537     for ( unsigned int i = 1,f =0 ; i <=  knbr    ; i++, f++)
00538   {  if ( i < knbr) {
00539             Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].Name ;
00540             if ( DDS_FILE.lg[DDS_FILE.slg[f]].Sel == 1) Xsql += " ='" ; else Xsql += " <='";
00541             Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].wxVal + "'  and " ;
00542      }
00543      else { Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].Name ;
00544             if ( DDS_FILE.lg[DDS_FILE.slg[f]].Sel == 1) Xsql += " ='" ; else Xsql += " <='";
00545             Xsql += DDS_FILE.lg[DDS_FILE.slg[f]].wxVal + "'     ";
00546      }
00547   }
00548                      }
00549 //==========================================================================================
00550 // debut ORDER BY
00551 //==========================================================================================
00552
00553 for( kx=0 , knbr = 0; DDS_FILE.klg[kx]  <99; kx++) knbr ++;
00554
00555     Xsql += "  ORDER BY  ";
00556
00557
00558     for ( unsigned int i = 1,f =0 ; i <= knbr ; i++, f++)
00559   {
00560       if ( i < knbr ) Xsql += DDS_FILE.lg[DDS_FILE.klg[f]].Name   + "  DESC, " ;
00561      else Xsql += DDS_FILE.lg[DDS_FILE.klg[f]].Name   + "  DESC";
00562
00563   }
00564       Xsql +=  " ;" ;
00565 Merr = _T(Xsql);  //return Berr = true ;
00566   try
00567   {
00568
00569      DDS_FILE.qry= DDS_FILE.db.ExecuteQuery(Xsql);
00570
00571     return Berr = false ;
00572     }
00573   catch (wxSQLite3Exception& e)
00574   {
00575   Merr =   _T(e.GetMessage());  Merr = Xsql;
00576   return Berr = true ;
00577   }
00578
00579 };
00580
00581 #endif


wx_Sqlite: C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.h Source File

  • Files

C:/GCC/docs/DocSqlite/wxSqlite/wx_SQLite.h

00001 #ifndef WX_SQLITE_H_INCLUDED
00002 #define WX_SQLITE_H_INCLUDED
00003
00005 #include <vector>
00006 #include <wx/wxSqlite/wxsqlite3.h>
00007
00008  using namespace std;
00009
00010 //------------------------
00011 // procedure acces DDS
00012 //------------------------
00013 enum Type_Zone {
00014      xInt    = 1,
00015      xDbl    = 2,
00016      xText   = 3,
00017      xDate   = 4,
00018      xBlod   = 5
00019      };
00020
00021
00022 class wx_SQL
00023 {
00024 private:
00025      wxString  Merr ;
00026      bool      Berr  ;
00027      wxString Xsql ;
00028
00029  // 1= entier  2 = num  3 = text  4 = Date  5 = blod(pas trt)
00030 struct DDS
00031 {
00032    DDS(int f, wxString n,wxString v, int t, int l,   int e, int p ,bool k , int o )
00033    : field(f), Name(n), wxVal(v), Type(t) , Lng(l),  Ent(e), Prs(p) , Key(k), Ord(o){}
00034
00035    int field;
00036    wxString Name;
00037    wxString wxVal;
00038    int    Type;
00039    int    Lng;
00040    int    Ent ;
00041    int    Prs;
00042    bool   Key;
00043    int    Ord; // N°index key
00044 };
00045 // Key index -> DDS
00046 struct KID
00047 {
00048    KID(int f, wxString n ,wxString v, int d , int s)
00049    : field(f), Name(n), wxVal(v), Desc(d), Sel(s) {}
00050
00051    int field;
00052    wxString Name;
00053    wxString wxVal;
00054    int Desc;    // descandant key = 1
00055    int Sel;     // selection  = 1  >= 0
00056 };
00057
00058 struct KLF
00059 {
00060    KLF(int f, wxString n ,wxString v, int d, int s)
00061    : field(f), Name(n), wxVal(v), Desc(d), Sel(s) {}
00062
00063    int field;
00064    wxString Name;
00065    wxString wxVal;
00066    int Desc;     // descandant key = 1
00067    int Sel;      // selection  = 1  >= 0
00068 };
00069
00070
00071 //     const int KEY = 00 ; // position enum (swicht = 00 )
00072  public:
00073
00074 struct  F_FILE{
00075  wxSQLite3Database  db;
00076  wxSQLite3ResultSet qry;
00077  wxSQLite3Statement stm;
00078  wxSQLite3Table     tbl;
00079
00080  std::vector<DDS>   ds ;  // Déf Data Structure
00081  std::vector<KID>   ki ;  // Key Index
00082  std::vector<KLF>   lg ;  // Key Index Logique
00083  int  slg[10];             // N° ordre de zone for Logique  where
00084  int  klg[10];             // N° ordre de zone for Logique  Key ASC
00085  wxString BD ;
00086  bool     OpnBD;
00087  } DDS_FILE;
00088
00089
00090  public:
00091    wx_SQL() ;
00092    virtual ~wx_SQL();
00093 // erreur
00094 bool  wx_SQL::F_Berr(){return Berr;};
00095 const wxString wx_SQL::F_Merr(){return Merr;};
00096
00097 // initialisation des definitions Fields
00098 void wx_SQL::F_Field(int nField, wxString nameField,wxString valeurField,
00099 int typeField, int lenField,   int entierField =0,
00100  int precisionField =0,bool keyField = false , int ordrefield = 0);
00101 // Initialisation Index
00102 void wx_SQL::F_Index(int nField, wxString nameField,
00103 wxString valeurField,bool keyField , int ordrefield);
00104 // Initialisation Index pour lecture Logique
00105 void wx_SQL::L_Index(int nField, wxString nameField,
00106 wxString valeurField,bool keyField , int ordrefield);
00107
00108 // initialisation des Logiques
00109 void wx_SQL::L_ValLGF( int i ,const wxString V_field = wxT(""));
00110
00111 // lecture des fields pour wxString
00112 const wxString  wx_SQL:: F_GetDDS( int i );
00113 // initialisation des fields pour wxString
00114 void  wx_SQL::F_SetDDS( int i ,const wxString V_field );
00115 // Open file .db3
00116 void  wx_SQL::F_OpnDDS(wxString Fpath);
00117 // fonction de creation Sqlite File  field
00118 wxString wx_SQL::F_CrtDDS(wxString Fname);
00119 // fonction de creation Sqlite File  Index
00120 const wxString  wx_SQL::F_IdxDDS(wxString Fname);
00121 // initialisation  de la base de données
00122 bool wx_SQL::F_CrtTable(wxString Fname, bool index = false);
00123 //  INSERT BD
00124 bool wx_SQL::F_WrtDDS(wxString Fname);
00125 //  UPDATE DB
00126 bool wx_SQL::F_UpdDDS(wxString Fname);
00127 //  UPDATE BD ( 1 Field)
00128 bool wx_SQL::F_UpdDDSx(wxString Fname,unsigned int x);
00129 //DELETE DB
00130 bool wx_SQL::F_DltDDS(wxString Fname);
00131 // Stell Index Unique
00132 bool wx_SQL::F_ChainDDS(wxString Fname);
00133
00134 //*********************************************************
00135 //*********************************************************
00136 // Gestion Lecture sur logique
00137 //*********************************************************
00138 //*********************************************************
00139
00140 // Setll  read *all
00141 bool L_RallDDS(wxString Fname);
00142 // Setll  read *GE
00143 bool L_ReadGeDDS(wxString Fname);
00144 // Setll  readp *LE
00145 bool L_ReadpLeDDS(wxString Fname);
00146 };
00147 #endif // WX_SQLITE_H_INCLUDED