OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 144 Rev 182
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 /*
14
 /*
15
 * Créé le 19 oct. 2011
15
 * Créé le 19 oct. 2011
16
 */
16
 */
17
package org.openconcerto.erp.core.supplychain.order.element;
17
package org.openconcerto.erp.core.supplychain.order.element;
18
 
18
 
19
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
19
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
20
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
20
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
21
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
21
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
22
import org.openconcerto.erp.panel.PanelOOSQLComponent;
22
import org.openconcerto.erp.panel.PanelOOSQLComponent;
23
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.Configuration;
24
import org.openconcerto.sql.element.ElementSQLObject;
24
import org.openconcerto.sql.element.ElementSQLObject;
25
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.element.SQLElement;
-
 
26
import org.openconcerto.sql.model.SQLBackgroundTableCache;
26
import org.openconcerto.sql.model.SQLRow;
27
import org.openconcerto.sql.model.SQLRow;
27
import org.openconcerto.sql.model.SQLRowAccessor;
28
import org.openconcerto.sql.model.SQLRowAccessor;
28
import org.openconcerto.sql.model.SQLRowValues;
29
import org.openconcerto.sql.model.SQLRowValues;
29
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.sqlobject.ElementComboBox;
31
import org.openconcerto.sql.sqlobject.ElementComboBox;
31
import org.openconcerto.sql.sqlobject.JUniqueTextField;
32
import org.openconcerto.sql.sqlobject.JUniqueTextField;
32
import org.openconcerto.sql.ui.RadioButtons;
33
import org.openconcerto.sql.ui.RadioButtons;
-
 
34
import org.openconcerto.sql.users.UserManager;
33
import org.openconcerto.sql.view.EditFrame;
35
import org.openconcerto.sql.view.EditFrame;
34
import org.openconcerto.sql.view.list.RowValuesTable;
36
import org.openconcerto.sql.view.list.RowValuesTable;
35
import org.openconcerto.ui.DefaultGridBagConstraints;
37
import org.openconcerto.ui.DefaultGridBagConstraints;
36
import org.openconcerto.ui.FormLayouter;
38
import org.openconcerto.ui.FormLayouter;
37
import org.openconcerto.ui.JDate;
39
import org.openconcerto.ui.JDate;
38
import org.openconcerto.ui.TitledSeparator;
40
import org.openconcerto.ui.TitledSeparator;
39
import org.openconcerto.ui.VFlowLayout;
41
import org.openconcerto.ui.VFlowLayout;
40
import org.openconcerto.ui.component.ITextArea;
42
import org.openconcerto.ui.component.ITextArea;
41
import org.openconcerto.ui.component.InteractionMode;
43
import org.openconcerto.ui.component.InteractionMode;
42
import org.openconcerto.utils.ExceptionHandler;
44
import org.openconcerto.utils.ExceptionHandler;
43
 
45
 
44
import java.awt.GridBagConstraints;
46
import java.awt.GridBagConstraints;
45
import java.awt.GridBagLayout;
47
import java.awt.GridBagLayout;
46
import java.sql.SQLException;
48
import java.sql.SQLException;
47
import java.util.List;
49
import java.util.List;
48
 
50
 
49
import javax.swing.BorderFactory;
51
import javax.swing.BorderFactory;
50
import javax.swing.JLabel;
52
import javax.swing.JLabel;
51
import javax.swing.JPanel;
53
import javax.swing.JPanel;
52
import javax.swing.JScrollPane;
54
import javax.swing.JScrollPane;
53
import javax.swing.JTextArea;
55
import javax.swing.JTextArea;
54
import javax.swing.SwingConstants;
56
import javax.swing.SwingConstants;
55
import javax.swing.SwingUtilities;
57
import javax.swing.SwingUtilities;
56
 
58
 
57
public class DemandePrixSQLComponent extends TransfertBaseSQLComponent {
59
public class DemandePrixSQLComponent extends TransfertBaseSQLComponent {
58
    JUniqueTextField field = new JUniqueTextField();
60
    JUniqueTextField field = new JUniqueTextField();
59
    DemandePrixItemTable table = new DemandePrixItemTable();
61
    DemandePrixItemTable table = new DemandePrixItemTable();
60
    PanelOOSQLComponent panelOO;
62
    PanelOOSQLComponent panelOO;
61
    private ElementSQLObject componentPrincipaleAdr;
63
    private ElementSQLObject componentPrincipaleAdr;
62
 
64
 
63
    public DemandePrixSQLComponent(SQLElement elt) {
65
    public DemandePrixSQLComponent(SQLElement elt) {
64
        super(elt);
66
        super(elt);
65
    }
67
    }
66
 
68
 
67
    @Override
69
    @Override
68
    protected void addViews() {
70
    protected void addViews() {
69
 
71
 
70
        GridBagConstraints c = new DefaultGridBagConstraints();
72
        GridBagConstraints c = new DefaultGridBagConstraints();
71
        setLayout(new GridBagLayout());
73
        setLayout(new GridBagLayout());
72
        // Champ Module
74
        // Champ Module
73
        c.gridx = 0;
75
        c.gridx = 0;
74
        c.gridy++;
76
        c.gridy++;
75
        c.gridwidth = GridBagConstraints.REMAINDER;
77
        c.gridwidth = GridBagConstraints.REMAINDER;
76
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
78
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
77
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
79
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
78
        this.add(addP, c);
80
        this.add(addP, c);
79
 
81
 
80
        // c.gridy++;
82
        // c.gridy++;
81
        // c.gridx = 0;
83
        // c.gridx = 0;
82
        // c.weightx = 0;
84
        // c.weightx = 0;
83
        // this.add(new JLabel(getLabelFor("ID_COMMANDE_PREV"), SwingConstants.RIGHT), c);
85
        // this.add(new JLabel(getLabelFor("ID_COMMANDE_PREV"), SwingConstants.RIGHT), c);
84
        // c.gridx++;
86
        // c.gridx++;
85
        // c.weightx = 1;
87
        // c.weightx = 1;
86
        // final ElementComboBox boxCmd = new ElementComboBox();
88
        // final ElementComboBox boxCmd = new ElementComboBox();
87
        // this.add(boxCmd, c);
89
        // this.add(boxCmd, c);
88
        // this.addView(boxCmd, "ID_COMMANDE_PREV");
90
        // this.addView(boxCmd, "ID_COMMANDE_PREV");
89
 
91
 
90
        c.gridy++;
92
        c.gridy++;
91
        c.gridwidth = 1;
93
        c.gridwidth = 1;
92
        c.gridx = 0;
94
        c.gridx = 0;
93
        c.weightx = 0;
95
        c.weightx = 0;
94
        this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
96
        this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
95
        c.gridx++;
97
        c.gridx++;
96
        c.weightx = 1;
98
        c.weightx = 1;
97
        this.add(field, c);
99
        this.add(field, c);
98
        this.addView(field, "NUMERO", REQ);
100
        this.addView(field, "NUMERO", REQ);
99
 
101
 
100
        c.gridx++;
102
        c.gridx++;
101
        c.weightx = 0;
103
        c.weightx = 0;
102
        this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);
104
        this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);
103
        c.gridx++;
105
        c.gridx++;
104
        c.weightx = 1;
106
        c.weightx = 1;
105
        JDate date = new JDate(true);
107
        JDate date = new JDate(true);
106
        this.add(date, c);
108
        this.add(date, c);
107
        this.addView(date, "DATE", REQ);
109
        this.addView(date, "DATE", REQ);
108
 
110
 
109
        c.gridx = 0;
111
        c.gridx = 0;
110
        c.gridy++;
112
        c.gridy++;
111
        c.weightx = 0;
113
        c.weightx = 0;
112
        this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);
114
        this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);
