BrightSide Workbench Full Report + Source Code
reference/CustomerOrderEdit.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.erp.reference;
20 
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.context.Application;
24 import org.turro.erp.entity.CustomerOrder;
25 import org.turro.erp.entity.OrderReference;
26 import org.turro.erp.sales.PendingCustomerOrderListbox;
27 import org.turro.zkoss.dialog.SelectionDialog;
28 import org.turro.zkoss.input.ExpressionInput;
29 import org.turro.zul.frame.Framework;
30 import org.zkoss.zk.ui.event.Event;
31 import org.zkoss.zk.ui.util.GenericForwardComposer;
32 import org.zkoss.zul.Checkbox;
33 import org.zkoss.zul.Datebox;
34 import org.zkoss.zul.Textbox;
35 import org.zkoss.zul.Window;
36 
41 public class CustomerOrderEdit extends GenericForwardComposer {
42 
43  private Object object;
44  private Window orderForm;
45  private CustomerOrder customerOrder;
46  private OrderReference orderReference;
47  private Textbox orderId, customerCode, description;
48  private Datebox orderDate, control, delivery;
49  private ExpressionInput quantity, price;
50  private Checkbox wantBudget;
51 
52  public void onUser(Event event) {
53  object = event.getData();
54  if(object instanceof OrderReference) {
55  orderReference = (OrderReference) object;
56  customerOrder = orderReference.getCustomerOrder();
57  }
58  if(customerOrder == null) {
59  customerOrder = new CustomerOrder();
60  customerOrder.initFrom(orderReference);
61  }
62  orderId.setValue(customerOrder.getOrderId());
63  orderDate.setValue(customerOrder.getOrderDate());
64  customerCode.setValue(customerOrder.getCustomerCode());
65  description.setValue(customerOrder.getDescription());
66  control.setValue(customerOrder.getControlDate());
67  delivery.setValue(customerOrder.getDelivery());
68  quantity.setValue(customerOrder.getQuantity());
69  price.setValue(customerOrder.getPrice());
70  wantBudget.setChecked(customerOrder.isWantBudget());
71  }
72 
73  public void onOK() {
74  onSave();
75  }
76 
77  public void onImport() {
79  pcolb.setMultiple(false);
80  pcolb.setCheckmark(false);
81  pcolb.setSelectFirst(false);
82  pcolb.setContract(orderReference.getWorkOrder().getContract());
83 
85  Framework.getCurrent().getPage(),
86  Application.getString("lCustomerOrders"),
87  pcolb,
88  "80%", "80%", new Command() {
89  @Override
90  public Object execute(Context context) {
91  if(pcolb != null) {
92  customerOrder = pcolb.getObjectValue();
93  orderReference.setCustomerOrder(customerOrder);
94  orderId.setValue(customerOrder.getOrderId());
95  orderDate.setValue(customerOrder.getOrderDate());
96  customerCode.setValue(customerOrder.getCustomerCode());
97  description.setValue(customerOrder.getDescription());
98  control.setValue(customerOrder.getControlDate());
99  delivery.setValue(customerOrder.getDelivery());
100  quantity.setValue(customerOrder.getQuantity());
101  price.setValue(customerOrder.getPrice());
102  wantBudget.setChecked(customerOrder.isWantBudget());
103  }
104  return null;
105  }
106  });
107  }
108 
109  public void onSave() {
110  customerOrder.setControlDate(control.getValue());
111  customerOrder.setDelivery(delivery.getValue());
112  customerOrder.setCustomerCode(customerCode.getValue());
113  customerOrder.setDescription(description.getValue());
114  customerOrder.setOrderDate(orderDate.getValue());
115  customerOrder.setOrderId(orderId.getValue());
116  customerOrder.setQuantity(((Number) quantity.getNumber()).doubleValue());
117  customerOrder.setPrice(((Number) price.getNumber()).doubleValue());
118  customerOrder.setWantBudget(wantBudget.isChecked());
119  orderReference.setCustomerOrder(customerOrder);
120  orderForm.detach();
121  }
122 
123  public void onCancel() {
124  orderForm.detach();
125  }
126 
127 }
128 
static String getString(String key)
void setControlDate(Date controlDate)
void setWantBudget(boolean wantBudget)
void initFrom(OrderReference orderReference)
void setDescription(String description)
void setCustomerCode(String customerCode)
void setCustomerOrder(CustomerOrder customerOrder)
void setSelectFirst(boolean selectFirst)
static Framework getCurrent()
Definition: Framework.java:203