OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 144 Rev 156
Line 19... Line 19...
19
import org.openconcerto.sql.Configuration;
19
import org.openconcerto.sql.Configuration;
20
import org.openconcerto.sql.model.SQLRow;
20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLRowValues;
21
import org.openconcerto.sql.model.SQLRowValues;
22
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
22
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
23
import org.openconcerto.sql.users.rights.UserRightsManager;
23
import org.openconcerto.sql.users.rights.UserRightsManager;
-
 
24
import org.openconcerto.sql.view.EditFrame;
-
 
25
import org.openconcerto.sql.view.EditPanel.EditMode;
24
import org.openconcerto.sql.view.list.IListe;
26
import org.openconcerto.sql.view.list.IListe;
25
import org.openconcerto.ui.JDate;
27
import org.openconcerto.ui.JDate;
26
import org.openconcerto.utils.GestionDevise;
28
import org.openconcerto.utils.GestionDevise;
27
 
29
 
28
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionListener;
31
import java.awt.event.ActionListener;
30
import java.sql.SQLException;
32
import java.sql.SQLException;
-
 
33
import java.util.List;
31
 
34
 
32
import javax.swing.AbstractAction;
35
import javax.swing.AbstractAction;
33
import javax.swing.JButton;
36
import javax.swing.JButton;
34
import javax.swing.JCheckBox;
37
import javax.swing.JCheckBox;
35
import javax.swing.JOptionPane;
38
import javax.swing.JOptionPane;
36
import javax.swing.JTextField;
39
import javax.swing.JTextField;
37
import javax.swing.text.JTextComponent;
40
import javax.swing.text.JTextComponent;
38
 
41
 
39
public class ListeDesChequesAEncaisserPanel extends ChequeListPanel {
42
public class ListeDesChequesAEncaisserPanel extends ChequeListPanel {
-
 
43
    private JTextField fieldLabel;
40
 
44
 
41
    public ListeDesChequesAEncaisserPanel(final ChequeAEncaisserSQLElement elem) {
45
    public ListeDesChequesAEncaisserPanel(final ChequeAEncaisserSQLElement elem) {
42
        super(elem);
46
        super(elem);
43
    }
47
    }
44
 
48
 
Line 47... Line 51...
47
        return new JButton("Aperçu du relevé");
51
        return new JButton("Aperçu du relevé");
48
    }
52
    }
49
 
53
 
50
    @Override
54
    @Override
51
    protected JTextComponent createLabelText() {
55
    protected JTextComponent createLabelText() {
-
 
56
        if (fieldLabel == null) {
-
 
57
            this.fieldLabel = new JTextField();
-
 
58
        }
52
        return new JTextField();
59
        return fieldLabel;
53
    }
60
    }
54
 
61
 
55
    @Override
62
    @Override
