@@ -31,7 +31,7 @@ void class_bdd::CreateEmpty(const wxString& path) | |||
{ | |||
rc = 0; | |||
rc += sqlite3_open_v2(_C(path), &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Consult(id INTEGER PRIMARY KEY ASC, n_dossier INTEGER, nom VARCHAR(50), prenom VARCHAR(50), responsable VARCHAR(100), consultant VARCHAR(50), theme TEXT, etablissement VARCHAR(100), travail VARCHAR(50), date_cs DATE, publi_prevue BOOLEAN, service VARCHAR(100));", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Consult(id INTEGER PRIMARY KEY ASC, n_dossier INTEGER, nom VARCHAR(50), prenom VARCHAR(50), responsable VARCHAR(100), consultant VARCHAR(50), theme TEXT, etablissement VARCHAR(100), travail VARCHAR(50), date_cs DATE, service VARCHAR(100));", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Result(id INTEGER PRIMARY KEY ASC, publi BOOLEAN DEFAULT 0, publi_CHU BOOLEAN DEFAULT 0, cs_associe BOOLEAN DEFAULT 0, nb_result INTEGER DEFAULT 0, id_result TEXT DEFAULT \"\");", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Publi(id INTEGER PRIMARY KEY, titre TEXT, auteurs TEXT, abstract TEXT, revue TEXT, lien VARCHAR(50), date_publi TEXT);", NULL, NULL, NULL); | |||
rc += sqlite3_exec(db, "CREATE TABLE Correc(orig TEXT PRIMARY KEY, dest TEXT);", NULL, NULL, NULL); | |||
@@ -95,7 +95,7 @@ void class_bdd::Importer(const wxString& filename) | |||
if (!is_first_line) | |||
{ | |||
//Insertion dans la table de consults | |||
wxString requete = "INSERT OR REPLACE INTO Consult (id, n_dossier, nom, prenom, responsable, consultant, theme, etablissement, travail, date_cs, publi_prevue, service) VALUES ("; | |||
wxString requete = "INSERT OR REPLACE INTO Consult (id, n_dossier, nom, prenom, responsable, consultant, theme, etablissement, travail, date_cs, service) VALUES ("; | |||
requete << item[0] << ", "; //numéro travail -> id PRIMARY KEY | |||
if (item[1].IsSameAs("")) //n_dossier | |||
requete << "NULL, "; | |||
@@ -108,12 +108,8 @@ void class_bdd::Importer(const wxString& filename) | |||
<< "\"" << item[13] << "\", " //Thème | |||
<< "\"" << item[7] << "\", " //Etablissement | |||
<< "\"" << item[12] << "\", " //Type travail | |||
<< "\"" << item[21] << "\", "; //Date_cs | |||
if (item[18].IsSameAs("VRAI", false)) //Publi prévue | |||
requete << "1, "; | |||
else | |||
requete << "0, "; | |||
requete << "\"" << item[6] << "\"" //Service | |||
<< "\"" << item[21] << "\", " //Date_cs | |||
<< "\"" << item[6] << "\"" //Service | |||
<< ");"; | |||
rc += sqlite3_exec(db, requete, NULL, NULL, NULL); | |||
@@ -225,13 +221,12 @@ void class_bdd::GenerateGrid() | |||
wxString orig = sqlite3_column_text(stmt, i); | |||
// corrections | |||
rc = sqlite3_prepare_v2(db, "SELECT dest FROM Correc WHERE orig=\"" + orig + "\";", -1, &stmt_correc, NULL); | |||
if (sqlite3_step(stmt_correc) == SQLITE_DONE) | |||
grid_consults->SetCellValue(line_nb, i+3, orig); | |||
else | |||
{ | |||
grid_consults->SetCellValue(line_nb, i+3, sqlite3_column_text(stmt_correc, 0)); | |||
//grid->SetCellBackgroundColour(line_nb, i+3, *wxYELLOW); | |||
} | |||
sqlite3_finalize(stmt_correc); | |||
} | |||
// autocorrection prenoms | |||
@@ -253,10 +248,6 @@ void class_bdd::GenerateGrid() | |||
grid_consults->SetCellValue(line_nb, 7, responsable); | |||
grid_consults->SetCellValue(line_nb, 13, _itoW(sqlite3_column_int(stmt, 0))); //id, caché | |||
/*wxColour lightgreen(230, 255, 230); //TODO: gestion des couleurs dans la config ? | |||
if (sqlite3_column_int(stmt, 10)) | |||
for (int j=0; j<13; j++) | |||
grid->SetCellBackgroundColour(line_nb, j, lightgreen); //coloration des publis prévues*/ | |||
line_nb++; | |||
} | |||
sqlite3_finalize(stmt); | |||
@@ -389,6 +380,7 @@ void class_bdd::SetCorrec(const wxString& orig, const wxString& dest) | |||
sqlite3_finalize(stmt); | |||
} | |||
// Suppression d'une correction si on revient à l'original | |||
if (dest == orig) | |||
DelCorrec(orig); | |||
@@ -466,10 +458,9 @@ void class_bdd::AddIdResult(const wxString& id, const wxString& id_result) | |||
bool class_bdd::IsPubli(const wxString& id) | |||
{ | |||
sqlite3_prepare_v2(db, "SELECT * FROM Publi WHERE id=" + id + ";", -1, &stmt, NULL); | |||
if (sqlite3_step(stmt) == SQLITE_DONE) | |||
return false; | |||
else | |||
return true; | |||
bool out = (sqlite3_step(stmt) == SQLITE_ROW); | |||
sqlite3_finalize(stmt); | |||
return out; | |||
} | |||
void class_bdd::AddPubli(wxString id, wxString title, wxString authors, wxString abstract, wxString journal, wxString link, wxString date) | |||
@@ -36,6 +36,7 @@ class class_bdd | |||
void SetResultPubli(int row, unsigned int bitfield); //modifie le statut de publi dans la bdd et la grille (publi(1<<1)/publichu(1<<2)/cs_associe(1<<3) | |||
// gestion des corrections | |||
//TODO: Utiliser un wxArrayString[2] pour GetListCorrecs | |||
int GetNbCorrecs(); | |||
wxString* GetCorrecOrig(); | |||
wxString* GetCorrecDest(); | |||
@@ -45,6 +45,7 @@ public: | |||
void Save(); | |||
void AddRule(rule to_add); | |||
void DelRule(int index); | |||
//TODO: GetListRules avec vector<rule>, éventuellement SetListRules, garder GetRule pour le fetch individuel | |||
int GetNbRules(); | |||
rule GetRule(int index); | |||
void SetRule(int index, rule temp); | |||
@@ -9,13 +9,12 @@ dialog_correc( parent ) | |||
void correc::Update() | |||
{ | |||
int nb_correc = bdd->GetNbCorrecs(); | |||
if (grid_correcs->GetNumberRows() != 0) | |||
grid_correcs->DeleteRows(0, grid_correcs->GetNumberRows()); //reset de la grille | |||
grid_correcs->AppendRows(nb_correc); | |||
grid_correcs->AppendRows(bdd->GetNbCorrecs()); | |||
wxString* correc_orig = bdd->GetCorrecOrig(); | |||
wxString* correc_dest = bdd->GetCorrecDest(); | |||
for (int i=0; i<nb_correc; i++) | |||
for (int i=0; i<bdd->GetNbCorrecs(); i++) | |||
{ | |||
grid_correcs->SetRowLabelValue(i, "X"); | |||
grid_correcs->SetCellValue(i, 0, correc_orig[i]); | |||
@@ -104,7 +104,7 @@ void cosmos::OnCellChange( wxGridEvent& event ) | |||
void cosmos::OnCellDbClick( wxGridEvent& event ) | |||
{ | |||
fenetre_resultats->SetCurrentrow(event.GetRow()); | |||
fenetre_resultats->SetCurrentRowConsult(event.GetRow()); | |||
fenetre_resultats->Update(); | |||
fenetre_resultats->Show(); | |||
} |
@@ -10,10 +10,7 @@ wxString bool2W(bool in) | |||
bool W2bool(wxString in) | |||
{ | |||
if (in == "true") | |||
return true; | |||
else | |||
return false; | |||
return (in == "true"); | |||
} | |||
wxString op2W(int in) | |||
@@ -30,11 +30,10 @@ id 0 0 13 | |||
n_dossier 1 1 4 | |||
nom 3 2 5 | |||
prenom 4 3 6 | |||
service 6 11 / | |||
service 6 10 / | |||
etablissement 7 7 10 | |||
travail 12 8 11 | |||
thème 13 6 9 | |||
publi prévue 18 10 / | |||
responsable 19 4 7 | |||
consultant 20 5 8 | |||
date 21 9 12 | |||
@@ -5,8 +5,7 @@ optionsRche::optionsRche( wxWindow* parent, class_config* config ) | |||
dialog_optionsRche( parent ) | |||
{ | |||
this->config = config; | |||
int nb_rule = config->GetNbRules(); | |||
for (int i=0; i < nb_rule; i++) | |||
for (int i=0; i < config->GetNbRules(); i++) | |||
{ | |||
checklist_ruleset->Append(config->GetRule(i).name); | |||
if (config->GetRule(i).in_use) | |||
@@ -140,10 +139,7 @@ void optionsRche::OnOk( wxCommandEvent& event ) | |||
for (int i=0; i < (int)checklist_ruleset->GetCount(); i++) | |||
{ | |||
rule temp = config->GetRule(i); | |||
if (checklist_ruleset->IsChecked(i)) | |||
temp.in_use = true; | |||
else | |||
temp.in_use = false; | |||
temp.in_use = (checklist_ruleset->IsChecked(i)); | |||
config->SetRule(i, temp); | |||
} | |||
config->Save(); | |||
@@ -34,9 +34,8 @@ void class_recherche::Start() | |||
for (unsigned int i=0; i < selection.GetCount(); i++) | |||
{ | |||
if (is_first_pass || (grid_consults->GetCellValue(selection[i], 0) == "0")) | |||
{ | |||
Go (selection[i], config->GetRule(j)); | |||
} | |||
if (!dialog_progress.Update(i)) | |||
break; | |||
} | |||
@@ -72,9 +71,11 @@ void class_recherche::Go(int row, rule regle) | |||
grid_consults->SetCellValue(row, 0, _itoW(bdd->GetNbResults(id_consult))); | |||
temp.Clear(); | |||
for (unsigned int i=0; i < list_id_results.GetCount(); i++) | |||
if (!(bdd->IsPubli(list_id_results[i]))) | |||
temp.Add(list_id_results[i]); | |||
list_id_results = temp; | |||
if (list_id_results.GetCount() > 0) | |||
@@ -22,31 +22,27 @@ void resultats::OnCheckPubli( wxCommandEvent& event ) | |||
{ | |||
if (event.GetId() == CHK_PUBLI) | |||
{ | |||
int prev_state; | |||
if (list_publi[current_row_publi].Left(1) == '@') | |||
prev_state=1; | |||
else | |||
prev_state=0; | |||
bool was_publi = (list_publi[current_row_publi].Left(1) == '@'); | |||
list_publi[current_row_publi] = list_publi[current_row_publi].AfterLast('!').AfterLast('@'); | |||
switch (checkbox_publi->Get3StateValue()) | |||
{ | |||
case wxCHK_CHECKED: | |||
list_publi[current_row_publi] = "@" + list_publi[current_row_publi]; | |||
grid_publis->SetCellBackgroundColour(current_row_publi, 0, *wxGREEN); | |||
if (prev_state == 0) | |||
if (!was_publi) | |||
nb_publi++; | |||
break; | |||
case wxCHK_UNDETERMINED: | |||
list_publi[current_row_publi] = "!" + list_publi[current_row_publi]; | |||
grid_publis->SetCellBackgroundColour(current_row_publi, 0, *wxLIGHT_GREY); | |||
if (prev_state == 1) | |||
if (was_publi) | |||
nb_publi--; | |||
break; | |||
case wxCHK_UNCHECKED: | |||
grid_publis->SetCellBackgroundColour(current_row_publi, 0, grid_publis->GetDefaultCellBackgroundColour()); | |||
if (prev_state == 1) | |||
if (was_publi) | |||
nb_publi--; | |||
break; | |||
@@ -193,6 +189,7 @@ void resultats::UpdateCheckUI() | |||
checkbox_publichu->Hide(); | |||
checkbox_cs->Hide(); | |||
} | |||
Fit(); | |||
} | |||
void resultats::Commit() | |||
@@ -34,7 +34,7 @@ | |||
<property name="hidden">0</property> | |||
<property name="id">wxID_ANY</property> | |||
<property name="maximum_size"></property> | |||
<property name="minimum_size">525,400</property> | |||
<property name="minimum_size">600,400</property> | |||
<property name="name">dialog_resultats</property> | |||
<property name="pos"></property> | |||
<property name="size">-1,-1</property> | |||
@@ -38,8 +38,7 @@ public: | |||
resultats( wxWindow* parent, class_bdd* bdd, wxGrid* grid_consults ); | |||
void Update(); //met à jour la fenêtre pour une consult | |||
void SetCurrentrow(int current_row_consult) {this->current_row_consult = current_row_consult;} | |||
int GetCurrentrow() const {return current_row_consult;} | |||
void SetCurrentRowConsult(int current_row_consult) {this->current_row_consult = current_row_consult;} | |||
//// end generated class members | |||
}; | |||
@@ -11,7 +11,7 @@ | |||
dialog_resultats::dialog_resultats( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) | |||
{ | |||
this->SetSizeHints( wxSize( 525,400 ), wxDefaultSize ); | |||
this->SetSizeHints( wxSize( 600,400 ), wxDefaultSize ); | |||
wxBoxSizer* verticalsizer; | |||
verticalsizer = new wxBoxSizer( wxVERTICAL ); | |||
@@ -129,6 +129,7 @@ dialog_resultats::dialog_resultats( wxWindow* parent, wxWindowID id, const wxStr | |||
this->Centre( wxBOTH ); | |||
// Connect Events | |||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( dialog_resultats::OnClose ) ); | |||
grid_publis->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( dialog_resultats::OnCellClick ), NULL, this ); | |||
grid_publis->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( dialog_resultats::OnKey ), NULL, this ); | |||
checkbox_publi->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_resultats::OnCheckPubli ), NULL, this ); | |||
@@ -142,6 +143,7 @@ dialog_resultats::dialog_resultats( wxWindow* parent, wxWindowID id, const wxStr | |||
dialog_resultats::~dialog_resultats() | |||
{ | |||
// Disconnect Events | |||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( dialog_resultats::OnClose ) ); | |||
grid_publis->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( dialog_resultats::OnCellClick ), NULL, this ); | |||
grid_publis->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( dialog_resultats::OnKey ), NULL, this ); | |||
checkbox_publi->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( dialog_resultats::OnCheckPubli ), NULL, this ); | |||
@@ -56,6 +56,7 @@ class dialog_resultats : public wxDialog | |||
wxButton* bouton_ok; | |||
// Virtual event handlers, overide them in your derived class | |||
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } | |||
virtual void OnCellClick( wxGridEvent& event ) { event.Skip(); } | |||
virtual void OnKey( wxKeyEvent& event ) { event.Skip(); } | |||
virtual void OnCheckPubli( wxCommandEvent& event ) { event.Skip(); } | |||