OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | Rev 174 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 149 Rev 156
Line 41... Line 41...
41
import org.openconcerto.sql.model.SQLRow;
41
import org.openconcerto.sql.model.SQLRow;
42
import org.openconcerto.sql.model.SQLRowAccessor;
42
import org.openconcerto.sql.model.SQLRowAccessor;
43
import org.openconcerto.sql.model.SQLRowValues;
43
import org.openconcerto.sql.model.SQLRowValues;
44
import org.openconcerto.sql.model.SQLTable;
44
import org.openconcerto.sql.model.SQLTable;
45
import org.openconcerto.sql.model.Where;
45
import org.openconcerto.sql.model.Where;
-
 
46
import org.openconcerto.sql.preferences.SQLPreferences;
46
import org.openconcerto.sql.sqlobject.ElementComboBox;
47
import org.openconcerto.sql.sqlobject.ElementComboBox;
47
import org.openconcerto.sql.sqlobject.JUniqueTextField;
48
import org.openconcerto.sql.sqlobject.JUniqueTextField;
48
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
49
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
49
import org.openconcerto.sql.users.UserManager;
50
import org.openconcerto.sql.users.UserManager;
50
import org.openconcerto.sql.view.EditFrame;
51
import org.openconcerto.sql.view.EditFrame;
Line 67... Line 68...
67
import java.awt.event.ActionEvent;
68
import java.awt.event.ActionEvent;
68
import java.awt.event.ActionListener;
69
import java.awt.event.ActionListener;
69
import java.beans.PropertyChangeEvent;
70
import java.beans.PropertyChangeEvent;
70
import java.beans.PropertyChangeListener;
71
import java.beans.PropertyChangeListener;
71
import java.sql.SQLException;
72
import java.sql.SQLException;
-
 
73
import java.util.List;
72
 
74
 
73
import javax.swing.JCheckBox;
75
import javax.swing.JCheckBox;
74
import javax.swing.JLabel;
76
import javax.swing.JLabel;
75
import javax.swing.JOptionPane;
77
import javax.swing.JOptionPane;
76
import javax.swing.JPanel;
78
import javax.swing.JPanel;
Line 166... Line 168...
166
        c.weightx = 1;
168
        c.weightx = 1;
167
        c.weighty = 0;
169
        c.weighty = 0;
168
        c.fill = GridBagConstraints.NONE;
170
        c.fill = GridBagConstraints.NONE;
169
        this.add(this.fourn, c);
171
        this.add(this.fourn, c);
170
        addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
172
        addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
-
 
173
        fourn.addModelListener("wantedID", new PropertyChangeListener() {
-
 
174
 
-
 
175
            @Override
-
 
176
            public void propertyChange(PropertyChangeEvent evt) {
-
 
177
                int wantedID = fourn.getWantedID();
-
 
178
                if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
-
 
179
 
-
 
180
                    final SQLRow rowF = getTable().getForeignTable("ID_FOURNISSEUR").getRow(wantedID);
-
 
181
 
-
 
182
                    if (rowF.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowF.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
-
 
183
                        table.setRowCatComptable(rowF.getForeign("ID_CATEGORIE_COMPTABLE"));
-
 
184
                    } else {
-
 
185
                        table.setRowCatComptable(null);
-
 
186
                    }
-
 
187
 
-
 
188
                } else {
-
 
189
                    table.setRowCatComptable(null);
-
 
190
                }
-
 
191
            }
-
 
192
        });
171
 
193
 
