100% found this document useful (4 votes)
5K views

Cafe Coffe Management System

The document contains Java code for a login page, main page, menu list, add menu, employee list, and add employee page. It also includes MySQL code to create a project database with tables for account, employee details, and menu. The Java code includes event handlers for buttons to login/logout, fetch and add data to tables, and exit forms.

Uploaded by

Aman Shrivastav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
5K views

Cafe Coffe Management System

The document contains Java code for a login page, main page, menu list, add menu, employee list, and add employee page. It also includes MySQL code to create a project database with tables for account, employee details, and menu. The Java code includes event handlers for buttons to login/logout, fetch and add data to tables, and exit forms.

Uploaded by

Aman Shrivastav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

JAVA CODE—

LOGIN PAGE

CODE FOR LOGIN , CLEAR AND EXIT BUTTON—


import java.sql.*;

import javax.swing.*;

public class LOGIN_PAGE extends javax.swing.JFrame

public LOGIN_PAGE() {

initComponents(); }

private void jButton2FocusGained(java.awt.event.FocusEvent evt)

String url="jdbc:mysql://localhost/project";

String user="root";
String pwd= "aman";

String n=new String(t2.getPassword());

String n2= t1.getText();

String query=("select password from account where user_id ='"+n2+"';");

try{

Connection conn= DriverManager.getConnection(url,user,pwd);

Statement stm=conn.createStatement();

ResultSet rs= stm.executeQuery(query);

if(rs.next())

if(rs.getString("password").equalsIgnoreCase(n)){

page.main(null);

this.dispose();}

else{

JOptionPane.showMessageDialog(this,"user does not exist"); }

catch(Exception e)

{ JOptionPane.showMessageDialog(this,e.getMessage()); }

private void jButton3FocusGained(java.awt.event.FocusEvent evt) {

t1.setText(null);

t2.setText(null); }

private void jButton1FocusGained(java.awt.event.FocusEvent evt) {

System.exit(0); }
MAIN PAGE—

CODE FOR “EMPLOYEE LIST” , ‘ADD EMPLOYEE’, ‘MENU LIST’ AND ‘ADD
MENU’ BUTTON—
public class page extends javax.swing.JFrame {

public page() {

initComponents();

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

Datafetch ob= new Datafetch();

ob.setVisible(true);

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

Dataenter ob= new Dataenter();

ob.setVisible(true);
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

menu ob= new menu();

ob.setVisible(true);

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

menuadd ob= new menuadd();

ob.setVisible(true);

MENU LIST--
CODE FOR ‘RETRIEVE’ AND ‘EXIT’ BUTTON—
import java.sql.*;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

import javax.swing.*;

public class menu extends javax.swing.JFrame {

public menu() {

initComponents();

private void jButton2FocusGained(java.awt.event.FocusEvent evt) {

DefaultTableModel model= (DefaultTableModel)jTable1.getModel();

String url="jdbc:mysql://localhost/project";

String user="root";

String pwd= "aman";

String query= "select * from menu;";

try

Connection conn= DriverManager.getConnection(url,user,pwd);

Statement stm=conn.createStatement();

ResultSet rs= stm.executeQuery(query);

while(rs.next())

String id=rs.getString("Item_code");

String item=rs.getString("items");
String price=rs.getString("price");

model.addRow(new Object[] {id,item,price}); }

rs.close();

stm.close(); }

catch(Exception e){

JOptionPane.showMessageDialog(this,e.getMessage()); } }

private void jButton1FocusGained(java.awt.event.FocusEvent evt) {

System.exit(0);

ADD MENU—
CODE FOR ‘ADD’ AND ‘EXIT’ BUTTON—
import javax.swing.*;

import java.sql.*;

import javax.swing.table.DefaultTableModel;

public class menuadd extends javax.swing.JFrame {

public menuadd() {

initComponents(); }

private void jButton2FocusGained(java.awt.event.FocusEvent evt) {

String url="jdbc:mysql://localhost/project";

String user="root";

String pwd= "aman";

String query="insert into menu values(?,?,?)";

String id=t1.getText();

String item=t2.getText();

String price=t3.getText();

Try {

Connection conn= DriverManager.getConnection(url,user,pwd);

PreparedStatement stm = conn.prepareCall(query);

stm.setString(1,id);

stm.setString(2,item);

stm.setString(3,price);

stm.execute();

JOptionPane.showMessageDialog(this,"One record added successfully");

t1.setText(null);

t2.setText(null);
t3.setText(null); }

catch(Exception e) {

JOptionPane.showMessageDialog(this, e) }

private void jButton1FocusGained(java.awt.event.FocusEvent evt) {

System.exit(0);

EMPLOYEE LIST—
CODE FOR ‘FETCH’ AND ‘EXIT’ BUTTON—
Import java.sql.*;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

import javax.swing.*;

public class Datafetch extends javax.swing.JFrame {

public Datafetch() {

initComponents();

} private void jButton2FocusGained(java.awt.event.FocusEvent evt) {

DefaultTableModel model= (DefaultTableModel)jTable1.getModel();

String url="jdbc:mysql://localhost/project";

String user="root";

String pwd= "aman";

String query= "select * from employee_details;";

Try {

Connection conn= DriverManager.getConnection(url,user,pwd);

Statement stm=conn.createStatement();

ResultSet rs= stm.executeQuery(query);

while(rs.next()) {

String id=rs.getString("ID");

String name=rs.getString("name");

String mobile_no=rs.getString("mobile_no");

String address=rs.getString("address");

String gender=rs.getString("gender");

String salary=rs.getString("salary");
String post=rs.getString("post");

model.addRow(new Object[] {id,name,mobile_no,address,gender,salary,post}); }

rs.close();

stm.close(); }

catch(Exception e){

JOptionPane.showMessageDialog(this,e.getMessage()); } }

private void jButton3FocusGained(java.awt.event.FocusEvent evt) {

System.exit(0); }

ADD EMPLOYEE PAGE—


CODE FOR ‘ADD’ AND ‘EXIT’ BUTTON—
import javax.swing.*;

import java.sql.*;

import javax.swing.table.DefaultTableModel;

public class Dataenter extends javax.swing.JFrame {

public Dataenter() {

initComponents();

} private void jButton5FocusGained(java.awt.event.FocusEvent evt) {

String url="jdbc:mysql://localhost/project";

String user="root";

String pwd= "aman";

String query="insert into employee_details values(?,?,?,?,?,?,?)";

String id=t1.getText();

String name=t2.getText();

String mob=t3.getText();

String add=t4.getText();

String gen=t5.getText();

String salary=t6.getText();

String post=t7.getText();

try

Connection conn= DriverManager.getConnection(url,user,pwd);

PreparedStatement stm = conn.prepareCall(query);

stm.setString(1,id);

stm.setString(2,name);
stm.setString(3,mob);

stm.setString(4,add);

stm.setString(5,gen);

stm.setString(6,salary);

stm.setString(7,post);

stm.execute();

JOptionPane.showMessageDialog(this,"One record added successfully");

t1.setText(null);

t2.setText(null);

t3.setText(null);

t4.setText(null);

t5.setText(null);

t6.setText(null);

t7.setText(null);

catch(Exception e)

JOptionPane.showMessageDialog(this, “something went wrong”);

}
MYSQL CODE—
CODE FOR NEW DATABASE—
Create database project;

CODE FOR TABLE ACCOUNT—

Create table account

( user_id varchar(50) primary key,

Password varchar(100)

);

CODE FOR TABLE EMPLOYEE_DETAILS—


Create table Employee_Details

( id varchar(10) primary key,

Name varchar(50) ,

Mobile_no varchar(10),

Address varchar(200),

Gender char(1),

Salary int,

Post varchar(50)

);

CODE FOR TABLE MENU—

Create table Menu

( Item_code varchar(10) primary key,

Items varchar(100) ,

Price int

);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy