Popular Posts

Thursday 24 January 2013

college library record


import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import javax.swing.JPopupMenu;
import com.sun.java.swing.plaf.motif.MotifLookAndFeel;

public class ProjectLibrary extends JFrame implements ActionListener
{
JTextField id,phno,name,add,city,padd,eadd,class1,shift,progress,date;
JTextField bookTF,authorTF,priceTF,bcodeTF;
JTextField cdcodeTF,cdtitleTF,cdisbnTF,cdeditionTF,cdpubTF;
Container c;
JButton search,save,delete,exit,update;
JButton searBook,saveNow,update1;
JButton cdsearch,cdsave,cddelete,cdexit,cdupdate;
JLabel cdlogo,cdcode,cdtitle,cdisbn,cdedit,cdpub;
JOptionPane jp = new JOptionPane();
JMenuBar menuBar,menuBar1;
JMenu menu1,menu2;
JMenuItem menuItemN,menuItemB,menuItemC,menuItemH,menuItemA,menuItemE;
Cursor cur;

public Project4()
{
super("Library Record System");
c = getContentPane(); c.setBackground(new Color(14,58,119));
c.setLayout(null);
setBounds(0,0,850,590);
setFont(new Font("verdana",3,14));
cur = new Cursor(Cursor.CROSSHAIR_CURSOR);
setCursor(cur);
ImageIcon coll = new ImageIcon("collicon.gif");
JLabel LogoColl = new JLabel(coll);
menuBar = new JMenuBar();
menu1 = new JMenu("Library"); menu1.setBackground(Color.white);
menu1.setMnemonic('L');
menu2 = new JMenu("Help");
menu2.setMnemonic('H'); menu2.setBackground(Color.white);
//menu1.setMnemonic(KeyEvent.VK_D);

menuItemN = new JMenuItem("New",new ImageIcon("NEW.GIF")); menuItemN.setBackground(Color.white);
menuItemN.setMnemonic('N');
        menuItemB = new JMenuItem("Books",new ImageIcon("b.gif")); menuItemB.setBackground(Color.white);
        menuItemB.setMnemonic('B');
menuItemC = new JMenuItem("CD's",new ImageIcon("c.gif")); menuItemC.setBackground(Color.white);
menuItemC.setMnemonic('C');
menuItemE = new JMenuItem("Exit",new ImageIcon("Exit.PNG")); menuItemE.setBackground(Color.white);
menuItemE.setMnemonic('E');
menuItemH = new JMenuItem("Help library",new ImageIcon("help.gif")); menuItemH.setBackground(Color.white);
menuItemH.setMnemonic('E');
menuItemA = new JMenuItem("About Library Record System");
setJMenuBar(menuBar);

JLabel lDate = new JLabel("Issue Of Date :");  lDate.setForeground(Color.white);
JLabel ph = new JLabel("Enter Phone Number :"); ph.setForeground(Color.white);
JLabel lname = new JLabel("Student's Name :"); lname.setForeground(Color.white);
JLabel address = new JLabel("Student's Address :"); address.setForeground(Color.white);
JLabel lid = new JLabel("Book Code"); lid.setForeground(Color.white);
JLabel lcity = new JLabel("City"); lcity.setForeground(Color.white);
JLabel pad = new JLabel("Permenent Address"); pad.setForeground(Color.white);

       JLabel leadd = new JLabel("Email Address"); leadd.setForeground(Color.white);
       JLabel lclass = new JLabel("Class"); lclass.setForeground(Color.white);
       JLabel lshift = new JLabel("Shift"); lshift.setForeground(Color.white);
       JLabel lprogress = new JLabel("Progress"); lprogress.setForeground(Color.white);
       ImageIcon next = new ImageIcon("next.gif");
       JLabel next1 = new JLabel(next);
       ImageIcon previous = new ImageIcon("Back.gif");
       JLabel previous1 = new JLabel(previous);

ImageIcon background = new ImageIcon("backg.jpg");
JLabel img = new JLabel(background);

ImageIcon college = new ImageIcon("Movie1.PNG");
JLabel colLogo = new JLabel(college);


ImageIcon LineStraight = new ImageIcon("lineh.gif");
JLabel Line = new JLabel(LineStraight);

date = new JTextField(); date.setForeground(Color.black); date.setBackground(Color.white);
phno = new JTextField(); phno.setForeground(Color.black); phno.setBackground(Color.white);
name = new JTextField(); name.setForeground(Color.black); name.setBackground(Color.white);
add = new JTextField();  add.setForeground(Color.black); add.setBackground(Color.white);

       eadd = new JTextField(); eadd.setForeground(Color.black); eadd.setBackground(Color.white);
       city = new JTextField(); city.setForeground(Color.black); city.setBackground(Color.white);
        padd = new JTextField(); padd.setForeground(Color.black);  padd.setBackground(Color.white);
       id = new JTextField(); id.setForeground(Color.black); id.setBackground(Color.white);
       class1 = new JTextField(); class1.setForeground(Color.black); class1.setBackground(Color.white);
       shift = new JTextField(); shift.setForeground(Color.black); shift.setBackground(Color.white);
       progress = new JTextField(); progress.setForeground(Color.black);  progress.setBackground(Color.white);

        search = new JButton("Search",new ImageIcon("search.gif"));  search.setForeground(Color.white); search.setBackground(Color.pink);
        save = new JButton("Save", new ImageIcon("Save.gif")); save.setForeground(Color.white); save.setBackground(Color.pink);
        delete = new JButton("Delete", new ImageIcon("remove.gif")); delete.setForeground(Color.white); delete.setBackground(Color.pink);
        exit = new JButton("Exit", new ImageIcon("exit.gif")); exit.setForeground(Color.white); exit.setBackground(Color.pink);
        update = new JButton("Update", new ImageIcon("update.gif")); update.setForeground(Color.white); update.setBackground(Color.pink);

search.setToolTipText("Search the record");
save.setToolTipText("Save the record");
delete.setToolTipText("Delete the record");
exit.setToolTipText("Exit from the library");
update.setToolTipText("Update the record");

lDate.setBounds(80,135,670,150);
LogoColl.setBounds(380,20,670,150);
lid.setBounds(80,240,150,20);
ph.setBounds(400,245,150,20);
lname.setBounds(80,285,150,20);
address.setBounds(400,290,150,20);
lcity.setBounds(400,330,150,20);
pad.setBounds(400,375,150,20);
leadd.setBounds(400,415,150,20);
lclass.setBounds(80,330,150,20);
lshift.setBounds(80,380,150,20);
lprogress.setBounds(80,415,150,20);
next1.setBounds(650,478,180,54);
previous1.setBounds(10,478,190,54);
img.setBounds(90,100,20,40);
colLogo.setBounds(3,0,790,142);
Line.setBounds(2,2,48,1000);

date.setBounds(220,190,152,26);
id.setBounds(220,235,152,26);
phno.setBounds(550,245,152,26);
name.setBounds(220,280,152,26);
add.setBounds(550,290,152,26);
        city.setBounds(550,330,152,26);
padd.setBounds(550,370,152,26);
eadd.setBounds(550,410,152,26);
class1.setBounds(220,325,152,26);
shift.setBounds(220,370,152,26);
progress.setBounds(220,415,152,26);

search.setBounds(160,490,105,30);
save.setBounds(270,490,90,30);
delete.setBounds(363,490,95,30);
update.setBounds(460,490,110,30);
exit.setBounds(575,490,95,30);

menu1.add(menuItemN);
menu1.add(menuItemB);
menu1.add(menuItemC);
menu1.add(menuItemE);
menuBar.add(menu1);

menu2.add(menuItemH);
menu2.add(menuItemA);
menuBar.add(menu2);

save.addActionListener(this);
search.addActionListener(this);
        delete.addActionListener(this);
update.addActionListener(this);
exit.addActionListener(this);
menuItemN.addActionListener(this);
menuItemB.addActionListener(this);
menuItemC.addActionListener(this);
menuItemH.addActionListener(this);
menuItemA.addActionListener(this);
menuItemE.addActionListener(this);

c.add(search);
c.add(save );
c.add(delete);
c.add(exit);
c.add(update);
c.add(LogoColl);
c.add(lDate);
c.add(ph);
c.add(lname);
c.add(address);
c.add(lid);
c.add(lcity);
c.add(pad);
c.add(leadd);
c.add(lclass);
c.add(lshift);
c.add(lprogress);
c.add(next1);
c.add(previous1);
c.add(img);
c.add(colLogo);
c.add(date);
c.add(phno);
c.add(name);
c.add(add);
c.add(city);
c.add(padd);
c.add(id);
c.add(eadd);
c.add(class1);
c.add(progress);
c.add(shift);
c.add(Line);


        next1.addMouseListener(new MouseAdapter()
   {
public void mousePressed(MouseEvent me)
{
int a = Integer.parseInt(id.getText());
a++;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();

   ResultSet rs = st.executeQuery("select * from Directory where Id="+a);
                    while(rs.next())
   {
date.setText(rs.getString("DateToday"));
id.setText(rs.getString("Id"));
name.setText(rs.getString("Name"));
add.setText(rs.getString("Address"));
class1.setText(rs.getString("Class"));
progress.setText(rs.getString("Progress"));
shift.setText(rs.getString("Shift"));
city.setText(rs.getString("City"));
padd.setText(rs.getString("Permenent_Address"));
phno.setText(rs.getString("PhoneNo"));
eadd.setText(rs.getString("eaddress"));

 }
c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{

System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
System.out.println(sql);
}

}
      });

previous1.addMouseListener(new MouseAdapter()
   {
public void mousePressed(MouseEvent me)
{
int a = Integer.parseInt(id.getText());
a--;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
   ResultSet rs = st.executeQuery("select * from Directory where Id="+a);

                    while(rs.next())
   { date.setText(rs.getString("DateToday"));
id.setText(rs.getString("Id"));
name.setText(rs.getString("Name"));
add.setText(rs.getString("Address"));
class1.setText(rs.getString("Class"));
progress.setText(rs.getString("Progress"));
shift.setText(rs.getString("Shift"));
city.setText(rs.getString("City"));
padd.setText(rs.getString("Permenent_Address"));
phno.setText(rs.getString("PhoneNo"));
eadd.setText(rs.getString("eaddress"));

     }
     c.close();
     st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
System.out.println(sql);
}


}
});
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public void actionPerformed(ActionEvent ae)
{
String str1=(String)ae.getActionCommand();
Object source = ae.getSource();
if(source==menuItemA)
{
JFrame aboutus = new JFrame("About us");
aboutus.setSize(700,500);
aboutus.getContentPane().setLayout(null);
ImageIcon design = new ImageIcon("about.png");
JLabel cover = new JLabel(design);
aboutus.getContentPane().add(cover);
cover.setBounds(5,0,685,500);
aboutus.setVisible(true);
}
if(source==menuItemN)
{
id.setEditable(true);
phno.setEditable(true);
name.setEditable(true);
add.setEditable(true);
city.setEditable(true);
padd.setEditable(true);
eadd.setEditable(true);
class1.setEditable(true);
shift.setEditable(true);
progress.setEditable(true);
date.setEditable(true);

id.setText(null);
phno.setText(null);
name.setText(null);
add.setText(null);
city.setText(null);
padd.setText(null);
eadd.setText(null);
class1.setText(null);
shift.setText(null);
progress.setText(null);
date.setText(null);

}
if(source==menuItemB)
{
JFrame book=new JFrame("Book's available in library");
book.setSize(660,560);
book.getContentPane().setLayout(null);
book.getContentPane().setBackground(new Color(14,58,119));
book.getContentPane().setForeground(Color.white);
book.setResizable(false);
JLabel BookName = new JLabel("Book Name:");
book.getContentPane().add(BookName);
JLabel AuthorName = new JLabel("Author Name:");
book.getContentPane().add(AuthorName);
JLabel Pri = new JLabel("Price:");
book.getContentPane().add(Pri);
JLabel Bcode = new JLabel("Book Code:");
book.getContentPane().add(Bcode);

bookTF = new JTextField(10);
book.getContentPane().add(bookTF);
authorTF = new JTextField(10);
book.getContentPane().add(authorTF);
priceTF = new JTextField(5);    
book.getContentPane().add(priceTF);
bcodeTF = new JTextField(5);
book.getContentPane().add(bcodeTF);

ImageIcon logobook = new ImageIcon("logoBook.jpg");
JLabel logoBook = new JLabel(logobook);
book.getContentPane().add(logoBook);

searBook = new JButton("Search", new ImageIcon("SEARCH.PNG"));
book.getContentPane().add(searBook);

saveNow = new JButton("Save", new ImageIcon("SAVE.PNG"));
book.getContentPane().add(saveNow);

update1 = new JButton("Update", new ImageIcon("UPDATE.PNG"));
book.getContentPane().add(update1);


logoBook.setBounds(0,0,650,171);
Bcode.setBounds(33,200,112,30);
BookName.setBounds(33,250,112,30);
AuthorName.setBounds(30,310,112,30);
Pri.setBounds(31,370,112,30);

bcodeTF.setBounds(123,200,100,20);
bookTF.setBounds(123,255,262,20);
authorTF.setBounds(123,315,262,20);
priceTF.setBounds(123,375,100,20);
saveNow.setBounds(280,500,111,30);
update1.setBounds(400,500,111,30);
searBook.setBounds(160,500,111,30);
saveNow.addActionListener(this);
update1.addActionListener(this);
searBook.addActionListener(this);

book.setVisible(true);
}
if(source==menuItemE)
{
System.exit(0);
jp = new JOptionPane();
}
if(source==saveNow)
{
try
  {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();

   PreparedStatement ps = c.prepareStatement("Insert into Book values(?,?,?,?)");
ps.setString(1,bcodeTF.getText());
ps.setString(2,bookTF.getText());
ps.setString(3,authorTF.getText());
ps.setString(4,priceTF.getText());

               ps.executeUpdate();
               jp.showMessageDialog(this,"Record Inserted Successfully","SUCCESS",jp.INFORMATION_MESSAGE);

c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{System.out.println("Cnf Exception");}
catch(SQLException sql)
{jp.showMessageDialog(this,"Record Already Exists","EXCEPTION",jp.ERROR_MESSAGE);}
}
        if(source==update1)
{
           try
              {
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();

PreparedStatement ps=c.prepareStatement ("Update Book set BookName=? , AuthorName=? , Price=? where BookCode="+bcodeTF.getText() );

ps.setString(1,bookTF.getText());
ps.setString(2,authorTF.getText());
ps.setInt(3,Integer.parseInt(priceTF.getText()));
ps.executeUpdate();
jp.showMessageDialog(this,"Record Updated Successfully","SUCCESS",jp.INFORMATION_MESSAGE);
c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{System.out.println("Cnf Exception");}
catch(SQLException sql)
{jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);}
}  
      if(source==menuItemC)
{
JFrame cd=new JFrame("CD's available in library");
cd.setSize(510,540);
cd.getContentPane().setLayout(null);
cd.getContentPane().setBackground(new Color(14,58,119));
cd.getContentPane().setLayout(null);
cd.setResizable(false);

ImageIcon backg = new ImageIcon("CD.PNG");
JLabel cdlogo = new JLabel(backg);
cd.getContentPane().add(cdlogo);

cdcode = new JLabel("CD Code:"); cdcode.setForeground(Color.white);
cdtitle = new JLabel("Title:"); cdtitle.setForeground(Color.white);
cdisbn = new JLabel("ISBN NO:"); cdisbn .setForeground(Color.white);
cdedit = new JLabel("Edition:"); cdedit .setForeground(Color.white);
cdpub = new JLabel("Publication:");cdpub .setForeground(Color.white);

cdcodeTF = new JTextField();
cdtitleTF = new JTextField();
cdisbnTF = new JTextField();
cdeditionTF = new JTextField();
cdpubTF = new JTextField();

cdsearch = new JButton("Search" , new ImageIcon("SEARCH.PNG"));
cdsave = new JButton("Save", new ImageIcon("SAVE.PNG"));
cddelete = new JButton("Delete", new ImageIcon("DELETE.PNG"));
cdupdate = new JButton("Update", new ImageIcon("UPDATE.PNG"));
cdexit = new JButton("Exit", new ImageIcon("EXIT.PNG"));

cd.getContentPane().add(cdcode);
cd.getContentPane().add(cdtitle);
cd.getContentPane().add(cdisbn);
cd.getContentPane().add(cdedit);
cd.getContentPane().add(cdpub);

cd.getContentPane().add(cdcodeTF);
cd.getContentPane().add(cdtitleTF);
cd.getContentPane().add(cdisbnTF);
cd.getContentPane().add(cdeditionTF);
cd.getContentPane().add(cdpubTF);

cd.getContentPane().add(cdsearch);
cd.getContentPane().add(cdsave);
cd.getContentPane().add(cddelete);
cd.getContentPane().add(cdupdate);
cd.getContentPane().add(cdexit);

cdlogo.setBounds(1,0,500,100);
cdcode.setBounds(50,120,210,25);
cdtitle.setBounds(50,160,210,25);
cdisbn.setBounds(50,200,210,25);
cdedit.setBounds(50,240,210,25);
cdpub.setBounds(50,280,210,25);

cdcodeTF.setBounds(150,120,210,25);
cdtitleTF.setBounds(150,160,210,25);
cdisbnTF.setBounds(150,200,210,25);
cdeditionTF.setBounds(150,240,210,25);
cdpubTF.setBounds(150,280,210,25);

cdsearch.setBounds(0,420,98,25);
cdsave.setBounds(100,420,98,25);
cddelete.setBounds(200,420,98,25);
cdupdate.setBounds(300,420,98,25);
cdexit.setBounds(400,420,98,25);

cdsearch.addActionListener(this);
cdsave.addActionListener(this);
cddelete.addActionListener(this);
cdexit.addActionListener(this);
cdupdate.addActionListener(this);
cd.setVisible(true);
  }

if(source==cdsearch)
{
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection c = DriverManager.getConnection("jdbc:odbc:Student");
                          Statement st = c.createStatement();
ResultSet rs = st.executeQuery("select * from CD  where CdCode="+cdcodeTF.getText());
      while(rs.next())
      {
   cdtitleTF.setText(rs.getString("Title"));
   cdisbnTF.setText(rs.getString("IsbnNO"));
       cdeditionTF.setText(rs.getString("Edition"));
   cdpubTF.setText(rs.getString("Publication"));
     
      }
        c.close();
        st.close();
 }
 catch(ClassNotFoundException cnf)
 {
jp.showMessageDialog(this,cnf,"EXCEPTION",jp.ERROR_MESSAGE);
System.out.println("Cnf Exception");
  }
catch(SQLException sql)
  {
    jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);
 }

  }

if(source==cdsave)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
   PreparedStatement ps  = c.prepareStatement("Insert into CD values(?,?,?,?,?)");

ps.setString(1,cdcodeTF.getText());
ps.setString(2,cdtitleTF.getText());
ps.setString(3,cdisbnTF.getText());
ps.setString(4,cdeditionTF.getText());
ps.setString(5,cdpubTF.getText());
ps.executeUpdate();
jp.showMessageDialog(this,"Record Inserted Successfully","SUCCESS",jp.INFORMATION_MESSAGE);

c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
jp.showMessageDialog(this,"Record Already Exists","EXCEPTION",jp.ERROR_MESSAGE);
}

}

