0% found this document useful (0 votes)
6 views

add fees structure

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

add fees structure

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package School_Management_System;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Random;
public class AddFeeStructure extends JFrame implements ActionListener
{ JFrame f;
JLabel l1,l2,l3,l4;
Choice ch1;
JTextField tf1;
JButton bt1,bt2;
public AddFeeStructure()
{
f=new JFrame("Add Fee Structure");
f.setBackground(Color.WHITE);
f.setLayout(null);
l1=new JLabel();
l1.setBounds(0,0,840, 600);
l1.setLayout(null);
ImageIcon img=new
ImageIcon(ClassLoader.getSystemResource("School_Management_System/Icons/
AddTeacher.jpg"));
Image i1=img.getImage().getScaledInstance(840, 600,Image.SCALE_SMOOTH );
ImageIcon img1=new ImageIcon(i1);
l1.setIcon(img1);
l2=new JLabel("Add Fee Structure");
l2.setBounds(50,150,150,30);
l2.setFont(new Font("Arial",Font.BOLD,15));
l2.setForeground(new Color(59,25,117));
l1.add(l2);
l3=new JLabel("Class Name");
l3.setBounds(400,200,150,30);
l3.setFont(new Font("Arial",Font.BOLD,20));
l3.setForeground(new Color(59,25,117));
l1.add(l3);
ch1=new Choice();
try
{ConnectionClass obj=new ConnectionClass();
String q="select distinct class_name from class";
ResultSet rest=obj.stm.executeQuery(q);
while (rest.next())
{
ch1.add(rest.getString("class_name"));
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
ch1.setBounds(600,200,150,30);
ch1.setFont(new Font("Arial",Font.BOLD,20));
l1.add (ch1);
l4=new JLabel("Fee/Year (Rs)");
l4.setBounds(400,400,200,30);
l4.setFont(new Font("Arial",Font.BOLD,20));
l4.setForeground(new Color(59,25,117));
l1.add(l4);
tf1=new JTextField();
tf1.setFont(new Font("Arial",Font.BOLD,20));
tf1.setBounds(600,400,150,30);
l1.add(tf1);
bt1=new JButton("Add Fee Details");
bt1.setBounds(400,450,150,40);
bt1.setForeground(Color.WHITE);
bt1.setBackground(Color.BLACK);
bt1.addActionListener(this);
l1.add(bt1);
bt2=new JButton("Back");
bt2.setBounds(600,450,150,40);
bt2.setForeground(Color.BLACK);
bt2.setBackground(new Color(191,247,161));
bt2.addActionListener(this);
l1.add(bt2);
f.setVisible(true);
f.setSize(840, 600);
f.setLocation(300,100);
f.add (l1);
}
public void actionPerformed(ActionEvent e)
{ if(e.getSource()==bt1)
{String class_name=ch1.getSelectedItem();
String fee_details=tf1.getText();
Random r=new Random();
String fee_id=""+Math.abs(r.nextInt()%100000);
if(fee_details.isEmpty())
{ JOptionPane.showMessageDialog(null, "Fee amount should not be empty");
} else if(Integer.parseInt(fee_details)>12000)
{ JOptionPane.showMessageDialog(null, "Fee amount should not be more then
12000");
} else if(Integer.parseInt(fee_details)<1000)
{JOptionPane.showMessageDialog(null, "Fee amount should not be less then
1000");
}else
{ try
{ ConnectionClass obj=new ConnectionClass();
String q="insert into fee_structure
values('"+fee_id+"','"+class_name+"','"+fee_details+"')";
obj.stm.executeUpdate(q);
JOptionPane.showMessageDialog(null, "Fee Detail sucessfully inserted");}
catch(Exception ex)
{ex.printStackTrace();}} }
try
{ConnectionClass obj=new ConnectionClass(); }
catch(Exception ex)
{ ex.printStackTrace();}
if(e.getSource()==bt2)
{
f.setVisible(false);
}}
public static void main(String[] args)
{ new AddFeeStructure();
}}

You might also like