172
        if (!getTable().getFieldsName().contains("LIVRER")) {
194
        if (!getTable().getFieldsName().contains("LIVRER")) {
173
            // Commande en cours
195
            // Commande en cours
174
            JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
196
            JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
175
            c.gridx += 2;
197
            c.gridx += 2;
Line 348... Line 370...
348
 
370
 
349
            } else {
371
            } else {
350
 
372
 
351
                c.gridy++;
373
                c.gridy++;
352
                c.gridx = 1;
374
                c.gridx = 1;
353
              
375
 
354
                c.gridwidth = GridBagConstraints.REMAINDER;
376
                c.gridwidth = GridBagConstraints.REMAINDER;
355
                this.add(boxLivrClient, c);
377
                this.add(boxLivrClient, c);
356
                c.gridwidth = 1;
378
                c.gridwidth = 1;
357
 
379
 
358
                final GridBagConstraints cAdr = new DefaultGridBagConstraints();
380
                final GridBagConstraints cAdr = new DefaultGridBagConstraints();
Line 452... Line 474...
452
        this.add(addP, c);
474
        this.add(addP, c);
453
 
475
 
454
        c.gridy++;
476
        c.gridy++;
455
        c.gridwidth = 1;
477
        c.gridwidth = 1;
456
 
478
 
-
 
479
        SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
-
 
480
        final boolean showDevise = prefs.getBoolean(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false);
-
 
481
 
457
        final ElementComboBox boxDevise = new ElementComboBox();
482
        final ElementComboBox boxDevise = new ElementComboBox();
458
        if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) {
483
        if (showDevise) {
459
            // Devise
484
            // Devise
460
            c.gridx = 0;
485
            c.gridx = 0;
461
            c.gridy++;
486
            c.gridy++;
462
            c.weightx = 0;
487
            c.weightx = 0;
463
            c.fill = GridBagConstraints.HORIZONTAL;
488
            c.fill = GridBagConstraints.HORIZONTAL;
Line 551... Line 576...
551
        c.gridx = 0;
576
        c.gridx = 0;
552
        c.weightx = 0;
577
        c.weightx = 0;
553
        c.weighty = 1;
578
        c.weighty = 1;
554
        c.gridwidth = 4;
579
        c.gridwidth = 4;
555
        this.add(this.table, c);
580
        this.add(this.table, c);
556
        if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) {
581
        if (showDevise) {
557
 
582
 
558
            boxDevise.addValueListener(new PropertyChangeListener() {
583
            boxDevise.addValueListener(new PropertyChangeListener() {
559
 
584
 
560
                @Override
585
                @Override
561
                public void propertyChange(PropertyChangeEvent evt) {
586
                public void propertyChange(PropertyChangeEvent evt) {
Line 913... Line 938...
913
            final boolean bLivraison = r != null && r.getFields().contains("ID_ADRESSE") && !r.isForeignEmpty("ID_ADRESSE");
938
            final boolean bLivraison = r != null && r.getFields().contains("ID_ADRESSE") && !r.isForeignEmpty("ID_ADRESSE");
914
            componentPrincipaleAdr.setEditable(bLivraison ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
939
            componentPrincipaleAdr.setEditable(bLivraison ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
915
        }
940
        }
916
 
941
 
917
        super.select(r);
942
        super.select(r);
918
        if (r != null) {
-
 
919
            this.table.insertFrom("ID_COMMANDE", r.getID());
-
 
920
        }
-
 
921
    }
943
    }
922
 
944
 
923
    @Override
945
    @Override
924
    public void update() {
946
    public void update() {
925
        if (!this.numeroUniqueCommande.checkValidation()) {
947
        if (!this.numeroUniqueCommande.checkValidation()) {
Line 1097... Line 1119...
1097
        if (this.dateCommande.getValue() != null) {
1119
        if (this.dateCommande.getValue() != null) {
1098
            this.table.setDateDevise(this.dateCommande.getValue());
1120
            this.table.setDateDevise(this.dateCommande.getValue());
1099
        }
1121
        }
1100
 
1122
 
1101
    }
1123
    }
-
 
1124
 
-
 
1125
    public void duplicate(final int idCmd) {
-
 
1126
 
-
 
1127
        final SQLElement cmd = Configuration.getInstance().getDirectory().getElement("COMMANDE");
-
 
1128
        final SQLElement cmdElt = Configuration.getInstance().getDirectory().getElement("COMMANDE_ELEMENT");
-
 
1129
 
-
 
1130
        if (idCmd > 1) {
-
 
1131
            final SQLRow row = cmd.getTable().getRow(idCmd);
-
 
1132
            final SQLRowValues rowVals = new SQLRowValues(cmd.getTable());
-
 
1133
            rowVals.put("ID_FOURNISSEUR", row.getInt("ID_FOURNISSEUR"));
-
 
1134
            rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
-
 
1135
 
-
 
1136
            this.select(rowVals);
-
 
1137
        }
-
 
1138
 
-
 
1139
        final List<SQLRow> myListItem = cmd.getTable().getRow(idCmd).getReferentRows(cmdElt.getTable());
-
 
1140
 
-
 
1141
        if (myListItem.size() != 0) {
-
 
1142
            this.table.getModel().clearRows();
-
 
1143
 
-
 
1144
            for (final SQLRow rowElt : myListItem) {
-
 
1145
 
-
 
1146
                final SQLRowValues rowVals = rowElt.createUpdateRow();
-
 
1147
                rowVals.clearPrimaryKeys();
-
 
1148
                this.table.getModel().addRow(rowVals);
-
 
1149
                final int rowIndex = this.table.getModel().getRowCount() - 1;
-
 
1150
                this.table.getModel().fireTableModelModified(rowIndex);
-
 
1151
            }
-
 
1152
        } else {
-
 
1153
            this.table.getModel().clearRows();
-
 
1154
        }
-
 
1155
        this.table.getModel().fireTableDataChanged();
-
 
1156
        this.table.repaint();
-
 
1157
 
-
 
1158
    }
1102
}
1159
}