169 |
ilm |
1 |
package org.openconcerto.modules.subscription;
|
|
|
2 |
|
|
|
3 |
import java.awt.event.ActionEvent;
|
|
|
4 |
import java.sql.SQLException;
|
|
|
5 |
import java.util.Arrays;
|
|
|
6 |
import java.util.List;
|
|
|
7 |
|
|
|
8 |
import javax.swing.AbstractAction;
|
|
|
9 |
|
|
|
10 |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
|
|
|
11 |
import org.openconcerto.sql.model.DBRoot;
|
|
|
12 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
13 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
|
|
14 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
15 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
16 |
import org.openconcerto.sql.model.Where;
|
|
|
17 |
|
|
|
18 |
public class CheckArticleAction extends AbstractAction {
|
|
|
19 |
|
|
|
20 |
private DBRoot root;
|
|
|
21 |
|
|
|
22 |
public CheckArticleAction(DBRoot root) {
|
|
|
23 |
this.root = root;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
@Override
|
|
|
27 |
public void actionPerformed(ActionEvent e) {
|
|
|
28 |
|
|
|
29 |
SQLTable tableDevisElt = this.root.getTable("DEVIS_ELEMENT");
|
|
|
30 |
SQLTable tableCmd = this.root.getTable("COMMANDE_CLIENT_ELEMENT");
|
|
|
31 |
SQLTable tableFacture = this.root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
|
|
32 |
SQLTable tableAvoir = this.root.getTable("AVOIR_CLIENT_ELEMENT");
|
|
|
33 |
|
|
|
34 |
List<SQLTable> tables = Arrays.asList(tableDevisElt, tableCmd, tableFacture, tableAvoir);
|
|
|
35 |
for (SQLTable sqlTable : tables) {
|
|
|
36 |
SQLSelect sel = new SQLSelect();
|
|
|
37 |
|
|
|
38 |
sel.addSelect(sqlTable.getField("CODE"));
|
|
|
39 |
sel.addSelect(sqlTable.getField("NOM"));
|
|
|
40 |
|
|
|
41 |
Where w = new Where(sqlTable.getField("ID_ARTICLE"), "=", 1);
|
|
|
42 |
sel.setWhere(w);
|
|
|
43 |
List<SQLRow> res = SQLRowListRSH.execute(sel);
|
|
|
44 |
for (SQLRow sqlRow : res) {
|
|
|
45 |
int id = ReferenceArticleSQLElement.getIdForCN(sqlRow.asRowValues(), false);
|
|
|
46 |
if (id > 1) {
|
|
|
47 |
try {
|
|
|
48 |
sqlRow.createEmptyUpdateRow().put("ID_ARTICLE", id).update();
|
|
|
49 |
} catch (SQLException e1) {
|
|
|
50 |
// TODO Auto-generated catch block
|
|
|
51 |
e1.printStackTrace();
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
}
|