OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 57 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 57 Rev 80
Line 21... Line 21...
21
import org.openconcerto.sql.model.SQLBase;
21
import org.openconcerto.sql.model.SQLBase;
22
import org.openconcerto.sql.model.SQLRowValues;
22
import org.openconcerto.sql.model.SQLRowValues;
23
import org.openconcerto.sql.model.SQLSelect;
23
import org.openconcerto.sql.model.SQLSelect;
24
import org.openconcerto.sql.model.SQLTable;
24
import org.openconcerto.sql.model.SQLTable;
25
import org.openconcerto.sql.model.Where;
25
import org.openconcerto.sql.model.Where;
-
 
26
import org.openconcerto.ui.DefaultGridBagConstraints;
26
 
27
 
-
 
28
import java.awt.GridBagConstraints;
-
 
29
import java.awt.GridBagLayout;
27
import java.util.ArrayList;
30
import java.util.ArrayList;
28
import java.util.List;
31
import java.util.List;
29
 
32
 
30
import javax.swing.JCheckBox;
33
import javax.swing.JCheckBox;
31
import javax.swing.JLabel;
34
import javax.swing.JLabel;
32
import javax.swing.JTextField;
35
import javax.swing.JTextField;
-
 
36
import javax.swing.SwingConstants;
33
 
37
 
34
import org.apache.commons.dbutils.handlers.ArrayListHandler;
38
import org.apache.commons.dbutils.handlers.ArrayListHandler;
35
 
39
 
36
public class JournalSQLElement extends ComptaSQLConfElement {
40
public class JournalSQLElement extends ComptaSQLConfElement {
37
 
41
 
Line 60... Line 64...
60
    }
64
    }
61
 
65
 
62
    public SQLComponent createComponent() {
66
    public SQLComponent createComponent() {
63
        return new BaseSQLComponent(this) {
67
        return new BaseSQLComponent(this) {
64
            public void addViews() {
68
            public void addViews() {
65
 
-
 
-
 
69
                this.setLayout(new GridBagLayout());
-
 
70
                final GridBagConstraints c = new DefaultGridBagConstraints();
66
                this.add(new JLabel(getLabelFor("CODE")));
71
                this.add(new JLabel(getLabelFor("CODE"), SwingConstants.RIGHT), c);
-
 
72
                c.gridx++;
-
 
73
                c.weightx = 1;
-
 
74
                c.fill = GridBagConstraints.NONE;
67
                final JTextField code = new JTextField(6);
75
                final JTextField code = new JTextField(6);
68
                this.add(code);
76
                this.add(code, c);
69
 
77
 
-
 
78
                c.gridx = 0;
-
 
79
                c.gridy++;
-
 
80
                c.fill = GridBagConstraints.HORIZONTAL;
-
 
81
                c.weightx = 0;
70
                this.add(new JLabel(getLabelFor("NOM")));
82
                this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
-
 
83
                c.gridx++;
-
 
84
                c.weightx = 1;
71
                final JTextField nom = new JTextField(25);
85
                final JTextField nom = new JTextField(25);
72
                this.add(nom);
86
                this.add(nom, c);
73
 
-
 
-
 
87
                c.gridy++;
-
 
88
                c.anchor = GridBagConstraints.NORTHWEST;
-
 
89
                c.weighty = 1;
74
                final JCheckBox checkBox = new JCheckBox(getLabelFor("TYPE_BANQUE"));
90
                final JCheckBox checkBox = new JCheckBox(getLabelFor("TYPE_BANQUE"));
75
                this.add(checkBox);
91
                this.add(checkBox, c);
76
 
92
 
77
                this.addView(nom, "NOM", REQ);
93
                this.addView(nom, "NOM", REQ);
78
                this.addView(code, "CODE", REQ);
94
                this.addView(code, "CODE", REQ);
79
                this.addView(checkBox, "TYPE_BANQUE");
95
                this.addView(checkBox, "TYPE_BANQUE");
80
            }
96
            }
Line 89... Line 105...
89
    }
105
    }
90
 
106
 
91
    public static int getIdJournal(final String nom) {
107
    public static int getIdJournal(final String nom) {
92
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
108
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
93
        final SQLTable journalTable = base.getTable("JOURNAL");
109
        final SQLTable journalTable = base.getTable("JOURNAL");
94
        final SQLSelect selJrnl = new SQLSelect(base);
110
        final SQLSelect selJrnl = new SQLSelect();
95
        selJrnl.addSelect(journalTable.getField("ID"));
111
        selJrnl.addSelect(journalTable.getField("ID"));
96
        selJrnl.setWhere(new Where(journalTable.getField("NOM"), "=", nom.trim()));
112
        selJrnl.setWhere(new Where(journalTable.getField("NOM"), "=", nom.trim()));
97
 
113
 
-
 
114
        @SuppressWarnings("unchecked")
98
        final List<Object[]> myListJrnl = (List<Object[]>) base.getDataSource().execute(selJrnl.asString(), new ArrayListHandler());
115
        final List<Object[]> myListJrnl = (List<Object[]>) base.getDataSource().execute(selJrnl.asString(), new ArrayListHandler());
99
 
116
 
100
        if (myListJrnl.size() != 0) {
117
        if (myListJrnl.size() != 0) {
101
            return Integer.parseInt(myListJrnl.get(0)[0].toString());
118
            return Integer.parseInt(myListJrnl.get(0)[0].toString());
102
        } else {
119
        } else {