changeset 6:76db82822e73

Implement kana fuzzy search. Implement batch print log.
author pyon@macmini
date Wed, 18 Sep 2013 18:20:40 +0900
parents bc2e2b304095
children 7ac7d28699af
files Changes include/bprint.h src/bprint.cpp src/db.cpp
diffstat 4 files changed, 37 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sat Sep 14 08:54:47 2013 +0900
+++ b/Changes	Wed Sep 18 18:20:40 2013 +0900
@@ -1,3 +1,9 @@
+version 03.07
+2013-09-18
+ Implement kana fuzzy search.
+ Implement batch print log.
+
+----
 version 03.06
 2013-09-13
  Clean up code.
--- a/include/bprint.h	Sat Sep 14 08:54:47 2013 +0900
+++ b/include/bprint.h	Wed Sep 18 18:20:40 2013 +0900
@@ -1,5 +1,5 @@
 // Filename   : bprint.h
-// Last Change: 13-Sep-2013.
+// Last Change: 18-Sep-2013.
 //
 #ifndef __BPRINT_H__
 #define __BPRINT_H__
@@ -30,6 +30,7 @@
 		~FrameBatchPrint();
 	
         void SetGridReadOnly( void );
+        void WriteLog( wxArrayString logline );
         void OnInput( wxGridEvent& event );
         void OnClear( wxCommandEvent& WXUNUSED(event) );
         void OnPrint( wxCommandEvent& WXUNUSED(event) );
--- a/src/bprint.cpp	Sat Sep 14 08:54:47 2013 +0900
+++ b/src/bprint.cpp	Wed Sep 18 18:20:40 2013 +0900
@@ -1,5 +1,5 @@
 // Filename   : bprint.cpp
-// Last Change: 13-Sep-2013.
+// Last Change: 18-Sep-2013.
 //
 
 #include "bprint.h"
@@ -120,6 +120,7 @@
     wxPrintDialogData pd;
     wxPrinter p( &pd );
     p.PrintDialog( NULL );
+    wxArrayString log;
 
     for ( int r = 0; r < m_grid->GetNumberRows(); r++ ) {
         wxString path = m_grid->GetCellValue( r, 2 );
@@ -175,7 +176,9 @@
         p.Print( NULL, &hpout, false );
 
         m_grid->SetCellValue( r, 3, wxT("処理済") );
+        log.Add( path );
     }
+    WriteLog( log );
 }
 
 /* 入力禁止 */
@@ -186,4 +189,20 @@
             m_grid->SetReadOnly( r, c, true );
 }
 
+/* 印刷ログ */
+void FrameBatchPrint::WriteLog( wxArrayString logline )
+{
+    wxDateTime now = wxDateTime::Now();
+    wxString log_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("log") + wxFILE_SEP_PATH + wxT("bp_") + now.Format( wxT("%Y%m%d%H%M%S.log") );
+    wxTextFile file( log_file );
+    file.Create();
+    wxTextFile logfile;
+    logfile.Open( log_file );
 
+    for ( int n = 0; n < logline.GetCount(); n++ ) {
+        logfile.AddLine( logline[n] );
+    }
+    logfile.Write();
+    logfile.Close();
+}
+
--- a/src/db.cpp	Sat Sep 14 08:54:47 2013 +0900
+++ b/src/db.cpp	Wed Sep 18 18:20:40 2013 +0900
@@ -1,5 +1,5 @@
 // Filename   : db.cpp
-// Last Change: 11-Sep-2013.
+// Last Change: 18-Sep-2013.
 //
 
 #include "db.h"
@@ -44,8 +44,14 @@
     wxSQLite3Database hhsdb;
     hhsdb.Open( gszFile );
 
-    wxString sql = wxT( "SELECT hhsno, kana, name, birth, addr FROM hhs_master WHERE kana = ? ORDER BY kana, birth;" ); 
-    //if ( fuzzy ) ;//*****
+    wxString sql = wxT( "SELECT hhsno, kana, name, birth, addr FROM hhs_master " );
+    if ( fuzzy ) {
+        kana = wxT("%") + kana + wxT("%");
+        sql += wxT( "WHERE kana LIKE ? ORDER BY kana, birth;" ); 
+    }
+    else {
+        sql += wxT( "WHERE kana = ? ORDER BY kana, birth;" ); 
+    }
 
     wxSQLite3Statement stmt = hhsdb.PrepareStatement( sql );
     stmt.Bind( 1, kana );