113
        c.gridx++;
115
        c.gridx++;
114
        c.weightx = 1;
116
        c.weightx = 1;
115
        final ElementComboBox boxFournisseur = new ElementComboBox();
117
        final ElementComboBox boxFournisseur = new ElementComboBox();
116
        this.add(boxFournisseur, c);
118
        this.add(boxFournisseur, c);
117
        this.addView(boxFournisseur, "ID_FOURNISSEUR", REQ);
119
        this.addView(boxFournisseur, "ID_FOURNISSEUR", REQ);
118
 
120
 
119
        c.gridx++;
121
        c.gridx++;
120
        c.weightx = 0;
122
        c.weightx = 0;
121
        this.add(new JLabel(getLabelFor("DATE_BUTOIRE"), SwingConstants.RIGHT), c);
123
        this.add(new JLabel(getLabelFor("DATE_BUTOIRE"), SwingConstants.RIGHT), c);
122
        c.gridx++;
124
        c.gridx++;
123
        c.weightx = 1;
125
        c.weightx = 1;
124
        JDate dateButoire = new JDate(false);
126
        JDate dateButoire = new JDate(false);
125
        this.add(dateButoire, c);
127
        this.add(dateButoire, c);
126
 
128
 
127
        this.addView(dateButoire, "DATE_BUTOIRE");
129
        this.addView(dateButoire, "DATE_BUTOIRE");
128
        //
130
        //
129
        // c.gridx++;
131
        // c.gridx++;
130
        // c.weightx = 0;
132
        // c.weightx = 0;
131
        // this.add(new JLabel(getLabelFor("DATE_DISPOSITION"), SwingConstants.RIGHT), c);
133
        // this.add(new JLabel(getLabelFor("DATE_DISPOSITION"), SwingConstants.RIGHT), c);
132
        // c.gridx++;
134
        // c.gridx++;
133
        // c.weightx = 1;
135
        // c.weightx = 1;
134
        // final JDate dateDisposition = new JDate();
136
        // final JDate dateDisposition = new JDate();
135
        // this.add(dateDisposition, c);
137
        // this.add(dateDisposition, c);
136
        // this.addView(dateDisposition, "DATE_DISPOSITION", REQ);
138
        // this.addView(dateDisposition, "DATE_DISPOSITION", REQ);
137
 
139
 
138
        // c.gridx = 0;
140
        // c.gridx = 0;
139
        // c.gridy++;
141
        // c.gridy++;
140
        // c.weightx = 0;
142
        // c.weightx = 0;
141
        // this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c);
143
        // this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c);
142
        // c.gridx++;
144
        // c.gridx++;
143
        // c.weightx = 1;
145
        // c.weightx = 1;
144
        // final ElementComboBox boxContactFournisseur = new ElementComboBox();
146
        // final ElementComboBox boxContactFournisseur = new ElementComboBox();
145
        // this.add(boxContactFournisseur, c);
147
        // this.add(boxContactFournisseur, c);
146
        // final SQLElement contactElement =
148
        // final SQLElement contactElement =
147
        // Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR");
149
        // Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR");
148
        // boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true));
150
        // boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true));
149
        // this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ);
151
        // this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ);
150
        //
152
        //
151
        // boxFournisseur.addModelListener("wantedID", new PropertyChangeListener() {
153
        // boxFournisseur.addModelListener("wantedID", new PropertyChangeListener() {
152
        //
154
        //
153
        // @Override
155
        // @Override
154
        // public void propertyChange(PropertyChangeEvent arg0) {
156
        // public void propertyChange(PropertyChangeEvent arg0) {
155
        //
157
        //
156
        // SQLRow selectedRow =
158
        // SQLRow selectedRow =
157
        // boxFournisseur.getRequest().getPrimaryTable().getRow(boxFournisseur.getWantedID());
159
        // boxFournisseur.getRequest().getPrimaryTable().getRow(boxFournisseur.getWantedID());
158
        // if (selectedRow != null) {
160
        // if (selectedRow != null) {
159
        // boxContactFournisseur.getRequest().setWhere(new
161
        // boxContactFournisseur.getRequest().setWhere(new
160
        // Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=", selectedRow.getID()));
162
        // Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=", selectedRow.getID()));
161
        // } else {
163
        // } else {
162
        // boxContactFournisseur.getRequest().setWhere(null);
164
        // boxContactFournisseur.getRequest().setWhere(null);
163
        // }
165
        // }
164
        // }
166
        // }
165
        // });
167
        // });
166
 
168
 
167
        // this.addView("ID_ADRESSE");
169
        // this.addView("ID_ADRESSE");
168
        // Etat devis
170
        // Etat devis
169
        // c.gridx = 0;
171
        // c.gridx = 0;
170
        // c.gridy++;
172
        // c.gridy++;
171
        //
173
        //
172
        // this.add(new JLabel(getLabelFor("ID_COMMERCIAL")), c);
174
        // this.add(new JLabel(getLabelFor("ID_COMMERCIAL")), c);
173
        // c.gridx++;
175
        // c.gridx++;
174
        // ElementComboBox boxComm = new ElementComboBox();
176
        // ElementComboBox boxComm = new ElementComboBox();
175
        // this.add(boxComm, c);
177
        // this.add(boxComm, c);
176
        // this.addView(boxComm, "ID_COMMERCIAL");
178
        // this.addView(boxComm, "ID_COMMERCIAL");
177
 
179
 
178
        // SQLRequestComboBox boxEtat = new SQLRequestComboBox();
180
        // SQLRequestComboBox boxEtat = new SQLRequestComboBox();
179
        // c.weightx = 0;
181
        // c.weightx = 0;