if(source==cddelete)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
   PreparedStatement ps=c.prepareStatement("Delete from CD where CdCode="+cdcodeTF.getText());
ps.executeUpdate();
jp.showMessageDialog(this,"Record Deleted Successfully","SUCCESS",jp.INFORMATION_MESSAGE);
c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);

}

}
if(source==cdupdate)
{
try
     {

 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
PreparedStatement ps=c.prepareStatement ("Update CD set Title=?, IsbnNO=?, Edition=?, Publication=?  where CdCode="+cdcodeTF.getText());

ps.setString(1,cdtitleTF.getText());
ps.setString(2,cdisbnTF.getText());
ps.setString(3,cdeditionTF.getText());
ps.setString(4,cdpubTF.getText());
ps.executeUpdate();
jp.showMessageDialog(this,"Record Updated Successfully","SUCCESS",jp.INFORMATION_MESSAGE);
c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);
}

}
if(source==cdexit)
{
System.exit(0);
}
if(source==menuItemH)
{
JFrame help=new JFrame("Help ?");
help.setSize(800,730);
help.getContentPane().setBackground(new Color(14,58,119));
help.getContentPane().setLayout(null);
help.setResizable(false);
ImageIcon hl = new ImageIcon("helpLib.png");
JLabel logoCD = new JLabel(hl);
help.getContentPane().add(logoCD);
logoCD.setBounds(0,0,800,540);
help.setVisible(true);
  }
