OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 177
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 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
 package org.openconcerto.erp.core.sales.invoice.element;
14
 package org.openconcerto.erp.core.sales.invoice.element;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
18
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
19
import org.openconcerto.erp.preferences.DefaultNXProps;
19
import org.openconcerto.erp.preferences.DefaultNXProps;
20
import org.openconcerto.erp.rights.NXRights;
20
import org.openconcerto.erp.rights.NXRights;
21
import org.openconcerto.sql.element.BaseSQLComponent;
21
import org.openconcerto.sql.element.BaseSQLComponent;
22
import org.openconcerto.sql.element.SQLComponent;
22
import org.openconcerto.sql.element.SQLComponent;
23
import org.openconcerto.sql.element.SQLElement;
23
import org.openconcerto.sql.element.SQLElement;
24
import org.openconcerto.sql.model.SQLInjector;
24
import org.openconcerto.sql.model.SQLInjector;
25
import org.openconcerto.sql.model.SQLRow;
25
import org.openconcerto.sql.model.SQLRow;
26
import org.openconcerto.sql.model.SQLRowAccessor;
26
import org.openconcerto.sql.model.SQLRowAccessor;
27
import org.openconcerto.sql.model.SQLRowValues;
27
import org.openconcerto.sql.model.SQLRowValues;
28
import org.openconcerto.sql.model.SQLSelect;
28
import org.openconcerto.sql.model.SQLSelect;
29
import org.openconcerto.sql.model.SQLTable;
29
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.model.Where;
30
import org.openconcerto.sql.model.Where;
31
import org.openconcerto.sql.sqlobject.ElementComboBox;
31
import org.openconcerto.sql.sqlobject.ElementComboBox;
32
import org.openconcerto.sql.users.rights.UserRights;
32
import org.openconcerto.sql.users.rights.UserRights;
33
import org.openconcerto.sql.users.rights.UserRightsManager;
33
import org.openconcerto.sql.users.rights.UserRightsManager;
34
import org.openconcerto.sql.view.EditFrame;
34
import org.openconcerto.sql.view.EditFrame;
35
import org.openconcerto.sql.view.EditPanel.EditMode;
35
import org.openconcerto.sql.view.EditPanel.EditMode;
36
import org.openconcerto.sql.view.list.IListe;
36
import org.openconcerto.sql.view.list.IListe;
37
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
37
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
38
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
38
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
39
import org.openconcerto.sql.view.list.SQLTableModelSource;
39
import org.openconcerto.sql.view.list.SQLTableModelSource;
40
import org.openconcerto.ui.DefaultGridBagConstraints;
40
import org.openconcerto.ui.DefaultGridBagConstraints;
41
import org.openconcerto.ui.component.InteractionMode;
41
import org.openconcerto.ui.component.InteractionMode;
42
import org.openconcerto.utils.DecimalUtils;
42
import org.openconcerto.utils.DecimalUtils;
43
import org.openconcerto.utils.cc.ITransformer;
43
import org.openconcerto.utils.cc.ITransformer;
44
 
44
 
45
import java.awt.GridBagConstraints;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
46
import java.awt.GridBagLayout;
47
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionEvent;
48
import java.math.BigDecimal;
48
import java.math.BigDecimal;
49
import java.sql.SQLException;
49
import java.sql.SQLException;
50
import java.util.ArrayList;
50
import java.util.ArrayList;
51
import java.util.HashMap;
51
import java.util.HashMap;
52
import java.util.HashSet;
52
import java.util.HashSet;
53
import java.util.List;
53
import java.util.List;
54
import java.util.Map;
54
import java.util.Map;
55
import java.util.Set;
55
import java.util.Set;
56
 
56
 
57
import javax.swing.AbstractAction;
57
import javax.swing.AbstractAction;
58
import javax.swing.JLabel;
58
import javax.swing.JLabel;
59
import javax.swing.JTextField;
59
import javax.swing.JTextField;
60
 
60
 
