├── .gitignore ├── bookstore ├── main │ ├── gitlab-ci.yml │ └── MainPage.java ├── db │ ├── Db.java │ ├── BookDb.java │ └── UserSignUpDb.java ├── after │ └── login │ │ └── option │ │ ├── SearchCD.java │ │ ├── SearchBooks.java │ │ ├── SearchSoftware.java │ │ └── AddBooks.java ├── options │ ├── LibrarianOption.java │ └── SearchItems.java ├── login │ ├── LibrarianLogin.java │ └── UserLogin.java └── signup │ └── UserSignUp.java └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bookstore/main/gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: java:latest 2 | 3 | stages: 4 | - build 5 | - execute 6 | 7 | build: 8 | stage: build 9 | script: /usr/lib/jvm/java-8-openjdk-amd64/bin/javac bookstore/main/MainPage.java 10 | artifacts: 11 | paths: 12 | - HelloWorld.* 13 | 14 | execute: 15 | stage: execute 16 | script: /usr/lib/jvm/java-8-openjdk-amd64/bin/java bookstore/main/MainPage 17 | -------------------------------------------------------------------------------- /bookstore/db/Db.java: -------------------------------------------------------------------------------- 1 | package bookstore.db; 2 | import java.sql.Connection; 3 | import java.sql.DriverManager; 4 | 5 | public class Db { 6 | public static Connection getConnection(){ 7 | Connection con=null; 8 | try{ 9 | Class.forName("com.mysql.cj.jdbc.Driver"); 10 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bookstore","root",""); 11 | }catch(Exception e){System.out.println(e);} 12 | return con; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bookstore/db/BookDb.java: -------------------------------------------------------------------------------- 1 | package bookstore.db; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | 6 | public class BookDb { 7 | 8 | public static int save(String name, String author, String publisher, String quantity) { 9 | int status = 0; 10 | try { 11 | Connection con = Db.getConnection(); 12 | PreparedStatement ps = con 13 | .prepareStatement("insert into AddBooksDb(name,author,publisher,quantity) values(?,?,?,?)"); 14 | ps.setString(1, name); 15 | ps.setString(2, author); 16 | ps.setString(3, publisher); 17 | ps.setString(4, quantity); 18 | status = ps.executeUpdate(); 19 | con.close(); 20 | } catch (Exception e) { 21 | System.out.println(e); 22 | } 23 | return status; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Check The Commits** 2 | 3 | 4 | If you want to check all the commits you have to goto all branches individually and the main branch is development because the code is still in development and after all the development the codes will be merged to branch named release. 5 | 6 | 7 | 8 | **Project Title** 9 | 10 | 11 | One Paragraph of project description goes here 12 | 13 | **Getting Started** 14 | 15 | This Readme File Contains The Basic Knowledge about my Code for the Oxford Book Store System. 16 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. 17 | 18 | **Prerequisites** 19 | 20 | The all program is merged in the branch called development. 21 | 22 | 23 | **Built With** 24 | 25 | This code was built and developed with JFrame is an extended version of java.awt.Frame that adds support for the JFC/Swing component architecture and with the help of the IDE named Eclipse. Java AWT API Tutorial with Button, TextField, Useful method of component class, simple example of awt by inheritance, TextArea and etc. 26 | 27 | -------------------------------------------------------------------------------- /bookstore/after/login/option/SearchCD.java: -------------------------------------------------------------------------------- 1 | package bookstore.after.login.option; 2 | 3 | import java.awt.EventQueue; 4 | import javax.swing.JFrame; 5 | import javax.swing.JLabel; 6 | import javax.swing.JTextField; 7 | import javax.swing.JButton; 8 | 9 | public class SearchCD { 10 | 11 | private JFrame frame; 12 | private JTextField textField; 13 | 14 | /** 15 | * Launch the application. 16 | */ 17 | public static void main(String[] args) { 18 | EventQueue.invokeLater(new Runnable() { 19 | public void run() { 20 | try { 21 | SearchCD window = new SearchCD(); 22 | window.frame.setVisible(true); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | }); 28 | } 29 | 30 | /** 31 | * Create the application. 32 | */ 33 | public SearchCD() { 34 | initialize(); 35 | } 36 | 37 | /** 38 | * Initialize the contents of the frame. 39 | */ 40 | private void initialize() { 41 | frame = new JFrame(); 42 | frame.setBounds(100, 100, 450, 300); 43 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 44 | frame.getContentPane().setLayout(null); 45 | 46 | JLabel lblEarchCds = new JLabel("Add CD's You Want"); 47 | lblEarchCds.setBounds(6, 6, 181, 16); 48 | frame.getContentPane().add(lblEarchCds); 49 | 50 | JLabel lblSearch = new JLabel("Search:"); 51 | lblSearch.setBounds(89, 66, 61, 16); 52 | frame.getContentPane().add(lblSearch); 53 | 54 | textField = new JTextField(); 55 | textField.setBounds(162, 61, 130, 26); 56 | frame.getContentPane().add(textField); 57 | textField.setColumns(10); 58 | 59 | JButton btnAddToCart = new JButton("Add To Cart"); 60 | btnAddToCart.setBounds(175, 138, 117, 29); 61 | frame.getContentPane().add(btnAddToCart); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /bookstore/db/UserSignUpDb.java: -------------------------------------------------------------------------------- 1 | package bookstore.db; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | 7 | public class UserSignUpDb { 8 | 9 | public static int save(String fname,String lname,String email,String username, String password,String contact){ 10 | int status=0; 11 | try{ 12 | Connection con=Db.getConnection(); 13 | PreparedStatement ps=con.prepareStatement("insert into SignUpDb(fname,lname,email,username,password,contact) values(?,?,?,?,?,?)"); 14 | ps.setString(1,fname); 15 | ps.setString(2,lname); 16 | ps.setString(3,email); 17 | ps.setString(4,username); 18 | ps.setString(5,password); 19 | ps.setString(6,contact); 20 | status=ps.executeUpdate(); 21 | con.close(); 22 | }catch(Exception e){System.out.println(e);} 23 | return status; 24 | } 25 | public static int delete(int id){ 26 | int status=0; 27 | try{ 28 | Connection con=Db.getConnection(); 29 | PreparedStatement ps=con.prepareStatement("delete from SignUpDb where username=?"); 30 | ps.setInt(1,id); 31 | status=ps.executeUpdate(); 32 | con.close(); 33 | }catch(Exception e){System.out.println(e);} 34 | return status; 35 | } 36 | 37 | public static boolean validate(String username,String password){ 38 | boolean status=false; 39 | try{ 40 | Connection con=Db.getConnection(); 41 | PreparedStatement ps=con.prepareStatement("select * from SignUpDb where username=? and password=?"); 42 | ps.setString(1,username); 43 | ps.setString(2,password); 44 | ResultSet rs=ps.executeQuery(); 45 | status=rs.next(); 46 | con.close(); 47 | }catch(Exception e){System.out.println(e);} 48 | return status; 49 | } 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /bookstore/after/login/option/SearchBooks.java: -------------------------------------------------------------------------------- 1 | package bookstore.after.login.option; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JLabel; 7 | import javax.swing.JTextField; 8 | import javax.swing.JButton; 9 | 10 | public class SearchBooks { 11 | 12 | private JFrame frame; 13 | private JTextField textField; 14 | 15 | /** 16 | * Launch the application. 17 | */ 18 | public static void main(String[] args) { 19 | EventQueue.invokeLater(new Runnable() { 20 | public void run() { 21 | try { 22 | SearchBooks window = new SearchBooks(); 23 | window.frame.setVisible(true); 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | }); 29 | } 30 | 31 | /** 32 | * Create the application. 33 | */ 34 | public SearchBooks() { 35 | initialize(); 36 | } 37 | 38 | /** 39 | * Initialize the contents of the frame. 40 | */ 41 | private void initialize() { 42 | frame = new JFrame(); 43 | frame.setBounds(100, 100, 450, 300); 44 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 45 | frame.getContentPane().setLayout(null); 46 | 47 | JLabel lblSearchBooksYou = new JLabel("Add Books You Want"); 48 | lblSearchBooksYou.setBounds(6, 6, 196, 16); 49 | frame.getContentPane().add(lblSearchBooksYou); 50 | 51 | JLabel lblSearchBooks = new JLabel("Search Books"); 52 | lblSearchBooks.setBounds(56, 77, 99, 16); 53 | frame.getContentPane().add(lblSearchBooks); 54 | 55 | textField = new JTextField(); 56 | textField.setBounds(167, 72, 130, 26); 57 | frame.getContentPane().add(textField); 58 | textField.setColumns(10); 59 | 60 | JButton btnAddToCart = new JButton("Add To Cart"); 61 | btnAddToCart.setBounds(179, 178, 117, 29); 62 | frame.getContentPane().add(btnAddToCart); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /bookstore/after/login/option/SearchSoftware.java: -------------------------------------------------------------------------------- 1 | package bookstore.after.login.option; 2 | 3 | import java.awt.EventQueue; 4 | import javax.swing.JFrame; 5 | import javax.swing.JLabel; 6 | import javax.swing.JTextField; 7 | import javax.swing.JButton; 8 | 9 | public class SearchSoftware { 10 | 11 | private JFrame frame; 12 | private JTextField textField; 13 | 14 | /** 15 | * Launch the application. 16 | */ 17 | public static void main(String[] args) { 18 | EventQueue.invokeLater(new Runnable() { 19 | public void run() { 20 | try { 21 | SearchSoftware window = new SearchSoftware(); 22 | window.frame.setVisible(true); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | }); 28 | } 29 | 30 | /** 31 | * Create the application. 32 | */ 33 | public SearchSoftware() { 34 | initialize(); 35 | } 36 | 37 | /** 38 | * Initialize the contents of the frame. 39 | */ 40 | private void initialize() { 41 | frame = new JFrame(); 42 | frame.setBounds(100, 100, 450, 300); 43 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 44 | frame.getContentPane().setLayout(null); 45 | 46 | JLabel lblAddSoftwaresYou = new JLabel("Add Softwares You Want"); 47 | lblAddSoftwaresYou.setBounds(6, 17, 180, 16); 48 | frame.getContentPane().add(lblAddSoftwaresYou); 49 | 50 | JLabel lblSearch = new JLabel("Search:"); 51 | lblSearch.setBounds(106, 88, 61, 16); 52 | frame.getContentPane().add(lblSearch); 53 | 54 | textField = new JTextField(); 55 | textField.setBounds(174, 83, 130, 26); 56 | frame.getContentPane().add(textField); 57 | textField.setColumns(10); 58 | 59 | JButton btnAddToCart = new JButton("Add To Cart"); 60 | btnAddToCart.setBounds(154, 155, 117, 29); 61 | frame.getContentPane().add(btnAddToCart); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /bookstore/main/MainPage.java: -------------------------------------------------------------------------------- 1 | package bookstore.main; 2 | import java.awt.EventQueue; 3 | 4 | import javax.swing.JFrame; 5 | 6 | import bookstore.login.LibrarianLogin; 7 | import bookstore.login.UserLogin; 8 | 9 | import javax.swing.JButton; 10 | import java.awt.event.ActionListener; 11 | import java.awt.event.ActionEvent; 12 | 13 | public class MainPage { 14 | 15 | private JFrame frame; 16 | /* 17 | * Nirojan 18 | */ 19 | 20 | 21 | 22 | public static void main(String[] args) { 23 | 24 | EventQueue.invokeLater(new Runnable() { 25 | public void run() { 26 | try { 27 | MainPage window = new MainPage(); 28 | window.frame.setVisible(true); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | } 33 | }); 34 | } 35 | 36 | /** 37 | * Create the application. 38 | */ 39 | public MainPage() { 40 | initialize(); 41 | } 42 | 43 | /** 44 | * Initialize the contents of the frame. 45 | */ 46 | private void initialize() { 47 | frame = new JFrame(); 48 | frame.setBounds(100, 100, 450, 300); 49 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 50 | frame.getContentPane().setLayout(null); 51 | 52 | JButton btnOxfordUser = new JButton("Oxford User"); 53 | btnOxfordUser.addActionListener(new ActionListener() { 54 | public void actionPerformed(ActionEvent e) { 55 | UserLogin.main(new String [] {}); 56 | } 57 | }); 58 | btnOxfordUser.setBounds(153, 51, 117, 29); 59 | frame.getContentPane().add(btnOxfordUser); 60 | 61 | JButton btnLibrarian = new JButton("Administrator"); 62 | btnLibrarian.addActionListener(new ActionListener() { 63 | public void actionPerformed(ActionEvent e) { 64 | LibrarianLogin.main(new String [] {}); 65 | } 66 | }); 67 | btnLibrarian.setBounds(153, 113, 117, 29); 68 | frame.getContentPane().add(btnLibrarian); 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /bookstore/options/LibrarianOption.java: -------------------------------------------------------------------------------- 1 | package bookstore.options; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JLabel; 7 | import javax.swing.JTextField; 8 | 9 | import bookstore.after.login.option.AddBooks; 10 | 11 | import javax.swing.JButton; 12 | import java.awt.event.ActionListener; 13 | import java.awt.event.ActionEvent; 14 | 15 | public class LibrarianOption { 16 | 17 | private JFrame frame; 18 | 19 | /** 20 | * Launch the application. 21 | */ 22 | public static void main(String[] args) { 23 | EventQueue.invokeLater(new Runnable() { 24 | public void run() { 25 | try { 26 | LibrarianOption window = new LibrarianOption(); 27 | window.frame.setVisible(true); 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | }); 33 | } 34 | 35 | /** 36 | * Create the application. 37 | */ 38 | public LibrarianOption() { 39 | initialize(); 40 | } 41 | 42 | /** 43 | * Initialize the contents of the frame. 44 | */ 45 | private void initialize() { 46 | frame = new JFrame(); 47 | frame.setBounds(100, 100, 450, 300); 48 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 49 | frame.getContentPane().setLayout(null); 50 | 51 | JLabel lblWelcomeLibrarian = new JLabel("WelCome Librarian"); 52 | lblWelcomeLibrarian.setBounds(6, 6, 148, 16); 53 | frame.getContentPane().add(lblWelcomeLibrarian); 54 | 55 | JButton btnAddBooks = new JButton("Add Books"); 56 | btnAddBooks.addActionListener(new ActionListener() { 57 | public void actionPerformed(ActionEvent e) { 58 | AddBooks.main(new String[]{}); 59 | 60 | } 61 | }); 62 | btnAddBooks.setBounds(165, 56, 117, 29); 63 | frame.getContentPane().add(btnAddBooks); 64 | 65 | JButton btnViewBooks = new JButton("View Books"); 66 | btnViewBooks.setBounds(165, 120, 117, 29); 67 | frame.getContentPane().add(btnViewBooks); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /bookstore/options/SearchItems.java: -------------------------------------------------------------------------------- 1 | package bookstore.options; 2 | 3 | 4 | import java.awt.EventQueue; 5 | import javax.swing.JFrame; 6 | import javax.swing.JLabel; 7 | import javax.swing.JTextField; 8 | 9 | import bookstore.after.login.option.SearchBooks; 10 | import bookstore.after.login.option.SearchCD; 11 | import bookstore.after.login.option.SearchSoftware; 12 | 13 | import javax.swing.JButton; 14 | import java.awt.event.ActionListener; 15 | import java.awt.event.ActionEvent; 16 | 17 | public class SearchItems { 18 | 19 | private JFrame frame; 20 | 21 | /** 22 | * Launch the application. 23 | */ 24 | public static void main(String[] args) { 25 | EventQueue.invokeLater(new Runnable() { 26 | public void run() { 27 | try { 28 | SearchItems window = new SearchItems(); 29 | window.frame.setVisible(true); 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | }); 35 | } 36 | 37 | /** 38 | * Create the application. 39 | */ 40 | public SearchItems() { 41 | initialize(); 42 | } 43 | 44 | /** 45 | * Initialize the contents of the frame. 46 | */ 47 | private void initialize() { 48 | frame = new JFrame(); 49 | frame.setBounds(100, 100, 450, 300); 50 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 51 | frame.getContentPane().setLayout(null); 52 | 53 | JButton btnAddToCart = new JButton("Books"); 54 | btnAddToCart.addActionListener(new ActionListener() { 55 | public void actionPerformed(ActionEvent e) { 56 | SearchBooks.main(new String[] {}); 57 | } 58 | }); 59 | btnAddToCart.setBounds(157, 67, 117, 29); 60 | frame.getContentPane().add(btnAddToCart); 61 | 62 | JButton btnBuyNow = new JButton("CD"); 63 | btnBuyNow.addActionListener(new ActionListener() { 64 | public void actionPerformed(ActionEvent e) { 65 | SearchCD.main(new String[] {}); 66 | } 67 | }); 68 | btnBuyNow.setBounds(157, 125, 117, 29); 69 | frame.getContentPane().add(btnBuyNow); 70 | 71 | JButton btnSoftware = new JButton("Software"); 72 | btnSoftware.addActionListener(new ActionListener() { 73 | public void actionPerformed(ActionEvent e) { 74 | SearchSoftware.main(new String[] {}); 75 | } 76 | }); 77 | btnSoftware.setBounds(157, 185, 117, 29); 78 | frame.getContentPane().add(btnSoftware); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /bookstore/login/LibrarianLogin.java: -------------------------------------------------------------------------------- 1 | package bookstore.login; 2 | import java.awt.EventQueue; 3 | import javax.swing.JFrame; 4 | import javax.swing.JLabel; 5 | import javax.swing.JOptionPane; 6 | import javax.swing.JTextField; 7 | 8 | import bookstore.db.UserSignUpDb; 9 | import bookstore.options.LibrarianOption; 10 | 11 | import javax.swing.JPasswordField; 12 | import javax.swing.JButton; 13 | import java.awt.event.ActionListener; 14 | import java.awt.event.ActionEvent; 15 | 16 | public class LibrarianLogin { 17 | 18 | private JFrame frame; 19 | private JTextField tbLibUsername; 20 | private JPasswordField passLibrLOgin; 21 | 22 | /** 23 | * Launch the application. 24 | */ 25 | public static void main(String[] args) { 26 | EventQueue.invokeLater(new Runnable() { 27 | public void run() { 28 | try { 29 | LibrarianLogin window = new LibrarianLogin(); 30 | window.frame.setVisible(true); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | }); 36 | } 37 | 38 | /** 39 | * Create the application. 40 | */ 41 | public LibrarianLogin() { 42 | initialize(); 43 | } 44 | 45 | /** 46 | * Initialize the contents of the frame. 47 | */ 48 | private void initialize() { 49 | frame = new JFrame(); 50 | frame.setBounds(100, 100, 450, 300); 51 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 52 | frame.getContentPane().setLayout(null); 53 | 54 | JLabel lblLibrarianLoginPage = new JLabel("Librarian Login Page"); 55 | lblLibrarianLoginPage.setBounds(23, 6, 127, 25); 56 | frame.getContentPane().add(lblLibrarianLoginPage); 57 | 58 | tbLibUsername = new JTextField(); 59 | tbLibUsername.setBounds(151, 69, 130, 26); 60 | frame.getContentPane().add(tbLibUsername); 61 | tbLibUsername.setColumns(10); 62 | 63 | passLibrLOgin = new JPasswordField(); 64 | passLibrLOgin.setBounds(151, 132, 130, 26); 65 | frame.getContentPane().add(passLibrLOgin); 66 | 67 | JButton btnLibLogin = new JButton("Login"); 68 | btnLibLogin.addActionListener(new ActionListener() { 69 | public void actionPerformed(ActionEvent e) { 70 | } 71 | }); 72 | btnLibLogin.setBounds(164, 202, 117, 29); 73 | frame.getContentPane().add(btnLibLogin); 74 | 75 | JLabel lblUserName = new JLabel("User Name:"); 76 | lblUserName.setBounds(49, 74, 90, 16); 77 | frame.getContentPane().add(lblUserName); 78 | 79 | JLabel lblPassword = new JLabel("Password:"); 80 | lblPassword.setBounds(49, 137, 90, 16); 81 | frame.getContentPane().add(lblPassword); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /bookstore/login/UserLogin.java: -------------------------------------------------------------------------------- 1 | package bookstore.login; 2 | 3 | import java.awt.EventQueue; 4 | import javax.swing.JFrame; 5 | import javax.swing.JTextField; 6 | 7 | import bookstore.db.UserSignUpDb; 8 | import bookstore.options.SearchItems; 9 | import bookstore.signup.UserSignUp; 10 | 11 | import javax.swing.JPasswordField; 12 | import javax.swing.JLabel; 13 | import javax.swing.JOptionPane; 14 | import javax.swing.JButton; 15 | import java.awt.event.ActionListener; 16 | import java.awt.event.ActionEvent; 17 | 18 | public class UserLogin { 19 | 20 | private JFrame frame; 21 | private JTextField tbUserLogin; 22 | private JPasswordField passUserLogin; 23 | 24 | /** 25 | * Launch the application. 26 | */ 27 | public static void main(String[] args) { 28 | EventQueue.invokeLater(new Runnable() { 29 | public void run() { 30 | try { 31 | UserLogin window = new UserLogin(); 32 | window.frame.setVisible(true); 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | }); 38 | } 39 | 40 | /** 41 | * Create the application. 42 | */ 43 | public UserLogin() { 44 | initialize(); 45 | } 46 | 47 | /** 48 | * Initialize the contents of the frame. 49 | */ 50 | private void initialize() { 51 | frame = new JFrame(); 52 | frame.setBounds(100, 100, 450, 300); 53 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 54 | frame.getContentPane().setLayout(null); 55 | 56 | tbUserLogin = new JTextField(); 57 | tbUserLogin.setBounds(178, 60, 130, 26); 58 | frame.getContentPane().add(tbUserLogin); 59 | tbUserLogin.setColumns(10); 60 | 61 | passUserLogin = new JPasswordField(); 62 | passUserLogin.setBounds(178, 129, 130, 26); 63 | frame.getContentPane().add(passUserLogin); 64 | 65 | JLabel lblNewLabel = new JLabel("User Name:"); 66 | lblNewLabel.setBounds(71, 65, 95, 16); 67 | frame.getContentPane().add(lblNewLabel); 68 | 69 | JLabel lblPassword = new JLabel("Password:"); 70 | lblPassword.setBounds(88, 134, 78, 16); 71 | frame.getContentPane().add(lblPassword); 72 | 73 | JButton btnLogin = new JButton("Login"); 74 | btnLogin.addActionListener(new ActionListener() { 75 | public void actionPerformed(ActionEvent e) { 76 | String username=tbUserLogin.getText(); 77 | String password=String.valueOf(passUserLogin.getPassword()); 78 | //System.out.println(name+" "+password); 79 | if(UserSignUpDb.validate(username, password)){ 80 | SearchItems.main(new String[]{}); 81 | frame.dispose(); 82 | }else{ 83 | //JOptionPane.showMessageDialog(LibrarianLogin.this, "Sorry, Username or Password Error","Login Error!", JOptionPane.ERROR_MESSAGE); 84 | tbUserLogin.setText(""); 85 | passUserLogin.setText(""); 86 | } 87 | } 88 | 89 | 90 | }); 91 | btnLogin.setBounds(90, 196, 117, 29); 92 | frame.getContentPane().add(btnLogin); 93 | 94 | JLabel lblUserLoginPage = new JLabel("User Login Page"); 95 | lblUserLoginPage.setBounds(19, 17, 163, 26); 96 | frame.getContentPane().add(lblUserLoginPage); 97 | 98 | JButton btnSignUp = new JButton("Sign Up"); 99 | btnSignUp.addActionListener(new ActionListener() { 100 | public void actionPerformed(ActionEvent e) { 101 | UserSignUp.main(new String [] {}); 102 | 103 | } 104 | }); 105 | btnSignUp.setBounds(255, 196, 117, 29); 106 | frame.getContentPane().add(btnSignUp); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /bookstore/after/login/option/AddBooks.java: -------------------------------------------------------------------------------- 1 | package bookstore.after.login.option; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JLabel; 7 | import javax.swing.JOptionPane; 8 | import javax.swing.JTextField; 9 | import javax.swing.JButton; 10 | import java.awt.event.ActionListener; 11 | import java.awt.event.ActionEvent; 12 | 13 | import bookstore.db.*; 14 | import bookstore.options.LibrarianOption; 15 | 16 | public class AddBooks { 17 | 18 | private JFrame frame; 19 | private JTextField tbNameOfBook; 20 | private JTextField tbAuthorOfBook; 21 | private JTextField tbPublisherOfBook; 22 | private JTextField tbQuantityOfBook; 23 | 24 | 25 | /** 26 | * Launch the application. 27 | */ 28 | public static void main(String[] args) { 29 | EventQueue.invokeLater(new Runnable() { 30 | public void run() { 31 | try { 32 | AddBooks window = new AddBooks(); 33 | window.frame.setVisible(true); 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | } 38 | }); 39 | } 40 | 41 | /** 42 | * Create the application. 43 | */ 44 | public AddBooks() { 45 | initialize(); 46 | } 47 | 48 | /** 49 | * Initialize the contents of the frame. 50 | */ 51 | private void initialize() { 52 | frame = new JFrame(); 53 | frame.setBounds(100, 100, 450, 300); 54 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 55 | frame.getContentPane().setLayout(null); 56 | 57 | JLabel lblAddBooks = new JLabel("Add Books"); 58 | lblAddBooks.setBounds(6, 6, 88, 16); 59 | frame.getContentPane().add(lblAddBooks); 60 | 61 | JLabel lblNameOfThe = new JLabel("Name Of The Book:"); 62 | lblNameOfThe.setBounds(47, 46, 137, 16); 63 | frame.getContentPane().add(lblNameOfThe); 64 | 65 | tbNameOfBook = new JTextField(); 66 | tbNameOfBook.setBounds(224, 41, 130, 26); 67 | frame.getContentPane().add(tbNameOfBook); 68 | tbNameOfBook.setColumns(10); 69 | 70 | JLabel lblAuthorOfThe = new JLabel("Author Of The Book:"); 71 | lblAuthorOfThe.setBounds(47, 91, 137, 16); 72 | frame.getContentPane().add(lblAuthorOfThe); 73 | 74 | tbAuthorOfBook = new JTextField(); 75 | tbAuthorOfBook.setBounds(224, 79, 130, 26); 76 | frame.getContentPane().add(tbAuthorOfBook); 77 | tbAuthorOfBook.setColumns(10); 78 | 79 | JLabel lblPublisherOfThe = new JLabel("Publisher Of The Book:"); 80 | lblPublisherOfThe.setBounds(28, 129, 156, 16); 81 | frame.getContentPane().add(lblPublisherOfThe); 82 | 83 | tbPublisherOfBook = new JTextField(); 84 | tbPublisherOfBook.setBounds(224, 117, 130, 26); 85 | frame.getContentPane().add(tbPublisherOfBook); 86 | tbPublisherOfBook.setColumns(10); 87 | 88 | JLabel lblNewLabel = new JLabel("Quantity Of The Book:"); 89 | lblNewLabel.setBounds(28, 164, 156, 16); 90 | frame.getContentPane().add(lblNewLabel); 91 | 92 | tbQuantityOfBook = new JTextField(); 93 | tbQuantityOfBook.setBounds(224, 159, 130, 26); 94 | frame.getContentPane().add(tbQuantityOfBook); 95 | tbQuantityOfBook.setColumns(10); 96 | 97 | JButton btnAddBook = new JButton("Add Book"); 98 | btnAddBook.addActionListener(new ActionListener() { 99 | public void actionPerformed(ActionEvent e) { 100 | 101 | String name=tbNameOfBook.getText(); 102 | String author=tbAuthorOfBook.getText(); 103 | String publisher=tbPublisherOfBook.getText(); 104 | String quantity=tbQuantityOfBook.getText(); 105 | 106 | int i=BookDb.save( name, author, publisher, quantity); 107 | if(i>0){ 108 | JOptionPane.showInputDialog(AddBooks.this,"Books added successfully!"); 109 | 110 | frame.dispose(); 111 | 112 | LibrarianOption.main(new String[]{}); 113 | 114 | }else{ 115 | JOptionPane.showInputDialog(AddBooks.this,"Sorry, unable to save!"); 116 | } 117 | 118 | } 119 | 120 | 121 | }); 122 | btnAddBook.setBounds(303, 218, 117, 29); 123 | frame.getContentPane().add(btnAddBook); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /bookstore/signup/UserSignUp.java: -------------------------------------------------------------------------------- 1 | package bookstore.signup; 2 | import bookstore.db.*; 3 | import bookstore.login.UserLogin; 4 | import bookstore.after.login.*; 5 | 6 | import java.awt.EventQueue; 7 | 8 | import javax.swing.JFrame; 9 | import javax.swing.JLabel; 10 | import javax.swing.JOptionPane; 11 | import java.awt.Font; 12 | import javax.swing.JTextField; 13 | import javax.swing.JPasswordField; 14 | import javax.swing.JButton; 15 | import java.awt.event.ActionListener; 16 | import java.awt.event.ActionEvent; 17 | 18 | public class UserSignUp { 19 | 20 | private JFrame frame; 21 | private JTextField tbCreatUserName; 22 | private JPasswordField passCreateUserSignUp; 23 | private JTextField tbCreateUserMobile; 24 | private JTextField tbCreateUserEmail; 25 | private JTextField tbCreateUserFname; 26 | private JTextField tbCreateUserLname; 27 | 28 | /** 29 | * Launch the application. 30 | */ 31 | public static void main(String[] args) { 32 | EventQueue.invokeLater(new Runnable() { 33 | public void run() { 34 | try { 35 | UserSignUp window = new UserSignUp(); 36 | window.frame.setVisible(true); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | } 41 | }); 42 | } 43 | 44 | /** 45 | * Create the application. 46 | */ 47 | public UserSignUp() { 48 | initialize(); 49 | } 50 | 51 | /** 52 | * Initialize the contents of the frame. 53 | */ 54 | private void initialize() { 55 | frame = new JFrame(); 56 | frame.setBounds(100, 100, 450, 300); 57 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 58 | frame.getContentPane().setLayout(null); 59 | 60 | JLabel lblUserSignupPage = new JLabel("User SignUp Page"); 61 | lblUserSignupPage.setBounds(6, 0, 255, 43); 62 | lblUserSignupPage.setFont(new Font("Khmer Sangam MN", Font.BOLD, 25)); 63 | frame.getContentPane().add(lblUserSignupPage); 64 | 65 | JLabel lblCreateAUser = new JLabel("User Name:"); 66 | lblCreateAUser.setBounds(40, 142, 144, 16); 67 | frame.getContentPane().add(lblCreateAUser); 68 | 69 | tbCreatUserName = new JTextField(); 70 | tbCreatUserName.setBounds(183, 137, 130, 26); 71 | frame.getContentPane().add(tbCreatUserName); 72 | tbCreatUserName.setColumns(10); 73 | 74 | JLabel lblCreateAPassword = new JLabel("Password:"); 75 | lblCreateAPassword.setBounds(50, 170, 130, 16); 76 | frame.getContentPane().add(lblCreateAPassword); 77 | 78 | passCreateUserSignUp = new JPasswordField(); 79 | passCreateUserSignUp.setBounds(183, 165, 130, 26); 80 | frame.getContentPane().add(passCreateUserSignUp); 81 | 82 | JLabel lblMobileNumber = new JLabel("Mobile Number:"); 83 | lblMobileNumber.setBounds(22, 198, 112, 16); 84 | frame.getContentPane().add(lblMobileNumber); 85 | 86 | tbCreateUserMobile = new JTextField(); 87 | tbCreateUserMobile.setBounds(183, 193, 130, 26); 88 | frame.getContentPane().add(tbCreateUserMobile); 89 | tbCreateUserMobile.setColumns(10); 90 | 91 | JLabel lblFirstName = new JLabel("First Name:"); 92 | lblFirstName.setBounds(40, 55, 94, 16); 93 | frame.getContentPane().add(lblFirstName); 94 | 95 | JLabel lblLastName = new JLabel("Last Name:"); 96 | lblLastName.setBounds(45, 83, 97, 16); 97 | frame.getContentPane().add(lblLastName); 98 | 99 | JLabel lblEmailAddress = new JLabel("Email Address:"); 100 | lblEmailAddress.setBounds(22, 110, 101, 16); 101 | frame.getContentPane().add(lblEmailAddress); 102 | 103 | tbCreateUserEmail = new JTextField(); 104 | tbCreateUserEmail.setBounds(183, 105, 130, 26); 105 | frame.getContentPane().add(tbCreateUserEmail); 106 | tbCreateUserEmail.setColumns(10); 107 | 108 | tbCreateUserFname = new JTextField(); 109 | tbCreateUserFname.setBounds(183, 50, 130, 26); 110 | frame.getContentPane().add(tbCreateUserFname); 111 | tbCreateUserFname.setColumns(10); 112 | 113 | JButton btnSignUp = new JButton("Sign Up"); 114 | btnSignUp.addActionListener(new ActionListener() { 115 | public void actionPerformed(ActionEvent e) { 116 | 117 | String fname = tbCreateUserFname.getText(); 118 | String lname = tbCreateUserLname.getText(); 119 | String email = tbCreateUserEmail.getText(); 120 | String username = tbCreatUserName.getText(); 121 | String password = String.valueOf(passCreateUserSignUp.getPassword()); 122 | String contact = tbCreateUserMobile.getText(); 123 | 124 | // String address=textField_2.getText(); 125 | // String city=textField_3.getText(); 126 | 127 | int i = UserSignUpDb.save(fname, lname, email, username, password, contact); 128 | if (i > 0) { 129 | JOptionPane.showInputDialog(UserSignUp.this, "User added successfully!"); 130 | UserLogin.main(new String[] {}); 131 | frame.dispose(); 132 | 133 | } else { 134 | JOptionPane.showInputDialog(UserSignUp.this, "Sorry, unable to save!"); 135 | } 136 | } 137 | }); 138 | btnSignUp.setBounds(299, 230, 117, 29); 139 | frame.getContentPane().add(btnSignUp); 140 | 141 | tbCreateUserLname = new JTextField(); 142 | tbCreateUserLname.setBounds(183, 78, 130, 26); 143 | frame.getContentPane().add(tbCreateUserLname); 144 | tbCreateUserLname.setColumns(10); 145 | } 146 | } 147 | --------------------------------------------------------------------------------