180
        // this.add(new JLabel(getLabelFor("ID_ETAT_DEMANDE_PRIX")), c);
182
        // this.add(new JLabel(getLabelFor("ID_ETAT_DEMANDE_PRIX")), c);
181
        // c.gridx++;
183
        // c.gridx++;
182
        // c.weightx = 1;
184
        // c.weightx = 1;
183
        // this.add(boxEtat, c);
185
        // this.add(boxEtat, c);
184
        // this.addView(boxEtat, "ID_ETAT_DEMANDE_PRIX");
186
        // this.addView(boxEtat, "ID_ETAT_DEMANDE_PRIX");
185
 
187
 
-
 
188
        c.gridx = 0;
-
 
189
        c.gridy++;
-
 
190
        c.weightx = 0;
-
 
191
        this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c);
-
 
192
        c.gridx++;
-
 
193
        c.weightx = 1;
-
 
194
        final ElementComboBox boxCom = new ElementComboBox();
-
 
195
        this.add(boxCom, c);
-
 
196
        this.addView(boxCom, "ID_COMMERCIAL", REQ);
-
 
197
 
186
        c.weightx = 0;
198
        c.weightx = 0;
187
        c.gridheight = 1;
199
        c.gridheight = 1;
188
        c.gridx = 0;
200
        c.gridx = 0;
189
        c.gridy++;
201
        c.gridy++;
190
        c.anchor = GridBagConstraints.WEST;
202
        c.anchor = GridBagConstraints.WEST;
191
        c.weightx = 0;
203
        c.weightx = 0;
192
        JLabel labelObjet = new JLabel(getLabelFor("OBJET"), SwingConstants.RIGHT);
204
        JLabel labelObjet = new JLabel(getLabelFor("OBJET"), SwingConstants.RIGHT);
193
        this.add(labelObjet, c);
205
        this.add(labelObjet, c);
194
        c.gridx++;
206
        c.gridx++;
195
        ITextArea area = new ITextArea();
207
        ITextArea area = new ITextArea();
196
        c.weightx = 1;
208
        c.weightx = 1;
197
        this.add(area, c);
209
        this.add(area, c);
198
        this.addView(area, "OBJET");
210
        this.addView(area, "OBJET");
199
 
211
 
200
        RadioButtons radioEtat = new RadioButtons("NOM");
212
        RadioButtons radioEtat = new RadioButtons("NOM");
201
        radioEtat.setLayout(new VFlowLayout());
213
        radioEtat.setLayout(new VFlowLayout());
202
        radioEtat.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_ETAT_DEMANDE_PRIX")));
214
        radioEtat.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_ETAT_DEMANDE_PRIX")));
203
        c.gridx = 3;
215
        c.gridx = 3;
204
        c.gridheight = 5;
216
        c.gridheight = 5;
205
        c.anchor = GridBagConstraints.NORTHWEST;
217
        c.anchor = GridBagConstraints.NORTHWEST;
206
        this.add(radioEtat, c);
218
        this.add(radioEtat, c);
207
        this.addView(radioEtat, "ID_ETAT_DEMANDE_PRIX", REQ);
219
        this.addView(radioEtat, "ID_ETAT_DEMANDE_PRIX", REQ);
208
 
220
 
209
        // c.gridx = 0;
221
        // c.gridx = 0;
210
        // c.gridy++;
222
        // c.gridy++;
211
        // c.gridwidth = 2;
223
        // c.gridwidth = 2;
212
        // c.weightx = 1;
224
        // c.weightx = 1;
213
        // this.add(new TitledSeparator("Adresse de destination"), c);
225
        // this.add(new TitledSeparator("Adresse de destination"), c);
214
        // c.gridy++;
226
        // c.gridy++;
215
        // c.weightx = 0;
227
        // c.weightx = 0;
216
        // final JCheckBox boxLivr = new JCheckBox("Livré par le fournisseur");
228
        // final JCheckBox boxLivr = new JCheckBox("Livré par le fournisseur");
217
        // this.add(boxLivr, c);
229
        // this.add(boxLivr, c);
218
        // this.addView(boxLivr, "LIVRAISON_F");
230
        // this.addView(boxLivr, "LIVRAISON_F");
219
        // c.gridy++;
231
        // c.gridy++;
220
        // final ElementComboBox boxAdr = new ElementComboBox();
232
        // final ElementComboBox boxAdr = new ElementComboBox();
221
        // final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
233
        // final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
222
        // boxAdr.init(adrElement);
234
        // boxAdr.init(adrElement);
223
        // c.gridwidth = 1;
235
        // c.gridwidth = 1;
224
        // final JLabel labelAdrLiv = new JLabel("Adresse de livraison existante");
236
        // final JLabel labelAdrLiv = new JLabel("Adresse de livraison existante");
225
        // this.add(labelAdrLiv, c);
237
        // this.add(labelAdrLiv, c);
226
        // c.gridx++;
238
        // c.gridx++;
227
        // c.gridwidth = 2;
239
        // c.gridwidth = 2;
228
        // this.add(boxAdr, c);
240
        // this.add(boxAdr, c);
229
        // c.gridy++;
241
        // c.gridy++;
230
        // c.gridx = 0;
242
        // c.gridx = 0;
231
        // this.addView("ID_ADRESSE");
243
        // this.addView("ID_ADRESSE");
232
        // final DefaultElementSQLObject comp = (DefaultElementSQLObject)
244
        // final DefaultElementSQLObject comp = (DefaultElementSQLObject)
233
        // this.getView("ID_ADRESSE").getComp();
245
        // this.getView("ID_ADRESSE").getComp();
234
        // componentPrincipaleAdr = (ElementSQLObject) this.getView("ID_ADRESSE");
246
        // componentPrincipaleAdr = (ElementSQLObject) this.getView("ID_ADRESSE");
235
        // this.add(comp, c);
247
        // this.add(comp, c);
236
        // boxLivr.addActionListener(new ActionListener() {
248
        // boxLivr.addActionListener(new ActionListener() {
237
        //
249
        //
238
        // @Override
250
        // @Override
239
        // public void actionPerformed(ActionEvent e) {
251
        // public void actionPerformed(ActionEvent e) {
240
        // if (boxLivr.isSelected() && !comp.isCreated()) {
252
        // if (boxLivr.isSelected() && !comp.isCreated()) {
241
        // comp.setCreated(true);
253
        // comp.setCreated(true);
242
        // componentPrincipaleAdr.setEditable(InteractionMode.READ_WRITE);
254
        // componentPrincipaleAdr.setEditable(InteractionMode.READ_WRITE);
243
        // final SQLRow selectedRow2 = boxAffaire.getSelectedRow();
255
        // final SQLRow selectedRow2 = boxAffaire.getSelectedRow();
