diff src/db.cpp @ 4:fdba695b99f1

More fast ( read from DB ). Improve the precision of marksheet judgement.
author pyon@macmini
date Wed, 11 Sep 2013 19:09:14 +0900
parents c066fde99517
children 76db82822e73
line wrap: on
line diff
--- a/src/db.cpp	Tue Aug 27 18:50:00 2013 +0900
+++ b/src/db.cpp	Wed Sep 11 19:09:14 2013 +0900
@@ -1,5 +1,5 @@
 // Filename   : db.cpp
-// Last Change: 23-Aug-2013.
+// Last Change: 11-Sep-2013.
 //
 
 #include "db.h"
@@ -243,6 +243,7 @@
     ccndb.Close();
 }
 
+//********** HHS-DB & CCN-DB **********//
 /* DB整合性チェック */
 wxArrayString CheckDBs( void )
 {
@@ -269,3 +270,47 @@
     return result;
 }
 
+// 被保険者番号リストから氏名と最新ファイルパスを取得
+wxArrayString GetHhsInfoAndPathByHhsNoList( wxArrayString hhsno )
+{
+    wxString gszFile = wxGetCwd() + wxFILE_SEP_PATH + wxT("db") + wxFILE_SEP_PATH + wxT("ccn.db");
+    wxSQLite3Database ccndb;
+    ccndb.Open( gszFile );
+
+    wxString sql = wxT( "ATTACH 'db/hhs.db' AS hhs;" );
+    wxSQLite3Statement stmt = ccndb.PrepareStatement( sql );
+    wxSQLite3ResultSet q = stmt.ExecuteQuery();
+
+    wxArrayString result;
+    for ( int i = 0; i < hhsno.GetCount(); i++ ) {
+        wxString str = hhsno[i];
+        str.Append( wxT("_") );
+
+        sql = wxT( "SELECT name FROM hhs.hhs_master WHERE hhsno = ?;" );
+        stmt = ccndb.PrepareStatement( sql );
+        stmt.Bind( 1, hhsno[i] );
+        q = stmt.ExecuteQuery();
+        if ( !q.IsNull(0) ) {
+            while ( q.NextRow() ) {
+                str.Append( q.GetString(0) );
+            }
+        }
+        str.Append( wxT("_") );
+
+        sql = wxT( "SELECT path FROM path WHERE hhsno = ? ORDER BY path DESC LIMIT 1;" );
+        stmt = ccndb.PrepareStatement( sql );
+        stmt.Bind( 1, hhsno[i] );
+        q = stmt.ExecuteQuery();
+        if ( !q.IsNull(0) ) {
+            while ( q.NextRow() ) {
+                str.Append( q.GetString(0) );
+            }
+        }
+
+        result.Add( str );
+    }
+    stmt.Finalize();
+    ccndb.Close();
+
+    return result;
+}