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

📄 posframeoper.java

📁 好的超市源码供大家下载
💻 JAVA
字号:
package view.frame.frameoper;

import java.util.Date;

import javax.swing.JOptionPane;
import javax.swing.text.JTextComponent;

import view.com.CheckInputText;
import view.frame.PosFrame;
import vo.SaleProductVo;
import dao.StoreDao;
import dao.VipDao;

public class PosFrameOper extends PosFrame {

  public static void initialTextValue() {
    product_idText.setText("");
    product_numText.setText("");
    product_sumText.setText("");
    vip_idText.setText("");
    vip_nameText.setText("");
    price_pctText.setText("");
    phoneText.setText("");

  }

  public static boolean checkInputValue() {
    CheckInputText check = new CheckInputText();
    if (check.checkInputIsNull(product_idText.getText())) {
      JOptionPane.showMessageDialog(null, "商品编号不能为空", "message",
          JOptionPane.YES_OPTION);
      product_idText.requestFocus();
      return false;
    }
    if (check.checkInputIsNull(product_numText.getText())) {
      JOptionPane.showMessageDialog(null, "售出数量不能为空", "message",
          JOptionPane.YES_OPTION);
      product_numText.requestFocus();
      return false;
    }
    if (new StoreDao().findStoreById(getProductId())) {
      if (new StoreDao().getStoreNumById(getProductId())
          - Integer.parseInt(product_numText.getText()) >= 0) {
        product_nameText.setText(new StoreDao()
            .getStoreNameById(getProductId()));

        if (check.checkInputIsNull(vip_idText.getText())) {

          if (check.checkInputIsNull(price_pctText.getText())) {
            price_pctText.setText("1.0");
          }

        } else {
          if (new VipDao().findVipById(getVipId())) {
            vip_nameText.setText(new VipDao().getVipNameById(getVipId()));
            price_pctText.setText(String.valueOf(new VipDao()
                .getVipPctById(getVipId())));
            phoneText.setText(String.valueOf(new VipDao()
                .getVipPhoneById(getVipId())));
            product_sumText.setText(String.valueOf(new StoreDao()
                .getStorePriceById(getProductId())
                * Double.parseDouble(price_pctText.getText())
                * Integer.parseInt(product_numText.getText())));
          } else {
            JOptionPane.showMessageDialog(null, "不存在此会员!", "错误",
                JOptionPane.ERROR_MESSAGE);
          }
        }

      } else {
        JOptionPane.showMessageDialog(null, "该种商品已经售完", "message",
            JOptionPane.YES_OPTION);
      }
    } else {
      JOptionPane.showMessageDialog(null, "不存在该种商品", "message",
          JOptionPane.YES_OPTION);
    }
    return true;
  }

  public static SaleProductVo getInputTextValue() {
    SaleProductVo value;
    int productId = getProductId();
    String productName = new StoreDao().getStoreNameById(getProductId());
    String productType = new StoreDao().getStoreTypeById(getProductId());
    double productPrice = new StoreDao().getStorePriceById(getProductId());
    double pricePct = new VipDao().getVipPctById(getVipId());
    int saleNum = Integer.parseInt(product_numText.getText());
    double saleSum = productPrice * pricePct * saleNum;
    String saleDate = product_dateBox.getSelectedItem().toString();

    value = new SaleProductVo(productId, productName, productType,
        productPrice, pricePct, saleNum, saleSum, saleDate);
    return value;
  }

  public static int getProductId() {

    int proId = Integer.parseInt(product_idText.getText());
    return proId;

  }

  public static int getVipId() {

    int vipId = Integer.parseInt(vip_idText.getText());
    return vipId;

  }

  public static double getSum() {
    double sum = 0;
    sum = new StoreDao().getStorePriceById(getProductId())
        * Integer.parseInt(product_numText.getText())
        * new VipDao().getVipPctById(getVipId());
    return sum;
  }
}

⌨️ 快捷键说明

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