cafe mgt system
TRANSCRIPT
-
7/30/2019 Cafe Mgt System
1/84
MINOR PROJECT
ON
SUBMITTED IN PARTIAL FULFILLMENT OF THE
REQUIREMENT FOR THE AWARD OF THE
DEGREE OF
BACHELOR OF TECHNOLOGY
(COMPUTER SCIENCE ENGINEERING)
Ch. Devi Lal Mem. Govt. Engg. College
Panniwalla motta , Sirsa(Haryana)
CH. DEVI LAL UNIVERSITY
SIRSA, INDIA
2010
SUBMITTED TO:-
Mr. Ved Prakash
(H.O.D. IN C.S.E.
Dept.)
SUBMITTED BY :-
MOHIT SAREEN
(7226)
AND
AMIT JANGRA
(7203)
(7th
Semester)
ROZGAR.COM A JOB FINDER PORTAL
-
7/30/2019 Cafe Mgt System
2/84
ACKNOWLEGDEMENT
One of the greatest pleasures of writing this major-report is acknowledging theefforts of many people whose cooperation and understanding were crucial to
the making of this project. This project happened because of the expert
guidance, encouragement, suggestions and precious comments of dedicated
Mr.Ved Prakash & Mr.Sanjay Dahiya, faculty, CSE Dept..
This is the part where we got to thank all the people who have helped us to
make this project a great experience academically.
Dated:-
-
7/30/2019 Cafe Mgt System
3/84
CERTIFICATE
This is to certify that the Major Project entitled CAF MANAGEMENT SYSTEM is a
bonafide work carried out by Srikant yadav(7252) ,Pardeep kumar(7232), Ajay
singh(7202) final year students , under my guidance and supervision and submitted in
fulfillment of the award of the B.Tech degree in Computer Science & Engineering.
The work embodied in the Major Project has not been submitted for the award of any other
degree or diploma to the best of my knowledge.
Our Team
Ajay Singh (7202)
Pardeep Kumar (7232)
Srikant Yadav (7252)
Head of the Department (Computer Science and engineering)
(Mr.Ved Prakash)
-
7/30/2019 Cafe Mgt System
4/84
PREFACE
In the modern world of the computer , Internet and the increasing popularity of
Internet , more and more peoples are getting use to of Internet, due to which
Internet Cafes are being opened as a full time business .
Internet Cafe is a place where a person can surf Internet , can do video or voice
chatting , can watch movies ,can download data etc.
Generally to keep track of costumers sitting on which system is done through
making entries in a register(notebook).
But this can done via a click of mouse as well.
What Cafe mgt. System do is it allows the host to keep track of costumers sitting
on which system by just a click of mouse. Once the surfing session of a customer
is over the customer name , address , phone numbers gets stored in the
database with date and time.
Thus the work and time is saved as the database can be updated regularly at the
back-end , and tedious job of doing entries in a register can be avoided.
.
-
7/30/2019 Cafe Mgt System
5/84
CONTENTS
1. Introduction
1.1 Introduction to the Project.
1.2 About JAVA.
1.3 Features of JAVA.
1.4 Java Swings and EJB Architecture.
2. System analysis.
3. Software requirements specification
3.1 S/W AND H/W Specification.
3.2 Acceptance Criteria.
4. Design.
5. Database design.
6. Data flow diagram.
7. Front-end design & coding.
8. Reference
-
7/30/2019 Cafe Mgt System
6/84
Chapter 1:- INTRODUCTION
ABOUT US:
Cafe Management System has a simple mission.
To make the management of cafe easy , faster , reliable.
We make it easy.
Cafe Management System do following tasks:
1. Keeps track of costumers sitting on which computer.
2. Then makes a entry in to the database i.e. costumer name , phone no. and
address with signing in time and signing out time with date is stored into thedatabase.
The road ahead.
We aim to make this project more user friendly , faster and reliable.
We are aiming to embed Screen locker into the software to make it more and
more secure.
We are proud of our achievements and excited about the future. However, somethings that will not change are our commitment to our project and belief in
endless possibilities.
-
7/30/2019 Cafe Mgt System
7/84
About JAVA:
Java is an object oriented language, multithreaded programming language developed by Sun
Microsystems in 1991.it is designed to be small, simple and portable across different
platforms as well as operating systems.
The popularity of Java is due to its unique technology that is designed on the basis of three
key elements. They are the usage of applets, powerful programming language constructs and
a rich set of significant object classes.
When a program is compiled, it is translated into machine code or processor instructions that
is specific to the processor. In the Java development environment there are two parts: a Java
compiler and a Java interpreter. The compiler generates the byte code(a set of instructions
that resemble machine code but are not specific to any processor)instead of machine code and
the interpreter executes the Java program.
The disadvantage of using bytecode is the execution speed. Since system specific programs
run directly on the hardware, they are faster than the Java bytecodes that is processed by the
interpreter. In order to write a Java program, an editor, a Java compiler and a Java Runtime
Environment are needed.
The editor can be a Notepad, Wordpad, MS-DOS editor etc. the easiest way to get a Java
Compiler and Runtime Environment is to download Suns Java Development Kit. This
provides system input and output capabilities and other utility functions in addition to classes
that support networking, common Internet protocols and user interface toolkit functions.
FEATURES OF JAVA
SIMPLE OBJECT-ORIENTED ROBUST MULTITHREADED ARCHITECTURE-NEUTRAL DISTRIBUTED DYNAMIC OBJECT-ORIENTED PROGRAMMING APPROACH
-
7/30/2019 Cafe Mgt System
8/84
Another way to access database(JDBC-ODBC)
SYSTEM ARCHITECTURE
A well-defined software application is partitioned into separate logical parts called layers.
Each layer has different responsibilities in the over all architecture. These layers are purely
abstraction and do not corresponds to physical distribution.
Typical layers in a software system are as follows:-
1) Presentation layer:- In this layer are parts that handle the user interface and userinteraction.
2) Business l0gic layer:- This layer contains components that handle the programminglogic of the application.
3) Data layer:- This layer is used by the business logic layer to persist state permanently.This state normally consists of one or more databases where data is stored.
-
7/30/2019 Cafe Mgt System
9/84
THE TWO-TIER ARCHITECTURE
It is a simple client server application in which the processing workload falls onto the client
computers shoulders and the server simply act as a traffic controller between the client and
the data.
The term fat client for this type of architecture is due to the bulk of the processing
requirements at the client side. In this architecture , the presentation layer and the business
logic layer are hosted in one tier and data layer is on other tier.
BENEFITS OF EBJ:
Performancethe performance of EJB is superior to CGI because there is no processcreation for each client request. Instead, each request is handed by the EJB 3.0
container process. After EJB 3.0 is finished processing a request, it stays resident in
memory, waiting for another request.
Portabilityyou can move them to other operating systems without serious hassles. Rapid development cycleAs a java technology, EJB 3.0 have access to the rich
java library, which helps speed up the development process.
RobustnessEJB 3.0 are managed by JVM. As such, you dont need to worry aboutmemory leak or garbage collection.
Widespread acceptanceJava is a widely accepted technology.
-
7/30/2019 Cafe Mgt System
10/84
-
7/30/2019 Cafe Mgt System
11/84
Chapter 2:- SYSTEM ANALYSIS
This process consists of the following stages:
Research & Analysis
This is the first stage where in the designers have to analyze the field so as to understand the
requirement of the user(s). This is accomplished through several interactive sessions between
the user(s) and the designer, where by the designer tries to understand the working of the
system with all the different factors that influence the database. Designers can then make the
package only after they have understood the functionality of the system.
Normalization
Normalization is a process that takes the relational schema through a series of tests to certify
whether or not it belongs to a certain normal form. It also aims at refining the data structureto minimize data redundancy and to avoid update anomalies in the database.
First Normal Form (1NF)
A Relation in which repeating groups are eliminated i.e. all the attributes in the
relation must be single valued or atomic in nature.Second Normal Form (2NF)
A Relation in which every non-prime attribute is fully, functionally dependent on the
complete prime attribute and not only a part of the prime attribute. The prime attribute
uniquely identifies the non-prime attribute.
Third Normal Form (3NF)
A Relation is 3NF if and only if it is in 2NF and every non-prime attribute is transitively
dependent on the prime attribute.
Building Stage
At this stage, we take the database design and implement it. Using the tools provided by the
MSaccess tables and Data Reports does the implementation.
Production Stage
At this stage, the database commences its role as a repository of data. The user can log
in through the front end.
-
7/30/2019 Cafe Mgt System
12/84
SYSTEM DESIGN:
Software Navigation
Software Navigation gives details of how the back-end (tables), in a database is connected to
its front-end (actual display forms). This in essence explains how the data gets stored in thedatabase and how it is retrieved after some user input is given.
Clearly, this operation takes place only through the implementation of certain software for the
front-end and back-end of the database.
Back-End: MS-Access , EJB 3.0 and web logic 10.0 server
Front-End: JAVA and JAVA SWINGS
The connectivity between the back-end and the front-end can be established by any of the
following standards:
ADODC: Active Data Object Data Control ADODB: Active Data Object Database Data Environment ADO: Active X Data Objects/Control RDO: Remote Data Object RDODC: Remote Data Object Data Control
The connectivity in this project has been established using Active X Control. Active X hasbeen implemented through the use of ADODB.
ADO is the method of data access that Microsoft has introduced. ADO provides a means by
which your program code accesses the database.
The ADO connects to the database to OLE DB Provider. The OLE DB Provider exposes
databases to ADO, which in turn allows you to connect to the data.
A data control is a custom control that handles communication with the database. You
simply set a few properties and bind some other controls to the data control to display
information.
-
7/30/2019 Cafe Mgt System
13/84
Chapter 3:- SOFTWARE REQUIREMENTS AND SPECIFICATION
Introduction
Purpose:
The purpose of this document is to describe the requirements for implementing and using the
Cafe Management System.
Scope:
The document is meant to be used by the developers to guide them through the development
and for the users to verify their requirements.
Overview:
The developers are responsible for the development of the database system for themaintenance, updating and to provide required information to the user so that he can use the
product effectively.
General Description
Product Prospective:
The product is independent of the other products and only dependent on DBMS to provide all
the functionality.
Product Functions:
The system has to make available all the details regarding the different trains and their
availability status, routes, fares, etc..
External Interface Requirements
User Interface Interface is neatly and consistently designed. Meaningful push buttons and menus are to be provided for easy usage. Help should be provided wherever necessary. Easy navigation facility between forms is necessary. Appropriate messages are to be displayed in case of errors or exceptions.
-
7/30/2019 Cafe Mgt System
14/84
System Requirements
1) Hardware Requirements:The editor is optimized to run on any hardware configuration. All it needs is
A system with color monitor. PENTIUM IV Processor. Minimum Ram of 128.0 MB2) Software Requirements
The editor can be installed and run in any system, which provides
PLATFORM Windows XP and above. BACKEND MS-Access , Weblogic server 10.0 FRONT END JAVA.
Acceptance Criteria
The developer will need to demonstrate the effective working of the system with sample data.
Queries and updates to the database should be supported in a consistent way. Check validity
of inputs by the user and give appropriate messages when necessary. The following features
must be satisfied.
No two Users can have the same account. No two Companies can view other companys messages. Critical data like password and other credentials cannot be left blank.
The system should support easy and consistent way for populating and removing data from
the database and for showing the output accordingly.
-
7/30/2019 Cafe Mgt System
15/84
Preliminary assessment
First phase of any project is preliminary assessment. The base of this phase is recognition
of needs for improving an information system or a procedure. This need leads to an initial
investigation to determine whether an alternative system can solve the problem.
The primary goal of the project is to enable the booking, cancellation of tickets and
providing information. A user need to be registered through their login ids and password.
When the user enters the data into the system either of the options in the menu list as a query.
The output/result will be given as specified.
Feasibility study
Feasibility study is a test of a system proposal according to its workability, impact onorganization, ability to met user needs and effective use of resources.
Task of this phase should clearly define:
Users demonstrable needs. Availability of resources. Estimate the resources required. Impact of this system on the organization Define & document in outline a proposed system.
There are some types of feasibility:
Technical feasibility: It is related to the availability of hardware and software toperform the essential computing.
Economic return feasibility: The new system should be economically beneficial. Forthe cost/ benefit analysis is performed.
Non economic return feasibility: System can be justified based on benefits inmonitory terms.
Time feasibility: System should be implemented within mentioned time constraints. Legal & ethical feasibility: System should exist within legal & ethical boundaries.
Analysis
Analysis is a detailed study of various operations performed by a system and their
relationships within & outside the system.
-
7/30/2019 Cafe Mgt System
16/84
Design
System design is determination of processes & data that are required by a new system.
Design describes a final system & process by which it is developed. It refers to the technical
specifications that will be applied in implementing the system.
Implementation & testing
Implementation is the acquisition and integration of the physical and conceptual resources
that produce a working system. It is concerned with those tasks leading immediately to a fully
operational system. It involves programmers, users and operational management but its plan
of timing is a prime function of system analysis.
Maintenance
Periodic maintenance of hardware & software are required to keep in tune with design
specifications. If the new information is inconsistent with the design specification, then
change have to be made.
Review & evaluation
A review is conducted whether system objectives are being met with the user requirements
and what are the problems in smooth running. Steps are taken to resolve them.
-
7/30/2019 Cafe Mgt System
17/84
Chapter 6) DATA FLOW DIAGRAM
CAFE MANAGEMENT SYSTEM
Host Interface Client Interface
Start/terminate
client session
Search by name , date or
name and date
Feed your name,
phone no. , address
Watch time escaped
while surfing
-
7/30/2019 Cafe Mgt System
18/84
Chapter 7: CODING://HOST INTERFACE(hostclient.java)
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.util.Date;
import java.util.*;
import javax.swing.Timer;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.text.html.*;
public class dd {
String str;
String chr;
JFrame frm;
JPanel pan1,pan2,pan3,pan4,pan5;
JButton but1,but2,but3;
Timer t,t1,t2;
JLabel label1;
JLabel label2;
JLabel l1,l2,l3,l4,l5,l6,timer;
LinkedList sysname=new LinkedList();
JFrame ifrm;
JDesktopPane desk;
JPopupMenu pmenu1,pmenu2;
JMenuItem menuItem1,menuItem2,menuItem3,menuItem11,menuItem22,menuItem33;
Formatter fmt=new Formatter();
Formatter fmt1=new Formatter();
Formatter fmt2=new Formatter();
-
7/30/2019 Cafe Mgt System
19/84
Formatter fmt3=new Formatter();
Calendar cal=Calendar.getInstance();
int secs=0;
int secs1=0;
int mins1=0;
int hours1=0;
int mins=0;
int secs2=0;
int mins2=0;
int hours2=0;
int hours=0;
public dd(){
l1=new JLabel();
l2=new JLabel();
l3=new JLabel();
l4=new JLabel();
l5=new JLabel();
l6=new JLabel();
timer=new JLabel();
pan1=new JPanel();
pan2=new JPanel();
pan3=new JPanel();
pan4=new JPanel();
pan5=new JPanel();
//sysname.add(0,"null");
// sysname.add(1,"null");
//String image="computer.gif";
//ImageIcon ii=new ImageIcon(image);
-
7/30/2019 Cafe Mgt System
20/84
//System.out.println(sysname.get(0));
// label1=new JLabel(sysname.get(0),ii,JLabel.LEFT);
// label2=new JLabel(sysname.get(1),ii,JLabel.LEFT);
//label1.setForeground(Color.gray);
//searchnewSystem();
//if(sysname.get(0).equals("null")){label1.setVisible(false);}
//if(sysname.get(1).equals("null")){label2.setVisible(false);}
frm=new JFrame("HostClient");
fmt1.format("%tA %tb %td %tY",cal,cal,cal,cal);
//fmt.format("%tr",cal);
frm.setIconImage(Toolkit.getDefaultToolkit().getImage("computer.gif"));
l2.setFont(new Font( "Verdana", Font.BOLD,10));
l3.setFont(new Font( "Verdana", Font.BOLD,12));
l4.setFont(new Font( "Verdana", Font.BOLD,12));
l5.setFont(new Font( "Verdana", Font.BOLD,12));
l6.setFont(new Font( "Verdana", Font.BOLD,15));
frm.setLayout(new BorderLayout());
l1.setFont(new Font( "Verdana", Font.BOLD,15));
JMenuBar menubar=new JMenuBar();
JMenu fileMenu=new JMenu("File");
JMenu fileMenu11=new JMenu("View");
fileMenu.add(new JSeparator());
fileMenu11.add(new JSeparator());
JMenuItem fileItem1=new JMenuItem("Your Cafe Name");
JMenuItem fileItem2=new JMenuItem("Set Charges");
JMenuItem fileItem3=new JMenuItem("Shutdown");
-
7/30/2019 Cafe Mgt System
21/84
JMenuItem fileItem4=new JMenuItem("Search by Customer Name");
JMenuItem fileItem5=new JMenuItem("Search by Date");
JMenuItem fileItem6=new JMenuItem("Search by Name and Date");
fileMenu11.add(fileItem4);
fileMenu11.add(fileItem5);
fileMenu11.add(fileItem6);
fileMenu.add(fileItem1);
fileMenu.add(fileItem2);
fileMenu.add(fileItem3);
menubar.add(fileMenu);
menubar.add(fileMenu11);
frm.setJMenuBar(menubar);
fileItem1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String str=JOptionPane.showInputDialog(null,"Enter the name:","Set cafe name",1);
if (str!=null){
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update cafename set nameofcafe=? where num=?");
pstmt.setString(1,str);
pstmt.setInt(2,1);
int count=pstmt.executeUpdate();
-
7/30/2019 Cafe Mgt System
22/84
System.out.println("inside inner try");
if(count>0)
{System.out.println("updated to "+str);
}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
getcafename();
}
catch(Exception e2)
{System.out.println(e2);
}
}
}});
fileItem2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String str=JOptionPane.showInputDialog(null,"Enter the money charged/hour:","Set charges",1);
if (str!=null){
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
-
7/30/2019 Cafe Mgt System
23/84
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update cafename set charge=? where num=?");
pstmt.setString(1,str);
pstmt.setInt(2,1);
int count=pstmt.executeUpdate();
System.out.println("inside inner try");
if(count>0)
{System.out.println("updated to "+str);
}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
getcafename();
}
catch(Exception e2)
{System.out.println(e2);
}
}
}});
fileItem3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
-
7/30/2019 Cafe Mgt System
24/84
int str=JOptionPane.showConfirmDialog(null,"This will terminate all client
sessions","Confirmation",JOptionPane.OK_CANCEL_OPTION);
if (str==0){
shutdown();
}
}});
pan1.setLayout(new BorderLayout());
pan2.setLayout(new BorderLayout());
pan4.setLayout(new BorderLayout());
pan5.setLayout(new FlowLayout());
pan5.setBackground(Color.yellow);
l2.setText(""+fmt1);
//l3.setText("Total number of Systems:0");
//l4.setText(" Number of Systems Occupied:3");
l5.setText("Charge for one hour Rs:20");
but3= new JButton("Click to Refresh");
pan1.add(but3,BorderLayout.NORTH);
but3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
searchnewSystem();
}});
but3.setToolTipText("Click to Refresh");
searchnewSystem();
pmenu1= new JPopupMenu();
menuItem1=new JMenuItem("START NEW SESSION");
pmenu1.add(menuItem1);
menuItem2=new JMenuItem("TERMINATE");
pmenu1.add(menuItem2);
-
7/30/2019 Cafe Mgt System
25/84
menuItem3=new JMenuItem("SHOW DETIALS");
pmenu1.add(menuItem3);
menuItem2.setEnabled(false);
menuItem3.setEnabled(false);
menuItem1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
menuItem1.setEnabled(false);
menuItem3.setEnabled(true);
menuItem2.setEnabled(true);
mins1=0;
secs1=0;
hours1=0;
t1.start();
label1.setForeground(Color.gray);
label1.setText(""+sysname.get(0)+"
"+hours1+":"+mins1+":"+secs1+"
"+"New sessionstarted"+"");
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update status set truefalse=? where sysname=?");
pstmt.setInt(1,1);
pstmt.setString(2,sysname.get(0));
int count=pstmt.executeUpdate();
-
7/30/2019 Cafe Mgt System
26/84
System.out.println("inside inner try");
if(count>0)
{System.out.println("updated to 1"+count+"label1");}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
}
catch(Exception e1)
{System.out.println(e1);
}
}
});
menuItem2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
menuItem1.setEnabled(true);
menuItem2.setEnabled(false);
menuItem3.setEnabled(false);
t1.stop();
//label1.setForeground(Color.black);
label1.setText(""+sysname.get(0)+"
"+hours1+":"+mins1+":"+secs1+"
"+"sessionstopped"+"");Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
-
7/30/2019 Cafe Mgt System
27/84
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update status set truefalse=? where sysname=?");
pstmt.setInt(1,0);
pstmt.setString(2,sysname.get(0));
int count=pstmt.executeUpdate();
System.out.println("inside inner try");
if(count>0)
{System.out.println("updated to 0"+count+"label1");}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2);
}
try
{
fmt2.format("%tr",cal);
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
-
7/30/2019 Cafe Mgt System
28/84
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt1=con.prepareStatement("update dbase set endtime=? where sysname=? and
status=?");
pstmt1.setString(2,sysname.get(0));
pstmt1.setString(1,""+fmt2+"");
pstmt1.setInt(3,1);
int count1=pstmt1.executeUpdate();
if(count1>0)
{System.out.println("endtime is set");
}
PreparedStatement pstmt=con.prepareStatement("update dbase set status=? where sysname=?");
pstmt.setInt(1,0);
pstmt.setString(2,sysname.get(0));
int count=pstmt.executeUpdate();
if(count>0)
{System.out.println("status is set to 0");
}
else{
System.out.println(" table not updated");
}
pstmt.close();
con.close();
}
-
7/30/2019 Cafe Mgt System
29/84
catch(Exception e2)
{System.out.println(e2);
}
}
});
menuItem3.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//menuItem1.setEnabled(true);
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
String cname1="";
String pno1="";
String add1="";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYy");
PreparedStatement pstmt=con.prepareStatement("select * from dbase where sysname=? and status=? ");
pstmt.setString(1,sysname.get(0));
pstmt.setInt(2,1);
System.out.println(sysname.get(0));
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{
-
7/30/2019 Cafe Mgt System
30/84
cname1=rsl.getString(2);
System.out.println(cname1);
pno1=rsl.getString(3);
add1=rsl.getString(4);
}
String info=""+"costumer name:"+cname1+"
"+"phone no.:"+pno1+"
"+"Address:"+add1;JOptionPane.showMessageDialog(null,info,"Details",1);
}
catch(Exception ee){System.out.println(ee+"here");}
}
});
/*label1.addMouseListener(new MouseAdapter(){
public void mouseReleased(MouseEvent Me){
if(Me.isPopupTrigger()){
pmenu1.show(Me.getComponent(),Me.getX(),Me.getY());
}
}
}); */
pmenu2= new JPopupMenu();
menuItem11=new JMenuItem("START NEW SESSION");
pmenu2.add(menuItem11);
menuItem22=new JMenuItem("TERMINATE");
pmenu2.add(menuItem22);
-
7/30/2019 Cafe Mgt System
31/84
menuItem33=new JMenuItem("SHOW DETIALS");
pmenu2.add(menuItem33);
menuItem22.setEnabled(false);
menuItem33.setEnabled(false);
menuItem22.setEnabled(false);
menuItem11.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
menuItem11.setEnabled(false);
menuItem33.setEnabled(true);
menuItem22.setEnabled(true);
mins2=0;
secs2=0;
hours2=0;
t2.start();
label2.setForeground(Color.gray);
label2.setText(""+sysname.get(1)+"
"+hours2+":"+mins2+":"+secs2+"
"+"New sessionstarted"+"");
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update status set truefalse=? where sysname=?");
pstmt.setInt(1,1);
-
7/30/2019 Cafe Mgt System
32/84
pstmt.setString(2,sysname.get(1));
int count=pstmt.executeUpdate();
System.out.println("inside inner try");
if(count>0)
{System.out.println("updated to 1"+count+"label2");}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
}
catch(Exception e11)
{System.out.println(e11);
}
}
});
menuItem22.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
menuItem11.setEnabled(true);
menuItem22.setEnabled(false);
menuItem33.setEnabled(true);
t2.stop();
label2.setText(""+sysname.get(1)+"
"+hours2+":"+mins2+":"+secs2+"
"+"sessionstopped"+"");
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
-
7/30/2019 Cafe Mgt System
33/84
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update status set truefalse=? where sysname=?");
pstmt.setInt(1,0);
pstmt.setString(2,sysname.get(1));
int count=pstmt.executeUpdate();
System.out.println("inside inner try");
if(count>0)
{System.out.println("updated to 0"+count+"label2");}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2);
}
try
{
fmt3.format("%tr",cal);
Class.forName(driverClassName);
-
7/30/2019 Cafe Mgt System
34/84
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt1=con.prepareStatement("update dbase set endtime=? where sysname=? and
status=?");
pstmt1.setString(2,sysname.get(1));
pstmt1.setString(1,""+fmt3+"");
pstmt1.setInt(3,1);
int count1=pstmt1.executeUpdate();
if(count1>0)
{System.out.println("endtime is set");
}
PreparedStatement pstmt=con.prepareStatement("update dbase set status=? where sysname=?");
pstmt.setInt(1,0);
pstmt.setString(2,sysname.get(1));
int count=pstmt.executeUpdate();
if(count>0)
{System.out.println("status is set to 0");
}
else{
System.out.println(" table not updated");
}
pstmt.close();
-
7/30/2019 Cafe Mgt System
35/84
con.close();
}
catch(Exception e2)
{System.out.println(e2);
}
}
});
menuItem33.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//menuItem11.setEnabled(true);
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
String cname1="";
String pno1="";
String add1="";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYy");
PreparedStatement pstmt=con.prepareStatement("select * from dbase where sysname=? and status=? ");
pstmt.setString(1,sysname.get(1));
pstmt.setInt(2,1);
System.out.println(sysname.get(1));
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{
-
7/30/2019 Cafe Mgt System
36/84
cname1=rsl.getString(2);
System.out.println(cname1);
pno1=rsl.getString(3);
add1=rsl.getString(4);
}
String info=""+"costumer name:"+cname1+"
"+"phone no.:"+pno1+"
"+"Address:"+add1;JOptionPane.showMessageDialog(null,info,"Details",1);
}
catch(Exception ee){System.out.println(ee+"here");}
}
});
/* label2.addMouseListener(new MouseAdapter(){
public void mouseReleased(MouseEvent Me1){
if(Me1.isPopupTrigger()){
pmenu2.show(Me1.getComponent(),Me1.getX(),Me1.getY());
}
}
}); */
ActionListener taskPerformerclock=new ActionListener()
{public void actionPerformed(ActionEvent evt){
l1.setText(new Date().toString().substring(11,19));
secs ++ ;
if(secs>=59){
secs=0;
-
7/30/2019 Cafe Mgt System
37/84
mins++;
}
if(mins>=59){
mins=0;
hours++;
}
timer.setText(""+hours+":"+mins+":"+secs);
}};
t=new Timer(1000,taskPerformerclock);
t.start();
ActionListener taskPerformer1=new ActionListener()
{public void actionPerformed(ActionEvent evt){
secs1 ++ ;
if(secs1>=59){
secs1=0;
mins1++;
}
if(mins1>=59){
mins1=0;
hours1++;
}
label1.setText(""+sysname.get(0)+"
"+hours1+":"+mins1+":"+secs1+"");}};
t1=new Timer(1000, taskPerformer1);
ActionListener taskPerformer2=new ActionListener()
{public void actionPerformed(ActionEvent evt){
secs2 ++ ;
if(secs2>=59){
secs2=0;
mins2++;
-
7/30/2019 Cafe Mgt System
38/84
}
if(mins2>=59){
mins2=0;
hours2++;
}
label2.setText(""+sysname.get(1)+"
"+hours2+":"+mins2+":"+secs2+"");}};
t2=new Timer(1000, taskPerformer2);
pan1.setBorder(BorderFactory.createLineBorder(Color.blue,1) );
pan2.setBorder(BorderFactory.createLineBorder(Color.green,1));
pan3.setBorder(BorderFactory.createLineBorder(Color.gray,1));
pan3.setBackground(Color.white);
pan1.add(pan3,BorderLayout.CENTER);
pan2.add(l3,BorderLayout.NORTH);
pan2.add(l4,BorderLayout.SOUTH);
pan2.add(l5,BorderLayout.WEST);
pan2.add(pan4,BorderLayout.EAST);
pan2.add(pan5,BorderLayout.CENTER);
pan4.add(l1,BorderLayout.CENTER);
pan4.add(l2,BorderLayout.SOUTH);
getcafename();
pan5.add(l6);
pan3.add(label1);
pan3.add(label2);
fileItem4.setToolTipText("to search customer by name");
fileItem5.setToolTipText("to search customer by date");
fileItem6.setToolTipText("to search customer by name and date");
fileItem3.setToolTipText("it will terminate all client sessions");
fileItem2.setToolTipText("set charge per hour");
fileItem1.setToolTipText("set name of your cafe");
fileItem4.addActionListener(new ActionListener(){
-
7/30/2019 Cafe Mgt System
39/84
public void actionPerformed(ActionEvent e){
Vector data =new Vector();
Vector row=new Vector();
Vector row1=new Vector();
Vector colHeads=new Vector();
String str=null;
str=JOptionPane.showInputDialog(null,"Enter Customer Name:","Search by Customer Name",1);
System.out.println(str+"null1");
if(str.equals("")){JOptionPane.showMessageDialog(null,"You must enter a name!","TextBox Empty",2);}
else{
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
PreparedStatement pstmt;
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYc");
pstmt=con.prepareStatement("select * from dbase where cname=? ");
pstmt.setString(1,str);
ResultSet rsl =pstmt.executeQuery();
int i=0;
-
7/30/2019 Cafe Mgt System
40/84
if (rsl.next())
{System.out.println("in while of search1");
String cname=rsl.getString(2);
String pno=rsl.getString(3);
String address=rsl.getString(4);
String sin=rsl.getString(5);
String sout=rsl.getString(6);
String date=rsl.getString(7);
System.out.println("in while of search2");
row.add(0,cname);
row.add(1,pno);
row.add(2,address);
row.add(3,date);
row.add(4,sin);
row.add(5,sout);
System.out.println(row);
data.add(i,row);
System.out.println(data);
i++;
}
/* int size=(row.size())/6;
int f=0;
int l=6;
for(int i1=1;i1
-
7/30/2019 Cafe Mgt System
41/84
}*/
//data=(Vector)row1;
colHeads.add("Customer Name");
colHeads.add("Phone Number");
colHeads.add("Address");
colHeads.add("Date");
colHeads.add("SignIn Time");
colHeads.add("SignOut Time");
JFrame sfrm1=new JFrame("Search Result");
JPanel spanel1=new JPanel();
//System.out.println(data);
JTable stable1=new JTable(data,colHeads);
stable1.setBackground(Color.yellow);
sfrm1.setIconImage(Toolkit.getDefaultToolkit().getImage("computer.gif"));
JScrollPane sjsp1=new JScrollPane(stable1);
spanel1.add(sjsp1);
sfrm1.add(spanel1);
sfrm1.setSize(520,450);
sfrm1.setVisible(true);
System.out.println("table create");
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");
}
}
-
7/30/2019 Cafe Mgt System
42/84
}});
fileItem5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Vector data =new Vector();
Vector row=new Vector(0);
Vector colHeads=new Vector();
String str=null;
str=JOptionPane.showInputDialog(null,"Enter Date(mm/dd/yy eg. jan/01/03):","Search by Date",1);
if(str.equals("")){JOptionPane.showMessageDialog(null,"You must enter a Date!","TextBox Empty",2);}
else{
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
PreparedStatement pstmt;
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYc");
pstmt=con.prepareStatement("select * from dbase where date=? ");
pstmt.setString(1,str);
-
7/30/2019 Cafe Mgt System
43/84
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{
for(int i=2;i
-
7/30/2019 Cafe Mgt System
44/84
colHeads.addElement("Address");
colHeads.addElement("Date");
colHeads.addElement("SignIn Time");
colHeads.addElement("SignOut Time");
JFrame sfrm1=new JFrame("Search Result");
JPanel spanel1=new JPanel();
JTable stable1=new JTable(data,colHeads);
stable1.setBackground(Color.yellow);
sfrm1.setIconImage(Toolkit.getDefaultToolkit().getImage("computer.gif"));
JScrollPane sjsp1=new JScrollPane(stable1);
spanel1.add(sjsp1);
sfrm1.add(spanel1);
sfrm1.setSize(520,450);
sfrm1.setVisible(true);
System.out.println("table create");
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");
}
}
}});
fileItem6.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Vector data =new Vector();
-
7/30/2019 Cafe Mgt System
45/84
Vector row=new Vector(0);
Vector colHeads=new Vector();
String strn=JOptionPane.showInputDialog(null,"Enter Customer Name:","Search by Customer Name and
Date",1);
if(strn.equals("")){JOptionPane.showMessageDialog(null,"You must enter a name !","TextBox Empty",2);}
else{
String strd=JOptionPane.showInputDialog(null,"Enter a Date(mm/dd/yy eg.jan/01/03):","Search by Customer
Name and Date",1);
if(strd.equals("")){JOptionPane.showMessageDialog(null,"You must enter a date !","TextBox Empty",2);}
if(!strd.equals("")){
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
PreparedStatement pstmt;
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYc");
pstmt=con.prepareStatement("select * from dbase where cname=? and date=?");
pstmt.setString(1,strn);
pstmt.setString(2,strd);
ResultSet rsl =pstmt.executeQuery();
-
7/30/2019 Cafe Mgt System
46/84
while (rsl.next())
{System.out.println("in while of search1");
for(int i=2;i
-
7/30/2019 Cafe Mgt System
47/84
JFrame sfrm1=new JFrame("Search Result");
JPanel spanel1=new JPanel();
JTable stable1=new JTable(data,colHeads);
stable1.setBackground(Color.yellow);
sfrm1.setIconImage(Toolkit.getDefaultToolkit().getImage("computer.gif"));
JScrollPane sjsp1=new JScrollPane(stable1);
spanel1.add(sjsp1);
sfrm1.add(spanel1);
sfrm1.setSize(520,450);
sfrm1.setVisible(true);
System.out.println("table create");
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");}
}}
}});
//pan2.add(l3,FlowLayout.RIGHT);
//System.out.println(jsp.HEIGHT);
//frm.add(pan3,BorderLayout.NORTH);
frm.add(pan2,BorderLayout.CENTER);
System.out.println(pan2.getSize());
frm.add(pan1,BorderLayout.SOUTH);
frm.setVisible(true);
frm.setSize(800,800);
frm.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
-
7/30/2019 Cafe Mgt System
48/84
}
int i=0;
int i1=0;
public void searchnewSystem(){
sysname.add(0,"null");
sysname.add(1,"null");
statusupdate();
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYy");
PreparedStatement pstmt=con.prepareStatement("select * from status ");
//pstmt.setInt(1,0);
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{
String sysname1=rsl.getString(1);
-
7/30/2019 Cafe Mgt System
49/84
System.out.println(i);
System.out.println(sysname1);
sysname.remove(i);
sysname.add(i,sysname1);
i++;
}
l3.setText("Total number of Systems:"+i);
i=0;
}
catch(Exception e){System.out.println(e+"here");}
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYy");
PreparedStatement pstmt=con.prepareStatement("select * from status where truefalse=?");
pstmt.setInt(1,1);
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{
String sysname11=rsl.getString(1);
System.out.println(i1);
System.out.println(sysname11);
-
7/30/2019 Cafe Mgt System
50/84
i1++;
}
pstmt.close();
con.close();
l4.setText("Number of systems occupied:"+i1);
i1=0;
}
catch(Exception e){System.out.println(e+"here");}
String image="computer.gif";
ImageIcon ii=new ImageIcon(image);
label1=new JLabel(sysname.get(0),ii,JLabel.LEFT);
label2=new JLabel(sysname.get(1),ii,JLabel.LEFT);
label1.setVisible(false);
label2.setVisible(false);
// label1.setForeground(Color.gray);
pan3.removeAll();
if(!sysname.get(0).equals("null")){label1.setVisible(true);
label1.setForeground(Color.gray);
label1.setText(""+sysname.get(0)+"
"+hours1+":"+mins1+":"+secs1+"");pan3.add(label1);
label1.addMouseListener(new MouseAdapter(){
public void mouseReleased(MouseEvent Me){
if(Me.isPopupTrigger()){
pmenu1.show(Me.getComponent(),Me.getX(),Me.getY());
}
}
});
}
-
7/30/2019 Cafe Mgt System
51/84
if(!sysname.get(1).equals("null")){label2.setVisible(true);
label2.setForeground(Color.gray);
label2.setText(""+sysname.get(1)+"
"+hours2+":"+mins2+":"+secs2+"");pan3.add(label2);
label2.addMouseListener(new MouseAdapter(){
public void mouseReleased(MouseEvent Me1){
if(Me1.isPopupTrigger()){
pmenu2.show(Me1.getComponent(),Me1.getX(),Me1.getY());
}
}
});
}
System.out.println(sysname.get(1));
}
public void getcafename(){
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY0");
PreparedStatement pstmt=con.prepareStatement("select * from cafename ");
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
-
7/30/2019 Cafe Mgt System
52/84
{
str=rsl.getString(1);
chr=rsl.getString(3);
}
l6.setText(str);
l5.setText("Money charged/Hour:"+chr);
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");
}
}
public void statusupdate(){
Vector data =new Vector();
Vector row=new Vector(0);
Vector colHeads=new Vector();
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
-
7/30/2019 Cafe Mgt System
53/84
con=DriverManager.getConnection(url);
PreparedStatement pstmt;
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYc");
pstmt=con.prepareStatement("select * from dbase where status=? ");
pstmt.setInt(1,1);
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{System.out.println("in while of search1");
for(int i=1;i
-
7/30/2019 Cafe Mgt System
54/84
}
colHeads.addElement("System Name");
colHeads.addElement("Customer Name");
colHeads.addElement("Phone Number");
colHeads.addElement("Address");
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");
}
JTable table=new JTable(data,colHeads);
table.setBackground(Color.yellow);
JScrollPane jsp=new JScrollPane(table);
jsp.setSize(300,300);
pan1.add(jsp,BorderLayout.EAST);
}
public void shutdown(){
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
-
7/30/2019 Cafe Mgt System
55/84
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY0");
PreparedStatement pstmt=con.prepareStatement("delete * from status where truefalse=? or truefalse=? ");
pstmt.setInt(1,0);
pstmt.setInt(2,1);
int count=pstmt.executeUpdate();
if(count>0){System.out.println(count);
}
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");
}
System.exit(0);
}
/*
String inames;
String idates;
JTable table;
-
7/30/2019 Cafe Mgt System
56/84
JScrollPane jsp;
Vector data =new Vector();
JPanel ipan3=new JPanel();
Vector row1=new Vector(4);
Vector colHeads=new Vector();
public void SearchFrame(){
ifrm=new JFrame("search");
//JDesktopPane desk=new JDesktopPane();
JPanel ipan1=new JPanel();
ipan1.setLayout(new BorderLayout());
JPanel ipan2=new JPanel();
JLabel name=new JLabel();
name.setText("Enter the name of costumer:");
JTextField name1=new JTextField(30);
JLabel date=new JLabel();
date.setText("Choose a date(mm/dd/yy eg.jan/01/10):");
JTextField date1=new JTextField(9);
JButton search=new JButton("Search");
inames=name1.getText();
idates=date1.getText();
System.out.println(data);
System.out.println(colHeads);
//jsp.setSize(300,300);
ipan2.add(name);
ipan2.add(name1);
ipan2.add(date);
ipan2.add(date1);
ipan2.add(search);
-
7/30/2019 Cafe Mgt System
57/84
ipan1.add(ipan2,BorderLayout.CENTER);
ipan1.add(ipan3,BorderLayout.NORTH);
ifrm.add(ipan1);
ifrm.setSize(520,570);
ifrm.setVisible(true);
search.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
PreparedStatement pstmt;
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYc");
if(inames!=null&&idates!=null){
pstmt=con.prepareStatement("select * from dbase where cname=? date=? ");
pstmt.setString(1,inames);
pstmt.setString(2,idates);
}
if(inames!=null&&idates==null){
pstmt=con.prepareStatement("select * from dbase where cname=? ");
pstmt.setString(1,inames);
}
if(inames==null&&idates!=null)
{ pstmt=con.prepareStatement("select * from dbase where date=? ");
pstmt.setString(1,idates);
-
7/30/2019 Cafe Mgt System
58/84
}
else{ pstmt=con.prepareStatement("select * from dbase ");}
ResultSet rsl =pstmt.executeQuery();
int row=0;
while (rsl.next())
{System.out.println("in while of search1");
String sname=rsl.getString(1);
String cname=rsl.getString(2);
String date=rsl.getString(7);
System.out.println("in while of search2"+date);
row1.addElement(sname);
row1.addElement(cname);
row1.addElement(date);
row1.addElement("click");
//System.out.println(row1);
}
data.addElement(row1);
System.out.println("table criated");
pstmt.close();
con.close();
}
catch(Exception e2)
{System.out.println(e2+"setname");
}
//System.out.println(data);
-
7/30/2019 Cafe Mgt System
59/84
colHeads.addElement("System Name");
colHeads.addElement("Customer Name");
colHeads.addElement("Date");
colHeads.addElement("Get Details");
//System.out.println(colHeads);
table=new JTable(data,colHeads);
//System.out.println(table);
jsp=new JScrollPane(table);
jsp.setVisible(true);
ipan3.add(jsp);
}});
//desk.add(ifrm);
//frm.add(desk,BorderLayout.NORTH);
} */
public static void main(String [] args){
new dd();
}
}// HOST INTERFACE(loginform.java)
import java.util.*;
import java.sql.*;
import java.awt.*;
-
7/30/2019 Cafe Mgt System
60/84
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.*;
import javax.swing.text.html.*;
public class LoginForm implements ActionListener {
String name;
String phoneno;
String address;
JButton SUBMIT,GetTime;
JPanel p1,p2,p3,p4;
JLabel label1,label2,label3,label4,label5,label6;
JTextField text1,text2,text3;
JFrame frame;
int secs=0;
int mins=0;
int hours=0;
String cafename="";
int charge=0;
Timer t;
/** Creates a new instance of LoginForm */
public LoginForm() {
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:ClientHost";
try
{
Class.forName(driverClassName);
-
7/30/2019 Cafe Mgt System
61/84
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLYy");
PreparedStatement pstmt=con.prepareStatement("select * from status where sysname=?");
pstmt.setInt(1,1);
ResultSet rsl =pstmt.executeQuery();
while (rsl.next())
{
cafename=rsl.getString(1);
charge=rsl.getInt(2);
}
pstmt.close();
con.close();
}
catch(Exception ee){System.out.println(ee+"here");}
t=new Timer(1000,this);
-
7/30/2019 Cafe Mgt System
62/84
frame=new JFrame();
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
p4=new JPanel();
p1.setBackground(Color.yellow);
p2.setBackground(Color.yellow);
p3.setBackground(Color.yellow);
p4.setBackground(Color.yellow);
p1.setLayout(new BorderLayout());
p2.setLayout(new BorderLayout());
p3.setLayout(new GridLayout(0,2,5,5));
p4.setLayout(new BorderLayout());
label3=new JLabel();
label3.setText("New session is Started Please fill your Details above then click to SUBMIT");
label1=new JLabel();
label2=new JLabel();
label4=new JLabel();
label5=new JLabel();
label5.setText(""+"Welcome to "+cafename+"
"+" Usage charge/hour Rs. : "+charge);label5.setFont(new Font( "Verdana", Font.BOLD,30));
label6=new JLabel();
label6.setText("Experience the High Speed Internet.Do Browsing ,Downloading,Chatting,Webcam Chat
available");
label1.setText("Your Name:");
text1=new JTextField(30);
label2.setText("Your Phoneno:");
text2=new JTextField(11);
label4.setText("Your Address:");
text3=new JTextField(40);
-
7/30/2019 Cafe Mgt System
63/84
SUBMIT=new JButton("SUBMIT");
// text1.setText("hello");
actionPerformed(null);
GetTime=new JButton();
name=text1.getText();
phoneno=text2.getText();
address=text3.getText();
p1.add(p2,BorderLayout.NORTH);
p1.add(p3,BorderLayout.CENTER);
p1.add(p4,BorderLayout.SOUTH);
p4.add(p2,BorderLayout.NORTH);
p2.add(label5,BorderLayout.NORTH);
p2.add(label6,BorderLayout.CENTER);
p2.add(label3,BorderLayout.SOUTH);
p3.add(label1);
p3.add(text1);
p3.add(label2);
p3.add(text2);
p3.add(label4);
p3.add(text3);
p4.add(SUBMIT,BorderLayout.WEST);
p4.add(GetTime,BorderLayout.SOUTH);
frame.add(p1);
frame.setBackground(Color.yellow);
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600,270);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
-
7/30/2019 Cafe Mgt System
64/84
// frame.getContentPane().add(new JPanelWithBackground("Bluehills.jpeg"));
SUBMIT.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){
if(text1.getText().equals("")||text2.getText().equals("")||text3.getText().equals("")){JOptionPane.showMessageD
ialog(null,"You left some field empty !","Information",1); }
else{setDisabled();
TimeButtonDisable();
name=text1.getText();
phoneno=text2.getText();
address=text3.getText();}
}});
GetTime.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){
// t.start();
}});
}
public void setDisabled(){
text3.setEnabled(false);
text1.setEnabled(false);
text2.setEnabled(false);
SUBMIT.setEnabled(false);}
public void setEnabled(){
text3.setEnabled(true);
text1.setEnabled(true);
text2.setEnabled(true);
SUBMIT.setEnabled(true);}
-
7/30/2019 Cafe Mgt System
65/84
public void setVisible(){frame.setVisible(true);
t.start();
}
public void setInvisible(){frame.setVisible(false);
text1.setText("");
text2.setText("");
text3.setText("");
t.stop();
secs=0;
mins=0;
hours=0;
}
public void actionPerformed(ActionEvent evt){
secs ++ ;
if(secs>=59){
secs=0;
mins++;
}
if(mins>=59){
mins=0;
hours++;
}
frame.setTitle(""+hours+":"+mins+":"+secs);
if(mins==59){JOptionPane.showMessageDialog(null,"One houre is Completed !","Information",1);}
}
public void TimeButtonEnable(){
-
7/30/2019 Cafe Mgt System
66/84
GetTime.setEnabled(true);
}
public void TimeButtonDisable(){
GetTime.setEnabled(false);
}
public boolean showtimeEnabledorDisabled(){
if((GetTime.isEnabled())==true){return true;}
else
{ return false;}
}
}
//MyBeanIface.java
package session;
import javax.ejb.*;
@Remote
public interface MyBeanIface {
-
7/30/2019 Cafe Mgt System
67/84
public String stopSession();
//public void name();
//public void phoneno();
public String startSession();
public void nameofUser(String name);
public void phonenoofUser(String phoneno);
public void addressofUser(String address);
public void addtodbase();
public String SystemName(String sysname);
public int charges();
public String cafename();
}
//MyBeanImpl.java
package session;
import javax.ejb.*;
import javax.annotation.*;
import java.sql.*;
import java.util.*;
@Stateful
public class MyBeanImpl implements MyBeanIface {
String sname;
String name;
-
7/30/2019 Cafe Mgt System
68/84
String phoneno;
String address;
@Resource
SessionContext sc;
public String startSession() {
try
{ Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
String name= sname;
PreparedStatement pstmt=con.prepareStatement("SELECT * FROM status WHERE sysname=?");
pstmt.setString(1,name);
ResultSet rsl =pstmt.executeQuery();
if(rsl.next())
{
int value =rsl.getInt(2);
if(value==0){return "value is 0";}
else if(value==1){return "value is 1";}
}
else{return "not executed";}
pstmt.close();
con.close();}
catch(Exception e)
{
-
7/30/2019 Cafe Mgt System
69/84
return ""+e+"start";
}
return "last"; }
public String stopSession() {
try
{ Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
String name= sname;
PreparedStatement pstmt=con.prepareStatement("SELECT * FROM status WHERE sysname=?");
pstmt.setString(1,name);
ResultSet rsl =pstmt.executeQuery();
if (rsl.next())
{
int value =rsl.getInt(2);
if(value==0){return "value is 0";}
else if(value==1){return "value is 1";}
//return ""+value+"";
}
else{return "not executed";}
-
7/30/2019 Cafe Mgt System
70/84
pstmt.close();
con.close();}
catch(Exception e)
{
return ""+e+"stop";
}
return "last";
}
public void nameofUser(String name) {
this.name=name;
}
public void phonenoofUser(String phoneno) {
this.phoneno=phoneno;
}
public void addressofUser(String address) {
this.address=address;
}
public void addtodbase(){
Formatter fmt=new Formatter();
Formatter fmt1=new Formatter();
Calendar cal=Calendar.getInstance();
fmt1.format("%tb/%td/%ty",cal,cal,cal);
fmt.format("%tr",cal);
try
{ Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
-
7/30/2019 Cafe Mgt System
71/84
String url="jdbc:odbc:cafe";
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("INSERT INTO dbase VALUES(?,?,?,?,?,?,?,?)");
pstmt.setString(1, sname);
pstmt.setString(2,name);
pstmt.setString(3,phoneno);
pstmt.setString(4,address);
pstmt.setString(5,""+fmt+"");
pstmt.setString(6,"Working");
pstmt.setString(7,""+fmt1+"");
pstmt.setInt(8,1);
int count=pstmt.executeUpdate();
if(count==1){
pstmt.close();
con.close();}
}
catch(Exception e)
{
}
}
public String cafename(){
try
-
7/30/2019 Cafe Mgt System
72/84
{ Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("SELECT * FROM cafename ");
// pstmt.setString(1,name);
ResultSet rsl =pstmt.executeQuery();
if (rsl.next())
{
String cname=rsl.getString(1);
pstmt.close();
con.close();
return(cname);
}
else{return "not executed";}
}
catch(Exception e)
{
-
7/30/2019 Cafe Mgt System
73/84
return ""+e+"cafe";
}
}
public int charges(){
try
{ Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("SELECT * FROM cafename");
//pstmt.setString(1,name);
ResultSet rsl =pstmt.executeQuery();
if (rsl.next())
{
int crg=rsl.getInt(3);
pstmt.close();
con.close();
return(crg);
-
7/30/2019 Cafe Mgt System
74/84
}
else{return 00;}
}
catch(Exception e)
{
return 00;
}
}
public String SystemName(String sysname){
sname=sysname;
try
{ Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:cafe";
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("INSERT INTO status VALUES(?,?)");
pstmt.setString(1,sname);
pstmt.setInt(2,0);
-
7/30/2019 Cafe Mgt System
75/84
int count=pstmt.executeUpdate();
if(count>0){
pstmt.close();
con.close();
return "system added";
}
}
catch(Exception e)
{
return ""+e+"";
}
return "nothing happned";
}
}
//TestClient.java
import session.MyBeanIface;
import javax.naming.*;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
import java.sql.*;
public class TestClient {
public static void main(String args[])throws Exception, UnknownHostException{
-
7/30/2019 Cafe Mgt System
76/84
Properties p= new Properties();
p.load(new FileInputStream("jndiproperties.properties"));
InitialContext ic =new InitialContext(p);
MyBeanIface mbi=(MyBeanIface)ic.lookup("session.MyBeanIface");
String cafename=mbi.cafename();
int charges=mbi.charges();
System.out.println(cafename+" "+charges);
Connection con;
String driverClassName=("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:ClientHost";
try
{
Class.forName(driverClassName);
con=DriverManager.getConnection(url);
System.out.println("CONNECTION TO DADABASE ESTABLISHED SUCCESSFULLY");
PreparedStatement pstmt=con.prepareStatement("update status set cafename=? where sysname=?");
pstmt.setString(1,cafename);
//pstmt.setInt(2,charges);
pstmt.setInt(2,1);
int count=pstmt.executeUpdate();
System.out.println("inside inner try");
if(count>0)
{System.out.println("got cafe name");}
PreparedStatement pstmt1=con.prepareStatement("update status set charges=? where sysname=?");
-
7/30/2019 Cafe Mgt System
77/84
pstmt1.setInt(1,charges);
pstmt1.setInt(2,1);
int count1=pstmt1.executeUpdate();
if(count1>0)
{System.out.println("got charge");}
else{
System.out.println("not updated");
}
pstmt.close();
con.close();
}
catch(Exception e11)
{System.out.println(e11);
}
LoginForm info=new LoginForm();
System.out.println("hello");
InetAddress Address=InetAddress.getLocalHost();
String sysname=Address.getHostName();
String s= mbi.SystemName(sysname);
System.out.println(s);
//boolean start;
String stop;
// long mytime=mbi.showTime();
String start=mbi.startSession();
System.out.println(start);
System.out.println(info.name);
while (true){
start=mbi.startSession();
if(start.equals("value is 1")){
//info.setEnabled();
-
7/30/2019 Cafe Mgt System
78/84
info.setVisible();
String name=info.name;
String phoneno=info.phoneno;
String address=info.address;
mbi.nameofUser(name);
mbi.phonenoofUser(phoneno);
mbi.addressofUser(address);
boolean enabled=info.showtimeEnabledorDisabled();
if(enabled==false){mbi.addtodbase();
info.TimeButtonEnable();
System.out.println("name is"+info.name);
}
}
stop=mbi.stopSession();
if(stop.equals("value is 0")){
info.setInvisible();
info.setEnabled();
}
}
}
}
//jndiproperties.properties
java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFact
ory
java.naming.provider.url=iiop://localhost:4848
-
7/30/2019 Cafe Mgt System
79/84
MAJOR PROJECT
ON
CAFE MANAGEMENT SYSTEM
SUBMITTED IN FULFILLMENT OF THE
REQUIREMENT FOR THE AWARD OF THE
DEGREE OF
BACHELOR OF TECHNOLOGY
(COMPUTER SCIENCE ENGINEERING)
Submitted by: Submitted to:
Srikant Yadav Mr. Sanjay Dhaya
7252 CSE (Lect. In CSE dept.)
Final year
Ch. Devi lal memorial government Engineering collage panniwala motta Sirsa ,Haryana
-
7/30/2019 Cafe Mgt System
80/84
Screen shots :
HostClient Home Screen
-
7/30/2019 Cafe Mgt System
81/84
HostClient :
Searching customer by name:
-
7/30/2019 Cafe Mgt System
82/84
Searching customer by Date:
Shutting down the HostClient:
-
7/30/2019 Cafe Mgt System
83/84
Search result of costumer named pardeep kumar:
MS Access database working in background:
-
7/30/2019 Cafe Mgt System
84/84
Chapter 8:
Reference:
1 : The Complete Reference (java)
2 : Internet