ALIEN IT PROJECT - Edited - Edited
ALIEN IT PROJECT - Edited - Edited
BISHNUPUR,MANIPUR
PROJECT ON INFORMATION
TECHNOLOGY
Guided by : Countersigned by
K. Kuber Singh Principal
PGT Computer Science JNV Bishnupur
JNV Bishnupur
Contents
1 Acknowledgement 1
2 Introduction 2
3 Login Form 3
4 Registration form 4
5 Main Menu 5
10 Conclusion 10
Acknowledgement
First we would like to express our special thanks of
gratitude to our principal as well as to our teacher Sir K.
Kuber Singh, PGT Computer Science who give us golden
opportunity to do this Project “STATE CITY INFORMATION
SYSTEM” which help us a lot in doing this project. We are
really thankful to them.
1. Login form
2. To create new ID.
3. Main menu of the project
a. To add new city
b. To display all data
c. To delete record.
The user is free to use the above mentioned forms and access data
according to his/her convenient. Adding new record of City accordingly
display all the information of city and delete data from City-State record
can be done very easily.
In the above login page there is one textfield (tf1) in which the user
should write their respected if and there is also a password field(p1) to write
their password. After completing, the user should click OK which brings the
user to the next page and if the user wants to clear the written id and
password he/she should press Reset. If the account is not registered the user
should click new user.
Try
{
Strings = uidtf.getText();
String pwd = new String(pf.getPassword());
Class.forName("java.sql.Driver");
Connection con;
con = DriverManager.getConnection ("jdbc:mysql://localhost/
jnvbpr","root","kvuc");
Statement stmt;
stmt = con.createStatement();
ResultSet rs;
rs= stmt.executeQuery("SELECT * FROM USERID WHERE USER_ID=
'"+uidtf.getText()+"';");
String s1;
//int n1=pdt.executeUpdate();
if( rs.next())
{
if(pwd.equals(rs.getString("password")))
{
this.setVisible(false);
new main_menu().setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null,"Password Miismatch
Try
again");
pf.setText("");
}
//ResultSet rs;
// stmt.executeUpdate(query);
// rs = stmt.executeUpdate(query);
// rs.close();
stmt.close();
con.close();
}
else
JOptionPane.showMessageDialog(null," User name Not found");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error occured");
// TODO add your handling code here:
}
}
import java.sql.*;
import javax.swing.JOptionPane;
String un = untf.getText();
String p1 = new String(pf1.getPassword());
String p2 = new String(pf2.getPassword());
if(p1.equals(p2))
{
Try
{
Class.forName("java.sql.Driver");
Connection con;
con =
DriverManager.getConnection("jdbc:mysql://localhost/jnvbpr","root
","kvuc");
Statement stmt;
stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO USERID VALUES( "+" "+"'"
+un+"'"+","+" "+"'" +p1+"'"+");");
stmt.close();
con.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error occured");
// TODO add your handling code here:
}
}
else
JOptionPane.showMessageDialog(null, "Password Mismatch ");
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new reg().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton backbt;
private javax.swing.JButton exitbt;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPasswordField pf1;
private javax.swing.JPasswordField pf2;
private javax.swing.JButton rgbt;
private javax.swing.JTextField untf;
// End of variables declaration
}
MAIN MENU OF CITY –STATE INFORMATION
In the above interface there are three radio buttons namely add new
city(rb1), display(rb2), remove(rb3). Moreover there are three buttons OK,
CANCEL and EXIT.
/**
* Creates new form main_menu
*/
public main_menu()
{
initComponents();
}
private void okbt2ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
if(rbadd.isSelected())
{
new Add().setVisible(true);
this.setVisible(false);
}
if(rbdis.isSelected())
{
new Display().setVisible(true);
this.setVisible(false);
}
if(rbrev.isSelected())
{
new remove().setVisible(true);
this.setVisible(false);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new main_menu().setVisible(true);
}
});
}
}
ADD NEW CITY FORM
/**
* Creates new form Add
*/
public Add()
{
initComponents();
}
private void submitbtActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
Try
{
Class.forName("java.sql.Driver");
Connection con;
con =
DriverManager.getConnection("jdbc:mysql://localhost/jnvbpr","root","kvuc
");
Statement stmt;
stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO CITY VALUES("+"'" + stf.getText() + "'"+",
"+"
"+"'" +ctf.getText() +"'"+", "+" '" +ptf.getText()+"', "+" "+ltf.getText()+");");
stmt.close();
con.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error occured");
// TODO add your handling code here:
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new Add().setVisible(true);
}
});
}
}
DISPLAY RECORD FRAME
DefaultTableModel model;
model = (DefaultTableModel)depTbl.getModel();
try
{
Class.forName("java.sql.Driver");
Connection con;
con =
DriverManager.getConnection("jdbc:mysql://localhost/jnvbpr","root","kvuc
");
Statement stmt;
stmt = con.createStatement();
String query = "SELECT * FROM CITY ORDER BY STATE;";
ResultSet rs;
rs = stmt.executeQuery(query);
while(rs.next())
{
String cn = rs.getString("City_name");
Stringsn = rs.getString("State");
String p = rs.getString("Population");
String l = rs.getString("Literacy");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error occured");
// TODO add your handling code here:
}
}
/**
*
* @param args
*/
public static void main(String args[])
{
/* Set the Nimbus look and feel */
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new Display().setVisible(true);
}
});
}
}
REMOVE DATA FROM TABLE
In the above interface the user can remove data from table.
Connection con;
con =
DriverManager.getConnection("jdbc:mysql://localhost/jnvbpr","root
","kvuc");
Statement stmt;
stmt = con.createStatement();
String query = "DELETE FROM CITY WHERE CITY_NAME='"
+cnametf.getText()+"';";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Record deleted");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error in Deletion");
}
}
cnametf.setText("");
stf.setText("");
ptf.setText("");
ltf.setText("");
delbt.setEnabled(false);
Connection con;
con =
DriverManager.getConnection("jdbc:mysql://localhost/jnvbpr","root","kvuc
");
Statement stmt;
stmt = con.createStatement();
String query = "SELECT * FROM CITY WHERE CITY_NAME='"
+cnametf.getText()+"';";
ResultSet rs;
rs = stmt.executeQuery(query);
if(rs.next())
{
String cn=rs.getString("City_name");
Stringsn=rs.getString("State");
String p=rs.getString("Population");
String l=rs.getString("Literacy");
cnametf.setText(cn);
stf.setText(sn);
ptf.setText(p);
ltf.setText(l);
delbt.setEnabled(true);
}
else
{
JOptionPane.showMessageDialog(null, "No such Reocrd Found");
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "Error occured");
// TODO add your handling code here:
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new remove().setVisible(true);
}
});
}
}
DATABASE DESIGN:
TALBES :
1. USER ID.
2. CITY
Lastly we would like to thank all those people who have helped us.