OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 96 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 96 Rev 169
Line 18... Line 18...
18
import javax.swing.JTabbedPane;
18
import javax.swing.JTabbedPane;
19
import javax.swing.JTextField;
19
import javax.swing.JTextField;
20
import javax.swing.SwingConstants;
20
import javax.swing.SwingConstants;
21
 
21
 
22
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
22
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
23
import org.openconcerto.erp.core.sales.quote.element.DevisSQLElement;
-
 
24
import org.openconcerto.sql.element.BaseSQLComponent;
23
import org.openconcerto.sql.element.BaseSQLComponent;
25
import org.openconcerto.sql.element.SQLElement;
24
import org.openconcerto.sql.element.SQLElement;
26
import org.openconcerto.sql.model.SQLRow;
25
import org.openconcerto.sql.model.SQLRow;
27
import org.openconcerto.sql.model.SQLRowAccessor;
26
import org.openconcerto.sql.model.SQLRowAccessor;
28
import org.openconcerto.sql.model.SQLRowValues;
27
import org.openconcerto.sql.model.SQLRowValues;
Line 51... Line 50...
51
    public void setLightUI(boolean b) {
50
    public void setLightUI(boolean b) {
52
        labelClient.setVisible(b);
51
        labelClient.setVisible(b);
53
        labelNumero.setVisible(b);
52
        labelNumero.setVisible(b);
54
        labelDate.setVisible(b);
53
        labelDate.setVisible(b);
55
        textNumero.setVisible(b);
54
        textNumero.setVisible(b);
56
 
-
 
57
        date.setVisible(b);
55
        date.setVisible(b);
58
        client.setVisible(b);
56
        client.setVisible(b);
59
    }
57
    }
60
 
58
 
61
    final JUniqueTextField textNumero = new JUniqueTextField(8);
59
    final JUniqueTextField textNumero = new JUniqueTextField(8);
Line 148... Line 146...
148
        this.addView(date, "DATE");
146
        this.addView(date, "DATE");
149
        this.addView(textNom, "NOM");
147
        this.addView(textNom, "NOM");
150
        this.addView(textDescription, "DESCRIPTION");
148
        this.addView(textDescription, "DESCRIPTION");
151
        this.addView(client, "ID_CLIENT");
149
        this.addView(client, "ID_CLIENT");
152
 
150
 
153
        // Codé mais jamais lancé.. a verifier: nom des champs
-
 
154
    }
151
    }
155
 
152
 
156
    private Component createTypeAboComponent(String type, String idName) {
153
    private Component createTypeAboComponent(String type, String idName) {
157
        final String fieldCreate = "CREATE_" + type;
154
        final String fieldCreate = "CREATE_" + type;
158
        final String fieldStart = "DATE_DEBUT_" + type;
155
        final String fieldStart = "DATE_DEBUT_" + type;
Line 178... Line 175...
178
        c.weightx = 0;
175
        c.weightx = 0;
179
        panel.add(new JLabel(getLabelFor(idName), SwingConstants.RIGHT), c);
176
        panel.add(new JLabel(getLabelFor(idName), SwingConstants.RIGHT), c);
180
        c.gridx++;
177
        c.gridx++;
181
        c.weightx = 1;
178
        c.weightx = 1;
182
        final ElementComboBox item = new ElementComboBox();
179
        final ElementComboBox item = new ElementComboBox();
183
        // SQLElement elt =
-
 
184
        // Configuration.getInstance().getDirectory().getElement(getTable().getForeignTable(idName));
-
 
185
        // ComboSQLRequest req = new ComboSQLRequest(elt.getComboRequest(true),
-
 
186
        // Arrays.asList(elt.getTable().getField("NUMERO"), elt.getTable().getField("ID_CLIENT")));
-
 
187
        // item.init(elt, req);
-
 
188
        panel.add(item, c);
180
        panel.add(item, c);
189
 
181
 
190
        // Start
182
        // Start
191
        c.gridx = 0;
183
        c.gridx = 0;
192
        c.gridy++;
184
        c.gridy++;
Line 239... Line 231...
239
 
231
 
240
        setFieldEnabled(item, startDate, stopDate, textPeriod, false);
232
        setFieldEnabled(item, startDate, stopDate, textPeriod, false);
241
        return panel;
233
        return panel;
242
    }
234
    }
243
 
235
 
244
    // @Override
-
 
245
    // protected SQLRowValues createDefaults() {
-
 
246
    // SQLRowValues rowVals = new SQLRowValues(getTable());
-
 
247
    // return super.createDefaults();
-
 
248
    // }
-
 
249
 
-
 
250
    public void setFieldEnabled(JComponent item, JComponent startDate, JComponent stopDate, JComponent textPeriod, boolean b) {
236
    public void setFieldEnabled(JComponent item, JComponent startDate, JComponent stopDate, JComponent textPeriod, boolean b) {
251
        System.err.println(b);
-
 
252
        // Thread.dumpStack();
-
 
253
        item.setEnabled(b);
237
        item.setEnabled(b);
254
        startDate.setEnabled(b);
238
        startDate.setEnabled(b);
255
        stopDate.setEnabled(b);
239
        stopDate.setEnabled(b);
256
        textPeriod.setEnabled(b);
240
        textPeriod.setEnabled(b);
257
    }
241
    }
Line 263... Line 247...
263
        return vals;
247
        return vals;
264
    }
248
    }
265
 
249
 
266
    @Override
250
    @Override
267
    public void select(SQLRowAccessor r) {
251
    public void select(SQLRowAccessor r) {
268
        // TODO Auto-generated method stub
-
 
269
        super.select(r);
252
        super.select(r);
270
        if (r != null) {
253
        if (r != null) {
271
            this.textNumero.setIdSelected(r.getID());
254
            this.textNumero.setIdSelected(r.getID());
272
        }
255
        }
273
    }
256
    }
274
 
257
 
275
    @Override
258
    @Override
276
    public int insert(SQLRow order) {
259
    public int insert(SQLRow order) {
277
        // TODO Auto-generated method stub
-
 
278
        int id = super.insert(order);
260
        int id = super.insert(order);
279
        // incrémentation du numéro auto
261
        // incrémentation du numéro auto
280
        if (NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class).equalsIgnoreCase(this.textNumero.getText().trim())) {
262
        if (NumerotationAutoSQLElement.getNextNumero(SubscriptionSQLElement.class).equalsIgnoreCase(this.textNumero.getText().trim())) {
281
            final SQLRowValues rowVals = new SQLRowValues(this.tableNum);
263
            final SQLRowValues rowVals = new SQLRowValues(this.tableNum);
282
            int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class));
264
            int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(SubscriptionSQLElement.class));
283
            val++;
265
            val++;
284
            rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class), new Integer(val));
266
            rowVals.put(NumerotationAutoSQLElement.getLabelNumberFor(SubscriptionSQLElement.class), val);
285
            try {
267
            try {
286
                rowVals.update(2);
268
                rowVals.update(2);
287
            } catch (final SQLException e) {
269
            } catch (final SQLException e) {
288
                e.printStackTrace();
270
                e.printStackTrace();
289
            }
271
            }
290
        }
272
        }
291
        return id;
273
        return id;
292
    }
274
    }
293
 
275
 
294
    @Override
-
 
295
    public void update() {
-
 
296
        // TODO Auto-generated method stub
-
 
297
        super.update();
-
 
298
    }
-
 
299
}
276
}