244
        // if (selectedRow2 != null) {
256
        // if (selectedRow2 != null) {
245
        // SQLRowValues rowVals = getLivraisonAdr(selectedRow2.asRow());
257
        // SQLRowValues rowVals = getLivraisonAdr(selectedRow2.asRow());
246
        // rowVals.put("RUE", "");
258
        // rowVals.put("RUE", "");
247
        // comp.setValue(rowVals);
259
        // comp.setValue(rowVals);
248
        // }
260
        // }
249
        // } else {
261
        // } else {
250
        // if (!boxLivr.isSelected()) {
262
        // if (!boxLivr.isSelected()) {
251
        // comp.setCreated(false);
263
        // comp.setCreated(false);
252
        // componentPrincipaleAdr.setEditable(InteractionMode.DISABLED);
264
        // componentPrincipaleAdr.setEditable(InteractionMode.DISABLED);
253
        // }
265
        // }
254
        // }
266
        // }
255
        //
267
        //
256
        // }
268
        // }
257
        // });
269
        // });
258
        // comp.addValueListener(new PropertyChangeListener() {
270
        // comp.addValueListener(new PropertyChangeListener() {
259
        //
271
        //
260
        // @Override
272
        // @Override
261
        // public void propertyChange(PropertyChangeEvent evt) {
273
        // public void propertyChange(PropertyChangeEvent evt) {
262
        // boxAdr.setVisible(comp.isCreated());
274
        // boxAdr.setVisible(comp.isCreated());
263
        // labelAdrLiv.setVisible(comp.isCreated());
275
        // labelAdrLiv.setVisible(comp.isCreated());
264
        // }
276
        // }
265
        // });
277
        // });
266
 
278
 
267
        // boxAffaire.addModelListener("wantedID", new PropertyChangeListener() {
279
        // boxAffaire.addModelListener("wantedID", new PropertyChangeListener() {
268
        // SQLTable tableAdr = getTable().getTable("ADRESSE");
280
        // SQLTable tableAdr = getTable().getTable("ADRESSE");
269
        //
281
        //
270
        // @Override
282
        // @Override
271
        // public void propertyChange(PropertyChangeEvent evt) {
283
        // public void propertyChange(PropertyChangeEvent evt) {
272
        //
284
        //
273
        // SQLRow selectedRow =
285
        // SQLRow selectedRow =
274
        // boxAffaire.getRequest().getPrimaryTable().getRow(boxAffaire.getWantedID());
286
        // boxAffaire.getRequest().getPrimaryTable().getRow(boxAffaire.getWantedID());
275
        // boxCmd.getRequest().setWhere(Where.FALSE);
287
        // boxCmd.getRequest().setWhere(Where.FALSE);
276
        // if (selectedRow != null && !selectedRow.isUndefined()) {
288
        // if (selectedRow != null && !selectedRow.isUndefined()) {
277
        //
289
        //
278
        // SQLRow client = selectedRow.getForeign("ID_CLIENT");
290
        // SQLRow client = selectedRow.getForeign("ID_CLIENT");
279
        //
291
        //
280
        // boxAdr.getRequest().setWhere(((AffaireSQLElement)
292
        // boxAdr.getRequest().setWhere(((AffaireSQLElement)
281
        // boxAffaire.getElement()).getWhereAdrL(client));
293
        // boxAffaire.getElement()).getWhereAdrL(client));
282
        // boxCmd.getRequest().setWhere(new
294
        // boxCmd.getRequest().setWhere(new
283
        // Where(getTable().getForeignTable("ID_COMMANDE_PREV").getField("ID_AFFAIRE"), "=",
295
        // Where(getTable().getForeignTable("ID_COMMANDE_PREV").getField("ID_AFFAIRE"), "=",
284
        // selectedRow.getID()));
296
        // selectedRow.getID()));
285
        //
297
        //
286
        // }
298
        // }
287
        // }
299
        // }
288
        // });
300
        // });
289
        // boxAdr.addValueListener(new PropertyChangeListener() {
301
        // boxAdr.addValueListener(new PropertyChangeListener() {
290
        //
302
        //
291
        // @Override
303
        // @Override
292
        // public void propertyChange(PropertyChangeEvent evt) {
304
        // public void propertyChange(PropertyChangeEvent evt) {
293
        // final SQLRow selectedRow = boxAdr.getSelectedRow().asRow();
305
        // final SQLRow selectedRow = boxAdr.getSelectedRow().asRow();
294
        // if (selectedRow != null && !selectedRow.isUndefined()) {
306
        // if (selectedRow != null && !selectedRow.isUndefined()) {
295
        // SQLRowValues rowVals = selectedRow.asRowValues();
307
        // SQLRowValues rowVals = selectedRow.asRowValues();
296
        // rowVals.clearPrimaryKeys();
308
        // rowVals.clearPrimaryKeys();
297
        // rowVals.put("RUE", "");
309
        // rowVals.put("RUE", "");
298
        // comp.setValue(rowVals);
310
        // comp.setValue(rowVals);
299
        // }
311
        // }
300
        // }
312
        // }
301
        // });
313
        // });
302
        // boxAdr.setVisible(false);
314
        // boxAdr.setVisible(false);
303
        // labelAdrLiv.setVisible(false);
315
        // labelAdrLiv.setVisible(false);
304
        c.gridwidth = GridBagConstraints.REMAINDER;
316
        c.gridwidth = GridBagConstraints.REMAINDER;
305
        c.gridheight = 1;
317
        c.gridheight = 1;
306
        c.gridy += 6;
318
        c.gridy += 6;
307
        c.gridx = 0;
319
        c.gridx = 0;
308
        c.weightx = 1;
320
        c.weightx = 1;
309
        c.weighty = 1;
321
        c.weighty = 1;
310
        c.fill = GridBagConstraints.BOTH;
322
        c.fill = GridBagConstraints.BOTH;
311
        this.add(this.table, c);
323
        this.add(this.table, c);
312
 
324
 
313
        // boxFournisseur.addValueListener(new PropertyChangeListener() {
325
        // boxFournisseur.addValueListener(new PropertyChangeListener() {
314
        //
326
        //
315
        // @Override
327
        // @Override
316
        // public void propertyChange(PropertyChangeEvent evt) {
328
        // public void propertyChange(PropertyChangeEvent evt) {
317
        // // TODO Raccord de méthode auto-généré
329
        // // TODO Raccord de méthode auto-généré
318
        // table.setFournisseurFilterOnCompletion(boxFournisseur.getSelectedRow().asRow());
330
        // table.setFournisseurFilterOnCompletion(boxFournisseur.getSelectedRow().asRow());
319
        // if (boxFournisseur.getSelectedRow().asRow() != null &&
