Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

ROAD REPAIR SYSTEM

==

LOGIN FORM

CODE for Login Button


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String username,password; username=jTextField1.getText(); password=jPasswordField1.getText(); if (password.equals("00000")) {new form3().setVisible(true); JOptionPane.showMessageDialog(this, username + " Welcome to the portal"); jTextField1.setText(""); jPasswordField1.setText(""); dispose();

} else JOptionPane.showMessageDialog(this,"INVALID PASSWORD");

CODE for Reset Button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { jTextField1.setText(""); jPasswordField1.setText("");

CODE for Complaint Button

new form2().setVisible(true); dispose();

CODE for About Us Button


private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { new Form7().setVisible(true); dispose();

CODE for Feedback Button

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { new FORM6().setVisible(true) dispose();

==

COMPLAINT FORM

CODE for SUBMIT Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { String Name=jTextField1.getText(); String Area=(String) jComboBox1.getSelectedItem(); String Address=(String) jComboBox2.getSelectedItem(); String Details=(String) jComboBox3.getSelectedItem(); String Specific_Address=jTextField2.getText();

String Priority; if (Name.isEmpty()) JOptionPane.showMessageDialog(this,"Name not Entered."); else if (Address.isEmpty()) JOptionPane.showMessageDialog(this,"Address not Entered."); else if (Area.isEmpty()) JOptionPane.showMessageDialog(this,"Area not Selected."); else if (Specific_Address.isEmpty()) JOptionPane.showMessageDialog(this,"Please Give a Specific Address."); else if (Details.isEmpty()) JOptionPane.showMessageDialog(this,"Details not Entered."); if (jComboBox1.getSelectedIndex()==2) { Priority="High"; } else if(jComboBox1.getSelectedIndex()==1) { Priority="Medium"; } else { Priority="Low"; } { try {Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement();

String query="INSERT INTO complaint VALUES('"+0+"','"+Name+"','"+Area+"','"+Address+"','"+Specific_Address+"','"+Details+"','"+Priority+"');"; stmt.executeUpdate(query); JOptionPane.showMessageDialog(this,"Complaint successfully filed. \n Immediate action would be taken");

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

==

COMPLAINT DATABASE

SHOW COMPLAINTS Button


Supervision Window Opens

CODE for GENERATE Button


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int sno; sno=Integer.parseInt(jTextField3.getText());

try {

Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String Complaint; Complaint="Complaint"; String query="SELECT Name,Area,Address,Specific_Address,Details From "+Complaint+" where SNo="+sno+";"; ResultSet rs=stmt.executeQuery(query); if (rs.next()) { String Details=rs.getString("Details"); String Name=rs.getString("Name"); String Area=rs.getString("Area"); String Address=rs.getString("Address"); String Specific_Address=rs.getString("Specific_Address");

jTextField1.setText(Name); jTextField2.setText(Area); jTextField6.setText(Address); jTextField7.setText(Specific_Address); jTextField8.setText(Details); } else {JOptionPane.showMessageDialog(this,"Complaint Number not valid."); jTextField3.setText(""); jTextField1.setText(""); jTextField2.setText(""); jTextField3.setText(""); jTextField6.setText("");

jTextField7.setText(""); jTextField8.setText(""); } } catch(Exception e) { } JOptionPane.showMessageDialog(this,e.getMessage());

CODE for SUBMIT Button

int ComplaintNo=Integer.parseInt(jTextField3.getText()); int No=Integer.parseInt(jTextField5.getText()); double Cost=Double.parseDouble(jTextField4.getText()); int Time=Integer.parseInt(jTextField9.getText()); try {Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String query="INSERT INTO r1 VALUES('"+ComplaintNo+"','"+Cost+"','"+No+"','"+Time+"');";

stmt.executeUpdate(query); JOptionPane.showMessageDialog(this,"Complaint added to portal."); new form3().setVisible(true); } catch(Exception e) { JOptionPane.showMessageDialog(this,e.getMessage()); } dispose();

ESTIMATION Button
ESTIMATION Window Opens

CODE for SHOW Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int sno; sno=Integer.parseInt(jTextField3.getText()); try { Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String query="SELECT Cost,No,Time From r1 where ComplaintNo='"+sno+"';"; ResultSet rs=stmt.executeQuery(query);

if (rs.next()) { String Cost=rs.getString("Cost"); String No=rs.getString("No"); String Time=rs.getString("Time"); jTextField4.setText(Cost); jTextField5.setText(No); jTextField9.setText(Time); } else { JOptionPane.showMessageDialog(this,"Complaint Number not valid."); }} catch(Exception e) { JOptionPane.showMessageDialog(this,e.getMessage()); }

CODE for FIRST Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String query="SELECT ComplaintNo,Cost,No,Time From r1"; ResultSet rs=stmt.executeQuery(query); if (rs.first()) { String ComplaintNo=rs.getString("ComplaintNo"); String Cost=rs.getString("Cost"); String No=rs.getString("No"); String Time=rs.getString("Time"); jTextField3.setText(ComplaintNo);

jTextField4.setText(Cost); jTextField5.setText(No); jTextField9.setText(Time); } } catch(Exception e) { JOptionPane.showMessageDialog(this,e.getMessage()); }

CODE for LAST Button

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { try { Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String query="SELECT ComplaintNo,Cost,No,Time From r1"; ResultSet rs=stmt.executeQuery(query); if (rs.last()) { String ComplaintNo=rs.getString("ComplaintNo"); String Cost=rs.getString("Cost"); String No=rs.getString("No"); String Time=rs.getString("Time"); jTextField3.setText(ComplaintNo); jTextField4.setText(Cost); jTextField5.setText(No); jTextField9.setText(Time); } } catch(Exception e) {

JOptionPane.showMessageDialog(this,e.getMessage()); }

CODE for NEXT Button

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { int ComplaintNo; ComplaintNo=Integer.parseInt(jTextField3.getText()); try { ComplaintNo=ComplaintNo+1; Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String query="SELECT ComplaintNo,Cost,No,Time from r1 where ComplaintNo='"+ComplaintNo+"';"; ResultSet rs=stmt.executeQuery(query); if(rs.next()) { String Cost=rs.getString("Cost"); String No=rs.getString("No"); String Time=rs.getString("Time"); jTextField4.setText(Cost); jTextField5.setText(No); jTextField9.setText(Time); jTextField3.setText(Integer.toString(ComplaintNo)); } else { JOptionPane.showMessageDialog(null,"End of list."); }} catch(Exception e) { JOptionPane.showMessageDialog(this,e.getMessage());

CODE for PREVIOUS Button

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) { int ComplaintNo; ComplaintNo=Integer.parseInt(jTextField3.getText()); try { ComplaintNo=ComplaintNo-1; Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String query="SELECT ComplaintNo,Cost,No,Time from r1 where ComplaintNo='"+ComplaintNo+"';"; ResultSet rs=stmt.executeQuery(query); if(rs.next()) { String Cost=rs.getString("Cost"); String No=rs.getString("No"); String Time=rs.getString("Time"); jTextField4.setText(Cost); jTextField5.setText(No); jTextField9.setText(Time); jTextField3.setText(Integer.toString(ComplaintNo)); } else { JOptionPane.showMessageDialog(null,"Start of list."); } }

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

FEEDBACK Button
Feedback Window Opens

CODE for SHOW Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { { DefaultTableModel model=(DefaultTableModel) jTable1.getModel(); try { Class.forName("java.sql.DriverManager"); Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","2013"); Statement stmt=(Statement) con.createStatement(); String feedback; feedback="feedback";

String query="SELECT SNo, FEEDBACK From "+feedback+";"; ResultSet rs=stmt.executeQuery(query); while(rs.next()) { String FEEDBACK=rs.getString("FEEDBACK"); String SNo=rs.getString("SNo");

model.addRow(new Object[]{SNo,FEEDBACK}); } } catch(Exception e) { JOptionPane.showMessageDialog(this,e.getMessage()); } }

CODE for EXIT Button

new form3().setVisible(true); dispose();

FROM FORM 1

ABOUT US Button
About Us Window Opens

You might also like