⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stockdiaryeditor.java

📁 是一个专门设计用于触摸屏的POS(point of sales)应用软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
//    Tina POS is a point of sales application designed for touch screens.//    Copyright (C) 2005 Adrian Romero Corchado.//    http://sourceforge.net/projects/tinapos////    This program is free software; you can redistribute it and/or modify//    it under the terms of the GNU General Public License as published by//    the Free Software Foundation; either version 2 of the License, or//    (at your option) any later version.////    This program is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//    GNU General Public License for more details.////    You should have received a copy of the GNU General Public License//    along with this program; if not, write to the Free Software//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USApackage net.adrianromero.tpv.inventory;import java.awt.BorderLayout;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Date;import net.adrianromero.beans.DateUtils;import net.adrianromero.beans.JCalendarDialog;import net.adrianromero.basic.BasicException;import net.adrianromero.data.gui.ComboBoxValModel;import net.adrianromero.data.gui.ListCellRendererBasic;import net.adrianromero.data.gui.MessageInf;import net.adrianromero.data.loader.SentenceList;import net.adrianromero.data.loader.TableDefinition;import net.adrianromero.format.Formats;import net.adrianromero.data.user.DirtyManager;import net.adrianromero.data.user.EditorRecord;import net.adrianromero.tpv.forms.AppLocal;import net.adrianromero.tpv.forms.AppView;import net.adrianromero.tpv.forms.SentenceContainer;import net.adrianromero.tpv.panels.JCatalog;import net.adrianromero.tpv.panels.JProductFinder;import net.adrianromero.tpv.ticket.ProductInfoExt;public class StockDiaryEditor extends javax.swing.JPanel implements EditorRecord {        private DirtyManager m_Dirty = new DirtyManager();        private JCatalog m_cat;    private Integer m_iID;    private ProductInfoExt m_product;        private ComboBoxValModel m_ReasonModel;        private SentenceList m_sentlocations;    private ComboBoxValModel m_LocationsModel;        private AppView m_App;        /** Creates new form StockDiaryEditor */    public StockDiaryEditor(AppView oApp) {                m_App = oApp;                initComponents();                      m_cat = new JCatalog(m_App);        m_cat.addActionListener(new CatalogListener());        m_jcatcontainer.add(m_cat, BorderLayout.CENTER);        // El modelo de locales        m_sentlocations = m_App.lookupDataLogic(SentenceContainer.class).getLocationsList();        m_LocationsModel = new ComboBoxValModel();                m_ReasonModel = new ComboBoxValModel();        m_ReasonModel.add(MovementReason.IN_PURCHASE);        m_ReasonModel.add(MovementReason.IN_REFUND);        m_ReasonModel.add(MovementReason.IN_MOVEMENT);        m_ReasonModel.add(MovementReason.OUT_SALE);        m_ReasonModel.add(MovementReason.OUT_REFUND);        m_ReasonModel.add(MovementReason.OUT_BREAK);        m_ReasonModel.add(MovementReason.OUT_MOVEMENT);                m_jreason.setModel(m_ReasonModel);                m_jdate.getDocument().addDocumentListener(m_Dirty);        m_jreason.addActionListener(m_Dirty);        m_jLocation.addActionListener(m_Dirty);        m_jproduct.getDocument().addDocumentListener(m_Dirty);        m_junits.getDocument().addDocumentListener(m_Dirty);        m_jprice.getDocument().addDocumentListener(m_Dirty);                 writeValueEOF();    }        public void activate() throws BasicException {        m_cat.loadCatalog();                m_LocationsModel = new ComboBoxValModel(m_sentlocations.list());        m_jLocation.setModel(m_LocationsModel); // para que lo refresque       }        public void writeValueEOF() {        m_iID = null;        m_jdate.setText(null);        m_ReasonModel.setSelectedKey(null);        m_product = null;        m_jreference.setText(null);        m_jcodebar.setText(null);        m_LocationsModel.setSelectedKey(m_App.getInventoryLocation());        m_jproduct.setText(null);        m_junits.setText(null);        m_jprice.setText(null);        m_jdate.setEnabled(false);        m_jbtndate.setEnabled(false);        m_jreason.setEnabled(false);        m_jreference.setEnabled(false);        m_jEnter1.setEnabled(false);        m_jcodebar.setEnabled(false);        m_jEnter.setEnabled(false);        m_jLocation.setEnabled(false);        m_jproduct.setEnabled(false);        m_jbtnproduct.setEnabled(false);        m_junits.setEnabled(false);        m_jprice.setEnabled(false);        m_cat.setEnabled(false);    }        public void writeValueInsert() {        m_iID = null;        m_jdate.setText(Formats.TIMESTAMP.formatValue(DateUtils.getTodayMinutes()));        m_ReasonModel.setSelectedItem(MovementReason.IN_PURCHASE);        m_product = null;        m_jreference.setText(null);        m_jcodebar.setText(null);        m_LocationsModel.setSelectedKey(m_App.getInventoryLocation());        m_jproduct.setText(null);        m_jcodebar.setText(null);        m_junits.setText(null);        m_jprice.setText(null);        m_jdate.setEnabled(true);        m_jbtndate.setEnabled(true);        m_jreason.setEnabled(true);        m_jreference.setEnabled(true);        m_jEnter1.setEnabled(true);        m_jcodebar.setEnabled(true);        m_jEnter.setEnabled(true);        m_jLocation.setEnabled(true);        m_jproduct.setEnabled(true);        m_jbtnproduct.setEnabled(true);        m_junits.setEnabled(true);        m_jprice.setEnabled(true);           m_cat.setEnabled(true);    }    public void writeValueDelete(Object value) {        Object[] diary = (Object[]) value;        m_iID = (Integer) diary[0];        m_jdate.setText(Formats.TIMESTAMP.formatValue(diary[1]));        m_ReasonModel.setSelectedKey(diary[2]);        m_LocationsModel.setSelectedKey(diary[3]);        m_product = getProductByReference((String) diary[4]);        m_jreference.setText(m_product.getReference());        m_jcodebar.setText(m_product.getCode());        m_jproduct.setText(m_product.toString());        m_junits.setText(Formats.DOUBLE.formatValue(signum((Double)diary[5], (Integer) diary[2])));        m_jprice.setText(Formats.CURRENCY.formatValue(diary[6]));        m_jdate.setEnabled(false);        m_jbtndate.setEnabled(false);        m_jreason.setEnabled(false);        m_jreference.setEnabled(false);        m_jEnter1.setEnabled(false);        m_jcodebar.setEnabled(false);        m_jEnter.setEnabled(false);        m_jLocation.setEnabled(false);        m_jproduct.setEnabled(false);        m_jbtnproduct.setEnabled(false);        m_junits.setEnabled(false);        m_jprice.setEnabled(false);           m_cat.setEnabled(false);    }        public void writeValueEdit(Object value) {        Object[] diary = (Object[]) value;        m_iID = (Integer) diary[0];        m_jdate.setText(Formats.TIMESTAMP.formatValue(diary[1]));        m_ReasonModel.setSelectedKey(diary[2]);        m_LocationsModel.setSelectedKey(diary[3]);        m_product = getProductByReference((String) diary[4]);        m_jreference.setText(m_product.getReference());        m_jcodebar.setText(m_product.getCode());        m_jproduct.setText(m_product.toString());        m_junits.setText(Formats.DOUBLE.formatValue(signum((Double)diary[5], (Integer) diary[2])));        m_jprice.setText(Formats.CURRENCY.formatValue(diary[6]));        m_jdate.setEnabled(false);        m_jbtndate.setEnabled(false);        m_jreason.setEnabled(false);        m_jreference.setEnabled(false);        m_jEnter1.setEnabled(false);        m_jcodebar.setEnabled(false);        m_jEnter.setEnabled(false);        m_jLocation.setEnabled(false);        m_jproduct.setEnabled(false);        m_jbtnproduct.setEnabled(false);        m_junits.setEnabled(false);        m_jprice.setEnabled(false);          m_cat.setEnabled(false);    }        public Object createValue() throws BasicException {        Object[] diary = new Object[7];        diary[0] = m_iID == null ? m_App.lookupDataLogic(SentenceContainer.class).getNextStockDiary() : m_iID; // si casca que suba la excepcion hacia arriba.        diary[1] = Formats.TIMESTAMP.parseValue(m_jdate.getText());        diary[2] = m_ReasonModel.getSelectedKey();        diary[3] = m_LocationsModel.getSelectedKey();        diary[4] = (m_product == null) ? null : m_product.getReference();        diary[5] = samesignum((Double) Formats.DOUBLE.parseValue(m_junits.getText()), (Integer) diary[2]);        diary[6] = Formats.CURRENCY.parseValue(m_jprice.getText());        return diary;    }        public DirtyManager getDirtyManager() {        return m_Dirty;    }     private ProductInfoExt getProductByReference(String sRef)  {                try {            return m_App.lookupDataLogic(SentenceContainer.class).getProductInfo2(sRef);        } catch (BasicException e) {            return null;        }    }         private Double signum(Double d, Integer i) {        if (d == null || i == null) {            return d;        } else if (i.intValue() < 0) {            return new Double(-d.doubleValue());        } else {            return d;        }     }        private Double samesignum(Double d, Integer i) {                if (d == null || i == null) {            return d;        } else if ((i.intValue() > 0 && d.doubleValue() < 0.0) ||            (i.intValue() < 0 && d.doubleValue() > 0.0)) {            return new Double(-d.doubleValue());        } else {            return d;        }                }        private void assignProduct(ProductInfoExt prod) {                if (m_jproduct.isEnabled()) {            if (prod == null) {                m_product = null;                m_jproduct.setText(null);                m_jcodebar.setText(null);                m_jreference.setText(null);            } else {                m_product = prod;                m_jproduct.setText(m_product.toString());                m_jcodebar.setText(m_product.getCode());                m_jreference.setText(m_product.getReference());                // calculo el precio sugerido para la entrada.                MovementReason reason = (MovementReason)  m_ReasonModel.getSelectedItem();                Double dPrice = reason.getPrice(m_product.getPriceBuy(), m_product.getPriceSell());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -