Javad 5
Javad 5
Javad 5
JFrame {
/**
* Creates new form student
*/
public student() {
initComponents();
Connect();
Load_Class();
Load_Section();
Student_load();
}
Connection con;
PreparedStatement pst;
ResultSet rs;
DefaultTableModel d;
{
try {
pst = con.prepareStatement("select Distinct classname from class");
rs = pst.executeQuery();
txtclass.removeAllItems();
while(rs.next())
{
txtclass.addItem(rs.getString("classname"));
}
} catch (SQLException ex) {
Logger.getLogger(Exam.class.getName()).log(Level.SEVERE, null, ex);
}
}
while (rs.next()) {
txtsection.addItem(rs.getString("section"));
}
} catch (SQLException ex) {
Logger.getLogger(Exam.class.getName()).log(Level.SEVERE, null, ex);
}
}
d = (DefaultTableModel) jTable1.getModel();
d.setRowCount(0);
while (rs.next()) {
Vector v2 = new Vector();
for (int i = 1; i <= c; i++) {
v2.add(rs.getString("id"));
v2.add(rs.getString("stname"));
v2.add(rs.getString("pname"));
v2.add(rs.getString("dob"));
v2.add(rs.getString("gender"));
v2.add(rs.getString("phone"));
v2.add(rs.getString("address"));
v2.add(rs.getString("class"));
v2.add(rs.getString("section"));
}
d.addRow(v2); // Ajouter la ligne au modèle de tableau
}
/**
* 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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setText("Student Name");
jLabel3.setText("Parent Name");
jLabel4.setText("Date of Birth");
jLabel5.setText("Gender");
jLabel6.setText("Phone");
jLabel7.setText("Address");
jLabel8.setText("Class");
jLabel9.setText("Section");
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel9))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtdob, javax.swing.GroupLayout.DEFAULT_SIZE, 197,
Short.MAX_VALUE)
.addComponent(txtgender, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(txtphone)
.addComponent(txtaddress)
.addComponent(txtclass, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(txtsection, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtstname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(txtpname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(txtdob, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(txtgender, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtphone, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtaddress, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(txtclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(14, 14, 14)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(14, Short.MAX_VALUE))
);
},
new String [] {
"StID", "Stname", "Prarentname", "Dob", "Gender", "Phone", "Address", "Class", "Section"
}
){
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class,
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class,
java.lang.Object.class
};