├── screenshots ├── history.jpg ├── products.jpg ├── customers.jpg ├── dashboard.jpg ├── login_page.jpg └── edit_profile.jpg ├── run.bat ├── Start.java ├── attr ├── Database.java ├── Theme.java ├── User.java ├── Employee.java ├── Product.java └── Customer.java ├── README.md ├── activity ├── ChangePasswordActivity.java ├── MyProductActivity.java ├── CustomerActivity.java ├── LoginActivity.java ├── EmployeeActivity.java ├── ManageCustomer.java ├── ViewCustomerActivity.java ├── ManageEmployee.java ├── AddProductActivity.java ├── ViewEmployeeActivity.java ├── SignupActivity.java ├── ManageProduct.java ├── AddEmployeeActivity.java ├── ViewProductActivity.java └── MyProfileActivity.java ├── sql └── f1.sql └── LICENSE /screenshots/history.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deba1/Shop-Management-System/HEAD/screenshots/history.jpg -------------------------------------------------------------------------------- /screenshots/products.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deba1/Shop-Management-System/HEAD/screenshots/products.jpg -------------------------------------------------------------------------------- /screenshots/customers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deba1/Shop-Management-System/HEAD/screenshots/customers.jpg -------------------------------------------------------------------------------- /screenshots/dashboard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deba1/Shop-Management-System/HEAD/screenshots/dashboard.jpg -------------------------------------------------------------------------------- /screenshots/login_page.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deba1/Shop-Management-System/HEAD/screenshots/login_page.jpg -------------------------------------------------------------------------------- /screenshots/edit_profile.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deba1/Shop-Management-System/HEAD/screenshots/edit_profile.jpg -------------------------------------------------------------------------------- /run.bat: -------------------------------------------------------------------------------- 1 | del activity\*.class 2 | del attr\*.class 3 | javac *.java 4 | java Start 5 | del activity\*.class 6 | del attr\*.class 7 | del *.class -------------------------------------------------------------------------------- /Start.java: -------------------------------------------------------------------------------- 1 | import java.lang.*; 2 | import activity.*; 3 | 4 | public class Start { 5 | public static void main(String args[]) { 6 | LoginActivity la = new LoginActivity(); 7 | la.setVisible(true); 8 | } 9 | } -------------------------------------------------------------------------------- /attr/Database.java: -------------------------------------------------------------------------------- 1 | package attr; 2 | 3 | public class Database { 4 | public static final String HOST_URI = "jdbc:mysql://localhost:3306/f1"; 5 | public static final String USER = "root"; 6 | public static final String PASSWORD = ""; 7 | } -------------------------------------------------------------------------------- /attr/Theme.java: -------------------------------------------------------------------------------- 1 | package attr; 2 | 3 | import java.awt.*; 4 | 5 | public class Theme { 6 | public static final int GUI_WIDTH = 800; 7 | public static final int GUI_HEIGHT = 600; 8 | public static final int BUTTON_PRIMARY_WIDTH = 100; 9 | 10 | public static final Color BACKGROUND_PANEL = new Color(250, 250, 250); 11 | public static final Color BACKGROUND_HEADER = new Color(0, 11, 106); 12 | public static final Color COLOR_TITLE = new Color(0, 11, 106); 13 | public static final Color COLOR_BUTTON_PRIMARY = new Color(255, 255, 255); 14 | public static final Color BACKGROUND_BUTTON_PRIMARY = new Color(0, 11, 106); 15 | 16 | public static final Font FONT_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 40); 17 | public static final Font FONT_BUTTON = new Font(Font.SANS_SERIF, Font.BOLD, 14); 18 | public static final Font FONT_REGULAR = new Font(Font.SANS_SERIF, Font.PLAIN, 20); 19 | public static final Font FONT_INPUT = new Font(Font.SANS_SERIF, Font.PLAIN, 16); 20 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Shop-Management-System 2 | ---------------------- 3 | **Description:** 4 | 5 | Shop Management System implemented in __Java__ and __MySQL__ 6 | 7 | _Supervisor:_ 8 | 9 |     Mohaimen-Bin-Noor,
10 |     Assistant Professor, Department of Computer Science,
11 |     Assistant ProfessorAmerican International University-Bangladesh 12 | 13 | **Features:** 14 | * Login for Manager, Employee and Customer 15 | * Admin can add new Employee and Customer with Randomly Generated Password 16 | * Manager can edit Employee and Customer Information 17 | * Manager can add, edit and delete Products 18 | * Employee can sell products* 19 | * Customer can check products and view own purchase history 20 | 21 | **Used Tools:** 22 | * Notepad++ 23 | * XAMPP 24 | 25 | **Screenshots:** 26 | 27 | 28 | 29 | _Login Page_ 30 | 31 | 32 | 33 | _Manager Dashboard_ 34 | 35 | 36 | 37 | _Profile Edit_ 38 | 39 | 40 | 41 | _Purchase History_ 42 | 43 | 44 | 45 | _Customer Management_ 46 | 47 | 48 | 49 | _Product Management_ 50 | -------------------------------------------------------------------------------- /activity/ChangePasswordActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import attr.*; 8 | 9 | public class ChangePasswordActivity extends JFrame implements ActionListener { 10 | private User user; 11 | private JPanel panel; 12 | private JLabel oldLabel, newLabel; 13 | private JPasswordField oldPF, newPF; 14 | private JButton buttonSubmit, buttonCancel; 15 | 16 | public ChangePasswordActivity(User user) { 17 | super("Change Password"); 18 | 19 | this.setSize(500,200); 20 | this.setResizable(false); 21 | this.setLocationRelativeTo(null); 22 | 23 | this.user = user; 24 | 25 | panel = new JPanel(); 26 | panel.setLayout(null); 27 | 28 | oldLabel = new JLabel("Old Password: "); 29 | oldLabel.setBounds(40, 20, 150, 30); 30 | oldLabel.setFont(Theme.FONT_INPUT); 31 | panel.add(oldLabel); 32 | 33 | oldPF = new JPasswordField(); 34 | oldPF.setBounds(160, 20, 280, 30); 35 | oldPF.setFont(Theme.FONT_INPUT); 36 | panel.add(oldPF); 37 | 38 | newLabel = new JLabel("New Password: "); 39 | newLabel.setBounds(40, 70, 150, 30); 40 | newLabel.setFont(Theme.FONT_INPUT); 41 | panel.add(newLabel); 42 | 43 | newPF = new JPasswordField(); 44 | newPF.setBounds(160, 70, 280, 30); 45 | newPF.setFont(Theme.FONT_INPUT); 46 | panel.add(newPF); 47 | 48 | buttonSubmit = new JButton("Change"); 49 | buttonSubmit.setBounds(90, 120, Theme.BUTTON_PRIMARY_WIDTH,30); 50 | buttonSubmit.setFont(Theme.FONT_BUTTON); 51 | buttonSubmit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 52 | buttonSubmit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 53 | buttonSubmit.addActionListener(this); 54 | panel.add(buttonSubmit); 55 | 56 | buttonCancel = new JButton("Cancel"); 57 | buttonCancel.setBounds(300, 120, Theme.BUTTON_PRIMARY_WIDTH,30); 58 | buttonCancel.setFont(Theme.FONT_BUTTON); 59 | buttonCancel.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 60 | buttonCancel.setForeground(Theme.COLOR_BUTTON_PRIMARY); 61 | buttonCancel.addActionListener(this); 62 | panel.add(buttonCancel); 63 | 64 | this.add(panel); 65 | } 66 | 67 | public void actionPerformed(ActionEvent ae) { 68 | if (ae.getSource().equals(buttonSubmit)) { 69 | user.changePassword(this, oldPF.getText(), newPF.getText()); 70 | } 71 | else if (ae.getSource().equals(buttonCancel)) { 72 | this.setVisible(false); 73 | } 74 | else {} 75 | } 76 | } -------------------------------------------------------------------------------- /activity/MyProductActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import java.util.*; 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import javax.swing.border.*; 8 | import java.awt.event.*; 9 | import javax.swing.table.*; 10 | import attr.*; 11 | 12 | public class MyProductActivity extends JFrame implements ActionListener { 13 | private JPanel panel; 14 | private Customer customer; 15 | private JFrame activity; 16 | private JScrollPane frame; 17 | private JTable table; 18 | private JButton buttonLogout, buttonBack, buttonCheck; 19 | private JLabel title, header, keywordLabel, productNameLabel, productQtLabel, productPriceLabel; 20 | private JTextField keywordTF, productNameTF, productQtTF, productPriceTF; 21 | public MyProductActivity(JFrame prev, Customer customer) { 22 | super("Purchase History"); 23 | 24 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 25 | this.setResizable(false); 26 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 27 | this.setLocationRelativeTo(null); 28 | this.activity = prev; 29 | this.customer = customer; 30 | 31 | panel = new JPanel(); 32 | panel.setLayout(null); 33 | panel.setBackground(Theme.BACKGROUND_PANEL); 34 | 35 | title = new JLabel("Purchase History"); 36 | title.setBounds(30, 40, 480,75); 37 | title.setOpaque(true); 38 | title.setBorder(new EmptyBorder(0,20,0,0)); 39 | title.setFont(Theme.FONT_TITLE); 40 | title.setForeground(Theme.COLOR_TITLE); 41 | panel.add(title); 42 | 43 | buttonLogout = new JButton("Logout"); 44 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 45 | buttonLogout.setFont(Theme.FONT_BUTTON); 46 | buttonLogout.setBackground(Color.WHITE); 47 | buttonLogout.setForeground(Theme.COLOR_TITLE); 48 | buttonLogout.addActionListener(this); 49 | panel.add(buttonLogout); 50 | 51 | buttonBack = new JButton("Back"); 52 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 53 | buttonBack.setFont(Theme.FONT_BUTTON); 54 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 55 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 56 | buttonBack.addActionListener(this); 57 | panel.add(buttonBack); 58 | 59 | table = new JTable(); 60 | table.setModel(customer.myProduct()); 61 | frame = new JScrollPane(table); 62 | frame.setBounds(40,140,600,300); 63 | panel.add(frame); 64 | 65 | header = new JLabel(); 66 | header.setBackground(Theme.BACKGROUND_HEADER); 67 | header.setOpaque(true); 68 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 69 | panel.add(header); 70 | 71 | this.add(panel); 72 | } 73 | 74 | public void actionPerformed(ActionEvent ae) { 75 | if (ae.getSource().equals(buttonLogout)) { 76 | this.setVisible(false); 77 | new LoginActivity().setVisible(true); 78 | } 79 | else if (ae.getSource().equals(buttonBack)) { 80 | this.setVisible(false); 81 | activity.setVisible(true); 82 | } 83 | else {} 84 | } 85 | 86 | private void jTable_ClickMouseClicked(MouseEvent evt) { 87 | 88 | } 89 | } -------------------------------------------------------------------------------- /activity/CustomerActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.border.*; 7 | import java.awt.event.*; 8 | import java.sql.*; 9 | import attr.*; 10 | 11 | public class CustomerActivity extends JFrame implements ActionListener { 12 | private JPanel panel; 13 | private Customer customer; 14 | private JButton buttonLogout, buttonProfile, buttonViewProduct, buttonMyProduct; 15 | private JLabel title, header; 16 | public CustomerActivity(String userId) { 17 | super("Dashboard - Customer"); 18 | 19 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 20 | this.setResizable(false); 21 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 22 | this.setLocationRelativeTo(null); 23 | 24 | panel = new JPanel(); 25 | panel.setLayout(null); 26 | panel.setBackground(Theme.BACKGROUND_PANEL); 27 | 28 | customer = new Customer(userId); 29 | customer.fetch(); 30 | 31 | title = new JLabel("Welcome, "+userId); 32 | title.setBounds(30, 40, userId.length()*30+220,75); 33 | title.setOpaque(true); 34 | title.setBorder(new EmptyBorder(0,20,0,0)); 35 | title.setFont(Theme.FONT_TITLE); 36 | title.setForeground(Theme.COLOR_TITLE); 37 | panel.add(title); 38 | 39 | buttonLogout = new JButton("Logout"); 40 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 41 | buttonLogout.setFont(Theme.FONT_BUTTON); 42 | buttonLogout.setBackground(Color.WHITE); 43 | buttonLogout.setForeground(Theme.COLOR_TITLE); 44 | buttonLogout.addActionListener(this); 45 | panel.add(buttonLogout); 46 | 47 | buttonProfile = new JButton("My Profile"); 48 | buttonProfile.setBounds(Theme.GUI_WIDTH-150, 80, 120,30); 49 | buttonProfile.setFont(Theme.FONT_BUTTON); 50 | buttonProfile.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 51 | buttonProfile.setForeground(Theme.COLOR_BUTTON_PRIMARY); 52 | buttonProfile.addActionListener(this); 53 | panel.add(buttonProfile); 54 | 55 | buttonViewProduct = new JButton("View Product"); 56 | buttonViewProduct.setBounds(60, 160, 200, 30); 57 | buttonViewProduct.setFont(Theme.FONT_BUTTON); 58 | buttonViewProduct.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 59 | buttonViewProduct.setForeground(Theme.COLOR_BUTTON_PRIMARY); 60 | buttonViewProduct.addActionListener(this); 61 | panel.add(buttonViewProduct); 62 | 63 | buttonMyProduct = new JButton("Purchase History"); 64 | buttonMyProduct.setBounds(60, 190, 200, 30); 65 | buttonMyProduct.setFont(Theme.FONT_BUTTON); 66 | buttonMyProduct.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 67 | buttonMyProduct.setForeground(Theme.COLOR_BUTTON_PRIMARY); 68 | buttonMyProduct.addActionListener(this); 69 | panel.add(buttonMyProduct); 70 | 71 | header = new JLabel(); 72 | header.setBackground(Theme.BACKGROUND_HEADER); 73 | header.setOpaque(true); 74 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 75 | panel.add(header); 76 | 77 | this.add(panel); 78 | } 79 | 80 | public void actionPerformed(ActionEvent ae) { 81 | if (ae.getSource().equals(buttonProfile)) { 82 | this.setVisible(false); 83 | new MyProfileActivity(this, customer).setVisible(true); 84 | } 85 | else if (ae.getSource().equals(buttonLogout)) { 86 | this.setVisible(false); 87 | new LoginActivity().setVisible(true); 88 | } 89 | else if (ae.getSource().equals(buttonViewProduct)) { 90 | this.setVisible(false); 91 | new ViewProductActivity(this, customer).setVisible(true); 92 | } 93 | else if (ae.getSource().equals(buttonMyProduct)) { 94 | this.setVisible(false); 95 | new MyProductActivity(this, customer).setVisible(true); 96 | } 97 | else {} 98 | } 99 | } -------------------------------------------------------------------------------- /attr/User.java: -------------------------------------------------------------------------------- 1 | package attr; 2 | 3 | import java.lang.*; 4 | import java.sql.*; 5 | import attr.*; 6 | import javax.swing.*; 7 | import activity.*; 8 | 9 | public abstract class User { 10 | protected String userId; 11 | protected String password; 12 | protected int status; 13 | 14 | public User(String userId) { 15 | if (!userId.isEmpty()) 16 | this.userId = userId; 17 | else 18 | throw new IllegalArgumentException("Fill in the User ID"); 19 | } 20 | 21 | public abstract void fetch(); 22 | 23 | public String getUserId() { 24 | return userId; 25 | } 26 | public void setStatus(int stts) { 27 | this.status = stts; 28 | } 29 | public void setPassword(String passwd) { 30 | if (!passwd.isEmpty()) 31 | this.password = passwd; 32 | else 33 | throw new IllegalArgumentException("Fill in the password"); 34 | } 35 | 36 | public static int checkStatus(String uid, String pass) { 37 | int result = -1; 38 | String query = "SELECT `userId`, `password`, `status` FROM `login`;"; 39 | Connection con = null; 40 | Statement st = null; 41 | ResultSet rs = null; 42 | System.out.println(query); 43 | try { 44 | Class.forName("com.mysql.jdbc.Driver"); 45 | System.out.println("driver loaded"); 46 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 47 | System.out.println("connection done");//connection with database established 48 | st = con.createStatement();//create statement 49 | System.out.println("statement created"); 50 | rs = st.executeQuery(query);//getting result 51 | System.out.println("results received"); 52 | 53 | while(rs.next()) { 54 | String userId = rs.getString("userId"); 55 | String password = rs.getString("password"); 56 | int status = rs.getInt("status"); 57 | 58 | if(userId.equals(uid) && password.equals(pass)) { 59 | result = status; 60 | } 61 | } 62 | } 63 | catch(Exception ex) { 64 | System.out.println("Exception : " +ex.getMessage()); 65 | ex.printStackTrace(); 66 | } 67 | finally { 68 | try { 69 | if(rs!=null) 70 | rs.close(); 71 | 72 | if(st!=null) 73 | st.close(); 74 | 75 | if(con!=null) 76 | con.close(); 77 | } 78 | catch(Exception ex) {} 79 | } 80 | return result; 81 | } 82 | 83 | public void changePassword(ChangePasswordActivity a, String oldPass, String newPass) { 84 | String query = "UPDATE `login` SET `password`='"+newPass+"' WHERE (`userId`='"+this.userId+"' AND `password`='"+oldPass+"');"; 85 | Connection con = null; 86 | Statement st = null; 87 | System.out.println(query); 88 | try { 89 | Class.forName("com.mysql.jdbc.Driver"); 90 | System.out.println("driver loaded"); 91 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 92 | System.out.println("connection done");//connection with database established 93 | st = con.createStatement();//create statement 94 | System.out.println("statement created"); 95 | int res = st.executeUpdate(query);//insert 96 | System.out.println("data inserted"); 97 | if (res > 0) { 98 | JOptionPane.showMessageDialog(null,"Password Updated!"); 99 | a.setVisible(false); 100 | } 101 | else { 102 | JOptionPane.showMessageDialog(null,"Password didn't match!"); 103 | } 104 | } 105 | catch(Exception ex) { 106 | System.out.println("Exception : " +ex.getMessage()); 107 | } 108 | finally { 109 | try { 110 | if(st!=null) 111 | st.close(); 112 | 113 | if(con!=null) 114 | con.close(); 115 | } 116 | catch(Exception ex) {} 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /activity/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.border.*; 7 | import java.awt.event.*; 8 | import attr.*; 9 | 10 | public class LoginActivity extends JFrame implements ActionListener { 11 | private JPanel panel; 12 | private JButton buttonExit, buttonLogin, buttonSignup; 13 | private JLabel title, header, usernameLabel, passwordLabel; 14 | private JTextField usernameTF; 15 | private JPasswordField passwordF; 16 | public LoginActivity() { 17 | super("Login"); 18 | 19 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 20 | this.setResizable(false); 21 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 22 | this.setLocationRelativeTo(null); 23 | 24 | panel = new JPanel(); 25 | panel.setLayout(null); 26 | panel.setBackground(Theme.BACKGROUND_PANEL); 27 | 28 | title = new JLabel("Shop Management System"); 29 | title.setBounds(30, 40, 555, 75); 30 | title.setOpaque(true); 31 | title.setBorder(new EmptyBorder(0,20,0,0)); 32 | title.setFont(Theme.FONT_TITLE); 33 | title.setForeground(Theme.COLOR_TITLE); 34 | panel.add(title); 35 | 36 | buttonExit = new JButton("Exit"); 37 | buttonExit.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 38 | buttonExit.setFont(Theme.FONT_BUTTON); 39 | buttonExit.setBackground(Color.WHITE); 40 | buttonExit.setForeground(Theme.COLOR_TITLE); 41 | buttonExit.addActionListener(this); 42 | panel.add(buttonExit); 43 | 44 | buttonSignup = new JButton("Sign up"); 45 | buttonSignup.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 46 | buttonSignup.setFont(Theme.FONT_BUTTON); 47 | buttonSignup.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 48 | buttonSignup.setForeground(Theme.COLOR_BUTTON_PRIMARY); 49 | buttonSignup.addActionListener(this); 50 | panel.add(buttonSignup); 51 | 52 | usernameLabel = new JLabel("User ID: "); 53 | usernameLabel.setBounds(210, 220, 120, 30); 54 | usernameLabel.setFont(Theme.FONT_REGULAR); 55 | panel.add(usernameLabel); 56 | 57 | usernameTF = new JTextField(); 58 | usernameTF.setBounds(330, 220, 220, 30); 59 | usernameTF.setFont(Theme.FONT_INPUT); 60 | panel.add(usernameTF); 61 | 62 | passwordLabel = new JLabel("Password: "); 63 | passwordLabel.setBounds(210, 280, 120, 30); 64 | passwordLabel.setFont(Theme.FONT_REGULAR); 65 | panel.add(passwordLabel); 66 | 67 | passwordF = new JPasswordField(); 68 | passwordF.setBounds(330, 280, 220, 30); 69 | passwordF.setFont(Theme.FONT_INPUT); 70 | panel.add(passwordF); 71 | 72 | buttonLogin = new JButton("Login"); 73 | buttonLogin.setBounds(230, 345, 300, 30); 74 | buttonLogin.setFont(Theme.FONT_BUTTON); 75 | buttonLogin.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 76 | buttonLogin.setForeground(Theme.COLOR_BUTTON_PRIMARY); 77 | buttonLogin.addActionListener(this); 78 | panel.add(buttonLogin); 79 | 80 | header = new JLabel(); 81 | header.setBackground(Theme.BACKGROUND_HEADER); 82 | header.setOpaque(true); 83 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 84 | panel.add(header); 85 | 86 | this.add(panel); 87 | } 88 | 89 | public void actionPerformed(ActionEvent ae) { 90 | if (ae.getSource().equals(buttonExit)) 91 | System.exit(0); 92 | else if (ae.getSource().equals(buttonSignup)) { 93 | this.setVisible(false); 94 | new SignupActivity().setVisible(true); 95 | } 96 | else if (ae.getSource().equals(buttonLogin)) { 97 | int status = User.checkStatus(usernameTF.getText(), passwordF.getText()); 98 | if (status == 0) { 99 | EmployeeActivity ea = new EmployeeActivity(usernameTF.getText()); 100 | ea.setVisible(true); 101 | this.setVisible(false); 102 | } 103 | else if (status == 1) { 104 | CustomerActivity ca = new CustomerActivity(usernameTF.getText()); 105 | ca.setVisible(true); 106 | this.setVisible(false); 107 | } 108 | else { 109 | JOptionPane.showMessageDialog(this,"Invalid ID or Password"); 110 | } 111 | } 112 | else {} 113 | } 114 | } -------------------------------------------------------------------------------- /activity/EmployeeActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.border.*; 7 | import java.awt.event.*; 8 | import attr.*; 9 | 10 | public class EmployeeActivity extends JFrame implements ActionListener { 11 | private JPanel panel; 12 | private Employee employee; 13 | private JButton buttonLogout, buttonProfile, buttonViewProduct; 14 | private JButton buttonViewCustomer, buttonViewEmployee; 15 | private JLabel title, header; 16 | public EmployeeActivity(String userId) { 17 | super("Dashboard - Employee"); 18 | 19 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 20 | this.setResizable(false); 21 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 22 | this.setLocationRelativeTo(null); 23 | 24 | employee = new Employee(userId); 25 | employee.fetch(); 26 | 27 | panel = new JPanel(); 28 | panel.setLayout(null); 29 | panel.setBackground(Theme.BACKGROUND_PANEL); 30 | 31 | title = new JLabel("Welcome, "+userId); 32 | title.setBounds(30, 40, userId.length()*30+220,75); 33 | title.setOpaque(true); 34 | title.setBorder(new EmptyBorder(0,20,0,0)); 35 | title.setFont(Theme.FONT_TITLE); 36 | title.setForeground(Theme.COLOR_TITLE); 37 | panel.add(title); 38 | 39 | buttonLogout = new JButton("Logout"); 40 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 41 | buttonLogout.setFont(Theme.FONT_BUTTON); 42 | buttonLogout.setBackground(Color.WHITE); 43 | buttonLogout.setForeground(Theme.COLOR_TITLE); 44 | buttonLogout.addActionListener(this); 45 | panel.add(buttonLogout); 46 | 47 | buttonProfile = new JButton("My Profile"); 48 | buttonProfile.setBounds(Theme.GUI_WIDTH-150, 80, 120,30); 49 | buttonProfile.setFont(Theme.FONT_BUTTON); 50 | buttonProfile.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 51 | buttonProfile.setForeground(Theme.COLOR_BUTTON_PRIMARY); 52 | buttonProfile.addActionListener(this); 53 | panel.add(buttonProfile); 54 | 55 | buttonViewProduct = new JButton("View Product"); 56 | buttonViewProduct.setBounds(60, 160, 200, 30); 57 | buttonViewProduct.setFont(Theme.FONT_BUTTON); 58 | buttonViewProduct.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 59 | buttonViewProduct.setForeground(Theme.COLOR_BUTTON_PRIMARY); 60 | buttonViewProduct.addActionListener(this); 61 | panel.add(buttonViewProduct); 62 | 63 | buttonViewCustomer = new JButton("View Customer"); 64 | buttonViewCustomer.setBounds(60, 190, 200, 30); 65 | buttonViewCustomer.setFont(Theme.FONT_BUTTON); 66 | buttonViewCustomer.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 67 | buttonViewCustomer.setForeground(Theme.COLOR_BUTTON_PRIMARY); 68 | buttonViewCustomer.addActionListener(this); 69 | panel.add(buttonViewCustomer); 70 | 71 | if (employee.getRole().equals("Manager")) { 72 | buttonViewEmployee = new JButton("View Employee"); 73 | buttonViewEmployee.setBounds(60, 220, 200, 30); 74 | buttonViewEmployee.setFont(Theme.FONT_BUTTON); 75 | buttonViewEmployee.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 76 | buttonViewEmployee.setForeground(Theme.COLOR_BUTTON_PRIMARY); 77 | buttonViewEmployee.addActionListener(this); 78 | panel.add(buttonViewEmployee); 79 | } 80 | 81 | header = new JLabel(); 82 | header.setBackground(Theme.BACKGROUND_HEADER); 83 | header.setOpaque(true); 84 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 85 | panel.add(header); 86 | 87 | this.add(panel); 88 | } 89 | 90 | public void actionPerformed(ActionEvent ae) { 91 | if (ae.getSource().equals(buttonProfile)) { 92 | this.setVisible(false); 93 | new MyProfileActivity(this, employee).setVisible(true); 94 | } 95 | else if (ae.getSource().equals(buttonLogout)) { 96 | this.setVisible(false); 97 | new LoginActivity().setVisible(true); 98 | } 99 | else if (ae.getSource().equals(buttonViewProduct)) { 100 | this.setVisible(false); 101 | new ViewProductActivity(this, employee).setVisible(true); 102 | } 103 | else if (ae.getSource().equals(buttonViewCustomer)) { 104 | this.setVisible(false); 105 | new ViewCustomerActivity(this, employee).setVisible(true); 106 | } 107 | else if (ae.getSource().equals(buttonViewEmployee)) { 108 | this.setVisible(false); 109 | new ViewEmployeeActivity(this, employee).setVisible(true); 110 | } 111 | else {} 112 | } 113 | } -------------------------------------------------------------------------------- /activity/ManageCustomer.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import attr.*; 8 | 9 | public class ManageCustomer extends JFrame implements ActionListener { 10 | private JPanel panel; 11 | ViewCustomerActivity prev; 12 | private Customer customer; 13 | private JButton buttonBack, buttonEdit, buttonDelete; 14 | private JLabel title, header, userIdLabel, customerNameLabel, phoneNumberLabel, addressLabel; 15 | private JTextField userIdTF, customerNameTF, phoneNumberTF, phoneCodeTF, addressTF; 16 | 17 | public ManageCustomer(String cid, ViewCustomerActivity prev) { 18 | super("Manage Customer"); 19 | 20 | this.setSize(500,400); 21 | this.setResizable(false); 22 | this.setLocationRelativeTo(null); 23 | this.prev = prev; 24 | 25 | customer = new Customer(cid); 26 | customer.fetch(); 27 | 28 | panel = new JPanel(); 29 | panel.setLayout(null); 30 | panel.setBackground(Theme.BACKGROUND_PANEL); 31 | 32 | userIdLabel = new JLabel("Customer ID: "+customer.getUserId()); 33 | userIdLabel.setBounds(60, 20, 140, 30); 34 | userIdLabel.setFont(Theme.FONT_INPUT); 35 | panel.add(userIdLabel); 36 | 37 | customerNameLabel = new JLabel("Name: "); 38 | customerNameLabel.setBounds(60, 60, 140, 30); 39 | customerNameLabel.setFont(Theme.FONT_INPUT); 40 | panel.add(customerNameLabel); 41 | 42 | phoneNumberLabel = new JLabel("Phone: "); 43 | phoneNumberLabel.setBounds(60, 100, 140, 30); 44 | phoneNumberLabel.setFont(Theme.FONT_INPUT); 45 | panel.add(phoneNumberLabel); 46 | 47 | addressLabel = new JLabel("Address: "); 48 | addressLabel.setBounds(60, 140, 140, 30); 49 | addressLabel.setFont(Theme.FONT_INPUT); 50 | panel.add(addressLabel); 51 | 52 | customerNameTF = new JTextField(customer.getCustomerName()); 53 | customerNameTF.setBounds(160, 60, 220, 30); 54 | customerNameTF.setFont(Theme.FONT_INPUT); 55 | panel.add(customerNameTF); 56 | 57 | phoneCodeTF = new JTextField("+880"); 58 | phoneCodeTF.setEnabled(false); 59 | phoneCodeTF.setBounds(160, 100, 40, 30); 60 | phoneCodeTF.setFont(Theme.FONT_INPUT); 61 | panel.add(phoneCodeTF); 62 | 63 | 64 | phoneNumberTF = new JTextField(customer.getPhoneNumber().substring(4)+""); 65 | phoneNumberTF.setBounds(200, 100, 180, 30); 66 | phoneNumberTF.setFont(Theme.FONT_INPUT); 67 | panel.add(phoneNumberTF); 68 | 69 | addressTF = new JTextField(customer.getAddress()+""); 70 | addressTF.setBounds(160, 140, 220, 30); 71 | addressTF.setFont(Theme.FONT_INPUT); 72 | panel.add(addressTF); 73 | 74 | buttonEdit = new JButton("Edit"); 75 | buttonEdit.setBounds(60, 180, Theme.BUTTON_PRIMARY_WIDTH,30); 76 | buttonEdit.setFont(Theme.FONT_BUTTON); 77 | buttonEdit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 78 | buttonEdit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 79 | buttonEdit.addActionListener(this); 80 | panel.add(buttonEdit); 81 | 82 | buttonDelete = new JButton("Delete"); 83 | buttonDelete.setBounds(180, 180, Theme.BUTTON_PRIMARY_WIDTH,30); 84 | buttonDelete.setFont(Theme.FONT_BUTTON); 85 | buttonDelete.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 86 | buttonDelete.setForeground(Theme.COLOR_BUTTON_PRIMARY); 87 | buttonDelete.addActionListener(this); 88 | panel.add(buttonDelete); 89 | 90 | this.add(panel); 91 | } 92 | 93 | public void actionPerformed(ActionEvent ae) { 94 | if (ae.getSource().equals(buttonEdit)) { 95 | try { 96 | customer.updateCustomer(customerNameTF.getText(),Integer.parseInt(phoneNumberTF.getText()),addressTF.getText().trim()); 97 | if (!prev.keywordTF.getText().trim().isEmpty()) 98 | prev.table.setModel(Customer.searchCustomer(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 99 | else 100 | prev.table.setModel(Customer.searchCustomer("", "By Name")); 101 | this.setVisible(false); 102 | } 103 | catch (NumberFormatException e) { 104 | JOptionPane.showMessageDialog(this,"Invalid Input!"); 105 | } 106 | } 107 | else if (ae.getSource().equals(buttonDelete)) { 108 | customer.deleteCustomer(); 109 | if (!prev.keywordTF.getText().trim().isEmpty()) 110 | prev.table.setModel(Customer.searchCustomer(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 111 | else 112 | prev.table.setModel(Customer.searchCustomer("", "By Name")); 113 | this.setVisible(false); 114 | } 115 | else {} 116 | } 117 | } -------------------------------------------------------------------------------- /activity/ViewCustomerActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.table.*; 7 | import javax.swing.border.*; 8 | import java.awt.event.*; 9 | import attr.*; 10 | 11 | public class ViewCustomerActivity extends JFrame implements ActionListener { 12 | private JPanel panel; 13 | private JFrame activity; 14 | private Employee employee; 15 | private JScrollPane frame; 16 | JComboBox byWhatCB; 17 | JTable table; 18 | private JButton buttonLogout, buttonBack, buttonCheck; 19 | private JLabel title, header, keywordLabel; 20 | JTextField keywordTF; 21 | 22 | public ViewCustomerActivity(JFrame prev, Employee employee) { 23 | super("View Customer"); 24 | 25 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 26 | this.setResizable(false); 27 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 28 | this.setLocationRelativeTo(null); 29 | this.activity = prev; 30 | 31 | panel = new JPanel(); 32 | panel.setLayout(null); 33 | panel.setBackground(Theme.BACKGROUND_PANEL); 34 | 35 | title = new JLabel("View Customer"); 36 | title.setBounds(30, 40, 340,75); 37 | title.setOpaque(true); 38 | title.setBorder(new EmptyBorder(0,20,0,0)); 39 | title.setFont(Theme.FONT_TITLE); 40 | title.setForeground(Theme.COLOR_TITLE); 41 | panel.add(title); 42 | 43 | buttonLogout = new JButton("Logout"); 44 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 45 | buttonLogout.setFont(Theme.FONT_BUTTON); 46 | buttonLogout.setBackground(Color.WHITE); 47 | buttonLogout.setForeground(Theme.COLOR_TITLE); 48 | buttonLogout.addActionListener(this); 49 | panel.add(buttonLogout); 50 | 51 | buttonBack = new JButton("Back"); 52 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 53 | buttonBack.setFont(Theme.FONT_BUTTON); 54 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 55 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 56 | buttonBack.addActionListener(this); 57 | panel.add(buttonBack); 58 | 59 | keywordLabel = new JLabel("Keyword: "); 60 | keywordLabel.setBounds(60, 140, 140, 30); 61 | keywordLabel.setFont(Theme.FONT_REGULAR); 62 | panel.add(keywordLabel); 63 | 64 | keywordTF = new JTextField(); 65 | keywordTF.setBounds(160, 140, 240, 30); 66 | keywordTF.setFont(Theme.FONT_INPUT); 67 | panel.add(keywordTF); 68 | 69 | byWhatCB = new JComboBox(new Object[]{"By ID", "By Name"}); 70 | byWhatCB.setBounds(400, 140, 100,30); 71 | byWhatCB.setFont(Theme.FONT_INPUT); 72 | panel.add(byWhatCB); 73 | 74 | buttonCheck = new JButton("Search"); 75 | buttonCheck.setBounds(500, 140, Theme.BUTTON_PRIMARY_WIDTH,30); 76 | buttonCheck.setFont(Theme.FONT_BUTTON); 77 | buttonCheck.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 78 | buttonCheck.setForeground(Theme.COLOR_BUTTON_PRIMARY); 79 | buttonCheck.addActionListener(this); 80 | panel.add(buttonCheck); 81 | 82 | table = new JTable(); 83 | DefaultTableModel model = new DefaultTableModel(); 84 | model.setColumnIdentifiers(Customer.columnName); 85 | table.setModel(model); 86 | table.addMouseListener(new MouseAdapter() { 87 | public void mouseClicked(MouseEvent evt) { 88 | jTable_ClickMouseClicked(evt); 89 | } 90 | }); 91 | frame = new JScrollPane(table); 92 | frame.setBounds(40,185,600,300); 93 | panel.add(frame); 94 | 95 | table.setModel(Customer.searchCustomer("", "By Name")); 96 | 97 | header = new JLabel(); 98 | header.setBackground(Theme.BACKGROUND_HEADER); 99 | header.setOpaque(true); 100 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 101 | panel.add(header); 102 | 103 | this.add(panel); 104 | } 105 | 106 | public void actionPerformed(ActionEvent ae) { 107 | if (ae.getSource().equals(buttonLogout)) { 108 | this.setVisible(false); 109 | new LoginActivity().setVisible(true); 110 | } 111 | else if (ae.getSource().equals(buttonBack)) { 112 | this.setVisible(false); 113 | activity.setVisible(true); 114 | } 115 | else if (ae.getSource().equals(buttonCheck)) { 116 | table.setModel(Customer.searchCustomer(keywordTF.getText().trim(), byWhatCB.getSelectedItem().toString())); 117 | } 118 | else {} 119 | } 120 | 121 | private void jTable_ClickMouseClicked(MouseEvent evt) { 122 | int index = table.getSelectedRow(); 123 | 124 | TableModel model = table.getModel(); 125 | 126 | String value1 = model.getValueAt(index, 0).toString(); 127 | new ManageCustomer(value1, this).setVisible(true); 128 | } 129 | } -------------------------------------------------------------------------------- /activity/ManageEmployee.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import attr.*; 8 | 9 | public class ManageEmployee extends JFrame implements ActionListener { 10 | private JPanel panel; 11 | ViewEmployeeActivity prev; 12 | private Employee employee; 13 | private JButton buttonBack, buttonEdit, buttonDelete; 14 | private JLabel title, header, userIdLabel, employeeNameLabel, phoneNumberLabel, roleLabel, salaryLabel; 15 | private JTextField userIdTF, employeeNameTF, phoneNumberTF, phoneCodeTF, salaryTF; 16 | private JComboBox roleCB; 17 | 18 | public ManageEmployee(String eid, ViewEmployeeActivity prev) { 19 | super("Manage Employee"); 20 | 21 | this.setSize(500,400); 22 | this.setResizable(false); 23 | this.setLocationRelativeTo(null); 24 | this.prev = prev; 25 | 26 | employee = new Employee(eid); 27 | employee.fetch(); 28 | 29 | panel = new JPanel(); 30 | panel.setLayout(null); 31 | panel.setBackground(Theme.BACKGROUND_PANEL); 32 | 33 | userIdLabel = new JLabel("Employee ID: "+employee.getUserId()); 34 | userIdLabel.setBounds(60, 20, 140, 30); 35 | userIdLabel.setFont(Theme.FONT_INPUT); 36 | panel.add(userIdLabel); 37 | 38 | employeeNameLabel = new JLabel("Name: "); 39 | employeeNameLabel.setBounds(60, 60, 140, 30); 40 | employeeNameLabel.setFont(Theme.FONT_INPUT); 41 | panel.add(employeeNameLabel); 42 | 43 | phoneNumberLabel = new JLabel("Phone: "); 44 | phoneNumberLabel.setBounds(60, 100, 140, 30); 45 | phoneNumberLabel.setFont(Theme.FONT_INPUT); 46 | panel.add(phoneNumberLabel); 47 | 48 | roleLabel = new JLabel("Role: "); 49 | roleLabel.setBounds(60, 140, 140, 30); 50 | roleLabel.setFont(Theme.FONT_INPUT); 51 | panel.add(roleLabel); 52 | 53 | salaryLabel = new JLabel("Salary: "); 54 | salaryLabel.setBounds(60, 180, 140, 30); 55 | salaryLabel.setFont(Theme.FONT_INPUT); 56 | panel.add(salaryLabel); 57 | 58 | employeeNameTF = new JTextField(employee.getEmployeeName()); 59 | employeeNameTF.setBounds(160, 60, 220, 30); 60 | employeeNameTF.setFont(Theme.FONT_INPUT); 61 | panel.add(employeeNameTF); 62 | 63 | phoneCodeTF = new JTextField("+880"); 64 | phoneCodeTF.setEnabled(false); 65 | phoneCodeTF.setBounds(160, 100, 40, 30); 66 | phoneCodeTF.setFont(Theme.FONT_INPUT); 67 | panel.add(phoneCodeTF); 68 | 69 | 70 | phoneNumberTF = new JTextField(employee.getPhoneNumber().substring(4)+""); 71 | phoneNumberTF.setBounds(200, 100, 180, 30); 72 | phoneNumberTF.setFont(Theme.FONT_INPUT); 73 | panel.add(phoneNumberTF); 74 | 75 | roleCB = new JComboBox(Employee.roles); 76 | roleCB.setBounds(160, 140, 160, 30); 77 | roleCB.setSelectedIndex(employee.getRole().equals("Manager") ? 1 : 0); 78 | roleCB.setFont(Theme.FONT_INPUT); 79 | panel.add(roleCB); 80 | 81 | salaryTF = new JTextField(employee.getSalary()+""); 82 | salaryTF.setBounds(160, 180, 220, 30); 83 | salaryTF.setFont(Theme.FONT_INPUT); 84 | panel.add(salaryTF); 85 | 86 | buttonEdit = new JButton("Edit"); 87 | buttonEdit.setBounds(60, 220, Theme.BUTTON_PRIMARY_WIDTH,30); 88 | buttonEdit.setFont(Theme.FONT_BUTTON); 89 | buttonEdit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 90 | buttonEdit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 91 | buttonEdit.addActionListener(this); 92 | panel.add(buttonEdit); 93 | 94 | buttonDelete = new JButton("Delete"); 95 | buttonDelete.setBounds(180, 220, Theme.BUTTON_PRIMARY_WIDTH,30); 96 | buttonDelete.setFont(Theme.FONT_BUTTON); 97 | buttonDelete.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 98 | buttonDelete.setForeground(Theme.COLOR_BUTTON_PRIMARY); 99 | buttonDelete.addActionListener(this); 100 | panel.add(buttonDelete); 101 | 102 | this.add(panel); 103 | } 104 | 105 | public void actionPerformed(ActionEvent ae) { 106 | if (ae.getSource().equals(buttonEdit)) { 107 | try { 108 | employee.updateEmployee(employeeNameTF.getText(),Integer.parseInt(phoneNumberTF.getText()),roleCB.getSelectedItem().toString(), Double.parseDouble(salaryTF.getText())); 109 | if (!prev.keywordTF.getText().trim().isEmpty()) 110 | prev.table.setModel(Employee.searchEmployee(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 111 | else 112 | prev.table.setModel(Employee.searchEmployee("", "By Name")); 113 | this.setVisible(false); 114 | } 115 | catch (NumberFormatException e) { 116 | JOptionPane.showMessageDialog(this,"Invalid Input!"); 117 | } 118 | } 119 | else if (ae.getSource().equals(buttonDelete)) { 120 | employee.deleteEmployee(); 121 | if (!prev.keywordTF.getText().trim().isEmpty()) 122 | prev.table.setModel(Employee.searchEmployee(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 123 | else 124 | prev.table.setModel(Employee.searchEmployee("", "By Name")); 125 | this.setVisible(false); 126 | } 127 | else {} 128 | } 129 | } -------------------------------------------------------------------------------- /activity/AddProductActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.border.*; 7 | import java.awt.event.*; 8 | import attr.*; 9 | 10 | public class AddProductActivity extends JFrame implements ActionListener { 11 | private JPanel panel; 12 | private ViewProductActivity activity; 13 | private Employee employee; 14 | private JButton buttonLogout, buttonBack, buttonAdd; 15 | private JLabel title, header, productNameLabel, productQtLabel, productPriceLabel; 16 | private JTextField productNameTF, productQtTF, productPriceTF; 17 | 18 | public AddProductActivity(ViewProductActivity prev, Employee employee) { 19 | super("Add Product"); 20 | 21 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 22 | this.setResizable(false); 23 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 24 | this.setLocationRelativeTo(null); 25 | this.activity = prev; 26 | this.employee = employee; 27 | 28 | panel = new JPanel(); 29 | panel.setLayout(null); 30 | panel.setBackground(Theme.BACKGROUND_PANEL); 31 | 32 | title = new JLabel("Add Product"); 33 | title.setBounds(30, 40, 280,75); 34 | title.setOpaque(true); 35 | title.setBorder(new EmptyBorder(0,20,0,0)); 36 | title.setFont(Theme.FONT_TITLE); 37 | title.setForeground(Theme.COLOR_TITLE); 38 | panel.add(title); 39 | 40 | buttonLogout = new JButton("Logout"); 41 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 42 | buttonLogout.setFont(Theme.FONT_BUTTON); 43 | buttonLogout.setBackground(Color.WHITE); 44 | buttonLogout.setForeground(Theme.COLOR_TITLE); 45 | buttonLogout.addActionListener(this); 46 | panel.add(buttonLogout); 47 | 48 | buttonBack = new JButton("Back"); 49 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 50 | buttonBack.setFont(Theme.FONT_BUTTON); 51 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 52 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 53 | buttonBack.addActionListener(this); 54 | panel.add(buttonBack); 55 | 56 | productNameLabel = new JLabel("Name: "); 57 | productNameLabel.setBounds(60, 190, 140, 30); 58 | productNameLabel.setFont(Theme.FONT_REGULAR); 59 | panel.add(productNameLabel); 60 | 61 | productPriceLabel = new JLabel("Price: "); 62 | productPriceLabel.setBounds(60, 240, 140, 30); 63 | productPriceLabel.setFont(Theme.FONT_REGULAR); 64 | panel.add(productPriceLabel); 65 | 66 | productQtLabel = new JLabel("Quantity: "); 67 | productQtLabel.setBounds(60, 290, 140, 30); 68 | productQtLabel.setFont(Theme.FONT_REGULAR); 69 | panel.add(productQtLabel); 70 | 71 | productNameTF = new JTextField(); 72 | productNameTF.setBounds(180, 190, 220, 30); 73 | productNameTF.setFont(Theme.FONT_INPUT); 74 | panel.add(productNameTF); 75 | 76 | productPriceTF = new JTextField(); 77 | productPriceTF.setBounds(180, 240, 220, 30); 78 | productPriceTF.setFont(Theme.FONT_INPUT); 79 | panel.add(productPriceTF); 80 | 81 | productQtTF = new JTextField(); 82 | productQtTF.setBounds(180, 290, 220, 30); 83 | productQtTF.setFont(Theme.FONT_INPUT); 84 | panel.add(productQtTF); 85 | 86 | buttonAdd = new JButton("Add"); 87 | buttonAdd.setBounds(60, 340, Theme.BUTTON_PRIMARY_WIDTH,30); 88 | buttonAdd.setFont(Theme.FONT_BUTTON); 89 | buttonAdd.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 90 | buttonAdd.setForeground(Theme.COLOR_BUTTON_PRIMARY); 91 | buttonAdd.addActionListener(this); 92 | panel.add(buttonAdd); 93 | 94 | header = new JLabel(); 95 | header.setBackground(Theme.BACKGROUND_HEADER); 96 | header.setOpaque(true); 97 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 98 | panel.add(header); 99 | 100 | this.add(panel); 101 | } 102 | 103 | public void actionPerformed(ActionEvent ae) { 104 | if (ae.getSource().equals(buttonLogout)) { 105 | this.setVisible(false); 106 | new LoginActivity().setVisible(true); 107 | } 108 | else if (ae.getSource().equals(buttonBack)) { 109 | this.setVisible(false); 110 | new ViewProductActivity(new EmployeeActivity(employee.getUserId()), employee).setVisible(true); 111 | } 112 | else if (ae.getSource().equals(buttonAdd)) { 113 | try { 114 | Product p = new Product(); 115 | p.setProductName(productNameTF.getText().trim()); 116 | p.setPrice(Double.parseDouble(productPriceTF.getText())); 117 | p.setQuantity(Integer.parseInt(productQtTF.getText())); 118 | p.createProduct(); 119 | productNameTF.setText(""); 120 | productPriceTF.setText(""); 121 | productQtTF.setText(""); 122 | if (!activity.keywordTF.getText().trim().isEmpty()) 123 | activity.table.setModel(Product.searchProduct(activity.keywordTF.getText().trim(), activity.byWhatCB.getSelectedItem().toString())); 124 | else 125 | activity.table.setModel(Product.searchProduct("", "By Name")); 126 | } 127 | catch (NumberFormatException e) { 128 | JOptionPane.showMessageDialog(this,"Enter price/quantity correctly!"); 129 | } 130 | catch (IllegalArgumentException e) { 131 | JOptionPane.showMessageDialog(this,e.getMessage()); 132 | } 133 | } 134 | else {} 135 | } 136 | } -------------------------------------------------------------------------------- /activity/ViewEmployeeActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import javax.swing.table.*; 6 | import java.awt.*; 7 | import javax.swing.border.*; 8 | import java.awt.event.*; 9 | import attr.*; 10 | 11 | public class ViewEmployeeActivity extends JFrame implements ActionListener { 12 | private JPanel panel; 13 | private JFrame activity; 14 | private Employee employee; 15 | private JScrollPane frame; 16 | JComboBox byWhatCB; 17 | JTable table; 18 | private JButton buttonLogout, buttonBack, buttonCheck, buttonAddEmployee; 19 | private JLabel title, header, keywordLabel; 20 | JTextField keywordTF; 21 | 22 | public ViewEmployeeActivity(JFrame prev, Employee employee) { 23 | super("View Employee"); 24 | 25 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 26 | this.setResizable(false); 27 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 28 | this.setLocationRelativeTo(null); 29 | this.activity = prev; 30 | 31 | panel = new JPanel(); 32 | panel.setLayout(null); 33 | panel.setBackground(Theme.BACKGROUND_PANEL); 34 | 35 | title = new JLabel("View Employee"); 36 | title.setBounds(30, 40, 340,75); 37 | title.setOpaque(true); 38 | title.setBorder(new EmptyBorder(0,20,0,0)); 39 | title.setFont(Theme.FONT_TITLE); 40 | title.setForeground(Theme.COLOR_TITLE); 41 | panel.add(title); 42 | 43 | buttonLogout = new JButton("Logout"); 44 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 45 | buttonLogout.setFont(Theme.FONT_BUTTON); 46 | buttonLogout.setBackground(Color.WHITE); 47 | buttonLogout.setForeground(Theme.COLOR_TITLE); 48 | buttonLogout.addActionListener(this); 49 | panel.add(buttonLogout); 50 | 51 | buttonBack = new JButton("Back"); 52 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 53 | buttonBack.setFont(Theme.FONT_BUTTON); 54 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 55 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 56 | buttonBack.addActionListener(this); 57 | panel.add(buttonBack); 58 | 59 | buttonAddEmployee = new JButton("Add"); 60 | buttonAddEmployee.setBounds(Theme.GUI_WIDTH-140, 115, Theme.BUTTON_PRIMARY_WIDTH, 30); 61 | buttonAddEmployee.setFont(Theme.FONT_BUTTON); 62 | buttonAddEmployee.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 63 | buttonAddEmployee.setForeground(Theme.COLOR_BUTTON_PRIMARY); 64 | buttonAddEmployee.addActionListener(this); 65 | panel.add(buttonAddEmployee); 66 | 67 | keywordLabel = new JLabel("Keyword: "); 68 | keywordLabel.setBounds(60, 140, 140, 30); 69 | keywordLabel.setFont(Theme.FONT_REGULAR); 70 | panel.add(keywordLabel); 71 | 72 | keywordTF = new JTextField(); 73 | keywordTF.setBounds(160, 140, 240, 30); 74 | keywordTF.setFont(Theme.FONT_INPUT); 75 | panel.add(keywordTF); 76 | 77 | byWhatCB = new JComboBox(new Object[]{"By ID", "By Name"}); 78 | byWhatCB.setBounds(400, 140, 100,30); 79 | byWhatCB.setFont(Theme.FONT_INPUT); 80 | panel.add(byWhatCB); 81 | 82 | buttonCheck = new JButton("Search"); 83 | buttonCheck.setBounds(500, 140, Theme.BUTTON_PRIMARY_WIDTH,30); 84 | buttonCheck.setFont(Theme.FONT_BUTTON); 85 | buttonCheck.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 86 | buttonCheck.setForeground(Theme.COLOR_BUTTON_PRIMARY); 87 | buttonCheck.addActionListener(this); 88 | panel.add(buttonCheck); 89 | 90 | table = new JTable(); 91 | DefaultTableModel model = new DefaultTableModel(); 92 | model.setColumnIdentifiers(Employee.columnNames); 93 | table.setModel(model); 94 | table.addMouseListener(new MouseAdapter() { 95 | public void mouseClicked(MouseEvent evt) { 96 | jTable_ClickMouseClicked(evt); 97 | } 98 | }); 99 | frame = new JScrollPane(table); 100 | frame.setBounds(40,185,600,300); 101 | panel.add(frame); 102 | 103 | table.setModel(Employee.searchEmployee("", "By Name")); 104 | 105 | header = new JLabel(); 106 | header.setBackground(Theme.BACKGROUND_HEADER); 107 | header.setOpaque(true); 108 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 109 | panel.add(header); 110 | 111 | this.add(panel); 112 | } 113 | 114 | public void actionPerformed(ActionEvent ae) { 115 | if (ae.getSource().equals(buttonLogout)) { 116 | this.setVisible(false); 117 | new LoginActivity().setVisible(true); 118 | } 119 | else if (ae.getSource().equals(buttonBack)) { 120 | this.setVisible(false); 121 | activity.setVisible(true); 122 | } 123 | else if (ae.getSource().equals(buttonAddEmployee)) { 124 | this.setVisible(false); 125 | new AddEmployeeActivity(this, employee).setVisible(true); 126 | } 127 | else if (ae.getSource().equals(buttonCheck)) { 128 | table.setModel(Employee.searchEmployee(keywordTF.getText().trim(), byWhatCB.getSelectedItem().toString())); 129 | } 130 | else {} 131 | } 132 | 133 | private void jTable_ClickMouseClicked(MouseEvent evt) { 134 | int index = table.getSelectedRow(); 135 | 136 | TableModel model = table.getModel(); 137 | 138 | String value1 = model.getValueAt(index, 0).toString(); 139 | new ManageEmployee(value1, this).setVisible(true); 140 | } 141 | } -------------------------------------------------------------------------------- /activity/SignupActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.border.*; 7 | import java.awt.event.*; 8 | import java.sql.*; 9 | import attr.*; 10 | 11 | public class SignupActivity extends JFrame implements ActionListener { 12 | private JPanel panel; 13 | private JButton buttonExit, buttonSubmit, buttonBack; 14 | private JLabel title, header, usernameLabel, passwordLabel, nameLabel, phoneLabel, addressLabel; 15 | private JTextField usernameTF, nameTF, phoneTF1, phoneTF2, addressTF; 16 | private JPasswordField passwordF; 17 | public SignupActivity() { 18 | super("Sign up"); 19 | 20 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 21 | this.setResizable(false); 22 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 23 | this.setLocationRelativeTo(null); 24 | 25 | panel = new JPanel(); 26 | panel.setLayout(null); 27 | panel.setBackground(Theme.BACKGROUND_PANEL); 28 | 29 | title = new JLabel("Sign up"); 30 | title.setBounds(30, 40, 200,75); 31 | title.setOpaque(true); 32 | title.setBorder(new EmptyBorder(0,20,0,0)); 33 | title.setFont(Theme.FONT_TITLE); 34 | title.setForeground(Theme.COLOR_TITLE); 35 | panel.add(title); 36 | 37 | buttonExit = new JButton("Exit"); 38 | buttonExit.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 39 | buttonExit.setFont(Theme.FONT_BUTTON); 40 | buttonExit.setBackground(Color.WHITE); 41 | buttonExit.setForeground(Theme.COLOR_TITLE); 42 | buttonExit.addActionListener(this); 43 | panel.add(buttonExit); 44 | 45 | buttonBack = new JButton("Back"); 46 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 47 | buttonBack.setFont(Theme.FONT_BUTTON); 48 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 49 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 50 | buttonBack.addActionListener(this); 51 | panel.add(buttonBack); 52 | 53 | usernameLabel = new JLabel("User ID: "); 54 | usernameLabel.setBounds(60, 140, 140, 30); 55 | usernameLabel.setFont(Theme.FONT_REGULAR); 56 | panel.add(usernameLabel); 57 | 58 | passwordLabel = new JLabel("Password: "); 59 | passwordLabel.setBounds(60, 190, 140, 30); 60 | passwordLabel.setFont(Theme.FONT_REGULAR); 61 | panel.add(passwordLabel); 62 | 63 | nameLabel = new JLabel("Name: "); 64 | nameLabel.setBounds(60, 240, 140, 30); 65 | nameLabel.setFont(Theme.FONT_REGULAR); 66 | panel.add(nameLabel); 67 | 68 | phoneLabel = new JLabel("Phone No: "); 69 | phoneLabel.setBounds(60, 290, 140, 30); 70 | phoneLabel.setFont(Theme.FONT_REGULAR); 71 | panel.add(phoneLabel); 72 | 73 | addressLabel = new JLabel("Address: "); 74 | addressLabel.setBounds(60, 340, 140, 30); 75 | addressLabel.setFont(Theme.FONT_REGULAR); 76 | panel.add(addressLabel); 77 | 78 | usernameTF = new JTextField(); 79 | usernameTF.setBounds(180, 140, 220, 30); 80 | usernameTF.setFont(Theme.FONT_INPUT); 81 | panel.add(usernameTF); 82 | 83 | passwordF = new JPasswordField(); 84 | passwordF.setBounds(180, 190, 220, 30); 85 | passwordF.setFont(Theme.FONT_INPUT); 86 | panel.add(passwordF); 87 | 88 | nameTF = new JTextField(); 89 | nameTF.setBounds(180, 240, 220, 30); 90 | nameTF.setFont(Theme.FONT_INPUT); 91 | panel.add(nameTF); 92 | 93 | phoneTF1 = new JTextField("+880"); 94 | phoneTF1.setBounds(180, 290, 40, 30); 95 | phoneTF1.setForeground(Theme.COLOR_BUTTON_PRIMARY); 96 | phoneTF1.setEnabled(false); 97 | phoneTF1.setFont(Theme.FONT_INPUT); 98 | phoneTF1.setDisabledTextColor(Color.BLACK); 99 | panel.add(phoneTF1); 100 | 101 | phoneTF2 = new JTextField(); 102 | phoneTF2.setBounds(220, 290, 180, 30); 103 | phoneTF2.setFont(Theme.FONT_INPUT); 104 | panel.add(phoneTF2); 105 | 106 | addressTF = new JTextField(); 107 | addressTF.setBounds(180, 340, 220, 30); 108 | addressTF.setFont(Theme.FONT_INPUT); 109 | panel.add(addressTF); 110 | 111 | buttonSubmit = new JButton("Submit"); 112 | buttonSubmit.setBounds(70, 400, 300, 35); 113 | buttonSubmit.setFont(Theme.FONT_BUTTON); 114 | buttonSubmit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 115 | buttonSubmit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 116 | buttonSubmit.addActionListener(this); 117 | panel.add(buttonSubmit); 118 | 119 | header = new JLabel(); 120 | header.setBackground(Theme.BACKGROUND_HEADER); 121 | header.setOpaque(true); 122 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 123 | panel.add(header); 124 | 125 | this.add(panel); 126 | } 127 | 128 | public void actionPerformed(ActionEvent ae) { 129 | if (ae.getSource().equals(buttonExit)) 130 | System.exit(0); 131 | else if (ae.getSource().equals(buttonBack)) { 132 | this.setVisible(false); 133 | new LoginActivity().setVisible(true); 134 | } 135 | else if (ae.getSource().equals(buttonSubmit)) { 136 | try { 137 | Customer c = new Customer(usernameTF.getText().trim()); 138 | c.setPassword(passwordF.getText()); 139 | c.setCustomerName(nameTF.getText()); 140 | c.setPhoneNumber(Integer.parseInt(phoneTF2.getText())); 141 | c.setAddress(addressTF.getText()); 142 | c.createCustomer(this); 143 | } 144 | catch (NumberFormatException e) { 145 | JOptionPane.showMessageDialog(this,"Enter phone no correctly!"); 146 | } 147 | catch (IllegalArgumentException e) { 148 | JOptionPane.showMessageDialog(this,e.getMessage()); 149 | } 150 | } 151 | else {} 152 | } 153 | } -------------------------------------------------------------------------------- /sql/f1.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.6.5.2 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: Sep 28, 2018 at 10:10 AM 7 | -- Server version: 10.1.21-MariaDB 8 | -- PHP Version: 5.6.30 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8mb4 */; 18 | 19 | -- 20 | -- Database: `f1` 21 | -- 22 | 23 | -- -------------------------------------------------------- 24 | 25 | -- 26 | -- Table structure for table `customer` 27 | -- 28 | 29 | CREATE TABLE `customer` ( 30 | `userId` varchar(12) NOT NULL, 31 | `customerName` varchar(30) NOT NULL, 32 | `phoneNumber` varchar(14) NOT NULL, 33 | `address` varchar(50) NOT NULL 34 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 35 | 36 | -- 37 | -- Dumping data for table `customer` 38 | -- 39 | 40 | INSERT INTO `customer` (`userId`, `customerName`, `phoneNumber`, `address`) VALUES 41 | ('c001', 'Customer', '+8801234567890', 'banani'), 42 | ('deba', 'Debashish', '+8801763923789', 'Kuril'); 43 | 44 | -- -------------------------------------------------------- 45 | 46 | -- 47 | -- Table structure for table `employee` 48 | -- 49 | 50 | CREATE TABLE `employee` ( 51 | `userId` varchar(12) NOT NULL, 52 | `employeeName` varchar(50) NOT NULL, 53 | `phoneNumber` varchar(14) NOT NULL, 54 | `role` varchar(8) NOT NULL, 55 | `salary` double(8,2) NOT NULL 56 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 57 | 58 | -- 59 | -- Dumping data for table `employee` 60 | -- 61 | 62 | INSERT INTO `employee` (`userId`, `employeeName`, `phoneNumber`, `role`, `salary`) VALUES 63 | ('e001', 'Employee1', '+8801234567890', 'Manager', 50000.00), 64 | ('e002', 'Employee2', '+8801234567891', 'General', 30000.00); 65 | 66 | -- -------------------------------------------------------- 67 | 68 | -- 69 | -- Table structure for table `login` 70 | -- 71 | 72 | CREATE TABLE `login` ( 73 | `userId` varchar(12) NOT NULL, 74 | `password` varchar(12) NOT NULL, 75 | `status` int(1) NOT NULL 76 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 77 | 78 | -- 79 | -- Dumping data for table `login` 80 | -- 81 | 82 | INSERT INTO `login` (`userId`, `password`, `status`) VALUES 83 | ('e001', 'e001', 0), 84 | ('e002', 'e002', 0), 85 | ('c001', 'c001', 1), 86 | ('deba', 'aaaa', 1); 87 | 88 | -- -------------------------------------------------------- 89 | 90 | -- 91 | -- Table structure for table `product` 92 | -- 93 | 94 | CREATE TABLE `product` ( 95 | `productId` int(5) UNSIGNED ZEROFILL NOT NULL, 96 | `productName` varchar(50) NOT NULL, 97 | `price` double(8,2) NOT NULL, 98 | `quantity` int(8) NOT NULL 99 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 100 | 101 | -- 102 | -- Dumping data for table `product` 103 | -- 104 | 105 | INSERT INTO `product` (`productId`, `productName`, `price`, `quantity`) VALUES 106 | (00001, 'Juice 1L', 66.00, 7), 107 | (00002, 'Mi Band', 2000.00, 5), 108 | (00003, 'Frutika', 55.00, 21), 109 | (00004, 'Samsung S9', 89999.00, 5), 110 | (00005, 'Bagpack XL', 2500.00, 6); 111 | 112 | -- -------------------------------------------------------- 113 | 114 | -- 115 | -- Table structure for table `purchaseinfo` 116 | -- 117 | 118 | CREATE TABLE `purchaseinfo` ( 119 | `purchaseId` int(5) UNSIGNED ZEROFILL NOT NULL, 120 | `userId` varchar(12) NOT NULL, 121 | `productId` varchar(12) NOT NULL, 122 | `cost` double(12,2) UNSIGNED NOT NULL, 123 | `amount` int(8) UNSIGNED NOT NULL, 124 | `date` varchar(18) NOT NULL 125 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 126 | 127 | -- 128 | -- Dumping data for table `purchaseinfo` 129 | -- 130 | 131 | INSERT INTO `purchaseinfo` (`purchaseId`, `userId`, `productId`, `cost`, `amount`, `date`) VALUES 132 | (00001, 'deba', '00003', 55.00, 1, '2018-09-26'), 133 | (00002, 'c001', '00005', 2500.00, 1, '2018-09-28'), 134 | (00006, 'c001', '00003', 110.00, 2, '2018-09-28'); 135 | 136 | -- 137 | -- Indexes for dumped tables 138 | -- 139 | 140 | -- 141 | -- Indexes for table `customer` 142 | -- 143 | ALTER TABLE `customer` 144 | ADD PRIMARY KEY (`userId`); 145 | 146 | -- 147 | -- Indexes for table `employee` 148 | -- 149 | ALTER TABLE `employee` 150 | ADD PRIMARY KEY (`userId`); 151 | 152 | -- 153 | -- Indexes for table `login` 154 | -- 155 | ALTER TABLE `login` 156 | ADD UNIQUE KEY `userId` (`userId`), 157 | ADD UNIQUE KEY `userId_2` (`userId`); 158 | 159 | -- 160 | -- Indexes for table `product` 161 | -- 162 | ALTER TABLE `product` 163 | ADD PRIMARY KEY (`productId`); 164 | 165 | -- 166 | -- Indexes for table `purchaseinfo` 167 | -- 168 | ALTER TABLE `purchaseinfo` 169 | ADD PRIMARY KEY (`purchaseId`), 170 | ADD KEY `userId` (`userId`), 171 | ADD KEY `userId_2` (`userId`); 172 | 173 | -- 174 | -- AUTO_INCREMENT for dumped tables 175 | -- 176 | 177 | -- 178 | -- AUTO_INCREMENT for table `product` 179 | -- 180 | ALTER TABLE `product` 181 | MODIFY `productId` int(5) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; 182 | -- 183 | -- AUTO_INCREMENT for table `purchaseinfo` 184 | -- 185 | ALTER TABLE `purchaseinfo` 186 | MODIFY `purchaseId` int(5) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; 187 | -- 188 | -- Constraints for dumped tables 189 | -- 190 | 191 | -- 192 | -- Constraints for table `purchaseinfo` 193 | -- 194 | ALTER TABLE `purchaseinfo` 195 | ADD CONSTRAINT `FK_PUR_CUS` FOREIGN KEY (`userId`) REFERENCES `purchaseinfo` (`userId`); 196 | 197 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 198 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 199 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 200 | -------------------------------------------------------------------------------- /activity/ManageProduct.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import java.awt.event.*; 7 | import attr.*; 8 | 9 | public class ManageProduct extends JFrame implements ActionListener { 10 | private JPanel panel; 11 | ViewProductActivity prev; 12 | private Product product; 13 | private JButton buttonBack, buttonEdit, buttonDelete, buttonSell, buttonSubmit; 14 | private JLabel title, header, productIdLabel, productNameLabel, productQtLabel, productPriceLabel, userIdLabel; 15 | private JTextField productIdTF, productNameTF, productQtTF, productPriceTF, userIdTF; 16 | 17 | public ManageProduct(String pid, ViewProductActivity prev) { 18 | super("Manage Product"); 19 | 20 | this.setSize(500,400); 21 | this.setResizable(false); 22 | this.setLocationRelativeTo(null); 23 | this.prev = prev; 24 | 25 | product = new Product(pid); 26 | product.fetch(); 27 | 28 | panel = new JPanel(); 29 | panel.setLayout(null); 30 | panel.setBackground(Theme.BACKGROUND_PANEL); 31 | 32 | productIdLabel = new JLabel("Product ID: "+product.getProductId()); 33 | productIdLabel.setBounds(60, 20, 140, 30); 34 | productIdLabel.setFont(Theme.FONT_INPUT); 35 | panel.add(productIdLabel); 36 | 37 | productNameLabel = new JLabel("Name: "); 38 | productNameLabel.setBounds(60, 60, 140, 30); 39 | productNameLabel.setFont(Theme.FONT_INPUT); 40 | panel.add(productNameLabel); 41 | 42 | productPriceLabel = new JLabel("Price: "); 43 | productPriceLabel.setBounds(60, 100, 140, 30); 44 | productPriceLabel.setVisible(false); 45 | productPriceLabel.setFont(Theme.FONT_INPUT); 46 | panel.add(productPriceLabel); 47 | 48 | userIdLabel = new JLabel("CustomerID: "); 49 | userIdLabel.setBounds(60, 100, 140, 30); 50 | userIdLabel.setFont(Theme.FONT_INPUT); 51 | panel.add(userIdLabel); 52 | 53 | productQtLabel = new JLabel("Quantity: "); 54 | productQtLabel.setBounds(60, 140, 140, 30); 55 | productQtLabel.setFont(Theme.FONT_INPUT); 56 | panel.add(productQtLabel); 57 | 58 | productNameTF = new JTextField(product.getProductName()); 59 | productNameTF.setBounds(180, 60, 220, 30); 60 | productNameTF.setEnabled(false); 61 | productNameTF.setFont(Theme.FONT_INPUT); 62 | panel.add(productNameTF); 63 | 64 | userIdTF = new JTextField(""); 65 | userIdTF.setBounds(180, 100, 220, 30); 66 | userIdTF.setFont(Theme.FONT_INPUT); 67 | panel.add(userIdTF); 68 | 69 | productPriceTF = new JTextField(product.getPrice()+""); 70 | productPriceTF.setBounds(180, 100, 220, 30); 71 | productPriceTF.setFont(Theme.FONT_INPUT); 72 | productPriceTF.setVisible(false); 73 | panel.add(productPriceTF); 74 | 75 | productQtTF = new JTextField(""); 76 | productQtTF.setBounds(180, 140, 220, 30); 77 | productQtTF.setFont(Theme.FONT_INPUT); 78 | panel.add(productQtTF); 79 | 80 | buttonEdit = new JButton("Edit"); 81 | buttonEdit.setBounds(180, 180, Theme.BUTTON_PRIMARY_WIDTH,30); 82 | buttonEdit.setFont(Theme.FONT_BUTTON); 83 | buttonEdit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 84 | buttonEdit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 85 | buttonEdit.addActionListener(this); 86 | panel.add(buttonEdit); 87 | 88 | buttonSubmit = new JButton("Submit"); 89 | buttonSubmit.setBounds(180, 180, Theme.BUTTON_PRIMARY_WIDTH,30); 90 | buttonSubmit.setFont(Theme.FONT_BUTTON); 91 | buttonSubmit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 92 | buttonSubmit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 93 | buttonSubmit.setVisible(false); 94 | buttonSubmit.addActionListener(this); 95 | panel.add(buttonSubmit); 96 | 97 | buttonDelete = new JButton("Delete"); 98 | buttonDelete.setBounds(300, 180, Theme.BUTTON_PRIMARY_WIDTH,30); 99 | buttonDelete.setFont(Theme.FONT_BUTTON); 100 | buttonDelete.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 101 | buttonDelete.setForeground(Theme.COLOR_BUTTON_PRIMARY); 102 | buttonDelete.addActionListener(this); 103 | panel.add(buttonDelete); 104 | 105 | buttonSell = new JButton("Sell"); 106 | buttonSell.setBounds(60, 180, Theme.BUTTON_PRIMARY_WIDTH,30); 107 | buttonSell.setFont(Theme.FONT_BUTTON); 108 | buttonSell.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 109 | buttonSell.setForeground(Theme.COLOR_BUTTON_PRIMARY); 110 | buttonSell.addActionListener(this); 111 | panel.add(buttonSell); 112 | 113 | this.add(panel); 114 | } 115 | 116 | public void actionPerformed(ActionEvent ae) { 117 | if (ae.getSource().equals(buttonSell)) { 118 | try { 119 | product.sellProduct(userIdTF.getText().trim(),Integer.parseInt(productQtTF.getText())); 120 | if (!prev.keywordTF.getText().trim().isEmpty()) 121 | prev.table.setModel(Product.searchProduct(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 122 | else 123 | prev.table.setModel(Product.searchProduct("", "By Name")); 124 | this.setVisible(false); 125 | } 126 | catch (NumberFormatException e) { 127 | JOptionPane.showMessageDialog(this,"Invalid Input!"); 128 | } 129 | } 130 | else if (ae.getSource().equals(buttonEdit)) { 131 | buttonEdit.setVisible(false); 132 | buttonSubmit.setVisible(true); 133 | buttonSell.setEnabled(false); 134 | productQtTF.setText(product.getQuantity()+""); 135 | productNameTF.setEnabled(true); 136 | userIdLabel.setVisible(false); 137 | userIdTF.setVisible(false); 138 | productPriceLabel.setVisible(true); 139 | productPriceTF.setVisible(true); 140 | } 141 | else if (ae.getSource().equals(buttonSubmit)) { 142 | try { 143 | product.updateProduct(productNameTF.getText(),Double.parseDouble(productPriceTF.getText()),Integer.parseInt(productQtTF.getText())); 144 | if (!prev.keywordTF.getText().trim().isEmpty()) 145 | prev.table.setModel(Product.searchProduct(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 146 | else 147 | prev.table.setModel(Product.searchProduct("", "By Name")); 148 | this.setVisible(false); 149 | } 150 | catch (NumberFormatException e) { 151 | JOptionPane.showMessageDialog(this,"Invalid Input!"); 152 | } 153 | } 154 | else if (ae.getSource().equals(buttonDelete)) { 155 | product.deleteProduct(); 156 | if (!prev.keywordTF.getText().trim().isEmpty()) 157 | prev.table.setModel(Product.searchProduct(prev.keywordTF.getText().trim(), prev.byWhatCB.getSelectedItem().toString())); 158 | else 159 | prev.table.setModel(Product.searchProduct("", "By Name")); 160 | this.setVisible(false); 161 | } 162 | else {} 163 | } 164 | } -------------------------------------------------------------------------------- /activity/AddEmployeeActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import java.util.*; 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import javax.swing.border.*; 8 | import java.awt.event.*; 9 | import attr.*; 10 | 11 | public class AddEmployeeActivity extends JFrame implements ActionListener { 12 | private JPanel panel; 13 | private ViewEmployeeActivity activity; 14 | private JButton buttonLogout, buttonBack, buttonAdd, buttonEdit, buttonDelete, buttonRandom; 15 | private JLabel title, header, employeeIdLabel, employeeNameLabel, roleLabel, employeePhoneLabel, salaryLabel; 16 | private JComboBox roleCB; 17 | private JTextField employeeIdTF, employeeNameTF, salaryTF, employeePhoneTF1, employeePhoneTF2, passwordTF; 18 | private Random r; 19 | 20 | public AddEmployeeActivity(ViewEmployeeActivity prev, Employee employee) { 21 | super("Add Employee"); 22 | 23 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 24 | this.setResizable(false); 25 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 26 | this.setLocationRelativeTo(null); 27 | this.activity = prev; 28 | r = new Random(); 29 | 30 | panel = new JPanel(); 31 | panel.setLayout(null); 32 | panel.setBackground(Theme.BACKGROUND_PANEL); 33 | 34 | title = new JLabel("Add Employee"); 35 | title.setBounds(30, 40, 340,75); 36 | title.setOpaque(true); 37 | title.setBorder(new EmptyBorder(0,20,0,0)); 38 | title.setFont(Theme.FONT_TITLE); 39 | title.setForeground(Theme.COLOR_TITLE); 40 | panel.add(title); 41 | 42 | buttonLogout = new JButton("Logout"); 43 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 44 | buttonLogout.setFont(Theme.FONT_BUTTON); 45 | buttonLogout.setBackground(Color.WHITE); 46 | buttonLogout.setForeground(Theme.COLOR_TITLE); 47 | buttonLogout.addActionListener(this); 48 | panel.add(buttonLogout); 49 | 50 | buttonBack = new JButton("Back"); 51 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 52 | buttonBack.setFont(Theme.FONT_BUTTON); 53 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 54 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 55 | buttonBack.addActionListener(this); 56 | panel.add(buttonBack); 57 | 58 | employeeIdLabel = new JLabel("Employee ID: "); 59 | employeeIdLabel.setBounds(60, 140, 140, 30); 60 | employeeIdLabel.setFont(Theme.FONT_REGULAR); 61 | panel.add(employeeIdLabel); 62 | 63 | employeeIdLabel = new JLabel("Password: "); 64 | employeeIdLabel.setBounds(60, 190, 140, 30); 65 | employeeIdLabel.setFont(Theme.FONT_REGULAR); 66 | panel.add(employeeIdLabel); 67 | 68 | employeeNameLabel = new JLabel("Name: "); 69 | employeeNameLabel.setBounds(60, 240, 140, 30); 70 | employeeNameLabel.setFont(Theme.FONT_REGULAR); 71 | panel.add(employeeNameLabel); 72 | 73 | employeePhoneLabel = new JLabel("Phone No: "); 74 | employeePhoneLabel.setBounds(60, 290, 140, 30); 75 | employeePhoneLabel.setFont(Theme.FONT_REGULAR); 76 | panel.add(employeePhoneLabel); 77 | 78 | roleLabel = new JLabel("Role: "); 79 | roleLabel.setBounds(60, 340, 340, 30); 80 | roleLabel.setFont(Theme.FONT_REGULAR); 81 | panel.add(roleLabel); 82 | 83 | salaryLabel = new JLabel("Salary: "); 84 | salaryLabel.setBounds(60, 390, 140, 30); 85 | salaryLabel.setFont(Theme.FONT_REGULAR); 86 | panel.add(salaryLabel); 87 | 88 | employeeIdTF = new JTextField(); 89 | employeeIdTF.setBounds(180, 140, 220, 30); 90 | employeeIdTF.setFont(Theme.FONT_INPUT); 91 | panel.add(employeeIdTF); 92 | 93 | passwordTF = new JTextField(""+(r.nextInt(89999999)+10000000)); 94 | passwordTF.setBounds(180, 190, 220, 30); 95 | passwordTF.setFont(Theme.FONT_INPUT); 96 | passwordTF.setEnabled(false); 97 | passwordTF.setDisabledTextColor(Color.BLACK); 98 | panel.add(passwordTF); 99 | 100 | buttonRandom = new JButton("Generate"); 101 | buttonRandom.setBounds(400, 190, Theme.BUTTON_PRIMARY_WIDTH,30); 102 | buttonRandom.setFont(Theme.FONT_BUTTON); 103 | buttonRandom.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 104 | buttonRandom.setForeground(Theme.COLOR_BUTTON_PRIMARY); 105 | buttonRandom.addActionListener(this); 106 | panel.add(buttonRandom); 107 | 108 | employeeNameTF = new JTextField(); 109 | employeeNameTF.setBounds(180, 240, 220, 30); 110 | employeeNameTF.setFont(Theme.FONT_INPUT); 111 | panel.add(employeeNameTF); 112 | 113 | employeePhoneTF1 = new JTextField("+880"); 114 | employeePhoneTF1.setBounds(180, 290, 40, 30); 115 | employeePhoneTF1.setEnabled(false); 116 | employeePhoneTF1.setFont(Theme.FONT_INPUT); 117 | panel.add(employeePhoneTF1); 118 | 119 | employeePhoneTF2 = new JTextField(); 120 | employeePhoneTF2.setBounds(220, 290, 180, 30); 121 | employeePhoneTF2.setFont(Theme.FONT_INPUT); 122 | panel.add(employeePhoneTF2); 123 | 124 | roleCB = new JComboBox(Employee.roles); 125 | roleCB.setBounds(180, 340, 160, 30); 126 | roleCB.setFont(Theme.FONT_INPUT); 127 | panel.add(roleCB); 128 | 129 | salaryTF = new JTextField(); 130 | salaryTF.setBounds(180, 390, 220, 30); 131 | salaryTF.setFont(Theme.FONT_INPUT); 132 | panel.add(salaryTF); 133 | 134 | buttonAdd = new JButton("Add"); 135 | buttonAdd.setBounds(60, 440, Theme.BUTTON_PRIMARY_WIDTH,30); 136 | buttonAdd.setFont(Theme.FONT_BUTTON); 137 | buttonAdd.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 138 | buttonAdd.setForeground(Theme.COLOR_BUTTON_PRIMARY); 139 | buttonAdd.addActionListener(this); 140 | panel.add(buttonAdd); 141 | 142 | header = new JLabel(); 143 | header.setBackground(Theme.BACKGROUND_HEADER); 144 | header.setOpaque(true); 145 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 146 | panel.add(header); 147 | 148 | this.add(panel); 149 | } 150 | 151 | public void actionPerformed(ActionEvent ae) { 152 | if (ae.getSource().equals(buttonLogout)) { 153 | this.setVisible(false); 154 | new LoginActivity().setVisible(true); 155 | } 156 | else if (ae.getSource().equals(buttonBack)) { 157 | this.setVisible(false); 158 | activity.setVisible(true); 159 | } 160 | else if (ae.getSource().equals(buttonAdd)) { 161 | try { 162 | Employee e = new Employee(employeeIdTF.getText().trim()); 163 | e.setPassword(passwordTF.getText().trim()); 164 | e.setEmployeeName(employeeNameTF.getText().trim()); 165 | e.setPhoneNumber(Integer.parseInt(employeePhoneTF2.getText())); 166 | e.setSalary(Double.parseDouble(salaryTF.getText())); 167 | e.setRole(roleCB.getSelectedItem().toString()); 168 | e.createEmployee(); 169 | employeeIdTF.setText(""); 170 | employeeNameTF.setText(""); 171 | employeePhoneTF2.setText(""); 172 | salaryTF.setText(""); 173 | roleCB.setSelectedIndex(0); 174 | if (!activity.keywordTF.getText().trim().isEmpty()) 175 | activity.table.setModel(Employee.searchEmployee(activity.keywordTF.getText().trim(), activity.byWhatCB.getSelectedItem().toString())); 176 | else 177 | activity.table.setModel(Employee.searchEmployee("", "By Name")); 178 | } 179 | catch (NumberFormatException e) { 180 | JOptionPane.showMessageDialog(this,"Enter phone no correctly!"); 181 | } 182 | catch (IllegalArgumentException e) { 183 | JOptionPane.showMessageDialog(this,e.getMessage()); 184 | } 185 | } 186 | else if (ae.getSource().equals(buttonRandom)) { 187 | passwordTF.setText(""+(r.nextInt(89999999)+10000000)); 188 | } 189 | else {} 190 | } 191 | } -------------------------------------------------------------------------------- /activity/ViewProductActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import java.util.*; 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import javax.swing.border.*; 8 | import java.awt.event.*; 9 | import javax.swing.table.*; 10 | import attr.*; 11 | 12 | public class ViewProductActivity extends JFrame implements ActionListener { 13 | private JPanel panel; 14 | private Customer customer; 15 | private JFrame activity; 16 | private Employee employee; 17 | private JScrollPane frame; 18 | JComboBox byWhatCB; 19 | JTable table; 20 | private JButton buttonLogout, buttonBack, buttonCheck, buttonAddProduct; 21 | private JLabel title, header, keywordLabel; 22 | JTextField keywordTF; 23 | public ViewProductActivity(JFrame prev, Customer customer) { 24 | super("View Product"); 25 | 26 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 27 | this.setResizable(false); 28 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 29 | this.setLocationRelativeTo(null); 30 | this.activity = prev; 31 | this.customer = customer; 32 | 33 | panel = new JPanel(); 34 | panel.setLayout(null); 35 | panel.setBackground(Theme.BACKGROUND_PANEL); 36 | 37 | title = new JLabel("View Product"); 38 | title.setBounds(30, 40, 300,75); 39 | title.setOpaque(true); 40 | title.setBorder(new EmptyBorder(0,20,0,0)); 41 | title.setFont(Theme.FONT_TITLE); 42 | title.setForeground(Theme.COLOR_TITLE); 43 | panel.add(title); 44 | 45 | buttonLogout = new JButton("Logout"); 46 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 47 | buttonLogout.setFont(Theme.FONT_BUTTON); 48 | buttonLogout.setBackground(Color.WHITE); 49 | buttonLogout.setForeground(Theme.COLOR_TITLE); 50 | buttonLogout.addActionListener(this); 51 | panel.add(buttonLogout); 52 | 53 | buttonBack = new JButton("Back"); 54 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 55 | buttonBack.setFont(Theme.FONT_BUTTON); 56 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 57 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 58 | buttonBack.addActionListener(this); 59 | panel.add(buttonBack); 60 | 61 | keywordLabel = new JLabel("Keyword: "); 62 | keywordLabel.setBounds(60, 140, 140, 30); 63 | keywordLabel.setFont(Theme.FONT_REGULAR); 64 | panel.add(keywordLabel); 65 | 66 | keywordTF = new JTextField(); 67 | keywordTF.setBounds(160, 140, 240, 30); 68 | keywordTF.setFont(Theme.FONT_INPUT); 69 | panel.add(keywordTF); 70 | 71 | byWhatCB = new JComboBox(new Object[]{"By ID", "By Name"}); 72 | byWhatCB.setBounds(400, 140, 100,30); 73 | byWhatCB.setFont(Theme.FONT_INPUT); 74 | panel.add(byWhatCB); 75 | 76 | buttonCheck = new JButton("Search"); 77 | buttonCheck.setBounds(500, 140, Theme.BUTTON_PRIMARY_WIDTH,30); 78 | buttonCheck.setFont(Theme.FONT_BUTTON); 79 | buttonCheck.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 80 | buttonCheck.setForeground(Theme.COLOR_BUTTON_PRIMARY); 81 | buttonCheck.addActionListener(this); 82 | panel.add(buttonCheck); 83 | 84 | table = new JTable(); 85 | DefaultTableModel model = new DefaultTableModel(); 86 | model.setColumnIdentifiers(Product.columnNames); 87 | table.setModel(model); 88 | table.addMouseListener(new MouseAdapter() { 89 | public void mouseClicked(MouseEvent evt) { 90 | jTable_ClickMouseClicked(evt); 91 | } 92 | }); 93 | frame = new JScrollPane(table); 94 | frame.setBounds(40,185,600,300); 95 | panel.add(frame); 96 | 97 | table.setModel(Product.searchProduct("", "By Name")); 98 | 99 | header = new JLabel(); 100 | header.setBackground(Theme.BACKGROUND_HEADER); 101 | header.setOpaque(true); 102 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 103 | panel.add(header); 104 | 105 | this.add(panel); 106 | } 107 | 108 | public ViewProductActivity(JFrame prev, Employee employee) { 109 | super("View Product"); 110 | 111 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 112 | this.setResizable(false); 113 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 114 | this.setLocationRelativeTo(null); 115 | this.activity = prev; 116 | this.employee = employee; 117 | 118 | panel = new JPanel(); 119 | panel.setLayout(null); 120 | panel.setBackground(Theme.BACKGROUND_PANEL); 121 | 122 | title = new JLabel("View Product"); 123 | title.setBounds(30, 40, 300,75); 124 | title.setOpaque(true); 125 | title.setBorder(new EmptyBorder(0,20,0,0)); 126 | title.setFont(Theme.FONT_TITLE); 127 | title.setForeground(Theme.COLOR_TITLE); 128 | panel.add(title); 129 | 130 | buttonLogout = new JButton("Logout"); 131 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30); 132 | buttonLogout.setFont(Theme.FONT_BUTTON); 133 | buttonLogout.setBackground(Color.WHITE); 134 | buttonLogout.setForeground(Theme.COLOR_TITLE); 135 | buttonLogout.addActionListener(this); 136 | panel.add(buttonLogout); 137 | 138 | buttonBack = new JButton("Back"); 139 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30); 140 | buttonBack.setFont(Theme.FONT_BUTTON); 141 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 142 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 143 | buttonBack.addActionListener(this); 144 | panel.add(buttonBack); 145 | 146 | buttonAddProduct = new JButton("Add"); 147 | buttonAddProduct.setBounds(Theme.GUI_WIDTH-140, 115, Theme.BUTTON_PRIMARY_WIDTH, 30); 148 | buttonAddProduct.setFont(Theme.FONT_BUTTON); 149 | buttonAddProduct.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 150 | buttonAddProduct.setForeground(Theme.COLOR_BUTTON_PRIMARY); 151 | buttonAddProduct.addActionListener(this); 152 | panel.add(buttonAddProduct); 153 | 154 | keywordLabel = new JLabel("Keyword: "); 155 | keywordLabel.setBounds(60, 140, 140, 30); 156 | keywordLabel.setFont(Theme.FONT_REGULAR); 157 | panel.add(keywordLabel); 158 | 159 | keywordTF = new JTextField(); 160 | keywordTF.setBounds(160, 140, 240, 30); 161 | keywordTF.setFont(Theme.FONT_INPUT); 162 | panel.add(keywordTF); 163 | 164 | byWhatCB = new JComboBox(new Object[]{"By ID", "By Name"}); 165 | byWhatCB.setBounds(400, 140, 100,30); 166 | byWhatCB.setFont(Theme.FONT_INPUT); 167 | panel.add(byWhatCB); 168 | 169 | buttonCheck = new JButton("Search"); 170 | buttonCheck.setBounds(500, 140, Theme.BUTTON_PRIMARY_WIDTH,30); 171 | buttonCheck.setFont(Theme.FONT_BUTTON); 172 | buttonCheck.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 173 | buttonCheck.setForeground(Theme.COLOR_BUTTON_PRIMARY); 174 | buttonCheck.addActionListener(this); 175 | panel.add(buttonCheck); 176 | 177 | table = new JTable(); 178 | DefaultTableModel model = new DefaultTableModel(); 179 | model.setColumnIdentifiers(Product.columnNames); 180 | table.setModel(model); 181 | table.addMouseListener(new MouseAdapter() { 182 | public void mouseClicked(MouseEvent evt) { 183 | jTable_ClickMouseClicked(evt); 184 | } 185 | }); 186 | frame = new JScrollPane(table); 187 | frame.setBounds(40,185,600,300); 188 | panel.add(frame); 189 | 190 | table.setModel(Product.searchProduct("", "By Name")); 191 | 192 | header = new JLabel(); 193 | header.setBackground(Theme.BACKGROUND_HEADER); 194 | header.setOpaque(true); 195 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 196 | panel.add(header); 197 | 198 | this.add(panel); 199 | } 200 | 201 | public void actionPerformed(ActionEvent ae) { 202 | if (ae.getSource().equals(buttonLogout)) { 203 | this.setVisible(false); 204 | new LoginActivity().setVisible(true); 205 | } 206 | else if (ae.getSource().equals(buttonBack)) { 207 | this.setVisible(false); 208 | activity.setVisible(true); 209 | } 210 | else if (ae.getSource().equals(buttonCheck)) { 211 | table.setModel(Product.searchProduct(keywordTF.getText().trim(), byWhatCB.getSelectedItem().toString())); 212 | } 213 | else if (ae.getSource().equals(buttonAddProduct)) { 214 | this.setVisible(false); 215 | new AddProductActivity(this, employee).setVisible(true); 216 | } 217 | else {} 218 | } 219 | 220 | private void jTable_ClickMouseClicked(MouseEvent evt) { 221 | int index = table.getSelectedRow(); 222 | 223 | TableModel model = table.getModel(); 224 | 225 | String value1 = model.getValueAt(index, 0).toString(); 226 | 227 | if (customer!=null) {} 228 | else if (employee!=null) 229 | new ManageProduct(value1, this).setVisible(true); 230 | else {} 231 | } 232 | } -------------------------------------------------------------------------------- /attr/Employee.java: -------------------------------------------------------------------------------- 1 | package attr; 2 | 3 | import java.lang.*; 4 | import java.sql.*; 5 | import javax.swing.*; 6 | import javax.swing.table.*; 7 | import attr.*; 8 | import activity.*; 9 | 10 | public class Employee extends User { 11 | private String employeeName; 12 | private String phoneNumber; 13 | private String role; 14 | public static String[] columnNames = {"EmployeeID", "EmployeeName", "PhoneNumber", "Role", "Salary"}; 15 | public static String[] roles = {"General", "Manager"}; 16 | private double salary; 17 | public Employee(String userId) { 18 | super(userId); 19 | this.setStatus(0); 20 | } 21 | 22 | public void setEmployeeName(String name) { 23 | if (!name.isEmpty()) 24 | this.employeeName = name; 25 | else 26 | throw new IllegalArgumentException("Fill in the name"); 27 | } 28 | public void setPhoneNumber(int num) { 29 | this.phoneNumber = "+880"+num; 30 | } 31 | public void setRole(String role) { 32 | this.role = role; 33 | } 34 | public void setSalary(double salary) { 35 | this.salary = salary; 36 | } 37 | public String getPhoneNumber() { 38 | return phoneNumber; 39 | } 40 | public String getEmployeeName() { 41 | return employeeName; 42 | } 43 | public String getRole() { 44 | return role; 45 | } 46 | public double getSalary() { 47 | return salary; 48 | } 49 | 50 | public void createEmployee() { 51 | String query1 = "INSERT INTO `login` VALUES ('"+userId+"','"+password+"',"+status+");"; 52 | String query2 = "INSERT INTO `employee` VALUES ('"+userId+"','"+employeeName+"','"+phoneNumber+"','"+role+"', '"+salary+"');"; 53 | Connection con = null; 54 | Statement st = null; 55 | System.out.println(query1); 56 | System.out.println(query2); 57 | try { 58 | Class.forName("com.mysql.jdbc.Driver"); 59 | System.out.println("driver loaded"); 60 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 61 | System.out.println("connection done");//connection with database established 62 | st = con.createStatement();//create statement 63 | System.out.println("statement created"); 64 | st.execute(query1);//insert 65 | st.execute(query2); 66 | System.out.println("data inserted"); 67 | JOptionPane.showMessageDialog(null,"Account Created!"); 68 | } 69 | catch(Exception ex) { 70 | JOptionPane.showMessageDialog(null,"Failed to create account!"); 71 | System.out.println("Exception : " +ex.getMessage()); 72 | } 73 | finally { 74 | try { 75 | if(st!=null) 76 | st.close(); 77 | 78 | if(con!=null) 79 | con.close(); 80 | } 81 | catch(Exception ex) {} 82 | } 83 | } 84 | 85 | public void fetch() { 86 | String query = "SELECT `userId`, `employeeName`, `phoneNumber`, `role`, `salary` FROM `employee` WHERE userId='"+this.userId+"';"; 87 | Connection con = null; 88 | Statement st = null; 89 | ResultSet rs = null; 90 | System.out.println(query); 91 | try { 92 | Class.forName("com.mysql.jdbc.Driver"); 93 | System.out.println("driver loaded"); 94 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 95 | System.out.println("connection done");//connection with database established 96 | st = con.createStatement();//create statement 97 | System.out.println("statement created"); 98 | rs = st.executeQuery(query);//getting result 99 | System.out.println("results received"); 100 | boolean flag = false; 101 | while(rs.next()) { 102 | this.employeeName = rs.getString("employeeName"); 103 | this.phoneNumber = rs.getString("phoneNumber"); 104 | this.role = rs.getString("role"); 105 | this.salary = rs.getDouble("salary"); 106 | } 107 | } 108 | catch(Exception ex) { 109 | System.out.println("Exception : " +ex.getMessage()); 110 | } 111 | finally { 112 | try { 113 | if(rs!=null) 114 | rs.close(); 115 | 116 | if(st!=null) 117 | st.close(); 118 | 119 | if(con!=null) 120 | con.close(); 121 | } 122 | catch(Exception ex) {} 123 | } 124 | } 125 | 126 | public void updateEmployee(String name, int phone, String role, double salary) { 127 | String query = "UPDATE `employee` SET `employeeName`='"+name+"', `phoneNumber`='+880"+phone+"', `role`='"+role+"', `salary`="+salary+" WHERE `userId`='"+this.userId+"';"; 128 | Connection con = null; 129 | Statement st = null; 130 | System.out.println(query); 131 | try { 132 | Class.forName("com.mysql.jdbc.Driver"); 133 | System.out.println("driver loaded"); 134 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 135 | System.out.println("connection done");//connection with database established 136 | st = con.createStatement();//create statement 137 | System.out.println("statement created"); 138 | st.executeUpdate(query);//insert 139 | System.out.println("data inserted"); 140 | JOptionPane.showMessageDialog(null,"Information Updated!"); 141 | this.employeeName = name; 142 | this.phoneNumber = "+880"+phone; 143 | this.role = role; 144 | this.salary = salary; 145 | } 146 | catch(Exception ex) { 147 | JOptionPane.showMessageDialog(null,"Failed to update account!"); 148 | System.out.println("Exception : " +ex.getMessage()); 149 | } 150 | finally { 151 | try { 152 | if(st!=null) 153 | st.close(); 154 | 155 | if(con!=null) 156 | con.close(); 157 | } 158 | catch(Exception ex) {} 159 | } 160 | } 161 | 162 | public void deleteEmployee() { 163 | String query1 = "DELETE FROM `login` WHERE `userId`='"+this.userId+"';"; 164 | String query2 = "DELETE FROM `employee` WHERE `userId`='"+this.userId+"';"; 165 | Connection con = null; 166 | Statement st = null; 167 | System.out.println(query1); 168 | System.out.println(query2); 169 | try { 170 | Class.forName("com.mysql.jdbc.Driver"); 171 | System.out.println("driver loaded"); 172 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 173 | System.out.println("connection done");//connection with database established 174 | st = con.createStatement();//create statement 175 | System.out.println("statement created"); 176 | st.execute(query1); 177 | st.execute(query2);//delete 178 | System.out.println("data deleted"); 179 | JOptionPane.showMessageDialog(null,"Account Deleted!"); 180 | this.userId = ""; 181 | this.employeeName = ""; 182 | this.phoneNumber = ""; 183 | this.role = ""; 184 | this.salary = 0; 185 | } 186 | catch(Exception ex) { 187 | JOptionPane.showMessageDialog(null,"Failed to delete account!"); 188 | System.out.println("Exception : " +ex.getMessage()); 189 | } 190 | finally { 191 | try { 192 | if(st!=null) 193 | st.close(); 194 | 195 | if(con!=null) 196 | con.close(); 197 | } 198 | catch(Exception ex) {} 199 | } 200 | } 201 | 202 | public static DefaultTableModel searchEmployee(String keyword, String byWhat) { 203 | DefaultTableModel model = new DefaultTableModel(); 204 | model.setColumnIdentifiers(columnNames); 205 | String query = "SELECT * FROM `employee` WHERE `userId`='"+keyword+"';"; 206 | if (byWhat.equals("By Name")) 207 | query = "SELECT * FROM `employee` WHERE `employeeName` LIKE '%"+keyword+"%';"; 208 | else {} 209 | Connection con = null; 210 | Statement st = null; 211 | ResultSet rs = null; 212 | System.out.println(query); 213 | try { 214 | Class.forName("com.mysql.jdbc.Driver"); 215 | System.out.println("driver loaded"); 216 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 217 | System.out.println("connection done");//connection with database established 218 | st = con.createStatement();//create statement 219 | System.out.println("statement created"); 220 | rs = st.executeQuery(query);//getting result 221 | System.out.println("results received"); 222 | 223 | while(rs.next()) { 224 | model.addRow(new Object[]{rs.getString("userId"), rs.getString("employeeName"), rs.getString("phoneNumber"), rs.getString("role"), rs.getString("salary")}); 225 | } 226 | } 227 | catch(Exception ex) { 228 | System.out.println("Exception : " +ex.getMessage()); 229 | } 230 | finally { 231 | try { 232 | if(rs!=null) 233 | rs.close(); 234 | 235 | if(st!=null) 236 | st.close(); 237 | 238 | if(con!=null) 239 | con.close(); 240 | } 241 | catch(Exception ex) {} 242 | } 243 | return model; 244 | } 245 | } -------------------------------------------------------------------------------- /attr/Product.java: -------------------------------------------------------------------------------- 1 | package attr; 2 | 3 | import java.lang.*; 4 | import java.util.*; 5 | import java.sql.*; 6 | import javax.swing.table.*; 7 | import java.awt.*; 8 | import java.text.*; 9 | import attr.*; 10 | import activity.*; 11 | import javax.swing.*; 12 | 13 | public class Product { 14 | private String productId; 15 | private String productName; 16 | private double price; 17 | private int quantity; 18 | public static String[] columnNames = {"PID", "Name", "Price", "AvailableQuantity"}; 19 | 20 | public Product() {} 21 | public Product(String productId) { 22 | if (!productId.isEmpty()) 23 | this.productId = productId; 24 | else 25 | throw new IllegalArgumentException("Fill in the ID"); 26 | } 27 | 28 | public void setProductName(String name) { 29 | if (!name.isEmpty()) 30 | this.productName = name; 31 | else 32 | throw new IllegalArgumentException("Fill in the name"); 33 | } 34 | public void setPrice(double p) { 35 | this.price = p; 36 | } 37 | public void setQuantity(int q) { 38 | this.quantity = q; 39 | } 40 | public String getProductId() { 41 | return productId; 42 | } 43 | public String getProductName() { 44 | return productName; 45 | } 46 | public double getPrice() { 47 | return price; 48 | } 49 | public int getQuantity() { 50 | return quantity; 51 | } 52 | 53 | public void fetch() { 54 | String query = "SELECT `productId`, `productName`, `price`, `quantity` FROM `product` WHERE productId='"+this.productId+"';"; 55 | Connection con = null; 56 | Statement st = null; 57 | ResultSet rs = null; 58 | System.out.println(query); 59 | try { 60 | Class.forName("com.mysql.jdbc.Driver"); 61 | System.out.println("driver loaded"); 62 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 63 | System.out.println("connection done");//connection with database established 64 | st = con.createStatement();//create statement 65 | System.out.println("statement created"); 66 | rs = st.executeQuery(query);//getting result 67 | System.out.println("results received"); 68 | 69 | while(rs.next()) { 70 | this.productName = rs.getString("productName"); 71 | this.price = rs.getDouble("price"); 72 | this.quantity = rs.getInt("quantity"); 73 | } 74 | } 75 | catch(Exception ex) { 76 | System.out.println("Exception : " +ex.getMessage()); 77 | } 78 | finally { 79 | try { 80 | if(rs!=null) 81 | rs.close(); 82 | 83 | if(st!=null) 84 | st.close(); 85 | 86 | if(con!=null) 87 | con.close(); 88 | } 89 | catch(Exception ex) {} 90 | } 91 | } 92 | 93 | public void sellProduct(String uid, int amount) { 94 | String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); 95 | String query = "INSERT INTO `purchaseInfo` (`userId`, `productId`, `amount`, `date`, `cost`) VALUES ('"+uid+"','"+this.productId+"',"+amount+", '"+date+"', "+(amount*this.price)+");"; 96 | Connection con = null; 97 | Statement st = null; 98 | System.out.println(query); 99 | try { 100 | Class.forName("com.mysql.jdbc.Driver"); 101 | System.out.println("driver loaded"); 102 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 103 | System.out.println("connection done");//connection with database established 104 | st = con.createStatement();//create statement 105 | System.out.println("statement created"); 106 | st.execute(query);//insert 107 | System.out.println("data inserted"); 108 | updateProduct(this.productName, this.price, this.quantity-amount); 109 | } 110 | catch(Exception ex) { 111 | JOptionPane.showMessageDialog(null,"Customer doesn't exist!"); 112 | System.out.println("Exception : " +ex.getMessage()); 113 | } 114 | finally { 115 | try { 116 | if(st!=null) 117 | st.close(); 118 | 119 | if(con!=null) 120 | con.close(); 121 | } 122 | catch(Exception ex) {} 123 | } 124 | } 125 | 126 | public void updateProduct(String name, double price, int quantity) { 127 | String query = "UPDATE `product` SET `productName`='"+name+"', `price`="+price+", `quantity`="+quantity+" WHERE `productId`='"+this.productId+"';"; 128 | Connection con = null; 129 | Statement st = null; 130 | System.out.println(query); 131 | try { 132 | Class.forName("com.mysql.jdbc.Driver"); 133 | System.out.println("driver loaded"); 134 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 135 | System.out.println("connection done");//connection with database established 136 | st = con.createStatement();//create statement 137 | System.out.println("statement created"); 138 | st.executeUpdate(query);//insert 139 | System.out.println("data inserted"); 140 | JOptionPane.showMessageDialog(null,"Done!"); 141 | } 142 | catch(Exception ex) { 143 | JOptionPane.showMessageDialog(null,"Failed!"); 144 | System.out.println("Exception : " +ex.getMessage()); 145 | } 146 | finally { 147 | try { 148 | if(st!=null) 149 | st.close(); 150 | 151 | if(con!=null) 152 | con.close(); 153 | } 154 | catch(Exception ex) {} 155 | } 156 | } 157 | 158 | public void createProduct() { 159 | String query = "INSERT INTO `product` (`productName`, `price`, `quantity`) VALUES ('"+productName+"','"+price+"','"+quantity+"');"; 160 | Connection con = null; 161 | Statement st = null; 162 | System.out.println(query); 163 | try { 164 | Class.forName("com.mysql.jdbc.Driver"); 165 | System.out.println("driver loaded"); 166 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 167 | System.out.println("connection done");//connection with database established 168 | st = con.createStatement();//create statement 169 | System.out.println("statement created"); 170 | st.execute(query);//insert 171 | System.out.println("data inserted"); 172 | JOptionPane.showMessageDialog(null,"Product Created!"); 173 | } 174 | catch(Exception ex) { 175 | JOptionPane.showMessageDialog(null,"Failed to add Product!"); 176 | System.out.println("Exception : " +ex.getMessage()); 177 | } 178 | finally { 179 | try { 180 | if(st!=null) 181 | st.close(); 182 | 183 | if(con!=null) 184 | con.close(); 185 | } 186 | catch(Exception ex) {} 187 | } 188 | } 189 | 190 | public static DefaultTableModel searchProduct(String keyword, String byWhat) { 191 | DefaultTableModel model = new DefaultTableModel(); 192 | model.setColumnIdentifiers(columnNames); 193 | String query = "SELECT `productId`, `productName`, `price`, `quantity` FROM `product` WHERE `productId`='"+keyword+"';"; 194 | if (byWhat.equals("By Name")) 195 | query = "SELECT `productId`, `productName`, `price`, `quantity` FROM `product` WHERE `productName` LIKE '%"+keyword+"%';"; 196 | else {} 197 | Connection con = null; 198 | Statement st = null; 199 | ResultSet rs = null; 200 | System.out.println(query); 201 | try { 202 | Class.forName("com.mysql.jdbc.Driver"); 203 | System.out.println("driver loaded"); 204 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 205 | System.out.println("connection done");//connection with database established 206 | st = con.createStatement();//create statement 207 | System.out.println("statement created"); 208 | rs = st.executeQuery(query);//getting result 209 | System.out.println("results received"); 210 | 211 | while(rs.next()) { 212 | model.addRow(new Object[]{rs.getString("productId"), rs.getString("productName"), rs.getDouble("price"), rs.getInt("quantity")}); 213 | } 214 | } 215 | catch(Exception ex) { 216 | System.out.println("Exception : " +ex.getMessage()); 217 | } 218 | finally { 219 | try { 220 | if(rs!=null) 221 | rs.close(); 222 | 223 | if(st!=null) 224 | st.close(); 225 | 226 | if(con!=null) 227 | con.close(); 228 | } 229 | catch(Exception ex) {} 230 | } 231 | return model; 232 | } 233 | 234 | public void deleteProduct() { 235 | String query1 = "DELETE FROM `product` WHERE `productId`='"+this.productId+"';"; 236 | Connection con = null; 237 | Statement st = null; 238 | System.out.println(query1); 239 | try { 240 | Class.forName("com.mysql.jdbc.Driver"); 241 | System.out.println("driver loaded"); 242 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 243 | System.out.println("connection done");//connection with database established 244 | st = con.createStatement();//create statement 245 | System.out.println("statement created"); 246 | st.execute(query1);//delete 247 | System.out.println("data deleted"); 248 | JOptionPane.showMessageDialog(null,"Product Deleted!"); 249 | } 250 | catch(Exception ex) { 251 | JOptionPane.showMessageDialog(null,"Failed to delete product!"); 252 | System.out.println("Exception : " +ex.getMessage()); 253 | } 254 | finally { 255 | try { 256 | if(st!=null) 257 | st.close(); 258 | 259 | if(con!=null) 260 | con.close(); 261 | } 262 | catch(Exception ex) {} 263 | } 264 | } 265 | } -------------------------------------------------------------------------------- /attr/Customer.java: -------------------------------------------------------------------------------- 1 | package attr; 2 | 3 | import java.lang.*; 4 | import java.util.*; 5 | import java.text.*; 6 | import javax.swing.*; 7 | import javax.swing.table.*; 8 | import java.sql.*; 9 | import attr.*; 10 | import activity.*; 11 | 12 | public class Customer extends User { 13 | private String customerName; 14 | private String phoneNumber; 15 | private String address; 16 | public static String[] columnNames = {"PurchaseID", "ProductID", "ProductName", "Amount", "Cost", "Date"}; 17 | public static String[] columnName = {"CustomerID", "CustomerName", "PhoneNumber", "Address"}; 18 | public Customer(String userId) { 19 | super(userId); 20 | 21 | this.setStatus(1); 22 | } 23 | 24 | public void setCustomerName(String name) { 25 | if (!name.isEmpty()) 26 | this.customerName = name; 27 | else 28 | throw new IllegalArgumentException("Fill in the name"); 29 | } 30 | public void setPhoneNumber(int num) { 31 | this.phoneNumber = "+880"+num; 32 | } 33 | public void setAddress(String address) { 34 | if (!address.isEmpty()) 35 | this.address = address; 36 | else 37 | throw new IllegalArgumentException("Fill in the address"); 38 | } 39 | public String getCustomerName() { 40 | return customerName; 41 | } 42 | public String getPhoneNumber() { 43 | return phoneNumber; 44 | } 45 | public String getAddress() { 46 | return address; 47 | } 48 | 49 | public void createCustomer(JFrame sa) { 50 | String query1 = "INSERT INTO `login` VALUES ('"+userId+"','"+password+"',"+status+");"; 51 | String query2 = "INSERT INTO `customer` VALUES ('"+userId+"','"+customerName+"','"+phoneNumber+"','"+address+"');"; 52 | Connection con = null; 53 | Statement st = null; 54 | System.out.println(query1); 55 | System.out.println(query2); 56 | try { 57 | Class.forName("com.mysql.jdbc.Driver"); 58 | System.out.println("driver loaded"); 59 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 60 | System.out.println("connection done");//connection with database established 61 | st = con.createStatement();//create statement 62 | System.out.println("statement created"); 63 | st.execute(query1);//insert 64 | st.execute(query2); 65 | System.out.println("data inserted"); 66 | JOptionPane.showMessageDialog(sa,"Account Created!"); 67 | sa.setVisible(false); 68 | new LoginActivity().setVisible(true); 69 | } 70 | catch(Exception ex) { 71 | JOptionPane.showMessageDialog(sa,"Failed to create account!"); 72 | System.out.println("Exception : " +ex.getMessage()); 73 | } 74 | finally { 75 | try { 76 | if(st!=null) 77 | st.close(); 78 | 79 | if(con!=null) 80 | con.close(); 81 | } 82 | catch(Exception ex) {} 83 | } 84 | } 85 | 86 | public void fetch() { 87 | String query = "SELECT `userId`, `customerName`, `phoneNumber`, `address` FROM `customer` WHERE userId='"+this.userId+"';"; 88 | Connection con = null; 89 | Statement st = null; 90 | ResultSet rs = null; 91 | System.out.println(query); 92 | try { 93 | Class.forName("com.mysql.jdbc.Driver"); 94 | System.out.println("driver loaded"); 95 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 96 | System.out.println("connection done");//connection with database established 97 | st = con.createStatement();//create statement 98 | System.out.println("statement created"); 99 | rs = st.executeQuery(query);//getting result 100 | System.out.println("results received"); 101 | 102 | while(rs.next()) { 103 | this.customerName = rs.getString("customerName"); 104 | this.phoneNumber = rs.getString("phoneNumber"); 105 | this.address = rs.getString("address"); 106 | } 107 | } 108 | catch(Exception ex) { 109 | System.out.println("Exception : " +ex.getMessage()); 110 | } 111 | finally { 112 | try { 113 | if(rs!=null) 114 | rs.close(); 115 | 116 | if(st!=null) 117 | st.close(); 118 | 119 | if(con!=null) 120 | con.close(); 121 | } 122 | catch(Exception ex) {} 123 | } 124 | } 125 | 126 | public void updateCustomer(String name, int phone, String address) { 127 | String query = "UPDATE `customer` SET `customerName`='"+name+"', `phoneNumber`='+880"+phone+"', `address`='"+address+"' WHERE `userId`='"+this.userId+"';"; 128 | Connection con = null; 129 | Statement st = null; 130 | System.out.println(query); 131 | try { 132 | Class.forName("com.mysql.jdbc.Driver"); 133 | System.out.println("driver loaded"); 134 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 135 | System.out.println("connection done");//connection with database established 136 | st = con.createStatement();//create statement 137 | System.out.println("statement created"); 138 | st.executeUpdate(query);//insert 139 | System.out.println("data inserted"); 140 | JOptionPane.showMessageDialog(null,"Information Updated!"); 141 | this.customerName = name; 142 | this.phoneNumber = "+880"+phone; 143 | this.address = address; 144 | } 145 | catch(Exception ex) { 146 | JOptionPane.showMessageDialog(null,"Failed to update account!"); 147 | System.out.println("Exception : " +ex.getMessage()); 148 | } 149 | finally { 150 | try { 151 | if(st!=null) 152 | st.close(); 153 | 154 | if(con!=null) 155 | con.close(); 156 | } 157 | catch(Exception ex) {} 158 | } 159 | } 160 | public void deleteCustomer() { 161 | String query1 = "DELETE FROM `login` WHERE `userId`='"+this.userId+"';"; 162 | String query2 = "DELETE FROM `customer` WHERE `userId`='"+this.userId+"';"; 163 | Connection con = null; 164 | Statement st = null; 165 | System.out.println(query1); 166 | System.out.println(query2); 167 | try { 168 | Class.forName("com.mysql.jdbc.Driver"); 169 | System.out.println("driver loaded"); 170 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 171 | System.out.println("connection done");//connection with database established 172 | st = con.createStatement();//create statement 173 | System.out.println("statement created"); 174 | st.execute(query1); 175 | st.execute(query2);//delete 176 | System.out.println("data deleted"); 177 | JOptionPane.showMessageDialog(null,"Account Deleted!"); 178 | this.userId = ""; 179 | this.customerName = ""; 180 | this.phoneNumber = ""; 181 | this.address = ""; 182 | } 183 | catch(Exception ex) { 184 | JOptionPane.showMessageDialog(null,"Failed to delete account!"); 185 | System.out.println("Exception : " +ex.getMessage()); 186 | } 187 | finally { 188 | try { 189 | if(st!=null) 190 | st.close(); 191 | 192 | if(con!=null) 193 | con.close(); 194 | } 195 | catch(Exception ex) {} 196 | } 197 | } 198 | 199 | public DefaultTableModel myProduct() { 200 | DefaultTableModel model = new DefaultTableModel(); 201 | model.setColumnIdentifiers(columnNames); 202 | String query = "SELECT purchaseInfo.purchaseId, purchaseInfo.productId, product.productName, purchaseInfo.cost, purchaseInfo.amount, purchaseInfo.date FROM purchaseInfo, product WHERE (`purchaseInfo`.`userId`='"+this.userId+"' AND `purchaseInfo`.`productId`=`product`.`productId`) ORDER BY `date` DESC;"; 203 | Connection con = null; 204 | Statement st = null; 205 | ResultSet rs = null; 206 | System.out.println(query); 207 | try { 208 | Class.forName("com.mysql.jdbc.Driver"); 209 | System.out.println("driver loaded"); 210 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 211 | System.out.println("connection done");//connection with database established 212 | st = con.createStatement();//create statement 213 | System.out.println("statement created"); 214 | rs = st.executeQuery(query);//getting result 215 | System.out.println("results received"); 216 | 217 | while(rs.next()) { 218 | String col1 = rs.getString("purchaseId"); 219 | String col2 = rs.getString("productId"); 220 | String col3 = rs.getString("productName"); 221 | int col4 = rs.getInt("amount"); 222 | double col5 = rs.getDouble("cost"); 223 | String col6 = rs.getString("date"); 224 | model.addRow(new Object[]{col1, col2, col3, col4, col5, col6}); 225 | } 226 | } 227 | catch(Exception ex) { 228 | System.out.println("Exception : " +ex.getMessage()); 229 | } 230 | finally { 231 | try { 232 | if(rs!=null) 233 | rs.close(); 234 | 235 | if(st!=null) 236 | st.close(); 237 | 238 | if(con!=null) 239 | con.close(); 240 | } 241 | catch(Exception ex) {} 242 | } 243 | return model; 244 | } 245 | 246 | public static DefaultTableModel searchCustomer(String keyword, String byWhat) { 247 | DefaultTableModel model = new DefaultTableModel(); 248 | model.setColumnIdentifiers(columnName); 249 | String query = "SELECT * FROM `customer` WHERE `userId`='"+keyword+"';"; 250 | if (byWhat.equals("By Name")) 251 | query = "SELECT * FROM `customer` WHERE `customerName` LIKE '%"+keyword+"%';"; 252 | else {} 253 | Connection con = null; 254 | Statement st = null; 255 | ResultSet rs = null; 256 | System.out.println(query); 257 | try { 258 | Class.forName("com.mysql.jdbc.Driver"); 259 | System.out.println("driver loaded"); 260 | con = DriverManager.getConnection(Database.HOST_URI, Database.USER, Database.PASSWORD); 261 | System.out.println("connection done");//connection with database established 262 | st = con.createStatement();//create statement 263 | System.out.println("statement created"); 264 | rs = st.executeQuery(query);//getting result 265 | System.out.println("results received"); 266 | 267 | while(rs.next()) { 268 | model.addRow(new Object[]{rs.getString("userId"), rs.getString("customerName"), rs.getString("phoneNumber"), rs.getString("address")}); 269 | } 270 | } 271 | catch(Exception ex) { 272 | System.out.println("Exception : " +ex.getMessage()); 273 | } 274 | finally { 275 | try { 276 | if(rs!=null) 277 | rs.close(); 278 | 279 | if(st!=null) 280 | st.close(); 281 | 282 | if(con!=null) 283 | con.close(); 284 | } 285 | catch(Exception ex) {} 286 | } 287 | return model; 288 | } 289 | } -------------------------------------------------------------------------------- /activity/MyProfileActivity.java: -------------------------------------------------------------------------------- 1 | package activity; 2 | 3 | import java.lang.*; 4 | import javax.swing.*; 5 | import java.awt.*; 6 | import javax.swing.border.*; 7 | import java.awt.event.*; 8 | import attr.*; 9 | 10 | public class MyProfileActivity extends JFrame implements ActionListener { 11 | private JPanel panel; 12 | private JButton buttonEdit, buttonBack, buttonLogout, buttonSubmit, buttonPass, buttonDelete; 13 | private JFrame backActivity; 14 | private User usr; 15 | private Employee employee; 16 | private Customer customer; 17 | private JLabel title, header, usernameLabel, nameLabel, phoneLabel, addressLabel; 18 | private JTextField nameTF, phoneTF1, phoneTF2, addressTF; 19 | private JLabel roleLabel, salaryLabel; 20 | public MyProfileActivity(JFrame activity, Customer customer) { 21 | super("My Profile"); 22 | 23 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 24 | this.setResizable(false); 25 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 26 | this.setLocationRelativeTo(null); 27 | 28 | panel = new JPanel(); 29 | panel.setLayout(null); 30 | panel.setBackground(Theme.BACKGROUND_PANEL); 31 | 32 | backActivity = activity; 33 | this.customer = customer; 34 | this.usr = (User) customer; 35 | 36 | title = new JLabel("My Profile"); 37 | title.setBounds(30, 40, 260,75); 38 | title.setOpaque(true); 39 | title.setBorder(new EmptyBorder(0,20,0,0)); 40 | title.setFont(Theme.FONT_TITLE); 41 | title.setForeground(Theme.COLOR_TITLE); 42 | panel.add(title); 43 | 44 | buttonEdit = new JButton("Edit Profile"); 45 | buttonEdit.setBounds(60, 330, 120, 30); 46 | buttonEdit.setFont(Theme.FONT_BUTTON); 47 | buttonEdit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 48 | buttonEdit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 49 | buttonEdit.addActionListener(this); 50 | panel.add(buttonEdit); 51 | 52 | buttonSubmit = new JButton("Submit"); 53 | buttonSubmit.setBounds(60, 330, 120, 30); 54 | buttonSubmit.setFont(Theme.FONT_BUTTON); 55 | buttonSubmit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 56 | buttonSubmit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 57 | buttonSubmit.setVisible(false); 58 | buttonSubmit.addActionListener(this); 59 | panel.add(buttonSubmit); 60 | 61 | buttonPass = new JButton("Change Password"); 62 | buttonPass.setBounds(Theme.GUI_WIDTH-180, 115, 160, 30); 63 | buttonPass.setFont(Theme.FONT_BUTTON); 64 | buttonPass.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 65 | buttonPass.setForeground(Theme.COLOR_BUTTON_PRIMARY); 66 | buttonPass.addActionListener(this); 67 | panel.add(buttonPass); 68 | 69 | buttonDelete = new JButton("Delete Account"); 70 | buttonDelete.setBounds(Theme.GUI_WIDTH-180, 150, 160, 30); 71 | buttonDelete.setFont(Theme.FONT_BUTTON); 72 | buttonDelete.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 73 | buttonDelete.setForeground(Theme.COLOR_BUTTON_PRIMARY); 74 | buttonDelete.addActionListener(this); 75 | panel.add(buttonDelete); 76 | 77 | buttonLogout = new JButton("Logout"); 78 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH, 30); 79 | buttonLogout.setFont(Theme.FONT_BUTTON); 80 | buttonLogout.setBackground(Color.WHITE); 81 | buttonLogout.setForeground(Theme.COLOR_TITLE); 82 | buttonLogout.addActionListener(this); 83 | panel.add(buttonLogout); 84 | 85 | buttonBack = new JButton("Back"); 86 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH, 30); 87 | buttonBack.setFont(Theme.FONT_BUTTON); 88 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 89 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 90 | buttonBack.addActionListener(this); 91 | panel.add(buttonBack); 92 | 93 | usernameLabel = new JLabel("User ID: "+customer.getUserId()); 94 | usernameLabel.setBounds(60, 140, 440, 30); 95 | usernameLabel.setFont(Theme.FONT_REGULAR); 96 | panel.add(usernameLabel); 97 | 98 | nameLabel = new JLabel("Name: "); 99 | nameLabel.setBounds(60, 190, 440, 30); 100 | nameLabel.setFont(Theme.FONT_REGULAR); 101 | panel.add(nameLabel); 102 | 103 | phoneLabel = new JLabel("Phone No: "); 104 | phoneLabel.setBounds(60, 240, 440, 30); 105 | phoneLabel.setFont(Theme.FONT_REGULAR); 106 | panel.add(phoneLabel); 107 | 108 | nameTF = new JTextField(customer.getCustomerName()); 109 | nameTF.setBounds(180, 190, 220, 30); 110 | nameTF.setFont(Theme.FONT_INPUT); 111 | nameTF.setEnabled(false); 112 | nameTF.setDisabledTextColor(Color.BLACK); 113 | panel.add(nameTF); 114 | 115 | phoneTF1 = new JTextField("+880"); 116 | phoneTF1.setBounds(180, 240, 40, 30); 117 | phoneTF1.setFont(Theme.FONT_INPUT); 118 | phoneTF1.setEnabled(false); 119 | phoneTF1.setDisabledTextColor(Color.BLACK); 120 | panel.add(phoneTF1); 121 | 122 | phoneTF2 = new JTextField(customer.getPhoneNumber().substring(4)); 123 | phoneTF2.setBounds(220, 240, 180, 30); 124 | phoneTF2.setFont(Theme.FONT_INPUT); 125 | phoneTF2.setEnabled(false); 126 | phoneTF2.setDisabledTextColor(Color.BLACK); 127 | panel.add(phoneTF2); 128 | 129 | addressTF = new JTextField(customer.getAddress()); 130 | addressTF.setBounds(180, 290, 220, 30); 131 | addressTF.setEnabled(false); 132 | addressTF.setFont(Theme.FONT_INPUT); 133 | addressTF.setDisabledTextColor(Color.BLACK); 134 | panel.add(addressTF); 135 | 136 | addressLabel = new JLabel("Address: "); 137 | addressLabel.setBounds(60, 290, 440, 30); 138 | addressLabel.setFont(Theme.FONT_REGULAR); 139 | panel.add(addressLabel); 140 | 141 | header = new JLabel(); 142 | header.setBackground(Theme.BACKGROUND_HEADER); 143 | header.setOpaque(true); 144 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 145 | panel.add(header); 146 | 147 | this.add(panel); 148 | } 149 | 150 | public MyProfileActivity(JFrame activity, Employee employee) { 151 | super("My Profile"); 152 | 153 | this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT); 154 | this.setResizable(false); 155 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 156 | this.setLocationRelativeTo(null); 157 | 158 | panel = new JPanel(); 159 | panel.setLayout(null); 160 | panel.setBackground(Theme.BACKGROUND_PANEL); 161 | 162 | backActivity = activity; 163 | this.employee = employee; 164 | this.usr = (User) employee; 165 | 166 | title = new JLabel("My Profile"); 167 | title.setBounds(30, 40, 260,75); 168 | title.setOpaque(true); 169 | title.setBorder(new EmptyBorder(0,20,0,0)); 170 | title.setFont(Theme.FONT_TITLE); 171 | title.setForeground(Theme.COLOR_TITLE); 172 | panel.add(title); 173 | 174 | buttonEdit = new JButton("Edit Profile"); 175 | buttonEdit.setBounds(60, 380, 120, 30); 176 | buttonEdit.setFont(Theme.FONT_BUTTON); 177 | buttonEdit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 178 | buttonEdit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 179 | buttonEdit.addActionListener(this); 180 | panel.add(buttonEdit); 181 | 182 | buttonSubmit = new JButton("Submit"); 183 | buttonSubmit.setBounds(60, 380, 120, 30); 184 | buttonSubmit.setFont(Theme.FONT_BUTTON); 185 | buttonSubmit.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 186 | buttonSubmit.setForeground(Theme.COLOR_BUTTON_PRIMARY); 187 | buttonSubmit.setVisible(false); 188 | buttonSubmit.addActionListener(this); 189 | panel.add(buttonSubmit); 190 | 191 | buttonPass = new JButton("Change Password"); 192 | buttonPass.setBounds(Theme.GUI_WIDTH-180, 115, 160, 30); 193 | buttonPass.setFont(Theme.FONT_BUTTON); 194 | buttonPass.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 195 | buttonPass.setForeground(Theme.COLOR_BUTTON_PRIMARY); 196 | buttonPass.addActionListener(this); 197 | panel.add(buttonPass); 198 | 199 | buttonLogout = new JButton("Logout"); 200 | buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH, 30); 201 | buttonLogout.setFont(Theme.FONT_BUTTON); 202 | buttonLogout.setBackground(Color.WHITE); 203 | buttonLogout.setForeground(Theme.COLOR_TITLE); 204 | buttonLogout.addActionListener(this); 205 | panel.add(buttonLogout); 206 | 207 | buttonBack = new JButton("Back"); 208 | buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH, 30); 209 | buttonBack.setFont(Theme.FONT_BUTTON); 210 | buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY); 211 | buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY); 212 | buttonBack.addActionListener(this); 213 | panel.add(buttonBack); 214 | 215 | usernameLabel = new JLabel("User ID: "+employee.getUserId()); 216 | usernameLabel.setBounds(60, 140, 440, 30); 217 | usernameLabel.setFont(Theme.FONT_REGULAR); 218 | panel.add(usernameLabel); 219 | 220 | nameLabel = new JLabel("Name: "); 221 | nameLabel.setBounds(60, 190, 440, 30); 222 | nameLabel.setFont(Theme.FONT_REGULAR); 223 | panel.add(nameLabel); 224 | 225 | phoneLabel = new JLabel("Phone No: "); 226 | phoneLabel.setBounds(60, 240, 440, 30); 227 | phoneLabel.setFont(Theme.FONT_REGULAR); 228 | panel.add(phoneLabel); 229 | 230 | roleLabel = new JLabel("Role: "+employee.getRole()); 231 | roleLabel.setBounds(60, 290, 440, 30); 232 | roleLabel.setFont(Theme.FONT_REGULAR); 233 | panel.add(roleLabel); 234 | 235 | salaryLabel = new JLabel("Salary: "+employee.getSalary()); 236 | salaryLabel.setBounds(60, 340, 440, 30); 237 | salaryLabel.setFont(Theme.FONT_REGULAR); 238 | panel.add(salaryLabel); 239 | 240 | 241 | nameTF = new JTextField(employee.getEmployeeName()); 242 | nameTF.setBounds(180, 190, 220, 30); 243 | nameTF.setFont(Theme.FONT_INPUT); 244 | nameTF.setEnabled(false); 245 | nameTF.setDisabledTextColor(Color.BLACK); 246 | panel.add(nameTF); 247 | 248 | phoneTF1 = new JTextField("+880"); 249 | phoneTF1.setBounds(180, 240, 40, 30); 250 | phoneTF1.setFont(Theme.FONT_INPUT); 251 | phoneTF1.setEnabled(false); 252 | phoneTF1.setDisabledTextColor(Color.BLACK); 253 | panel.add(phoneTF1); 254 | 255 | phoneTF2 = new JTextField(employee.getPhoneNumber().substring(4)); 256 | phoneTF2.setBounds(220, 240, 180, 30); 257 | phoneTF2.setFont(Theme.FONT_INPUT); 258 | phoneTF2.setEnabled(false); 259 | phoneTF2.setDisabledTextColor(Color.BLACK); 260 | panel.add(phoneTF2); 261 | 262 | header = new JLabel(); 263 | header.setBackground(Theme.BACKGROUND_HEADER); 264 | header.setOpaque(true); 265 | header.setBounds(0, 0, Theme.GUI_WIDTH, 75); 266 | panel.add(header); 267 | 268 | this.add(panel); 269 | } 270 | 271 | public void actionPerformed(ActionEvent ae) { 272 | if (ae.getSource().equals(buttonBack)) { 273 | this.setVisible(false); 274 | backActivity.setVisible(true); 275 | } 276 | else if (ae.getSource().equals(buttonLogout)) { 277 | this.setVisible(false); 278 | new LoginActivity().setVisible(true); 279 | } 280 | else if (ae.getSource().equals(buttonEdit)) { 281 | buttonEdit.setVisible(false); 282 | buttonSubmit.setVisible(true); 283 | nameTF.setEnabled(true); 284 | phoneTF2.setEnabled(true); 285 | if (customer!=null) 286 | addressTF.setEnabled(true); 287 | } 288 | else if (ae.getSource().equals(buttonSubmit)) { 289 | 290 | if (customer!=null) { 291 | addressTF.setEnabled(false); 292 | try { 293 | customer.updateCustomer(nameTF.getText().trim(), Integer.parseInt(phoneTF2.getText()), addressTF.getText().trim()); 294 | buttonEdit.setVisible(true); 295 | buttonSubmit.setVisible(false); 296 | nameTF.setEnabled(false); 297 | phoneTF2.setEnabled(false); 298 | } 299 | catch (NumberFormatException e) { 300 | JOptionPane.showMessageDialog(null,"Invalid Number!"); 301 | } 302 | } 303 | else if (employee!=null) { 304 | try { 305 | employee.updateEmployee(nameTF.getText().trim(), Integer.parseInt(phoneTF2.getText()), employee.getRole(), employee.getSalary()); 306 | buttonEdit.setVisible(true); 307 | buttonSubmit.setVisible(false); 308 | nameTF.setEnabled(false); 309 | phoneTF2.setEnabled(false); 310 | } 311 | catch (NumberFormatException e) { 312 | JOptionPane.showMessageDialog(null,"Invalid number!"); 313 | } 314 | } 315 | } 316 | else if (ae.getSource().equals(buttonPass)) { 317 | new ChangePasswordActivity(this.usr).setVisible(true); 318 | } 319 | else if (ae.getSource().equals(buttonDelete)) { 320 | int input = JOptionPane.showConfirmDialog(null, "Sure to Delete?", "Delete "+customer.getUserId()+"?", JOptionPane.YES_NO_OPTION); 321 | if (input == 0) { 322 | customer.deleteCustomer(); 323 | this.setVisible(false); 324 | new LoginActivity().setVisible(true); 325 | } 326 | else {} 327 | } 328 | else {} 329 | } 330 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------