if(source==searBook)
{
                           try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection c = DriverManager.getConnection("jdbc:odbc:Student");
      Statement st = c.createStatement();
      ResultSet rs = st.executeQuery("select * from Book where BookCode="+bcodeTF.getText());
      while(rs.next())
      {
   bookTF.setText(rs.getString("BookName"));
       authorTF.setText(rs.getString("AuthorName"));
   priceTF.setText(rs.getString("Price"));
       /*add.setText(rs.getString("Address"));
   class1.setText(rs.getString("Class"));
   progress.setText(rs.getString("Progress"));
   phno.setText(rs.getString("PhoneNo"));
   shift.setText(rs.getString("Shift"));
   city.setText(rs.getString("City"));
   padd.setText(rs.getString("Permenent_Address"));
   eadd.setText(rs.getString("eaddress"));*/
 
      }
        c.close();
        st.close();
 }
 catch(ClassNotFoundException cnf)
 {
jp.showMessageDialog(this,cnf,"EXCEPTION",jp.ERROR_MESSAGE);
System.out.println("Cnf Exception");
}
catch(SQLException sql)
 {
    jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);
 }

 }

if(str1.equals("Search"))
{
    try
   {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection c = DriverManager.getConnection("jdbc:odbc:Student");
      Statement st = c.createStatement();
      ResultSet rs = st.executeQuery("select * from Directory where Id="+id.getText());

      while(rs.next())
      {   date.setText(rs.getString("DateToday"));
       id.setText(rs.getString("Id"));
   name.setText(rs.getString("Name"));
       add.setText(rs.getString("Address"));
   class1.setText(rs.getString("Class"));
   progress.setText(rs.getString("Progress"));
   phno.setText(rs.getString("PhoneNo"));
   shift.setText(rs.getString("Shift"));
   city.setText(rs.getString("City"));
   padd.setText(rs.getString("Permenent_Address"));
   eadd.setText(rs.getString("eaddress"));
 
     }
        c.close();
        st.close();
 }
 catch(ClassNotFoundException cnf)
 {
    jp.showMessageDialog(this,cnf,"EXCEPTION",jp.ERROR_MESSAGE);
    System.out.println("Cnf Exception");
 }
 catch(SQLException sql)
 {
    jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);
 }
 }