56
    protected JButton createSubmitBtn(final SQLRequestComboBox banqueSelect, final JDate dateDepot, final JCheckBox checkImpression, final JTextComponent text) {
63
    protected JButton createSubmitBtn(final SQLRequestComboBox banqueSelect, final JDate dateDepot, final JCheckBox checkImpression, final JTextComponent text) {
57
        final JButton res = new JButton("Valider le dépôt");
64
        final JButton res = new JButton("Valider le dépôt");
58
        res.addActionListener(new ActionListener() {
65
        res.addActionListener(new ActionListener() {
59
            @Override
66
            @Override
60
            public void actionPerformed(ActionEvent e) {
67
            public void actionPerformed(ActionEvent e) {
61
                final String s = text.getText();
68
                final String s = text.getText();
-
 
69
                SQLRowValues rowValsDepot = new SQLRowValues(element.getTable().getTable("DEPOT_CHEQUE"));
-
 
70
                rowValsDepot.put("DATE", dateDepot.getValue());
-
 
71
                rowValsDepot.put("NOM", fieldLabel.getText());
-
 
72
                final SQLRow selectedBanque = banqueSelect.getSelectedRow();
-
 
73
                if (selectedBanque != null) {
62
                getModel().valideDepot(banqueSelect.getSelectedRow(), dateDepot.getDate(), checkImpression.isSelected(), s);
74
                    rowValsDepot.put("ID_" + selectedBanque.getTable().getName(), selectedBanque.getID());
-
 
75
                }
-
 
76
                List<SQLRowValues> chq = getListe().getSelectedRows();
-
 
77
                for (SQLRowValues sqlRowValues : chq) {
-
 
78
                    SQLRow rowChq = sqlRowValues.asRow();
-
 
79
                    rowChq.fetchValues();
-
 
80
                    SQLRowValues rowValsDepotElt = new SQLRowValues(element.getTable().getTable("DEPOT_CHEQUE_ELEMENT"));
-
 
81
                    rowValsDepotElt.put("ID_DEPOT_CHEQUE", rowValsDepot);
-
 
82
                    if (rowChq.getObject("ID_CLIENT") != null && !rowChq.isForeignEmpty("ID_CLIENT")) {
-
 
83
                        rowValsDepotElt.put("ID_CLIENT", rowChq.getForeignID("ID_CLIENT"));
-
 
84
                    }
-
 
85
                    rowValsDepotElt.put("TIERS", rowChq.getString("TIERS"));
-
 
86
                    rowValsDepotElt.put("ID_CHEQUE_A_ENCAISSER", rowChq.getID());
-
 
87
                    if (rowChq.getObject("DATE") != null) {
-
 
88
                        rowValsDepotElt.put("DATE", rowChq.getObject("DATE"));
-
 
89
                    } else if (rowChq.getObject("DATE_VENTE") != null) {
-
 
90
                        rowValsDepotElt.put("DATE", rowChq.getObject("DATE_VENTE"));
-
 
91
                    }
-
 
92
                    rowValsDepotElt.put("BANQUE", (rowChq.getObject("ETS") == null ? "" : rowChq.getObject("ETS")));
-
 
93
                    if (rowChq.getObject("ID_MOUVEMENT") != null && !rowChq.isForeignEmpty("ID_MOUVEMENT")) {
-
 
94
                        rowValsDepotElt.put("PIECE", rowChq.getForeign("ID_MOUVEMENT").getForeign("ID_PIECE").getString("NOM"));
-
 
95
                    }
-
 
96
                    rowValsDepotElt.put("NUMERO", (rowChq.getObject("NUMERO") == null ? "" : rowChq.getObject("NUMERO")));
-
 
97
                    rowValsDepotElt.put("MONTANT", rowChq.getObject("MONTANT"));
-
 
98
                }
-
 
99
                EditFrame frame = new EditFrame(element.getDirectory().getElement("DEPOT_CHEQUE"), EditMode.CREATION);
-
 
100
                frame.getSQLComponent().select(rowValsDepot);
-
 
101
                frame.setVisible(true);
63
                text.setText("");
102
                text.setText("");
64
            }
103
            }
65
        });
104
        });
66
        return res;
105
        return res;
67
    }
106
    }
Line 76... Line 115...
76
                public void actionPerformed(ActionEvent e) {
115
                public void actionPerformed(ActionEvent e) {
77
                    final SQLRow rowCheque = IListe.get(e).fetchSelectedRow();
116
                    final SQLRow rowCheque = IListe.get(e).fetchSelectedRow();
78
 
117
 
79
                    String price = GestionDevise.currencyToString(rowCheque.getLong("MONTANT"));
118
                    String price = GestionDevise.currencyToString(rowCheque.getLong("MONTANT"));
80
                    SQLRow rowClient = rowCheque.getForeignRow("ID_CLIENT");
119
                    SQLRow rowClient = rowCheque.getForeignRow("ID_CLIENT");
81
                    String nomClient = rowClient.getString("NOM");
120
                    String nomClient = rowClient == null ? rowCheque.getString("TIERS") : rowClient.getString("NOM");
82
                    String piece = "";
121
                    String piece = "";
83
                    SQLRow rowMvt = rowCheque.getForeignRow("ID_MOUVEMENT");
122
                    SQLRow rowMvt = rowCheque.getForeignRow("ID_MOUVEMENT");
84
                    if (rowMvt != null) {
123
                    if (rowMvt != null) {
85
                        SQLRow rowPiece = rowMvt.getForeignRow("ID_PIECE");
124
                        SQLRow rowPiece = rowMvt.getForeignRow("ID_PIECE");
86
                        piece = rowPiece.getString("NOM");
125
                        piece = rowPiece.getString("NOM");