331
        // if (boxFournisseur.getSelectedRow().asRow() != null &&
320
        // !boxFournisseur.getSelectedRow().asRow().isUndefined()) {
332
        // !boxFournisseur.getSelectedRow().asRow().isUndefined()) {
321
        // SQLRow rowFam =
333
        // SQLRow rowFam =
322
        // boxFournisseur.getSelectedRow().asRow().getForeignRow("ID_FAMILLE_ARTICLE");
334
        // boxFournisseur.getSelectedRow().asRow().getForeignRow("ID_FAMILLE_ARTICLE");
323
        // if (rowFam != null && !rowFam.isUndefined()) {
335
        // if (rowFam != null && !rowFam.isUndefined()) {
324
        // table.getRowValuesTable().getRowValuesTableModel().getDefaultRowValues().put("ID_FAMILLE_ARTICLE",
336
        // table.getRowValuesTable().getRowValuesTableModel().getDefaultRowValues().put("ID_FAMILLE_ARTICLE",
325
        // rowFam.getID());
337
        // rowFam.getID());
326
        // } else {
338
        // } else {
327
        // table.getRowValuesTable().getRowValuesTableModel().getDefaultRowValues().putEmptyLink("ID_FAMILLE_ARTICLE");
339
        // table.getRowValuesTable().getRowValuesTableModel().getDefaultRowValues().putEmptyLink("ID_FAMILLE_ARTICLE");
328
        // }
340
        // }
329
        // } else {
341
        // } else {
330
        // table.getRowValuesTable().getRowValuesTableModel().getDefaultRowValues().putEmptyLink("ID_FAMILLE_ARTICLE");
342
        // table.getRowValuesTable().getRowValuesTableModel().getDefaultRowValues().putEmptyLink("ID_FAMILLE_ARTICLE");
331
        // }
343
        // }
332
        // }
344
        // }
333
        // });
345
        // });
334
 
346
 
335
        // INfos
347
        // INfos
336
        c.gridx = 0;
348
        c.gridx = 0;
337
        c.gridy++;
349
        c.gridy++;
338
        c.gridheight = 1;
350
        c.gridheight = 1;
339
        c.weighty = 0;
351
        c.weighty = 0;
340
        c.weightx = 1;
352
        c.weightx = 1;
341
        c.anchor = GridBagConstraints.WEST;
353
        c.anchor = GridBagConstraints.WEST;
342
        c.gridwidth = 3;
354
        c.gridwidth = 3;
343
        c.fill = GridBagConstraints.HORIZONTAL;
355
        c.fill = GridBagConstraints.HORIZONTAL;
344
        this.add(new TitledSeparator(getLabelFor("INFOS")), c);
356
        this.add(new TitledSeparator(getLabelFor("INFOS")), c);
345
 
357
 
346
        c.gridy++;
358
        c.gridy++;
347
        c.weightx = 1;
359
        c.weightx = 1;
348
        c.weighty = 1;
360
        c.weighty = 1;
349
        c.fill = GridBagConstraints.BOTH;
361
        c.fill = GridBagConstraints.BOTH;
350
        JTextArea infos = new ITextArea();
362
        JTextArea infos = new ITextArea();
351
        final JScrollPane scrollPane = new JScrollPane(infos);
363
        final JScrollPane scrollPane = new JScrollPane(infos);
352
        scrollPane.setBorder(null);
364
        scrollPane.setBorder(null);
353
        this.add(scrollPane, c);
365
        this.add(scrollPane, c);
354
 
366
 
355
        // Total
367
        // Total
356
        // DeviseField fieldHT = new DeviseField();
368
        // DeviseField fieldHT = new DeviseField();
357
        // DeviseField fieldTVA = new DeviseField();
369
        // DeviseField fieldTVA = new DeviseField();
358
        // DeviseField fieldTTC = new DeviseField();
370
        // DeviseField fieldTTC = new DeviseField();
359
        // fieldHT.setOpaque(false);
371
        // fieldHT.setOpaque(false);
360
        // fieldTVA.setOpaque(false);
372
        // fieldTVA.setOpaque(false);
361
        // fieldTTC.setOpaque(false);
373
        // fieldTTC.setOpaque(false);
362
        //
374
        //
363
        // addRequiredSQLObject(fieldHT, "T_HT");
375
        // addRequiredSQLObject(fieldHT, "T_HT");
364
        // addRequiredSQLObject(fieldTVA, "T_TVA");
376
        // addRequiredSQLObject(fieldTVA, "T_TVA");
365
        // addRequiredSQLObject(fieldTTC, "T_TTC");
377
        // addRequiredSQLObject(fieldTTC, "T_TTC");
366
        // JTextField poids = new JTextField();
378
        // JTextField poids = new JTextField();
367
        // // addSQLObject(poids, "T_POIDS");
379
        // // addSQLObject(poids, "T_POIDS");
368
        // final TotalPanel totalTTC = new TotalPanel(this.table.getRowValuesTable(),
380
        // final TotalPanel totalTTC = new TotalPanel(this.table.getRowValuesTable(),
369
        // this.table.getPrixTotalHTElement(), this.table.getPrixTotalTTCElement(),
381
        // this.table.getPrixTotalHTElement(), this.table.getPrixTotalTTCElement(),
370
        // this.table.getHaElement(),
382
        // this.table.getHaElement(),
371
        // this.table.getQteElement(), fieldHT, fieldTVA, fieldTTC, new DeviseField(), new
383
        // this.table.getQteElement(), fieldHT, fieldTVA, fieldTTC, new DeviseField(), new
372
        // DeviseField(), new DeviseField(), this.table.getPrixServiceElement(), new DeviseField(),
384
        // DeviseField(), new DeviseField(), this.table.getPrixServiceElement(), new DeviseField(),
373
        // this.table.getTableElementTotalDevise(), poids, this.table.getPoidsTotalElement());
385
        // this.table.getTableElementTotalDevise(), poids, this.table.getPoidsTotalElement());
374
        //
386
        //
375
        // c.gridx = GridBagConstraints.RELATIVE;
387
        // c.gridx = GridBagConstraints.RELATIVE;
376
        // c.gridy--;
388
        // c.gridy--;
377
        // c.gridwidth = GridBagConstraints.REMAINDER;
389
        // c.gridwidth = GridBagConstraints.REMAINDER;
378
        // c.gridheight = 2;
390
        // c.gridheight = 2;
379
        // c.anchor = GridBagConstraints.NORTHEAST;
391
        // c.anchor = GridBagConstraints.NORTHEAST;
380
        // c.fill = GridBagConstraints.NONE;
392
        // c.fill = GridBagConstraints.NONE;
381
        // c.weighty = 0;
