1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
9 |
* language governing permissions and limitations under the License.
|
9 |
* language governing permissions and limitations under the License.
|
10 |
*
|
10 |
*
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.core.sales.order.component;
|
14 |
package org.openconcerto.erp.core.sales.order.component;
|
15 |
|
15 |
|
16 |
import static org.openconcerto.utils.CollectionUtils.createSet;
|
16 |
import static org.openconcerto.utils.CollectionUtils.createSet;
|
17 |
|
17 |
|
18 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
18 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
19 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
19 |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent;
|
20 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
20 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
21 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
|
21 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
|
22 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
22 |
import org.openconcerto.erp.core.common.ui.DeviseField;
|
23 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
23 |
import org.openconcerto.erp.core.common.ui.TotalPanel;
|
24 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
|
24 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI;
|
25 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
25 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseType;
|
26 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
|
26 |
import org.openconcerto.erp.core.customerrelationship.customer.ui.CategorieComptableChoiceUI;
|
27 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
27 |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
|
28 |
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
|
28 |
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
|
29 |
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
|
29 |
import org.openconcerto.erp.core.sales.order.ui.CommandeClientItemTable;
|
30 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
|
30 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
|
31 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClientComboBox;
|
31 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClientComboBox;
|
32 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeRowItemView;
|
32 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeRowItemView;
|
33 |
import org.openconcerto.erp.core.supplychain.order.table.ChiffrageCommandeTable;
|
33 |
import org.openconcerto.erp.core.supplychain.order.table.ChiffrageCommandeTable;
|
34 |
import org.openconcerto.erp.core.supplychain.order.table.FacturationCommandeTable;
|
34 |
import org.openconcerto.erp.core.supplychain.order.table.FacturationCommandeTable;
|
35 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
35 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater;
|
36 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
36 |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate;
|
37 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
37 |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel;
|
38 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
38 |
import org.openconcerto.erp.panel.PanelOOSQLComponent;
|
39 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
39 |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
|
40 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
40 |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
|
41 |
import org.openconcerto.erp.utils.TM;
|
41 |
import org.openconcerto.erp.utils.TM;
|
42 |
import org.openconcerto.sql.Configuration;
|
42 |
import org.openconcerto.sql.Configuration;
|
43 |
import org.openconcerto.sql.element.SQLElement;
|
43 |
import org.openconcerto.sql.element.SQLElement;
|
44 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
44 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
45 |
import org.openconcerto.sql.model.SQLInjector;
|
45 |
import org.openconcerto.sql.model.SQLInjector;
|
46 |
import org.openconcerto.sql.model.SQLRow;
|
46 |
import org.openconcerto.sql.model.SQLRow;
|
47 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
47 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
48 |
import org.openconcerto.sql.model.SQLRowValues;
|
48 |
import org.openconcerto.sql.model.SQLRowValues;
|
49 |
import org.openconcerto.sql.model.SQLTable;
|
49 |
import org.openconcerto.sql.model.SQLTable;
|
50 |
import org.openconcerto.sql.model.Where;
|
50 |
import org.openconcerto.sql.model.Where;
|
51 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
51 |
import org.openconcerto.sql.preferences.SQLPreferences;
|
52 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
52 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
53 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
53 |
import org.openconcerto.sql.sqlobject.JUniqueTextField;
|
54 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
54 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
55 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
55 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
56 |
import org.openconcerto.sql.users.UserManager;
|
56 |
import org.openconcerto.sql.users.UserManager;
|
57 |
import org.openconcerto.sql.view.EditFrame;
|
57 |
import org.openconcerto.sql.view.EditFrame;
|
58 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
58 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
59 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
59 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
60 |
import org.openconcerto.ui.FormLayouter;
|
60 |
import org.openconcerto.ui.FormLayouter;
|
61 |
import org.openconcerto.ui.JDate;
|
61 |
import org.openconcerto.ui.JDate;
|
62 |
import org.openconcerto.ui.TitledSeparator;
|
62 |
import org.openconcerto.ui.TitledSeparator;
|
63 |
import org.openconcerto.ui.component.ITextArea;
|
63 |
import org.openconcerto.ui.component.ITextArea;
|
64 |
import org.openconcerto.utils.ExceptionHandler;
|
64 |
import org.openconcerto.utils.ExceptionHandler;
|
65 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
65 |
import org.openconcerto.utils.text.SimpleDocumentListener;
|
66 |
|
66 |
|
67 |
import java.awt.Color;
|
67 |
import java.awt.Color;
|
68 |
import java.awt.GridBagConstraints;
|
68 |
import java.awt.GridBagConstraints;
|
69 |
import java.awt.GridBagLayout;
|
69 |
import java.awt.GridBagLayout;
|
70 |
import java.beans.PropertyChangeEvent;
|
70 |
import java.beans.PropertyChangeEvent;
|
71 |
import java.beans.PropertyChangeListener;
|
71 |
import java.beans.PropertyChangeListener;
|
72 |
import java.sql.SQLException;
|
72 |
import java.sql.SQLException;
|
73 |
import java.util.Date;
|
73 |
import java.util.Date;
|
74 |
import java.util.HashSet;
|
74 |
import java.util.HashSet;
|
75 |
import java.util.Set;
|
75 |
import java.util.Set;
|
76 |
|
76 |
|
77 |
import javax.swing.JLabel;
|
77 |
import javax.swing.JLabel;
|
78 |
import javax.swing.JOptionPane;
|
78 |
import javax.swing.JOptionPane;
|
79 |
import javax.swing.JPanel;
|
79 |
import javax.swing.JPanel;
|
80 |
import javax.swing.JScrollPane;
|
80 |
import javax.swing.JScrollPane;
|
81 |
import javax.swing.JTabbedPane;
|
81 |
import javax.swing.JTabbedPane;
|
82 |
import javax.swing.JTextField;
|
82 |
import javax.swing.JTextField;
|
83 |
import javax.swing.SwingConstants;
|
83 |
import javax.swing.SwingConstants;
|
84 |
import javax.swing.SwingUtilities;
|
84 |
import javax.swing.SwingUtilities;
|
85 |
import javax.swing.event.DocumentEvent;
|
85 |
import javax.swing.event.DocumentEvent;
|
86 |
import javax.swing.event.DocumentListener;
|
86 |
import javax.swing.event.DocumentListener;
|
87 |
import javax.swing.event.TableModelEvent;
|
87 |
import javax.swing.event.TableModelEvent;
|
88 |
import javax.swing.event.TableModelListener;
|
88 |
import javax.swing.event.TableModelListener;
|
89 |
|
89 |
|
90 |
public class CommandeClientSQLComponent extends TransfertBaseSQLComponent {
|
90 |
public class CommandeClientSQLComponent extends TransfertBaseSQLComponent {
|
91 |
|
91 |
|
92 |
private CommandeClientItemTable table;
|
92 |
private CommandeClientItemTable table;
|
93 |
private FacturationCommandeTable tableFacturationItem;
|
93 |
private FacturationCommandeTable tableFacturationItem;
|
94 |
private ChiffrageCommandeTable tableChiffrageItem;
|
94 |
private ChiffrageCommandeTable tableChiffrageItem;
|
95 |
private JUniqueTextField numeroUniqueCommande;
|
95 |
private JUniqueTextField numeroUniqueCommande;
|
96 |
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
|
96 |
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
|
97 |
private final ITextArea infos = new ITextArea(3, 3);
|
97 |
private final ITextArea infos = new ITextArea(3, 3);
|
98 |
private ElementComboBox comboCommercial, comboDevis, comboClient;
|
98 |
private ElementComboBox comboCommercial, comboDevis, comboClient;
|
99 |
private PanelOOSQLComponent panelOO;
|
99 |
private PanelOOSQLComponent panelOO;
|
100 |
final JDate dateCommande = new JDate(true);
|
100 |
final JDate dateCommande = new JDate(true);
|
101 |
private final boolean displayDpt;
|
101 |
private final boolean displayDpt;
|
102 |
private final ElementComboBox comboDpt = new ElementComboBox();
|
102 |
private final ElementComboBox comboDpt = new ElementComboBox();
|
103 |
|
103 |
|
104 |
private final SQLTextCombo textObjet = new SQLTextCombo();
|
104 |
private final SQLTextCombo textObjet = new SQLTextCombo();
|
105 |
|
105 |
|
106 |
public CommandeClientSQLComponent() {
|
106 |
public CommandeClientSQLComponent() {
|
107 |
super(Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT"));
|
107 |
super(Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT"));
|
108 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
108 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
109 |
this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
|
109 |
this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false);
|
110 |
}
|
110 |
}
|
111 |
|
111 |
|
112 |
public RowValuesTable getRowValuesTable() {
|
112 |
public RowValuesTable getRowValuesTable() {
|
113 |
return this.table.getRowValuesTable();
|
113 |
return this.table.getRowValuesTable();
|
114 |
}
|
114 |
}
|
115 |
|
115 |
|
116 |
public void addViews() {
|
116 |
public void addViews() {
|
117 |
this.setLayout(new GridBagLayout());
|
117 |
this.setLayout(new GridBagLayout());
|
118 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
118 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
119 |
|
119 |
|
120 |
// Numero du commande
|
120 |
// Numero du commande
|
121 |
c.gridx = 0;
|
121 |
c.gridx = 0;
|
122 |
this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
|
122 |
this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
|
123 |
|
123 |
|
124 |
this.numeroUniqueCommande = new JUniqueTextField(16) {
|
124 |
this.numeroUniqueCommande = new JUniqueTextField(16) {
|
125 |
@Override
|
125 |
@Override
|
126 |
public String getAutoRefreshNumber() {
|
126 |
public String getAutoRefreshNumber() {
|
127 |
if (getMode() == Mode.INSERTION) {
|
127 |
if (getMode() == Mode.INSERTION) {
|
128 |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateCommande.getDate());
|
128 |
return NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateCommande.getDate());
|
129 |
} else {
|
129 |
} else {
|
130 |
return null;
|
130 |
return null;
|
131 |
}
|
131 |
}
|
132 |
}
|
132 |
}
|
133 |
};
|
133 |
};
|
134 |
c.fill = GridBagConstraints.NONE;
|
134 |
c.fill = GridBagConstraints.NONE;
|
135 |
c.gridx++;
|
135 |
c.gridx++;
|
136 |
c.weightx = 1;
|
136 |
c.weightx = 1;
|
137 |
this.add(this.numeroUniqueCommande, c);
|
137 |
this.add(this.numeroUniqueCommande, c);
|
138 |
|
138 |
|
139 |
// Date
|
139 |
// Date
|
140 |
JLabel labelDate = new JLabel(getLabelFor("DATE"));
|
140 |
JLabel labelDate = new JLabel(getLabelFor("DATE"));
|
141 |
labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
|
141 |
labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
|
142 |
c.gridx = 2;
|
142 |
c.gridx = 2;
|
143 |
c.fill = GridBagConstraints.HORIZONTAL;
|
143 |
c.fill = GridBagConstraints.HORIZONTAL;
|
144 |
c.weightx = 0;
|
144 |
c.weightx = 0;
|
145 |
this.add(labelDate, c);
|
145 |
this.add(labelDate, c);
|
146 |
|
146 |
|
147 |
c.gridx++;
|
147 |
c.gridx++;
|
148 |
c.fill = GridBagConstraints.NONE;
|
148 |
c.fill = GridBagConstraints.NONE;
|
149 |
this.add(dateCommande, c);
|
149 |
this.add(dateCommande, c);
|
150 |
dateCommande.addValueListener(new PropertyChangeListener() {
|
150 |
dateCommande.addValueListener(new PropertyChangeListener() {
|
151 |
|
151 |
|
152 |
@Override
|
152 |
@Override
|
153 |
public void propertyChange(PropertyChangeEvent evt) {
|
153 |
public void propertyChange(PropertyChangeEvent evt) {
|
154 |
if (!isFilling() && dateCommande.getValue() != null) {
|
154 |
if (!isFilling() && dateCommande.getValue() != null) {
|
155 |
table.setDateDevise(dateCommande.getValue());
|
155 |
table.setDateDevise(dateCommande.getValue());
|
156 |
}
|
156 |
}
|
157 |
}
|
157 |
}
|
158 |
});
|
158 |
});
|
159 |
|
159 |
|
160 |
// Champ Module
|
160 |
// Champ Module
|
161 |
c.gridx = 0;
|
161 |
c.gridx = 0;
|
162 |
c.gridy++;
|
162 |
c.gridy++;
|
163 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
163 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
164 |
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
|
164 |
final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
|
165 |
|
165 |
|
166 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
|
166 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
|
167 |
c.fill = GridBagConstraints.HORIZONTAL;
|
167 |
c.fill = GridBagConstraints.HORIZONTAL;
|
168 |
c.weightx = 1;
|
168 |
c.weightx = 1;
|
169 |
this.add(addP, c);
|
169 |
this.add(addP, c);
|
170 |
|
170 |
|
171 |
c.gridy++;
|
171 |
c.gridy++;
|
172 |
c.gridwidth = 1;
|
172 |
c.gridwidth = 1;
|
173 |
|
173 |
|
174 |
this.comboDevis = new ElementComboBox();
|
174 |
this.comboDevis = new ElementComboBox();
|
175 |
|
175 |
|
176 |
// Reference
|
176 |
// Reference
|
177 |
c.gridx = 0;
|
177 |
c.gridx = 0;
|
178 |
c.gridy++;
|
178 |
c.gridy++;
|
179 |
c.gridwidth = 1;
|
179 |
c.gridwidth = 1;
|
180 |
c.gridwidth = 1;
|
180 |
c.gridwidth = 1;
|
181 |
c.gridheight = 1;
|
181 |
c.gridheight = 1;
|
182 |
c.fill = GridBagConstraints.HORIZONTAL;
|
182 |
c.fill = GridBagConstraints.HORIZONTAL;
|
183 |
|
183 |
|
184 |
JLabel labelObjet = new JLabel(getLabelFor("NOM"));
|
184 |
JLabel labelObjet = new JLabel(getLabelFor("NOM"));
|
185 |
labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);
|
185 |
labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);
|
186 |
c.weightx = 0;
|
186 |
c.weightx = 0;
|
187 |
this.add(labelObjet, c);
|
187 |
this.add(labelObjet, c);
|
188 |
|
188 |
|
189 |
c.gridx++;
|
189 |
c.gridx++;
|
190 |
c.weightx = 1;
|
190 |
c.weightx = 1;
|
191 |
c.fill = GridBagConstraints.BOTH;
|
191 |
c.fill = GridBagConstraints.BOTH;
|
192 |
this.add(this.textObjet, c);
|
192 |
this.add(this.textObjet, c);
|
193 |
|
193 |
|
194 |
String field;
|
194 |
String field;
|
195 |
field = "ID_COMMERCIAL";
|
195 |
field = "ID_COMMERCIAL";
|
196 |
c.fill = GridBagConstraints.HORIZONTAL;
|
196 |
c.fill = GridBagConstraints.HORIZONTAL;
|
197 |
// Commercial
|
197 |
// Commercial
|
198 |
JLabel labelCommercial = new JLabel(getLabelFor(field));
|
198 |
JLabel labelCommercial = new JLabel(getLabelFor(field));
|
199 |
labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);
|
199 |
labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);
|
200 |
|
200 |
|
201 |
c.gridx++;
|
201 |
c.gridx++;
|
202 |
c.weightx = 0;
|
202 |
c.weightx = 0;
|
203 |
this.add(labelCommercial, c);
|
203 |
this.add(labelCommercial, c);
|
204 |
|
204 |
|
205 |
this.comboCommercial = new ElementComboBox(false, 25);
|
205 |
this.comboCommercial = new ElementComboBox(false, 25);
|
206 |
this.comboCommercial.setListIconVisible(false);
|
206 |
this.comboCommercial.setListIconVisible(false);
|
207 |
c.gridx++;
|
207 |
c.gridx++;
|
208 |
c.fill = GridBagConstraints.NONE;
|
208 |
c.fill = GridBagConstraints.NONE;
|
209 |
c.weightx = 1;
|
209 |
c.weightx = 1;
|
210 |
this.add(this.comboCommercial, c);
|
210 |
this.add(this.comboCommercial, c);
|
211 |
addRequiredSQLObject(this.comboCommercial, field);
|
211 |
addRequiredSQLObject(this.comboCommercial, field);
|
212 |
|
212 |
|
213 |
// Ligne 3: Client
|
213 |
// Ligne 3: Client
|
214 |
c.gridx = 0;
|
214 |
c.gridx = 0;
|
215 |
c.gridy++;
|
215 |
c.gridy++;
|
216 |
c.weightx = 0;
|
216 |
c.weightx = 0;
|
217 |
c.fill = GridBagConstraints.HORIZONTAL;
|
217 |
c.fill = GridBagConstraints.HORIZONTAL;
|
218 |
this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);
|
218 |
this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);
|
219 |
|
219 |
|
220 |
this.comboClient = new ElementComboBox();
|
220 |
this.comboClient = new ElementComboBox();
|
221 |
c.gridx++;
|
221 |
c.gridx++;
|
222 |
c.gridwidth = 1;
|
222 |
c.gridwidth = 1;
|
223 |
c.weightx = 1;
|
223 |
c.weightx = 1;
|
224 |
c.weighty = 0;
|
224 |
c.weighty = 0;
|
225 |
c.fill = GridBagConstraints.NONE;
|
225 |
c.fill = GridBagConstraints.NONE;
|
226 |
this.add(this.comboClient, c);
|
226 |
this.add(this.comboClient, c);
|
227 |
final ElementComboBox boxTarif = new ElementComboBox();
|
227 |
final ElementComboBox boxTarif = new ElementComboBox();
|
228 |
this.comboClient.addValueListener(new PropertyChangeListener() {
|
228 |
this.comboClient.addValueListener(new PropertyChangeListener() {
|
229 |
|
229 |
|
230 |
@Override
|
230 |
@Override
|
231 |
public void propertyChange(PropertyChangeEvent evt) {
|
231 |
public void propertyChange(PropertyChangeEvent evt) {
|
232 |
if (!isFilling() && comboClient.getValue() != null) {
|
232 |
if (!isFilling() && comboClient.getValue() != null) {
|
233 |
Integer id = comboClient.getValue();
|
233 |
Integer id = comboClient.getValue();
|
234 |
|
234 |
|
235 |
if (id > 1) {
|
235 |
if (id > 1) {
|
236 |
|
236 |
|
237 |
SQLRow row = comboClient.getElement().getTable().getRow(id);
|
237 |
SQLRow row = comboClient.getElement().getTable().getRow(id);
|
238 |
if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
|
238 |
if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {
|
239 |
|
239 |
|
240 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
240 |
SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
241 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
241 |
if (!foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID())
|
242 |
&& JOptionPane.showConfirmDialog(null, TM.tr("apply.associated.pricelist.to.customer")) == JOptionPane.YES_OPTION) {
|
242 |
&& JOptionPane.showConfirmDialog(null, TM.tr("apply.associated.pricelist.to.customer")) == JOptionPane.YES_OPTION) {
|
243 |
boxTarif.setValue(foreignRow.getID());
|
243 |
boxTarif.setValue(foreignRow.getID());
|
244 |
// SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
|
244 |
// SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
|
245 |
// true);
|
245 |
// true);
|
246 |
} else {
|
246 |
} else {
|
247 |
boxTarif.setValue(foreignRow.getID());
|
247 |
boxTarif.setValue(foreignRow.getID());
|
248 |
}
|
248 |
}
|
249 |
// SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
249 |
// SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
|
250 |
// if (foreignRow.isUndefined() &&
|
250 |
// if (foreignRow.isUndefined() &&
|
251 |
// !row.getForeignRow("ID_DEVISE").isUndefined()) {
|
251 |
// !row.getForeignRow("ID_DEVISE").isUndefined()) {
|
252 |
// SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
|
252 |
// SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
|
253 |
// rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
|
253 |
// rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
|
254 |
// foreignRow = rowValsD;
|
254 |
// foreignRow = rowValsD;
|
255 |
//
|
255 |
//
|
256 |
// }
|
256 |
// }
|
257 |
// table.setTarif(foreignRow, true);
|
257 |
// table.setTarif(foreignRow, true);
|
258 |
}
|
258 |
}
|
259 |
if (!isFilling()) {
|
259 |
if (!isFilling()) {
|
260 |
table.setClient(row, true);
|
260 |
table.setClient(row, true);
|
261 |
}
|
261 |
}
|
262 |
|
262 |
|
263 |
} else {
|
263 |
} else {
|
264 |
if (!isFilling()) {
|
264 |
if (!isFilling()) {
|
265 |
table.setClient(null, true);
|
265 |
table.setClient(null, true);
|
266 |
}
|
266 |
}
|
267 |
}
|
267 |
}
|
268 |
}
|
268 |
}
|
269 |
|
269 |
|
270 |
}
|
270 |
}
|
271 |
});
|
271 |
});
|
272 |
addRequiredSQLObject(this.comboClient, "ID_CLIENT");
|
272 |
addRequiredSQLObject(this.comboClient, "ID_CLIENT");
|
273 |
|
273 |
|
274 |
if (this.displayDpt) {
|
274 |
if (this.displayDpt) {
|
275 |
c.gridx++;
|
275 |
c.gridx++;
|
276 |
c.gridwidth = 1;
|
276 |
c.gridwidth = 1;
|
277 |
final JLabel labelDpt = new JLabel(getLabelFor("ID_CLIENT_DEPARTEMENT"));
|
277 |
final JLabel labelDpt = new JLabel(getLabelFor("ID_CLIENT_DEPARTEMENT"));
|
278 |
labelDpt.setHorizontalAlignment(SwingConstants.RIGHT);
|
278 |
labelDpt.setHorizontalAlignment(SwingConstants.RIGHT);
|
279 |
c.weightx = 0;
|
279 |
c.weightx = 0;
|
280 |
c.gridwidth = 1;
|
280 |
c.gridwidth = 1;
|
281 |
c.fill = GridBagConstraints.HORIZONTAL;
|
281 |
c.fill = GridBagConstraints.HORIZONTAL;
|
282 |
this.add(labelDpt, c);
|
282 |
this.add(labelDpt, c);
|
283 |
|
283 |
|
284 |
c.gridx++;
|
284 |
c.gridx++;
|
285 |
c.gridwidth = 1;
|
285 |
c.gridwidth = 1;
|
286 |
c.weightx = 0;
|
286 |
c.weightx = 0;
|
287 |
c.weighty = 0;
|
287 |
c.weighty = 0;
|
288 |
c.fill = GridBagConstraints.NONE;
|
288 |
c.fill = GridBagConstraints.NONE;
|
289 |
this.add(this.comboDpt, c);
|
289 |
this.add(this.comboDpt, c);
|
290 |
DefaultGridBagConstraints.lockMinimumSize(this.comboDpt);
|
290 |
DefaultGridBagConstraints.lockMinimumSize(this.comboDpt);
|
291 |
addSQLObject(this.comboDpt, "ID_CLIENT_DEPARTEMENT");
|
291 |
addSQLObject(this.comboDpt, "ID_CLIENT_DEPARTEMENT");
|
292 |
|
292 |
|
293 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
293 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
294 |
|
294 |
|
295 |
@Override
|
295 |
@Override
|
296 |
public void propertyChange(PropertyChangeEvent evt) {
|
296 |
public void propertyChange(PropertyChangeEvent evt) {
|
297 |
int wantedID = comboClient.getWantedID();
|
297 |
int wantedID = comboClient.getWantedID();
|
298 |
|
298 |
|
299 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
299 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
300 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
300 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
301 |
comboDpt.getRequest().setWhere(new Where(comboDpt.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", rowClient.getID()));
|
301 |
comboDpt.getRequest().setWhere(new Where(comboDpt.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", rowClient.getID()));
|
302 |
} else {
|
302 |
} else {
|
303 |
comboDpt.getRequest().setWhere(null);
|
303 |
comboDpt.getRequest().setWhere(null);
|
304 |
}
|
304 |
}
|
305 |
}
|
305 |
}
|
306 |
});
|
306 |
});
|
307 |
|
307 |
|
308 |
}
|
308 |
}
|
309 |
if (getTable().contains("ID_CONTACT")) {
|
309 |
if (getTable().contains("ID_CONTACT")) {
|
310 |
// Contact Client
|
310 |
// Contact Client
|
311 |
c.gridx = 0;
|
311 |
c.gridx = 0;
|
312 |
c.gridy++;
|
312 |
c.gridy++;
|
313 |
c.gridwidth = 1;
|
313 |
c.gridwidth = 1;
|
314 |
final JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"));
|
314 |
final JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"));
|
315 |
labelContact.setHorizontalAlignment(SwingConstants.RIGHT);
|
315 |
labelContact.setHorizontalAlignment(SwingConstants.RIGHT);
|
316 |
c.weightx = 0;
|
316 |
c.weightx = 0;
|
317 |
c.gridwidth = 1;
|
317 |
c.gridwidth = 1;
|
318 |
c.fill = GridBagConstraints.HORIZONTAL;
|
318 |
c.fill = GridBagConstraints.HORIZONTAL;
|
319 |
this.add(labelContact, c);
|
319 |
this.add(labelContact, c);
|
320 |
|
320 |
|
321 |
final ElementComboBox comboContact = new ElementComboBox();
|
321 |
final ElementComboBox comboContact = new ElementComboBox();
|
322 |
c.gridx++;
|
322 |
c.gridx++;
|
323 |
c.gridwidth = 1;
|
323 |
c.gridwidth = 1;
|
324 |
c.weightx = 0;
|
324 |
c.weightx = 0;
|
325 |
c.weighty = 0;
|
325 |
c.weighty = 0;
|
326 |
c.fill = GridBagConstraints.NONE;
|
326 |
c.fill = GridBagConstraints.NONE;
|
327 |
this.add(comboContact, c);
|
327 |
this.add(comboContact, c);
|
328 |
final SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
|
328 |
final SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
|
329 |
comboContact.init(contactElement, contactElement.getComboRequest(true));
|
329 |
comboContact.init(contactElement, contactElement.getComboRequest(true));
|
330 |
comboContact.getRequest().setWhere(Where.FALSE);
|
330 |
comboContact.getRequest().setWhere(Where.FALSE);
|
331 |
DefaultGridBagConstraints.lockMinimumSize(comboContact);
|
331 |
DefaultGridBagConstraints.lockMinimumSize(comboContact);
|
332 |
this.addView(comboContact, "ID_CONTACT");
|
332 |
this.addView(comboContact, "ID_CONTACT");
|
333 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
333 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
334 |
|
334 |
|
335 |
@Override
|
335 |
@Override
|
336 |
public void propertyChange(PropertyChangeEvent evt) {
|
336 |
public void propertyChange(PropertyChangeEvent evt) {
|
337 |
int wantedID = comboClient.getWantedID();
|
337 |
int wantedID = comboClient.getWantedID();
|
338 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
338 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
339 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
339 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
340 |
|
340 |
|
341 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
341 |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID);
|
342 |
|
342 |
|
343 |
if (rowClient.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowClient.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
|
343 |
if (rowClient.getObject("ID_CATEGORIE_COMPTABLE") != null && !rowClient.isForeignEmpty("ID_CATEGORIE_COMPTABLE")) {
|
344 |
table.setRowCatComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
|
344 |
table.setRowCatComptable(rowClient.getForeign("ID_CATEGORIE_COMPTABLE"));
|
345 |
} else {
|
345 |
} else {
|
346 |
table.setRowCatComptable(null);
|
346 |
table.setRowCatComptable(null);
|
347 |
}
|
347 |
}
|
348 |
|
348 |
|
349 |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) {
|
349 |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) {
|
350 |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL"));
|
350 |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL"));
|
351 |
}
|
351 |
}
|
352 |
int idClient = rowClient.getID();
|
352 |
int idClient = rowClient.getID();
|
353 |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient));
|
353 |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient));
|
354 |
} else {
|
354 |
} else {
|
355 |
table.setRowCatComptable(null);
|
355 |
table.setRowCatComptable(null);
|
356 |
comboContact.getRequest().setWhere(Where.FALSE);
|
356 |
comboContact.getRequest().setWhere(Where.FALSE);
|
357 |
// DevisSQLComponent.this.table.setTarif(null, false);
|
357 |
// DevisSQLComponent.this.table.setTarif(null, false);
|
358 |
}
|
358 |
}
|
359 |
}
|
359 |
}
|
360 |
});
|
360 |
});
|
361 |
|
361 |
|
362 |
if (getTable().contains("DATE_LIVRAISON_PREV")) {
|
362 |
if (getTable().contains("DATE_LIVRAISON_PREV")) {
|
363 |
// Date
|
363 |
// Date
|
364 |
JLabel labelDatePrev = new JLabel(getLabelFor("DATE_LIVRAISON_PREV"));
|
364 |
JLabel labelDatePrev = new JLabel(getLabelFor("DATE_LIVRAISON_PREV"));
|
365 |
labelDatePrev.setHorizontalAlignment(SwingConstants.RIGHT);
|
365 |
labelDatePrev.setHorizontalAlignment(SwingConstants.RIGHT);
|
366 |
c.gridx = 2;
|
366 |
c.gridx = 2;
|
367 |
c.fill = GridBagConstraints.HORIZONTAL;
|
367 |
c.fill = GridBagConstraints.HORIZONTAL;
|
368 |
c.weightx = 0;
|
368 |
c.weightx = 0;
|
369 |
this.add(labelDatePrev, c);
|
369 |
this.add(labelDatePrev, c);
|
370 |
|
370 |
|
371 |
c.gridx++;
|
371 |
c.gridx++;
|
372 |
c.fill = GridBagConstraints.NONE;
|
372 |
c.fill = GridBagConstraints.NONE;
|
373 |
JDate datePrev = new JDate();
|
373 |
JDate datePrev = new JDate();
|
374 |
this.add(datePrev, c);
|
374 |
this.add(datePrev, c);
|
375 |
this.addView(datePrev, "DATE_LIVRAISON_PREV");
|
375 |
this.addView(datePrev, "DATE_LIVRAISON_PREV");
|
376 |
}
|
376 |
}
|
377 |
|
377 |
|
378 |
}
|
378 |
}
|
379 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
379 |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot());
|
380 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) {
|
380 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) {
|
381 |
|
381 |
|
382 |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
|
382 |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE");
|
383 |
final AddressChoiceUI addressUI = new AddressChoiceUI();
|
383 |
final AddressChoiceUI addressUI = new AddressChoiceUI();
|
384 |
addressUI.addToUI(this, c);
|
384 |
addressUI.addToUI(this, c);
|
385 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
385 |
comboClient.addModelListener("wantedID", new PropertyChangeListener() {
|
386 |
|
386 |
|
387 |
@Override
|
387 |
@Override
|
388 |
public void propertyChange(PropertyChangeEvent evt) {
|
388 |
public void propertyChange(PropertyChangeEvent evt) {
|
389 |
int wantedID = comboClient.getWantedID();
|
389 |
int wantedID = comboClient.getWantedID();
|
390 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
390 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID);
|
391 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
391 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
392 |
|
392 |
|
393 |
addressUI.getComboAdrF().getRequest().setWhere(
|
393 |
addressUI.getComboAdrF().getRequest().setWhere(
|
394 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId())));
|
394 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId())));
|
395 |
addressUI.getComboAdrL().getRequest().setWhere(
|
395 |
addressUI.getComboAdrL().getRequest().setWhere(
|
396 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId())));
|
396 |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId())));
|
397 |
} else {
|
397 |
} else {
|
398 |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE);
|
398 |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE);
|
399 |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
|
399 |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE);
|
400 |
}
|
400 |
}
|
401 |
}
|
401 |
}
|
402 |
});
|
402 |
});
|
403 |
}
|
403 |
}
|
404 |
|
404 |
|
405 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
|
405 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CATEGORIE_COMPTABLE_SPEC, false)) {
|
406 |
// cat spe
|
406 |
// cat spe
|
407 |
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
|
407 |
final CategorieComptableChoiceUI catUI = new CategorieComptableChoiceUI();
|
408 |
catUI.addToUI(this, c);
|
408 |
catUI.addToUI(this, c);
|
409 |
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
|
409 |
catUI.getCombo().addModelListener("wantedID", new PropertyChangeListener() {
|
410 |
|
410 |
|
411 |
@Override
|
411 |
@Override
|
412 |
public void propertyChange(PropertyChangeEvent evt) {
|
412 |
public void propertyChange(PropertyChangeEvent evt) {
|
413 |
int wantedID = catUI.getCombo().getWantedID();
|
413 |
int wantedID = catUI.getCombo().getWantedID();
|
414 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
414 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) {
|
415 |
table.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
|
415 |
table.setRowCatComptable(catUI.getCombo().getElement().getTable().getRow(wantedID));
|
416 |
} else {
|
416 |
} else {
|
417 |
table.setRowCatComptable(null);
|
417 |
table.setRowCatComptable(null);
|
418 |
}
|
418 |
}
|
419 |
}
|
419 |
}
|
420 |
});
|
420 |
});
|
421 |
}
|
421 |
}
|
422 |
|
422 |
|
423 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) {
|
423 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) {
|
424 |
// Emballage
|
424 |
// Emballage
|
425 |
c.gridy++;
|
425 |
c.gridy++;
|
426 |
c.gridx = 0;
|
426 |
c.gridx = 0;
|
427 |
c.weightx = 0;
|
427 |
c.weightx = 0;
|
428 |
c.fill = GridBagConstraints.HORIZONTAL;
|
428 |
c.fill = GridBagConstraints.HORIZONTAL;
|
429 |
this.add(new JLabel(getLabelFor("EMBALLAGE"), SwingConstants.RIGHT), c);
|
429 |
this.add(new JLabel(getLabelFor("EMBALLAGE"), SwingConstants.RIGHT), c);
|
430 |
|
430 |
|
431 |
c.fill = GridBagConstraints.HORIZONTAL;
|
431 |
c.fill = GridBagConstraints.HORIZONTAL;
|
432 |
c.gridx++;
|
432 |
c.gridx++;
|
433 |
c.weightx = 1;
|
433 |
c.weightx = 1;
|
434 |
SQLTextCombo fieldEmballage = new SQLTextCombo();
|
434 |
SQLTextCombo fieldEmballage = new SQLTextCombo();
|
435 |
this.add(fieldEmballage, c);
|
435 |
this.add(fieldEmballage, c);
|
436 |
this.addView(fieldEmballage, "EMBALLAGE");
|
436 |
this.addView(fieldEmballage, "EMBALLAGE");
|
437 |
|
437 |
|
438 |
// N° Exp
|
438 |
// N° Exp
|
439 |
JLabel labelNumExp = new JLabel(getLabelFor("NUMERO_EXPEDITION"));
|
439 |
JLabel labelNumExp = new JLabel(getLabelFor("NUMERO_EXPEDITION"));
|
440 |
labelNumExp.setHorizontalAlignment(SwingConstants.RIGHT);
|
440 |
labelNumExp.setHorizontalAlignment(SwingConstants.RIGHT);
|
441 |
c.gridx = 2;
|
441 |
c.gridx = 2;
|
442 |
c.fill = GridBagConstraints.HORIZONTAL;
|
442 |
c.fill = GridBagConstraints.HORIZONTAL;
|
443 |
c.weightx = 0;
|
443 |
c.weightx = 0;
|
444 |
this.add(labelNumExp, c);
|
444 |
this.add(labelNumExp, c);
|
445 |
|
445 |
|
446 |
JTextField fieldNumExp = new JTextField();
|
446 |
JTextField fieldNumExp = new JTextField();
|
447 |
c.gridx++;
|
447 |
c.gridx++;
|
448 |
c.weightx = 1;
|
448 |
c.weightx = 1;
|
449 |
this.add(fieldNumExp, c);
|
449 |
this.add(fieldNumExp, c);
|
450 |
this.addView(fieldNumExp, "NUMERO_EXPEDITION");
|
450 |
this.addView(fieldNumExp, "NUMERO_EXPEDITION");
|
451 |
|
451 |
|
452 |
// expedition
|
452 |
// expedition
|
453 |
|
453 |
|
454 |
c.gridy++;
|
454 |
c.gridy++;
|
455 |
c.gridx = 0;
|
455 |
c.gridx = 0;
|
456 |
c.weightx = 0;
|
456 |
c.weightx = 0;
|
457 |
c.weighty = 0;
|
457 |
c.weighty = 0;
|
458 |
c.gridwidth = 1;
|
458 |
c.gridwidth = 1;
|
459 |
c.fill = GridBagConstraints.HORIZONTAL;
|
459 |
c.fill = GridBagConstraints.HORIZONTAL;
|
460 |
this.add(new JLabel(getLabelFor("TYPE_EXPEDITION"), SwingConstants.RIGHT), c);
|
460 |
this.add(new JLabel(getLabelFor("TYPE_EXPEDITION"), SwingConstants.RIGHT), c);
|
461 |
c.gridx++;
|
461 |
c.gridx++;
|
462 |
c.gridwidth = 1;
|
462 |
c.gridwidth = 1;
|
463 |
c.weightx = 1;
|
463 |
c.weightx = 1;
|
464 |
c.fill = GridBagConstraints.NONE;
|
464 |
c.fill = GridBagConstraints.NONE;
|
465 |
SQLTextCombo tTypeExpedition = new SQLTextCombo();
|
465 |
SQLTextCombo tTypeExpedition = new SQLTextCombo();
|
466 |
this.add(tTypeExpedition, c);
|
466 |
this.add(tTypeExpedition, c);
|
467 |
this.addView(tTypeExpedition, "TYPE_EXPEDITION");
|
467 |
this.addView(tTypeExpedition, "TYPE_EXPEDITION");
|
468 |
|
468 |
|
469 |
// Etat
|
469 |
// Etat
|
470 |
final JLabel labelEtat = new JLabel(getLabelFor("ETAT_COMMANDE"), SwingConstants.RIGHT);
|
470 |
final JLabel labelEtat = new JLabel(getLabelFor("ETAT_COMMANDE"), SwingConstants.RIGHT);
|
471 |
c.gridx++;
|
471 |
c.gridx++;
|
472 |
c.weightx = 0;
|
472 |
c.weightx = 0;
|
473 |
c.fill = GridBagConstraints.HORIZONTAL;
|
473 |
c.fill = GridBagConstraints.HORIZONTAL;
|
474 |
this.add(labelEtat, c);
|
474 |
this.add(labelEtat, c);
|
475 |
final EtatCommandeClientComboBox comboEtat = new EtatCommandeClientComboBox();
|
475 |
final EtatCommandeClientComboBox comboEtat = new EtatCommandeClientComboBox();
|
476 |
c.gridx++;
|
476 |
c.gridx++;
|
477 |
c.fill = GridBagConstraints.NONE;
|
477 |
c.fill = GridBagConstraints.NONE;
|
478 |
c.weightx = 1;
|
478 |
c.weightx = 1;
|
479 |
this.add(comboEtat, c);
|
479 |
this.add(comboEtat, c);
|
480 |
addView(new EtatCommandeRowItemView(comboEtat), "ETAT_COMMANDE", REQ);
|
480 |
addView(new EtatCommandeRowItemView(comboEtat), "ETAT_COMMANDE", REQ);
|
481 |
}
|
481 |
}
|
482 |
// tarif
|
482 |
// tarif
|
483 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
483 |
if (this.getTable().getFieldsName().contains("ID_TARIF")) {
|
484 |
// TARIF
|
484 |
// TARIF
|
485 |
c.fill = GridBagConstraints.HORIZONTAL;
|
485 |
c.fill = GridBagConstraints.HORIZONTAL;
|
486 |
c.gridy++;
|
486 |
c.gridy++;
|
487 |
c.gridx = 0;
|
487 |
c.gridx = 0;
|
488 |
c.weightx = 0;
|
488 |
c.weightx = 0;
|
489 |
c.weighty = 0;
|
489 |
c.weighty = 0;
|
490 |
c.gridwidth = 1;
|
490 |
c.gridwidth = 1;
|
491 |
this.add(new JLabel(getLabelFor("ID_TARIF"), SwingConstants.RIGHT), c);
|
491 |
this.add(new JLabel(getLabelFor("ID_TARIF"), SwingConstants.RIGHT), c);
|
492 |
c.gridx++;
|
492 |
c.gridx++;
|
493 |
c.gridwidth = 1;
|
493 |
c.gridwidth = 1;
|
494 |
|
494 |
|
495 |
c.weightx = 1;
|
495 |
c.weightx = 1;
|
496 |
this.add(boxTarif, c);
|
496 |
this.add(boxTarif, c);
|
497 |
this.addView(boxTarif, "ID_TARIF");
|
497 |
this.addView(boxTarif, "ID_TARIF");
|
498 |
boxTarif.addModelListener("wantedID", new PropertyChangeListener() {
|
498 |
boxTarif.addModelListener("wantedID", new PropertyChangeListener() {
|
499 |
|
499 |
|
500 |
@Override
|
500 |
@Override
|
501 |
public void propertyChange(PropertyChangeEvent evt) {
|
501 |
public void propertyChange(PropertyChangeEvent evt) {
|
502 |
SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
|
502 |
SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
|
503 |
table.setTarif(selectedRow, false);
|
503 |
table.setTarif(selectedRow, false);
|
504 |
}
|
504 |
}
|
505 |
});
|
505 |
});
|
506 |
if (getTable().contains("DATE_LIVRAISON_REELLE")) {
|
506 |
if (getTable().contains("DATE_LIVRAISON_REELLE")) {
|
507 |
// Date
|
507 |
// Date
|
508 |
JLabel labelDatePrev = new JLabel(getLabelFor("DATE_LIVRAISON_REELLE"));
|
508 |
JLabel labelDatePrev = new JLabel(getLabelFor("DATE_LIVRAISON_REELLE"));
|
509 |
labelDatePrev.setHorizontalAlignment(SwingConstants.RIGHT);
|
509 |
labelDatePrev.setHorizontalAlignment(SwingConstants.RIGHT);
|
510 |
c.gridx++;
|
510 |
c.gridx++;
|
511 |
c.fill = GridBagConstraints.HORIZONTAL;
|
511 |
c.fill = GridBagConstraints.HORIZONTAL;
|
512 |
c.weightx = 0;
|
512 |
c.weightx = 0;
|
513 |
this.add(labelDatePrev, c);
|
513 |
this.add(labelDatePrev, c);
|
514 |
|
514 |
|
515 |
c.gridx++;
|
515 |
c.gridx++;
|
516 |
c.fill = GridBagConstraints.NONE;
|
516 |
c.fill = GridBagConstraints.NONE;
|
517 |
JDate datePrev = new JDate();
|
517 |
JDate datePrev = new JDate();
|
518 |
this.add(datePrev, c);
|
518 |
this.add(datePrev, c);
|
519 |
this.addView(datePrev, "DATE_LIVRAISON_REELLE");
|
519 |
this.addView(datePrev, "DATE_LIVRAISON_REELLE");
|
520 |
}
|
520 |
}
|
521 |
}
|
521 |
}
|
522 |
if (this.getTable().getFieldsName().contains("ACOMPTE_COMMANDE")) {
|
522 |
if (this.getTable().getFieldsName().contains("ACOMPTE_COMMANDE")) {
|
523 |
// ACOMPTE
|
523 |
// ACOMPTE
|
524 |
c.gridy += (this.getTable().getFieldsName().contains("ID_TARIF") ? 0 : 1);
|
524 |
c.gridy += (this.getTable().getFieldsName().contains("ID_TARIF") ? 0 : 1);
|
525 |
c.gridx += (this.getTable().getFieldsName().contains("ID_TARIF") ? 1 : 2);
|
525 |
c.gridx += (this.getTable().getFieldsName().contains("ID_TARIF") ? 1 : 2);
|
526 |
c.weightx = 0;
|
526 |
c.weightx = 0;
|
527 |
c.weighty = 0;
|
527 |
c.weighty = 0;
|
528 |
c.gridwidth = 1;
|
528 |
c.gridwidth = 1;
|
529 |
c.fill = GridBagConstraints.HORIZONTAL;
|
529 |
c.fill = GridBagConstraints.HORIZONTAL;
|
530 |
this.add(new JLabel(getLabelFor("ACOMPTE_COMMANDE"), SwingConstants.RIGHT), c);
|
530 |
this.add(new JLabel(getLabelFor("ACOMPTE_COMMANDE"), SwingConstants.RIGHT), c);
|
531 |
c.gridx++;
|
531 |
c.gridx++;
|
532 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
532 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
533 |
c.fill = GridBagConstraints.NONE;
|
533 |
c.fill = GridBagConstraints.NONE;
|
534 |
c.weightx = 1;
|
534 |
c.weightx = 1;
|
535 |
JTextField acompteCmd = new JTextField(15);
|
535 |
JTextField acompteCmd = new JTextField(15);
|
536 |
DefaultGridBagConstraints.lockMinimumSize(acompteCmd);
|
536 |
DefaultGridBagConstraints.lockMinimumSize(acompteCmd);
|
537 |
this.add(acompteCmd, c);
|
537 |
this.add(acompteCmd, c);
|
538 |
this.addView(acompteCmd, "ACOMPTE_COMMANDE");
|
538 |
this.addView(acompteCmd, "ACOMPTE_COMMANDE");
|
539 |
}
|
539 |
}
|
540 |
|
540 |
|
541 |
// Table d'élément
|
541 |
// Table d'élément
|
542 |
this.table = new CommandeClientItemTable();
|
542 |
this.table = new CommandeClientItemTable();
|
543 |
JTabbedPane pane = new JTabbedPane();
|
543 |
JTabbedPane pane = new JTabbedPane();
|
544 |
c.fill = GridBagConstraints.BOTH;
|
544 |
c.fill = GridBagConstraints.BOTH;
|
545 |
c.gridy++;
|
545 |
c.gridy++;
|
546 |
c.gridx = 0;
|
546 |
c.gridx = 0;
|
547 |
c.weightx = 1;
|
547 |
c.weightx = 1;
|
548 |
c.weighty = 1;
|
548 |
c.weighty = 1;
|
549 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
549 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
550 |
pane.add("Eléments", this.table);
|
550 |
pane.add("Eléments", this.table);
|
551 |
this.tableFacturationItem = new FacturationCommandeTable(this);
|
551 |
this.tableFacturationItem = new FacturationCommandeTable(this);
|
552 |
pane.add("Facturation", this.tableFacturationItem);
|
552 |
pane.add("Facturation", this.tableFacturationItem);
|
553 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CHIFFRAGE_COMMANDE_CLIENT, false)) {
|
553 |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.CHIFFRAGE_COMMANDE_CLIENT, false)) {
|
554 |
this.tableChiffrageItem = new ChiffrageCommandeTable(this);
|
554 |
this.tableChiffrageItem = new ChiffrageCommandeTable(this);
|
555 |
pane.add("Chiffrage", this.tableChiffrageItem);
|
555 |
pane.add("Chiffrage", this.tableChiffrageItem);
|
556 |
}
|
556 |
}
|
557 |
this.add(pane, c);
|
557 |
this.add(pane, c);
|
558 |
|
558 |
|
559 |
DeviseField textPortHT = new DeviseField(5);
|
559 |
DeviseField textPortHT = new DeviseField(5);
|
560 |
DeviseField textRemiseHT = new DeviseField();
|
560 |
DeviseField textRemiseHT = new DeviseField();
|
561 |
|
561 |
|
562 |
// Total
|
562 |
// Total
|
563 |
DeviseField fieldHT = new DeviseField();
|
563 |
DeviseField fieldHT = new DeviseField();
|
564 |
DeviseField fieldTVA = new DeviseField();
|
564 |
DeviseField fieldTVA = new DeviseField();
|
565 |
DeviseField fieldTTC = new DeviseField();
|
565 |
DeviseField fieldTTC = new DeviseField();
|
566 |
DeviseField fieldDevise = new DeviseField();
|
566 |
DeviseField fieldDevise = new DeviseField();
|
567 |
DeviseField fieldService = new DeviseField();
|
567 |
DeviseField fieldService = new DeviseField();
|
568 |
DeviseField fieldHA = new DeviseField();
|
568 |
DeviseField fieldHA = new DeviseField();
|
569 |
DeviseField fieldEco = new DeviseField();
|
569 |
DeviseField fieldEco = new DeviseField();
|
570 |
fieldHT.setOpaque(false);
|
570 |
fieldHT.setOpaque(false);
|
571 |
fieldHA.setOpaque(false);
|
571 |
fieldHA.setOpaque(false);
|
572 |
fieldTVA.setOpaque(false);
|
572 |
fieldTVA.setOpaque(false);
|
573 |
fieldTTC.setOpaque(false);
|
573 |
fieldTTC.setOpaque(false);
|
574 |
fieldService.setOpaque(false);
|
574 |
fieldService.setOpaque(false);
|
575 |
addSQLObject(fieldDevise, "T_DEVISE");
|
575 |
addSQLObject(fieldDevise, "T_DEVISE");
|
576 |
addSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
|
576 |
addSQLObject(fieldEco, "T_ECO_CONTRIBUTION");
|
577 |
addRequiredSQLObject(fieldHT, "T_HT");
|
577 |
addRequiredSQLObject(fieldHT, "T_HT");
|
578 |
addRequiredSQLObject(fieldTVA, "T_TVA");
|
578 |
addRequiredSQLObject(fieldTVA, "T_TVA");
|
579 |
addRequiredSQLObject(fieldTTC, "T_TTC");
|
579 |
addRequiredSQLObject(fieldTTC, "T_TTC");
|
580 |
addRequiredSQLObject(fieldService, "T_SERVICE");
|
580 |
addRequiredSQLObject(fieldService, "T_SERVICE");
|
581 |
if (getTable().contains("PREBILAN")) {
|
581 |
if (getTable().contains("PREBILAN")) {
|
582 |
addSQLObject(fieldHA, "PREBILAN");
|
582 |
addSQLObject(fieldHA, "PREBILAN");
|
583 |
} else if (getTable().contains("T_HA")) {
|
583 |
} else if (getTable().contains("T_HA")) {
|
584 |
this.allowEditable("T_HA", false);
|
584 |
this.allowEditable("T_HA", false);
|
585 |
addSQLObject(fieldHA, "T_HA");
|
585 |
addSQLObject(fieldHA, "T_HA");
|
586 |
}
|
586 |
}
|
587 |
// Disable
|
587 |
// Disable
|
588 |
this.allowEditable("T_ECO_CONTRIBUTION", false);
|
588 |
this.allowEditable("T_ECO_CONTRIBUTION", false);
|
589 |
this.allowEditable("T_HT", false);
|
589 |
this.allowEditable("T_HT", false);
|
590 |
this.allowEditable("T_TVA", false);
|
590 |
this.allowEditable("T_TVA", false);
|
591 |
this.allowEditable("T_TTC", false);
|
591 |
this.allowEditable("T_TTC", false);
|
592 |
this.allowEditable("T_SERVICE", false);
|
592 |
this.allowEditable("T_SERVICE", false);
|
593 |
|
593 |
|
594 |
JTextField poids = new JTextField();
|
594 |
JTextField poids = new JTextField();
|
595 |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8);
|
595 |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8);
|
596 |
|
596 |
|
597 |
// addSQLObject(poids, "T_POIDS");
|
597 |
// addSQLObject(poids, "T_POIDS");
|
598 |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null,
|
598 |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldEco, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null,
|
599 |
(getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
599 |
(getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null), null);
|
600 |
|
600 |
|
601 |
// INfos
|
601 |
// INfos
|
602 |
c.gridx = 0;
|
602 |
c.gridx = 0;
|
603 |
c.gridy++;
|
603 |
c.gridy++;
|
604 |
c.gridheight = 1;
|
604 |
c.gridheight = 1;
|
605 |
c.weighty = 0;
|
605 |
c.weighty = 0;
|
606 |
c.weightx = 1;
|
606 |
c.weightx = 1;
|
607 |
c.anchor = GridBagConstraints.WEST;
|
607 |
c.anchor = GridBagConstraints.WEST;
|
608 |
c.gridwidth = 2;
|
608 |
c.gridwidth = 2;
|
609 |
this.add(new TitledSeparator(getLabelFor("INFOS")), c);
|
609 |
this.add(new TitledSeparator(getLabelFor("INFOS")), c);
|
610 |
|
610 |
|
611 |
c.gridy++;
|
611 |
c.gridy++;
|
612 |
c.weightx = 1;
|
612 |
c.weightx = 1;
|
613 |
c.weighty = 0;
|
613 |
c.weighty = 0;
|
614 |
c.fill = GridBagConstraints.BOTH;
|
614 |
c.fill = GridBagConstraints.BOTH;
|
615 |
final JScrollPane scrollPane = new JScrollPane(this.infos);
|
615 |
final JScrollPane scrollPane = new JScrollPane(this.infos);
|
616 |
scrollPane.setBorder(null);
|
616 |
scrollPane.setBorder(null);
|
617 |
this.add(scrollPane, c);
|
617 |
this.add(scrollPane, c);
|
618 |
|
618 |
|
619 |
// Poids
|
619 |
// Poids
|
620 |
|
620 |
|
621 |
final JTextField textPoidsTotal = new JTextField(8);
|
621 |
final JTextField textPoidsTotal = new JTextField(8);
|
622 |
JPanel panel = new JPanel(new GridBagLayout());
|
622 |
JPanel panel = new JPanel(new GridBagLayout());
|
623 |
GridBagConstraints cFrais = new DefaultGridBagConstraints();
|
623 |
GridBagConstraints cFrais = new DefaultGridBagConstraints();
|
624 |
c.fill = GridBagConstraints.HORIZONTAL;
|
624 |
c.fill = GridBagConstraints.HORIZONTAL;
|
625 |
panel.add(new JLabel(getLabelFor("T_POIDS"), JTextField.RIGHT), cFrais);
|
625 |
panel.add(new JLabel(getLabelFor("T_POIDS"), JTextField.RIGHT), cFrais);
|
626 |
textPoidsTotal.setEnabled(false);
|
626 |
textPoidsTotal.setEnabled(false);
|
627 |
textPoidsTotal.setDisabledTextColor(Color.BLACK);
|
627 |
textPoidsTotal.setDisabledTextColor(Color.BLACK);
|
628 |
cFrais.gridx++;
|
628 |
cFrais.gridx++;
|
629 |
panel.add(textPoidsTotal, cFrais);
|
629 |
panel.add(textPoidsTotal, cFrais);
|
630 |
|
630 |
|
631 |
panel.setOpaque(false);
|
631 |
panel.setOpaque(false);
|
632 |
|
632 |
|
633 |
DefaultGridBagConstraints.lockMinimumSize(textPortHT);
|
633 |
DefaultGridBagConstraints.lockMinimumSize(textPortHT);
|
634 |
addSQLObject(textPortHT, "PORT_HT");
|
634 |
addSQLObject(textPortHT, "PORT_HT");
|
635 |
DefaultGridBagConstraints.lockMinimumSize(textRemiseHT);
|
635 |
DefaultGridBagConstraints.lockMinimumSize(textRemiseHT);
|
636 |
addSQLObject(textRemiseHT, "REMISE_HT");
|
636 |
addSQLObject(textRemiseHT, "REMISE_HT");
|
637 |
|
637 |
|
638 |
// Frais de port
|
638 |
// Frais de port
|
639 |
|
639 |
|
640 |
if (getTable().contains("ID_TAXE_PORT")) {
|
640 |
if (getTable().contains("ID_TAXE_PORT")) {
|
641 |
|
641 |
|
642 |
JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
|
642 |
JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
|
643 |
labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
643 |
labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
644 |
cFrais.gridx = 0;
|
644 |
cFrais.gridx = 0;
|
645 |
cFrais.gridy++;
|
645 |
cFrais.gridy++;
|
646 |
panel.add(labelPortHT, cFrais);
|
646 |
panel.add(labelPortHT, cFrais);
|
647 |
cFrais.gridx++;
|
647 |
cFrais.gridx++;
|
648 |
panel.add(textPortHT, cFrais);
|
648 |
panel.add(textPortHT, cFrais);
|
649 |
|
649 |
|
650 |
JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT"));
|
650 |
JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT"));
|
651 |
labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
651 |
labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
652 |
cFrais.gridx = 0;
|
652 |
cFrais.gridx = 0;
|
653 |
cFrais.gridy++;
|
653 |
cFrais.gridy++;
|
654 |
panel.add(labelTaxeHT, cFrais);
|
654 |
panel.add(labelTaxeHT, cFrais);
|
655 |
cFrais.gridx++;
|
655 |
cFrais.gridx++;
|
656 |
panel.add(boxTaxePort, cFrais);
|
656 |
panel.add(boxTaxePort, cFrais);
|
657 |
this.addView(boxTaxePort, "ID_TAXE_PORT", REQ);
|
657 |
this.addView(boxTaxePort, "ID_TAXE_PORT", REQ);
|
658 |
|
658 |
|
659 |
boxTaxePort.addValueListener(new PropertyChangeListener() {
|
659 |
boxTaxePort.addValueListener(new PropertyChangeListener() {
|
660 |
|
660 |
|
661 |
@Override
|
661 |
@Override
|
662 |
public void propertyChange(PropertyChangeEvent evt) {
|
662 |
public void propertyChange(PropertyChangeEvent evt) {
|
663 |
totalTTC.updateTotal();
|
663 |
totalTTC.updateTotal();
|
664 |
}
|
664 |
}
|
665 |
});
|
665 |
});
|
666 |
}
|
666 |
}
|
667 |
|
667 |
|
668 |
// Remise
|
668 |
// Remise
|
669 |
JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
|
669 |
JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
|
670 |
labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
670 |
labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
|
671 |
cFrais.gridy++;
|
671 |
cFrais.gridy++;
|
672 |
cFrais.gridx = 0;
|
672 |
cFrais.gridx = 0;
|
673 |
panel.add(labelRemiseHT, cFrais);
|
673 |
panel.add(labelRemiseHT, cFrais);
|
674 |
cFrais.gridx++;
|
674 |
cFrais.gridx++;
|
675 |
panel.add(textRemiseHT, cFrais);
|
675 |
panel.add(textRemiseHT, cFrais);
|
676 |
|
676 |
|
677 |
c.gridx = 2;
|
677 |
c.gridx = 2;
|
678 |
c.weightx = 0;
|
678 |
c.weightx = 0;
|
679 |
c.weighty = 0;
|
679 |
c.weighty = 0;
|
680 |
c.gridwidth = 1;
|
680 |
c.gridwidth = 1;
|
681 |
c.fill = GridBagConstraints.NONE;
|
681 |
c.fill = GridBagConstraints.NONE;
|
682 |
c.anchor = GridBagConstraints.NORTHEAST;
|
682 |
c.anchor = GridBagConstraints.NORTHEAST;
|
683 |
DefaultGridBagConstraints.lockMinimumSize(panel);
|
683 |
DefaultGridBagConstraints.lockMinimumSize(panel);
|
684 |
this.add(panel, c);
|
684 |
this.add(panel, c);
|
685 |
|
685 |
|
686 |
c.gridx = GridBagConstraints.RELATIVE;
|
686 |
c.gridx = GridBagConstraints.RELATIVE;
|
687 |
c.gridy--;
|
687 |
c.gridy--;
|
688 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
688 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
689 |
c.gridheight = 2;
|
689 |
c.gridheight = 2;
|
690 |
c.anchor = GridBagConstraints.NORTHEAST;
|
690 |
c.anchor = GridBagConstraints.NORTHEAST;
|
691 |
c.fill = GridBagConstraints.NONE;
|
691 |
c.fill = GridBagConstraints.NONE;
|
692 |
c.weighty = 0;
|
692 |
c.weighty = 0;
|
693 |
|
693 |
|
694 |
this.add(totalTTC, c);
|
694 |
this.add(totalTTC, c);
|
695 |
|
695 |
|
696 |
this.panelOO = new PanelOOSQLComponent(this);
|
696 |
this.panelOO = new PanelOOSQLComponent(this);
|
697 |
c.gridwidth = 1;
|
697 |
c.gridwidth = 1;
|
698 |
c.fill = GridBagConstraints.NONE;
|
698 |
c.fill = GridBagConstraints.NONE;
|
699 |
c.anchor = GridBagConstraints.EAST;
|
699 |
c.anchor = GridBagConstraints.EAST;
|
700 |
c.gridx = 0;
|
700 |
c.gridx = 0;
|
701 |
c.gridy += 3;
|
701 |
c.gridy += 3;
|
702 |
c.weightx = 0;
|
702 |
c.weightx = 0;
|
703 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
703 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
704 |
this.add(this.panelOO, c);
|
704 |
this.add(this.panelOO, c);
|
705 |
|
705 |
|
706 |
textPortHT.getDocument().addDocumentListener(new DocumentListener() {
|
706 |
textPortHT.getDocument().addDocumentListener(new DocumentListener() {
|
707 |
public void changedUpdate(DocumentEvent e) {
|
707 |
public void changedUpdate(DocumentEvent e) {
|
708 |
totalTTC.updateTotal();
|
708 |
totalTTC.updateTotal();
|
709 |
}
|
709 |
}
|
710 |
|
710 |
|
711 |
public void removeUpdate(DocumentEvent e) {
|
711 |
public void removeUpdate(DocumentEvent e) {
|
712 |
totalTTC.updateTotal();
|
712 |
totalTTC.updateTotal();
|
713 |
}
|
713 |
}
|
714 |
|
714 |
|
715 |
public void insertUpdate(DocumentEvent e) {
|
715 |
public void insertUpdate(DocumentEvent e) {
|
716 |
totalTTC.updateTotal();
|
716 |
totalTTC.updateTotal();
|
717 |
}
|
717 |
}
|
718 |
});
|
718 |
});
|
719 |
|
719 |
|
720 |
textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
|
720 |
textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
|
721 |
public void changedUpdate(DocumentEvent e) {
|
721 |
public void changedUpdate(DocumentEvent e) {
|
722 |
totalTTC.updateTotal();
|
722 |
totalTTC.updateTotal();
|
723 |
}
|
723 |
}
|
724 |
|
724 |
|
725 |
public void removeUpdate(DocumentEvent e) {
|
725 |
public void removeUpdate(DocumentEvent e) {
|
726 |
totalTTC.updateTotal();
|
726 |
totalTTC.updateTotal();
|
727 |
}
|
727 |
}
|
728 |
|
728 |
|
729 |
public void insertUpdate(DocumentEvent e) {
|
729 |
public void insertUpdate(DocumentEvent e) {
|
730 |
totalTTC.updateTotal();
|
730 |
totalTTC.updateTotal();
|
731 |
}
|
731 |
}
|
732 |
});
|
732 |
});
|
733 |
|
733 |
|
734 |
addSQLObject(this.textObjet, "NOM");
|
734 |
addSQLObject(this.textObjet, "NOM");
|
735 |
addSQLObject(textPoidsTotal, "T_POIDS");
|
735 |
addSQLObject(textPoidsTotal, "T_POIDS");
|
736 |
addRequiredSQLObject(dateCommande, "DATE");
|
736 |
addRequiredSQLObject(dateCommande, "DATE");
|
737 |
// addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
|
737 |
// addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
|
738 |
addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
|
738 |
addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
|
739 |
addSQLObject(this.infos, "INFOS");
|
739 |
addSQLObject(this.infos, "INFOS");
|
740 |
addSQLObject(this.comboDevis, "ID_DEVIS");
|
740 |
addSQLObject(this.comboDevis, "ID_DEVIS");
|
741 |
|
741 |
|
742 |
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
|
742 |
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
|
743 |
|
743 |
|
744 |
this.table.getModel().addTableModelListener(new TableModelListener() {
|
744 |
this.table.getModel().addTableModelListener(new TableModelListener() {
|
745 |
|
745 |
|
746 |
public void tableChanged(TableModelEvent e) {
|
746 |
public void tableChanged(TableModelEvent e) {
|
747 |
textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
|
747 |
textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
|
748 |
}
|
748 |
}
|
749 |
});
|
749 |
});
|
750 |
DefaultGridBagConstraints.lockMinimumSize(comboClient);
|
750 |
DefaultGridBagConstraints.lockMinimumSize(comboClient);
|
751 |
DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
|
751 |
DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
|
752 |
DefaultGridBagConstraints.lockMinimumSize(comboDevis);
|
752 |
DefaultGridBagConstraints.lockMinimumSize(comboDevis);
|
753 |
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
|
753 |
DefaultGridBagConstraints.lockMinimumSize(totalTTC);
|
754 |
DefaultGridBagConstraints.lockMaximumSize(totalTTC);
|
754 |
DefaultGridBagConstraints.lockMaximumSize(totalTTC);
|
755 |
DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);
|
755 |
DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);
|
756 |
|
756 |
|
757 |
}
|
757 |
}
|
758 |
|
758 |
|
759 |
public int insert(SQLRow order) {
|
759 |
public int insert(SQLRow order) {
|
760 |
final int idCommande;
|
760 |
final int idCommande;
|
761 |
|
761 |
|
762 |
int attempt = 0;
|
762 |
int attempt = 0;
|
763 |
// on verifie qu'un devis du meme numero n'a pas été inséré entre temps
|
763 |
// on verifie qu'un devis du meme numero n'a pas été inséré entre temps
|
764 |
if (!this.numeroUniqueCommande.checkValidation(false)) {
|
764 |
if (!this.numeroUniqueCommande.checkValidation(false)) {
|
765 |
while (attempt < JUniqueTextField.RETRY_COUNT) {
|
765 |
while (attempt < JUniqueTextField.RETRY_COUNT) {
|
766 |
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateCommande.getDate());
|
766 |
String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), dateCommande.getDate());
|
767 |
this.numeroUniqueCommande.setText(num);
|
767 |
this.numeroUniqueCommande.setText(num);
|
768 |
attempt++;
|
768 |
attempt++;
|
769 |
if (this.numeroUniqueCommande.checkValidation(false)) {
|
769 |
if (this.numeroUniqueCommande.checkValidation(false)) {
|
770 |
System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
|
770 |
System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
|
771 |
break;
|
771 |
break;
|
772 |
}
|
772 |
}
|
773 |
try {
|
773 |
try {
|
774 |
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
|
774 |
Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
|
775 |
} catch (InterruptedException e) {
|
775 |
} catch (InterruptedException e) {
|
776 |
e.printStackTrace();
|
776 |
e.printStackTrace();
|
777 |
}
|
777 |
}
|
778 |
}
|
778 |
}
|
779 |
}
|
779 |
}
|
780 |
final String num = this.numeroUniqueCommande.getText();
|
780 |
final String num = this.numeroUniqueCommande.getText();
|
781 |
if (attempt == JUniqueTextField.RETRY_COUNT) {
|
781 |
if (attempt == JUniqueTextField.RETRY_COUNT) {
|
782 |
idCommande = getSelectedID();
|
782 |
idCommande = getSelectedID();
|
783 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de commande existant.");
|
783 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de commande existant.");
|
784 |
final Object root = SwingUtilities.getRoot(this);
|
784 |
final Object root = SwingUtilities.getRoot(this);
|
785 |
if (root instanceof EditFrame) {
|
785 |
if (root instanceof EditFrame) {
|
786 |
final EditFrame frame = (EditFrame) root;
|
786 |
final EditFrame frame = (EditFrame) root;
|
787 |
frame.getPanel().setAlwaysVisible(true);
|
787 |
frame.getPanel().setAlwaysVisible(true);
|
788 |
}
|
788 |
}
|
789 |
} else {
|
789 |
} else {
|
790 |
idCommande = super.insert(order);
|
790 |
idCommande = super.insert(order);
|
791 |
this.table.updateField("ID_COMMANDE_CLIENT", idCommande);
|
791 |
this.table.updateField("ID_COMMANDE_CLIENT", idCommande);
|
792 |
this.tableFacturationItem.updateField("ID_COMMANDE_CLIENT", idCommande);
|
792 |
this.tableFacturationItem.updateField("ID_COMMANDE_CLIENT", idCommande);
|
793 |
if (this.tableChiffrageItem != null) {
|
793 |
if (this.tableChiffrageItem != null) {
|
794 |
this.tableChiffrageItem.updateField("ID_COMMANDE_CLIENT", idCommande);
|
794 |
this.tableChiffrageItem.updateField("ID_COMMANDE_CLIENT", idCommande);
|
795 |
}
|
795 |
}
|
796 |
try {
|
796 |
try {
|
797 |
updateStock(idCommande);
|
797 |
updateStock(idCommande);
|
798 |
} catch (SQLException e1) {
|
798 |
} catch (SQLException e1) {
|
799 |
ExceptionHandler.handle("Erreur lors de la mise à du stock!", e1);
|
799 |
ExceptionHandler.handle("Erreur lors de la mise à du stock!", e1);
|
800 |
}
|
800 |
}
|
801 |
// Création des articles
|
801 |
// Création des articles
|
802 |
this.table.createArticle(idCommande, this.getElement());
|
802 |
this.table.createArticle(idCommande, this.getElement());
|
803 |
// generation du document
|
803 |
// generation du document
|
804 |
|
804 |
|
805 |
try {
|
805 |
try {
|
806 |
CommandeClientXmlSheet sheet = new CommandeClientXmlSheet(getTable().getRow(idCommande));
|
806 |
CommandeClientXmlSheet sheet = new CommandeClientXmlSheet(getTable().getRow(idCommande));
|
807 |
sheet.createDocumentAsynchronous();
|
807 |
sheet.createDocumentAsynchronous();
|
808 |
sheet.showPrintAndExportAsynchronous(CommandeClientSQLComponent.this.panelOO.isVisualisationSelected(), CommandeClientSQLComponent.this.panelOO.isImpressionSelected(), true);
|
808 |
sheet.showPrintAndExportAsynchronous(CommandeClientSQLComponent.this.panelOO.isVisualisationSelected(), CommandeClientSQLComponent.this.panelOO.isImpressionSelected(), true);
|
809 |
} catch (Exception e) {
|
809 |
} catch (Exception e) {
|
810 |
ExceptionHandler.handle("Impossible de créer la commande", e);
|
810 |
ExceptionHandler.handle("Impossible de créer la commande", e);
|
811 |
}
|
811 |
}
|
812 |
|
812 |
|
813 |
// incrémentation du numéro auto
|
813 |
// incrémentation du numéro auto
|
814 |
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
|
814 |
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) {
|
815 |
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
|
815 |
SQLRowValues rowVals = new SQLRowValues(this.tableNum);
|
816 |
int val = this.tableNum.getRow(2).getInt("COMMANDE_CLIENT_START");
|
816 |
int val = this.tableNum.getRow(2).getInt("COMMANDE_CLIENT_START");
|
817 |
val++;
|
817 |
val++;
|
818 |
rowVals.put("COMMANDE_CLIENT_START", new Integer(val));
|
818 |
rowVals.put("COMMANDE_CLIENT_START", new Integer(val));
|
819 |
|
819 |
|
820 |
try {
|
820 |
try {
|
821 |
rowVals.update(2);
|
821 |
rowVals.update(2);
|
822 |
} catch (SQLException e) {
|
822 |
} catch (SQLException e) {
|
823 |
e.printStackTrace();
|
823 |
e.printStackTrace();
|
824 |
}
|
824 |
}
|
825 |
}
|
825 |
}
|
826 |
if (attempt > 0) {
|
826 |
if (attempt > 0) {
|
827 |
SwingUtilities.invokeLater(new Runnable() {
|
827 |
SwingUtilities.invokeLater(new Runnable() {
|
828 |
public void run() {
|
828 |
public void run() {
|
829 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
829 |
JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
|
830 |
}
|
830 |
}
|
831 |
});
|
831 |
});
|
832 |
}
|
832 |
}
|
833 |
}
|
833 |
}
|
834 |
|
834 |
|
835 |
return idCommande;
|
835 |
return idCommande;
|
836 |
}
|
836 |
}
|
837 |
|
837 |
|
838 |
@Override
|
838 |
@Override
|
839 |
public Set<String> getPartialResetNames() {
|
839 |
public Set<String> getPartialResetNames() {
|
840 |
Set<String> s = new HashSet<String>();
|
840 |
Set<String> s = new HashSet<String>();
|
841 |
s.add("NOM");
|
841 |
s.add("NOM");
|
842 |
s.add("NUMERO");
|
842 |
s.add("NUMERO");
|
843 |
s.add("INFOS");
|
843 |
s.add("INFOS");
|
844 |
s.add("ID_CLIENT");
|
844 |
s.add("ID_CLIENT");
|
845 |
if (getTable().contains("ACOMPTE_COMMANDE")) {
|
845 |
if (getTable().contains("ACOMPTE_COMMANDE")) {
|
846 |
s.add("ACOMPTE_COMMANDE");
|
846 |
s.add("ACOMPTE_COMMANDE");
|
847 |
}
|
847 |
}
|
848 |
return s;
|
848 |
return s;
|
849 |
}
|
849 |
}
|
850 |
|
850 |
|
851 |
@Override
|
851 |
@Override
|
852 |
public void select(SQLRowAccessor r) {
|
852 |
public void select(SQLRowAccessor r) {
|
853 |
if (r == null || r.getIDNumber() == null)
|
853 |
if (r == null || r.getIDNumber() == null)
|
854 |
super.select(r);
|
854 |
super.select(r);
|
855 |
else {
|
855 |
else {
|
856 |
System.err.println(r);
|
856 |
System.err.println(r);
|
857 |
final SQLRowValues rVals = r.asRowValues().deepCopy();
|
857 |
final SQLRowValues rVals = r.asRowValues().deepCopy();
|
858 |
final SQLRowValues vals = new SQLRowValues(r.getTable());
|
858 |
final SQLRowValues vals = new SQLRowValues(r.getTable());
|
859 |
vals.load(rVals, createSet("ID_CLIENT"));
|
859 |
vals.load(rVals, createSet("ID_CLIENT"));
|
860 |
vals.setID(rVals.getID());
|
860 |
vals.setID(rVals.getID());
|
861 |
System.err.println("Select CLIENT");
|
861 |
System.err.println("Select CLIENT");
|
862 |
super.select(vals);
|
862 |
super.select(vals);
|
863 |
rVals.remove("ID_CLIENT");
|
863 |
rVals.remove("ID_CLIENT");
|
864 |
super.select(rVals);
|
864 |
super.select(rVals);
|
865 |
}
|
865 |
}
|
866 |
if (r != null) {
|
866 |
if (r != null) {
|
867 |
this.table.insertFrom("ID_COMMANDE_CLIENT", r.getID());
|
867 |
this.table.getRowValuesTable().insertFrom(r);
|
868 |
this.tableFacturationItem.insertFrom("ID_COMMANDE_CLIENT", r.getID());
|
868 |
this.tableFacturationItem.getRowValuesTable().insertFrom(r);
|
869 |
if (this.tableChiffrageItem != null) {
|
869 |
if (this.tableChiffrageItem != null) {
|
870 |
this.tableChiffrageItem.insertFrom("ID_COMMANDE_CLIENT", r.getID());
|
870 |
this.tableChiffrageItem.getRowValuesTable().insertFrom(r);
|
871 |
}
|
871 |
}
|
872 |
}
|
872 |
}
|
873 |
// this.radioEtat.setVisible(r.getID() > 1);
|
873 |
// this.radioEtat.setVisible(r.getID() > 1);
|
874 |
}
|
874 |
}
|
875 |
|
875 |
|
876 |
@Override
|
876 |
@Override
|
877 |
public void update() {
|
877 |
public void update() {
|
878 |
|
878 |
|
879 |
if (!this.numeroUniqueCommande.checkValidation()) {
|
879 |
if (!this.numeroUniqueCommande.checkValidation()) {
|
880 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de commande client existant.");
|
880 |
ExceptionHandler.handle("Impossible d'ajouter, numéro de commande client existant.");
|
881 |
Object root = SwingUtilities.getRoot(this);
|
881 |
Object root = SwingUtilities.getRoot(this);
|
882 |
if (root instanceof EditFrame) {
|
882 |
if (root instanceof EditFrame) {
|
883 |
EditFrame frame = (EditFrame) root;
|
883 |
EditFrame frame = (EditFrame) root;
|
884 |
frame.getPanel().setAlwaysVisible(true);
|
884 |
frame.getPanel().setAlwaysVisible(true);
|
885 |
}
|
885 |
}
|
886 |
return;
|
886 |
return;
|
887 |
}
|
887 |
}
|
888 |
super.update();
|
888 |
super.update();
|
889 |
final int id = getSelectedID();
|
889 |
final int id = getSelectedID();
|
890 |
this.table.updateField("ID_COMMANDE_CLIENT", id);
|
890 |
this.table.updateField("ID_COMMANDE_CLIENT", id);
|
891 |
this.tableFacturationItem.updateField("ID_COMMANDE_CLIENT", id);
|
891 |
this.tableFacturationItem.updateField("ID_COMMANDE_CLIENT", id);
|
892 |
if (this.tableChiffrageItem != null) {
|
892 |
if (this.tableChiffrageItem != null) {
|
893 |
this.tableChiffrageItem.updateField("ID_COMMANDE_CLIENT", id);
|
893 |
this.tableChiffrageItem.updateField("ID_COMMANDE_CLIENT", id);
|
894 |
}
|
894 |
}
|
895 |
this.table.createArticle(id, this.getElement());
|
895 |
this.table.createArticle(id, this.getElement());
|
896 |
|
896 |
|
897 |
final SQLRow row = getTable().getRow(id);
|
897 |
final SQLRow row = getTable().getRow(id);
|
898 |
try {
|
898 |
try {
|
899 |
updateStock(id);
|
899 |
updateStock(id);
|
900 |
} catch (SQLException e1) {
|
900 |
} catch (SQLException e1) {
|
901 |
ExceptionHandler.handle("Erreur lors de la mise à du stock!", e1);
|
901 |
ExceptionHandler.handle("Erreur lors de la mise à du stock!", e1);
|
902 |
}
|
902 |
}
|
903 |
|
903 |
|
904 |
// generation du document
|
904 |
// generation du document
|
905 |
try {
|
905 |
try {
|
906 |
CommandeClientXmlSheet sheet = new CommandeClientXmlSheet(row);
|
906 |
CommandeClientXmlSheet sheet = new CommandeClientXmlSheet(row);
|
907 |
sheet.createDocumentAsynchronous();
|
907 |
sheet.createDocumentAsynchronous();
|
908 |
sheet.showPrintAndExportAsynchronous(CommandeClientSQLComponent.this.panelOO.isVisualisationSelected(), CommandeClientSQLComponent.this.panelOO.isImpressionSelected(), true);
|
908 |
sheet.showPrintAndExportAsynchronous(CommandeClientSQLComponent.this.panelOO.isVisualisationSelected(), CommandeClientSQLComponent.this.panelOO.isImpressionSelected(), true);
|
909 |
} catch (Exception e) {
|
909 |
} catch (Exception e) {
|
910 |
ExceptionHandler.handle("Impossible de créer la commande", e);
|
910 |
ExceptionHandler.handle("Impossible de créer la commande", e);
|
911 |
}
|
911 |
}
|
912 |
|
912 |
|
913 |
}
|
913 |
}
|
914 |
|
914 |
|
915 |
protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
|
915 |
protected String getLibelleStock(SQLRowAccessor row, SQLRowAccessor rowElt) {
|
916 |
return "Commande client N°" + row.getString("NUMERO");
|
916 |
return "Commande client N°" + row.getString("NUMERO");
|
917 |
}
|
917 |
}
|
918 |
|
918 |
|
919 |
/**
|
919 |
/**
|
920 |
* Mise à jour des stocks pour chaque article composant la facture
|
920 |
* Mise à jour des stocks pour chaque article composant la facture
|
921 |
*
|
921 |
*
|
922 |
* @throws SQLException
|
922 |
* @throws SQLException
|
923 |
*/
|
923 |
*/
|
924 |
private void updateStock(int id) throws SQLException {
|
924 |
private void updateStock(int id) throws SQLException {
|
925 |
|
925 |
|
926 |
SQLRow row = getTable().getRow(id);
|
926 |
SQLRow row = getTable().getRow(id);
|
927 |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
|
927 |
StockItemsUpdater stockUpdater = new StockItemsUpdater(new StockLabel() {
|
928 |
@Override
|
928 |
@Override
|
929 |
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
|
929 |
public String getLabel(SQLRowAccessor rowOrigin, SQLRowAccessor rowElt) {
|
930 |
return getLibelleStock(rowOrigin, rowElt);
|
930 |
return getLibelleStock(rowOrigin, rowElt);
|
931 |
}
|
931 |
}
|
932 |
}, row, row.getReferentRows(getTable().getTable("COMMANDE_CLIENT_ELEMENT")), TypeStockUpdate.VIRTUAL_DELIVER);
|
932 |
}, row, row.getReferentRows(getTable().getTable("COMMANDE_CLIENT_ELEMENT")), TypeStockUpdate.VIRTUAL_DELIVER);
|
933 |
|
933 |
|
934 |
stockUpdater.update();
|
934 |
stockUpdater.update();
|
935 |
}
|
935 |
}
|
936 |
|
936 |
|
937 |
public void setDefaults() {
|
937 |
public void setDefaults() {
|
938 |
this.resetValue();
|
938 |
this.resetValue();
|
939 |
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
|
939 |
this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
|
940 |
this.table.getModel().clearRows();
|
940 |
this.table.getModel().clearRows();
|
941 |
}
|
941 |
}
|
942 |
|
942 |
|
943 |
/**
|
943 |
/**
|
944 |
* Création d'une commande à partir d'un devis
|
944 |
* Création d'une commande à partir d'un devis
|
945 |
*
|
945 |
*
|
946 |
* @param idDevis
|
946 |
* @param idDevis
|
947 |
*
|
947 |
*
|
948 |
*/
|
948 |
*/
|
949 |
public void loadDevis(int idDevis) {
|
949 |
public void loadDevis(int idDevis) {
|
950 |
|
950 |
|
951 |
SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
951 |
SQLElement devis = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
952 |
SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
|
952 |
SQLElement devisElt = Configuration.getInstance().getDirectory().getElement("DEVIS_ELEMENT");
|
953 |
|
953 |
|
954 |
if (idDevis > 1) {
|
954 |
if (idDevis > 1) {
|
955 |
SQLInjector injector = SQLInjector.getInjector(devis.getTable(), this.getTable());
|
955 |
SQLInjector injector = SQLInjector.getInjector(devis.getTable(), this.getTable());
|
956 |
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(idDevis);
|
956 |
SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(idDevis);
|
957 |
SQLRow rowDevis = devis.getTable().getRow(idDevis);
|
957 |
SQLRow rowDevis = devis.getTable().getRow(idDevis);
|
958 |
|
958 |
|
959 |
String string = rowDevis.getString("OBJET");
|
959 |
String string = rowDevis.getString("OBJET");
|
960 |
createRowValuesFrom.put("NOM", string + (string.trim().length() == 0 ? "" : ",") + rowDevis.getString("NUMERO"));
|
960 |
createRowValuesFrom.put("NOM", string + (string.trim().length() == 0 ? "" : ",") + rowDevis.getString("NUMERO"));
|
961 |
this.select(createRowValuesFrom);
|
961 |
this.select(createRowValuesFrom);
|
962 |
}
|
962 |
}
|
963 |
|
963 |
|
964 |
loadItem(this.table, devis, idDevis, devisElt);
|
964 |
loadItem(this.table, devis, idDevis, devisElt);
|
965 |
}
|
965 |
}
|
966 |
|
966 |
|
967 |
@Override
|
967 |
@Override
|
968 |
protected SQLRowValues createDefaults() {
|
968 |
protected SQLRowValues createDefaults() {
|
969 |
SQLRowValues rowVals = new SQLRowValues(getTable());
|
969 |
SQLRowValues rowVals = new SQLRowValues(getTable());
|
970 |
rowVals.put("T_POIDS", 0.0F);
|
970 |
rowVals.put("T_POIDS", 0.0F);
|
971 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
|
971 |
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(getElement().getClass(), new Date()));
|
972 |
// User
|
972 |
// User
|
973 |
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
|
973 |
// SQLSelect sel = new SQLSelect(Configuration.getInstance().getBase());
|
974 |
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
|
974 |
SQLElement eltComm = Configuration.getInstance().getDirectory().getElement("COMMERCIAL");
|
975 |
int idUser = UserManager.getInstance().getCurrentUser().getId();
|
975 |
int idUser = UserManager.getInstance().getCurrentUser().getId();
|
976 |
//
|
976 |
//
|
977 |
// sel.addSelect(eltComm.getTable().getKey());
|
977 |
// sel.addSelect(eltComm.getTable().getKey());
|
978 |
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
|
978 |
// sel.setWhere(new Where(eltComm.getTable().getField("ID_USER_COMMON"), "=", idUser));
|
979 |
// List<SQLRow> rowsComm = (List<SQLRow>)
|
979 |
// List<SQLRow> rowsComm = (List<SQLRow>)
|
980 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
|
980 |
// Configuration.getInstance().getBase().getDataSource().execute(sel.asString(), new
|
981 |
// SQLRowListRSH(eltComm.getTable()));
|
981 |
// SQLRowListRSH(eltComm.getTable()));
|
982 |
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
|
982 |
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(eltComm.getTable()).getFirstRowContains(idUser, eltComm.getTable().getField("ID_USER_COMMON"));
|
983 |
|
983 |
|
984 |
if (rowsComm != null) {
|
984 |
if (rowsComm != null) {
|
985 |
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
|
985 |
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
|
986 |
}
|
986 |
}
|
987 |
if (getTable().contains("ETAT_COMMANDE")) {
|
987 |
if (getTable().contains("ETAT_COMMANDE")) {
|
988 |
rowVals.put("ETAT_COMMANDE", EtatCommandeClient.A_PREPARER.getId());
|
988 |
rowVals.put("ETAT_COMMANDE", EtatCommandeClient.A_PREPARER.getId());
|
989 |
}
|
989 |
}
|
990 |
if (getTable().contains("ID_TAXE_PORT")) {
|
990 |
if (getTable().contains("ID_TAXE_PORT")) {
|
991 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
991 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
992 |
rowVals.put("ID_TAXE_PORT", taxeDefault.getID());
|
992 |
rowVals.put("ID_TAXE_PORT", taxeDefault.getID());
|
993 |
}
|
993 |
}
|
994 |
|
994 |
|
995 |
if (getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
|
995 |
if (getTable().contains("ID_TAXE_FRAIS_DOCUMENT")) {
|
996 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
996 |
SQLRow taxeDefault = TaxeCache.getCache().getFirstTaxe();
|
997 |
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", taxeDefault.getID());
|
997 |
rowVals.put("ID_TAXE_FRAIS_DOCUMENT", taxeDefault.getID());
|
998 |
}
|
998 |
}
|
999 |
|
999 |
|
1000 |
return rowVals;
|
1000 |
return rowVals;
|
1001 |
}
|
1001 |
}
|
1002 |
|
1002 |
|
1003 |
@Override
|
1003 |
@Override
|
1004 |
protected void refreshAfterSelect(SQLRowAccessor r) {
|
1004 |
protected void refreshAfterSelect(SQLRowAccessor r) {
|
1005 |
if (this.dateCommande.getValue() != null && r.getObject("DATE") != null) {
|
1005 |
if (this.dateCommande.getValue() != null && r.getObject("DATE") != null) {
|
1006 |
this.table.setDateDevise(r.getDate("DATE").getTime());
|
1006 |
this.table.setDateDevise(r.getDate("DATE").getTime());
|
1007 |
}
|
1007 |
}
|
1008 |
}
|
1008 |
}
|
1009 |
}
|
1009 |
}
|