61
public class SaisieVenteFactureItemSQLElement extends ComptaSQLConfElement {
61
public class SaisieVenteFactureItemSQLElement extends ComptaSQLConfElement {
62
 
62
 
63
    private final ComptaPropsConfiguration conf;
63
    private final ComptaPropsConfiguration conf;
64
 
64
 
65
    public SaisieVenteFactureItemSQLElement(final ComptaPropsConfiguration conf) {
65
    public SaisieVenteFactureItemSQLElement(final ComptaPropsConfiguration conf) {
66
        super(conf.getRootSociete().getTable("SAISIE_VENTE_FACTURE_ELEMENT"));
66
        super(conf.getRootSociete().getTable("SAISIE_VENTE_FACTURE_ELEMENT"));
67
        this.conf = conf;
67
        this.conf = conf;
68
        PredicateRowAction action = new PredicateRowAction(new AbstractAction("Transfert vers commande fournisseur") {
68
        PredicateRowAction action = new PredicateRowAction(new AbstractAction("Transfert vers commande fournisseur") {
69
 
69
 
70
            @Override
70
            @Override
71
            public void actionPerformed(ActionEvent e) {
71
            public void actionPerformed(ActionEvent e) {
72
                SQLElement cmd = getDirectory().getElement("COMMANDE");
72
                SQLElement cmd = getDirectory().getElement("COMMANDE");
73
                EditFrame f = new EditFrame(cmd, EditMode.CREATION);
73
                EditFrame f = new EditFrame(cmd, EditMode.CREATION);
74
                f.getSQLComponent().select(transfertCommande(IListe.get(e).getSelectedRows()));
74
                f.getSQLComponent().select(transfertCommande(IListe.get(e).getSelectedRows()));
75
                f.setVisible(true);
75
                f.setVisible(true);
76
            }
76
            }
77
        }, false);
77
        }, false);
78
        action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
78
        action.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
79
        getRowActions().add(action);
79
        getRowActions().add(action);
80
    }
80
    }
81
 
81
 
82
    public final ComptaPropsConfiguration getConf() {
82
    public final ComptaPropsConfiguration getConf() {
83
        return this.conf;
83
        return this.conf;
84
    }
84
    }
85
    
85
    
86
    @Override
86
    @Override
87
    protected String getParentFFName() {
87
    protected String getParentFFName() {
88
 
88
 
89
        return "ID_SAISIE_VENTE_FACTURE";
89
        return "ID_SAISIE_VENTE_FACTURE";
90
    }
90
    }
91
 
91
 
92
    /**
92
    /**
93
     * Transfert d'une commande en commande fournisseur
93
     * Transfert d'une commande en commande fournisseur
94
     * 
94
     * 
95
     * @param commandeID
95
     * @param commandeID
96
     */
96
     */
97
    public SQLRowValues transfertCommande(List<SQLRowValues> factItems) {
97
    public SQLRowValues transfertCommande(List<SQLRowValues> factItems) {
98
        SQLTable tableCmd = getDirectory().getElement("COMMANDE").getTable();
98
        SQLTable tableCmd = getDirectory().getElement("COMMANDE").getTable();
99
        SQLTable tableCmdElt = getDirectory().getElement("COMMANDE_ELEMENT").getTable();
99
        SQLTable tableCmdElt = getDirectory().getElement("COMMANDE_ELEMENT").getTable();
100
        SQLRowValues rowCmd = new SQLRowValues(tableCmd);
100
        SQLRowValues rowCmd = new SQLRowValues(tableCmd);
101
 
101
 
102
        final Map<Integer, SQLRowValues> map = new HashMap<Integer, SQLRowValues>();
102
        final Map<Integer, SQLRowValues> map = new HashMap<Integer, SQLRowValues>();
103
        for (SQLRowAccessor sqlRow : factItems) {
103
        for (SQLRowAccessor sqlRow : factItems) {
104
            // on récupére l'article qui lui correspond
104
            // on récupére l'article qui lui correspond
105
            SQLRow sqlRowFetch = sqlRow.asRow();
105
            SQLRow sqlRowFetch = sqlRow.asRow();
106
            sqlRowFetch.fetchValues();
106
            sqlRowFetch.fetchValues();
107
            if (sqlRowFetch.getObject("ID_ARTICLE") != null && !sqlRowFetch.getForeign("ID_ARTICLE").isUndefined()) {
107
            if (sqlRowFetch.getObject("ID_ARTICLE") != null && !sqlRowFetch.getForeign("ID_ARTICLE").isUndefined()) {
108
                int idArt = sqlRowFetch.getForeignID("ID_ARTICLE");
108
                int idArt = sqlRowFetch.getForeignID("ID_ARTICLE");
109
                if (map.containsKey(idArt)) {
109
                if (map.containsKey(idArt)) {
110
                    SQLRowValues rowValsElt = map.get(idArt);
110
                    SQLRowValues rowValsElt = map.get(idArt);
111
                    rowValsElt.put("QTE", rowValsElt.getInt("QTE") + sqlRowFetch.getInt("QTE"));
111
                    rowValsElt.put("QTE", rowValsElt.getInt("QTE") + sqlRowFetch.getInt("QTE"));
112
                } else {
112
                } else {
113
                    SQLInjector inj = SQLInjector.getInjector(sqlRowFetch.getForeign("ID_ARTICLE").getTable(), tableCmdElt);
113
                    SQLInjector inj = SQLInjector.getInjector(sqlRowFetch.getForeign("ID_ARTICLE").getTable(), tableCmdElt);
114
                    SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(sqlRowFetch.getForeign("ID_ARTICLE").asRow()));
114
                    SQLRowValues rowValsElt = new SQLRowValues(inj.createRowValuesFrom(sqlRowFetch.getForeign("ID_ARTICLE").asRow()));
115
                    rowValsElt.put("ID_STYLE", sqlRowFetch.getObject("ID_STYLE"));
115
                    rowValsElt.put("ID_STYLE", sqlRowFetch.getObject("ID_STYLE"));
116
                    rowValsElt.put("QTE", sqlRowFetch.getObject("QTE"));
116
                    rowValsElt.put("QTE", sqlRowFetch.getObject("QTE"));
117
                    rowValsElt.put("T_POIDS", sqlRowFetch.getLong("POIDS") * rowValsElt.getInt("QTE"));
117
                    rowValsElt.put("T_POIDS", sqlRowFetch.getLong("POIDS") * rowValsElt.getInt("QTE"));
118
                    rowValsElt.put("T_PA_HT", ((BigDecimal) sqlRowFetch.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
118
                    rowValsElt.put("T_PA_HT", ((BigDecimal) sqlRowFetch.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION));
119
                    rowValsElt.put("T_PA_TTC",
119
                    rowValsElt.put("T_PA_TTC",
120
                            ((BigDecimal) sqlRowFetch.getObject("T_PA_HT")).multiply(new BigDecimal((sqlRowFetch.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION));
120
                            ((BigDecimal) sqlRowFetch.getObject("T_PA_HT")).multiply(new BigDecimal((sqlRowFetch.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION));
121
                    rowValsElt.put("ID_COMMANDE", rowCmd);
121
                    rowValsElt.put("ID_COMMANDE", rowCmd);
122
                    map.put(idArt, rowValsElt);
122
                    map.put(idArt, rowValsElt);
123
                }
123
                }
124
            }
124
            }
125
 
125
 
126
        }
126
        }
127
        return rowCmd;
127
        return rowCmd;
128
    }
128
    }
129
 
129
 
130
    /*
130
    /*
131
     * (non-Javadoc)
131
     * (non-Javadoc)
132
     * 
132
     * 
133
     * @see org.openconcerto.devis.BaseSQLElement#getComboFields()
133
     * @see org.openconcerto.devis.BaseSQLElement#getComboFields()
134
     */
134
     */
135
    protected List<String> getComboFields() {
135
    protected List<String> getComboFields() {
136
        List<String> l = new ArrayList<String>();
136
        List<String> l = new ArrayList<String>();
137
        l.add("NIVEAU");
137
        l.add("NIVEAU");
138
        l.add("CODE");
138
        l.add("CODE");
139
        l.add("NOM");
139
        l.add("NOM");
140
        l.add("PV_HT");
140
        l.add("PV_HT");
141
        l.add("ID_TAXE");
141
        l.add("ID_TAXE");
142
        l.add("POIDS");
142
        l.add("POIDS");
143
        return l;
143
        return l;
144
    }
144
    }
145
 
145
 
146
    @Override
146
    @Override
147
    protected synchronized void _initTableSource(final SQLTableModelSource table) {
147
    protected synchronized void _initTableSource(final SQLTableModelSource table) {
148
        super._initTableSource(table);
148
        super._initTableSource(table);
149
    }
149
    }
150
 
150
 
151
    @Override
151
    @Override
152
    public Set<String> getReadOnlyFields() {
152
    public Set<String> getReadOnlyFields() {
153
        Set<String> s = new HashSet<String>();
153
        Set<String> s = new HashSet<String>();
154
        s.add("CODE");
154
        s.add("CODE");
155
        s.add("NOM");
155
        s.add("NOM");
156
        s.add("PV_HT");
156
        s.add("PV_HT");
157
        s.add("POIDS");
157
        s.add("POIDS");
158
        s.add("ID_TAXE");
158
        s.add("ID_TAXE");
159
        return super.getReadOnlyFields();
159
        return super.getReadOnlyFields();
160
    }
160
    }
161
 
161
 
162
    /*
162
    /*
163
     * (non-Javadoc)
163
     * (non-Javadoc)
164
     * 
164
     * 
165
     * @see org.openconcerto.devis.BaseSQLElement#getListFields()
165
     * @see org.openconcerto.devis.BaseSQLElement#getListFields()
166
     */
166
     */
-
 
167
    @Override
167
    protected List<String> getListFields() {
168
    protected List<String> getListFields() {
168
        List<String> l = new ArrayList<String>();
169
        List<String> l = new ArrayList<String>();
169
        l.add("ID_SAISIE_VENTE_FACTURE");
170
        l.add("ID_SAISIE_VENTE_FACTURE");
170
 
-
 
171
            l.add("CODE");
171
        l.add("CODE");
172
            l.add("NOM");
172
        l.add("NOM");
173
            l.add("DESCRIPTIF");
173
        l.add("DESCRIPTIF");
174
            String articleAdvanced = DefaultNXProps.getInstance().getStringProperty("ArticleModeVenteAvance");
174
        String articleAdvanced = DefaultNXProps.getInstance().getStringProperty("ArticleModeVenteAvance");
175
            Boolean bArticleAdvanced = Boolean.valueOf(articleAdvanced);
175
        Boolean bArticleAdvanced = Boolean.valueOf(articleAdvanced);
176
            if (bArticleAdvanced) {
176
        if (bArticleAdvanced) {
177
                l.add("PRIX_METRIQUE_VT_1");
177
            l.add("PRIX_METRIQUE_VT_1");
178
                l.add("ID_MODE_VENTE_ARTICLE");
178
            l.add("ID_MODE_VENTE_ARTICLE");
179
            }
179
        }
180
            if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) {
180
        if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) {
181
                l.add("PA_HT");
181
            l.add("PA_HT");
182
            }
182
        }
183
            l.add("PV_HT");
183
        l.add("PV_HT");
184
        l.add("QTE");
184
        l.add("QTE");
185
        if (getTable().contains("ID_ECO_CONTRIBUTION")) {
185
        if (getTable().contains("ID_ECO_CONTRIBUTION")) {
186
            l.add("ID_ECO_CONTRIBUTION");
186
            l.add("ID_ECO_CONTRIBUTION");
187
            l.add("ECO_CONTRIBUTION");
187
            l.add("ECO_CONTRIBUTION");
188
            l.add("T_ECO_CONTRIBUTION");
188
            l.add("T_ECO_CONTRIBUTION");
189
        }
189
        }
190
        l.add("T_PA_HT");
190
        l.add("T_PA_HT");
191
        l.add("T_PV_HT");
191
        l.add("T_PV_HT");
192
        l.add("T_PV_TTC");
192
        l.add("T_PV_TTC");
193
 
193
 
194
        return l;
194
        return l;
195
    }
195
    }
196
 
196
 
197
    /*
197
    /*
198
     * (non-Javadoc)
198
     * (non-Javadoc)
199
     * 
199
     * 
200
     * @see org.openconcerto.devis.SQLElement#getComponent()
200
     * @see org.openconcerto.devis.SQLElement#getComponent()
201
     */
201
     */
202
    public SQLComponent createComponent() {
202
    public SQLComponent createComponent() {
203
        return new BaseSQLComponent(this) {
203
        return new BaseSQLComponent(this) {
204
            JTextField textCode = new JTextField();
204
            JTextField textCode = new JTextField();
205
            JTextField textNom = new JTextField();
205
            JTextField textNom = new JTextField();
206
            JTextField textMontantHT = new JTextField();
206
            JTextField textMontantHT = new JTextField();
207
            JTextField textMontantHA = new JTextField();
207
            JTextField textMontantHA = new JTextField();
208
            ElementComboBox comboTaxe = new ElementComboBox();
208
            ElementComboBox comboTaxe = new ElementComboBox();
209
            JTextField textPoids = new JTextField();
209
            JTextField textPoids = new JTextField();
210
            JTextField textQte = new JTextField();
210
            JTextField textQte = new JTextField();
211
 
211
 
212
            public void addViews() {
212
            public void addViews() {
213
                this.setLayout(new GridBagLayout());
213
                this.setLayout(new GridBagLayout());
214
                final GridBagConstraints c = new DefaultGridBagConstraints();
214
                final GridBagConstraints c = new DefaultGridBagConstraints();
215
 
215
 
216
                // Code
216
                // Code
217
                JLabel labelCode = new JLabel(getLabelFor("CODE"));
217
                JLabel labelCode = new JLabel(getLabelFor("CODE"));
218
                c.weightx = 0;
218
                c.weightx = 0;
219
                this.add(labelCode, c);
219
                this.add(labelCode, c);
220
 
220
 
221
                c.weightx = 1;
221
                c.weightx = 1;
222
                c.gridx++;
222
                c.gridx++;
223
                textCode.setEditable(false);
223
                textCode.setEditable(false);
224
                this.add(textCode, c);
224
                this.add(textCode, c);
225
 
225
 
226
                // Libelle
226
                // Libelle
227
                JLabel labelNom = new JLabel(getLabelFor("NOM"));
227
                JLabel labelNom = new JLabel(getLabelFor("NOM"));
228
                c.weightx = 0;
228
                c.weightx = 0;
229
                c.gridx++;
229
                c.gridx++;
230
                this.add(labelNom, c);
230
                this.add(labelNom, c);
231
 
231
 
232
                c.weightx = 1;
232
                c.weightx = 1;
233
                c.gridx++;
233
                c.gridx++;
234
                textNom.setEditable(false);
234
                textNom.setEditable(false);
235
                this.add(textNom, c);
235
                this.add(textNom, c);
236
 
236
 
237
                // Montant HT
237
                // Montant HT
238
                JLabel labelMontantHT = new JLabel(getLabelFor("PV_HT"));
238
                JLabel labelMontantHT = new JLabel(getLabelFor("PV_HT"));
239
                c.weightx = 0;
239
                c.weightx = 0;
240
                c.gridy++;
240
                c.gridy++;
241
                c.gridx = 0;
241
                c.gridx = 0;
242
                this.add(labelMontantHT, c);
242
                this.add(labelMontantHT, c);
243
 
243
 
244
                c.weightx = 1;
244
                c.weightx = 1;
245
                c.gridx++;
245
                c.gridx++;
246
                textMontantHT.setEditable(false);
246
                textMontantHT.setEditable(false);
247
                this.add(textMontantHT, c);
247
                this.add(textMontantHT, c);
248
 
248
 
249
                // PA HT
249
                // PA HT
250
                JLabel labelMontantHA = new JLabel(getLabelFor("PA_HT"));
250
                JLabel labelMontantHA = new JLabel(getLabelFor("PA_HT"));
251
                c.weightx = 0;
251
                c.weightx = 0;
252
                c.gridy++;
252
                c.gridy++;
253
                c.gridx = 0;
253
                c.gridx = 0;
254
                this.add(labelMontantHA, c);
254
                this.add(labelMontantHA, c);
255
 
255
 
256
                c.weightx = 1;
256
                c.weightx = 1;
257
                c.gridx++;
257
                c.gridx++;
258
                this.add(textMontantHA, c);
258
                this.add(textMontantHA, c);
259
 
259
 
260
                // Taxe
260
                // Taxe
261
                c.gridx++;
261
                c.gridx++;
262
                c.weightx = 0;
262
                c.weightx = 0;
263
                c.gridwidth = GridBagConstraints.REMAINDER;
263
                c.gridwidth = GridBagConstraints.REMAINDER;
264
                comboTaxe.setEnabled(false);
264
                comboTaxe.setEnabled(false);
265
                this.add(comboTaxe, c);
265
                this.add(comboTaxe, c);
266
 
266
 
267
                // Poids
267
                // Poids
268
                JLabel labelPoids = new JLabel(getLabelFor("POIDS"));
268
                JLabel labelPoids = new JLabel(getLabelFor("POIDS"));
269
                c.weightx = 0;
269
                c.weightx = 0;
270
                c.gridy++;
270
                c.gridy++;
271
                c.gridx = 0;
271
                c.gridx = 0;
272
                c.gridwidth = 1;
272
                c.gridwidth = 1;
273
                this.add(labelPoids, c);
273
                this.add(labelPoids, c);
274
 
274
 
275
                c.weightx = 1;
275
                c.weightx = 1;
276
                c.gridx++;
276
                c.gridx++;
277
                textPoids.setEditable(false);
277
                textPoids.setEditable(false);
278
                this.add(textPoids, c);
278
                this.add(textPoids, c);
279
 
279
 
280
                // Quantité
280
                // Quantité
281
                JLabel labelQte = new JLabel(getLabelFor("QTE"));
281
                JLabel labelQte = new JLabel(getLabelFor("QTE"));
282
                // JLabel labelQte = new JLabel("TOTO");
282
                // JLabel labelQte = new JLabel("TOTO");
283
                c.weightx = 0;
283
                c.weightx = 0;
284
                c.gridx++;
284
                c.gridx++;
285
                this.add(labelQte, c);
285
                this.add(labelQte, c);
286
 
286
 
287
                c.weightx = 1;
287
                c.weightx = 1;
288
                c.gridx++;
288
                c.gridx++;
289
                textQte.setEditable(false);
289
                textQte.setEditable(false);
290
                this.add(textQte, c);
290
                this.add(textQte, c);
291
 
291
 
292
                this.addRequiredSQLObject(textCode, "CODE");
292
                this.addRequiredSQLObject(textCode, "CODE");
293
                this.addRequiredSQLObject(textNom, "NOM");
293
                this.addRequiredSQLObject(textNom, "NOM");
294
                this.addRequiredSQLObject(textMontantHT, "PV_HT");
294
                this.addRequiredSQLObject(textMontantHT, "PV_HT");
295
                this.addRequiredSQLObject(textMontantHA, "PA_HT");
295
                this.addRequiredSQLObject(textMontantHA, "PA_HT");
296
                this.addSQLObject(textPoids, "POIDS");
296
                this.addSQLObject(textPoids, "POIDS");
297
                this.addSQLObject(textQte, "QTE");
297
                this.addSQLObject(textQte, "QTE");
298
                this.addRequiredSQLObject(comboTaxe, "ID_TAXE");
298
                this.addRequiredSQLObject(comboTaxe, "ID_TAXE");
299
            }
299
            }
300
 
300
 
301
            @Override
301
            @Override
302
            public void select(SQLRowAccessor r) {
302
            public void select(SQLRowAccessor r) {
303
                // TODO Auto-generated method stub
303
                // TODO Auto-generated method stub
304
                super.select(r);
304
                super.select(r);
305
                textCode.setEditable(false);
305
                textCode.setEditable(false);
306
                textNom.setEditable(false);
306
                textNom.setEditable(false);
307
                textMontantHT.setEditable(false);
307
                textMontantHT.setEditable(false);
308
                comboTaxe.setInteractionMode(InteractionMode.READ_ONLY);
308
                comboTaxe.setInteractionMode(InteractionMode.READ_ONLY);
309
                textPoids.setEditable(false);
309
                textPoids.setEditable(false);
310
                textQte.setEditable(false);
310
                textQte.setEditable(false);
311
 
311
 
312
            }
312
            }
313
 
313
 
314
            @Override
314
            @Override
315
            public void update() {
315
            public void update() {
316
                int id = getSelectedID();
316
                int id = getSelectedID();
317
                super.update();
317
                super.update();
318
                SQLRow row = getTable().getRow(id);
318
                SQLRow row = getTable().getRow(id);
319
                final SQLRowValues createEmptyUpdateRow = row.createEmptyUpdateRow();
319
                final SQLRowValues createEmptyUpdateRow = row.createEmptyUpdateRow();
320
                createEmptyUpdateRow.put("PRIX_METRIQUE_HA_1", row.getObject("PA_HT"));
320
                createEmptyUpdateRow.put("PRIX_METRIQUE_HA_1", row.getObject("PA_HT"));
321
                createEmptyUpdateRow.put("T_PA_HT", row.getObject("PA_HT"));
321
                createEmptyUpdateRow.put("T_PA_HT", row.getObject("PA_HT"));
322
                try {
322
                try {
323
                    createEmptyUpdateRow.commit();
323
                    createEmptyUpdateRow.commit();
324
                } catch (SQLException e) {
324
                } catch (SQLException e) {
325
                    // TODO Auto-generated catch block
325
                    // TODO Auto-generated catch block
326
                    e.printStackTrace();
326
                    e.printStackTrace();
327
                }
327
                }
328
            }
328
            }
329
        };
329
        };
330
    }
330
    }
331
 
331
 
332
    @Override
332
    @Override
333
    protected String createCode() {
333
    protected String createCode() {
334
        return createCodeOfPackage() + ".item";
334
        return createCodeOfPackage() + ".item";
335
    }
335
    }
336
}
336
}