~igor-cali/bilancio/stable

« back to all changes in this revision

Viewing changes to src/ombtray/datawithalarms.cpp

  • Committer: Igor Calì
  • Date: 2019-04-07 16:24:48 UTC
  • Revision ID: igor.cali0@gmail.com-20190407162448-5mfwr7c39y3kzz6u
 v3.3.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * Name:      datawithalarms.cpp
3
3
 * Purpose:   Alarm extension for TData
4
4
 * Author:    Igor Calì (igor.cali0@gmail.com)
5
 
 * Created:   2017-09-10
 
5
 * Created:   2019-02-10
6
6
 * Copyright: Igor Calì (igor.cali0@gmail.com)
7
7
 * License:             GNU
8
8
 **************************************************************/
13
13
#include "ui/Alarm.h"
14
14
#include "../constants.h"
15
15
 
 
16
#ifdef _OMB_USE_CIPHER
 
17
        extern int ExecuteUpdate(sqlite3 *m_db, const char* sql/*, bool saveRC = false*/);
 
18
#endif // _OMB_USE_CIPHER
 
19
 
16
20
TDataWithAlarms::TDataWithAlarms(void):TData_v32(NULL){
17
21
        SoundFile = GetDataDir() + L"alarm_clock.wav";}
18
22
 
50
54
                delete sound;}
