Credit Management System Project in Java
Note:
it doe not contain usage of database
Background:
This mini project helped us a lot. Working in a group made us come up with different idea’s which further helped us to get a better understanding of java and its application’s. This program was mainly created to make the management in canteen easier for the customers as well as the people managing the canteen. Credit management system has the ability to create a food menu items, create desktop applications that will generate orders, calculate the bill by adding the prices of the things ordered and also to keep record of the unpaid bills. In this way it is easy to manage and more beneficial. This management system will not only help the owner of the canteen to prevent any loss but also the customers who run out of low payment.
Why we choose this topic?
The conventional system of Credit Billing is not so effective; Canteen Owners have to note everything on a book. When, the students comes with money, the canteen owner has to turn the thousand pages notebook to find the name of the student, making the work very inefficient to both the worker as well as the customer. Hence, the conventional Credit Management System is uneconomical, high chances of losing data and is a lengthy process overall. In order to solve this lengthy process and loss of data, a window based computerized system is essential. This proposed Credit Management System project overcomes all these drawbacks with the features aforementioned. It is beneficial to both consumers and the canteen owners.
Aim:
Using Object-Oriented Programming Concepts and API Features available in java programming language to create a Mini- Project (credit management system).
Objective:
The main objective of this project is to develop a trusting relationship with the customers so that the business outcomes are achieved and profits are increased. Safeguarding customer risk, settling outstanding balances and improving cash flow are the main objectives of this project. A well-designed system which makes not only the management team’s work easier and more effective (grab more customers) but also the customers (paying and asking credit). A new software system to modernize the Credit management procedure is required. This Credit Management system project would replace the existing traditional type of Credit management system ensuring security, ease and comfort to customers as well as the owners. It meets the current user demands, and new features can be easily integrated into the system in future as per users requirement
Code Explaination:
It contains two packages :
1.Backend(1 class)
2.Default(7 classes)
The backend package stores the details of the customer and verifies it during login process
Code Snippet of backend package: verifiaction Class
package backend;
public class verifiaction
{
public static int setId;
public static int sum;
static String Pas;
public static String name="user";
public static int phone;
public static String gender;
public static String Course;
public boolean verify(int x, String y)
{
String Password = "123";
int id=123;
if( x== id && y.equals(Password) || x==setId && y.equals(Pas))
{
return true;
}
else
{
return false;
}
}
public void store(String n, int P,int id,String pa,String gen,String course)
{
Pas=pa;
setId=id;
name=n;
phone = P;
gender =gen;
Course = course;
System.out.println(name+ Pas + setId + phone +gender+course);
}
public String name()
{
return name;
}
public void total(int x, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11,
int x12, int x13, int x14, int x15, int x16, int x17, int x18, int x19)
{
x = x*100;
x1=x1*90;
x2=x2*30;
x3=x3*30;
x4=x4*60;
sum=(x1+x2+x3+x4+x5);
x5=x5*50;
x6=x6*50;
x7 = x7*40;
x8=x8*30;
x9=x9*25;
sum= sum + (x5+x6+x7+x8+x9+x10);
x10=x10*30;
x11=x11*20;
x12=x12*50;
x13=x13*60;
x14=x14*70;
sum= sum+(x10+x11+x12+x13+x14);
x15=20*x15;
x16=3*x16;
x17=x17*25;
x18=x18*25;
x19=x19*35;
sum=sum+(x15+x16+x17+x18+x19);
}
}
package backend;
public class verifiaction
{
public static int setId;
public static int sum;
static String Pas;
public static String name="user";
public static int phone;
public static String gender;
public static String Course;
public boolean verify(int x, String y)
{
String Password = "123";
int id=123;
if( x== id && y.equals(Password) || x==setId && y.equals(Pas))
{
return true;
}
else
{
return false;
}
}
public void store(String n, int P,int id,String pa,String gen,String course)
{
Pas=pa;
setId=id;
name=n;
phone = P;
gender =gen;
Course = course;
System.out.println(name+ Pas + setId + phone +gender+course);
}
public String name()
{
return name;
}
public void total(int x, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11,
int x12, int x13, int x14, int x15, int x16, int x17, int x18, int x19)
{
x = x*100;
x1=x1*90;
x2=x2*30;
x3=x3*30;
x4=x4*60;
sum=(x1+x2+x3+x4+x5);
x5=x5*50;
x6=x6*50;
x7 = x7*40;
x8=x8*30;
x9=x9*25;
sum= sum + (x5+x6+x7+x8+x9+x10);
x10=x10*30;
x11=x11*20;
x12=x12*50;
x13=x13*60;
x14=x14*70;
sum= sum+(x10+x11+x12+x13+x14);
x15=20*x15;
x16=3*x16;
x17=x17*25;
x18=x18*25;
x19=x19*35;
sum=sum+(x15+x16+x17+x18+x19);
}
}
package backend;
public class verifiaction
{
public static int setId;
public static int sum;
static String Pas;
public static String name="user";
public static int phone;
public static String gender;
public static String Course;
public boolean verify(int x, String y)
{
String Password = "123";
int id=123;
if( x== id && y.equals(Password) || x==setId && y.equals(Pas))
{
return true;
}
else
{
return false;
}
}
public void store(String n, int P,int id,String pa,String gen,String course)
{
Pas=pa;
setId=id;
name=n;
phone = P;
gender =gen;
Course = course;
System.out.println(name+ Pas + setId + phone +gender+course);
}
public String name()
{
return name;
}
public void total(int x, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9, int x10, int x11,
int x12, int x13, int x14, int x15, int x16, int x17, int x18, int x19)
{
x = x*100;
x1=x1*90;
x2=x2*30;
x3=x3*30;
x4=x4*60;
sum=(x1+x2+x3+x4+x5);
x5=x5*50;
x6=x6*50;
x7 = x7*40;
x8=x8*30;
x9=x9*25;
sum= sum + (x5+x6+x7+x8+x9+x10);
x10=x10*30;
x11=x11*20;
x12=x12*50;
x13=x13*60;
x14=x14*70;
sum= sum+(x10+x11+x12+x13+x14);
x15=20*x15;
x16=3*x16;
x17=x17*25;
x18=x18*25;
x19=x19*35;
sum=sum+(x15+x16+x17+x18+x19);
}
}
The default package has 7 classes used for different purposes
Code Snippet of default package: Project Class
public class Project {
public static void main(String[] args)
{
Login f = new Login();
f.Register();
}
}
Code Snippet of default package: Login Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import backend.verifiaction;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel C = new JPanel();
String password;
int userId;
JButton log,Sig;
JTextField uid;
JPasswordField pw;
Login()
{
setVisible(true);
setTitle("Login");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,700,400);
setContentPane(C);
C.setLayout(null);
}
public void Register()
{
ImageIcon Img = new ImageIcon(this.getClass().getResource("logo.png"));;
/*Initilazing Components required to make the
login form */
JPanel c = new JPanel();
c.setLayout(null);
JLabel logoI = new JLabel("");
JLabel Cst = new JLabel("CST");
JLabel top = new JLabel("CREDIT MANAGEMENT SYSTEM ");
JLabel id = new JLabel("Student Id:");
JLabel pas= new JLabel("Password:");
JLabel Fa = new JLabel("No Account? ");
log = new JButton("Login");
Sig = new JButton("Signup");
uid = new JTextField(10);
pw = new JPasswordField(10);
/*Seting the size and distance of the components*/
c.setBounds(0, 0, 250, 360);
logoI.setBounds(35, 0, 150, 147);
Cst.setBounds(425, 0, 140, 65);
top.setBounds(260, 40, 406, 64);
id.setBounds(300, 175, 100, 30);
pas.setBounds(300, 230, 100, 30);
Fa.setBounds(320, 310, 120, 40);
log.setBounds(440, 275, 90, 25);
Sig.setBounds(440, 320, 90, 25);
uid.setBounds(430, 175, 170, 30);
pw.setBounds(430, 228, 170, 32);
/*Adding Design to the Components*/
/*Changing font-size of the labels*/
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font f2 = new Font("Times New Roman", Font.PLAIN, 20);
logoI.setIcon(Img);
Cst.setFont(F1);
top.setFont(F1);
id.setFont(f2);
pas.setFont(f2);
Fa.setFont(f2);
log.setFont(f2);
Sig.setFont(f2);
c.setBackground(Color.BLUE);
Cst.setForeground(Color.BLUE);
top.setForeground(Color.BLUE);
id.setForeground(Color.BLUE);
pas.setForeground(Color.BLUE);
Fa.setForeground(Color.BLUE);
log.setBackground(Color.BLUE);
Sig.setBackground(Color.BLUE);
/*Adding components to the panel*/
c.add(logoI);
C.add(c);
C.add(Cst);
C.add(top);
C.add(id);
C.add(pas);
C.add(Fa);
C.add(log);
C.add(Sig);
C.add(uid);
C.add(pw);
/*Adding action listiner*/
log.addActionListener(this);
Sig.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==log)
{
try
{
userId = Integer.parseInt(uid.getText());
password = String.valueOf(pw.getPassword());
verifiaction f = new verifiaction();
boolean y = f.verify(userId, password);
if(y==true)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
else
{
JOptionPane.showInternalMessageDialog(null, "Usename or Password does not match","login Error",JOptionPane.ERROR_MESSAGE);
}
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Invalid Login","login Error",JOptionPane.ERROR_MESSAGE);
}
}
if(e.getSource()==Sig)
{
setVisible(false);
register f = new register();
f.RF();
}
}
}
Code Snippet of default package: register Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import backend.verifiaction;
public class register extends JFrame implements ActionListener
{
JPanel C = new JPanel();
JTextField tf1,tf2,tf3;
private JPasswordField pas;
JComboBox Cou ;
JRadioButton jb1,jb2;
JLabel er;
String[] course = new String[] {"Architecture","Civil","Electrical","Electronics and Communication","Information Technology","Geology","Instrumentation and control","Masters"};
register()
{
setVisible(true);
setTitle("Register");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,600,600);
setContentPane(C);
C.setLayout(null);
}
void RF()
{
/*Declaring variables*/
JPanel p = new JPanel();
JLabel JL1 = new JLabel("REGISTRATION FORM");
JLabel JL2= new JLabel("Name:");
JLabel JL3 = new JLabel("Phone Number");
JLabel JL4= new JLabel("Gender");
JLabel JL5 = new JLabel("Course");
JLabel JL6 = new JLabel("Student ID");
JLabel JL7= new JLabel("Password");
tf1 = new JTextField(15);
tf2 = new JTextField(15);
tf3= new JTextField(15);
pas=new JPasswordField(15);
jb1 = new JRadioButton("Male");
jb2 = new JRadioButton("Female");
Cou = new JComboBox(course);
JButton Reg= new JButton("Register");
er = new JLabel();
p.setLayout(null);
/*Making button group*/
ButtonGroup gen = new ButtonGroup();
gen.add(jb1);
gen.add(jb2);
/*Displaying the components Size*/
p.setBounds(0, 0, 585, 80);
JL1.setBounds(145, 10, 290, 50);
JL2.setBounds(30, 95, 95, 40);
JL3.setBounds(30, 145, 110, 40);
JL4.setBounds(30,195,95,40);
JL5.setBounds(30, 245, 95, 40);
JL6.setBounds(30, 295, 95, 40);
JL7.setBounds(30, 345, 95, 40);
tf1.setBounds(155, 95, 200, 25);
tf2.setBounds(155, 145, 200, 25);
jb1.setBounds(155, 200, 75, 25);
jb2.setBounds(245,200,75,25);
Cou.setBounds(155, 250, 200, 20);
tf3.setBounds(155,300,200,25);
pas.setBounds(155, 350,200, 25);
Reg.setBounds(155, 410, 130, 40);
er.setBounds(140, 450, 225, 40);
/*Customization of the components*/
p.setBackground(Color.blue);
Cou.setBackground(Color.blue);
Reg.setBackground(Color.blue);
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font F2 = new Font("Arial",Font.PLAIN,15);
JL1.setFont(F1);
JL2.setFont(F2);
JL3.setFont(F2);
JL4.setFont(F2);
JL5.setFont(F2);
JL6.setFont(F2);
JL7.setFont(F2);
er.setFont(F2);
er.setForeground(Color.BLUE);
/* Adding components to the panel*/
p.add(JL1);
C.add(JL2);
C.add(JL3);
C.add(JL4);
C.add(JL5);
C.add(JL6);
C.add(JL7);
C.add(tf1);
C.add(tf2);
C.add(p);
C.add(jb1);
C.add(jb2);
C.add(Cou);
C.add(tf3);
C.add(pas);
C.add(Reg);
C.add(er);
Reg.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String name = tf1.getText();
String cour = String.valueOf(Cou.getSelectedItem());
int ph,sd;
String ge;
String pass = String.valueOf(pas.getPassword());
if(pass.isEmpty()==false)
{
if(jb1.isSelected()==true)
{
ge = "Male";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
if(ph/100000000 > 1 || ph/10000000!=1 && ph/10000000!=7 || ph/1000000!=17 && ph/1000000 !=77 )
{
throw new CustommadeException();
}
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else if(jb2.isSelected()==true)
{
ge="Female";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else
{
er.setText("Please fill all the correctly");
}
}
else
{
er.setText("Please fill the form correctly");
}
}
private void Rco()
{
JOptionPane.showInternalMessageDialog(null, "Thanks for registering","Registered",JOptionPane.INFORMATION_MESSAGE);
setVisible(false);
Login f = new Login();
f.Register();
}
}
Code Snippet of default package: FirstBody Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import backend.verifiaction;
public class FirstBody extends JFrame implements ActionListener
{
JPanel C = new JPanel();
verifiaction y = new verifiaction ();
String s = y.name();
JButton B1,B2,B3,b4;
FirstBody()
{
setVisible(true);
setTitle("WELCOME");
setBounds(0,0,1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
C = new JPanel();
setContentPane(C);
C.setLayout(null);
}
public void body()
{
JPanel p = new JPanel();
JLabel LB1 = new JLabel("CST ");
JLabel LB2 = new JLabel("CANTEEN CREDIT MANAGEMENT SYSTEM");
JLabel LB3 = new JLabel("KUZU ZANGPO "+ s.toUpperCase());
JLabel LB4 = new JLabel("");
B1 = new JButton("ASK CREDIT");
B2 = new JButton("PAY CREDIT");
B3 = new JButton("check Details");
b4=new JButton("LogOut");
ImageIcon JPG = new ImageIcon(this.getClass().getResource("/w.jpg"));
LB4.setIcon(JPG);
p.setLayout(null);
Font f = new Font("Times New Roman", Font.BOLD, 40);
p.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB2.setForeground(Color.GREEN);
LB3.setForeground(Color.GREEN);
b4.setForeground(Color.GREEN);
LB1.setFont(f);
LB2.setFont(f);
LB3.setFont(new Font("Vladimir Script", Font.BOLD, 25));
b4.setBackground(Color.BLUE);
p.setBounds(0, 0, 1000, 660);
LB1.setBounds(425, 10, 330, 75);
LB2.setBounds(45, 65, 945, 75);
LB3.setBounds(190, 121, 510, 75);
B1.setBounds(100, 480, 120, 120);
B2.setBounds(400, 480, 120, 120);
B3.setBounds(700, 480, 120, 120);
LB4.setBounds(90, 195, 785, 245);
b4.setBounds(0,5,90,20);
p.add(LB1);
p.add(LB2);
p.add(LB3);
p.add(LB4);
p.add(b4);
p.add(B1);
p.add(B2);
p.add(B3);
C.add(p);
B1.addActionListener(this);
b4.addActionListener(this);
B3.addActionListener(this);
B2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b4)
{
setVisible(false);
Login f = new Login();
f.Register();
}
if(e.getSource()==B1)
{
setVisible(false);
AskCredit f = new AskCredit();
f.CreditAsked();
}
if(e.getSource()==B3)
{
setVisible(false);
showdetails f = new showdetails();
f.userd();
}
if(e.getSource()==B2)
{
AskCredit f = new AskCredit();
try
{
f.Payed();
setVisible(false);
}
catch(Exception e1)
{
f.setVisible(false);
JOptionPane.showInternalMessageDialog(null, "Congratlation you dont have Credit","No credit",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: AskCredit Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: showdetails Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
public class Project {
public static void main(String[] args)
{
Login f = new Login();
f.Register();
}
}
public class Project {
public static void main(String[] args)
{
Login f = new Login();
f.Register();
}
}
Code Snippet of default package: Login Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import backend.verifiaction;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel C = new JPanel();
String password;
int userId;
JButton log,Sig;
JTextField uid;
JPasswordField pw;
Login()
{
setVisible(true);
setTitle("Login");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,700,400);
setContentPane(C);
C.setLayout(null);
}
public void Register()
{
ImageIcon Img = new ImageIcon(this.getClass().getResource("logo.png"));;
/*Initilazing Components required to make the
login form */
JPanel c = new JPanel();
c.setLayout(null);
JLabel logoI = new JLabel("");
JLabel Cst = new JLabel("CST");
JLabel top = new JLabel("CREDIT MANAGEMENT SYSTEM ");
JLabel id = new JLabel("Student Id:");
JLabel pas= new JLabel("Password:");
JLabel Fa = new JLabel("No Account? ");
log = new JButton("Login");
Sig = new JButton("Signup");
uid = new JTextField(10);
pw = new JPasswordField(10);
/*Seting the size and distance of the components*/
c.setBounds(0, 0, 250, 360);
logoI.setBounds(35, 0, 150, 147);
Cst.setBounds(425, 0, 140, 65);
top.setBounds(260, 40, 406, 64);
id.setBounds(300, 175, 100, 30);
pas.setBounds(300, 230, 100, 30);
Fa.setBounds(320, 310, 120, 40);
log.setBounds(440, 275, 90, 25);
Sig.setBounds(440, 320, 90, 25);
uid.setBounds(430, 175, 170, 30);
pw.setBounds(430, 228, 170, 32);
/*Adding Design to the Components*/
/*Changing font-size of the labels*/
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font f2 = new Font("Times New Roman", Font.PLAIN, 20);
logoI.setIcon(Img);
Cst.setFont(F1);
top.setFont(F1);
id.setFont(f2);
pas.setFont(f2);
Fa.setFont(f2);
log.setFont(f2);
Sig.setFont(f2);
c.setBackground(Color.BLUE);
Cst.setForeground(Color.BLUE);
top.setForeground(Color.BLUE);
id.setForeground(Color.BLUE);
pas.setForeground(Color.BLUE);
Fa.setForeground(Color.BLUE);
log.setBackground(Color.BLUE);
Sig.setBackground(Color.BLUE);
/*Adding components to the panel*/
c.add(logoI);
C.add(c);
C.add(Cst);
C.add(top);
C.add(id);
C.add(pas);
C.add(Fa);
C.add(log);
C.add(Sig);
C.add(uid);
C.add(pw);
/*Adding action listiner*/
log.addActionListener(this);
Sig.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==log)
{
try
{
userId = Integer.parseInt(uid.getText());
password = String.valueOf(pw.getPassword());
verifiaction f = new verifiaction();
boolean y = f.verify(userId, password);
if(y==true)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
else
{
JOptionPane.showInternalMessageDialog(null, "Usename or Password does not match","login Error",JOptionPane.ERROR_MESSAGE);
}
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Invalid Login","login Error",JOptionPane.ERROR_MESSAGE);
}
}
if(e.getSource()==Sig)
{
setVisible(false);
register f = new register();
f.RF();
}
}
}
Code Snippet of default package: register Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import backend.verifiaction;
public class register extends JFrame implements ActionListener
{
JPanel C = new JPanel();
JTextField tf1,tf2,tf3;
private JPasswordField pas;
JComboBox Cou ;
JRadioButton jb1,jb2;
JLabel er;
String[] course = new String[] {"Architecture","Civil","Electrical","Electronics and Communication","Information Technology","Geology","Instrumentation and control","Masters"};
register()
{
setVisible(true);
setTitle("Register");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,600,600);
setContentPane(C);
C.setLayout(null);
}
void RF()
{
/*Declaring variables*/
JPanel p = new JPanel();
JLabel JL1 = new JLabel("REGISTRATION FORM");
JLabel JL2= new JLabel("Name:");
JLabel JL3 = new JLabel("Phone Number");
JLabel JL4= new JLabel("Gender");
JLabel JL5 = new JLabel("Course");
JLabel JL6 = new JLabel("Student ID");
JLabel JL7= new JLabel("Password");
tf1 = new JTextField(15);
tf2 = new JTextField(15);
tf3= new JTextField(15);
pas=new JPasswordField(15);
jb1 = new JRadioButton("Male");
jb2 = new JRadioButton("Female");
Cou = new JComboBox(course);
JButton Reg= new JButton("Register");
er = new JLabel();
p.setLayout(null);
/*Making button group*/
ButtonGroup gen = new ButtonGroup();
gen.add(jb1);
gen.add(jb2);
/*Displaying the components Size*/
p.setBounds(0, 0, 585, 80);
JL1.setBounds(145, 10, 290, 50);
JL2.setBounds(30, 95, 95, 40);
JL3.setBounds(30, 145, 110, 40);
JL4.setBounds(30,195,95,40);
JL5.setBounds(30, 245, 95, 40);
JL6.setBounds(30, 295, 95, 40);
JL7.setBounds(30, 345, 95, 40);
tf1.setBounds(155, 95, 200, 25);
tf2.setBounds(155, 145, 200, 25);
jb1.setBounds(155, 200, 75, 25);
jb2.setBounds(245,200,75,25);
Cou.setBounds(155, 250, 200, 20);
tf3.setBounds(155,300,200,25);
pas.setBounds(155, 350,200, 25);
Reg.setBounds(155, 410, 130, 40);
er.setBounds(140, 450, 225, 40);
/*Customization of the components*/
p.setBackground(Color.blue);
Cou.setBackground(Color.blue);
Reg.setBackground(Color.blue);
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font F2 = new Font("Arial",Font.PLAIN,15);
JL1.setFont(F1);
JL2.setFont(F2);
JL3.setFont(F2);
JL4.setFont(F2);
JL5.setFont(F2);
JL6.setFont(F2);
JL7.setFont(F2);
er.setFont(F2);
er.setForeground(Color.BLUE);
/* Adding components to the panel*/
p.add(JL1);
C.add(JL2);
C.add(JL3);
C.add(JL4);
C.add(JL5);
C.add(JL6);
C.add(JL7);
C.add(tf1);
C.add(tf2);
C.add(p);
C.add(jb1);
C.add(jb2);
C.add(Cou);
C.add(tf3);
C.add(pas);
C.add(Reg);
C.add(er);
Reg.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String name = tf1.getText();
String cour = String.valueOf(Cou.getSelectedItem());
int ph,sd;
String ge;
String pass = String.valueOf(pas.getPassword());
if(pass.isEmpty()==false)
{
if(jb1.isSelected()==true)
{
ge = "Male";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
if(ph/100000000 > 1 || ph/10000000!=1 && ph/10000000!=7 || ph/1000000!=17 && ph/1000000 !=77 )
{
throw new CustommadeException();
}
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else if(jb2.isSelected()==true)
{
ge="Female";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else
{
er.setText("Please fill all the correctly");
}
}
else
{
er.setText("Please fill the form correctly");
}
}
private void Rco()
{
JOptionPane.showInternalMessageDialog(null, "Thanks for registering","Registered",JOptionPane.INFORMATION_MESSAGE);
setVisible(false);
Login f = new Login();
f.Register();
}
}
Code Snippet of default package: FirstBody Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import backend.verifiaction;
public class FirstBody extends JFrame implements ActionListener
{
JPanel C = new JPanel();
verifiaction y = new verifiaction ();
String s = y.name();
JButton B1,B2,B3,b4;
FirstBody()
{
setVisible(true);
setTitle("WELCOME");
setBounds(0,0,1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
C = new JPanel();
setContentPane(C);
C.setLayout(null);
}
public void body()
{
JPanel p = new JPanel();
JLabel LB1 = new JLabel("CST ");
JLabel LB2 = new JLabel("CANTEEN CREDIT MANAGEMENT SYSTEM");
JLabel LB3 = new JLabel("KUZU ZANGPO "+ s.toUpperCase());
JLabel LB4 = new JLabel("");
B1 = new JButton("ASK CREDIT");
B2 = new JButton("PAY CREDIT");
B3 = new JButton("check Details");
b4=new JButton("LogOut");
ImageIcon JPG = new ImageIcon(this.getClass().getResource("/w.jpg"));
LB4.setIcon(JPG);
p.setLayout(null);
Font f = new Font("Times New Roman", Font.BOLD, 40);
p.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB2.setForeground(Color.GREEN);
LB3.setForeground(Color.GREEN);
b4.setForeground(Color.GREEN);
LB1.setFont(f);
LB2.setFont(f);
LB3.setFont(new Font("Vladimir Script", Font.BOLD, 25));
b4.setBackground(Color.BLUE);
p.setBounds(0, 0, 1000, 660);
LB1.setBounds(425, 10, 330, 75);
LB2.setBounds(45, 65, 945, 75);
LB3.setBounds(190, 121, 510, 75);
B1.setBounds(100, 480, 120, 120);
B2.setBounds(400, 480, 120, 120);
B3.setBounds(700, 480, 120, 120);
LB4.setBounds(90, 195, 785, 245);
b4.setBounds(0,5,90,20);
p.add(LB1);
p.add(LB2);
p.add(LB3);
p.add(LB4);
p.add(b4);
p.add(B1);
p.add(B2);
p.add(B3);
C.add(p);
B1.addActionListener(this);
b4.addActionListener(this);
B3.addActionListener(this);
B2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b4)
{
setVisible(false);
Login f = new Login();
f.Register();
}
if(e.getSource()==B1)
{
setVisible(false);
AskCredit f = new AskCredit();
f.CreditAsked();
}
if(e.getSource()==B3)
{
setVisible(false);
showdetails f = new showdetails();
f.userd();
}
if(e.getSource()==B2)
{
AskCredit f = new AskCredit();
try
{
f.Payed();
setVisible(false);
}
catch(Exception e1)
{
f.setVisible(false);
JOptionPane.showInternalMessageDialog(null, "Congratlation you dont have Credit","No credit",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: AskCredit Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: showdetails Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import backend.verifiaction;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel C = new JPanel();
String password;
int userId;
JButton log,Sig;
JTextField uid;
JPasswordField pw;
Login()
{
setVisible(true);
setTitle("Login");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,700,400);
setContentPane(C);
C.setLayout(null);
}
public void Register()
{
ImageIcon Img = new ImageIcon(this.getClass().getResource("logo.png"));;
/*Initilazing Components required to make the
login form */
JPanel c = new JPanel();
c.setLayout(null);
JLabel logoI = new JLabel("");
JLabel Cst = new JLabel("CST");
JLabel top = new JLabel("CREDIT MANAGEMENT SYSTEM ");
JLabel id = new JLabel("Student Id:");
JLabel pas= new JLabel("Password:");
JLabel Fa = new JLabel("No Account? ");
log = new JButton("Login");
Sig = new JButton("Signup");
uid = new JTextField(10);
pw = new JPasswordField(10);
/*Seting the size and distance of the components*/
c.setBounds(0, 0, 250, 360);
logoI.setBounds(35, 0, 150, 147);
Cst.setBounds(425, 0, 140, 65);
top.setBounds(260, 40, 406, 64);
id.setBounds(300, 175, 100, 30);
pas.setBounds(300, 230, 100, 30);
Fa.setBounds(320, 310, 120, 40);
log.setBounds(440, 275, 90, 25);
Sig.setBounds(440, 320, 90, 25);
uid.setBounds(430, 175, 170, 30);
pw.setBounds(430, 228, 170, 32);
/*Adding Design to the Components*/
/*Changing font-size of the labels*/
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font f2 = new Font("Times New Roman", Font.PLAIN, 20);
logoI.setIcon(Img);
Cst.setFont(F1);
top.setFont(F1);
id.setFont(f2);
pas.setFont(f2);
Fa.setFont(f2);
log.setFont(f2);
Sig.setFont(f2);
c.setBackground(Color.BLUE);
Cst.setForeground(Color.BLUE);
top.setForeground(Color.BLUE);
id.setForeground(Color.BLUE);
pas.setForeground(Color.BLUE);
Fa.setForeground(Color.BLUE);
log.setBackground(Color.BLUE);
Sig.setBackground(Color.BLUE);
/*Adding components to the panel*/
c.add(logoI);
C.add(c);
C.add(Cst);
C.add(top);
C.add(id);
C.add(pas);
C.add(Fa);
C.add(log);
C.add(Sig);
C.add(uid);
C.add(pw);
/*Adding action listiner*/
log.addActionListener(this);
Sig.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==log)
{
try
{
userId = Integer.parseInt(uid.getText());
password = String.valueOf(pw.getPassword());
verifiaction f = new verifiaction();
boolean y = f.verify(userId, password);
if(y==true)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
else
{
JOptionPane.showInternalMessageDialog(null, "Usename or Password does not match","login Error",JOptionPane.ERROR_MESSAGE);
}
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Invalid Login","login Error",JOptionPane.ERROR_MESSAGE);
}
}
if(e.getSource()==Sig)
{
setVisible(false);
register f = new register();
f.RF();
}
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import backend.verifiaction;
import javax.swing.*;
public class Login extends JFrame implements ActionListener
{
JPanel C = new JPanel();
String password;
int userId;
JButton log,Sig;
JTextField uid;
JPasswordField pw;
Login()
{
setVisible(true);
setTitle("Login");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,700,400);
setContentPane(C);
C.setLayout(null);
}
public void Register()
{
ImageIcon Img = new ImageIcon(this.getClass().getResource("logo.png"));;
/*Initilazing Components required to make the
login form */
JPanel c = new JPanel();
c.setLayout(null);
JLabel logoI = new JLabel("");
JLabel Cst = new JLabel("CST");
JLabel top = new JLabel("CREDIT MANAGEMENT SYSTEM ");
JLabel id = new JLabel("Student Id:");
JLabel pas= new JLabel("Password:");
JLabel Fa = new JLabel("No Account? ");
log = new JButton("Login");
Sig = new JButton("Signup");
uid = new JTextField(10);
pw = new JPasswordField(10);
/*Seting the size and distance of the components*/
c.setBounds(0, 0, 250, 360);
logoI.setBounds(35, 0, 150, 147);
Cst.setBounds(425, 0, 140, 65);
top.setBounds(260, 40, 406, 64);
id.setBounds(300, 175, 100, 30);
pas.setBounds(300, 230, 100, 30);
Fa.setBounds(320, 310, 120, 40);
log.setBounds(440, 275, 90, 25);
Sig.setBounds(440, 320, 90, 25);
uid.setBounds(430, 175, 170, 30);
pw.setBounds(430, 228, 170, 32);
/*Adding Design to the Components*/
/*Changing font-size of the labels*/
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font f2 = new Font("Times New Roman", Font.PLAIN, 20);
logoI.setIcon(Img);
Cst.setFont(F1);
top.setFont(F1);
id.setFont(f2);
pas.setFont(f2);
Fa.setFont(f2);
log.setFont(f2);
Sig.setFont(f2);
c.setBackground(Color.BLUE);
Cst.setForeground(Color.BLUE);
top.setForeground(Color.BLUE);
id.setForeground(Color.BLUE);
pas.setForeground(Color.BLUE);
Fa.setForeground(Color.BLUE);
log.setBackground(Color.BLUE);
Sig.setBackground(Color.BLUE);
/*Adding components to the panel*/
c.add(logoI);
C.add(c);
C.add(Cst);
C.add(top);
C.add(id);
C.add(pas);
C.add(Fa);
C.add(log);
C.add(Sig);
C.add(uid);
C.add(pw);
/*Adding action listiner*/
log.addActionListener(this);
Sig.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==log)
{
try
{
userId = Integer.parseInt(uid.getText());
password = String.valueOf(pw.getPassword());
verifiaction f = new verifiaction();
boolean y = f.verify(userId, password);
if(y==true)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
else
{
JOptionPane.showInternalMessageDialog(null, "Usename or Password does not match","login Error",JOptionPane.ERROR_MESSAGE);
}
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Invalid Login","login Error",JOptionPane.ERROR_MESSAGE);
}
}
if(e.getSource()==Sig)
{
setVisible(false);
register f = new register();
f.RF();
}
}
}
Code Snippet of default package: register Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import backend.verifiaction;
public class register extends JFrame implements ActionListener
{
JPanel C = new JPanel();
JTextField tf1,tf2,tf3;
private JPasswordField pas;
JComboBox Cou ;
JRadioButton jb1,jb2;
JLabel er;
String[] course = new String[] {"Architecture","Civil","Electrical","Electronics and Communication","Information Technology","Geology","Instrumentation and control","Masters"};
register()
{
setVisible(true);
setTitle("Register");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,600,600);
setContentPane(C);
C.setLayout(null);
}
void RF()
{
/*Declaring variables*/
JPanel p = new JPanel();
JLabel JL1 = new JLabel("REGISTRATION FORM");
JLabel JL2= new JLabel("Name:");
JLabel JL3 = new JLabel("Phone Number");
JLabel JL4= new JLabel("Gender");
JLabel JL5 = new JLabel("Course");
JLabel JL6 = new JLabel("Student ID");
JLabel JL7= new JLabel("Password");
tf1 = new JTextField(15);
tf2 = new JTextField(15);
tf3= new JTextField(15);
pas=new JPasswordField(15);
jb1 = new JRadioButton("Male");
jb2 = new JRadioButton("Female");
Cou = new JComboBox(course);
JButton Reg= new JButton("Register");
er = new JLabel();
p.setLayout(null);
/*Making button group*/
ButtonGroup gen = new ButtonGroup();
gen.add(jb1);
gen.add(jb2);
/*Displaying the components Size*/
p.setBounds(0, 0, 585, 80);
JL1.setBounds(145, 10, 290, 50);
JL2.setBounds(30, 95, 95, 40);
JL3.setBounds(30, 145, 110, 40);
JL4.setBounds(30,195,95,40);
JL5.setBounds(30, 245, 95, 40);
JL6.setBounds(30, 295, 95, 40);
JL7.setBounds(30, 345, 95, 40);
tf1.setBounds(155, 95, 200, 25);
tf2.setBounds(155, 145, 200, 25);
jb1.setBounds(155, 200, 75, 25);
jb2.setBounds(245,200,75,25);
Cou.setBounds(155, 250, 200, 20);
tf3.setBounds(155,300,200,25);
pas.setBounds(155, 350,200, 25);
Reg.setBounds(155, 410, 130, 40);
er.setBounds(140, 450, 225, 40);
/*Customization of the components*/
p.setBackground(Color.blue);
Cou.setBackground(Color.blue);
Reg.setBackground(Color.blue);
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font F2 = new Font("Arial",Font.PLAIN,15);
JL1.setFont(F1);
JL2.setFont(F2);
JL3.setFont(F2);
JL4.setFont(F2);
JL5.setFont(F2);
JL6.setFont(F2);
JL7.setFont(F2);
er.setFont(F2);
er.setForeground(Color.BLUE);
/* Adding components to the panel*/
p.add(JL1);
C.add(JL2);
C.add(JL3);
C.add(JL4);
C.add(JL5);
C.add(JL6);
C.add(JL7);
C.add(tf1);
C.add(tf2);
C.add(p);
C.add(jb1);
C.add(jb2);
C.add(Cou);
C.add(tf3);
C.add(pas);
C.add(Reg);
C.add(er);
Reg.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String name = tf1.getText();
String cour = String.valueOf(Cou.getSelectedItem());
int ph,sd;
String ge;
String pass = String.valueOf(pas.getPassword());
if(pass.isEmpty()==false)
{
if(jb1.isSelected()==true)
{
ge = "Male";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
if(ph/100000000 > 1 || ph/10000000!=1 && ph/10000000!=7 || ph/1000000!=17 && ph/1000000 !=77 )
{
throw new CustommadeException();
}
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else if(jb2.isSelected()==true)
{
ge="Female";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else
{
er.setText("Please fill all the correctly");
}
}
else
{
er.setText("Please fill the form correctly");
}
}
private void Rco()
{
JOptionPane.showInternalMessageDialog(null, "Thanks for registering","Registered",JOptionPane.INFORMATION_MESSAGE);
setVisible(false);
Login f = new Login();
f.Register();
}
}
Code Snippet of default package: FirstBody Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import backend.verifiaction;
public class FirstBody extends JFrame implements ActionListener
{
JPanel C = new JPanel();
verifiaction y = new verifiaction ();
String s = y.name();
JButton B1,B2,B3,b4;
FirstBody()
{
setVisible(true);
setTitle("WELCOME");
setBounds(0,0,1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
C = new JPanel();
setContentPane(C);
C.setLayout(null);
}
public void body()
{
JPanel p = new JPanel();
JLabel LB1 = new JLabel("CST ");
JLabel LB2 = new JLabel("CANTEEN CREDIT MANAGEMENT SYSTEM");
JLabel LB3 = new JLabel("KUZU ZANGPO "+ s.toUpperCase());
JLabel LB4 = new JLabel("");
B1 = new JButton("ASK CREDIT");
B2 = new JButton("PAY CREDIT");
B3 = new JButton("check Details");
b4=new JButton("LogOut");
ImageIcon JPG = new ImageIcon(this.getClass().getResource("/w.jpg"));
LB4.setIcon(JPG);
p.setLayout(null);
Font f = new Font("Times New Roman", Font.BOLD, 40);
p.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB2.setForeground(Color.GREEN);
LB3.setForeground(Color.GREEN);
b4.setForeground(Color.GREEN);
LB1.setFont(f);
LB2.setFont(f);
LB3.setFont(new Font("Vladimir Script", Font.BOLD, 25));
b4.setBackground(Color.BLUE);
p.setBounds(0, 0, 1000, 660);
LB1.setBounds(425, 10, 330, 75);
LB2.setBounds(45, 65, 945, 75);
LB3.setBounds(190, 121, 510, 75);
B1.setBounds(100, 480, 120, 120);
B2.setBounds(400, 480, 120, 120);
B3.setBounds(700, 480, 120, 120);
LB4.setBounds(90, 195, 785, 245);
b4.setBounds(0,5,90,20);
p.add(LB1);
p.add(LB2);
p.add(LB3);
p.add(LB4);
p.add(b4);
p.add(B1);
p.add(B2);
p.add(B3);
C.add(p);
B1.addActionListener(this);
b4.addActionListener(this);
B3.addActionListener(this);
B2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b4)
{
setVisible(false);
Login f = new Login();
f.Register();
}
if(e.getSource()==B1)
{
setVisible(false);
AskCredit f = new AskCredit();
f.CreditAsked();
}
if(e.getSource()==B3)
{
setVisible(false);
showdetails f = new showdetails();
f.userd();
}
if(e.getSource()==B2)
{
AskCredit f = new AskCredit();
try
{
f.Payed();
setVisible(false);
}
catch(Exception e1)
{
f.setVisible(false);
JOptionPane.showInternalMessageDialog(null, "Congratlation you dont have Credit","No credit",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: AskCredit Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: showdetails Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import backend.verifiaction;
public class register extends JFrame implements ActionListener
{
JPanel C = new JPanel();
JTextField tf1,tf2,tf3;
private JPasswordField pas;
JComboBox Cou ;
JRadioButton jb1,jb2;
JLabel er;
String[] course = new String[] {"Architecture","Civil","Electrical","Electronics and Communication","Information Technology","Geology","Instrumentation and control","Masters"};
register()
{
setVisible(true);
setTitle("Register");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,600,600);
setContentPane(C);
C.setLayout(null);
}
void RF()
{
/*Declaring variables*/
JPanel p = new JPanel();
JLabel JL1 = new JLabel("REGISTRATION FORM");
JLabel JL2= new JLabel("Name:");
JLabel JL3 = new JLabel("Phone Number");
JLabel JL4= new JLabel("Gender");
JLabel JL5 = new JLabel("Course");
JLabel JL6 = new JLabel("Student ID");
JLabel JL7= new JLabel("Password");
tf1 = new JTextField(15);
tf2 = new JTextField(15);
tf3= new JTextField(15);
pas=new JPasswordField(15);
jb1 = new JRadioButton("Male");
jb2 = new JRadioButton("Female");
Cou = new JComboBox(course);
JButton Reg= new JButton("Register");
er = new JLabel();
p.setLayout(null);
/*Making button group*/
ButtonGroup gen = new ButtonGroup();
gen.add(jb1);
gen.add(jb2);
/*Displaying the components Size*/
p.setBounds(0, 0, 585, 80);
JL1.setBounds(145, 10, 290, 50);
JL2.setBounds(30, 95, 95, 40);
JL3.setBounds(30, 145, 110, 40);
JL4.setBounds(30,195,95,40);
JL5.setBounds(30, 245, 95, 40);
JL6.setBounds(30, 295, 95, 40);
JL7.setBounds(30, 345, 95, 40);
tf1.setBounds(155, 95, 200, 25);
tf2.setBounds(155, 145, 200, 25);
jb1.setBounds(155, 200, 75, 25);
jb2.setBounds(245,200,75,25);
Cou.setBounds(155, 250, 200, 20);
tf3.setBounds(155,300,200,25);
pas.setBounds(155, 350,200, 25);
Reg.setBounds(155, 410, 130, 40);
er.setBounds(140, 450, 225, 40);
/*Customization of the components*/
p.setBackground(Color.blue);
Cou.setBackground(Color.blue);
Reg.setBackground(Color.blue);
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font F2 = new Font("Arial",Font.PLAIN,15);
JL1.setFont(F1);
JL2.setFont(F2);
JL3.setFont(F2);
JL4.setFont(F2);
JL5.setFont(F2);
JL6.setFont(F2);
JL7.setFont(F2);
er.setFont(F2);
er.setForeground(Color.BLUE);
/* Adding components to the panel*/
p.add(JL1);
C.add(JL2);
C.add(JL3);
C.add(JL4);
C.add(JL5);
C.add(JL6);
C.add(JL7);
C.add(tf1);
C.add(tf2);
C.add(p);
C.add(jb1);
C.add(jb2);
C.add(Cou);
C.add(tf3);
C.add(pas);
C.add(Reg);
C.add(er);
Reg.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String name = tf1.getText();
String cour = String.valueOf(Cou.getSelectedItem());
int ph,sd;
String ge;
String pass = String.valueOf(pas.getPassword());
if(pass.isEmpty()==false)
{
if(jb1.isSelected()==true)
{
ge = "Male";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
if(ph/100000000 > 1 || ph/10000000!=1 && ph/10000000!=7 || ph/1000000!=17 && ph/1000000 !=77 )
{
throw new CustommadeException();
}
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else if(jb2.isSelected()==true)
{
ge="Female";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else
{
er.setText("Please fill all the correctly");
}
}
else
{
er.setText("Please fill the form correctly");
}
}
private void Rco()
{
JOptionPane.showInternalMessageDialog(null, "Thanks for registering","Registered",JOptionPane.INFORMATION_MESSAGE);
setVisible(false);
Login f = new Login();
f.Register();
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import backend.verifiaction;
public class register extends JFrame implements ActionListener
{
JPanel C = new JPanel();
JTextField tf1,tf2,tf3;
private JPasswordField pas;
JComboBox Cou ;
JRadioButton jb1,jb2;
JLabel er;
String[] course = new String[] {"Architecture","Civil","Electrical","Electronics and Communication","Information Technology","Geology","Instrumentation and control","Masters"};
register()
{
setVisible(true);
setTitle("Register");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,600,600);
setContentPane(C);
C.setLayout(null);
}
void RF()
{
/*Declaring variables*/
JPanel p = new JPanel();
JLabel JL1 = new JLabel("REGISTRATION FORM");
JLabel JL2= new JLabel("Name:");
JLabel JL3 = new JLabel("Phone Number");
JLabel JL4= new JLabel("Gender");
JLabel JL5 = new JLabel("Course");
JLabel JL6 = new JLabel("Student ID");
JLabel JL7= new JLabel("Password");
tf1 = new JTextField(15);
tf2 = new JTextField(15);
tf3= new JTextField(15);
pas=new JPasswordField(15);
jb1 = new JRadioButton("Male");
jb2 = new JRadioButton("Female");
Cou = new JComboBox(course);
JButton Reg= new JButton("Register");
er = new JLabel();
p.setLayout(null);
/*Making button group*/
ButtonGroup gen = new ButtonGroup();
gen.add(jb1);
gen.add(jb2);
/*Displaying the components Size*/
p.setBounds(0, 0, 585, 80);
JL1.setBounds(145, 10, 290, 50);
JL2.setBounds(30, 95, 95, 40);
JL3.setBounds(30, 145, 110, 40);
JL4.setBounds(30,195,95,40);
JL5.setBounds(30, 245, 95, 40);
JL6.setBounds(30, 295, 95, 40);
JL7.setBounds(30, 345, 95, 40);
tf1.setBounds(155, 95, 200, 25);
tf2.setBounds(155, 145, 200, 25);
jb1.setBounds(155, 200, 75, 25);
jb2.setBounds(245,200,75,25);
Cou.setBounds(155, 250, 200, 20);
tf3.setBounds(155,300,200,25);
pas.setBounds(155, 350,200, 25);
Reg.setBounds(155, 410, 130, 40);
er.setBounds(140, 450, 225, 40);
/*Customization of the components*/
p.setBackground(Color.blue);
Cou.setBackground(Color.blue);
Reg.setBackground(Color.blue);
Font F1 = new Font("Times New Roman", Font.BOLD, 25);
Font F2 = new Font("Arial",Font.PLAIN,15);
JL1.setFont(F1);
JL2.setFont(F2);
JL3.setFont(F2);
JL4.setFont(F2);
JL5.setFont(F2);
JL6.setFont(F2);
JL7.setFont(F2);
er.setFont(F2);
er.setForeground(Color.BLUE);
/* Adding components to the panel*/
p.add(JL1);
C.add(JL2);
C.add(JL3);
C.add(JL4);
C.add(JL5);
C.add(JL6);
C.add(JL7);
C.add(tf1);
C.add(tf2);
C.add(p);
C.add(jb1);
C.add(jb2);
C.add(Cou);
C.add(tf3);
C.add(pas);
C.add(Reg);
C.add(er);
Reg.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String name = tf1.getText();
String cour = String.valueOf(Cou.getSelectedItem());
int ph,sd;
String ge;
String pass = String.valueOf(pas.getPassword());
if(pass.isEmpty()==false)
{
if(jb1.isSelected()==true)
{
ge = "Male";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
if(ph/100000000 > 1 || ph/10000000!=1 && ph/10000000!=7 || ph/1000000!=17 && ph/1000000 !=77 )
{
throw new CustommadeException();
}
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else if(jb2.isSelected()==true)
{
ge="Female";
try
{
ph=Integer.parseInt(tf2.getText());
sd=Integer.parseInt(tf3.getText());
char name0[]=name.toCharArray();
for(char a : name0)
{
if(Character.isDigit(a))
throw new CustommadeException();
}
verifiaction f = new verifiaction();
f.store(name, ph, sd, pass, ge, cour);
Rco();
}
catch(Exception es)
{
er.setText("Please fill the form correctly");
}
}
else
{
er.setText("Please fill all the correctly");
}
}
else
{
er.setText("Please fill the form correctly");
}
}
private void Rco()
{
JOptionPane.showInternalMessageDialog(null, "Thanks for registering","Registered",JOptionPane.INFORMATION_MESSAGE);
setVisible(false);
Login f = new Login();
f.Register();
}
}
Code Snippet of default package: FirstBody Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import backend.verifiaction;
public class FirstBody extends JFrame implements ActionListener
{
JPanel C = new JPanel();
verifiaction y = new verifiaction ();
String s = y.name();
JButton B1,B2,B3,b4;
FirstBody()
{
setVisible(true);
setTitle("WELCOME");
setBounds(0,0,1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
C = new JPanel();
setContentPane(C);
C.setLayout(null);
}
public void body()
{
JPanel p = new JPanel();
JLabel LB1 = new JLabel("CST ");
JLabel LB2 = new JLabel("CANTEEN CREDIT MANAGEMENT SYSTEM");
JLabel LB3 = new JLabel("KUZU ZANGPO "+ s.toUpperCase());
JLabel LB4 = new JLabel("");
B1 = new JButton("ASK CREDIT");
B2 = new JButton("PAY CREDIT");
B3 = new JButton("check Details");
b4=new JButton("LogOut");
ImageIcon JPG = new ImageIcon(this.getClass().getResource("/w.jpg"));
LB4.setIcon(JPG);
p.setLayout(null);
Font f = new Font("Times New Roman", Font.BOLD, 40);
p.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB2.setForeground(Color.GREEN);
LB3.setForeground(Color.GREEN);
b4.setForeground(Color.GREEN);
LB1.setFont(f);
LB2.setFont(f);
LB3.setFont(new Font("Vladimir Script", Font.BOLD, 25));
b4.setBackground(Color.BLUE);
p.setBounds(0, 0, 1000, 660);
LB1.setBounds(425, 10, 330, 75);
LB2.setBounds(45, 65, 945, 75);
LB3.setBounds(190, 121, 510, 75);
B1.setBounds(100, 480, 120, 120);
B2.setBounds(400, 480, 120, 120);
B3.setBounds(700, 480, 120, 120);
LB4.setBounds(90, 195, 785, 245);
b4.setBounds(0,5,90,20);
p.add(LB1);
p.add(LB2);
p.add(LB3);
p.add(LB4);
p.add(b4);
p.add(B1);
p.add(B2);
p.add(B3);
C.add(p);
B1.addActionListener(this);
b4.addActionListener(this);
B3.addActionListener(this);
B2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b4)
{
setVisible(false);
Login f = new Login();
f.Register();
}
if(e.getSource()==B1)
{
setVisible(false);
AskCredit f = new AskCredit();
f.CreditAsked();
}
if(e.getSource()==B3)
{
setVisible(false);
showdetails f = new showdetails();
f.userd();
}
if(e.getSource()==B2)
{
AskCredit f = new AskCredit();
try
{
f.Payed();
setVisible(false);
}
catch(Exception e1)
{
f.setVisible(false);
JOptionPane.showInternalMessageDialog(null, "Congratlation you dont have Credit","No credit",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: AskCredit Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: showdetails Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import backend.verifiaction;
public class FirstBody extends JFrame implements ActionListener
{
JPanel C = new JPanel();
verifiaction y = new verifiaction ();
String s = y.name();
JButton B1,B2,B3,b4;
FirstBody()
{
setVisible(true);
setTitle("WELCOME");
setBounds(0,0,1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
C = new JPanel();
setContentPane(C);
C.setLayout(null);
}
public void body()
{
JPanel p = new JPanel();
JLabel LB1 = new JLabel("CST ");
JLabel LB2 = new JLabel("CANTEEN CREDIT MANAGEMENT SYSTEM");
JLabel LB3 = new JLabel("KUZU ZANGPO "+ s.toUpperCase());
JLabel LB4 = new JLabel("");
B1 = new JButton("ASK CREDIT");
B2 = new JButton("PAY CREDIT");
B3 = new JButton("check Details");
b4=new JButton("LogOut");
ImageIcon JPG = new ImageIcon(this.getClass().getResource("/w.jpg"));
LB4.setIcon(JPG);
p.setLayout(null);
Font f = new Font("Times New Roman", Font.BOLD, 40);
p.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB2.setForeground(Color.GREEN);
LB3.setForeground(Color.GREEN);
b4.setForeground(Color.GREEN);
LB1.setFont(f);
LB2.setFont(f);
LB3.setFont(new Font("Vladimir Script", Font.BOLD, 25));
b4.setBackground(Color.BLUE);
p.setBounds(0, 0, 1000, 660);
LB1.setBounds(425, 10, 330, 75);
LB2.setBounds(45, 65, 945, 75);
LB3.setBounds(190, 121, 510, 75);
B1.setBounds(100, 480, 120, 120);
B2.setBounds(400, 480, 120, 120);
B3.setBounds(700, 480, 120, 120);
LB4.setBounds(90, 195, 785, 245);
b4.setBounds(0,5,90,20);
p.add(LB1);
p.add(LB2);
p.add(LB3);
p.add(LB4);
p.add(b4);
p.add(B1);
p.add(B2);
p.add(B3);
C.add(p);
B1.addActionListener(this);
b4.addActionListener(this);
B3.addActionListener(this);
B2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b4)
{
setVisible(false);
Login f = new Login();
f.Register();
}
if(e.getSource()==B1)
{
setVisible(false);
AskCredit f = new AskCredit();
f.CreditAsked();
}
if(e.getSource()==B3)
{
setVisible(false);
showdetails f = new showdetails();
f.userd();
}
if(e.getSource()==B2)
{
AskCredit f = new AskCredit();
try
{
f.Payed();
setVisible(false);
}
catch(Exception e1)
{
f.setVisible(false);
JOptionPane.showInternalMessageDialog(null, "Congratlation you dont have Credit","No credit",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import backend.verifiaction;
public class FirstBody extends JFrame implements ActionListener
{
JPanel C = new JPanel();
verifiaction y = new verifiaction ();
String s = y.name();
JButton B1,B2,B3,b4;
FirstBody()
{
setVisible(true);
setTitle("WELCOME");
setBounds(0,0,1000,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
C = new JPanel();
setContentPane(C);
C.setLayout(null);
}
public void body()
{
JPanel p = new JPanel();
JLabel LB1 = new JLabel("CST ");
JLabel LB2 = new JLabel("CANTEEN CREDIT MANAGEMENT SYSTEM");
JLabel LB3 = new JLabel("KUZU ZANGPO "+ s.toUpperCase());
JLabel LB4 = new JLabel("");
B1 = new JButton("ASK CREDIT");
B2 = new JButton("PAY CREDIT");
B3 = new JButton("check Details");
b4=new JButton("LogOut");
ImageIcon JPG = new ImageIcon(this.getClass().getResource("/w.jpg"));
LB4.setIcon(JPG);
p.setLayout(null);
Font f = new Font("Times New Roman", Font.BOLD, 40);
p.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB2.setForeground(Color.GREEN);
LB3.setForeground(Color.GREEN);
b4.setForeground(Color.GREEN);
LB1.setFont(f);
LB2.setFont(f);
LB3.setFont(new Font("Vladimir Script", Font.BOLD, 25));
b4.setBackground(Color.BLUE);
p.setBounds(0, 0, 1000, 660);
LB1.setBounds(425, 10, 330, 75);
LB2.setBounds(45, 65, 945, 75);
LB3.setBounds(190, 121, 510, 75);
B1.setBounds(100, 480, 120, 120);
B2.setBounds(400, 480, 120, 120);
B3.setBounds(700, 480, 120, 120);
LB4.setBounds(90, 195, 785, 245);
b4.setBounds(0,5,90,20);
p.add(LB1);
p.add(LB2);
p.add(LB3);
p.add(LB4);
p.add(b4);
p.add(B1);
p.add(B2);
p.add(B3);
C.add(p);
B1.addActionListener(this);
b4.addActionListener(this);
B3.addActionListener(this);
B2.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b4)
{
setVisible(false);
Login f = new Login();
f.Register();
}
if(e.getSource()==B1)
{
setVisible(false);
AskCredit f = new AskCredit();
f.CreditAsked();
}
if(e.getSource()==B3)
{
setVisible(false);
showdetails f = new showdetails();
f.userd();
}
if(e.getSource()==B2)
{
AskCredit f = new AskCredit();
try
{
f.Payed();
setVisible(false);
}
catch(Exception e1)
{
f.setVisible(false);
JOptionPane.showInternalMessageDialog(null, "Congratlation you dont have Credit","No credit",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: AskCredit Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: showdetails Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import backend.verifiaction;
public class AskCredit extends JFrame implements ActionListener
{
JPanel P;
JButton BB,TB, AC,PAA;
JTextField VegRice,NonVeg,Snack,Momo,FryRice;
JTextField Magi,koka,Wai,Chips,pickel;
JTextField FrizzyDr,Tea,CanDri,water,dewfresh;
JTextField ice, chocolate,Pan, CG,doma;
JCheckBox CB;
JLabel Tt,lb2,lb1;
static JComboBox SN ;
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM//YYYY");
Date date = new Date();
verifiaction x20 = new verifiaction();
String time = formatter.format(date);
String[] s = new String[4];
public static JTable table;
static JTextField Total = new JTextField();
static JTextField dae = new JTextField();
static DefaultTableModel model;
AskCredit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 900, 600);
P=new JPanel();
setContentPane(P);
P.setLayout(null);
}
public void CreditAsked()
{
setVisible(true);
setTitle("Ask Credit");
Font f = new Font("Times New Roman", Font.BOLD, 20);
Font f2 = new Font("Times New Roman",Font.PLAIN,15);
/*Creating header panel and its components*/
JPanel p1 = new JPanel();
JLabel LB1= new JLabel("ASK CREDIT");
BB=new JButton("Back");
/*Designing the components*/
p1.setBackground(Color.BLUE);
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
BB.setFont(f);
BB.setBackground(Color.BLUE);
/*Making layouts*/
p1.setLayout(null);
p1.setBounds(0, 0, 900, 70);
LB1.setBounds(395, 0, 282, 65);
BB.setBounds(0, 0, 100, 25);
/*Adding components to small panel*/
p1.add(LB1);
p1.add(BB);
BB.addActionListener(this);
/*Making menu panel and its components*/
JPanel p2 = new JPanel();
JLabel LB2 = new JLabel("ITEMS ORDERED");
JSeparator s1 = new JSeparator();
JLabel LB3 = new JLabel("Items:");
JLabel LB4 = new JLabel("Quantity:");
JLabel LB5 = new JLabel("Veg Rice");
JLabel LB6 = new JLabel("Non-veg Rice");
JLabel LB7 = new JLabel("Snacks");
JLabel LB8 = new JLabel("Momo");
JLabel LB9 = new JLabel("Fried Rice");
JLabel LB10 = new JLabel("DRINKS ORDERED");
JSeparator s2 = new JSeparator();
JLabel LB11 = new JLabel("Items:");
JLabel LB12= new JLabel("Quantity:");
JLabel LB13 = new JLabel("Fizzy Drinks");
JLabel LB14=new JLabel("Tea/Coffee");
JLabel LB15=new JLabel("Canned Drinks");
JLabel LB16=new JLabel("Water");
JLabel LB17 = new JLabel("Dew Fresh");
JLabel LB18= new JLabel("Items:");
JLabel LB19 = new JLabel("Quantity:");
JLabel LB20 = new JLabel("Maagi");
JLabel LB21 = new JLabel("Koka");
JLabel LB22 = new JLabel("Wai-Wai");
JLabel LB23 = new JLabel("Chips");
JLabel LB24 = new JLabel("Pickel");
JLabel LB25 = new JLabel("OTHER ITEMS");
JSeparator s3 = new JSeparator();
JLabel LB26 = new JLabel("Quantity:");
JLabel LB27 = new JLabel("Items:");
JLabel LB28 = new JLabel("Doma");
JLabel LB29 = new JLabel("Chiewing Gum");
JLabel LB30 = new JLabel("Pan Masala");
JLabel LB31 = new JLabel("Chocolate");
JLabel LB32 = new JLabel("Ice Cream");
VegRice = new JTextField(10);
NonVeg = new JTextField(10);
Snack = new JTextField(10);
Momo = new JTextField(10);
FryRice = new JTextField(10);
Magi = new JTextField(10);
koka = new JTextField(10);
Wai = new JTextField(10);
Chips = new JTextField(10);
pickel = new JTextField(10);
FrizzyDr = new JTextField(10);
Tea = new JTextField(10);
CanDri = new JTextField(10);
water = new JTextField(10);
doma = new JTextField(10);
CG = new JTextField(10);
Pan = new JTextField(10);
dewfresh = new JTextField(10);
ice = new JTextField(10);
chocolate = new JTextField(10);
p2.setLayout(null);
s1.setBounds(180, 25, 120, 5);
LB2.setBounds(180, 0, 120, 25);
p2.setBounds(0, 72, 500,500);
LB3.setBounds(0, 35, 150, 15);
LB4.setBounds(100, 35, 150, 15);
LB5.setBounds(0, 70, 90, 25);
LB6.setBounds(0, 100, 90, 25);
LB7.setBounds(0,130,90,25);
LB8.setBounds(0, 160, 90, 25);
LB9.setBounds(0, 190, 90, 25);
LB10.setBounds(5, 230, 135, 25);
s2.setBounds(5,255,150,15);
LB11.setBounds(0, 270, 90, 15);
LB12.setBounds(100, 270, 90, 15);
LB13.setBounds(0,300,90,25);
LB14.setBounds(0,330,90,25);
LB15.setBounds(0,360,90,25);
LB16.setBounds(0,390,90,25);
LB17.setBounds(0, 414, 90, 25);
LB18.setBounds(250, 40, 150, 15);
LB19.setBounds(350, 40, 150, 15);
LB20.setBounds(250, 70, 90, 25);
LB21.setBounds(250, 100, 90, 25);
LB22.setBounds(250, 130, 90, 25);
LB23.setBounds(250, 160, 90, 25);
LB24.setBounds(250, 190, 90, 25);
s3.setBounds(250, 255, 150, 15);
LB25.setBounds(250, 230, 135, 25);
LB26.setBounds(345, 270, 90, 15);
LB27.setBounds(245, 270, 90, 15);
LB28.setBounds(250, 300, 90, 25);
LB29.setBounds(250, 330, 90, 25);
LB30.setBounds(250, 360, 90, 25);
LB31.setBounds(250, 390, 90, 25);
LB32.setBounds(250, 415, 90, 25);
VegRice.setBounds(100, 75, 70, 20);
NonVeg.setBounds(100, 105, 70, 20);
Snack.setBounds(100, 135, 70, 20);
Momo.setBounds(100, 165, 70, 20);
FryRice.setBounds(100, 190, 70, 20);
Magi.setBounds(360, 70, 70, 20);
koka.setBounds(360, 100, 70, 20);
Wai.setBounds(360, 130, 70, 20);
Chips.setBounds(360, 160, 70, 20);
pickel.setBounds(360, 190, 70, 20);
FrizzyDr.setBounds(100, 300, 70, 20);
Tea.setBounds(100, 330, 70, 20);
CanDri.setBounds(100, 360, 70, 20);
water.setBounds(100, 390, 70, 20);
dewfresh.setBounds(100, 420, 70, 20);
ice.setBounds(350, 420, 70, 20);
chocolate.setBounds(350, 392, 70, 20);
Pan.setBounds(350, 360, 70, 20);
CG.setBounds(350, 330, 70, 20);
doma.setBounds(350, 300, 70, 20);
LB2.setFont(f2);
LB3.setFont(f);
LB4.setFont(f);
LB5.setFont(f2);
LB6.setFont(f2);
LB7.setFont(f2);
LB8.setFont(f2);
LB9.setFont(f2);
LB10.setFont(f2);
LB11.setFont(f);
LB12.setFont(f);
LB13.setFont(f2);
LB14.setFont(f2);
LB15.setFont(f2);
LB16.setFont(f2);
LB17.setFont(f2);
LB18.setFont(f);
LB19.setFont(f);
LB20.setFont(f2);
LB21.setFont(f2);
LB22.setFont(f2);
LB23.setFont(f2);
LB24.setFont(f2);
LB25.setFont(f2);
LB26.setFont(f);
LB27.setFont(f);
LB28.setFont(f2);
LB29.setFont(f2);
LB30.setFont(f2);
LB31.setFont(f2);
LB32.setFont(f2);
s1.setBackground(Color.BLUE);
s2.setBackground(Color.BLUE);
s3.setBackground(Color.BLUE);
p2.setBackground(Color.GREEN);
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
p2.add(s1);
p2.add(LB2);
p2.add(LB3);
p2.add(LB4);
p2.add(LB5);
p2.add(LB6);
p2.add(LB7);
p2.add(LB8);
p2.add(LB9);
p2.add(LB10);
p2.add(s2);
p2.add(LB11);
p2.add(LB12);
p2.add(LB13);
p2.add(LB14);
p2.add(LB15);
p2.add(LB16);
p2.add(LB17);
p2.add(LB18);
p2.add(LB19);
p2.add(LB20);
p2.add(LB21);
p2.add(LB22);
p2.add(LB23);
p2.add(LB24);
p2.add(LB25);
p2.add(s3);
p2.add(LB25);
p2.add(LB26);
p2.add(LB27);
p2.add(LB28);
p2.add(LB29);
p2.add(LB30);
p2.add(LB31);
p2.add(LB32);
p2.add(VegRice);
p2.add(NonVeg);
p2.add(Snack);
p2.add(Momo);
p2.add(FryRice);
p2.add(Magi);
p2.add(koka);
p2.add(Wai);
p2.add(Chips);
p2.add(pickel);
p2.add(FrizzyDr);
p2.add(Tea);
p2.add(CanDri);
p2.add(water);
p2.add(dewfresh);
p2.add(ice);
p2.add(chocolate);
p2.add(Pan);
p2.add(CG);
p2.add(doma);
/*Adding items to the comboBox*/
s[0]="SELECT";
s[1]="JM";
s[2]="GNH";
s[3]="Guest House";
/*Making JtabbedPane*/
JTabbedPane TP = new JTabbedPane(JTabbedPane.TOP);
JPanel p3 = new JPanel();
JPanel p4 = new JPanel();
/*Making size and adding the components*/
TP.addTab("Terms and condition", null, p3, null);
TP.addTab("Proceed", null, p4, null);
JLabel TandC = new JLabel("html>I hereby accept the condition that i will pay the credit within 1 month if i fail to do so i will accept any action taken by the Management/html>");
CB = new JCheckBox("I Accept the Terms and Condition");
lb1 = new JLabel("Total Amount: ");
lb2 = new JLabel("Date:");
JLabel lb3 = new JLabel("Shop Name");
SN = new JComboBox(s);
AC = new JButton("Add To Credit");
Tt = new JLabel("");
TB = new JButton("GenerateTotal");
p3.setLayout(null);
p4.setLayout(null);
TP.setBounds(510, 72, 364, 449);
TandC.setBounds(0, 38, 359, 188);
CB.setBounds(75, 233, 225, 30);
lb1.setBounds(0, 80, 360, 70);
lb2.setBounds(0, 0, 360, 70);
lb3.setBounds(0, 184, 125, 70);
AC.setBounds(96, 310, 150, 50);
SN.setBounds(179, 210, 140, 25);
Tt.setBounds(10, 282, 290, 57);
TB.setBounds(115, 350, 150, 30);
TandC.setForeground(Color.BLUE);
lb1.setForeground(Color.BLUE);
lb2.setForeground(Color.BLUE);
lb3.setForeground(Color.BLUE);
TandC.setFont(f2);
TB.setEnabled(false);
p3.add(TandC);
p3.add(CB);
p3.add(Tt);
p3.add(TB);
p4.add(AC);
p4.add(lb1);
p4.add(lb2);
p4.add(lb3);
p4.add(SN);
P.add(p1);
P.add(p2);
P.add(TP);
CB.addActionListener(this);
TB.addActionListener(this);
AC.addActionListener(this);
JPanel cp = new JPanel();
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 86, 560, 250);
cp.add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"Date", "Shop Name", "Amount(Nu)"
}
));
table.getColumnModel().getColumn(1).setPreferredWidth(111);
scrollPane.setViewportView(table);
}
void Payed()
{
setVisible(true);
setTitle("Pay Credit");
setBounds(100, 100, 596, 452);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 85, 560, 250);
P.add(scrollPane);
scrollPane.setViewportView(table);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Boolean x = table.isEditing();
if(x==false)
{
JOptionPane.showMessageDialog(null,"You cannot edit");
}
}
});
PAA = new JButton("Pay");
PAA.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JOptionPane.showInternalMessageDialog(null, "Sucessfully Payed","Sucessful",JOptionPane.PLAIN_MESSAGE);
model.removeRow(table.getSelectedRow());
}
catch(Exception e1)
{
JOptionPane.showInternalMessageDialog(null, "Please Select the item","Error",JOptionPane.ERROR_MESSAGE);
}
}
});
JPanel panel = new JPanel();
panel.setBackground(Color.BLUE);
panel.setBounds(0, 0, 570, 75);
P.add(panel);
panel.setLayout(null);
JLabel lTitle= new JLabel("Pay Credit");
lTitle.setForeground(Color.GREEN);
lTitle.setFont(new Font("Times New Roman", Font.BOLD, 30));
lTitle.setBounds(188, 11, 195, 53);
JButton btnNewButton = new JButton("Back");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
FirstBody f = new FirstBody();
f.body();
}
});
btnNewButton.setFont(new Font("Times New Roman", Font.PLAIN, 20));
btnNewButton.setBackground(Color.BLUE);
btnNewButton.setBounds(0, 0, 90, 20);
panel.add(btnNewButton);
panel.add(lTitle);
PAA.setBounds(230, 345, 120, 45);
P.add(PAA);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==BB)
{
setVisible(false);
FirstBody y1 = new FirstBody();
y1.body();
}
if(CB.isSelected()==true)
{
TB.setEnabled(true);
try
{
int x = Integer.parseInt(VegRice.getText());
int x1 = Integer.parseInt(NonVeg.getText());
int x2 = Integer.parseInt(Snack.getText());
int x3 = Integer.parseInt(Momo.getText());
int x4 = Integer.parseInt(FryRice.getText());
int x5 = Integer.parseInt(Magi.getText());
int x6 = Integer.parseInt(koka.getText());
int x7 = Integer.parseInt(Wai.getText());
int x8 = Integer.parseInt(Chips.getText());
int x9 = Integer.parseInt(pickel.getText());
int x10 = Integer.parseInt(FrizzyDr.getText());
int x11= Integer.parseInt(Tea.getText());
int x12= Integer.parseInt(CanDri.getText());
int x13= Integer.parseInt(water.getText());
int x14= Integer.parseInt(doma.getText());
int x15= Integer.parseInt(CG.getText());
int x16= Integer.parseInt(Pan.getText());
int x17= Integer.parseInt(dewfresh.getText());
int x18= Integer.parseInt(ice.getText());
int x19= Integer.parseInt(chocolate.getText());
x20.total(x,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19);
}
catch(Exception es)
{
VegRice.setText("0");
NonVeg.setText("0");
Snack.setText("0");
Momo.setText("0");
FryRice.setText("0");
Magi.setText("0");
koka.setText("0");
Wai.setText("0");
Chips.setText("0");
pickel.setText("0");
FrizzyDr.setText("0");
Tea.setText("0");
CanDri.setText("0");
water.setText("0");
doma.setText("0");
CG.setText("0");
Pan.setText("0");
dewfresh.setText("0");
ice.setText("0");
chocolate.setText("0");
JOptionPane.showInternalMessageDialog(null, "invalid input","Invalid input",JOptionPane.ERROR_MESSAGE);
}
}
else
{
TB.setEnabled(false);
AC.setEnabled(false);
}
if(e.getSource()==TB)
{
Tt.setText("Total is Nu: " + x20.sum + " ");
lb2.setText("Date: " + formatter.format(date));
lb1.setText("Total Nu:" + x20.sum + " ");
AC.setEnabled(true);
}
if(e.getSource()==AC)
{
String shopNa = String.valueOf(SN.getSelectedItem());
if(shopNa.contains("SELECT"))
{
JOptionPane.showInternalMessageDialog(null, "Select Shop","Select Shop",JOptionPane.ERROR_MESSAGE);
}
else
{
Total = new JTextField();
dae = new JTextField();
Total.setText(String.valueOf(x20.sum));
dae.setText(time);
model = (DefaultTableModel) table.getModel();
model.addRow(new Object[] {
dae.getText(),
SN.getSelectedItem(),
Total.getText(),
});
if(table.getSelectedRow() == 0)
{
if(table.getRowCount()==0)
{
System.out.print("Nice");
}
}
JOptionPane.showInternalMessageDialog(null, "Sucessfully added","Added",JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Code Snippet of default package: showdetails Class
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import backend.verifiaction;
public class showdetails extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
JPanel C = new JPanel();
JButton Button;
verifiaction f = new verifiaction();
showdetails()
{
setVisible(true);
setTitle("Details");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(200,100,300,400);
setContentPane(C);
C.setLayout(null);
}
public void userd()
{
Font f = new Font("Times New Roman", Font.BOLD, 25);
JPanel p = new JPanel();
p.setBackground(Color.BLUE);
p.setBounds(0, 0, 273, 83);
C.add(p);
p.setLayout(null);
JLabel LB1 = new JLabel("Details");
LB1.setForeground(Color.GREEN);
LB1.setFont(f);
LB1.setBounds(30, 0, 243, 61);
p.add(LB1);
JLabel LB2 = new JLabel("Name: "+verifiaction.name);
LB2.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB2.setBounds(30, 94, 234, 30);
C.add(LB2);
JLabel LB3 = new JLabel("Phone no: " + verifiaction.phone);
LB3.setFont(new Font("Times New Roman", Font.PLAIN, 15));
LB3.setBounds(30, 135, 234, 30);
C.add(LB3);
JLabel LB4 = new JLabel("Gender " + verifiaction.gender);
LB4.setBounds(30, 176, 234, 30);
C.add(LB4);
JLabel LB5 = new JLabel("Student Number" + verifiaction.setId);
LB5.setBounds(30, 217, 234, 30);
C.add(LB5);
JLabel LB6 = new JLabel("Course " + verifiaction.Course);
LB6.setBounds(30, 258, 234, 30);
C.add(LB6);
Button = new JButton("OKAY");
Button.setBackground(Color.BLUE);
Button.setBounds(85, 290, 89, 23);
C.add(Button);
Button.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==Button)
{
FirstBody b = new FirstBody();
b.body();
}
}
}
Code Snippet of default package: CustommadeException Class
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
public class CustommadeException extends Exception
{
CustommadeException()
{
super("Error");
}
}
Outputs:
Conclusion:
We could run the program successfully and anyone who are access to this project can run and use it without any trouble as it was made a lot easier. The developed system accomplishes all the objectives stated for the need for the change of the system. First the users need to click the signup button whereby they have to register a form so that there won’t be any kind of mistrust and confusion at the end. After filling up the registration form you can login and then click the ‘ask credit’ button and add any number of items to the cart from any of the available food categories by simply clicking the ‘I accept the terms and conditions’ button for the total amount of items you asked for. Once the total amount of money is generated, you have to choose the proceed button wherein you will be asked to choose the canteen from which you are going to purchase things you ordered. Once you have selected the canteen name you have to click the ‘add to credit’ button whereby the credit will be given for one month. For paying the credit, you need to click the ‘back’ button which will be on the top left-side corner and then you can click the ‘paying credit’ button which will show you the total amount of things you purchased, the canteen from which you purchased those things and the date on which those things where purchased. You can even check your details by clicking the ‘check details’ button. Application of all the concepts of GUI made the project possible. It can be an efficient, convenient and fast mode to purchase anything with all the required information. Lastly I would like to thank sir for giving us such an opportunity which helped us to further enhance our knowledge on Java its application in real life.
0 Comments:
Post a Comment