Esempio n. 1
0
  /** Constructor for objects of class Cart_Add */
  public Cart_Add(int itemID) {
    this.setLayout(null);
    this.setMaximumSize(new Dimension(1400, 50));
    product = invAccess.GetProductInfo(itemID);
    /** Create the DAO here */
    name = new JLabel(product.getName());
    discount = new JTextField();
    discount.setText(String.valueOf(product.getDiscount()));

    add.addActionListener(this);

    /** Absolute Positioning of the components */
    Insets insets = this.getInsets();
    /** The dimentsions of the JPanel */
    this.add(name);
    name.setBounds(25 + insets.left, 15 + insets.top, 250, 25);
    this.add(discount);
    discount.setBounds(125 + insets.left, 15 + insets.top, 75, 25);
    this.add(add);
    add.setBounds(250 + insets.left, 15 + insets.top, 85, 25);

    // this.setBorder (BorderFactory.createLineBorder(Color.black));
    product = invAccess.GetProductInfo(itemID);

    this.setVisible(true);
  }
Esempio n. 2
0
  public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    String info = "";

    if (action.equals("Add")) {
      CartFile_DAO test = new CartFile_DAO();

      info = Integer.toString(product.getId());
      info = info + " " + product.getName();
      info = info + " " + (product.getPrice() * (1 + product.getMarkup()));
      info = info + " 1";
      info = info + " " + (product.getPrice() * (1 + product.getMarkup()));

      test.write(info);
    }
  }