Академический Документы
Профессиональный Документы
Культура Документы
java
public class Main {
new TPassword().setVisible(true);
// TPassword.java
private void btnClickActionPerformed(java.awt.event.ActionEvent evt) {
String PassW="SST";
if(p.equals(PassW))
{new StuMain().setVisible(true);
this.setVisible(false);
else
System.exit(0);
}
// StuMain.java
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
new TSave().setVisible(true);
this.setVisible(false);
System.exit(0);
new TNavigate().setVisible(true);
this.setVisible(false);
new DSave().setVisible(true);
this.setVisible(false);
new TUpdate().setVisible(true);
this.setVisible(false);
new TDelete().setVisible(true);
this.setVisible(false);
new TReport().setVisible(true);
this.setVisible(false);
new DNavigate().setVisible(true);
this.setVisible(false);
new DUpdate().setVisible(true);
this.setVisible(false);
new DDelete().setVisible(true);
this.setVisible(false);
new DReport().setVisible(true);
this.setVisible(false);
}
//TSave.java
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
rs = stmt.executeQuery(SQL);
while (rs.next()){
System.out.println(rs.getString("tname"));
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
new StuMain().setVisible(true);
this.setVisible(false);
txtTNo.setText("");
txtTName.setText("");
txtTsalary.setText("");
txtTdeptno.setText("");
}
//DSave.java
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
rs = stmt.executeQuery(SQL);
while (rs.next()){
System.out.println(rs.getString("tname"));
e.printStackTrace();
new StuMain().setVisible(true);
this.setVisible(false);
txtdno.setText("");
txtdname.setText("");
}
//TNavigate.java
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
rs = stmt.executeQuery(SQL);
rs.first();
txtTNo.setText(ntNo);
txtTName.setText(name);
txtTsalary.setText(""+ nSalary);
txtTdeptno.setText(ndept);
btnPrev.setEnabled(false);
btnLast.setEnabled(true);
btnNext.setEnabled(true);
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
txtTNo.setText(ntNo);
txtTName.setText(name);
txtTsalary.setText(""+ nSalary);
txtTdeptno.setText(ndept);
btnPrev.setEnabled(true);
btnLast.setEnabled(true);
btnFirst.setEnabled(true);
else{
JOptionPane.showMessageDialog(this,e.getMessage());
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
if(rs.previous()){
txtTNo.setText(ntNo);
txtTName.setText(name);
txtTsalary.setText(""+ nSalary);
txtTdeptno.setText(ndept);
btnNext.setEnabled(true);
btnLast.setEnabled(true);
btnFirst.setEnabled(true);
else{
JOptionPane.showMessageDialog(this,e.getMessage());
}
private void btnLastActionPerformed(java.awt.event.ActionEvent evt) {
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
if(rs.previous()){
txtTNo.setText(ntNo);
txtTName.setText(name);
txtTsalary.setText(""+ nSalary);
txtTdeptno.setText(ndept);
btnNext.setEnabled(false);
btnPrev.setEnabled(true);
btnFirst.setEnabled(false);
else{
JOptionPane.showMessageDialog(this,"You are at last record position","Teacher",0);
JOptionPane.showMessageDialog(this,e.getMessage());
txtTNo.setText("");
txtTName.setText("");
txtTsalary.setText("");
txtTdeptno.setText("");
new StuMain().setVisible(true);
this.setVisible(false);
}
//DNavigate.java
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
if(rs.previous())
txtdno.setText(DNo);
txtdname.setText(DName);
btnMNext.setEnabled(false);
btnMPrevious.setEnabled(true);
btnMFirst.setEnabled(false);
else{
JOptionPane.showMessageDialog(this,"You are at last record
position","DEPARTMENT",0);
JOptionPane.showMessageDialog(this,e.getMessage());
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
rs = stmt.executeQuery(SQL);
rs.first();
txtdno.setText(Dno);
txtdname.setText(Dname);
btnMPrevious.setEnabled(false);
btnMLast.setEnabled(true);
btnMNext.setEnabled(true);
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
txtdno.setText(Dno);
txtdname.setText(Dname);
btnMPrevious.setEnabled(true);
btnMLast.setEnabled(true);
btnMFirst.setEnabled(true);
else{
JOptionPane.showMessageDialog(this,e.getMessage());
ResultSet rs = null;
try
Class.forName("com.mysql.jdbc.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
if(rs.previous())
{
txtdno.setText(nDNO);
txtdname.setText(nDName);
btnMNext.setEnabled(true);
btnMLast.setEnabled(true);
btnMFirst.setEnabled(true);
else{
JOptionPane.showMessageDialog(this,e.getMessage());
txtdno.setText("");
txtdname.setText("");
new StuMain().setVisible(true);
this.setVisible(false);
}
//DUpdate.java
try
Class.forName("com.mysql.jdbc.Driver");
int rowsEffected=stmt.executeUpdate(strSQL);
if (rowsEffected== 0)
else
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
private void btnBTMActionPerformed(java.awt.event.ActionEvent evt) {
new StuMain().setVisible(true);
this.setVisible(false);
txtdno.enableInputMethods(false);
try
Class.forName("com.mysql.jdbc.Driver");
while(rs.next())
jList1.setModel(dModel);
con.close();
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
try
Class.forName("com.mysql.jdbc.Driver");
MDno= MDno.substring(0,3).trim();
txtdno.enableInputMethods(false);
while (rs.next())
txtdname.setText(DName);
catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
e.printStackTrace();
txtdno.setText("");
txtdname.setText("");
}
//TUpdate.java
new StuMain().setVisible(true);
this.setVisible(false);
try
Class.forName("com.mysql.jdbc.Driver");
int rowsEffected=stmt.executeUpdate(strSQL);
if (rowsEffected== 0)
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
txtNo.setText("");
txtName.setText("");
txtSal.setText("");
txtDept.setText("");
txtNo.enableInputMethods(false);
try
Class.forName("com.mysql.jdbc.Driver");
Connection con= (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "aps");
while(rs.next())
jList1.setModel(dModel);
con.close();
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
try
Class.forName("com.mysql.jdbc.Driver");
MTno= MTno.substring(0,3).trim();
txtNo.enableInputMethods(false);
while (rs.next())
txtNo.setText(tcode);
txtName.setText(name);
txtSal.setText("" + sal);
txtDept.setText(dept);
catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
e.printStackTrace();
}
//TDelete.java
try
Class.forName("com.mysql.jdbc.Driver");
int rowsEffected=stmt.executeUpdate(strSQL);
if (rowsEffected== 0)
else
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
txtNo.enableInputMethods(false);
try
Class.forName("com.mysql.jdbc.Driver");
while(rs.next())
jList1.setModel(dModel);
con.close();
e.printStackTrace();
try
Class.forName("com.mysql.jdbc.Driver");
MTno= MTno.substring(0,3).trim();
txtNo.enableInputMethods(false);
while (rs.next())
txtNo.setText(tcode);
txtName.setText(name);
txtSal.setText("" + sal);
txtDept.setText(dept);
catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
e.printStackTrace();
new StuMain().setVisible(true);
this.setVisible(false);
}
//DDelete.java
txtdno.enableInputMethods(false);
try
Class.forName("com.mysql.jdbc.Driver");
while(rs.next())
jList1.setModel(dModel);
con.close();
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
try
Class.forName("com.mysql.jdbc.Driver");
MDno= MDno.substring(0,3).trim();
txtdno.enableInputMethods(false);
while (rs.next())
txtdno.setText(nDNo);
txtdname.setText(nDName);
}
catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
e.printStackTrace();
try
Class.forName("com.mysql.jdbc.Driver");
int rowsEffected=stmt.executeUpdate(strSQL);
if (rowsEffected== 0)
else
e.printStackTrace();
new StuMain().setVisible(true);
this.setVisible(false);
}
//TReport.java
//Before writing the following line, you should import the line:
if(rows> 0)
model.removeRow(0);
//SQL Query
try
Class.forName("com.mysql.jdbc.Driver").newInstance();
while(rs.next())
catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
new StuMain().setVisible(true);
this.setVisible(false);
}
//DReport.java
//Before writing the following line, you should import the line:
if(rows> 0)
model.removeRow(0);
//SQL Query
try
Class.forName("com.mysql.jdbc.Driver").newInstance();
while(rs.next())
catch (Exception e)
JOptionPane.showMessageDialog(this, e.getMessage());
new StuMain().setVisible(true);
this.setVisible(false);