///Generated by GuiGenie - Copyright (c) 2004 Mario Awad.
//Home Page <a rel="nofollow" href="http://guigenie.cjb.net" target="_blank">http://guigenie.cjb.net</a> - Check often for new versions!
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class stockControlSystem extends JFrame implements ActionListener, WindowListener {
private JLabel productIdLabel;
private JTextField productIDField;
private JLabel productTypeLabel;
private JTextField productTypeField;
private JTextField productPriceField;
private JLabel productPriceLabel;
private JLabel quantityInStockLabel;
private JTextField qInStockField;
private JLabel reOrderLabel;
private JTextField reOrderField;
private JLabel reOrderQLabel;
private JTextField reOrderQField;
private JTextField costPriceField;
private JButton firstRecordButton;
private JButton addRecordButton;
private JButton searchButton;
private JButton nextButton;
private JButton clearButton;
private JButton lastRecordButton;
private JButton previousRecordButton;
private JButton deleteRecordButton;
private JLabel costLabel;
private JTextField supplierIdField;
private JLabel jcomp27;
private JLabel supplierIdLabel;
private JLabel menuTitleLabel;
//private JLabel jcomp29;
private FileOutputStream fos;
private PrintWriter out;
public stockControlSystem(String str) throws IOException{
super(str);
fos = new FileOutputStream("AccountFile.txt", true);
out = new PrintWriter(new OutputStreamWriter(fos));
//construct components
productIdLabel = new JLabel ("Product ID:");
productIDField = new JTextField (5);
productTypeLabel = new JLabel ("Product Type:");
productTypeField = new JTextField (5);
productPriceField = new JTextField (5);
productPriceLabel = new JLabel ("Product Price:");
quantityInStockLabel = new JLabel ("Quantity In Stock:");
qInStockField = new JTextField (5);
reOrderLabel = new JLabel ("Re- Order Level:");
reOrderField = new JTextField (5);
reOrderQLabel = new JLabel ("Re- Order Quantity:");
reOrderQField = new JTextField (5);
costPriceField = new JTextField (5);
firstRecordButton = new JButton ("First Record");
addRecordButton = new JButton ("Add Record");
searchButton = new JButton ("Search Record");
nextButton = new JButton ("Next Record");
clearButton = new JButton ("Clear");
lastRecordButton = new JButton ("Last Record");
previousRecordButton = new JButton ("Previous Record");
deleteRecordButton = new JButton ("Delete Record");
costLabel = new JLabel ("Cost Price:");
supplierIdField = new JTextField (5);
jcomp27 = new JLabel ("newLabel");
supplierIdLabel = new JLabel ("Supplier ID:");
menuTitleLabel = new JLabel (" ");
//adjust size and set layout
//setPreferredSize (new Dimension (448, 519));
//setLayout (null);
setSize(448,519);
//add components
add (productIdLabel);
add (productIDField);
add (productTypeLabel);
add (productTypeField);
add (productPriceField);
add (productPriceLabel);
add (quantityInStockLabel);
add (qInStockField);
add (reOrderLabel);
add (reOrderField);
add (reOrderQLabel);
add (reOrderQField);
add (costPriceField);
add (firstRecordButton);
add (addRecordButton);
add (searchButton);
add (nextButton);
add (clearButton);
add (lastRecordButton);
add (previousRecordButton);
add (deleteRecordButton);
add (costLabel);
add (supplierIdField);
add (jcomp27);
add (supplierIdLabel);
add (menuTitleLabel);
//set component bounds (only needed by Absolute Positioning)
productIdLabel.setBounds (30, 75, 100, 25);
productIDField.setBounds (160, 75, 155, 25);
productTypeLabel.setBounds (30, 110, 100, 25);
productTypeField.setBounds (160, 105, 155, 30);
productPriceField.setBounds (160, 140, 155, 25);
productPriceLabel.setBounds (35, 140, 100, 25);
quantityInStockLabel.setBounds (30, 180, 100, 25);
qInStockField.setBounds (160, 180, 155, 25);
reOrderLabel.setBounds (30, 220, 100, 25);
reOrderField.setBounds (160, 220, 155, 25);
reOrderQLabel.setBounds (25, 250, 120, 35);
reOrderQField.setBounds (160, 255, 155, 25);
costPriceField.setBounds (160, 290, 155, 25);
firstRecordButton.setBounds (15, 370, 115, 50);
addRecordButton.setBounds (135, 405, 160, 30);
searchButton.setBounds (135, 440, 160, 30);
nextButton.setBounds (305, 425, 135, 45);
clearButton.setBounds (330, 75, 100, 25);
lastRecordButton.setBounds (15, 425, 115, 45);
previousRecordButton.setBounds (305, 370, 135, 50);
deleteRecordButton.setBounds (135, 370, 160, 30);
costLabel.setBounds (25, 285, 100, 25);
supplierIdField.setBounds (160, 325, 155, 25);
jcomp27.setBounds (610, 175, 120, 25);
supplierIdLabel.setBounds (25, 320, 100, 25);
menuTitleLabel.setBounds (35, 10, 10, 35);
nextButton.addActionListener(this);
clearButton.addActionListener(this);
previousRecordButton.addActionListener(this);
addRecordButton.addActionListener(this);
deleteRecordButton.addActionListener(this);
searchButton.addActionListener(this);
lastRecordButton.addActionListener(this);
firstRecordButton.addActionListener(this);
//set window listener listening w00t
this.addWindowListener(this);
//setBackGround(Color, white);
setVisible(true);
}
public void windowActivated(WindowEvent e) {}
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e) {System.exit(0);}
public void windowDeactivated(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowOpened(WindowEvent e) {}
public void actionPerformed(ActionEvent e)
{
//Object target = e.getSource();
if (target == addRecordButton)
{
/*String s1 = productIDField.getText();
s1.trim();
out.println(s1);*/
NodeList L1 = new NodeList();
L1.insert(productIDField);
productIDField.setText("");
productTypeField.setText(L1.p1);
}
if (target == firstRecordButton)
{
}
}
class Node
{
public String productID;
/*
public String productType;
public int productPrice;
public int quantityInStock;
public int reorderLevel;
public int reorderQuanitity;
public int costPrice;
public int supplierId;*/
public Node next;
public Node(int p1)//, String p2, int p3, int p4, int p5, int p6, int p7, int p8)
{
productID = new String (p1);
/*
productType = new String[p2];
productPrice = new int[p3];
quantityInStock = new int[p4];
reorderLevel = new int[p5];
reorderQuantity = new int [p6];
costPrice = new int[p7];
supplierId = new int [p8];*/
}
public int readName(){return productID;}
}
}
class NodeList
{
private Node head;
public NodeList(){head = null;}
public void insert(String id)//String pT, int pP, int qIS, int rL, int rQ, int cP, int sId)
{
Node temp = new Node(id);//, pT, pP, qIS, rL, rQ, cP, sId);
temp.next = head;
head = temp;
}
}
public static void main (String args[]) throws IOException{
stockControlSystem F1 = new stockControlSystem("Stock Control Menu");
}
}