Вы находитесь на странице: 1из 45

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/

/**
*
* @author DUGGAL
*/
import java.io.File;
import java.util.List;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class login extends javax.swing.JFrame {

/**
* Creates new form login
*/
public login() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

f1 = new javax.swing.JFrame();
jLabel3 = new javax.swing.JLabel();
rb1 = new javax.swing.JRadioButton();
rb2 = new javax.swing.JRadioButton();
rb3 = new javax.swing.JRadioButton();
jButton2 = new javax.swing.JButton();
sc = new javax.swing.JFrame();
jButton4 = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
l1 = new javax.swing.JList();
classandsec = new javax.swing.JFrame();
jScrollPane4 = new javax.swing.JScrollPane();
l3 = new javax.swing.JList();
jScrollPane5 = new javax.swing.JScrollPane();
l4 = new javax.swing.JList();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
xi = new javax.swing.JFrame();
c1u1 = new javax.swing.JRadioButton();
mt = new javax.swing.JRadioButton();
c2u2 = new javax.swing.JRadioButton();
fi = new javax.swing.JRadioButton();
jButton5 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
b1 = new javax.swing.ButtonGroup();
csvfile = new javax.swing.JFrame();
fc1 = new javax.swing.JFileChooser();
jButton6 = new javax.swing.JButton();
com = new javax.swing.JFrame();
jButton7 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
l2 = new javax.swing.JList();
art = new javax.swing.JFrame();
jButton8 = new javax.swing.JButton();
jScrollPane6 = new javax.swing.JScrollPane();
li3 = new javax.swing.JList();
tbl = new javax.swing.JFrame();
jScrollPane1 = new javax.swing.JScrollPane();
tb1 = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
tf1 = new javax.swing.JTextField();
pf1 = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();

f1.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel3.setText("SELECT STREAM");

rb1.setText("SCIENCE");

rb2.setText("COMMERCE");
rb2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rb2ActionPerformed(evt);
}
});

rb3.setText("HUMANITIES");

jButton2.setText("NEXT");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

javax.swing.GroupLayout f1Layout = new javax.swing.GroupLayout(f1.getContentPane());
f1.getContentPane().setLayout(f1Layout);
f1Layout.setHorizontalGroup(
f1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(f1Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(f1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 91,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(f1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(f1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(rb2)
.addComponent(rb1)
.addComponent(rb3)
.addComponent(jButton2))))
.addContainerGap(461, Short.MAX_VALUE))
);
f1Layout.setVerticalGroup(
f1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(f1Layout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rb1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rb2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rb3)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addContainerGap(184, Short.MAX_VALUE))
);

sc.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton4.setText("NEXT");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

l1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "english", "Phy", "Chem", "Bio", "math", "info", "ped", "Biotech", "economics",
"hindi" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
l1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
l1ValueChanged(evt);
}
});
jScrollPane3.setViewportView(l1);

