Upload
crash-zerocool
View
242
Download
6
Tags:
Embed Size (px)
DESCRIPTION
Appendix D-code Listing
Citation preview
LOG IN CODES/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package eosystem;
import java.awt.Color;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author arielespiritu
*/
public class LoginForm extends javax.swing.JDialog {
/**
* Creates new form LoginForm
*/
public LoginForm() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jTextField2 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Login Form");
setModal(true);
setUndecorated(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
jPanel1.setBackground(new java.awt.Color(0, 0, 0));
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(0, 0, 0), null, null));
jPanel1.setLayout(null);
jPanel3.setBackground(new java.awt.Color(255, 255, 255));
jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
jPanel3.setLayout(null);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setText("Password:");
jPanel3.add(jLabel3);
jLabel3.setBounds(20, 150, 90, 40);
jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jPasswordField1ActionPerformed(evt);
}
});
jPanel3.add(jPasswordField1);
jPasswordField1.setBounds(110, 150, 330, 40);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jPanel3.add(jTextField2);
jTextField2.setBounds(110, 90, 330, 40);
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel2.setText("Username:");
jPanel3.add(jLabel2);
jLabel2.setBounds(20, 90, 90, 40);
jButton1.setText("Login");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel3.add(jButton1);
jButton1.setBounds(240, 210, 100, 40);
jButton2.setText("Exit");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel3.add(jButton2);
jButton2.setBounds(340, 210, 100, 40);
jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 30)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Enterprise Operations System");
jPanel3.add(jLabel1);
jLabel1.setBounds(10, 10, 440, 70);
jPanel1.add(jPanel3);
jPanel3.setBounds(10, 10, 460, 270);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE)
);
setSize(new java.awt.Dimension(478, 290));
setLocationRelativeTo(null);
}//
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
System.exit(0);
config.con.close();
} catch (SQLException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void formWindowClosing(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
System.exit(1);
}
private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(MainFrame.testInet("http://www.google.com/")==false){
int n=JOptionPane.showConfirmDialog(this, "System is Offline do you want to proceed?","",JOptionPane.OK_CANCEL_OPTION);
if(n==JOptionPane.OK_OPTION){
MainFrame.isLoading=true;
config.inetConnection=false;
this.dispose();
MainFrame.isLoading=false;
}else{
System.exit(1);
}
}else{
config.inetConnection=true;
this.dispose();
}
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/* Create and display the dialog */
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel3;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}
MAINFRAME CODES
package eosystem;
import eosystem.inventory.InventoryDeployment;
import eosystem.transportation.LoginVehicle;
import eosystem.transportation.LogoutVehicle;
import eosystem.transportation.ParkingOfVehicle;
import eosystem.transportation.SettingsYard;
import eosystem.warehouse.WarehouseFrame;
import eosystem.transportation.TransportationManagement;
import eosystem.warehouse.AddCriticalLevel;
import eosystem.warehouse.AddInventoryMonitoring;
import eosystem.warehouse.AddWarehouseFrame;
import eosystem.warehouse.CriticalLevel;
import eosystem.transportation.GPSTracking;
import eosystem.warehouse.AddBOProducts;
import eosystem.warehouse.AddPurchaseRequest;
import eosystem.warehouse.BOProductList;
import eosystem.warehouse.FormsFrame;
import eosystem.warehouse.InventoryDetails;
import eosystem.warehouse.JobOrders;
import eosystem.warehouse.MonitoringInventory;
import eosystem.warehouse.ProductIn;
import eosystem.warehouse.PurchaseRequest;
import eosystem.warehouse.ReportsFrame;
import eosystem.warehouse.WarehouseFrame;
import eosystem.warehouse.WarehouseList;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import java.net.URLConnection;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.RectangleInsets;
import org.jfree.util.Rotation;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author arielespiritu
*/
public class MainFrame extends javax.swing.JFrame {
/**
* Creates new form MainFrame
*/
public static SimpleDateFormat dateFormat,timeFormat;
public static Date date;
JFreeChart pieChart;
ChartPanel chartPanel;
public DepartmentFrame department;
public DepartmentList departmentList;
public EmployeeFrame employee;
public AddEmployee addEmployee;
public ViewContactDetail contactDetail;
public ViewAddressDetails addressDetail;
public CompanyList companyList;
public AddCompany addCompany;
public SupplierList supplierList;
public AddSupplier addSupplier;
public ProductList prodList;
public AddProduct addProduct;
public ProdCategoryList prodCatList;
public AddProdCategory addProdCat;
public ViewProductDetails viewProdDetails;
public PositionFrame position;
public AddPostion addPosition;
public static LoadingFrame load;
public TransportationManagement transport;
public GPSTracking gps;
public SettingsYard yard;
public ParkingOfVehicle parking;
public WarehouseFrame warehouse;
public CriticalLevel crit;
public AddCriticalLevel addcrit;
public AddInventoryMonitoring addMonitoring;
public MonitoringInventory monitoring;
public AddWarehouseFrame addWarehouse;
public InventoryDetails inventoryDetails;
public ProductIn prodin;
public WarehouseList whlist;
public LoginVehicle loginV;
public LogoutVehicle logoutV;
public InventoryDeployment invDeployment;
public BOProductList boList;
public AddBOProducts addBO;
public FormsFrame forms;
public ReportsFrame reports;
public PurchaseRequest purchaseRequest;
public AddPurchaseRequest addPurRequest;
public JobOrders jobOrder;
private static final long serialVersionUID = 1L;
public static boolean isLoading=false;
int width =0;
int height=0;
public MainFrame() {
new LoginForm().setVisible(true);
load=new LoadingFrame();
load.setVisible(false);
initComponents();
warehouse = new WarehouseFrame(this);
warehouse.setVisible(false);
deskPane.add(warehouse);
crit=new CriticalLevel(this);
crit.setVisible(false);
deskPane.add(crit);
addcrit=new AddCriticalLevel(this);
addcrit.setVisible(false);
deskPane.add(addcrit);
addMonitoring=new AddInventoryMonitoring(this);
addMonitoring.setVisible(false);
deskPane.add(addMonitoring);
monitoring=new MonitoringInventory(this);
monitoring.setVisible(false);
deskPane.add(monitoring);
addWarehouse=new AddWarehouseFrame(this);
addWarehouse.setVisible(false);
deskPane.add(addWarehouse);
inventoryDetails=new InventoryDetails(this);
inventoryDetails.setVisible(false);
deskPane.add(inventoryDetails);
prodin=new ProductIn(this);
prodin.setVisible(false);
deskPane.add(prodin);
whlist=new WarehouseList(this);
whlist.setVisible(false);
deskPane.add(whlist);
transport=new TransportationManagement(this);
transport.setVisible(false);
deskPane.add(transport);
gps=new GPSTracking(this);
gps.setVisible(false);
deskPane.add(gps);
yard=new SettingsYard(this);
yard.setVisible(false);
deskPane.add(yard);
parking=new ParkingOfVehicle(this);
parking.setVisible(false);
deskPane.add(parking);
loginV=new LoginVehicle(this);
loginV.setVisible(false);
deskPane.add(loginV);
logoutV=new LogoutVehicle(this);
logoutV.setVisible(false);
deskPane.add(logoutV);
department=new DepartmentFrame(this);
department.setVisible(false);
deskPane.add(department);
departmentList=new DepartmentList(this);
departmentList.setVisible(false);
deskPane.add(departmentList);
employee=new EmployeeFrame(this);
employee.setVisible(false);
deskPane.add(employee);
addEmployee=new AddEmployee(this);
addEmployee.setVisible(false);
deskPane.add(addEmployee);
position=new PositionFrame(this);
position.setVisible(false);
deskPane.add(position);
addPosition=new AddPostion(this);
addPosition.setVisible(false);
deskPane.add(addPosition);
contactDetail=new ViewContactDetail(this);
contactDetail.setVisible(false);
deskPane.add(contactDetail);
addressDetail=new ViewAddressDetails(this);
addressDetail.setVisible(false);
deskPane.add(addressDetail);
companyList=new CompanyList(this);
companyList.setVisible(false);
deskPane.add(companyList);
addCompany=new AddCompany(this);
addCompany.setVisible(false);
deskPane.add(addCompany);
supplierList=new SupplierList(this);
supplierList.setVisible(false);
deskPane.add(supplierList);
addSupplier=new AddSupplier(this);
addSupplier.setVisible(false);
deskPane.add(addSupplier);
prodList=new ProductList(this);
prodList.setVisible(false);
deskPane.add(prodList);
addProduct=new AddProduct(this);
addProduct.setVisible(false);
deskPane.add(addProduct);
prodCatList=new ProdCategoryList(this);
prodCatList.setVisible(false);
deskPane.add(prodCatList);
addProdCat=new AddProdCategory(this);
addProdCat.setVisible(false);
deskPane.add(addProdCat);
viewProdDetails=new ViewProductDetails(this);
viewProdDetails.setVisible(false);
deskPane.add(viewProdDetails);
boList=new BOProductList(this);
boList.setVisible(false);
deskPane.add(boList);
addBO=new AddBOProducts(this);
addBO.setVisible(false);
deskPane.add(addBO);
forms=new FormsFrame(this);
forms.setVisible(false);
deskPane.add(forms);
reports=new ReportsFrame(this);
reports.setVisible(false);
deskPane.add(reports);
purchaseRequest=new PurchaseRequest(this);
purchaseRequest.setVisible(false);
deskPane.add(purchaseRequest);
addPurRequest=new AddPurchaseRequest(this);
addPurRequest.setVisible(false);
deskPane.add(addPurRequest);
jobOrder=new JobOrders(this);
jobOrder.setVisible(false);
deskPane.add(jobOrder);
invDeployment=new InventoryDeployment(this);
invDeployment.setVisible(false);
deskPane.add(invDeployment);
this.setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
if(config.inetConnection=true){
internetStatus.setForeground(Color.GREEN);
internetStatus.setText("Online");
}else{
internetStatus.setForeground(Color.RED);
internetStatus.setText("Offline");
}
Thread t = new Thread(new Runnable(){
@Override
public void run(){
boolean bool =true;
while(true){
dateTime.setText(getDate()+" "+getTime());
//// if(bool==true){
//// chartsPanel.removeAll();
//// pieChart = ChartFactory.createBarChart("Orders", "", "Score", createDataset(),PlotOrientation.VERTICAL, true, true, false);
//// chartPanel = new ChartPanel(pieChart);
//// pieChart.removeLegend();
//// chartPanel.setBounds(5, 5, chartsPanel.getWidth()-10, chartsPanel.getHeight()-10);
//// chartsPanel.add(chartPanel);
//// chartsPanel.repaint();
//// bool =false;
//// }
try{Thread.sleep(1000);}catch(Exception e){}
}
}
});t.start();
Thread t2 = new Thread(new Runnable(){
@Override
public void run(){
while(true){
checkInternet();
try{Thread.sleep(20000);}catch(Exception e){}
}
}
});t2.start();
Thread desktop = new Thread(new Runnable(){
@Override
public void run(){
while(true){
width=deskPane.getWidth();
height=deskPane.getHeight();
desktopLbl.setBounds(0, 0, width, height);
// getImageForProduct();
deskPane.setPosition(desktopLbl, -1);
try{Thread.sleep(500);}catch(Exception e){}
}
}
});desktop.start();
Thread loads = new Thread(new Runnable(){
@Override
public void run(){
while(true){
if(isLoading==true){
load.setVisible(true);
Graphics graph=load.getGraphics();
load.paint(graph);
load.setAlwaysOnTop(true);
}else if(isLoading==false){
load.setVisible(false);
load.setAlwaysOnTop(false);
}
try{Thread.sleep(1000);}catch(Exception e){}
}
}
});loads.start();
}
//////////////////////////////////////////methods////////////////////////////////////////
// public void getImageForProduct(){
// File file;
// BufferedImage bi;
//
// boolean withImage=false;
//
// try{
// file = new File("/eosystem/icon/desktop2.jpg");
// bi=ImageIO.read(file);
// bi= resizeImage(bi,bi.getType() == 0? BufferedImage.TYPE_INT_ARGB : bi.getType(),width,height);
// desktopLbl.setText("");
// desktopLbl.setIcon(new ImageIcon(bi));
//
// }catch(Exception ee){
//
// }
//
//
// }
// public static BufferedImage resizeImage(BufferedImage originalImage, int type,int IMG_WIDTH,int IMG_HEIGHT){
//BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
//Graphics2D g = resizedImage.createGraphics();
//g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
//g.dispose();
//
//return resizedImage;
// }
public void createGraph(){
invDeployment.chartsPanel.removeAll();
pieChart = ChartFactory.createBarChart("Over All Product Inventory", "", "Quantity", createDataset(invDeployment.products,invDeployment.quantity,invDeployment.unit),PlotOrientation.VERTICAL, true, true, false);
chartPanel = new ChartPanel(pieChart);
pieChart.removeLegend();
chartPanel.setBounds(5, 5, invDeployment.chartsPanel.getWidth()-10, invDeployment.chartsPanel.getHeight()-10);
invDeployment.chartsPanel.add(chartPanel);
invDeployment.chartsPanel.repaint();
}
private CategoryDataset createDataset(ArrayList product,ArrayList quantity,ArrayList unit) {
final String mon = "Over All";
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
int n =0;
for(int x=0;x