393
        // c.weighty = 0;
382
        //
394
        //
383
        // this.add(totalTTC, c);
395
        // this.add(totalTTC, c);
384
 
396
 
385
        addSQLObject(infos, "INFOS");
397
        addSQLObject(infos, "INFOS");
386
 
398
 
387
        this.panelOO = new PanelOOSQLComponent(this);
399
        this.panelOO = new PanelOOSQLComponent(this);
388
        c.gridwidth = 1;
400
        c.gridwidth = 1;
389
        c.fill = GridBagConstraints.HORIZONTAL;
401
        c.fill = GridBagConstraints.HORIZONTAL;
390
        c.anchor = GridBagConstraints.SOUTHEAST;
402
        c.anchor = GridBagConstraints.SOUTHEAST;
391
        // c.gridx = 0;
403
        // c.gridx = 0;
392
        c.gridx += 3;
404
        c.gridx += 3;
393
        c.weightx = 0;
405
        c.weightx = 0;
394
        c.fill = GridBagConstraints.NONE;
406
        c.fill = GridBagConstraints.NONE;
395
        c.gridwidth = GridBagConstraints.REMAINDER;
407
        c.gridwidth = GridBagConstraints.REMAINDER;
396
        this.add(this.panelOO, c);
408
        this.add(this.panelOO, c);
397
        // this.addView("PRIX");
409
        // this.addView("PRIX");
398
 
410
 
399
        // boxAffaire.addValueListener(new PropertyChangeListener() {
411
        // boxAffaire.addValueListener(new PropertyChangeListener() {
400
        //
412
        //
401
        // @Override
413
        // @Override
402
        // public void propertyChange(PropertyChangeEvent evt) {
414
        // public void propertyChange(PropertyChangeEvent evt) {
403
        // SQLRow selectedRow = boxAffaire.getSelectedRow().asRow();
415
        // SQLRow selectedRow = boxAffaire.getSelectedRow().asRow();
404
        // if (!isFilling() && selectedRow != null && !selectedRow.isUndefined()) {
416
        // if (!isFilling() && selectedRow != null && !selectedRow.isUndefined()) {
405
        // Calendar date = selectedRow.getDate("DATE_LIVRAISON_EFFECTIVE");
417
        // Calendar date = selectedRow.getDate("DATE_LIVRAISON_EFFECTIVE");
406
        // if (date != null) {
418
        // if (date != null) {
407
        //
419
        //
408
        // dateDisposition.setValue(date.getTime());
420
        // dateDisposition.setValue(date.getTime());
409
        // }
421
        // }
410
        // }
422
        // }
411
        // }
423
        // }
412
        // });
424
        // });
413
 
425
 
414
    }
426
    }
415
 
427
 
416
    private SQLRowValues getLivraisonAdr(SQLRow rowAffaire) {
428
    private SQLRowValues getLivraisonAdr(SQLRow rowAffaire) {
417
        if (rowAffaire != null) {
429
        if (rowAffaire != null) {
418
            SQLRow rowClient = rowAffaire.getForeignRow("ID_CLIENT");
430
            SQLRow rowClient = rowAffaire.getForeignRow("ID_CLIENT");
419
            SQLRow rowAdrL = rowClient.getForeignRow("ID_ADRESSE_L");
431
            SQLRow rowAdrL = rowClient.getForeignRow("ID_ADRESSE_L");
420
            if (rowAdrL == null || rowAdrL.isUndefined()) {
432
            if (rowAdrL == null || rowAdrL.isUndefined()) {
421
                rowAdrL = rowClient.getForeignRow("ID_ADRESSE");
433
                rowAdrL = rowClient.getForeignRow("ID_ADRESSE");
422
            }
434
            }
423
            SQLRowValues rowVals = rowAdrL.asRowValues();
435
            SQLRowValues rowVals = rowAdrL.asRowValues();
424
            rowVals.clearPrimaryKeys();
436
            rowVals.clearPrimaryKeys();
425
            return rowVals;
437
            return rowVals;
426
        } else {
438
        } else {
427
            return new SQLRowValues(getTable().getTable("ADRESSE"));
439
            return new SQLRowValues(getTable().getTable("ADRESSE"));
428
        }
440
        }
429
    }
441
    }
430
 
442
 
431
    @Override
443
    @Override