if(str1.equals("Save"))
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
   PreparedStatement ps  = c.prepareStatement("Insert into Directory values(?,?,?,?,?,?,?,?,?,?,?)");

ps.setString(1,date.getText());
ps.setString(2,id.getText());
ps.setString(3,name.getText());
ps.setString(4,class1.getText());
ps.setString(5,shift.getText());
ps.setString(6,progress.getText());
ps.setString(7,add.getText());
ps.setString(8,city.getText());
ps.setString(9,padd.getText());
ps.setString(10,phno.getText());
ps.setString(11,eadd.getText());
                   ps.executeUpdate();
jp.showMessageDialog(this,"Record Inserted Successfully","SUCCESS",jp.INFORMATION_MESSAGE);

c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
jp.showMessageDialog(this,"Record Already Exists","EXCEPTION",jp.ERROR_MESSAGE);
}
}
if(str1.equals("Delete"))
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
   PreparedStatement ps=c.prepareStatement("Delete from Directory where Id="+id.getText());
ps.executeUpdate();
jp.showMessageDialog(this,"Record Deleted Successfully","SUCCESS",jp.INFORMATION_MESSAGE);
c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);

}
}
if(str1.equals("Update"))
{
     try
     {

 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c = DriverManager.getConnection("jdbc:odbc:Student");
   Statement st = c.createStatement();
//PreparedStatement ps=c.prepareStatement ("Update Directory set  Date=?,Name=?,Class=?,Shift=?,Progress=?,Address=?,City=?,Permenent_Address=?,PhoneNo=?,eaddress=?  where Id="+id.getText());
PreparedStatement ps=c.prepareStatement ("Update Directory set Name=?, Class=?, Shift=?, Progress=?, Address=?, City=?, Permenent_Address=?, PhoneNo=?, eaddress=?, DateToday=? where Id="+id.getText());

ps.setString(1,name.getText());
ps.setString(2,class1.getText());
ps.setString(3,shift.getText());
ps.setString(4,progress.getText());
ps.setString(5,add.getText());
ps.setString(6,city.getText());
ps.setString(7,padd.getText());
ps.setString(8,phno.getText());
ps.setString(9,eadd.getText());
ps.setString(10,date.getText());
ps.executeUpdate();
jp.showMessageDialog(this,"Record Updated Successfully","SUCCESS",jp.INFORMATION_MESSAGE);
c.close();
st.close();
}
catch(ClassNotFoundException cnf)
{
System.out.println("Cnf Exception");
}
catch(SQLException sql)
{
jp.showMessageDialog(this,sql,"EXCEPTION",jp.ERROR_MESSAGE);
}
}
if(str1.equals("Exit"))
{
System.exit(0);
}
 }