51
55
                if(PostAll){
52
56
                        ShopItems[i].Alarm = AlarmF->DatePicker->GetValue();
53
 
                        database->ExecuteUpdate(L"update Shoplist set alarm = " +
 
57
                        #ifdef _OMB_USE_CIPHER
 
58
                                wxString update = L"update Shoplist set alarm = " +
 
59
                                                                                                                                wxString::Format(L"%d", (int) ShopItems[i].Alarm.GetTicks()) +
 
60
                                                                                                                                L" where id = " +
 
61
                                                                                                                                wxString::Format(L"%d", ShopItems[i].Id) +
 
62
                                                                                                                                L";";
 
63
        #ifdef __OPENSUSE__
 
64
          ExecuteUpdate(database, update.c_str());
 
65
        #else
 
66
          ExecuteUpdate(database, update);
 
67
        #endif
 
68
                        #else
 
69
                                database->ExecuteUpdate(L"update Shoplist set alarm = " +
54
70
                                                                                                                                wxString::Format(L"%d", (int) ShopItems[i].Alarm.GetTicks()) +
55
71
                                                                                                                                L" where id = " +
56
72
                                                                                                                                wxString::Format(L"%d", ShopItems[i].Id) +
57
73
                                                                                                                                L";");
 
74
                        #endif // _OMB_USE_CIPHER
58
75
                }
59
 
                else{
 
76
                else{
 
77
                        #ifdef _OMB_USE_CIPHER
 
78
                                wxString Sql;
 
79
                        #endif // _OMB_USE_CIPHER
60
80
                        switch(AlarmF->ShowModal()){
61
81
                                case wxID_OK:
62
82
                                        ShopItems[i].Alarm=AlarmF->DatePicker->GetValue();
63
 
                                        database->ExecuteUpdate(L"update Shoplist set alarm = " +
 
83
                                        #ifdef _OMB_USE_CIPHER
 
84
                                                Sql = L"update Shoplist set alarm = " +
 
85
                                                                                                                                                wxString::Format(L"%d", (int) ShopItems[i].Alarm.GetTicks()) +
 
86
                                                                                                                                                L" where id = " +
 
87
                                                                                                                                                wxString::Format(L"%d", ShopItems[i].Id) +
 
88
                                                                                                                                                L";";
 
89
            #ifdef __OPENSUSE__
 
90
              ExecuteUpdate(database, Sql.c_str());
 
91
            #else
 
92
              ExecuteUpdate(database, Sql);
 
93
            #endif
 
94
                                        #else
 
95
                                                database->ExecuteUpdate(L"update Shoplist set alarm = " +
64
96
                                                                                                                                                wxString::Format(L"%d", (int) ShopItems[i].Alarm.GetTicks()) +
65
97
                                                                                                                                                L" where id = " +
66
98
                                                                                                                                                wxString::Format(L"%d", ShopItems[i].Id) +
67
99
                                                                                                                                                L";");
 
100
                                        #endif // _OMB_USE_CIPHER
68
101
                                        if(AlarmF->cb_PostponeAll->IsChecked())PostAll=true;
69
102
                                        break;
70
103
                        case wxID_CANCEL:
89
122
                        delete sound;}
90
123
                if(PostAll){
91
124
                Lent[i].Alarm=AlarmF->DatePicker->GetValue();
92
 
                database->ExecuteUpdate(L"update Loans set alarm = " +
 
125
                #ifdef _OMB_USE_CIPHER
 
126
                        wxString update = L"update Loans set alarm = " +
 
127
                                                                                                                        wxString::Format(L"%d", (int) Lent[i].Alarm.GetTicks()) +
 
128
                                                                                                                        L" where id = " +
 
129
                                                                                                                        wxString::Format(L"%d", Lent[i].Id) +
 
130
                                                                                                                        L";";
 
131
                        #ifdef __OPENSUSE__
 
132
        ExecuteUpdate(database, update.c_str());
 
133
                        #else
 
134
        ExecuteUpdate(database, update);
 
135
      #endif
 
136
                #else
 
137
                        database->ExecuteUpdate(L"update Loans set alarm = " +
93
138
                                                                                                                        wxString::Format(L"%d", (int) Lent[i].Alarm.GetTicks()) +
94
139
                                                                                                                        L" where id = " +
95
140
                                                                                                                        wxString::Format(L"%d", Lent[i].Id) +
96
141
                                                                                                                        L";");
 
142
                #endif // _OMB_USE_CIPHER
97
143
                }
98
 
                else{
 
144
                else{
 
145
                        #ifdef _OMB_USE_CIPHER
 
146
                                wxString Sql;
 
147
                        #endif // _OMB_USE_CIPHER
99
148
                        switch(AlarmF->ShowModal()){
100
149
                                case wxID_OK:
101
 
                                                Lent[i].Alarm=AlarmF->DatePicker->GetValue();
 
150
                                        Lent[i].Alarm=AlarmF->DatePicker->GetValue();
 
151
                                        #ifdef _OMB_USE_CIPHER
 
152
                                                Sql = L"update Loans set alarm = " +
 
153
                                                                                                                                                wxString::Format(L"%d", (int) Lent[i].Alarm.GetTicks()) +
 
154
                                                                                                                                                L" where id = " +
 
155
                                                                                                                                                wxString::Format(L"%d", Lent[i].Id) +
 
156
                                                                                                                                                L";";
 
157
                                                #ifdef __OPENSUSE__
 
158
              ExecuteUpdate(database, Sql.c_str());
 
159
                                                #else
 
160
              ExecuteUpdate(database, Sql);
 
161
            #endif
 
162
                                        #else
102
163
                                                database->ExecuteUpdate(L"update Loans set alarm = " +
103
164
                                                                                                                                                        wxString::Format(L"%d", (int) Lent[i].Alarm.GetTicks()) +
104
165
                                                                                                                                                        L" where id = " +
105
166
                                                                                                                                                        wxString::Format(L"%d", Lent[i].Id) +
106
167
                                                                                                                                                        L";");
107
 
                                                if(AlarmF->cb_PostponeAll->IsChecked())PostAll=true;
108
 
                                                break;
 
168
                                        #endif // _OMB_USE_CIPHER
 
169
                                        if(AlarmF->cb_PostponeAll->IsChecked())PostAll=true;
 
170
                                        break;
109
171
                                case wxID_CANCEL:
110
 
                                                Lent[i].Alarm.Add(wxDateSpan(100,0,0,0));}
 
172
                                        Lent[i].Alarm.Add(wxDateSpan(100,0,0,0));}
111
173
                                FileData.Modified=true;}}
112
174
  delete AlarmF;}
113
175
 
128
190
          delete sound;}
129
191
                if(PostAll){
130
192
                        Borrowed[i].Alarm=AlarmF->DatePicker->GetValue();
131
 
                        database->ExecuteUpdate(L"update Borrows set alarm = " +
 
193
                        #ifdef _OMB_USE_CIPHER
 
194
                                wxString update = L"update Borrows set alarm = " +
 
195
                                                                                                                                wxString::Format(L"%d", (int) Borrowed[i].Alarm.GetTicks()) +
 
196
                                                                                                                                L" where id = " +
 
197
                                                                                                                                wxString::Format(L"%d", Borrowed[i].Id) +
 
198
                                                                                                                                L";";
 
199
        #ifdef __OPENSUSE__
 
200
          ExecuteUpdate(database, update.c_str());
 
201
        #else
 
202
          ExecuteUpdate(database, update);
 
203
        #endif
 
204
                        #else
 
205
                                database->ExecuteUpdate(L"update Borrows set alarm = " +
132
206
                                                                                                                                wxString::Format(L"%d", (int) Borrowed[i].Alarm.GetTicks()) +
133
207
                                                                                                                                L" where id = " +
134
208
                                                                                                                                wxString::Format(L"%d", Borrowed[i].Id) +
135
209
                                                                                                                                L";");
 
210
                        #endif // _OMB_USE_CIPHER
136
211
                }
137
212
                else{
138
213
                        switch(AlarmF->ShowModal()){