432
    public void select(SQLRowAccessor r) {
444
    public void select(SQLRowAccessor r) {
433
        // TODO Raccord de méthode auto-généré
445
        // TODO Raccord de méthode auto-généré
434
        if (getTable().contains("LIVRAISON_F") && componentPrincipaleAdr != null) {
446
        if (getTable().contains("LIVRAISON_F") && componentPrincipaleAdr != null) {
435
            final boolean bLivraison = r != null && r.getFields().contains("ID_ADRESSE") && !r.isForeignEmpty("ID_ADRESSE");
447
            final boolean bLivraison = r != null && r.getFields().contains("ID_ADRESSE") && !r.isForeignEmpty("ID_ADRESSE");
436
            componentPrincipaleAdr.setEditable(bLivraison ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
448
            componentPrincipaleAdr.setEditable(bLivraison ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
437
        }
449
        }
438
 
450
 
439
        if (r != null) {
451
        if (r != null) {
440
            // final SQLRowValues rVals = r.asRowValues().deepCopy();
452
            // final SQLRowValues rVals = r.asRowValues().deepCopy();
441
            // final SQLRowValues vals = new SQLRowValues(r.getTable());
453
            // final SQLRowValues vals = new SQLRowValues(r.getTable());
442
            // vals.load(rVals, CollectionUtils.createSet("ID_AFFAIRE"));
454
            // vals.load(rVals, CollectionUtils.createSet("ID_AFFAIRE"));
443
            // // vals a besoin de l'ID sinon incohérence entre ID_AFFAIRE et ID (eg for
455
            // // vals a besoin de l'ID sinon incohérence entre ID_AFFAIRE et ID (eg for
444
            // // reloadTable())
456
            // // reloadTable())
445
            // // ne pas supprimer l'ID de rVals pour qu'on puisse UPDATE
457
            // // ne pas supprimer l'ID de rVals pour qu'on puisse UPDATE
446
            // vals.setID(rVals.getID());
458
            // vals.setID(rVals.getID());
447
            // super.select(vals);
459
            // super.select(vals);
448
            // rVals.remove("ID_AFFAIRE");
460
            // rVals.remove("ID_AFFAIRE");
449
            // super.select(rVals);
461
            // super.select(rVals);
450
            super.select(r);
462
            super.select(r);
451
            this.field.setIdSelected(r.getID());
463
            this.field.setIdSelected(r.getID());
452
            this.table.insertFrom("ID_DEMANDE_PRIX", r.getID());
464
            this.table.insertFrom("ID_DEMANDE_PRIX", r.getID());
453
        } else {
465
        } else {
454
            super.select(r);
466
            super.select(r);
455
        }
467
        }
456
    }
468
    }
457
 
469
 
458
    @Override
470
    @Override
459
    public int insert(SQLRow order) {
471
    public int insert(SQLRow order) {
460
 
472
 
461
        int idCommande = getSelectedID();
473
        int idCommande = getSelectedID();
462
 
474
 
463
        // on verifie qu'un devis du meme numero n'a pas été inséré entre temps
475
        // on verifie qu'un devis du meme numero n'a pas été inséré entre temps
464
        if (this.field.checkValidation()) {
476
        if (this.field.checkValidation()) {
465
 
477
 
466
            idCommande = super.insert(order);
478
            idCommande = super.insert(order);
467
            // this.table.updateField("ID_COMMANDE_CLIENT", idCommande);
479
            // this.table.updateField("ID_COMMANDE_CLIENT", idCommande);
468
            this.table.updateField("ID_DEMANDE_PRIX", idCommande);
480
            this.table.updateField("ID_DEMANDE_PRIX", idCommande);
469
            // Création des articles
481
            // Création des articles
470
            // this.table.createArticle(idCommande, this.getElement());
482
            // this.table.createArticle(idCommande, this.getElement());
471
 
483
 
472
            // generation du document
484
            // generation du document
-
 
485
            final SQLRow row = getTable().getRow(idCommande);
473
            DemandePrixSheetXML sheet = new DemandePrixSheetXML(getTable().getRow(idCommande));
486
            DemandePrixSheetXML sheet = new DemandePrixSheetXML(row);
474
            sheet.createDocumentAsynchronous();
487
            sheet.createDocumentAsynchronous();
475
            sheet.showPrintAndExportAsynchronous(true, false, true);
488
            sheet.showPrintAndExportAsynchronous(true, false, true, getElement(), row);
476
 
489
 
477
            // incrémentation du numéro auto
490
            // incrémentation du numéro auto
478
            if (NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class).equalsIgnoreCase(this.field.getText().trim())) {
491
            if (NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class).equalsIgnoreCase(this.field.getText().trim())) {
479
                SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
492
                SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
480
                SQLRowValues rowVals = new SQLRowValues(tableNum);
493
                SQLRowValues rowVals = new SQLRowValues(tableNum);
481
                int val = tableNum.getRow(2).getInt("DMD_PRIX_START");
494
                int val = tableNum.getRow(2).getInt("DMD_PRIX_START");
482
                val++;
495
                val++;
483
                rowVals.put("DMD_PRIX_START", new Integer(val));
496
                rowVals.put("DMD_PRIX_START", new Integer(val));
484
 
497
 
485
                try {
498
                try {
486
                    rowVals.update(2);
499
                    rowVals.update(2);
487
                } catch (SQLException e) {
500
                } catch (SQLException e) {
488
                    e.printStackTrace();
501
                    e.printStackTrace();
489
                }
502
                }
490
            }
503
            }
491
 
504
 
492
            DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
505
            DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
493
            elt.updateStatus(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"), idCommande);
506
            elt.updateStatus(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"), idCommande);
494
        } else {
507
        } else {
495
            ExceptionHandler.handle("Impossible d'ajouter, numéro de demande existant.");
508
            ExceptionHandler.handle("Impossible d'ajouter, numéro de demande existant.");
496
            Object root = SwingUtilities.getRoot(this);
509
            Object root = SwingUtilities.getRoot(this);
497
            if (root instanceof EditFrame) {
510
            if (root instanceof EditFrame) {
498
                EditFrame frame = (EditFrame) root;
511
                EditFrame frame = (EditFrame) root;
499
                frame.getPanel().setAlwaysVisible(true);
512
                frame.getPanel().setAlwaysVisible(true);
500
            }
513
            }
501
        }
514
        }
502
 
515
 
503
        return idCommande;
516
        return idCommande;
504
    }
517
    }
505
 
518
 
506
    @Override
519
    @Override
507
    public void update() {
520
    public void update() {
508
 
521
 
509
        if (!this.field.checkValidation()) {
522
        if (!this.field.checkValidation()) {
510
            ExceptionHandler.handle("Impossible d'ajouter, numéro de demande existant.");
523
            ExceptionHandler.handle("Impossible d'ajouter, numéro de demande existant.");
511
            Object root = SwingUtilities.getRoot(this);
524
            Object root = SwingUtilities.getRoot(this);
512
            if (root instanceof EditFrame) {
525
            if (root instanceof EditFrame) {
513
                EditFrame frame = (EditFrame) root;
526
                EditFrame frame = (EditFrame) root;
514
                frame.getPanel().setAlwaysVisible(true);
527
                frame.getPanel().setAlwaysVisible(true);
515
            }
528
            }
516
            return;
529
            return;
517
        }
530
        }
518
        super.update();
531
        super.update();
519
        // this.table.updateField("ID_COMMANDE_CLIENT", getSelectedID());
532
        // this.table.updateField("ID_COMMANDE_CLIENT", getSelectedID());
520
        // this.table.createArticle(getSelectedID(), this.getElement());
533
        // this.table.createArticle(getSelectedID(), this.getElement());
521
        this.table.updateField("ID_DEMANDE_PRIX", getSelectedID());
534
        this.table.updateField("ID_DEMANDE_PRIX", getSelectedID());
522
        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
535
        DemandeAchatItemSQLElement elt = getElement().getDirectory().getElement(DemandeAchatItemSQLElement.class);
523
        elt.updateStatus(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"), getSelectedID());
536
        elt.updateStatus(getTable(), getTable().getTable("DEMANDE_PRIX_ELEMENT"), getSelectedID());
524
 
537
 
-
 
538
        final SQLRow row = getTable().getRow(getSelectedID());
525
        DemandePrixSheetXML sheet = new DemandePrixSheetXML(getTable().getRow(getSelectedID()));
539
        DemandePrixSheetXML sheet = new DemandePrixSheetXML(row);
526
        sheet.createDocumentAsynchronous();
540
        sheet.createDocumentAsynchronous();
527
        sheet.showPrintAndExportAsynchronous(true, false, true);
541
        sheet.showPrintAndExportAsynchronous(true, false, true, getElement(), row);
528
 
542
 
529
    }
543
    }
530
 
544
 
531
    @Override
545
    @Override
532
    protected SQLRowValues createDefaults() {
546
    protected SQLRowValues createDefaults() {
533
        SQLRowValues rowVals = new SQLRowValues(getTable());
547
        SQLRowValues rowVals = new SQLRowValues(getTable());
534
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class));
548
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class));
-
 
549
        SQLElement eltComm = getElement().getForeignElement("ID_COMMERCIAL");
-
 
550
        int idUser = UserManager.getInstance().getCurrentUserID();
-
 
551
 
-
 
552
        SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
-
 
553
 
-
 
554
        if (rowsComm != null) {
-
 
555
            rowVals.put("ID_COMMERCIAL", rowsComm.getID());
-
 
556
        }
-
 
557
 
535
        if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
558
        if (getTable().getUndefinedID() == SQLRow.NONEXISTANT_ID) {
536
            rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
559
            rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
537
        } else {
560
        } else {
538
            SQLRow rowUndef = getTable().getRow(getTable().getUndefinedID());
561
            SQLRow rowUndef = getTable().getRow(getTable().getUndefinedID());
539
            SQLRow foreign = rowUndef.getForeign("ID_ETAT_DEMANDE_PRIX");
562
            SQLRow foreign = rowUndef.getForeign("ID_ETAT_DEMANDE_PRIX");
540
            if (foreign != null && !foreign.isUndefined()) {
563
            if (foreign != null && !foreign.isUndefined()) {
541
                rowVals.put("ID_ETAT_DEMANDE_PRIX", foreign.getID());
564
                rowVals.put("ID_ETAT_DEMANDE_PRIX", foreign.getID());
542
            } else {
565
            } else {
543
                rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
566
                rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
544
            }
567
            }
545
        }
568
        }
