OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 83 Rev 90
Line 18... Line 18...
18
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
18
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
19
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
19
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
20
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
20
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
21
import org.openconcerto.erp.core.common.ui.DeviseField;
21
import org.openconcerto.erp.core.common.ui.DeviseField;
22
import org.openconcerto.erp.core.common.ui.TotalPanel;
22
import org.openconcerto.erp.core.common.ui.TotalPanel;
23
import org.openconcerto.erp.core.sales.order.element.CommandeClientSQLElement;
-
 
24
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
23
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
25
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
24
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
26
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
-
 
27
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
25
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
28
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.Type;
26
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.Type;
29
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
27
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
30
import org.openconcerto.erp.panel.PanelOOSQLComponent;
28
import org.openconcerto.erp.panel.PanelOOSQLComponent;
31
import org.openconcerto.erp.preferences.DefaultNXProps;
29
import org.openconcerto.erp.preferences.DefaultNXProps;
Line 34... Line 32...
34
import org.openconcerto.sql.model.SQLBackgroundTableCache;
32
import org.openconcerto.sql.model.SQLBackgroundTableCache;
35
import org.openconcerto.sql.model.SQLInjector;
33
import org.openconcerto.sql.model.SQLInjector;
36
import org.openconcerto.sql.model.SQLRow;
34
import org.openconcerto.sql.model.SQLRow;
37
import org.openconcerto.sql.model.SQLRowAccessor;
35
import org.openconcerto.sql.model.SQLRowAccessor;
38
import org.openconcerto.sql.model.SQLRowValues;
36
import org.openconcerto.sql.model.SQLRowValues;
39
import org.openconcerto.sql.model.SQLSelect;
-
 
40
import org.openconcerto.sql.model.SQLTable;
37
import org.openconcerto.sql.model.SQLTable;
41
import org.openconcerto.sql.model.Where;
-
 
42
import org.openconcerto.sql.sqlobject.ElementComboBox;
38
import org.openconcerto.sql.sqlobject.ElementComboBox;
43
import org.openconcerto.sql.sqlobject.JUniqueTextField;
39
import org.openconcerto.sql.sqlobject.JUniqueTextField;
44
import org.openconcerto.sql.sqlobject.SQLTextCombo;
40
import org.openconcerto.sql.sqlobject.SQLTextCombo;
45
import org.openconcerto.sql.users.UserManager;
41
import org.openconcerto.sql.users.UserManager;
46
import org.openconcerto.sql.view.EditFrame;
42
import org.openconcerto.sql.view.EditFrame;
Line 58... Line 54...
58
import java.awt.GridBagLayout;
54
import java.awt.GridBagLayout;
59
import java.beans.PropertyChangeEvent;
55
import java.beans.PropertyChangeEvent;
60
import java.beans.PropertyChangeListener;
56
import java.beans.PropertyChangeListener;
61
import java.sql.SQLException;
57
import java.sql.SQLException;
62
import java.util.Date;
58
import java.util.Date;
63
import java.util.List;
-
 
64
 
59
 
65
import javax.swing.JLabel;
60
import javax.swing.JLabel;
66
import javax.swing.JOptionPane;
61
import javax.swing.JOptionPane;
67
import javax.swing.JPanel;
62
import javax.swing.JPanel;
68
import javax.swing.JScrollPane;
63
import javax.swing.JScrollPane;
Line 72... Line 67...
72
import javax.swing.event.DocumentEvent;
67
import javax.swing.event.DocumentEvent;
73
import javax.swing.event.DocumentListener;
68
import javax.swing.event.DocumentListener;
74
import javax.swing.event.TableModelEvent;
69
import javax.swing.event.TableModelEvent;
75
import javax.swing.event.TableModelListener;
70
import javax.swing.event.TableModelListener;
76
 
71
 
77
import org.apache.commons.dbutils.handlers.ArrayListHandler;
-
 
78
 
-
 