javax.swing.GroupLayout scLayout = new javax.swing.GroupLayout(sc.getContentPane());
sc.getContentPane().setLayout(scLayout);
scLayout.setHorizontalGroup(
scLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(scLayout.createSequentialGroup()
.addGroup(scLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(scLayout.createSequentialGroup()
.addGap(132, 132, 132)
.addComponent(jButton4))
.addGroup(scLayout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 117,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(211, Short.MAX_VALUE))
);
scLayout.setVerticalGroup(
scLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(scLayout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 188,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton4)
.addContainerGap(29, Short.MAX_VALUE))
);

classandsec.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

l3.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "xi", "xii" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
l3.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane4.setViewportView(l3);

l4.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "A", "B", "C", "D", "E", "F", "G" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
l4.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jScrollPane5.setViewportView(l4);

jLabel6.setText("CLASS");

jLabel7.setText("SECTION");

jButton3.setText("NEXT");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

javax.swing.GroupLayout classandsecLayout = new
javax.swing.GroupLayout(classandsec.getContentPane());
classandsec.getContentPane().setLayout(classandsecLayout);
classandsecLayout.setHorizontalGroup(
classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(classandsecLayout.createSequentialGroup()

.addGroup(classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(classandsecLayout.createSequentialGroup()

.addGroup(classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(classandsecLayout.createSequentialGroup()
.addGap(105, 105, 105)
.addComponent(jLabel6))
.addGroup(classandsecLayout.createSequentialGroup()
.addGap(94, 94, 94)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(66, 66, 66)

.addGroup(classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(classandsecLayout.createSequentialGroup()
.addGap(154, 154, 154)
.addComponent(jButton3)))
.addContainerGap(208, Short.MAX_VALUE))
);
classandsecLayout.setVerticalGroup(
classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(classandsecLayout.createSequentialGroup()
.addGap(30, 30, 30)

.addGroup(classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(classandsecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 52,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(35, 35, 35)
.addComponent(jButton3)
.addContainerGap(85, Short.MAX_VALUE))
);

xi.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

b1.add(c1u1);
c1u1.setText("ct1ut1");

b1.add(mt);
mt.setText("midterm");

b1.add(c2u2);
c2u2.setText("ct2ut2");

b1.add(fi);
fi.setText("finals");

jButton5.setText("make table");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton9.setText("next");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});

javax.swing.GroupLayout xiLayout = new javax.swing.GroupLayout(xi.getContentPane());
xi.getContentPane().setLayout(xiLayout);
xiLayout.setHorizontalGroup(
xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, xiLayout.createSequentialGroup()
.addContainerGap(111, Short.MAX_VALUE)
.addGroup(xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, xiLayout.createSequentialGroup()
.addComponent(jButton5)
.addGap(108, 108, 108)
.addGroup(xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(fi)
.addComponent(c2u2))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(c1u1)
.addComponent(mt)))
.addGap(33, 33, 33))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, xiLayout.createSequentialGroup()
.addComponent(jButton9)
.addGap(77, 77, 77))))
);
xiLayout.setVerticalGroup(
xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(xiLayout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(c1u1)
.addGroup(xiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(xiLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(mt)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(c2u2))
.addGroup(xiLayout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jButton5)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(fi)
.addGap(96, 96, 96)
.addComponent(jButton9)
.addContainerGap(43, Short.MAX_VALUE))
);

csvfile.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

fc1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fc1ActionPerformed(evt);
}
});

jButton6.setText("NEXT");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

javax.swing.GroupLayout csvfileLayout = new javax.swing.GroupLayout(csvfile.getContentPane());
csvfile.getContentPane().setLayout(csvfileLayout);
csvfileLayout.setHorizontalGroup(
csvfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(csvfileLayout.createSequentialGroup()
.addContainerGap()
.addComponent(fc1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton6)
.addContainerGap(26, Short.MAX_VALUE))
);
csvfileLayout.setVerticalGroup(
csvfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, csvfileLayout.createSequentialGroup()
.addGap(0, 14, Short.MAX_VALUE)
.addComponent(fc1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(csvfileLayout.createSequentialGroup()
.addGap(139, 139, 139)
.addComponent(jButton6)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

com.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton7.setText("next");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

l2.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "bst", "english", "economics", "info", "ped", "hindi", "maths", "accounts" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane2.setViewportView(l2);

javax.swing.GroupLayout comLayout = new javax.swing.GroupLayout(com.getContentPane());
com.getContentPane().setLayout(comLayout);
comLayout.setHorizontalGroup(
comLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, comLayout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 98,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51,
Short.MAX_VALUE)
.addComponent(jButton7)
.addGap(124, 124, 124))
);
comLayout.setVerticalGroup(
comLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, comLayout.createSequentialGroup()
.addContainerGap(37, Short.MAX_VALUE)
.addGroup(comLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 183,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton7))
.addGap(80, 80, 80))
);

art.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton8.setText("next");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

li3.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "phsycology", "history", "english", "ped", "hindi", "info", "maths", "economics"
};
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane6.setViewportView(li3);

javax.swing.GroupLayout artLayout = new javax.swing.GroupLayout(art.getContentPane());
art.getContentPane().setLayout(artLayout);
artLayout.setHorizontalGroup(
artLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, artLayout.createSequentialGroup()
.addGap(64, 64, 64)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 86,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33,
Short.MAX_VALUE)
.addComponent(jButton8)
.addGap(162, 162, 162))
);
artLayout.setVerticalGroup(
artLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(artLayout.createSequentialGroup()
.addContainerGap(53, Short.MAX_VALUE)
.addGroup(artLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
artLayout.createSequentialGroup()
.addComponent(jButton8)
.addGap(88, 88, 88))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
artLayout.createSequentialGroup()
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 205,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42))))
);

tbl.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
tbl.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
tblWindowOpened(evt);
}
});

