Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions Samarth_1710991710 6G-02/LastBill.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package Electricity;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

public class LastBill extends JFrame implements ActionListener{
JLabel l1;
JTextArea t1;
JButton b1;
Choice c1;
JPanel p1;
LastBill(){
setSize(500,900);
setLayout(new BorderLayout());

p1 = new JPanel();

l1 = new JLabel("Generate Bill");

c1 = new Choice();

c1.add("1001");
c1.add("1002");
c1.add("1003");
c1.add("1004");
c1.add("1005");
c1.add("1006");
c1.add("1007");
c1.add("1008");
c1.add("1009");
c1.add("1010");


t1 = new JTextArea(50,15);
JScrollPane jsp = new JScrollPane(t1);
t1.setFont(new Font("Senserif",Font.ITALIC,18));

b1 = new JButton("Generate Bill");

p1.add(l1);
p1.add(c1);
add(p1,"North");

add(jsp,"Center");
add(b1,"South");

b1.addActionListener(this);

setLocation(350,40);
}
public void actionPerformed(ActionEvent ae){
try{
conn c = new conn();

ResultSet rs = c.s.executeQuery("select * from emp where meter_number="+c1.getSelectedItem());

if(rs.next()){
t1.append("\n Customer Name:"+rs.getString("name"));
t1.append("\n Meter Number: "+rs.getString("meter_number"));
t1.append("\n Address: "+rs.getString("address"));
t1.append("\n State: "+rs.getString("state"));
t1.append("\n City: "+rs.getString("city"));
t1.append("\n Email: "+rs.getString("email"));
t1.append("\n Phone Number "+rs.getString("phone"));
t1.append("\n-------------------------------------------------------------");
t1.append("\n");
}

t1.append("Details of the Last Bills\n\n\n");

rs = c.s.executeQuery("select * from bill where meter_number="+c1.getSelectedItem());

while(rs.next()){
t1.append(" "+ rs.getString("month") + " " +rs.getString("amount") + "\n");
}






}catch(Exception e){
e.printStackTrace();
}
}

public static void main(String[] args){
new LastBill().setVisible(true);
}
}
97 changes: 97 additions & 0 deletions Samarth_1710991710 6G-02/Login.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package Electricity;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

public class Login extends JFrame implements ActionListener{
JLabel l1,l2,l3;
JTextField tf1;
JPasswordField pf2;
JButton b1,b2;
JPanel p1,p2,p3,p4;
Login(){
super("Login Page");

l1 = new JLabel("Username");
l2 = new JLabel("Password");
tf1 = new JTextField(15);
pf2 = new JPasswordField(15);

ImageIcon ic1 = new ImageIcon(ClassLoader.getSystemResource("icon/login.png"));
Image i1 = ic1.getImage().getScaledInstance(16, 16,Image.SCALE_DEFAULT);
b1 = new JButton("Login", new ImageIcon(i1));

ImageIcon ic2 = new ImageIcon(ClassLoader.getSystemResource("icon/cancel.jpg"));
Image i2 = ic2.getImage().getScaledInstance(16, 16,Image.SCALE_DEFAULT);
b2 = new JButton("Cancel",new ImageIcon(i2));

b1.addActionListener(this);
b2.addActionListener(this);


ImageIcon ic3 = new ImageIcon(ClassLoader.getSystemResource("icon/pop.png"));
Image i3 = ic3.getImage().getScaledInstance(128, 128,Image.SCALE_DEFAULT);
ImageIcon icc3 = new ImageIcon(i3);
l3 = new JLabel(icc3);

setLayout(new BorderLayout());


p1 = new JPanel();
p2 = new JPanel();
p3 = new JPanel();
p4 = new JPanel();


add(l3,BorderLayout.WEST);
p2.add(l1);
p2.add(tf1);
p2.add(l2);
p2.add(pf2);
add(p2,BorderLayout.CENTER);

p4.add(b1);
p4.add(b2);
add(p4,BorderLayout.SOUTH);

p2.setBackground(Color.WHITE);
p4.setBackground(Color.WHITE);


setSize(440,250);
setLocation(600,400);
setVisible(true);



}
public void actionPerformed(ActionEvent ae){

try{
conn c1 = new conn();
String a = tf1.getText();
String b = pf2.getText();
String q = "select * from login where username = '"+a+"' and password = '"+b+"'";
ResultSet rs = c1.s.executeQuery(q);
if(rs.next()){
new Project().setVisible(true);
this.setVisible(false);

}else{
JOptionPane.showMessageDialog(null, "Invalid login");
setVisible(false);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("error: "+e);
}
}

public static void main(String[] args){
new Login().setVisible(true);
}


}
Loading