79
public class CommandeClientSQLComponent extends TransfertBaseSQLComponent {
72
public class CommandeClientSQLComponent extends TransfertBaseSQLComponent {
80
 
73
 
81
    private CommandeClientItemTable table;
74
    private CommandeClientItemTable table;
82
    private JUniqueTextField numeroUniqueCommande;
75
    private JUniqueTextField numeroUniqueCommande;
83
    private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
76
    private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
Line 392... Line 385...
392
        // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
385
        // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
393
        addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
386
        addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
394
        addSQLObject(this.infos, "INFOS");
387
        addSQLObject(this.infos, "INFOS");
395
        addSQLObject(this.comboDevis, "ID_DEVIS");
388
        addSQLObject(this.comboDevis, "ID_DEVIS");
396
 
389
 
397
        this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));
390
        this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
398
 
391
 
399
        this.table.getModel().addTableModelListener(new TableModelListener() {
392
        this.table.getModel().addTableModelListener(new TableModelListener() {
400
 
393
 
401
            public void tableChanged(TableModelEvent e) {
394
            public void tableChanged(TableModelEvent e) {
402
                textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
395
                textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
Line 434... Line 427...
434
            } catch (Exception e) {
427
            } catch (Exception e) {
435
                ExceptionHandler.handle("Impossible de créer la commande", e);
428
                ExceptionHandler.handle("Impossible de créer la commande", e);
436
            }
429
            }
437
 
430
 
438
            // incrémentation du numéro auto
431
            // incrémentation du numéro auto
439
            if (NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
432
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
440
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
433
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
441
                int val = this.tableNum.getRow(2).getInt("COMMANDE_CLIENT_START");
434
                int val = this.tableNum.getRow(2).getInt("COMMANDE_CLIENT_START");
442
                val++;
435
                val++;
443
                rowVals.put("COMMANDE_CLIENT_START", new Integer(val));
436
                rowVals.put("COMMANDE_CLIENT_START", new Integer(val));
444
 
437
 
Line 461... Line 454...
461
        return idCommande;
454
        return idCommande;
462
    }
455
    }
463
 
456
 
464
    @Override
457
    @Override
465
    public void select(SQLRowAccessor r) {
458
    public void select(SQLRowAccessor r) {
466
 
-
 
467
        if (r != null) {
-
 
468
            this.numeroUniqueCommande.setIdSelected(r.getID());
-
 
469
        }
-
 
470
        if (r == null || r.getIDNumber() == null)
459
        if (r == null || r.getIDNumber() == null)
471
            super.select(r);
460
            super.select(r);
472
        else {
461
        else {
473
            System.err.println(r);
462
            System.err.println(r);
474
            final SQLRowValues rVals = r.asRowValues();
463
            final SQLRowValues rVals = r.asRowValues();
Line 543... Line 532...
543
        stockUpdater.update();
532
        stockUpdater.update();
544
    }
533
    }
545
 
534
 
546
    public void setDefaults() {
535
    public void setDefaults() {
547
        this.resetValue();
536
        this.resetValue();
548
        this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));
537
        this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
549
        this.table.getModel().clearRows();
538
        this.table.getModel().clearRows();
550
    }
539
    }
551
 
540
 
552
    /**
541
    /**
553
     * Création d'une commande à partir d'un devis
542
     * Création d'une commande à partir d'un devis
Line 575... Line 564...
575
 
564
 
576
    @Override
565
    @Override
577
    protected SQLRowValues createDefaults() {
566
    protected SQLRowValues createDefaults() {
578
        SQLRowValues rowVals = new SQLRowValues(getTable());
567
        SQLRowValues rowVals = new SQLRowValues(getTable());
579
        rowVals.put("T_POIDS", 0.0F);
568
        rowVals.put("T_POIDS", 0.0F);
580
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));
569
        rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
581
        // User
570
        // User
582
        // SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
571
        // SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
583
        SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
572
        SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
584
        int idUser = UserManager.getInstance().getCurrentUser().getId();
573
        int idUser = UserManager.getInstance().getCurrentUser().getId();
585
        //
574
        //