automation of certificates

Upload: adeniran-ojo

Post on 03-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Automation of certificates

    1/57

    1

    TITLE

    AUTOMATION OF CERTIFICATES

    NAME

    OJO ADENIRAN OLATUNDE

    MATRIC

    090805039

    PLACE OF INDUSTRIAL TRAINING

    HALLIBURTON ENERGY SERVICES NIG. LTD

    DEPARTMENTAL SUPERVISOR

    DR (MRS) F. OLADEJI

  • 8/11/2019 Automation of certificates

    2/57

    2

    ABSTRACT

    Halliburton Energy Services Nigeria limited has different departments and sub

    department, I worked with the cementing department for a while before I was

    transferred to a sub department known as QAQC (quality assurance quality

    control).They are in charge of any equipment purchased and ensuring that

    standard is not compromised, they also keep records of all the paper works

    especially certificates. Certificates are like receipts given for a purchased item, so

    for every tool/equipment a certificate is given which are kept for later use for rig

    assignment manually in a file. The certificate gives a detailed information about

    the product/equipment purchased e.g. the production date, sap number, the psi

    (pounds per square inch) i.e. its efficiency etc.

    While I was at QAQC an incident happened, we have a rig operation and for

    every tool we at QAQC must make available the certificate of any equipment to

    be used for the job, so we were looking for a particular certificate in one of the

    files for over an hour before locating it.

    I was motivated to automate the process of keeping those records,

    whereby it will be possible for us to upload, search, view, update and printcertificate without delay and avoid a situation of misplacing certificates or not

    being able retrieve them when needed, hence the need for certificates to be

    automated for proper record keeping begun.

    So an Agile Software Development methodologywas adopted because of the

    clear understanding of what to do, to enable us deliver part of the application in

    time and also to give room for changes that may arise during the development.

    The result was very impressive and I believe it enhances productivity and alsoends any form of delay as regards trying to locate certificates.

  • 8/11/2019 Automation of certificates

    3/57

    3

    BACKGROUND / SYSTEM DESCRIPTION

    Halliburton is one of the worlds leading providers of products and services to

    the upstream and downstream energy industry, serving the life cycle of the

    reservoir from locating hydrocarbons and managing geological data to

    drilling and formation evaluation, well construction and completion, and

    optimizing production through the life of the field.

    Founded in 1919, Halliburton is one of the world's largest providers of

    products and services to the oil and gas industry. Halliburton's fascinating and

    proud history reveals a continuous focus on innovation and expansion that

    began with the company's founder, Erle P. Halliburton. After borrowing a

    wagon, a team of mules and a pump, he built a wooden mixing box and started

    an oil well cementing business in Duncan, Oklahoma.

    Halliburton established its presence in Nigeria in 1959 with the original

    Halliburton objective to help service Nigerias promising new oil and gas

    industry. Since then, Halliburtons service offerings have grown.

    Halliburton Company is a world leader in energy services, as well as

    engineering and construction. The company has two main business segments:

  • 8/11/2019 Automation of certificates

    4/57

    4

    the Halliburton Energy Services Group, which offers a broad range of services

    and products used in the exploration, development, and production of oil and

    gas, and the KBR--Engineering and Construction Group, which designs and

    constructs major projects, including liquefied natural gas plants, refining and

    processing plants, production facilities, and pipelines.

    One of Halliburton's numerous service operations is oil well cementing. This

    process protects oil from contamination by underground water, strengthens

    the walls of a well, lessens the danger of explosions from high pressure oil and

    gas, and protects fresh water veins from contamination by oil. This was the

    first service offered by the company founder Erle Palmer Halliburton.

  • 8/11/2019 Automation of certificates

    5/57

    5

    OBJECTIVE OF THE ESTABLISHMENT

    Vision it defines who we are as a company and what we aspire to be and

    gives us an image of what success will look like.

    Halliburtons vision is:

    To be the preferred upstream service company for the development of global

    oil and gas assets.

    A preferred upstream service company:

    Builds a reputation for distinctive health, safety, environment and service

    quality performance through our emphasis on process assurance and processexecution consistently wherever we work around the globe

    Maintains long-term sustainable customer relationships that meet the

    individual differences of a global client base

    Understands that the reservoir is the source of all value, and it has the

    resources and expertise to provide the right solutions to increasing access to

    hydrocarbons and striving to improve recovery

    Is a credible, reliable service provider that matches actions to words

    Is an effective innovator, applying technology that delivers results

    Is balanced geographically and in its portfolio to serve and support itscustomers cost effectively

    Epitomizes excellence in integration, using technology to link its global

    network to maximize results.

    Mission- it identifies what an organization does, why it does it and for whom.

    Halliburton's mission is:

    To create sustainable value for our stakeholders by safely delivering

    outstanding products, services and solutions that help our customers meettheir technical and economic objectives in the exploitation of their energy

    resources.

  • 8/11/2019 Automation of certificates

    6/57

    6

    ORGANISATIONAL STRUCTURE

  • 8/11/2019 Automation of certificates

    7/57

    7

    PRODUCTION SERVICE LINES OF HALLIBURTON

    Halliburton comprises 13 product service lines (PSLs). The PSLs operate in

    two divisions: Drilling and Evaluation, and Completion and Production.

    The Consulting and Project Management PSL works across both divisions and

    is the spearhead of our integrated-services strategy. Its financial results are

    included in the Drilling and Evaluation Division. PSLs are primarily

    responsible and accountable for strategy, technology development, process

    development, people development and capital allocation.

    Drilling and Evaluation Division

    Baroid Sperry Drilling

    Drill Bits and Services Testing and Subsea

    Landmark Software and Services Wireline and perforating

    Completion and Production Division

    Artificial Lift Completion Tools

    Boots & Coots Multi-Chem

    Cementing Production Enhancement

    Supporting both Divisions

    Consulting and Project Management

    Production Service L ines

  • 8/11/2019 Automation of certificates

    8/57

    8

    SYSTEM ANALYSIS

    The fact finding methodology which I adopted are

    Interview

    Observation

    INTERVIEW

    This is one of the methodologies I applied in factoring out some of the

    requirement; I was able to discuss with the head of QAQC (Quality Assurance

    and Quality Control) who is in charge of certifying and receiving consignment ,

    keeping records of certificate(s) of certificates and adhering to organizational

    standard. During the interview he made known to me the importance of the

    certificates and quality standards, I also reminded him of a certificate we could

    not locate on time due to the manual way of keeping records and he said he is

    aware of the challenge.

    OBSERVATION

    This is another method I used to get the system requirement; this is an

    addition to the information I got from the interview. I also witnessed how long

    it takes sometimes to sort certificates for some equipment while I was working

    with them.

  • 8/11/2019 Automation of certificates

    9/57

    9

    DATA FLOW DIAGRAM

    CONTEXT DIAGRAM

    AUTOMATION OF

    CERTIFICATES

    USER INFO

    ENTRY

    UPLOAD CERTIFICATE

    INFO

    CERTIFICATE

    MAINTENANCE

    CERTIFICATE

    USER INFO

    REPORT

  • 8/11/2019 Automation of certificates

    10/57

    10

    LEVEL 1 DFD

    Upload

    certificate

    users

    certificate

    Certificate file

    Maintain

    users info

    Users info file

    Users data

    Maintain

    certificate

    Edit,view, delete

    Print

    certificate

    Printed certificate

  • 8/11/2019 Automation of certificates

    11/57

    11

    LEVEL 2 DFD

  • 8/11/2019 Automation of certificates

    12/57

    12

    LOGICAL DATABASE DESIGN

    ENTITY RELATION DIAGRAM

  • 8/11/2019 Automation of certificates

    13/57

    13

    SYSTEM DESIGN

    USE CASE

  • 8/11/2019 Automation of certificates

    14/57

    14

    USE CASE DESCRIPTION

    1.

    LOGIN

    1.1 Introduction

    This use case describes how to login into the Certificate Record

    Management System and it comes into play when the actor (Admin)wishes to login.

    1.2 Actors

    The administrator interact with the system

    1.3 Pre-condition

    The admin must be logged onto the system before this use case

    begins.1.4 Post-condition

    If the use case is successful the user will be logged into the system and willbe able to perform expected actions.

    1.5 FLOW OF EVENT

    1.5.1 BASIC FLOW

    This use case begins when an actor wishes to login into the Record system.

    The system requests the actors username and password

    The actor enters his/ her password

    The system then validates the username and the password

    and also checks his/ her privileges.

    The options that will be made available to each actor will

    be based on its privileges.

    The use case ends

    The use case ends

    1.5.2 Alternate Flow

    1.5.3Invalid Username / Password

    If a wrong username or password is inputted into the

    system, the system will return an error message and

    the use case will end.

    1.6 Special Requirement

    None

  • 8/11/2019 Automation of certificates

    15/57

    15

    1.7 Pre-condition

    Users must have an account (i.e username, password and role) created for

    them by the administrator prior to login to the system.

    1.8 Post condition

    If the use case is successful, user is granted permission to perform

    expected action based on its role.

    2 ADD USER

    This use case allows more users by the Admin. Users can only view, search and

    print. The system requires the following information :

    (i) Surname

    (ii) Other name

    (iii) Department

    (iv) E-mail

    (v) Mobile Number

    (vi) User Name

    (vii) Password

    (viii) Re-enter Password

    2.1 VIEW USER

    This use case allows the admin to view all users.

    2.2 Maintain - ADD/MODIFY/UPDATE/DELETEThis use case enables the admin to maintain and update the certificate.

    2.3 UPLOAD CERTIFICATE

    This use case allows the admin to upload certificates.

    2.4 VIEW CERTIFICATE

    This use case allows all users to view certificate.

    2.5 SEARCH CERTIFICATE

    This use case allows all users to search for certificates.

  • 8/11/2019 Automation of certificates

    16/57

    16

    TABLE AND THEIR FUNCTIONS

    NAME FUNCTION

    TABLE REPRESENTATION

    USERS

    COLUMN NAME COLUMN TYPE

    USER_ID INT(11)

    SURNAME VARCHAR(50)

    OTHERNAME VARCHAR(100)

    DEPARTMENT VARCHAR(100)

    EMAIL VARCHAR(100)

    MOBILE VARCHAR(50)

    USERNAME VARCHAR(100)

    PASSWORD VARCHAR(100)

    TOOLS

    COLUMN NAME COLUMN TYPE

    TOOL_ID INT(11)

    TOOL_NAME VARCHAR(100)

    TOOL_TYPE VARCHAR(20)

    TOOL_SAP NO VARCHAR(20)

    COMPANY_ID INT(11)

    COMPANY

    COLUMN NAME COLUMN TYPE

    COMPANY_ID INT(11)

    COMPANY_NAME VARCHAR(120)

  • 8/11/2019 Automation of certificates

    17/57

    17

    CERTIFICATE

    COLUMN NAME COLUMN TYPE

    CERTIFICATE_ID INT(11)

    TOOL_ID INT(11)

    COMPANY_ID INT(11)

    UPLOAD_DATE DATE

    CERTIFICATE_NAME TEXT

  • 8/11/2019 Automation of certificates

    18/57

    18

    SYSTEM IMPLEMENTATION

    The System was implemented based on the understanding of the problem which

    is intended to be solved. The tools used are as follows:

    PROGRAMMING LANGUAGE

    The programming language used is Java. It was used to encapsulate and display

    the design view of the system.

    CSScascading style sheet is used for the layout and styling of the web page.

    HTMLis a display language which is used to develop web pages and

    PHP is the scripting language used to communicate with the database.

    DATABASE MANAGEMENT SYSTEM

    The Database Management System used is SQL server. Although there are several

    DBMS that could be used but this was readily available as at the time of creation

    and also because of the ease of query with SQL.

  • 8/11/2019 Automation of certificates

    19/57

    19

    RESULTS

    The result obtained from the project (Automation of Certificate) shows that the

    manual process of keeping records leads to delay and/or misplacement of

    document needed per time. The automated system solves the problems

    encountered in the manual way of keeping Certificate. The automated system

    allows more users through the Administrator giving permission to the new users.

    It also allows user to

    uploading of certificate

    searching for any certificate in the database

    printing of certificate

    and modification of certificate by the Admin.

    CONCLUSION

    The mini-project has given me more insight on prioritizing organization goals,

    how to recognize organizational problem and steps to take to go about solving

    it. It helps me to appreciate programming as a tool to revolutionize the

    cooperate world and the usage of Database Management System. It has also

    made known to me a means of providing a well formatted and descriptive

    report.

  • 8/11/2019 Automation of certificates

    20/57

    20

    To log in, the user must provide username and password

    ADD NEW USER

    The Admin adds new user by providing the details of the user

  • 8/11/2019 Automation of certificates

    21/57

    21

    VIEW USERS

    The admin can view or delete from the list of users

    ADD NEW CERTIFICATE

    To add new certificate the user fills details of the equipment

    DELETEUSEREDIT USER

  • 8/11/2019 Automation of certificates

    22/57

    22

    VIEW CERTIFICATES

    From the list of uploaded certificate a user can click the view icon for

    a particular certificate to print

    View icon

  • 8/11/2019 Automation of certificates

    23/57

    23

    SEARCH CERTIFICATE

    User can search for tools/equip cert by Sap number, Alphabet, Type,

    Company name or tool name

    Click print

    certificate icon

  • 8/11/2019 Automation of certificates

    24/57

  • 8/11/2019 Automation of certificates

    25/57

    25

    APPENDICES

    EXCERPTS OF THE CODES

    CODE TO ADD CERTIFICATE

    import java.awt.*;

    import javax.swing.*;

    import java.awt.event.*;

    import java.sql.*;

    import java.util.*;

    import javax.swing.table.*;

    import javax.swing.event.*;

    import java.io.*;

    import javax.swing.filechooser.*;

    public class AddCertificate extends JInternalFrame{

    private JButton button;

    private static int xOffset=0, yOffset=0;

    private JEditorPane pane;

    public AddCertificate(){

    super("ADD NEW CERTIFICATE", true, true);

    try{

    pane=new JEditorPane();

  • 8/11/2019 Automation of certificates

    26/57

    26

    pane.setEditable(false);

    pane.setPage("http://localhost/halliburton/add_certificate.php");

    }

    catch(IOException io){

    JOptionPane.showMessageDialog(null, io);

    }

    button=new JButton("Print Certificate");

    button.setBackground(Color.cyan);

    pane.addHyperlinkListener(new HyperlinkListener(){

    @Override

    public void hyperlinkUpdate(HyperlinkEvent e){

    if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){

    try{

    pane.setPage(e.getURL());

    }

    catch(Exception exp){

    pane.setText("Could not open "+e.getURL());

    }

    }

    }

    });

    Container c=getContentPane();

  • 8/11/2019 Automation of certificates

    27/57

    27

    c.add(button, BorderLayout.NORTH);

    button.addActionListener(new PrintUIWindow(c));

    c.add(new JScrollPane(pane));

    setBounds(xOffset, yOffset, 300,300);

    xOffset=(xOffset+30)%300;

    yOffset=(yOffset+30)%300;

    setVisible(true);

    }

    }

    CODE TO CONNECT TO DATABASE

    import java.sql.*;

    import java.util.*;

    import javax.swing.*;

    import javax.swing.JOptionPane;

    public class ConnectToDb {

    private Connection connection;

    private PreparedStatement query,userName;

    public ConnectToDb() throws Exception{

    connectToDatabase();

    //check admin login info

  • 8/11/2019 Automation of certificates

    28/57

    28

    userName=connection.prepareStatement("select username from users");

    query=connection.prepareStatement("SELECT * FROM users where username=? and

    password =?");

    }

    public void connectToDatabase() throws Exception{

    String driver="com.mysql.jdbc.Driver";

    String url="jdbc:mysql://localhost:3306/halliburton";

    String user="root",password="";

    Class.forName(driver);

    connection=DriverManager.getConnection(url, user, password);

    connection.setAutoCommit(false);

    }

    public void loginUser(String username, String password) throws Exception{

    try{

    query.setString(1, username);

    query.setString(2, password);

    ResultSet resultset=query.executeQuery();

    if(resultset.next()){

    new HumanResource().setResizable(false);

  • 8/11/2019 Automation of certificates

    29/57

    29

    }

    else{

    JOptionPane.showMessageDialog(null, "User not found","User record not found\n

    please contact the administrator",JOptionPane.INFORMATION_MESSAGE);

    }

    }

    catch(SQLException sqlException){

    JOptionPane.showMessageDialog(null, sqlException,"ERROR IN SELECTING USERT",

    JOptionPane.ERROR_MESSAGE);

    }

    }

    public UsersFrame addUsers() throws Exception{

    UsersFrame addusersFrame=new UsersFrame();

    addusersFrame.setVisible(true);

    addusersFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    return addusersFrame;

    }

    public ViewAllUsers viewUsersFrame() throws Exception{

    ViewAllUsers usersViewframe=new ViewAllUsers();

    usersViewframe.setVisible(true);

    usersViewframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    return usersViewframe;

    }

  • 8/11/2019 Automation of certificates

    30/57

    30

    public ViewCertificates viewCertificateFrame() throws Exception{

    ViewCertificates certificate=new ViewCertificates();

    certificate.setVisible(true);

    certificate.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    return certificate;

    }

    public AddCertificate addCertificateFrame() throws Exception{

    AddCertificate addCertificate=new AddCertificate();

    addCertificate.setVisible(true);

    addCertificate.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    return addCertificate;

    }

    public SearchCertificate searchNewCertificate() throws Exception{

    SearchCertificate scert=new SearchCertificate();

    scert.setVisible(true);

    scert.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    return scert;

    }

    public PreparedStatement username(){

    return userName;

    }

    public void close(){

  • 8/11/2019 Automation of certificates

    31/57

    31

    try{

    query.close();

    }

    catch(SQLException ex){

    JOptionPane.showMessageDialog(null, ex,"Could not close

    connection",JOptionPane.INFORMATION_MESSAGE);

    }

    }

    }

    HALLIBURTON HOME PAGE CODE

    import java.sql.*;

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.*;

    public class Halliburton extends JFrame{

    private ConnectToDb db;

    private String username_info, password_info;

    private JLabel loginlabel, username,password;

    private JButton loginButton;

    private JTextField userN,passW;

    private JComboBox bx;

  • 8/11/2019 Automation of certificates

    32/57

    32

    private Connection conn;

    private PreparedStatement use;

    public Halliburton(){

    super("Halliburton Energy Services Nigeria Limited");

    try{

    db=new ConnectToDb();

    }

    catch(Exception ex){

    ex.printStackTrace();

    }

    JPanel panel=new JPanel();

    panel.setLayout(new GridLayout(3,2));

    panel.setBackground(Color.DARK_GRAY);

    panel.add(username=new JLabel("Username"));

    username.setForeground(Color.white);

    panel.add(bx=new JComboBox());

    panel.add(password=new JLabel("Password"));

    password.setForeground(Color.white);

    panel.add(passW=new JTextField(20));

    //get username

    bx.addItem("select username");

    try{

    db.connectToDatabase();

    use=db.username();

  • 8/11/2019 Automation of certificates

    33/57

    33

    ResultSet s=use.executeQuery();

    while(s.next()){

    bx.addItem(s.getString("username"));

    }

    }

    catch(Exception exx){

    bx.addItem("No user created");

    }

    panel.add(new JLabel());

    panel.add(loginButton=new JButton("Login"));

    panel.setBorder(BorderFactory.createTitledBorder(null, "Users Login panel"));

    panel.setForeground(Color.white);

    Container cont=getContentPane();

    cont.setBackground(Color.CYAN);

    cont.add(panel, BorderLayout.CENTER);

    Toolkit tool=getToolkit();

    Dimension dimension=tool.getScreenSize();

    int xOffset=500, yOffset=250;

    setBounds(xOffset, yOffset, 800,550);

    xOffset=(xOffset+30)%300;

    yOffset=(yOffset+300)%300;

    //setBounds(100,100, dimension.height-0, dimension.width-0);

  • 8/11/2019 Automation of certificates

    34/57

    34

    setVisible(true);

    loginButton.addActionListener(new ActionListener(){

    @Override

    public void actionPerformed(ActionEvent event){

    try{

    db.loginUser(getUserName(), getPassword());

    }

    catch(NullPointerException nullException){

    JOptionPane.showMessageDialog(null, "Null Pointer

    Exception",nullException.getMessage(), JOptionPane.ERROR_MESSAGE);

    nullException.printStackTrace();

    }

    catch(Exception ex){

    ex.printStackTrace();

    }

    }

    });

    }

    public String getUserName(){

    return bx.getSelectedItem().toString();

    }

    public String getPassword(){

    return passW.getText().toString();

    }

    /**

  • 8/11/2019 Automation of certificates

    35/57

    35

    * @param args the command line arguments

    */

    public static void main(String[] args) {

    // TODO code application logic here

    Halliburton school=new Halliburton();

    school.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    school.setResizable(false);

    school.setSize(300, 170);

    school.setResizable(false);

    }

    }

    HUMAN RESOURCE CODE

    import java.awt.Dimension;

    import java.awt.Graphics;

    import java.awt.image.BufferedImage;

    import java.io.File;

    import java.io.IOException;

    import javax.imageio.ImageIO;

    import javax.swing.JFrame;

    import javax.swing.JPanel;

    import javax.swing.SwingUtilities;

  • 8/11/2019 Automation of certificates

    36/57

    36

    import javax.swing.*;

    import java.awt.*;

    import java.awt.event.*;

    import java.sql.*;

    import java.awt.event.*;

    import javax.swing.event.*;

    import java.util.*;

    public class HumanResource extends JFrame{

    private ConnectToDb connect;

    private Action newUserAction, viewUserAction,searchUserAction, deleteUserAction,

    exitAction, editAction;

    private Action addCertificateAction, viewCertificateAction;

    private Action searchCertificate;

    private ContentPane desktop;

    public HumanResource(){

    super("Halliburton Energy Services Nigeria Limited");

    try{

    connect=new ConnectToDb();

    }

    catch(Exception ex){

    JOptionPane.showMessageDialog(null, ex,"Null pointer to database",

    JOptionPane.ERROR_MESSAGE);

    }

    //if connection is done successfully show GUI

  • 8/11/2019 Automation of certificates

    37/57

    37

    newUserAction=new newUserAccount();

    viewUserAction=new viewUserAccount();

    exitAction=new exitAccount();

    JMenu filem=new JMenu("File");

    JMenu filemenu=new JMenu("System Users");

    filemenu.setMnemonic(new Integer('F'));

    filemenu.add(newUserAction);

    filemenu.addSeparator();

    filemenu.add(viewUserAction);

    filemenu.addSeparator();

    filem.add(exitAction);

    //students menu

    JMenu studMenu=new JMenu("Tool / Equipment Certificates");

    viewCertificateAction=new ViewAllCertificates();

    addCertificateAction=new AddAllCertificate();

    searchCertificate=new SearchACertificate();

    studMenu.add(viewCertificateAction);

    studMenu.addSeparator();

    studMenu.add(addCertificateAction);

    studMenu.addSeparator();

    studMenu.add(searchCertificate);

    //set JToolbar

  • 8/11/2019 Automation of certificates

    38/57

    38

    JToolBar toolb=new JToolBar();

    toolb.add(newUserAction);

    toolb.add(viewUserAction);

    toolb.add(addCertificateAction);

    toolb.add(viewCertificateAction);

    toolb.add(searchCertificate);

    //set JMenuBar

    JMenuBar menubar=new JMenuBar();

    menubar.add(filem);

    menubar.add(filemenu);

    menubar.add(studMenu);

    setJMenuBar(menubar);

    desktop=new ContentPane();

    Container c=getContentPane();

    desktop.setBackground(Color.darkGray);

    desktop.setName("Halliburton Energy Services Nigeria Limited");

    c.add(toolb, BorderLayout.NORTH);

    c.add(desktop, BorderLayout.CENTER);

    addWindowListener(new WindowAdapter(){

    @Override

    public void windowClosing(WindowEvent event){

  • 8/11/2019 Automation of certificates

    39/57

    39

    shutDown();

    }

    });

    Toolkit toolkit=getToolkit();

    Dimension dimension=toolkit.getScreenSize();

    setBounds(0,0,dimension.width-0, dimension.height-0);

    setVisible(true);

    }

    private UsersFrame createNewUserFrame(){

    UsersFrame frame=new UsersFrame();

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    frame.addInternalFrameListener(new InternalFrameAdapter(){

    @Override

    public void internalFrameDeactivated(InternalFrameEvent event){

    viewUserAction.setEnabled(true);

    }

    @Override

    public void internalFrameActivated(InternalFrameEvent event){

    viewUserAction.setEnabled(true);

    }

  • 8/11/2019 Automation of certificates

    40/57

    40

    });

    frame.dispose();

    return frame;

    }

    private class newUserAccount extends AbstractAction{

    public newUserAccount(){

    putValue(NAME,"ADD NEW USER");

    putValue(SMALL_ICON, new

    ImageIcon(getClass().getResource("images/add_user.jpg")));

    putValue(SHORT_DESCRIPTION, "ADD NEW USER");

    putValue(LONG_DESCRIPTION, "Add new user to the system");

    putValue(MNEMONIC_KEY, new Integer('A'));

    }

    @Override

    public void actionPerformed(ActionEvent event){

    UsersFrame frame=createNewUserFrame();

    desktop.add(frame);

    frame.setSize(getWidth()-200, getHeight()-200);

    frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    frame.setVisible(true);

    }

  • 8/11/2019 Automation of certificates

    41/57

    41

    }

    private class viewUserAccount extends AbstractAction{

    public viewUserAccount(){

    putValue(NAME, "VIEW USER");

    putValue(SMALL_ICON, new

    ImageIcon(getClass().getResource("images/view_users.jpg")));

    putValue(SHORT_DESCRIPTION, "VIEW USERS");

    putValue(LONG_DESCRIPTION, "VIEW USERS");

    putValue(MNEMONIC_KEY, new Integer('V'));

    }

    @Override

    public void actionPerformed(ActionEvent event){

    try{

    ViewAllUsers uFrame=connect.viewUsersFrame();

    desktop.add(uFrame);

    uFrame.setSize(getWidth()-150, getHeight()-200);

    uFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    }

    catch(Exception ex){

    ex.printStackTrace();

    }

    }

  • 8/11/2019 Automation of certificates

    42/57

    42

    }

    private class exitAccount extends AbstractAction{

    public exitAccount(){

    putValue(NAME,"Exit");

    putValue(SMALL_ICON, new ImageIcon(getClass().getResource("images/logout.jpg")));

    putValue(SHORT_DESCRIPTION, "EXIT");

    putValue(LONG_DESCRIPTION, "Exit the application");

    putValue(MNEMONIC_KEY, new Integer('x'));

    }

    @Override

    public void actionPerformed(ActionEvent e){

    connect.close();

    System.exit(1);

    }

    }

    private class ViewAllCertificates extends AbstractAction{

    public ViewAllCertificates(){

    putValue(NAME, "View Certificates");

    putValue(SMALL_ICON, new ImageIcon(getClass().getResource("images/view.jpg")));

    putValue(SHORT_DESCRIPTION, "VIEW CERTIFICATE");

    putValue(LONG_DESCRIPTION,"View all certificates");

  • 8/11/2019 Automation of certificates

    43/57

    43

    putValue(MNEMONIC_KEY,new Integer('V'));

    }

    @Override

    public void actionPerformed(ActionEvent e){

    try{

    ViewCertificates newInfo=connect.viewCertificateFrame();

    desktop.add(newInfo);

    newInfo.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    newInfo.setSize(getWidth()-100, getHeight()-200);

    }

    catch(Exception ex){

    }

    }

    }

    private class AddAllCertificate extends AbstractAction{

    public AddAllCertificate(){

    putValue(NAME, "Add Certificates");

    putValue(SMALL_ICON, new ImageIcon(getClass().getResource("images/upload.jpg")));

    putValue(SHORT_DESCRIPTION, "ADD CERTIFICATE");

    putValue(LONG_DESCRIPTION,"Add new certificate");

    putValue(MNEMONIC_KEY,new Integer('C'));

    }

    @Override

  • 8/11/2019 Automation of certificates

    44/57

    44

    public void actionPerformed(ActionEvent e){

    try{

    AddCertificate newInfo=connect.addCertificateFrame();

    desktop.add(newInfo);

    newInfo.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    newInfo.setSize(getWidth()-100, getHeight()-200);

    }

    catch(Exception ex){

    }

    }

    }

    private class SearchACertificate extends AbstractAction{

    public SearchACertificate(){

    putValue(NAME, "Seach Certificate");

    putValue(SMALL_ICON, new ImageIcon(getClass().getResource("images/search.jpg")));

    putValue(SHORT_DESCRIPTION, "SEARCH CERTIFICATE");

    putValue(LONG_DESCRIPTION, "SEARCH FOR A PARTICULAR CERTIFICATE");

    putValue(MNEMONIC_KEY, new Integer('S'));

    }

    @Override

    public void actionPerformed(ActionEvent e){

    try{

    SearchCertificate sCert=connect.searchNewCertificate();

  • 8/11/2019 Automation of certificates

    45/57

    45

    desktop.add(sCert);

    sCert.setSize(getWidth()-100, getHeight()-200);

    sCert.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    }

    catch(Exception ex){

    JOptionPane.showMessageDialog(null,"Error"+"Could not open search page"+

    JOptionPane.ERROR_MESSAGE);

    }

    }

    }

    private static class ContentPane extends JDesktopPane {

    BufferedImage image = null;

    public ContentPane() {

    try {

    String pathToImage = "C:/Users/TUNDE

    OJO/Documents/NetBeansProjects/Halliburton/src/halliburton/images/background.jpg";

    image = ImageIO.read(new File(pathToImage));

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    protected void paintComponent(Graphics g) {

  • 8/11/2019 Automation of certificates

    46/57

    46

    Toolkit toolkit=getToolkit();

    Dimension dimension=toolkit.getScreenSize();

    super.paintComponent(g);

    g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(),this);

    };

    @Override

    public Dimension getPreferredSize() {

    return new Dimension(image.getWidth(), image.getHeight());

    }

    }

    public void shutDown(){

    connect.close();

    System.exit(1);

    }

    }

    PRINT CODE

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.*;

    import java.awt.print.*;

    public class PrintUIWindow implements Printable, ActionListener {

    Container frameToPrint;

  • 8/11/2019 Automation of certificates

    47/57

    47

    @Override

    public int print(Graphics g, PageFormat pf, int page) throws

    PrinterException {

    if (page > 0) { /* We have only one page, and 'page' is zero-based */

    return NO_SUCH_PAGE;

    }

    /* User (0,0) is typically outside the imageable area, so we must

    * translate by the X and Y values in the PageFormat to avoid clipping

    */

    Graphics2D g2d = (Graphics2D)g;

    g2d.translate(pf.getImageableX(), pf.getImageableY());

    /* Now print the window and its visible contents */

    frameToPrint.printAll(g);

    /* tell the caller that this page is part of the printed document */

    return PAGE_EXISTS;

    }

    public void actionPerformed(ActionEvent e) {

    PrinterJob job = PrinterJob.getPrinterJob();

    job.setPrintable(this);

    boolean ok = job.printDialog();

  • 8/11/2019 Automation of certificates

    48/57

    48

    if (ok) {

    try {

    job.print();

    } catch (PrinterException ex) {

    /* The job did not successfully complete */

    }

    }

    }

    public PrintUIWindow(Container f) {

    frameToPrint = f;

    }

    }

    SEARCH CODE

    import java.awt.*;

    import javax.swing.*;

    import javax.swing.event.*;

    import java.io.*;

    public class SearchCertificate extends JInternalFrame{

    private JEditorPane pane;

    private static int xOffset, yOffset;

    private JButton button;

    public SearchCertificate(){

    super("SEARCH CERTIFICATE",true,true);

  • 8/11/2019 Automation of certificates

    49/57

    49

    try{

    pane=new JEditorPane();

    pane.setEditable(false);

    pane.setPage("http://localhost/halliburton/search_certificate.php");

    }

    catch(IOException io){

    JOptionPane.showMessageDialog(null, io);

    }

    button=new JButton("Print Certificate");

    button.setBackground(Color.cyan);

    pane.addHyperlinkListener(new HyperlinkListener(){

    @Override

    public void hyperlinkUpdate(HyperlinkEvent e){

    if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){

    try{

    pane.setPage(e.getURL());

    }

    catch(Exception exp){

    pane.setText("Could not open "+e.getURL());

    }

    }

    }

    });

    Container c=getContentPane();

  • 8/11/2019 Automation of certificates

    50/57

    50

    c.add(button, BorderLayout.NORTH);

    button.addActionListener(new PrintUIWindow(c));

    c.add(new JScrollPane(pane));

    setBounds(xOffset, yOffset, 300,300);

    xOffset=(xOffset+30)%300;

    yOffset=(yOffset+30)%300;

    setVisible(true);

    }

    }

    UPLOAD CODE

    import java.awt.*;

    import javax.swing.*;

    import javax.swing.event.*;

    import java.io.*;

    public class UploadCertificate extends JInternalFrame{

    private static int xOffset=0, yOffset=0;

    private JEditorPane pane;

    public UploadCertificate(){

    super("UPLOAD CERTIFICATE", true, true);

    try{

    pane=new JEditorPane();

    pane.setEditable(false);

  • 8/11/2019 Automation of certificates

    51/57

    51

    pane.setPage("http://localhost/halliburton/upload_certificate.php");

    }

    catch(IOException io){

    JOptionPane.showMessageDialog(null, io);

    }

    //make link respond

    pane.addHyperlinkListener(new HyperlinkListener(){

    @Override

    public void hyperlinkUpdate(HyperlinkEvent e){

    if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){

    try{

    pane.setPage(e.getURL());

    }

    catch(Exception exp){

    pane.setText("Could not open "+e.getURL()+"");

    }

    }

    }

    });

    //end of

    Container c=getContentPane();

    c.add(new JScrollPane(pane));

    setBounds(xOffset, yOffset, 300,300);

    xOffset=(xOffset+30)%300;

  • 8/11/2019 Automation of certificates

    52/57

    52

    yOffset=(yOffset+30)%300;

    setVisible(true);

    }

    }

    USER FRAME CODE

    import javax.swing.*;

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.event.*;

    import java.io.*;

    public class UsersFrame extends JInternalFrame{

    private static int xOffset=0, yOffset=0;

    private JEditorPane pane;

    public UsersFrame(){

    super("Halliburton Energy Services Nigeria Limited",true,true);

    try{

    pane=new JEditorPane();

    pane.setEditable(false);

    pane.setPage("http://localhost/halliburton/add_new_user.php");

    }

    catch(IOException ex){

    JOptionPane.showMessageDialog(null, ex, "Error", JOptionPane.ERROR_MESSAGE);

    }

    pane.addHyperlinkListener(new HyperlinkListener(){

    @Override

  • 8/11/2019 Automation of certificates

    53/57

    53

    public void hyperlinkUpdate(HyperlinkEvent e){

    if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){

    try{

    pane.setPage(e.getURL());

    }

    catch(Exception ex){

    pane.setText("Could not open "+e.getURL()+"");

    }

    }

    }

    });

    Container c=getContentPane();

    c.add(new JScrollPane(pane));

    setBounds(xOffset, yOffset, 300,300);

    xOffset=(xOffset+30)%300;

    yOffset=(yOffset+30)%300;

    setVisible(true);

    }

    }

    CODE TO VIEW ALL USER

    import java.awt.*;

    import javax.swing.*;

    import java.awt.event.*;

    import java.sql.*;

  • 8/11/2019 Automation of certificates

    54/57

    54

    import java.util.*;

    import javax.swing.table.*;

    import javax.swing.event.*;

    import java.io.*;

    public class ViewAllUsers extends JInternalFrame{

    private static int xOffset=0, yOffset=0;

    private JEditorPane pane;

    public ViewAllUsers(){

    super("SYSTEM USERS INFORMATION", true, true);

    try{

    pane=new JEditorPane();

    pane.setEditable(false);

    pane.setPage("http://localhost/halliburton/view_users.php");

    }

    catch(IOException io){

    JOptionPane.showMessageDialog(null, io);

    }

    pane.addHyperlinkListener(new HyperlinkListener(){

    @Override

    public void hyperlinkUpdate(HyperlinkEvent e){

    if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){

    try{

    pane.setPage(e.getURL());

    }

  • 8/11/2019 Automation of certificates

    55/57

    55

    catch(Exception exp){

    pane.setText("Could not open "+e.getURL());

    }

    }

    }

    });

    Container c=getContentPane();

    c.add(new JScrollPane(pane));

    setBounds(xOffset, yOffset, 300,300);

    xOffset=(xOffset+30)%300;

    yOffset=(yOffset+30)%300;

    setVisible(true);

    }

    }

    CODE TO VIEW CERTIFICATE

    import java.awt.*;

    import javax.swing.*;

    import java.awt.event.*;

    import java.sql.*;

    import java.util.*;

    import javax.swing.table.*;

    import javax.swing.event.*;

    import java.io.*;

    import java.awt.Component.*;

    import java.awt.print.*;

  • 8/11/2019 Automation of certificates

    56/57

    56

    import java.awt.event.*;

    public class ViewCertificates extends JInternalFrame{

    private JButton button;

    private static int xOffset=0, yOffset=0;

    private JEditorPane pane;

    private Graphics g;

    public ViewCertificates(){

    super("EQUIPMENT / TOOLS CERTIFICATES", true, true);

    button=new JButton("Print Certificate");

    button.setBackground(Color.cyan);

    try{

    pane=new JEditorPane();

    pane.setEditable(false);

    pane.setPage("http://localhost/halliburton/view_certificates.php");

    }

    catch(IOException io){

    JOptionPane.showMessageDialog(null, io);

    }

    pane.addHyperlinkListener(new HyperlinkListener(){

    @Override

    public void hyperlinkUpdate(HyperlinkEvent e){

    if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){

  • 8/11/2019 Automation of certificates

    57/57

    try{

    pane.setPage(e.getURL());

    }

    catch(Exception exp){

    pane.setText("Could not open "+e.getURL());

    }

    }

    }

    });

    Container c=getContentPane();

    c.add(button, BorderLayout.NORTH);

    button.addActionListener(new PrintUIWindow(c));

    c.add(new JScrollPane(pane), BorderLayout.CENTER);

    setBounds(xOffset, yOffset, 300,300);

    xOffset=(xOffset+30)%300;

    yOffset=(yOffset+30)%300;

    setVisible(true);

    }

    }