public static void main(String arg[])
  {
  Project4 p4 = new Project4();
p4.setResizable(false);

}

}

Monday 14 January 2013

Course Registration System



Course Registration

PROBLEM DESCRIPTION:-
                        The allotment of courses during the start of the academic year can consume more time when done by physical means. By implementing the registration of course online, it would be efficient for both college and students to add new course and register for course respectively.
INTERFACES:-
                        The whole system is divided into 5 levels. They are
Ø  Selecting User
Ø  Adding a course
Ø  Display Availability
Ø  Register Course
Ø  Generate order form
SELECTING USER :-
                        This module is to select the type of user accessing the project. By determining the user the authentication for the rest of the project is provided for safety concerns.
ADDING A COURSE :-
        This module is used for the colleges. Adding course has three sub modules namely,
Ø  Login module
Ø  College selection
Ø  Slots according to the Quota
LOGIN:-
This module is used to store the information of the officer’s user name and password.
COLLEGE SELECTION:-
        This module is to let the user to select which college does he want to add the seats for this academic year.

SLOTS ACCOTDING TO THE QUOTA:-
                This module provides the user with the slots to fill the specified seats in the college according to the quota as category.
DISPLAY AVAILABILITY:-
                        This module is to display the students with the seats available for them to register. This again has 2 other modules,
Ø  Stream selection
Ø  Check availability
STREAM SELECTION:-
                        This module contains the streams for the students to select. The users would be able to select the course under the stream choosen.
CHECK AVAILABILITY:-
                        This module is used to check the selected course is occupied of free in the project database for security concerns.
REGISTER COURSE:-
                        This module lets the students to select the course the preferred for and then register for it. The order form is generated at last.
GENERATE ORDER FORM:-
            This module is to generate the order form according to the course and college the user has registered for with the details specified in the form including the registration number and the quota under which the seat has been taken.
Security and Privacy:-
                        The students can only register for the seats that the college decides to give which ensures no data loss for the college. The students are asked only few reasonable details to match their choice of course.
RELIABLITY:-
                        There is no atomicity problem.
SAFETY:-             
       No data loss occurs in this system. It is very much protected   in such a way that it gives permission to college to access only to modify to the course availability assignment.
QUALITY:-
                        The VB tool which has graphic interface features makes the project a quality one.
DATA STRUCTURE:-
                The data in this project are maintained in the tabular form using Oracle as the Back-End and VB6.0 as the Front-End, which is user friendly.
USEFULNESS OF PROJECT:-
                        This system guides the students and the concerned staff personals to find the course which they preferred to take and to fill out the course available for the academic year by providing authentication. Thus providing an easier means of filling the seats for the colleges.















Use Case Diagram:-








Class Diagram:-





Sequential Diagram:-


Activity Diagram:-



Select-User  Form:-

Select-User  Form Code:-
Private Sub CmdCollege_Click()
Unload Me
Frmcollege_login.Show
End Sub            

Private Sub CmdStudent_Click()
Unload Me
Frmselect_stream.Show
End Sub

Private Sub CmdEnd_Click()
End
End Sub

