Library Management System
#11
[attachment=15572]
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

public class AddBCat extends JInternalFrame implements ActionListener {

    private JPanel pNew = new JPanel();
    private JLabel lbUser;
    private JTextField txtUser;
    private JButton btnOk, btnCancel;

    private Statement st;            //Statement for Getting the Required Table.

    //Constructor of Class.

    public AddBCat (Connection con) {

        //super(title, resizable, closable, maximizable, iconifiable)
        super ("New Book Category", false, true, false, true);
        setSize (280, 175);

        //Setting the Form's Labels.

        lbUser = new JLabel ("Category:");
        lbUser.setForeground (Color.black);
        lbUser.setBounds (20, 20, 100, 25);
          
        //Setting the Form's TextField & PasswordField.

        txtUser = new JTextField ();
        txtUser.setBounds (100, 20, 150, 25);
        
        //Setting the Form's Buttons.

        btnOk = new JButton ("OK");
        btnOk.setBounds (20, 100, 100, 25);
        btnOk.addActionListener (this);
        btnCancel = new JButton ("Cancel");
        btnCancel.setBounds (150, 100, 100, 25);
        btnCancel.addActionListener (this);

        //Setting Panel's Layout.

        pNew.setLayout (null);

        //Adding All the Controls in Panel.

        pNew.add (lbUser);
        
        pNew.add (txtUser);
        
        pNew.add (btnOk);
        pNew.add (btnCancel);

        //Adding Panel to the Form.

        getContentPane().add (pNew);

        try {
            st = con.createStatement ();    //Creating Statement Object.
        }
        catch (SQLException sqlex) {            //If Problem then Show the User a Message.
            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading the Form.");
            dispose ();                //Closing the Form.
         }

        setVisible (true);

    }

    public void actionPerformed (ActionEvent ae) {

        Object obj = ae.getSource();

        if (obj == btnOk) {        //If OK Button Pressed.

            

            if (txtUser.getText().equals ("")) {
                txtUser.requestFocus();
                JOptionPane.showMessageDialog (this, "Category not Provided.");
            }
            
            else {
                try {    //INSERT Query to Add Book Record in Table.
                    String id= txtUser.getText();
                    String q = "SELECT * FROM BCat ";
                    ResultSet rs = st.executeQuery (q);    //Executing the Query.
                    int fl=0;
                    while(rs.next())
                    {
                        String memberNo = rs.getString ("Cat");    //Storing the Record.
                        if(id.equals(memberNo))
                        {
                            JOptionPane.showMessageDialog(this,"Already existing Category");
                            txtUser.setText("");
                            txtUser.requestFocus();
                            fl=1;
                            break;
                            
                        }
                    }
                    rs.close();
                    if(fl==0){
                    q = "INSERT INTO BCat " +
                        "VALUES ('" + txtUser.getText() + "')";

                    int result = st.executeUpdate (q);    //Running Query.
                    if (result == 1) {            //If Query Successful.
                        JOptionPane.showMessageDialog (this, "New Category Created.");
                        txtUser.setText ("");
                        txtUser.requestFocus ();
                    }
                    else {                    //If Query Failed.
                        JOptionPane.showMessageDialog (this, "Problem while Creating. ");
                        txtUser.setText ("");
                        txtUser.requestFocus ();
                    }
                    }
                }
                catch (SQLException sqlex) {
                    
                    JOptionPane.showMessageDialog (this, "Problem while Creating excep.");
                }
            }

        }        

        if (obj == btnCancel) {        //If Cancel Button Pressed Unload the From.

            setVisible (false);
            dispose();

        }

    }


}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: library management, seminar topics in e library management system, normalisation of library management system, library system, cds library management, algorythm for library management system, library management system hardcopy in vb,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
RE: Library Management System - by project topics - 22-04-2010, 10:54 AM
RE: Library Management System - by gucci - 02-08-2010, 08:29 AM
RE: Library Management System - by Zigbee - 03-08-2010, 07:19 PM
RE: Library Management System - by gucci - 04-08-2010, 01:57 AM
RE: Library Management System - by Zigbee - 05-08-2010, 05:33 PM
RE: Library Management System - by smart paper boy - 30-08-2011, 02:55 PM
RE: Library Management System - by seminar addict - 26-01-2012, 03:04 PM
RE: Library Management System - by seminar addict - 01-02-2012, 04:58 PM
RE: Library Management System - by seminar addict - 08-02-2012, 09:39 AM
RE: Library Management System - by seminar paper - 05-03-2012, 03:49 PM
RE: Library Management System - by seminar paper - 12-03-2012, 10:44 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  event management system project report tiger 3 6,400 30-08-2017, 12:43 PM
Last Post: jaseela123d
  Development of a Recipe Management System seminar topics 1 3,068 24-04-2017, 10:17 AM
Last Post: Zakir Hussain
  The impact of technology on queue management system holax 1 1,446 14-07-2016, 02:39 PM
Last Post: seminar report asees
  School Management System project topics 9 8,553 27-06-2016, 09:23 AM
Last Post: computer science crazy
Smile school management system amrita 2211 4 5,660 27-06-2016, 09:23 AM
Last Post: computer science crazy
  Employee Cubicle Management System full report computer science technology 4 5,148 07-04-2016, 11:37 AM
Last Post: dhanabhagya
  Attendance Management System mechanical engineering crazy 18 23,543 05-04-2016, 09:50 AM
Last Post: dhanabhagya
  warehouse management system project report tiger 3 4,180 17-12-2015, 02:23 PM
Last Post: seminar report asees
  Student Fee Management System project topics 4 6,015 25-09-2015, 09:54 AM
Last Post: seminar report asees
  Development of a workflow based Complaint Management System (where the complaints are mechanical engineering crazy 5 5,657 28-08-2015, 04:59 AM
Last Post: AlbertFak

Forum Jump: