OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 25... Line 25...
25
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.element.SQLElement;
26
import org.openconcerto.sql.element.TreesOfSQLRows;
26
import org.openconcerto.sql.element.TreesOfSQLRows;
27
import org.openconcerto.sql.model.AliasedTable;
27
import org.openconcerto.sql.model.AliasedTable;
28
import org.openconcerto.sql.model.SQLName;
28
import org.openconcerto.sql.model.SQLName;
29
import org.openconcerto.sql.model.SQLRow;
29
import org.openconcerto.sql.model.SQLRow;
-
 
30
import org.openconcerto.sql.model.SQLRowValues;
30
import org.openconcerto.sql.model.SQLSelect;
31
import org.openconcerto.sql.model.SQLSelect;
31
import org.openconcerto.sql.model.SQLTable;
32
import org.openconcerto.sql.model.SQLTable;
32
import org.openconcerto.sql.model.Where;
33
import org.openconcerto.sql.model.Where;
33
import org.openconcerto.sql.request.UpdateBuilder;
34
import org.openconcerto.sql.request.UpdateBuilder;
34
import org.openconcerto.sql.view.EditFrame;
35
import org.openconcerto.sql.view.EditFrame;
35
import org.openconcerto.sql.view.list.IListe;
36
import org.openconcerto.sql.view.list.IListe;
36
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
37
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
37
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
38
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
-
 
39
import org.openconcerto.utils.ExceptionHandler;
38
import org.openconcerto.utils.ListMap;
40
import org.openconcerto.utils.ListMap;
39
 
41
 
40
import java.awt.event.ActionEvent;
42
import java.awt.event.ActionEvent;
41
import java.sql.SQLException;
43
import java.sql.SQLException;
42
import java.util.ArrayList;
44
import java.util.ArrayList;
43
import java.util.List;
45
import java.util.List;
44
 
46
 
45
import javax.swing.AbstractAction;
47
import javax.swing.AbstractAction;
46
import javax.swing.ImageIcon;
48
import javax.swing.ImageIcon;
47
import javax.swing.JFrame;
49
import javax.swing.JFrame;
-
 
50
import javax.swing.JOptionPane;
-
 
51
import javax.swing.SwingWorker;
48
 
52
 
49
import org.apache.commons.dbutils.handlers.ArrayListHandler;
53
import org.apache.commons.dbutils.handlers.ArrayListHandler;
50
 
54
 
51
public class BonReceptionSQLElement extends ComptaSQLConfElement {
55
public class BonReceptionSQLElement extends ComptaSQLConfElement {
52
 
56
 
53
    public BonReceptionSQLElement() {
57
    public BonReceptionSQLElement() {
54
        super("BON_RECEPTION", "un bon de réception", "bons de réception");
58
        super("BON_RECEPTION", "un bon de réception", "bons de réception");
55
 
59
 
56
        PredicateRowAction actionsTRFA = new PredicateRowAction(new AbstractAction("Transfert vers facture fournisseur") {
60
        PredicateRowAction actionsTRFA = new PredicateRowAction(new AbstractAction("Transfert vers facture fournisseur") {
57
            public void actionPerformed(ActionEvent e) {
61
            public void actionPerformed(ActionEvent e) {
-
 
62
                final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows();
-
 
63
                SwingWorker<Boolean, Object> worker = new SwingWorker<Boolean, Object>() {
-
 
64
                    @Override
-
 
65
                    protected Boolean doInBackground() throws Exception {
-
 
66
 
-
 
67
                        boolean b = TransfertBaseSQLComponent.isAlreadyAllTransfert(selectedRows, getTable(), getTable().getTable("FACTURE_FOURNISSEUR"), "TOTAL_HT", "T_HT");
-
 
68
 
-
 
69
                        if (b) {
-
 
70
                            String label = "Attention ";
-
 
71
                            if (selectedRows.size() > 1) {
-
 
72
                                label += " les " + getPluralName() + " ont déjà été transféré!";
-
 
73
                            } else {
-
 
74
                                label += getSingularName() + " a déjà été transféré!";
-
 
75
                            }
-
 
76
                            label += "\n Voulez vous continuer?";
-
 
77
 
-
 
78
                            int ans = JOptionPane.showConfirmDialog(null, label, "Transfert " + getSingularName(), JOptionPane.YES_NO_OPTION);
-
 
79
                            if (ans == JOptionPane.NO_OPTION) {
-
 
80
                                return Boolean.FALSE;
-
 
81
                            }
-
 
82
                        }
-
 
83
 
-
 
84
                        return Boolean.TRUE;
-
 
85
 
-
 
86
                    }
-
 
87
 
-
 
88
                    @Override
-
 
89
                    protected void done() {
-
 
90
                        try {
-
 
91
                            Boolean b = get();
-
 
92
                            if (b) {
58
                TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).getSelectedRows(), "FACTURE_FOURNISSEUR");
93
                                TransfertBaseSQLComponent.openTransfertFrame(selectedRows, "FACTURE_FOURNISSEUR");
-
 
94
                            }
-
 
95
                        } catch (Exception e) {
-
 
96
                            ExceptionHandler.handle("Erreur lors du transfert des " + getPluralName() + "!", e);
-
 
97
                        }
-
 
98
                    }
-
 
99
                };
-
 
100
                worker.execute();
59
            }
101
            }
60
        }, true);
102
        }, true);
61
        actionsTRFA.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
103
        actionsTRFA.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
62
 
104
 
63
        PredicateRowAction actionTRSimple = new PredicateRowAction(new AbstractAction("Transfert vers facture simple") {
105
        PredicateRowAction actionTRSimple = new PredicateRowAction(new AbstractAction("Transfert vers facture simple") {
Line 83... Line 125...
83
 
125
 
84
    @Override
126
    @Override
85
    protected List<String> getListFields() {
127
    protected List<String> getListFields() {
86
        final List<String> l = new ArrayList<>(5);
128
        final List<String> l = new ArrayList<>(5);
87
        l.add("NUMERO");
129
        l.add("NUMERO");
-
 
130
        l.add("NOM");
88
        l.add("DATE");
131
        l.add("DATE");
89
        l.add("ID_FOURNISSEUR");
132
        l.add("ID_FOURNISSEUR");
90
        l.add("TOTAL_HT");
133
        l.add("TOTAL_HT");
91
        l.add("INFOS");
134
        l.add("INFOS");
92
        return l;
135
        return l;