Private Sub Form_Load()
Me.Move 4800, 5000
'Frmselect_user.StartUpPosition = FormStartPosition.CenterScreen
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
ChoiceOne.Show
End If
End Sub

Private Sub Form_Load()
ChoiceOne.Left = (Screen.Width - ChoiceOne.Width) / 2
ChoiceOne.Top = (Screen.Height - ChoiceOne.Height) / 2
End Sub
Login Form:-


Login Form Code:-
Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim flag, Flag1 As Integer

Private Sub CmdCancel_Click()
End
End Sub

Private Sub CmdOk_Click()
If KeyAscii = 13 Then
If Text1.Text = "" Then
MsgBox "Please Fill The Admin_Name Field's", vbInformation, ""
Else
If Text2.Text = "" Then
MsgBox "Please Fill The Admin_Password Field's", vbInformation, ""
Else
flag = 0
If Text1.Text = "college" Then
If Text2.Text = "123" Then
Flag1 = 1
MsgBox "" & Text1.Text & " Permission Granted!!!", vbInformation, "RailWay Login"
Text1.Text = ""
Text2.Text = ""
Unload Me
Frmcolleges_show.Show
End If
End If
flag = 2
If flag = 2 And Flag1 <> 1 Then
MsgBox "Invalid Password", vbExclamation, "Error"
End If
If flag = 0 And Flag1 <> 1 Then
MsgBox "Un_Authorized User", vbExclamation, "Error"
End If
End If
End If
End If
End Sub

Private Sub Form_Load()
Me.Move 4500, 5000
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text1.Text = "" Then
MsgBox "Please Fill The Admin_Name Field's", vbInformation, ""
Else
If Text2.Text = "" Then
MsgBox "Please Fill The Admin_Password Field's", vbInformation, ""
Else
flag = 0
If Text1.Text = "college" Then
If Text2.Text = "123" Then
Flag1 = 1
MsgBox "" & Text1.Text & " Permission Granted!!!", vbInformation, "RailWay Login"
Text1.Text = ""
Text2.Text = ""
Unload Me
Frmcolleges_show.Show
End If
End If
flag = 2
If flag = 2 And Flag1 <> 1 Then
MsgBox "Invalid Password", vbExclamation, "Error"
End If
If flag = 0 And Flag1 <> 1 Then
MsgBox "Un_Authorized User", vbExclamation, "Error"
End If
End If
End If
End If
End Sub


Select-College  Form:-




Select College Form Code:-

Private Sub Command1_Click()
Frmengineering_addseat.Show
Frmcolleges_show.Hide
End Sub

Private Sub Command2_Click()
Frmmedical_addseat.Show
Frmcolleges_show.Hide
End Sub

Private Sub Command3_Click()
Frmarts_addseat.Show
Frmcolleges_show.Hide
End Sub

Private Sub Form_Load()
Me.Move 2200, 2500
End Sub

Adding seat to College Form:-


Adding seat to Engineering-College Form Code:-
Dim Cn As New ADODB.Connection
Dim Rs1 As New ADODB.Recordset
Dim Rs2 As New ADODB.Recordset
Dim Rs3 As New ADODB.Recordset
Dim str1 As String
Dim str2 As String
Dim str3 As String

Private Sub CmdSaveECE_Click()
If Rs1.State = 1 Then Rs1.Close
Rs1.CursorLocation = adUseClient
Rs1.Open "select * from ece", Cn, adOpenStatic, adLockBatchOptimistic
Rs1.AddNew
Rs1.Fields(0) = Val(Text1.Text)
Rs1.Fields(1) = Val(Text2.Text)
Rs1.Fields(2) = Val(Text3.Text)
Rs1.Fields(3) = Val(Text5.Text)
Rs1.Fields(4) = Val(Text6.Text)
Rs1.UpdateBatch
If Rs2.State = 1 Then Rs2.Close
Rs2.CursorLocation = adUseClient
Rs2.Open "select * from cse", Cn, adOpenStatic, adLockBatchOptimistic
Rs2.AddNew
Rs2.Fields(0) = Val(Text7.Text)
Rs2.Fields(1) = Val(Text8.Text)
Rs2.Fields(2) = Val(Text9.Text)
Rs2.Fields(3) = Val(Text10.Text)
Rs2.Fields(4) = Val(Text11.Text)
Rs2.UpdateBatch
If Rs3.State = 1 Then Rs3.Close
Rs3.CursorLocation = adUseClient
Rs3.Open "select * from eee", Cn, adOpenStatic, adLockBatchOptimistic
Rs3.AddNew
Rs3.Fields(0) = Val(Text12.Text)
Rs3.Fields(1) = Val(Text13.Text)
Rs3.Fields(2) = Val(Text14.Text)
Rs3.Fields(3) = Val(Text15.Text)
Rs3.Fields(4) = Val(Text16.Text)
Rs3.UpdateBatch
MsgBox "Seats Added", vbInformation, ""
Unload Frmengineering_addseat
Frmselect_user.Show
End Sub

Private Sub cmdMain_Click()
Unload Frmengineering_addseat
Frmselect_user.Show
End Sub

Private Sub Command1_Click()
str1 = "truncate table ece"
str2 = "truncate table cse"
str3 = "truncate table eee"
Cn.Execute (str1)
Cn.Execute (str2)
Cn.Execute (str3)
MsgBox "Database Cleared ! Continue adding seats.", vbInformation, ""
End Sub

Private Sub Form_Load()
Me.Move 4500, 1500
If Cn.State = 1 Then Cn.Close
Cn.CursorLocation = adUseClient
Cn.Open "Provider=OraOLEDB.Oracle;Password=tiger;User ID=scott;Persist Security Info=True;"
End Sub

Stream Display Form :-


Stream Display Form Code:-

Private Sub CmdArts_Click()
Frmselect_stream.Hide
Frmarts_studentdetails.Show
End Sub

