OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 76 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
76 ilm 1
/*
2
 * Créé le 18 mai 2012
3
 */
4
package org.openconcerto.modules.subscription.panel;
5
 
6
import java.sql.SQLException;
7
import java.util.Calendar;
8
import java.util.Date;
9
 
10
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
11
import org.openconcerto.sql.Configuration;
181 ilm 12
import org.openconcerto.sql.element.SQLElement;
76 ilm 13
import org.openconcerto.sql.model.SQLRow;
14
import org.openconcerto.sql.model.SQLRowValues;
15
import org.openconcerto.sql.model.SQLTable;
16
 
17
public class DevisAboPanel extends AboPanel {
18
 
19
    public DevisAboPanel() {
20
        super(Configuration.getInstance().getDirectory().getElement("DEVIS"), Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT"), "DEVIS");
21
    }
22
 
23
    private SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
181 ilm 24
    private SQLElement eltDev = Configuration.getInstance().getDirectory().getElement("DEVIS");
76 ilm 25
 
26
    @Override
27
    protected void injectRow(SQLRow row, SQLRowValues rowVals, Date dateNew, SQLRow rowAbonnement) {
28
        super.injectRow(row, rowVals, dateNew, rowAbonnement);
181 ilm 29
        String nextNumero = NumerotationAutoSQLElement.getNextNumero(this.eltDev.getClass());
76 ilm 30
        rowVals.put("NUMERO", nextNumero);
31
 
32
        // incrémentation du numéro auto
33
        final SQLRowValues rowValsNum = new SQLRowValues(this.tableNum);
181 ilm 34
        int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(this.eltDev.getClass()));
76 ilm 35
        val++;
181 ilm 36
        rowValsNum.put(NumerotationAutoSQLElement.getLabelNumberFor(this.eltDev.getClass()), new Integer(val));
76 ilm 37
        try {
38
            rowValsNum.update(2);
39
        } catch (final SQLException e) {
40
            e.printStackTrace();
41
        }
42
 
43
        rowVals.put("ID_ETAT_DEVIS", org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement.EN_ATTENTE);
44
        rowVals.put("REMISE_HT", row.getObject("REMISE_HT"));
45
        rowVals.put("INFOS", row.getObject("INFOS"));
46
        rowVals.put("PORT_HT", row.getObject("PORT_HT"));
47
        rowVals.put("OBJET", row.getObject("OBJET"));
48
        rowVals.put("T_POIDS", row.getObject("T_POIDS"));
49
        rowVals.put("ID_ADRESSE", row.getObject("ID_ADRESSE"));
50
        Calendar cal = Calendar.getInstance();
51
        cal.setTime(dateNew);
52
        cal.add(Calendar.MONTH, 1);
53
        rowVals.put("DATE_VALIDITE", cal.getTime());
54
    }
55
 
56
}