tb1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {

},
new String [] {
"rank", "rno", "name", "percentage"
}
));
jScrollPane1.setViewportView(tb1);

javax.swing.GroupLayout tblLayout = new javax.swing.GroupLayout(tbl.getContentPane());
tbl.getContentPane().setLayout(tblLayout);
tblLayout.setHorizontalGroup(
tblLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(tblLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 733,
Short.MAX_VALUE)
.addContainerGap())
);
tblLayout.setVerticalGroup(
tblLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(tblLayout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 337,
Short.MAX_VALUE))
);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});

jLabel1.setText("User-ID");

jLabel2.setText("Password");

jButton1.setText("LOGIN");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(90, 90, 90)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addGap(45, 45, 45)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE, 95,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pf1, javax.swing.GroupLayout.PREFERRED_SIZE, 129,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(135, 135, 135)
.addComponent(jButton1)))
.addContainerGap(160, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(62, 62, 62)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(tf1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(pf1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(45, 45, 45)
.addComponent(jButton1)
.addContainerGap(160, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

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

try
{ //Class.forName("java.sql.Driver");
// con= DriverManager.getConnection("jdbc:mysql://localhost/school","root","colton");
//stmt=con.createStatement();

String uid=tf1.getText();
String pas=new String(pf1.getPassword());
int j=1;
String q="Select* from login where user_id = '"+uid+"';";
ResultSet rs=stmt2.executeQuery(q);
System.out.print("logdin");
if( rs.next())
{
String pass=rs.getString("password");
if(pas.equals(pass))
{
System.out.print("pass corr");
System.out.print(""+rs.getString("classandsec")+rs.getString("classandsec").equalsIgnoreCase("0"));
if(rs.getString("classandsec").equalsIgnoreCase("0"))
{ f1.setVisible(true);
f1.setSize(400,400);
this.dispose();}
else
{ xi.setVisible(true);
xi.setSize(400,400);
this.dispose();
}
}
else
j=0;
}
else
j=0;

if(j==0)
JOptionPane.showMessageDialog(null,"Incorrect user_id or password. Please check for capital and
small letters and retry","ERROR",JOptionPane.ERROR_MESSAGE);

}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
if(rb1.isSelected())
{sc.setVisible(true);
sc.setSize(400,400);
f1.dispose();
}
if(rb2.isSelected())
{com.setVisible(true);
com.setSize(400,400);
f1.dispose();
}
if(rb3.isSelected())
{art.setVisible(true);
art.setSize(400,400);
f1.dispose();
}
}
Statement stmt;
Connection con;
Statement stmt2;
Connection con2;
private void formWindowOpened(java.awt.event.WindowEvent evt) {
try
{Class.forName("java.sql.Driver");
con2=DriverManager.getConnection("jdbc:mysql://localhost/school","root","colton");
stmt2=con2.createStatement();
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());
}


}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
try
{Object [] s1
=l1.getSelectedValues();
int len=s1.length;
int j=1;
for(int i=0;i<len;i++)
{String usid=tf1.getText();
String s2=(String)s1[i];
String comp=("sub").concat(""+j);

String q2="Update login set " +comp+" = "+"'"+s2+"'"+" where user_id= "+"'"+usid+"'"+";";

stmt2.executeUpdate(q2);
j++;

}
classandsec.setVisible(true);
classandsec.setSize(400,400);
sc.dispose();
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}

}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try
{ String cl=(String)l3.getSelectedValue();
String sec=(String)l4.getSelectedValue();
String clandsec=cl.concat(sec);
String usid=tf1.getText();
String q1="Update login set classandsec="+"'"+clandsec+"'"+"where user_id="+"'"+usid+"'"+";";
stmt2.executeUpdate(q1);



}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}
int ind=l3.getSelectedIndex();
xi.setVisible(true);
xi.setSize(400,400);
classandsec.dispose();


}
String x1="";
String x2="";
String x3="";
String x4="";
String x5="";
String x6="";
String x7="";
String x8="";
String dh="";
String yac="";
String yau="";
String ybc="";
String ybu="";
String ycc="";
String ycu="";
String ydc="";
String ydu="";
String ygc="";
String ygu="";
String yhc="";
String yhu="";
String yec="";
String yeu="";
String yfc="";
String yfu="";
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