Private Sub CmdEngineering_Click()
Frmselect_stream.Hide
Frmengineering_studentdetails.Show
End Sub

Private Sub CmdMedical_Click()
Frmselect_stream.Hide
Frmmedical_studentdetails.Show
End Sub

Private Sub Form_Load()
Me.Move 0, 0
End Sub

StudentDetails  Form :-


Arts-StudentDetails  Form Code:-

Dim Cn1 As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub CmdCancel_Click()
End
End Sub

Private Sub CmdClear_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Combo2.Text = ""
End Sub

Private Sub CmdSubmit_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Combo1.Text = "" Or regno = Val(Text1.Text) Or sname = Text2.Text Or stream = Combo1.Text Then
MsgBox "Please complete all the details needed"
End If
If Rs.State = 1 Then Rs.Close
Rs.CursorLocation = adUseClient
Rs.Open "select * from artsregister", Cn1, adOpenStatic, adLockBatchOptimistic
Rs.AddNew
Rs.Fields(0) = Val(Text1.Text)
Rs.Fields(1) = Text2.Text
Rs.Fields(2) = Val(Text3.Text)
Rs.Fields(3) = Combo1.Text
Rs.UpdateBatch
MsgBox "Information Added. Please Proceed.", vbInformation, ""
Frmarts_seatdisplay.Show
Unload Me
End Sub

Private Sub Form_Load()
Me.Move 4500, 2500
If Cn1.State = 1 Then Cn1.Close
Cn1.CursorLocation = adUseClient
Cn1.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=True;"
End Sub


Display-Availability  Form :-





Display-Arts-Availability  Form Code:-
Dim Cn As New ADODB.Connection
Dim Rs1 As New ADODB.Recordset
Dim Rs2 As New ADODB.Recordset
Dim Rs3 As New ADODB.Recordset
Private Sub CmdBack_Click()
Frmarts_seatdisplay.Hide
Frmarts_studentdetails.Show
End Sub
Private Sub CmdRegister_Click()
Frmarts_seatdisplay.Hide
Frmarts_register.Show
End Sub
Private Sub Form_Load()
Me.Move 1700, 1950
Dim i As Integer
If Cn.State = 1 Then Cn.Close
Cn.CursorLocation = adUseClient
Cn.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=True;"
Rs1.Open "select * from maths", Cn
If Rs1.EOF = False Then
Label8.Caption = Rs1.Fields(0)
'Text1.Text = Rs1.Fields(0)
Label9.Caption = Rs1.Fields(1)
Label10.Caption = Rs1.Fields(2)
Label11.Caption = Rs1.Fields(3)
Label12.Caption = Rs1.Fields(4)
Rs1.Close
End If
Rs2.Open "select * from history", Cn
If Rs2.EOF = False Then
Label13.Caption = Rs2.Fields(0)
Label14.Caption = Rs2.Fields(1)
Label15.Caption = Rs2.Fields(2)
Label16.Caption = Rs2.Fields(3)
Label21.Caption = Rs2.Fields(4)
Rs2.Close
End If
Rs3.Open "select * from litrature", Cn
If Rs3.EOF = False Then
Label23.Caption = Rs3.Fields(0)
Label24.Caption = Rs3.Fields(1)
Label25.Caption = Rs3.Fields(2)
Label26.Caption = Rs3.Fields(3)
Label27.Caption = Rs3.Fields(4)
'Text15.Text = Rs3.Fields(4)
Rs3.Close
End If
End Sub
Register-Course Form :-


Arts-Register-Course Form Code:-

Dim Cn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim Rs1 As New ADODB.Recordset
Dim flag As Integer

Public Function check()
Dim Rs As New ADODB.Recordset
Dim Rs1 As New ADODB.Recordset
Dim Rs2 As New ADODB.Recordset
Dim Rs3 As New ADODB.Recordset
Dim Rs4 As New ADODB.Recordset
Dim i As Integer
Dim str2 As String

If course.Text = "Maths" Then
Rs.Open "select * from maths", Cn
If quota.Text = "GENERAL" Then
i = 0
If Rs.Fields(0) <> 0 Then
str2 = "update maths set general='" & (Rs.Fields(0) - 1) & "'"
Cn.Execute (str2)
'Rs.Fields(0) = Rs.Fields(0) - 1
MsgBox "Successfully Registered Maths"
Frmarts_seatdisplay.Label8.Caption = Rs.Fields(0)
flag = 1
Else
MsgBox "The course is currently Unavailable ! Please select other course."
flag = 0
End If
End If
Rs.Close
            'XXXXXXXXXXXXX'
              
