/** * Check availability and insert record * * @return true if saved/updated */ private boolean cmd_save() { log.config(""); // Set AssignDateTo Calendar date = new GregorianCalendar(); getDateAndTimeFrom(date); Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis()); BigDecimal qty = fQty.getValue(); KeyNamePair uom = (KeyNamePair) m_lookup.get(fResource.getSelectedItem()); int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty); Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes); m_mAssignment.setAssignDateTo(assignDateTo); // // m_mAssignment.dump(); return m_mAssignment.save(); } // cmdSave
public void onEvent(Event e) throws Exception { if (m_setting) return; // Update Assignment ListItem listItem = fResource.getSelectedItem(); KeyNamePair resource = listItem != null ? new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel()) : null; if (resource != null) { int S_Resource_ID = resource.getKey(); m_mAssignment.setS_Resource_ID(S_Resource_ID); } Calendar date = new GregorianCalendar(); getDateAndTimeFrom(date); Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis()); if (assignDateFrom != null) m_mAssignment.setAssignDateFrom(assignDateFrom); if (fQty.getValue() != null) { BigDecimal qty = fQty.getValue(); m_mAssignment.setQty(qty); } m_mAssignment.setName((String) fName.getValue()); m_mAssignment.setDescription((String) fDescription.getValue()); // Resource - Look up UOM if (e.getTarget() == fResource) { Object o = m_lookup.get(fResource.getSelectedItem()); if (o == null) lUOM.setValue(" ? "); else lUOM.setValue(o.toString()); } // Zoom - InfoResource else if (e.getTarget().getId().equals("Zoom")) { InfoSchedule is = new InfoSchedule(m_mAssignment, true); if (is.getMResourceAssignment() != null) { m_mAssignment = is.getMResourceAssignment(); // setDisplay(); detach(); } is = null; } // cancel - return else if (e.getTarget().getId().equals("Cancel")) { m_cancel = true; detach(); } // delete - delete and return else if (e.getTarget().getId().equals("Delete")) { if (m_mAssignment.delete(true)) { m_mAssignment = null; detach(); } else FDialog.error(0, this, "ResourceAssignmentNotDeleted"); } // OK - Save else if (e.getTarget().getId().equals("Ok")) { if (cmd_save()) detach(); } }