try
{ String usid=tf1.getText();
String a="Select* from login where user_id='"+usid+"' ;";
ResultSet rs=stmt2.executeQuery(a);
if(rs.next())
{ x1=rs.getString("sub1");
yac=x1.concat("ct");
yau=x1.concat("ut");
x2=rs.getString("sub2");
ybc=x2.concat("ct");
ybu=x2.concat("ut");
x3=rs.getString("sub3");
ycc=x3.concat("ct");
ycu=x3.concat("ut");
x4=rs.getString("sub4");
ydc=x4.concat("ct");
ydu=x4.concat("ut");
x5=rs.getString("sub5");
yec=x5.concat("ct");
yeu=x5.concat("ut");
x6=rs.getString("sub6");
yfc=x6.concat("ct");
yfu=x6.concat("ut");
x7=rs.getString("sub7");
if(x7.equalsIgnoreCase("0")==false)
{
ygc=x7.concat("ct");
ygu=x7.concat("ut");
}
x8=rs.getString("sub8");
if(x8.equalsIgnoreCase("0")==false)
{
yhc=x8.concat("ct");
yhu=x8.concat("ut");
}
dh=rs.getString("classandsec");}
if(c1u1.isSelected())
{
tablename="ct1ut1";
}
if(c2u2.isSelected())
{
tablename="ct2ut2";
}
if(fi.isSelected())
{
tablename="finals";
}
if(mt.isSelected())
{
tablename="midterms";
}
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/"+dh,"root","colton");
stmt=con.createStatement();
String b;
b="Create table "+tablename+"(r_no int(3) ,name varchar(50), "+yac+" double(4,2), " +yau+ "
double(4,2),"+ybc+""
+ " double(4,2),"+ybu+" double(4,2),"+ycc+" double(4,2),"+ ycu+" double(4,2),"+ydc+"
double(4,2),"+ydu+" "
+ "double(4,2),"+yec+" double(4,2),"+yeu+" double(4,2),"+yfc+" double(4,2),"+yfu+" double(4,2),
"+ygc+" double(4,2), " +ygu+ " double(4,2),"+yhc+""
+ " double(4,2),"+yhu+" double(4,2));";
stmt.execute(b);
csvfile.setVisible(true);
csvfile.setSize(800,400);
xi.dispose();
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());
}
}

private void l1ValueChanged(javax.swing.event.ListSelectionEvent evt) {

}
String tablename="";
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
dh="";
File f=fc1.getSelectedFile();
String fname=f.getAbsolutePath();
String p2="";
for(int i=0; i< fname.length(); i++)
{char ch=fname.charAt(i);
if(ch=='\\')

p2=p2+ch+"\\";
else
p2=p2+ch;
}
System.out.println(p2);


try
{ String usid=tf1.getText();
String a="Select* from login where user_id="+"'"+usid+"'"+";";
ResultSet rs=stmt2.executeQuery(a);
if(rs.next())
{ dh=rs.getString("classandsec");

}
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}
try
{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/"+dh,"root","colton");
stmt=con.createStatement();
String q="delete from "+tablename +";";
stmt.execute(q);
q="load data local infile \""+p2+
" \" into table "+tablename +" fields terminated by\",\"enclosed by \",\" lines terminated by
\'\r\n';";
stmt.execute(q);
q="delete from "+tablename +" where name='name' or name is null";
stmt.execute(q);
q="alter table "+tablename +" add column total double(5,2);";
stmt.execute(q);
q="alter table "+tablename +" add column per double(5,2);";
stmt.execute(q);
q="alter table "+tablename +" add column rank int(2) unique;";
stmt.execute(q);
q="alter table "+tablename +" add column cttot double(5,2);";
stmt.execute(q);
tbl.setVisible(true);
tbl.setSize(1000,600);
csvfile.dispose();
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}
}

