OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 174 Rev 177
Line 14... Line 14...
14
 package org.openconcerto.erp.core.customerrelationship.customer.element;
14
 package org.openconcerto.erp.core.customerrelationship.customer.element;
15
 
15
 
16
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
16
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
18
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
18
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
-
 
19
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
19
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
20
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
20
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
21
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
-
 
22
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
21
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
23
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
22
import org.openconcerto.erp.utils.TM;
24
import org.openconcerto.erp.utils.TM;
23
import org.openconcerto.sql.Configuration;
25
import org.openconcerto.sql.Configuration;
24
import org.openconcerto.sql.element.ElementSQLObject;
26
import org.openconcerto.sql.element.ElementSQLObject;
25
import org.openconcerto.sql.element.GroupSQLComponent;
27
import org.openconcerto.sql.element.GroupSQLComponent;
26
import org.openconcerto.sql.element.SQLElement;
28
import org.openconcerto.sql.element.SQLElement;
27
import org.openconcerto.sql.model.SQLRow;
29
import org.openconcerto.sql.model.SQLRow;
28
import org.openconcerto.sql.model.SQLRowAccessor;
30
import org.openconcerto.sql.model.SQLRowAccessor;
29
import org.openconcerto.sql.model.SQLRowValues;
31
import org.openconcerto.sql.model.SQLRowValues;
-
 
32
import org.openconcerto.sql.model.SQLSelect;
30
import org.openconcerto.sql.model.SQLTable;
33
import org.openconcerto.sql.model.SQLTable;
31
import org.openconcerto.sql.model.UndefinedRowValuesCache;
34
import org.openconcerto.sql.model.UndefinedRowValuesCache;
-
 
35
import org.openconcerto.sql.model.Where;
-
 
36
import org.openconcerto.sql.preferences.SQLPreferences;
32
import org.openconcerto.sql.sqlobject.JUniqueTextField;
37
import org.openconcerto.sql.sqlobject.JUniqueTextField;
33
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
38
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
34
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu;
39
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu;
35
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenuItemsTableFetcher;
40
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenuItemsTableFetcher;
36
import org.openconcerto.sql.ui.textmenu.TextFieldWithWebBrowsing;
41
import org.openconcerto.sql.ui.textmenu.TextFieldWithWebBrowsing;
Line 47... Line 52...
47
import org.openconcerto.ui.component.InteractionMode;
52
import org.openconcerto.ui.component.InteractionMode;
48
import org.openconcerto.utils.ExceptionHandler;
53
import org.openconcerto.utils.ExceptionHandler;
49
 
54
 
50
import java.awt.Component;
55
import java.awt.Component;
51
import java.awt.Dimension;
56
import java.awt.Dimension;
-
 
57
import java.awt.Font;
52
import java.awt.GridBagConstraints;
58
import java.awt.GridBagConstraints;
53
import java.awt.GridBagLayout;
59
import java.awt.GridBagLayout;
54
import java.awt.event.ActionEvent;
60
import java.awt.event.ActionEvent;
55
import java.awt.event.ActionListener;
61
import java.awt.event.ActionListener;
56
import java.sql.SQLException;
62
import java.sql.SQLException;
Line 68... Line 74...
68
import javax.swing.JTextField;
74
import javax.swing.JTextField;
69
import javax.swing.SwingUtilities;
75
import javax.swing.SwingUtilities;
70
import javax.swing.event.DocumentEvent;
76
import javax.swing.event.DocumentEvent;
71
import javax.swing.event.DocumentListener;
77
import javax.swing.event.DocumentListener;
72
 
78
 
73
import com.lowagie.text.Font;
-
 
74
 
-
 
75
public class CustomerSQLComponent extends GroupSQLComponent {
79
public class CustomerSQLComponent extends GroupSQLComponent {
76
    private ContactItemTable table;
80
    private ContactItemTable table;
77
    private ClientCodeArticleTable tableCustomProduct;
81
    private ClientCodeArticleTable tableCustomProduct;
78
    private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
82
    private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
79
 
83
 
Line 324... Line 328...
324
                        JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
328
                        JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
325
                    }
329
                    }
326
                });
330
                });
327
            }
331
            }
328
        }
332
        }
-
 
333
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
-
 
334
        if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.COMPTE_CLIENT_AUTO, Boolean.FALSE)) {
-
 
335
            createCompteClientFromCodeAuto(id);
-
 
336
        }
329
        return id;
337
        return id;
330
    }
338
    }
331
 
339
 
-
 
340
    private void createCompteClientFromCodeAuto(int idClient) {
-
 
341
        final SQLRow rowClient = getTable().getRow(idClient);
-
 
342
        if (rowClient.isForeignEmpty("ID_COMPTE_PCE")) {
-
 
343
 
-
 
344
            SQLRowValues rowVals = rowClient.createEmptyUpdateRow();
-
 
345
            final String text = rowClient.getString("CODE");
-
 
346
 
-
 
347
            String compte = "411" + text;
-
 
348
 
-
 
349
            SQLTable table = getTable().getForeignTable("ID_COMPTE_PCE");
-
 
350
            SQLSelect selCompte = new SQLSelect();
-
 
351
            selCompte.addSelectFunctionStar("COUNT");
-
 
352
            selCompte.setArchivedPolicy(SQLSelect.BOTH);
-
 
353
            selCompte.setWhere(new Where(table.getField("NUMERO"), "LIKE", compte + "%"));
-
 
354
            System.err.println(selCompte.asString());
-
 
355
            Object o = getTable().getDBRoot().getDBSystemRoot().getDataSource().executeScalar(selCompte.asString());
-
 
356
 
-
 
357
            int nb = 0;
-
 
358
            if (o != null) {
-
 
359
                Long i = (Long) o;
-
 
360
                nb = i.intValue();
-
 
361
            }
-
 
362
            if (nb > 0) {
-
 
363
                compte = compte + nb;
-
 
364
            }
-
 
365
            int idCpt = ComptePCESQLElement.getId(compte, rowClient.getString("NOM"));
-
 
366
            rowVals.put("ID_COMPTE_PCE", idCpt);
-
 
367
            try {
-
 
368
                rowVals.update();
-
 
369
            } catch (SQLException e) {
-
 
370
                e.printStackTrace();
-
 
371
            }
-
 
372
        }
-
 
373
    }
-
 
374
 
332
    private JComponent createAdressesComponent() {
375
    private JComponent createAdressesComponent() {
333
        final JTabbedPane tabbedAdresse = new JTabbedPane() {
376
        final JTabbedPane tabbedAdresse = new JTabbedPane() {
334
            public void insertTab(String title, Icon icon, Component component, String tip, int index) {
377
            public void insertTab(String title, Icon icon, Component component, String tip, int index) {
335
                if (component instanceof JComponent) {
378
                if (component instanceof JComponent) {
336
                    ((JComponent) component).setOpaque(false);
379
                    ((JComponent) component).setOpaque(false);