Mercurial > mercurial > hgweb_searcher03.cgi
comparison src/db.cpp @ 1:7b6dab24f4b8
Gui parts complete.
| author | pyon@macmini |
|---|---|
| date | Sun, 04 Aug 2013 21:42:49 +0900 |
| parents | 0c0701a935f8 |
| children | c066fde99517 |
comparison
equal
deleted
inserted
replaced
| 0:0c0701a935f8 | 1:7b6dab24f4b8 |
|---|---|
| 1 // Filename : db.cpp | 1 // Filename : db.cpp |
| 2 // Last Change: 21-Jul-2013. | 2 // Last Change: 02-Aug-2013. |
| 3 // | 3 // |
| 4 | 4 |
| 5 #include "db.h" | 5 #include "db.h" |
| 6 #include "wx/wxsqlite3.h" | 6 #include "wx/wxsqlite3.h" |
| 7 | 7 |
| 8 /* $BHoJ]81<THV9f$+$iHoJ]81<TL>$r<hF@(B */ | 8 /* $BHoJ]HV$GHoJ]81<T>pJs$r<hF@(B */ |
| 9 wxString GetHhsNameByNo( wxString hhsno ) | 9 wxString GetHhsInfoByHhsNo( wxString hhsno ) |
| 10 { | 10 { |
| 11 wxString name; | 11 wxString name, addr; |
| 12 | 12 |
| 13 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); | 13 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); |
| 14 wxSQLite3Database hhsdb; | 14 wxSQLite3Database hhsdb; |
| 15 hhsdb.Open( gszFile ); | 15 hhsdb.Open( gszFile ); |
| 16 | 16 |
| 17 wxSQLite3Statement stmt = hhsdb.PrepareStatement("SELECT name FROM hhs_master WHERE hhsno = ?"); | 17 wxSQLite3Statement stmt = hhsdb.PrepareStatement("SELECT name, addr FROM hhs_master WHERE hhsno = ?"); |
| 18 stmt.Bind( 1, hhsno ); | 18 stmt.Bind( 1, hhsno ); |
| 19 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | 19 wxSQLite3ResultSet q = stmt.ExecuteQuery(); |
| 20 if ( !q.IsNull(0) ) { | 20 if ( !q.IsNull(0) ) { |
| 21 while ( q.NextRow() ) { | 21 while ( q.NextRow() ) { |
| 22 name = q.GetString(0); | 22 name = q.GetString(0); |
| 23 addr = q.GetString(1); | |
| 23 } | 24 } |
| 24 } | 25 } |
| 25 stmt.Finalize(); | 26 stmt.Finalize(); |
| 26 hhsdb.Close(); | 27 hhsdb.Close(); |
| 27 | 28 |
| 28 return name; | 29 if ( name.IsEmpty() ) { |
| 30 return wxEmptyString; | |
| 31 } | |
| 32 else { | |
| 33 return name + wxT("_") + addr; | |
| 34 } | |
| 29 } | 35 } |
| 30 /* $B%+%J$+$iHoJ]81<T>pJs$r<hF@(B */ | 36 |
| 31 wxArrayString GetHhsByKana( wxString kana, bool fuzzy ) | 37 // $B;aL>%+%J$GHoJ]81<T>pJs$r8!:w(B |
| 38 wxArrayString GetHhsInfoByKana( wxString kana, bool fuzzy ) | |
| 32 { | 39 { |
| 33 wxArrayString data; | 40 wxArrayString data; |
| 34 | 41 |
| 35 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); | 42 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("hhs.db"); |
| 36 wxSQLite3Database hhsdb; | 43 wxSQLite3Database hhsdb; |
| 37 hhsdb.Open( gszFile ); | 44 hhsdb.Open( gszFile ); |
| 38 | 45 |
| 39 wxSQLite3Statement stmt = hhsdb.PrepareStatement("SELECT hhs_no, kana, name, birth, addr FROM hhs_master WHERE kana = ? ORDER BY kana, birth DESC"); | 46 wxString sql = wxT( "SELECT hhsno, kana, name, birth, addr FROM hhs_master WHERE kana = ? ORDER BY kana, birth;" ); |
| 47 //if ( fuzzy ) ;//***** | |
| 48 | |
| 49 wxSQLite3Statement stmt = hhsdb.PrepareStatement( sql ); | |
| 40 stmt.Bind( 1, kana ); | 50 stmt.Bind( 1, kana ); |
| 41 wxSQLite3ResultSet q = stmt.ExecuteQuery(); | 51 wxSQLite3ResultSet q = stmt.ExecuteQuery(); |
| 42 | 52 |
| 43 if ( !q.IsNull(0) ) { | 53 if ( !q.IsNull(0) ) { |
| 44 wxString str; | 54 wxString str; |
| 80 ccndb.Close(); | 90 ccndb.Close(); |
| 81 | 91 |
| 82 return date_path; | 92 return date_path; |
| 83 } | 93 } |
| 84 | 94 |
| 85 /* $B3+:EF|$r<hF@(B */ | 95 /* $B9g5DBN3+:EF|$r<hF@(B */ |
| 86 wxArrayString GetCcnDate( void ) | 96 wxArrayString GetCcnDate( void ) |
| 87 { | 97 { |
| 88 wxArrayString date_cnt; | 98 wxArrayString date_cnt; |
| 89 | 99 |
| 90 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | 100 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); |
| 105 ccndb.Close(); | 115 ccndb.Close(); |
| 106 | 116 |
| 107 return date_cnt; | 117 return date_cnt; |
| 108 } | 118 } |
| 109 | 119 |
| 110 /* $B9g5DBN$r<hF@(B */ | 120 /* $BF|IU$+$i?3::2q$r<hF@(B */ |
| 111 wxArrayString GetCcnByDate( wxString date ) | 121 wxArrayString GetCcnByDate( wxString date ) |
| 112 { | 122 { |
| 113 wxArrayString ccn_cnt; | 123 wxArrayString ccn_cnt; |
| 114 | 124 |
| 115 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | 125 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); |
| 131 ccndb.Close(); | 141 ccndb.Close(); |
| 132 | 142 |
| 133 return ccn_cnt; | 143 return ccn_cnt; |
| 134 } | 144 } |
| 135 | 145 |
| 136 /* $BHoJ]81<THV9f$r<hF@(B */ | 146 /* $B9g5DBN$+$iHoJ]81<THV9f$r<hF@(B */ |
| 137 wxArrayString GetHhsNoByCcn( wxString ccn, wxString date ) | 147 wxArrayString GetHhsNoByCcn( wxString ccn, wxString date ) |
| 138 { | 148 { |
| 139 wxArrayString hhsno; | 149 wxArrayString hhsno; |
| 140 | 150 |
| 141 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); | 151 wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db"); |
