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

📄 jpanelticket.java

📁 是一个专门设计用于触摸屏的POS(point of sales)应用软件
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        } catch (NumberFormatException e){            return 0.0;        }    }    private double getPorValue() {        try {            return Double.parseDouble(m_jPor.getText().substring(1));                        } catch (NumberFormatException e){            return 1.0;        } catch (StringIndexOutOfBoundsException e){            return 1.0;        }    }        private void stateToZero(){        m_jPor.setText("");        m_jPrice.setText("");        m_sBarcode = new StringBuffer();        m_iNumberStatus = NUMBER_INPUTZERO;        m_iNumberStatusInput = NUMBERZERO;        m_iNumberStatusPor = NUMBERZERO;    }        private void incProductByCode(String sCode) {    // precondicion: sCode != null                try {            ProductInfoExt oProduct = m_App.lookupDataLogic(SentenceContainer.class).getProductInfo(sCode);            if (oProduct == null) {                                  Toolkit.getDefaultToolkit().beep();                                   stateToZero();            } else {                // Se anade directamente una unidad con el precio y todo                incProduct(oProduct);            }        } catch (BasicException eData) {            stateToZero();                       MessageInf msg = new MessageInf(eData);            msg.show(this);                    }    }        private void incProductByCode(String sCode, double dWeight) {    // precondicion: sCode != null                try {            ProductInfoExt oProduct = m_App.lookupDataLogic(SentenceContainer.class).getProductInfo(sCode);            if (oProduct == null) {                                  Toolkit.getDefaultToolkit().beep();                                   stateToZero();            } else {                // Se anade directamente una unidad con el precio y todo                incProduct(dWeight, oProduct);            }        } catch (BasicException eData) {            stateToZero();                       MessageInf msg = new MessageInf(eData);            msg.show(this);                    }    }        private void incProductByCodePrice(String sCode, double dPriceSell) {    // precondicion: sCode != null                try {            ProductInfoExt oProduct = m_App.lookupDataLogic(SentenceContainer.class).getProductInfo(sCode);            if (oProduct == null) {                                  Toolkit.getDefaultToolkit().beep();                                   stateToZero();            } else {                // Se anade directamente una unidad con el precio y todo                if (m_jaddtax.isSelected()) {                    // debemos quitarle los impuestos ya que el precio es con iva incluido...                    addTicketLine(oProduct, 1.0, dPriceSell / (1.0 + oProduct.getTaxRate()));                } else {                    addTicketLine(oProduct, 1.0, dPriceSell);                }                            }        } catch (BasicException eData) {            stateToZero();            MessageInf msg = new MessageInf(eData);            msg.show(this);            }    }        private void incProduct(ProductInfoExt prod) {                if (prod.isScale() && m_App.getDeviceScale().existsScale()) {            try {                double dweight = m_App.getDeviceScale().readWeight();                if (dweight > 0.001) {                    // peso valido                    incProduct(dweight, prod);                } else {                    // Peso 0.000                    Toolkit.getDefaultToolkit().beep();                }            } catch (ScaleException e) {                // Error de pesada.                Toolkit.getDefaultToolkit().beep();            }        } else {            // No es un producto que se pese o no hay balanza            incProduct(1.0, prod);        }    }        private void incProduct(double dPor, ProductInfoExt prod) {        // precondicion: prod != null        addTicketLine(prod, dPor, prod.getPriceSell());           }           protected void buttonTransition(ProductInfoExt prod) {    // precondicion: prod != null                 if (m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {            incProduct(prod);        } else if (m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO) {            incProduct(getInputValue(), prod);        } else {            Toolkit.getDefaultToolkit().beep();        }           }        private void stateTransition(char cTrans) {        if (cTrans == '\n') {            // Codigo de barras introducido            if (m_sBarcode.length() > 0) {                            String sCode = m_sBarcode.toString();                if (sCode.length() == 13 && sCode.startsWith("250")) {                    // es un ticket de la maquina                    ProductInfoExt oProduct = new ProductInfoExt(); // Es un ticket                    oProduct.setReference(null); // para que no se grabe                    oProduct.setCode(sCode);                    oProduct.setName("Ticket " + sCode.substring(3, 7));                    oProduct.setPriceSell(Double.parseDouble(sCode.substring(7, 12)) / 100);                       // Se anade directamente una unidad con el precio y todo                    addTicketLine(oProduct, 1.0, oProduct.getPriceSell());                } else if (sCode.length() == 13 && sCode.startsWith("210")) {                    // es un ticket al peso                    // incProductByCode(sCode.substring(0, 7), Double.parseDouble(sCode.substring(7, 12)) / 100);                    incProductByCodePrice(sCode.substring(0, 7), Double.parseDouble(sCode.substring(7, 12)) / 100);                } else {                    incProductByCode(sCode);                }            } else {                Toolkit.getDefaultToolkit().beep();            }        } else {            // otro caracter            // Esto es para el codigo de barras...            m_sBarcode.append(cTrans);            // Esto es para el los productos normales...            if (cTrans == '\u007f') {                 stateToZero();            } else if ((cTrans == '0')                     && (m_iNumberStatus == NUMBER_INPUTZERO)) {                m_jPrice.setText("0");                        } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')                    && (m_iNumberStatus == NUMBER_INPUTZERO)) {                 // Un numero entero                m_jPrice.setText(Character.toString(cTrans));                m_iNumberStatus = NUMBER_INPUTINT;                    m_iNumberStatusInput = NUMBERVALID;            } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')                       && (m_iNumberStatus == NUMBER_INPUTINT)) {                 // Un numero entero                m_jPrice.setText(m_jPrice.getText() + cTrans);            } else if (cTrans == '.' && m_iNumberStatus == NUMBER_INPUTZERO) {                m_jPrice.setText("0.");                m_iNumberStatus = NUMBER_INPUTZERODEC;                        } else if (cTrans == '.' && m_iNumberStatus == NUMBER_INPUTINT) {                m_jPrice.setText(m_jPrice.getText() + ".");                m_iNumberStatus = NUMBER_INPUTDEC;            } else if ((cTrans == '0')                       && (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) {                 // Un numero decimal                m_jPrice.setText(m_jPrice.getText() + cTrans);            } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')                       && (m_iNumberStatus == NUMBER_INPUTZERODEC || m_iNumberStatus == NUMBER_INPUTDEC)) {                 // Un numero decimal                m_jPrice.setText(m_jPrice.getText() + cTrans);                m_iNumberStatus = NUMBER_INPUTDEC;                m_iNumberStatusInput = NUMBERVALID;            } else if (cTrans == '*'                     && (m_iNumberStatus == NUMBER_INPUTINT || m_iNumberStatus == NUMBER_INPUTDEC)) {                m_jPor.setText("x");                m_iNumberStatus = NUMBER_PORZERO;                        } else if (cTrans == '*'                     && (m_iNumberStatus == NUMBER_INPUTZERO || m_iNumberStatus == NUMBER_INPUTZERODEC)) {                m_jPrice.setText("0");                m_jPor.setText("x");                m_iNumberStatus = NUMBER_PORZERO;                   } else if ((cTrans == '0')                     && (m_iNumberStatus == NUMBER_PORZERO)) {                m_jPor.setText("x0");                        } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')                    && (m_iNumberStatus == NUMBER_PORZERO)) {                 // Un numero entero                m_jPor.setText("x" + Character.toString(cTrans));                m_iNumberStatus = NUMBER_PORINT;                            m_iNumberStatusPor = NUMBERVALID;            } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')                       && (m_iNumberStatus == NUMBER_PORINT)) {                 // Un numero entero                m_jPor.setText(m_jPor.getText() + cTrans);            } else if (cTrans == '.' && m_iNumberStatus == NUMBER_PORZERO) {                m_jPor.setText("x0.");                m_iNumberStatus = NUMBER_PORZERODEC;                        } else if (cTrans == '.' && m_iNumberStatus == NUMBER_PORINT) {                m_jPor.setText(m_jPor.getText() + ".");                m_iNumberStatus = NUMBER_PORDEC;            } else if ((cTrans == '0')                       && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) {                 // Un numero decimal                m_jPor.setText(m_jPor.getText() + cTrans);            } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9')                       && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) {                 // Un numero decimal                m_jPor.setText(m_jPor.getText() + cTrans);                m_iNumberStatus = NUMBER_PORDEC;                            m_iNumberStatusPor = NUMBERVALID;                          } else if (cTrans == '\u00a7'                     && m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO) {                // Bascula con una cantidad tecleada                                if (m_App.getDeviceScale().existsScale()) {                    try {                        double dweight = m_App.getDeviceScale().readWeight();                        if (dweight > 0.002) {                            // peso valido                            addTicketLine(getInputProduct(), dweight, includeTaxes(getInputValue()));                        } else {                            // Peso 0.000                            Toolkit.getDefaultToolkit().beep();                        }                    } catch (ScaleException e) {                        // Error de pesada.                        Toolkit.getDefaultToolkit().beep();                    }                } else {                    // No existe la balanza;                    Toolkit.getDefaultToolkit().beep();                }            } else if (cTrans == '\u00a7'                     && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {                // Bascula a 0, ponemos el peso de la bascula a las cantidades.                int i = m_ticketlines.getSelectedIndex();                if (i < 0){                    Toolkit.getDefaultToolkit().beep();                } else if (m_App.getDeviceScale().existsScale()) {                    try {                        double dweight = m_App.getDeviceScale().readWeight();                        if (dweight > 0.002) {                            // peso valido                            TicketLineInfo oLine = m_oTicket.getLine(i);                            oLine.setMultiply(dweight);                            oLine.setPrice(Math.abs(oLine.getPrice()));                            paintTicketLine(i, oLine);                        } else {                            // Peso 0.000                            Toolkit.getDefaultToolkit().beep();                        }                    } catch (ScaleException e) {                        // Error de pesada.                        Toolkit.getDefaultToolkit().beep();                    }                } else {                    // No existe la balanza;                    Toolkit.getDefaultToolkit().beep();                }                                  // Anadimos un producto mas a la linea seleccionada            } else if (cTrans == '+'                     && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {                int i = m_ticketlines.getSelectedIndex();                if (i < 0){                    Toolkit.getDefaultToolkit().beep();                } else {                    // Sumamos uno a la seleccionada...                    TicketLineInfo oLine = m_oTicket.getLine(i);                    oLine.addOneMore();                    paintTicketLine(i, oLine);                 }            // Eliminamos un producto mas a la linea seleccionada            } else if (cTrans == '-'                     && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) {                int i = m_ticketlines.getSelectedIndex();                if (i < 0){                    Toolkit.getDefaultToolkit().beep();                } else {                    // Restamos uno a la seleccionada...                    TicketLineInfo oLine = m_oTicket.getLine(i);                    oLine.remOneMore();                    if (oLine.getMultiply() <= 0.0) {                                           removeTicketLine(i); // elimino la linea                    } else {                        paintTicketLine(i, oLine);                                       }                }            // Ponemos n productos a la linea seleccionada            } else if (cTrans == '+'                     && m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERVALID) {                int i = m_ticketlines.getSelectedIndex();                if (i < 0){                    Toolkit.getDefaultToolkit().beep();                } else {                    double dPor = getPorValue();                    TicketLineInfo oLine = m_oTicket.getLine(i);                    oLine.setMultiply(dPor);

⌨️ 快捷键说明

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