18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.finance.accounting.element;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
17 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
|
|
18 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
|
|
19 |
import org.openconcerto.erp.core.common.ui.PanelFrame;
|
142 |
ilm |
20 |
import org.openconcerto.erp.core.edm.AttachmentAction;
|
156 |
ilm |
21 |
import org.openconcerto.erp.core.finance.accounting.ui.AssociationAnalytiquePanel;
|
142 |
ilm |
22 |
import org.openconcerto.erp.core.finance.accounting.ui.ConsultationCompteFrame;
|
177 |
ilm |
23 |
import org.openconcerto.erp.core.finance.accounting.ui.LettragePanel;
|
19 |
ilm |
24 |
import org.openconcerto.erp.core.finance.accounting.ui.LettrageRenderer;
|
|
|
25 |
import org.openconcerto.erp.core.finance.accounting.ui.ListEcritureRenderer;
|
142 |
ilm |
26 |
import org.openconcerto.erp.core.finance.accounting.ui.ListeDesEcrituresPanel;
|
19 |
ilm |
27 |
import org.openconcerto.erp.core.finance.accounting.ui.PointageRenderer;
|
18 |
ilm |
28 |
import org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel;
|
|
|
29 |
import org.openconcerto.sql.Configuration;
|
|
|
30 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
|
|
31 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
32 |
import org.openconcerto.sql.element.SQLElement;
|
132 |
ilm |
33 |
import org.openconcerto.sql.element.TreesOfSQLRows;
|
93 |
ilm |
34 |
import org.openconcerto.sql.model.FieldPath;
|
18 |
ilm |
35 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
36 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
37 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
180 |
ilm |
38 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
18 |
ilm |
39 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
40 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
41 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
42 |
import org.openconcerto.sql.model.Where;
|
93 |
ilm |
43 |
import org.openconcerto.sql.model.graph.Path;
|
18 |
ilm |
44 |
import org.openconcerto.sql.request.ListSQLRequest;
|
83 |
ilm |
45 |
import org.openconcerto.sql.request.UpdateBuilder;
|
18 |
ilm |
46 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
47 |
import org.openconcerto.sql.users.UserManager;
|
|
|
48 |
import org.openconcerto.sql.utils.SQLUtils;
|
|
|
49 |
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
|
|
|
50 |
import org.openconcerto.sql.view.EditFrame;
|
93 |
ilm |
51 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
|
156 |
ilm |
52 |
import org.openconcerto.sql.view.list.IListe;
|
142 |
ilm |
53 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
|
|
54 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
19 |
ilm |
55 |
import org.openconcerto.sql.view.list.SQLTableModelColumn;
|
142 |
ilm |
56 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
19 |
ilm |
57 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
18 |
ilm |
58 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
59 |
import org.openconcerto.ui.JDate;
|
93 |
ilm |
60 |
import org.openconcerto.ui.component.InteractionMode;
|
|
|
61 |
import org.openconcerto.utils.CollectionUtils;
|
18 |
ilm |
62 |
import org.openconcerto.utils.ExceptionHandler;
|
142 |
ilm |
63 |
import org.openconcerto.utils.convertor.ValueConvertor;
|
18 |
ilm |
64 |
|
|
|
65 |
import java.awt.GridBagConstraints;
|
|
|
66 |
import java.awt.GridBagLayout;
|
142 |
ilm |
67 |
import java.awt.event.ActionEvent;
|
18 |
ilm |
68 |
import java.awt.event.KeyAdapter;
|
|
|
69 |
import java.awt.event.KeyEvent;
|
142 |
ilm |
70 |
import java.math.BigDecimal;
|
|
|
71 |
import java.math.BigInteger;
|
18 |
ilm |
72 |
import java.sql.SQLException;
|
|
|
73 |
import java.util.ArrayList;
|
80 |
ilm |
74 |
import java.util.Collection;
|
18 |
ilm |
75 |
import java.util.Date;
|
|
|
76 |
import java.util.List;
|
93 |
ilm |
77 |
import java.util.Set;
|
18 |
ilm |
78 |
|
142 |
ilm |
79 |
import javax.swing.AbstractAction;
|
18 |
ilm |
80 |
import javax.swing.JFrame;
|
|
|
81 |
import javax.swing.JLabel;
|
|
|
82 |
import javax.swing.JOptionPane;
|
|
|
83 |
import javax.swing.JTextField;
|
|
|
84 |
import javax.swing.SwingUtilities;
|
|
|
85 |
|
|
|
86 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
|
|
87 |
|
|
|
88 |
public class EcritureSQLElement extends ComptaSQLConfElement {
|
|
|
89 |
|
|
|
90 |
public EcritureSQLElement() {
|
|
|
91 |
super("ECRITURE", "une écriture", "écritures");
|
142 |
ilm |
92 |
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction("ID_MOUVEMENT").getAction(), true);
|
|
|
93 |
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
94 |
getRowActions().add(actionAttachment);
|
156 |
ilm |
95 |
|
|
|
96 |
PredicateRowAction consult = new PredicateRowAction(new AbstractAction("Consultation du compte") {
|
|
|
97 |
public void actionPerformed(ActionEvent event) {
|
|
|
98 |
SQLRowAccessor row = IListe.get(event).getSelectedRow();
|
|
|
99 |
consultationCompte(ComptePCESQLElement.getRow(row.getString("COMPTE_NUMERO"), row.getString("COMPTE_NOM")));
|
|
|
100 |
}
|
|
|
101 |
}, false);
|
|
|
102 |
consult.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
103 |
getRowActions().add(consult);
|
|
|
104 |
|
177 |
ilm |
105 |
PredicateRowAction interrogation = new PredicateRowAction(new AbstractAction("Interrogation du compte") {
|
|
|
106 |
public void actionPerformed(ActionEvent event) {
|
|
|
107 |
|
|
|
108 |
SQLRowAccessor row = IListe.get(event).getSelectedRow();
|
|
|
109 |
|
|
|
110 |
PanelFrame f = new PanelFrame(new LettragePanel(row.getForeignID("ID_COMPTE_PCE")), "Lettrage manuel par compte");
|
|
|
111 |
f.setVisible(true);
|
|
|
112 |
}
|
|
|
113 |
}, false);
|
|
|
114 |
interrogation.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
115 |
getRowActions().add(interrogation);
|
|
|
116 |
|
156 |
ilm |
117 |
PredicateRowAction contre = new PredicateRowAction(new AbstractAction("Contrepassation") {
|
|
|
118 |
public void actionPerformed(ActionEvent event) {
|
|
|
119 |
EcritureSQLElement.contrePassationPiece(IListe.get(event).getSelectedId());
|
|
|
120 |
}
|
|
|
121 |
}, false);
|
|
|
122 |
contre.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
123 |
getRowActions().add(contre);
|
|
|
124 |
// menuDroit.add(new AbstractAction("Valider le mouvement") {
|
|
|
125 |
// public void actionPerformed(ActionEvent event) {
|
|
|
126 |
// if (JOptionPane.showConfirmDialog(null, "Etes vous sûr de vouloir valider le
|
|
|
127 |
// mouvement?") == JOptionPane.YES_OPTION) {
|
|
|
128 |
// EcritureSQLElement.validationEcritures(frame.getPanel().getListe().getSelectedRow().getInt("ID_MOUVEMENT"));
|
|
|
129 |
// }
|
|
|
130 |
// }
|
|
|
131 |
// });
|
|
|
132 |
|
|
|
133 |
PredicateRowAction clone = new PredicateRowAction(new AbstractAction("Dupliquer") {
|
|
|
134 |
public void actionPerformed(ActionEvent event) {
|
|
|
135 |
EcritureSQLElement.dupliquer(IListe.get(event).fetchSelectedRow());
|
|
|
136 |
}
|
|
|
137 |
}, false);
|
|
|
138 |
clone.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
139 |
getRowActions().add(clone);
|
|
|
140 |
|
|
|
141 |
PredicateRowAction an = new PredicateRowAction(new AbstractAction("Gérer l'analytique") {
|
|
|
142 |
public void actionPerformed(ActionEvent event) {
|
|
|
143 |
PanelFrame frameAssoc = new PanelFrame(new AssociationAnalytiquePanel(IListe.get(event).getSelectedRow().asRow()), "Association analytique");
|
|
|
144 |
frameAssoc.setVisible(true);
|
|
|
145 |
}
|
|
|
146 |
}, false);
|
|
|
147 |
an.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
148 |
getRowActions().add(an);
|
|
|
149 |
|
|
|
150 |
PredicateRowAction show = new PredicateRowAction(new AbstractAction("Voir la source") {
|
|
|
151 |
public void actionPerformed(ActionEvent event) {
|
|
|
152 |
|
|
|
153 |
SQLRow row = IListe.get(event).fetchSelectedRow();
|
|
|
154 |
|
|
|
155 |
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
|
|
|
156 |
}
|
|
|
157 |
}, false);
|
|
|
158 |
show.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
|
|
159 |
getRowActions().add(show);
|
18 |
ilm |
160 |
}
|
|
|
161 |
|
132 |
ilm |
162 |
@Override
|
|
|
163 |
protected String getParentFFName() {
|
|
|
164 |
return "ID_MOUVEMENT";
|
|
|
165 |
}
|
|
|
166 |
|
174 |
ilm |
167 |
@Override
|
|
|
168 |
public boolean isPrivate() {
|
|
|
169 |
return false;
|
|
|
170 |
}
|
|
|
171 |
|
18 |
ilm |
172 |
// Impossible de modifier si validée
|
|
|
173 |
// FIXME impossible de saisir une écriture avant la date de debut d'exercice --> de saisir de
|
|
|
174 |
// document de gest comm
|
|
|
175 |
|
|
|
176 |
public List<String> getListFields() {
|
|
|
177 |
final List<String> l = new ArrayList<String>();
|
21 |
ilm |
178 |
l.add("VALIDE");
|
18 |
ilm |
179 |
l.add("ID_MOUVEMENT");
|
93 |
ilm |
180 |
if (getTable().contains("NOM_PIECE")) {
|
|
|
181 |
l.add("NOM_PIECE");
|
|
|
182 |
}
|
18 |
ilm |
183 |
// l.add("ID_COMPTE_PCE");
|
|
|
184 |
l.add("COMPTE_NUMERO");
|
|
|
185 |
l.add("COMPTE_NOM");
|
|
|
186 |
// l.add("ID_JOURNAL");
|
|
|
187 |
l.add("JOURNAL_NOM");
|
|
|
188 |
l.add("NOM");
|
|
|
189 |
l.add("DATE");
|
|
|
190 |
|
|
|
191 |
l.add("DEBIT");
|
|
|
192 |
l.add("CREDIT");
|
|
|
193 |
|
|
|
194 |
return l;
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
protected List<String> getComboFields() {
|
|
|
198 |
final List<String> l = new ArrayList<String>();
|
|
|
199 |
l.add("NOM");
|
|
|
200 |
l.add("DATE");
|
|
|
201 |
l.add("DEBIT");
|
|
|
202 |
l.add("CREDIT");
|
|
|
203 |
l.add("ID_JOURNAL");
|
|
|
204 |
l.add("ID_MOUVEMENT");
|
|
|
205 |
return l;
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
@Override
|
132 |
ilm |
209 |
protected void _initListRequest(ListSQLRequest req) {
|
|
|
210 |
super._initListRequest(req);
|
|
|
211 |
req.addToGraphToFetch("VALIDE");
|
19 |
ilm |
212 |
}
|
|
|
213 |
|
142 |
ilm |
214 |
public void consultationCompte(SQLRowAccessor rowCpt) {
|
174 |
ilm |
215 |
final ListeDesEcrituresPanel panel = new ListeDesEcrituresPanel();
|
|
|
216 |
final ConsultationCompteFrame f = new ConsultationCompteFrame(panel, rowCpt);
|
142 |
ilm |
217 |
|
151 |
ilm |
218 |
f.getPanel().getListe().setModificationAllowed(false);
|
142 |
ilm |
219 |
f.pack();
|
|
|
220 |
f.setVisible(true);
|
|
|
221 |
}
|
|
|
222 |
|
19 |
ilm |
223 |
@Override
|
142 |
ilm |
224 |
protected void _initTableSource(SQLTableModelSource res) {
|
19 |
ilm |
225 |
super._initTableSource(res);
|
142 |
ilm |
226 |
BaseSQLTableModelColumn analytique = new BaseSQLTableModelColumn("Poste analytique", String.class) {
|
|
|
227 |
|
|
|
228 |
@Override
|
|
|
229 |
protected Object show_(SQLRowAccessor r) {
|
|
|
230 |
Collection<? extends SQLRowAccessor> assocs = r.getReferentRows(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
|
|
|
231 |
StringBuffer res = new StringBuffer();
|
|
|
232 |
|
|
|
233 |
for (SQLRowAccessor sqlRowAccessor : assocs) {
|
|
|
234 |
res.append(sqlRowAccessor.getForeign("ID_POSTE_ANALYTIQUE").getString("NOM"));
|
|
|
235 |
res.append(", ");
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
return res.toString();
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
@Override
|
|
|
242 |
public Set<FieldPath> getPaths() {
|
|
|
243 |
Path p = new Path(getTable());
|
|
|
244 |
p = p.add(getTable().getTable("ASSOCIATION_ANALYTIQUE"));
|
|
|
245 |
p = p.add(p.getLast().getForeignTable("ID_POSTE_ANALYTIQUE"));
|
|
|
246 |
return CollectionUtils.createSet(new FieldPath(p, "NOM"));
|
|
|
247 |
}
|
|
|
248 |
};
|
|
|
249 |
res.getColumns().add(analytique);
|
19 |
ilm |
250 |
for (SQLTableModelColumn col : res.getColumns()) {
|
|
|
251 |
col.setRenderer(ListEcritureRenderer.UTILS.getRenderer(col.getRenderer()));
|
|
|
252 |
}
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
public final SQLTableModelSourceOnline createPointageTableSource() {
|
|
|
256 |
final List<String> listEcriture = new ArrayList<String>();
|
|
|
257 |
listEcriture.add("POINTEE");
|
|
|
258 |
listEcriture.add("DATE_POINTEE");
|
|
|
259 |
listEcriture.add("ID_MOUVEMENT");
|
|
|
260 |
listEcriture.add("NOM");
|
|
|
261 |
listEcriture.add("DATE");
|
|
|
262 |
listEcriture.add("DEBIT");
|
|
|
263 |
listEcriture.add("CREDIT");
|
142 |
ilm |
264 |
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
|
|
|
265 |
for (SQLTableModelColumn col : res.getColumns()) {
|
|
|
266 |
if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
|
|
|
267 |
col.setConverter(new ValueConvertor<Number, BigDecimal>() {
|
|
|
268 |
@Override
|
|
|
269 |
public BigDecimal convert(Number o) {
|
|
|
270 |
if (o == null) {
|
|
|
271 |
return BigDecimal.ZERO;
|
|
|
272 |
}
|
|
|
273 |
return new BigDecimal(o.longValue()).movePointLeft(2);
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
@Override
|
|
|
277 |
public Number unconvert(BigDecimal o) {
|
|
|
278 |
|
|
|
279 |
if (o == null) {
|
|
|
280 |
return 0;
|
|
|
281 |
}
|
|
|
282 |
return o.movePointRight(2);
|
|
|
283 |
}
|
|
|
284 |
}, BigDecimal.class);
|
|
|
285 |
col.setRenderer(CURRENCY_RENDERER);
|
|
|
286 |
}
|
|
|
287 |
|
|
|
288 |
col.setRenderer(PointageRenderer.UTILS.getRenderer(col.getRenderer()));
|
19 |
ilm |
289 |
}
|
142 |
ilm |
290 |
return this.initTableSource(res, true);
|
19 |
ilm |
291 |
}
|
|
|
292 |
|
|
|
293 |
public final SQLTableModelSourceOnline createLettrageTableSource() {
|
|
|
294 |
final List<String> listEcriture = new ArrayList<String>();
|
|
|
295 |
listEcriture.add("LETTRAGE");
|
180 |
ilm |
296 |
listEcriture.add("LETTRAGE_PARTIEL");
|
19 |
ilm |
297 |
listEcriture.add("ID_COMPTE_PCE");
|
|
|
298 |
listEcriture.add("ID_MOUVEMENT");
|
94 |
ilm |
299 |
if (getTable().contains("NOM_PIECE")) {
|
|
|
300 |
listEcriture.add("NOM_PIECE");
|
|
|
301 |
}
|
19 |
ilm |
302 |
listEcriture.add("NOM");
|
|
|
303 |
listEcriture.add("DATE_LETTRAGE");
|
|
|
304 |
listEcriture.add("DATE");
|
|
|
305 |
listEcriture.add("DEBIT");
|
|
|
306 |
listEcriture.add("CREDIT");
|
142 |
ilm |
307 |
final SQLTableModelSourceOnline res = this.instantiateTableSourceOnline(this.createListRequest(listEcriture));
|
|
|
308 |
for (SQLTableModelColumn col : res.getColumns()) {
|
|
|
309 |
if (col.getValueClass() == Long.class || col.getValueClass() == BigInteger.class) {
|
|
|
310 |
col.setConverter(new ValueConvertor<Number, BigDecimal>() {
|
|
|
311 |
@Override
|
|
|
312 |
public BigDecimal convert(Number o) {
|
|
|
313 |
if (o == null) {
|
|
|
314 |
return BigDecimal.ZERO;
|
|
|
315 |
}
|
|
|
316 |
return new BigDecimal(o.longValue()).movePointLeft(2);
|
|
|
317 |
}
|
19 |
ilm |
318 |
|
142 |
ilm |
319 |
@Override
|
|
|
320 |
public Number unconvert(BigDecimal o) {
|
93 |
ilm |
321 |
|
142 |
ilm |
322 |
if (o == null) {
|
|
|
323 |
return 0;
|
|
|
324 |
}
|
|
|
325 |
return o.movePointRight(2);
|
|
|
326 |
}
|
|
|
327 |
}, BigDecimal.class);
|
|
|
328 |
col.setRenderer(CURRENCY_RENDERER);
|
93 |
ilm |
329 |
}
|
142 |
ilm |
330 |
col.setRenderer(LettrageRenderer.UTILS.getRenderer(col.getRenderer()));
|
|
|
331 |
}
|
|
|
332 |
return this.initTableSource(res, true);
|
93 |
ilm |
333 |
}
|
|
|
334 |
|
18 |
ilm |
335 |
/*
|
|
|
336 |
* (non-Javadoc)
|
|
|
337 |
*
|
|
|
338 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
339 |
*/
|
|
|
340 |
public SQLComponent createComponent() {
|
|
|
341 |
return new BaseSQLComponent(this) {
|
|
|
342 |
|
|
|
343 |
private JTextField nom;
|
|
|
344 |
private DeviseField debit;
|
|
|
345 |
private DeviseField credit;
|
|
|
346 |
private JDate date;
|
|
|
347 |
private ElementComboBox journal;
|
|
|
348 |
|
|
|
349 |
public void addViews() {
|
|
|
350 |
this.setLayout(new GridBagLayout());
|
|
|
351 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
352 |
|
|
|
353 |
this.nom = new JTextField();
|
|
|
354 |
this.debit = new DeviseField();
|
|
|
355 |
this.credit = new DeviseField();
|
|
|
356 |
this.date = new JDate();
|
|
|
357 |
this.journal = new ElementComboBox();
|
|
|
358 |
// Mouvement
|
|
|
359 |
/*
|
|
|
360 |
* JLabel labelMouvement = new JLabel("Mouvement"); this.add(labelMouvement, c);
|
|
|
361 |
*
|
|
|
362 |
* c.gridx ++; c.weightx = 1; this.add(idMouvement, c);
|
|
|
363 |
*/
|
|
|
364 |
|
|
|
365 |
// Journal
|
|
|
366 |
JLabel labelJournal = new JLabel("Journal");
|
|
|
367 |
c.gridx = 0;
|
|
|
368 |
this.add(labelJournal, c);
|
|
|
369 |
|
|
|
370 |
c.gridx++;
|
|
|
371 |
c.weightx = 1;
|
|
|
372 |
this.add(this.journal, c);
|
|
|
373 |
|
|
|
374 |
// Date
|
|
|
375 |
JLabel labelDate = new JLabel("Date");
|
|
|
376 |
c.gridx++;
|
|
|
377 |
this.add(labelDate, c);
|
|
|
378 |
|
|
|
379 |
c.gridx++;
|
|
|
380 |
c.weightx = 1;
|
|
|
381 |
this.add(this.date, c);
|
|
|
382 |
|
|
|
383 |
// libellé
|
|
|
384 |
JLabel labelNom = new JLabel("Libellé");
|
|
|
385 |
c.gridy++;
|
|
|
386 |
c.gridx = 0;
|
|
|
387 |
this.add(labelNom, c);
|
|
|
388 |
|
|
|
389 |
c.gridx++;
|
|
|
390 |
c.weightx = 1;
|
|
|
391 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
392 |
this.add(this.nom, c);
|
|
|
393 |
|
|
|
394 |
// debit
|
|
|
395 |
c.gridwidth = 1;
|
|
|
396 |
JLabel labelDebit = new JLabel("Debit");
|
|
|
397 |
c.gridy++;
|
|
|
398 |
c.gridx = 0;
|
|
|
399 |
this.add(labelDebit, c);
|
|
|
400 |
|
|
|
401 |
c.gridx++;
|
|
|
402 |
c.weightx = 1;
|
|
|
403 |
this.add(this.debit, c);
|
|
|
404 |
this.debit.addKeyListener(new KeyAdapter() {
|
|
|
405 |
public void keyReleased(KeyEvent e) {
|
|
|
406 |
if ((credit.getText().trim().length() != 0) && (debit.getText().trim().length() != 0)) {
|
|
|
407 |
credit.setText("");
|
|
|
408 |
}
|
|
|
409 |
}
|
|
|
410 |
});
|
|
|
411 |
|
|
|
412 |
// Credit
|
|
|
413 |
JLabel labelCredit = new JLabel("Credit");
|
|
|
414 |
c.gridx++;
|
|
|
415 |
this.add(labelCredit, c);
|
|
|
416 |
|
|
|
417 |
c.gridx++;
|
|
|
418 |
c.weightx = 1;
|
|
|
419 |
this.add(this.credit, c);
|
|
|
420 |
|
|
|
421 |
this.credit.addKeyListener(new KeyAdapter() {
|
|
|
422 |
public void keyReleased(KeyEvent e) {
|
|
|
423 |
if ((debit.getText().trim().length() != 0) && (credit.getText().trim().length() != 0)) {
|
|
|
424 |
debit.setText("");
|
|
|
425 |
}
|
|
|
426 |
}
|
|
|
427 |
});
|
|
|
428 |
|
|
|
429 |
this.addSQLObject(this.nom, "NOM");
|
|
|
430 |
this.addSQLObject(this.debit, "DEBIT");
|
|
|
431 |
this.addSQLObject(this.credit, "CREDIT");
|
|
|
432 |
this.addRequiredSQLObject(this.date, "DATE");
|
|
|
433 |
this.addRequiredSQLObject(this.journal, "ID_JOURNAL");
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
@Override
|
|
|
437 |
public void select(SQLRowAccessor r) {
|
|
|
438 |
super.select(r);
|
|
|
439 |
|
|
|
440 |
if (r != null && r.getBoolean("VALIDE")) {
|
|
|
441 |
this.nom.setEnabled(false);
|
|
|
442 |
this.debit.setEnabled(false);
|
|
|
443 |
this.credit.setEnabled(false);
|
93 |
ilm |
444 |
this.date.setInteractionMode(InteractionMode.DISABLED);
|
18 |
ilm |
445 |
this.journal.setEnabled(false);
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
}
|
|
|
449 |
|
|
|
450 |
public void update() {
|
|
|
451 |
SQLRow row = EcritureSQLElement.this.getTable().getRow(getSelectedID());
|
|
|
452 |
if (row.getBoolean("VALIDE")) {
|
|
|
453 |
System.out.println("Impossible de modifier une ecriture validée");
|
|
|
454 |
} else {
|
|
|
455 |
super.update();
|
|
|
456 |
}
|
|
|
457 |
}
|
|
|
458 |
|
|
|
459 |
};
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
/**
|
|
|
463 |
* Validation d'un mouvement, implique la validation de l'ensemble de la piece
|
|
|
464 |
*
|
|
|
465 |
* @param idMvt
|
|
|
466 |
*/
|
|
|
467 |
private static void validerMouvement(int idMvt) {
|
|
|
468 |
|
|
|
469 |
if (idMvt == 1) {
|
|
|
470 |
return;
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
|
|
|
474 |
SQLRow rowMvt = tableMvt.getRow(idMvt);
|
|
|
475 |
|
|
|
476 |
// On parcourt en profondeur
|
|
|
477 |
if (rowMvt.getInt("ID_MOUVEMENT_PERE") > 1) {
|
|
|
478 |
validerMouvement(rowMvt.getInt("ID_MOUVEMENT_PERE"));
|
|
|
479 |
} else {
|
|
|
480 |
validerMouvementProfondeur(idMvt);
|
|
|
481 |
}
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
/**
|
|
|
485 |
* Valider l'ensemble des mouvements formés par le sous arbre de du mouvement d'id idMvtPere
|
|
|
486 |
*
|
|
|
487 |
* @param idMvtPere
|
|
|
488 |
*/
|
|
|
489 |
private static void validerMouvementProfondeur(int idMvtPere) {
|
|
|
490 |
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
491 |
SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
|
|
|
492 |
|
80 |
ilm |
493 |
SQLSelect selectFils = new SQLSelect();
|
18 |
ilm |
494 |
selectFils.addSelect(tableMvt.getField("ID"));
|
65 |
ilm |
495 |
selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
|
18 |
ilm |
496 |
|
|
|
497 |
List l = (List) base.getDataSource().execute(selectFils.asString(), new ArrayListHandler());
|
|
|
498 |
|
|
|
499 |
// valide mouvements fils
|
|
|
500 |
for (int i = 0; i < l.size(); i++) {
|
|
|
501 |
Object[] tmp = (Object[]) l.get(i);
|
|
|
502 |
validerMouvementProfondeur(Integer.parseInt(tmp[0].toString()));
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
// valide mouvement
|
|
|
506 |
validationEcritures(idMvtPere);
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
/**
|
|
|
510 |
* Valide l'ensemble des ecritures du mouvement
|
|
|
511 |
*
|
|
|
512 |
* @param idMvt Id du mouvement à valider
|
|
|
513 |
*/
|
|
|
514 |
public static final void validationEcritures(int idMvt) {
|
|
|
515 |
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
516 |
SQLTable tableEcriture = base.getTable("ECRITURE");
|
|
|
517 |
|
|
|
518 |
SQLSelect selEcriture = new SQLSelect(base);
|
|
|
519 |
selEcriture.addSelect(tableEcriture.getField("ID"));
|
|
|
520 |
|
|
|
521 |
Where w = new Where(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt);
|
|
|
522 |
|
|
|
523 |
selEcriture.setWhere(w);
|
|
|
524 |
|
|
|
525 |
String reqEcriture = selEcriture.asString();
|
|
|
526 |
|
|
|
527 |
Object obEcriture = base.getDataSource().execute(reqEcriture, new ArrayListHandler());
|
|
|
528 |
|
|
|
529 |
List myListEcriture = (List) obEcriture;
|
|
|
530 |
|
|
|
531 |
if (myListEcriture.size() != 0) {
|
|
|
532 |
|
|
|
533 |
for (int i = 0; i < myListEcriture.size(); i++) {
|
|
|
534 |
Object[] objTmp = (Object[]) myListEcriture.get(i);
|
|
|
535 |
valideEcriture(Integer.parseInt(objTmp[0].toString()));
|
|
|
536 |
}
|
|
|
537 |
}
|
|
|
538 |
}
|
|
|
539 |
|
|
|
540 |
/**
|
|
|
541 |
* Validation des ecritures avant la date d
|
|
|
542 |
*
|
|
|
543 |
* @param d date
|
|
|
544 |
* @param cloture
|
|
|
545 |
*/
|
|
|
546 |
public static final void validationEcrituresBefore(Date d, boolean cloture) {
|
|
|
547 |
|
|
|
548 |
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
549 |
SQLTable tableEcriture = base.getTable("ECRITURE");
|
|
|
550 |
|
|
|
551 |
// on recupere l'ensemble des mouvements à valider
|
|
|
552 |
SQLSelect selEcriture = new SQLSelect(base);
|
|
|
553 |
selEcriture.addSelect(tableEcriture.getField("ID_MOUVEMENT"));
|
|
|
554 |
selEcriture.setDistinct(true);
|
|
|
555 |
Where w1 = new Where(tableEcriture.getField("DATE"), "<=", d);
|
|
|
556 |
Where w2 = new Where(tableEcriture.getField("VALIDE"), "=", Boolean.FALSE);
|
|
|
557 |
selEcriture.setWhere(w1.and(w2));
|
|
|
558 |
List l = (List) base.getDataSource().execute(selEcriture.asString(), new ArrayListHandler());
|
|
|
559 |
|
|
|
560 |
// validation de tous les mouvements
|
|
|
561 |
for (int i = 0; i < l.size(); i++) {
|
|
|
562 |
Object[] tmp = (Object[]) l.get(i);
|
|
|
563 |
System.err.println("Validation du mouvement " + tmp[0]);
|
|
|
564 |
validationEcritures(Integer.parseInt(tmp[0].toString()));
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
if (cloture) {
|
|
|
568 |
|
|
|
569 |
SQLTable tableExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON");
|
|
|
570 |
|
|
|
571 |
SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
|
|
|
572 |
SQLRow rowExercice = tableExercice.getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
|
|
|
573 |
Date dateCloture = (Date) rowExercice.getObject("DATE_CLOTURE");
|
|
|
574 |
|
|
|
575 |
if (dateCloture == null || dateCloture.before(d)) {
|
|
|
576 |
|
|
|
577 |
SQLRowValues rowVals = new SQLRowValues(tableExercice);
|
|
|
578 |
rowVals.put("DATE_CLOTURE", new java.sql.Date(d.getTime()));
|
|
|
579 |
try {
|
|
|
580 |
rowVals.update(rowExercice.getID());
|
|
|
581 |
} catch (SQLException e) {
|
|
|
582 |
e.printStackTrace();
|
|
|
583 |
}
|
|
|
584 |
}
|
|
|
585 |
}
|
|
|
586 |
}
|
|
|
587 |
|
|
|
588 |
private static final void valideEcriture(int id) {
|
|
|
589 |
SQLTable tableEcriture = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("ECRITURE");
|
|
|
590 |
SQLRowValues rowVals = new SQLRowValues(tableEcriture);
|
|
|
591 |
rowVals.put("VALIDE", Boolean.TRUE);
|
|
|
592 |
rowVals.put("DATE_VALIDE", new java.sql.Date(new Date().getTime()));
|
|
|
593 |
rowVals.put("IDUSER_VALIDE", UserManager.getInstance().getCurrentUser().getId());
|
|
|
594 |
|
|
|
595 |
try {
|
|
|
596 |
rowVals.update(id);
|
|
|
597 |
} catch (SQLException e) {
|
|
|
598 |
e.printStackTrace();
|
|
|
599 |
}
|
|
|
600 |
}
|
|
|
601 |
|
|
|
602 |
public void archiveMouvement(int idMvt) {
|
|
|
603 |
SQLTable tableMouvement = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
|
|
|
604 |
SQLRow rowMvt = tableMouvement.getRow(idMvt);
|
|
|
605 |
|
|
|
606 |
if (rowMvt.getInt("ID_MOUVEMENT_PERE") > 1) {
|
|
|
607 |
archiveMouvement(rowMvt.getInt("ID_MOUVEMENT_PERE"));
|
|
|
608 |
} else {
|
|
|
609 |
archiveMouvementProfondeur(idMvt, true);
|
|
|
610 |
}
|
|
|
611 |
}
|
|
|
612 |
|
|
|
613 |
/**
|
|
|
614 |
* Archivage de l'ensemble des opérations liés au mouvement passé en parametre
|
|
|
615 |
*
|
|
|
616 |
* @param idMvtPere mouvement racine
|
|
|
617 |
* @param dropPere suppression du mouvement pere
|
|
|
618 |
*/
|
|
|
619 |
public void archiveMouvementProfondeur(int idMvtPere, boolean dropPere) {
|
|
|
620 |
if (idMvtPere > 1) {
|
|
|
621 |
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
622 |
SQLTable tableMvt = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("MOUVEMENT");
|
|
|
623 |
|
73 |
ilm |
624 |
SQLSelect selectFils = new SQLSelect();
|
18 |
ilm |
625 |
selectFils.addSelect(tableMvt.getField("ID"));
|
65 |
ilm |
626 |
selectFils.setWhere(tableMvt.getField("ID_MOUVEMENT_PERE"), "=", idMvtPere);
|
18 |
ilm |
627 |
|
|
|
628 |
List l = (List) base.getDataSource().execute(selectFils.asString(), new ArrayListHandler());
|
|
|
629 |
|
|
|
630 |
// archive mouvements fils
|
|
|
631 |
for (int i = 0; i < l.size(); i++) {
|
|
|
632 |
Object[] tmp = (Object[]) l.get(i);
|
|
|
633 |
archiveMouvementProfondeur(Integer.parseInt(tmp[0].toString()), true);
|
|
|
634 |
}
|
|
|
635 |
|
|
|
636 |
// archive mouvement
|
|
|
637 |
archiveEcritures(idMvtPere, dropPere);
|
|
|
638 |
|
|
|
639 |
} else {
|
|
|
640 |
|
|
|
641 |
System.err.println("Suppression du mouvement d'id 1 impossible.");
|
83 |
ilm |
642 |
JOptionPane.showMessageDialog(null, "Impossible d'archiver, le mouvement est indéfini.");
|
18 |
ilm |
643 |
}
|
|
|
644 |
}
|
|
|
645 |
|
|
|
646 |
// Suppression des ecritures associées à un mouvement
|
93 |
ilm |
647 |
public synchronized void archiveEcritures(final int idMvt, final boolean dropMvt) {
|
18 |
ilm |
648 |
final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
649 |
final SQLTable tableMvt = base.getTable("MOUVEMENT");
|
|
|
650 |
final SQLTable tableEcriture = base.getTable("ECRITURE");
|
|
|
651 |
final SQLRow rowMvt = tableMvt.getRow(idMvt);
|
|
|
652 |
|
|
|
653 |
// on verifie que le mouvement n'est pas validé
|
|
|
654 |
if (MouvementSQLElement.isEditable(idMvt)) {
|
|
|
655 |
|
|
|
656 |
// on archive le mouvement
|
|
|
657 |
if (dropMvt) {
|
174 |
ilm |
658 |
|
|
|
659 |
SQLElement elt = getDirectory().getElement(tableMvt);
|
|
|
660 |
|
18 |
ilm |
661 |
try {
|
|
|
662 |
elt.archive(idMvt);
|
|
|
663 |
} catch (SQLException e) {
|
|
|
664 |
ExceptionHandler.handle("Erreur lors de la suppression du mouvement d'id [" + idMvt + "]", e);
|
|
|
665 |
e.printStackTrace();
|
|
|
666 |
}
|
|
|
667 |
} else {
|
|
|
668 |
|
|
|
669 |
SQLFactory<Object> sqlFactory = new SQLFactory<Object>() {
|
|
|
670 |
@Override
|
|
|
671 |
public Object create() throws SQLException {
|
|
|
672 |
// on recupere l'ensemble des ecritures associées au mouvement
|
180 |
ilm |
673 |
|
73 |
ilm |
674 |
SQLSelect selEcritures = new SQLSelect();
|
18 |
ilm |
675 |
selEcritures.addSelect(tableEcriture.getField("ID"));
|
180 |
ilm |
676 |
selEcritures.addSelect(tableEcriture.getField("VALIDE"));
|
|
|
677 |
selEcritures.addSelect(tableEcriture.getField("LETTRAGE"));
|
65 |
ilm |
678 |
selEcritures.setWhere(tableEcriture.getField("ID_MOUVEMENT"), "=", idMvt);
|
18 |
ilm |
679 |
|
180 |
ilm |
680 |
List<SQLRow> rowEcr = SQLRowListRSH.execute(selEcritures);
|
|
|
681 |
for (SQLRow r : rowEcr) {
|
|
|
682 |
archiveEcriture(r);
|
18 |
ilm |
683 |
}
|
|
|
684 |
|
|
|
685 |
return null;
|
|
|
686 |
}
|
|
|
687 |
};
|
|
|
688 |
|
|
|
689 |
try {
|
|
|
690 |
SQLUtils.executeAtomic(base.getDataSource(), sqlFactory);
|
|
|
691 |
} catch (SQLException e) {
|
73 |
ilm |
692 |
|
|
|
693 |
ExceptionHandler.handle("Une erreur est survenue lors de la suppression des écritures.", e);
|
18 |
ilm |
694 |
}
|
|
|
695 |
}
|
|
|
696 |
|
|
|
697 |
} else {
|
156 |
ilm |
698 |
JOptionPane.showMessageDialog(null, "Impossible de supprimer le mouvement n°" + rowMvt.getInt("NUMERO") + " car il est validé.");
|
18 |
ilm |
699 |
}
|
|
|
700 |
}
|
|
|
701 |
|
|
|
702 |
@Override
|
132 |
ilm |
703 |
protected void archive(TreesOfSQLRows trees, boolean cutLinks) throws SQLException {
|
|
|
704 |
for (SQLRow row : trees.getRows()) {
|
|
|
705 |
// Si on supprime une ecriture on doit supprimer toutes les ecritures du mouvement
|
|
|
706 |
// associé
|
|
|
707 |
System.err.println("Archivage des écritures");
|
|
|
708 |
// archiveMouvement(row.getInt("ID_MOUVEMENT"));
|
|
|
709 |
JFrame frame = new PanelFrame(new SuppressionEcrituresPanel(row.getInt("ID_MOUVEMENT")), "Suppression d'ecritures");
|
|
|
710 |
frame.pack();
|
|
|
711 |
frame.setResizable(false);
|
|
|
712 |
frame.setLocationRelativeTo(null);
|
|
|
713 |
frame.setVisible(true);
|
|
|
714 |
}
|
18 |
ilm |
715 |
}
|
|
|
716 |
|
|
|
717 |
/**
|
|
|
718 |
* Permet d'archiver une ecriture seule attention méthode à utiliser en vérifiant que la balance
|
|
|
719 |
* est respectée
|
|
|
720 |
*
|
|
|
721 |
* @param row
|
|
|
722 |
* @throws SQLException
|
|
|
723 |
*/
|
180 |
ilm |
724 |
public void archiveEcriture(SQLRowAccessor row) throws SQLException {
|
18 |
ilm |
725 |
|
|
|
726 |
if (!row.getBoolean("VALIDE")) {
|
|
|
727 |
|
180 |
ilm |
728 |
UpdateBuilder builderArc = new UpdateBuilder(getTable());
|
|
|
729 |
builderArc.setObject("IDUSER_DELETE", UserManager.getInstance().getCurrentUser().getId());
|
|
|
730 |
builderArc.setObject("ARCHIVE", 1);
|
|
|
731 |
builderArc.setWhere(new Where(getTable().getKey(), "=", row.getID()));
|
|
|
732 |
getTable().getDBSystemRoot().getDataSource().execute(builderArc.asString());
|
18 |
ilm |
733 |
|
83 |
ilm |
734 |
// Annulation du lettrage si l'ecriture est lettrée pour ne pas avoir de lettrage
|
|
|
735 |
// déséquilibré
|
|
|
736 |
final String codeLettrage = row.getString("LETTRAGE");
|
|
|
737 |
if (codeLettrage != null && codeLettrage.trim().length() > 0) {
|
|
|
738 |
UpdateBuilder builder = new UpdateBuilder(getTable());
|
|
|
739 |
builder.setObject("LETTRAGE", "");
|
|
|
740 |
builder.setObject("DATE_LETTRAGE", null);
|
|
|
741 |
builder.setWhere(new Where(getTable().getField("LETTRAGE"), "=", codeLettrage));
|
|
|
742 |
getTable().getDBSystemRoot().getDataSource().execute(builder.asString());
|
|
|
743 |
}
|
180 |
ilm |
744 |
getTable().fireRowDeleted(row.getID());
|
132 |
ilm |
745 |
// super.archive(row, true);
|
18 |
ilm |
746 |
} else {
|
|
|
747 |
System.err.println("Impossible de supprimer une ecriture validée");
|
|
|
748 |
JOptionPane.showMessageDialog(null, "Impossible de supprimer une ecriture validée. \n" + row);
|
|
|
749 |
}
|
|
|
750 |
}
|
|
|
751 |
|
|
|
752 |
private static EditFrame frameSaisieKm = null;
|
|
|
753 |
|
|
|
754 |
/**
|
|
|
755 |
* Contrepassation d'un piece comptable à partir de l'id d'une écriture. Chargement d'un panel
|
|
|
756 |
* Saisie au Km avec les ecritures inversées
|
|
|
757 |
*
|
|
|
758 |
* @param id
|
|
|
759 |
*/
|
|
|
760 |
public static void contrePassationPiece(int id) {
|
|
|
761 |
|
|
|
762 |
SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
|
|
763 |
|
|
|
764 |
SQLTable tableEcriture = base.getTable("ECRITURE");
|
|
|
765 |
SQLRow rowEcr = tableEcriture.getRow(id);
|
|
|
766 |
final int idMvt = rowEcr.getInt("ID_MOUVEMENT");
|
|
|
767 |
System.err.println("ID MOUVEMENT --> " + idMvt);
|
|
|
768 |
if (frameSaisieKm == null) {
|
|
|
769 |
frameSaisieKm = new EditFrame(Configuration.getInstance().getDirectory().getElement("SAISIE_KM"));
|
|
|
770 |
}
|
|
|
771 |
|
|
|
772 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
773 |
public void run() {
|
|
|
774 |
SaisieKmSQLElement.loadContrePassation(frameSaisieKm.getSQLComponent(), idMvt);
|
|
|
775 |
}
|
|
|
776 |
});
|
|
|
777 |
frameSaisieKm.setVisible(true);
|
|
|
778 |
}
|
57 |
ilm |
779 |
|
|
|
780 |
@Override
|
|
|
781 |
protected String createCode() {
|
156 |
ilm |
782 |
return createCodeOfPackage() + ".entry.item";
|
57 |
ilm |
783 |
}
|
80 |
ilm |
784 |
|
|
|
785 |
public static void dupliquer(SQLRow selectedRow) {
|
|
|
786 |
|
|
|
787 |
final SQLRow foreignMvt = selectedRow.getForeign("ID_MOUVEMENT");
|
|
|
788 |
if (foreignMvt.getString("SOURCE").equalsIgnoreCase("SAISIE_KM")) {
|
|
|
789 |
final SQLElement elementSaisieKm = Configuration.getInstance().getDirectory().getElement("SAISIE_KM");
|
|
|
790 |
final SQLElement elementSaisieKmItem = Configuration.getInstance().getDirectory().getElement("SAISIE_KM_ELEMENT");
|
|
|
791 |
final EditFrame frameCloneSaisieKm = new EditFrame(elementSaisieKm);
|
|
|
792 |
int idSource = foreignMvt.getInt("IDSOURCE");
|
|
|
793 |
SQLRow rowKm = elementSaisieKm.getTable().getRow(idSource);
|
|
|
794 |
final SQLRowValues rowVals = elementSaisieKm.createCopy(idSource);
|
|
|
795 |
rowVals.put("ID_MOUVEMENT", null);
|
|
|
796 |
Collection<SQLRow> items = rowKm.getReferentRows(elementSaisieKm.getTable().getTable("SAISIE_KM_ELEMENT"));
|
|
|
797 |
for (SQLRow sqlRow : items) {
|
|
|
798 |
SQLRowValues sqlRowValues = elementSaisieKmItem.createCopy(sqlRow.getID());
|
|
|
799 |
sqlRowValues.put("ID_ECRITURE", null);
|
|
|
800 |
sqlRowValues.put("ID_SAISIE_KM", rowVals);
|
|
|
801 |
System.err.println("ADD ELEMENT KM :: " + sqlRowValues.getID());
|
|
|
802 |
}
|
|
|
803 |
|
|
|
804 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
805 |
public void run() {
|
|
|
806 |
frameCloneSaisieKm.getSQLComponent().select(rowVals);
|
|
|
807 |
}
|
|
|
808 |
});
|
|
|
809 |
frameCloneSaisieKm.setVisible(true);
|
|
|
810 |
} else {
|
|
|
811 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
812 |
public void run() {
|
|
|
813 |
JOptionPane.showMessageDialog(null, "La duplication n'est possible que sur les saisies au kilomètre");
|
|
|
814 |
}
|
|
|
815 |
});
|
|
|
816 |
}
|
|
|
817 |
}
|
18 |
ilm |
818 |
}
|