Line 17... |
Line 17... |
17 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
17 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
18 |
import org.openconcerto.erp.core.sales.invoice.report.EtatStockInventaireXmlSheet;
|
18 |
import org.openconcerto.erp.core.sales.invoice.report.EtatStockInventaireXmlSheet;
|
19 |
import org.openconcerto.sql.element.GroupSQLComponent;
|
19 |
import org.openconcerto.sql.element.GroupSQLComponent;
|
20 |
import org.openconcerto.sql.element.SQLComponent;
|
20 |
import org.openconcerto.sql.element.SQLComponent;
|
21 |
import org.openconcerto.sql.element.SQLElement;
|
21 |
import org.openconcerto.sql.element.SQLElement;
|
22 |
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
|
- |
|
23 |
import org.openconcerto.sql.model.SQLDataSource;
|
- |
|
24 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
22 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
25 |
import org.openconcerto.sql.model.Where;
|
23 |
import org.openconcerto.sql.model.Where;
|
26 |
import org.openconcerto.sql.utils.SQLUtils;
|
- |
|
27 |
import org.openconcerto.sql.view.IListFrame;
|
24 |
import org.openconcerto.sql.view.IListFrame;
|
28 |
import org.openconcerto.sql.view.list.IListe;
|
25 |
import org.openconcerto.sql.view.list.IListe;
|
29 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
26 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
30 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
27 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
31 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
28 |
import org.openconcerto.sql.view.list.SQLTableModelSource;
|
32 |
import org.openconcerto.ui.FrameUtil;
|
29 |
import org.openconcerto.ui.FrameUtil;
|
33 |
import org.openconcerto.ui.SwingThreadUtils;
|
30 |
import org.openconcerto.ui.PanelFrame;
|
34 |
import org.openconcerto.utils.ExceptionHandler;
|
31 |
import org.openconcerto.utils.ExceptionHandler;
|
35 |
|
32 |
|
36 |
import java.awt.Component;
|
- |
|
37 |
import java.awt.FileDialog;
|
- |
|
38 |
import java.awt.Frame;
|
- |
|
39 |
import java.awt.event.ActionEvent;
|
33 |
import java.awt.event.ActionEvent;
|
40 |
import java.io.File;
|
- |
|
41 |
import java.io.IOException;
|
- |
|
42 |
import java.sql.SQLException;
|
- |
|
43 |
import java.util.ArrayList;
|
34 |
import java.util.ArrayList;
|
44 |
import java.util.Date;
|
35 |
import java.util.Date;
|
45 |
import java.util.List;
|
36 |
import java.util.List;
|
46 |
|
37 |
|
47 |
import javax.swing.AbstractAction;
|
38 |
import javax.swing.AbstractAction;
|
48 |
import javax.swing.JComponent;
|
39 |
import javax.swing.JComponent;
|
49 |
import javax.swing.JOptionPane;
|
- |
|
50 |
import javax.swing.JTextField;
|
40 |
import javax.swing.JTextField;
|
51 |
|
41 |
|
52 |
public class EtatStockSQLElement extends ComptaSQLConfElement {
|
42 |
public class EtatStockSQLElement extends ComptaSQLConfElement {
|
53 |
|
43 |
|
54 |
public EtatStockSQLElement() {
|
44 |
public EtatStockSQLElement() {
|
Line 57... |
Line 47... |
57 |
{
|
47 |
{
|
58 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Créer un état de stock") {
|
48 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Créer un état de stock") {
|
59 |
|
49 |
|
60 |
@Override
|
50 |
@Override
|
61 |
public void actionPerformed(ActionEvent e) {
|
51 |
public void actionPerformed(ActionEvent e) {
|
62 |
EtatStockSnapshotCreator creator = new EtatStockSnapshotCreator(new Date(), getTable().getDBRoot());
|
52 |
EtatStockSnapshotCreator creator = new EtatStockSnapshotCreator(getTable().getTable("DEPOT_STOCK").getRow(DepotStockSQLElement.DEFAULT_ID), new Date(), getTable().getDBRoot());
|
63 |
creator.create();
|
53 |
creator.create();
|
64 |
}
|
54 |
}
|
65 |
}, true);
|
55 |
}, true);
|
66 |
action.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
|
56 |
action.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
|
67 |
getRowActions().add(action);
|
57 |
getRowActions().add(action);
|
Line 101... |
Line 91... |
101 |
|
91 |
|
102 |
{
|
92 |
{
|
103 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Import Inventaire") {
|
93 |
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Import Inventaire") {
|
104 |
@Override
|
94 |
@Override
|
105 |
public void actionPerformed(ActionEvent e) {
|
95 |
public void actionPerformed(ActionEvent e) {
|
106 |
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
|
96 |
PanelFrame frame = new PanelFrame(new ImportInventairePanel(getDirectory().getElement(DepotStockSQLElement.class)), "Import inventaire");
|
107 |
final FileDialog fd = new FileDialog(frame, "Import Inventaire", FileDialog.LOAD);
|
- |
|
108 |
fd.setVisible(true);
|
97 |
FrameUtil.showPacked(frame);
|
109 |
if (fd.getFile() != null) {
|
- |
|
110 |
final File f = new File(fd.getDirectory(), fd.getFile());
|
- |
|
111 |
if (!f.exists()) {
|
- |
|
112 |
JOptionPane.showMessageDialog(null, "Le ficher selectionné n'existe pas", "Erreur", JOptionPane.ERROR_MESSAGE);
|
- |
|
113 |
} else if (f.isDirectory()) {
|
- |
|
114 |
JOptionPane.showMessageDialog(null, "Le fichier selectionné n'est pas valide", "Erreur", JOptionPane.ERROR_MESSAGE);
|
- |
|
115 |
} else {
|
- |
|
116 |
new Thread(new Runnable() {
|
- |
|
117 |
|
- |
|
118 |
@Override
|
- |
|
119 |
public void run() {
|
- |
|
120 |
final InventaireFromEtatStockImporter impoter = new InventaireFromEtatStockImporter();
|
- |
|
121 |
try {
|
- |
|
122 |
SQLUtils.executeAtomic(getTable().getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
|
- |
|
123 |
@Override
|
- |
|
124 |
public Object handle(final SQLDataSource ds) throws SQLException, IOException {
|
- |
|
125 |
|
- |
|
126 |
impoter.importArticles(f, getTable().getDBRoot());
|
- |
|
127 |
return null;
|
- |
|
128 |
}
|
- |
|
129 |
});
|
- |
|
130 |
} catch (Exception e1) {
|
- |
|
131 |
ExceptionHandler.handle("Erreur lors de l'importation", e1);
|
- |
|
132 |
}
|
- |
|
133 |
|
- |
|
134 |
}
|
- |
|
135 |
}).start();
|
- |
|
136 |
}
|
- |
|
137 |
}
|
- |
|
138 |
}
|
98 |
}
|
139 |
}, true);
|
99 |
}, true);
|
140 |
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
100 |
action.setPredicate(IListeEvent.getSingleSelectionPredicate());
|
141 |
getRowActions().add(action);
|
101 |
getRowActions().add(action);
|
142 |
}
|
102 |
}
|