Rs1.Open "select * from maths", Cn
If quota.Text = "OBC" Then
i = 1
If Rs1.Fields(1) <> 0 Then
str2 = "update maths set obc='" & (Rs1.Fields(1) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered Maths"
Frmarts_seatdisplay.Label9.Caption = Rs1.Fields(1)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs1.Close
            'XXXXXXXXXXXXX'
              
Rs2.Open "select * from maths", Cn
If quota.Text = "MBC" Then
i = 2
If Rs2.Fields(2) <> 0 Then
str2 = "update maths set mbc='" & (Rs2.Fields(2) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered Maths"
Frmarts_seatdisplay.Label10.Caption = Rs2.Fields(2)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs2.Close
           
            'XXXXXXXXXXXXX'
              
Rs3.Open "select * from maths", Cn
If quota.Text = "SC" Then
i = 3
If Rs3.Fields(3) <> 0 Then
str2 = "update maths set sc='" & (Rs3.Fields(3) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered Maths"
Frmarts_seatdisplay.Label11.Caption = Rs3.Fields(3)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs3.Close
           
            'XXXXXXXXXXXXX'
              
Rs4.Open "select * from maths", Cn
If quota.Text = "OTHER" Then
i = 4
If Rs4.Fields(4) <> 0 Then
str2 = "update maths set other='" & (Rs4.Fields(4) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered MAths"
Frmarts_seatdisplay.Label12.Caption = Rs4.Fields(4)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs4.Close
End If
                                                               ‘History Register'

If course.Text = "History" Then
Rs.Open "select * from history", Cn
If quota.Text = "GENERAL" Then
i = 0
If Rs.Fields(0) <> 0 Then
str2 = "update history set general='" & (Rs.Fields(0) - 1) & "'"
Cn.Execute (str2)
'Rs.Fields(0) = Rs.Fields(0) - 1
MsgBox "Successfully Registered History"
Frmarts_seatdisplay.Label13.Caption = Rs.Fields(0)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs.Close
            'XXXXXXXXXXXXX'
              
Rs1.Open "select * from history", Cn
If quota.Text = "OBC" Then
i = 1
If Rs1.Fields(1) <> 0 Then
str2 = "update history set obc='" & (Rs1.Fields(1) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered History"
Frmarts_seatdisplay.Label14.Caption = Rs1.Fields(1)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs1.Close
            'XXXXXXXXXXXXX'
              
Rs2.Open "select * from history", Cn
If quota.Text = "MBC" Then
i = 2
If Rs2.Fields(2) <> 0 Then
str2 = "update history set mbc='" & (Rs2.Fields(2) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label15.Caption = Rs2.Fields(2)
flag = 1
Else
MsgBox "Not Registered"
flag = 1
End If
End If
Rs2.Close
            'XXXXXXXXXXXXX'
              
Rs3.Open "select * from history", Cn
If quota.Text = "SC" Then
i = 3
If Rs3.Fields(3) <> 0 Then
str2 = "update history set sc='" & (Rs3.Fields(3) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label16.Caption = Rs3.Fields(3)
Else
MsgBox "Not Registered"
End If
End If
Rs3.Close
            'XXXXXXXXXXXXX'
              
Rs4.Open "select * from history", Cn
If quota.Text = "OTHER" Then
i = 4
If Rs4.Fields(4) <> 0 Then
str2 = "update history set other='" & (Rs4.Fields(4) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label21.Caption = Rs4.Fields(4)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs4.Close
End If
                                                                                                                                        
If course.Text = "Litrature" Then
Rs.Open "select * from litrature", Cn
If quota.Text = "GENERAL" Then
i = 0
If Rs.Fields(0) <> 0 Then
str2 = "update litrature set general='" & (Rs.Fields(0) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label23.Caption = Rs.Fields(0)
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs.Close
            'XXXXXXXXXXXXX'
              
Rs1.Open "select * from litrature", Cn
If quota.Text = "OBC" Then
i = 1
If Rs1.Fields(1) <> 0 Then
str2 = "update litrature set obc='" & (Rs1.Fields(1) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label24.Caption = Rs1.Fields(1)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs1.Close
            'XXXXXXXXXXXXX'
              
Rs2.Open "select * from litrature", Cn
If quota.Text = "MBC" Then
i = 2
If Rs2.Fields(2) <> 0 Then
str2 = "update litrature set mbc='" & (Rs2.Fields(2) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label25.Caption = Rs2.Fields(2)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs2.Close
            'XXXXXXXXXXXXX'
              
Rs3.Open "select * from litrature", Cn
If quota.Text = "SC" Then
i = 3
If Rs3.Fields(3) <> 0 Then
str2 = "update litrature set sc='" & (Rs3.Fields(3) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label26.Caption = Rs3.Fields(3)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs3.Close
            'XXXXXXXXXXXXX'
              
Rs4.Open "select * from litrature", Cn
If quota.Text = "OTHER" Then
i = 4
If Rs4.Fields(4) <> 0 Then
str2 = "update litrature set other='" & (Rs4.Fields(4) - 1) & "'"
Cn.Execute (str2)
MsgBox "Successfully Registered"
Frmarts_seatdisplay.Label27.Caption = Rs4.Fields(4)
flag = 1
Else
MsgBox "Not Registered"
flag = 0
End If
End If
Rs4.Close
End If
End Function

Private Sub CmdRegister_Click()
quo = quota.Text
cou = course.Text
If quota.Text = "" Or course.Text = "" Then
MsgBox "Select all the items promptly"
Exit Sub
End If
Call check
If flag = 1 Then
Frmarts_register.Hide
Frmorder_generation.Show
End If
If flag = 0 Then
MsgBox "The course is currently Unavailable ! Please select other course."
End If
End Sub


Private Sub Form_Load()
Me.Move 5500, 4500
If Cn.State = 1 Then Cn.Close
Cn.CursorLocation = adUseClient
Cn.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=True;"
End Sub


Generate-Order Form :-





Generate-Order Form Code:-

Private Sub Command1_Click()
CommonDialog1.ShowPrinter
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Me.Move 3900, 1500
Label6.Caption = sname
Label7.Caption = regno
Label8.Caption = cou
Label9.Caption = quo
Select Case stream
Case "Engineering": Label5.Caption = "PONDICHERRY ENGINEERING COLLEGE"
Case "Medicine": Label5.Caption = "PONDICHERRY MEDICAL COLLEGE"
Case "Arts": Label5.Caption = "PONDICHERRY ARTS COLLEGE"
End Select
End Sub

MDI Form Code :-

Option Explicit
  
   Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  
      Const WS_CAPTION = &HC00000
      Const WS_SYSMENU = &H80000
      Const WS_MINIMIZEBOX = &H20000
      Const WS_MAXIMIZEBOX = &H10000
      Const GWL_STYLE = (-16)
 
Private Sub MDIForm_Load()
Frmselect_user.Show
Dim L As Long
L = GetWindowLong(Me.hwnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = L Xor WS_CAPTION
L = SetWindowLong(Me.hwnd, GWL_STYLE, L)
End Sub































CONCLUSION:
                             Thus the project for “Course Registration” with oracle database was developed and executed successfully.