private void rb2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
try
{Object [] s1
=li3.getSelectedValues();
int len=s1.length;
int j=1;
for(int i=0;i<len;i++)
{String usid=tf1.getText();
String s2=(String)s1[i];
String comp=("sub").concat(""+j);

String q2="Update login set " +comp+" = "+"'"+s2+"'"+" where user_id= "+"'"+usid+"'"+";";

stmt2.executeUpdate(q2);
j++;

}
classandsec.setVisible(true);
classandsec.setSize(400,400);
art.dispose();
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}
// TODO add your handling code here:
}

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
try
{Object [] s1
=l2.getSelectedValues();
int len=s1.length;
int j=1;
for(int i=0;i<len;i++)
{String usid=tf1.getText();
String s2=(String)s1[i];
String comp=("sub").concat(""+j);

String q2="Update login set " +comp+" = "+"'"+s2+"'"+" where user_id= "+"'"+usid+"'"+";";

stmt2.executeUpdate(q2);
j++;

}
classandsec.setVisible(true);
classandsec.setSize(400,400);
com.dispose();
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage());

}
// TODO add your handling code here:
}

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
if(c1u1.isSelected())
{
tablename="ct1ut1";
}
if(c2u2.isSelected())
{
tablename="ct2ut2";
}
if(fi.isSelected())
{
tablename="finals";
}
if(mt.isSelected())
{
tablename="midterms";
}

tbl.setVisible(true);
tbl.setSize(1000,600);
xi.dispose();
}

private void fc1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

private void tblWindowOpened(java.awt.event.WindowEvent evt) {
try {
Class.forName("java.sql.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost/"+dh,"root","colton");
stmt=con.createStatement();
String q;
stmt.execute("update "+tablename +" set
total="+yau+"+"+ycu+"+"+ybu+"+"+ydu+"+"+yeu+"+"+yfu+";");

stmt.execute("update "+tablename +" set cttot="+yac+"+"+ycc+"+"+ybc+"+"+ydc+"+"+yec+"+"+yfc+";");

if(c1u1.isSelected())
{
stmt.execute("update "+tablename +" set per=(total*100)/250;");

}
if(c2u2.isSelected())
{
stmt.execute("update "+tablename +" set per=(total*100)/250;");

}
if(fi.isSelected())
{
stmt.execute("update "+tablename +" set per=(total*100)/500;");

}
if(mt.isSelected())
{
stmt.execute("update "+tablename +" set per=(total*100)/500;");

}
q="select * from "+tablename +";";
ResultSet rs2=stmt.executeQuery(q);
int lrno=0;
while(rs2.next())
lrno=rs2.getInt("r_no");

q="select * from "+tablename +" order by per desc;";
//System.out.println("order");
ResultSet rs=stmt.executeQuery(q);
//Statement stmt2=stmt;
int i=1;
String w="";
char x=' ';
while(rs.next())
{
w=w+rs.getInt("r_no")+",";

}
String d="";
int y=0;
long j=w.length();
//System.out.println(j);
w=w+" ";
while(i<=lrno)
{
// System.out.println(w+""+i);

while (x!=',')
{
d=(d+x).trim();
x=w.charAt(y);
y++;
//System.out.println(y);
//System.out.println(d+""+y);

}
stmt.execute("update "+tablename+" set rank ="+i+" where r_no="+d+";");
//System.out.println("rnk"+i);

i++;
d="";
x=0;
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e.getMessage());
}
DefaultTableModel dt=(DefaultTableModel)tb1.getModel();
try{

String q="select * from "+tablename+" order by rank;";
ResultSet rs=stmt.executeQuery(q);
while(rs.next())
{
n=rs.getString("name");
no=rs.getInt("r_no");
m=rs.getInt("per");
r=rs.getInt("rank");
Object row[]={r,no,n,m,r};
dt.addRow(row);
}
}
catch(Exception e)
{
javax.swing.JOptionPane.showMessageDialog(null, e.getMessage());
} // TODO add your handling code here:
}
String n;
int no,r;
int m;
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JFrame art;
private javax.swing.ButtonGroup b1;
private javax.swing.JRadioButton c1u1;
private javax.swing.JRadioButton c2u2;
private javax.swing.JFrame classandsec;
private javax.swing.JFrame com;
private javax.swing.JFrame csvfile;
private javax.swing.JFrame f1;
private javax.swing.JFileChooser fc1;
private javax.swing.JRadioButton fi;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JList l1;
private javax.swing.JList l2;
private javax.swing.JList l3;
private javax.swing.JList l4;
private javax.swing.JList li3;
private javax.swing.JRadioButton mt;
private javax.swing.JPasswordField pf1;
private javax.swing.JRadioButton rb1;
private javax.swing.JRadioButton rb2;
private javax.swing.JRadioButton rb3;
private javax.swing.JFrame sc;
private javax.swing.JTable tb1;
private javax.swing.JFrame tbl;
private javax.swing.JTextField tf1;
private javax.swing.JFrame xi;
// End of variables declaration
}

Вам также может понравиться