546
        if (getTable().contains("LIVRAISON_F") && componentPrincipaleAdr != null) {
569
        if (getTable().contains("LIVRAISON_F") && componentPrincipaleAdr != null) {
547
            componentPrincipaleAdr.setEditable(InteractionMode.DISABLED);
570
            componentPrincipaleAdr.setEditable(InteractionMode.DISABLED);
548
        }
571
        }
549
        return rowVals;
572
        return rowVals;
550
    }
573
    }
551
 
574
 
552
    /**
575
    /**
553
     * Création d'une demande à partir d'une demande existante
576
     * Création d'une demande à partir d'une demande existante
554
     * 
577
     * 
555
     * @param idDemande
578
     * @param idDemande
556
     * 
579
     * 
557
     */
580
     */
558
    public void loadDemandeExistant(final int idDemande) {
581
    public void loadDemandeExistant(final int idDemande) {
559
 
582
 
560
        final SQLElement demande = Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX");
583
        final SQLElement demande = Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX");
561
        final SQLElement demandeElt = Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX_ELEMENT");
584
        final SQLElement demandeElt = Configuration.getInstance().getDirectory().getElement("DEMANDE_PRIX_ELEMENT");
562
 
585
 
563
        // On duplique la demande
586
        // On duplique la demande
564
        if (idDemande > 1) {
587
        if (idDemande > 1) {
565
            final SQLRow row = demande.getTable().getRow(idDemande);
588
            final SQLRow row = demande.getTable().getRow(idDemande);
566
            final SQLRowValues rowVals = new SQLRowValues(demande.getTable());
589
            final SQLRowValues rowVals = new SQLRowValues(demande.getTable());
567
            rowVals.put("ID_AFFAIRE", row.getInt("ID_AFFAIRE"));
590
            rowVals.put("ID_AFFAIRE", row.getInt("ID_AFFAIRE"));
568
            // rowVals.put("DATE_BUTOIRE", row.getObject("DATE_BUTOIRE"));
591
            // rowVals.put("DATE_BUTOIRE", row.getObject("DATE_BUTOIRE"));
569
            // rowVals.put("DATE_DISPOSITION", row.getObject("DATE_DISPOSITION"));
592
            // rowVals.put("DATE_DISPOSITION", row.getObject("DATE_DISPOSITION"));
570
            rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class));
593
            rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(DemandePrixSQLElement.class));
571
            rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
594
            rowVals.put("ID_ETAT_DEMANDE_PRIX", EtatDemandePrixSQLElement.EN_ATTENTE);
572
            rowVals.put("OBJET", row.getObject("OBJET"));
595
            rowVals.put("OBJET", row.getObject("OBJET"));
573
            rowVals.put("ID_COMMERCIAL", row.getObject("ID_COMMERCIAL"));
596
            rowVals.put("ID_COMMERCIAL", row.getObject("ID_COMMERCIAL"));
574
            this.select(rowVals);
597
            this.select(rowVals);
575
        }
598
        }
576
 
599
 
577
        // On duplique les elements de devis
600
        // On duplique les elements de devis
578
        final List<SQLRow> myListItem = demande.getTable().getRow(idDemande).getReferentRows(demandeElt.getTable());
601
        final List<SQLRow> myListItem = demande.getTable().getRow(idDemande).getReferentRows(demandeElt.getTable());
579
 
602
 
580
        if (myListItem.size() != 0) {
603
        if (myListItem.size() != 0) {
581
            this.table.getModel().clearRows();
604
            this.table.getModel().clearRows();
582
 
605
 
583
            for (final SQLRow rowElt : myListItem) {
606
            for (final SQLRow rowElt : myListItem) {
584
 
607
 
585
                final SQLRowValues rowVals = rowElt.createUpdateRow();
608
                final SQLRowValues rowVals = rowElt.createUpdateRow();
586
                rowVals.clearPrimaryKeys();
609
                rowVals.clearPrimaryKeys();
587
                this.table.getModel().addRow(rowVals);
610
                this.table.getModel().addRow(rowVals);
588
                final int rowIndex = this.table.getModel().getRowCount() - 1;
611
                final int rowIndex = this.table.getModel().getRowCount() - 1;
589
                this.table.getModel().fireTableModelModified(rowIndex);
612
                this.table.getModel().fireTableModelModified(rowIndex);
590
            }
613
            }
591
        } else {
614
        } else {
592
            this.table.getModel().clearRows();
615
            this.table.getModel().clearRows();
593
        }
616
        }
594
        this.table.getModel().fireTableDataChanged();
617
        this.table.getModel().fireTableDataChanged();
595
        this.table.repaint();
618
        this.table.repaint();
596
    }
619
    }
597
 
620
 
598
    @Override
621
    @Override
599
    protected RowValuesTable getRowValuesTable() {
622
    protected RowValuesTable getRowValuesTable() {
600
        return this.table.getRowValuesTable();
623
        return this.table.getRowValuesTable();
601
    }
624
    }
602
 
625
 
603
    @Override
626
    @Override
604
    protected void refreshAfterSelect(SQLRowAccessor rSource) {
627
    protected void refreshAfterSelect(SQLRowAccessor rSource) {
605
        // TODO Auto-generated method stub
628
        // TODO Auto-generated method stub
606
 
629
 
607
    }
630
    }
608
}
631
}