Study Notion
Study Notion
Project Report
Degree of
Submitted to
<444> - <SSSPTM>
DATE:…18/04/2024……………
CERTIFICATE
This is to certify that the work embodies in this project entitled, “<Study
Prof. Neeraj Agrawal Er. Amit Kumar Shukla Prof. Ravi Soni
Director Head of Department-IT Assistant Professor-IT
Page1|
<SSSPTM>
Session 2021-24
Date:
APPROVAL CERTIFICATE
The project report entitled “ED platform study notin”, being submitted by
<Aniket Chaursiya> (< 202144400045 >) has been examined by us and is
hereby approved for the award of degree “Bachelor of Computer
Applications”, for which it has been submitted. It is understood that by
this approval the undersigned do not necessarily endorse or approve any
statement made, the opinion expressed or conclusion drawn therein, but
approve the project only for the purpose for which it has been submitted.
Date: Date:
Page2|
<SSSPTM>
Session 2021-24
Date:
DECLARATION
my own work carried under the joint guidance of Prof. Niraj Kumar
Singh Sir and Prof. Ravi Kumar Soni Sir. I have not submitted the
matter embodied in this report for the award of any other degree.
<Aniket chaursiya>
Registration No : <
Session-2021-2024
Page3|
ACKNOWLEDGEMENT
“A journey is easier when you travel together. Interdependence is certainly more valuable than
independence.”
I would like to thanks, Prof. Niraj Kumar Singh Sir and Prof. Ravi Soni Sir, for providing
regular guidance and insight into my project work. I also thank them for all advice he has given me in the
past year, and for always having time for me, whenever I needed.
I give special thanks to Er. Amit Kumar Shukla Sir, Prof. Anjesh Sir and Prof. Raju Upadhyay
Sir for always being willing to help find solutions to any problems I had with my work.
“The completion of any project depends upon the cooperation, coordination, and
combined efforts of several resources of knowledge, inspiration, and energy”.
I express my gratitude and thanks to all the staff members of Computer Science departments for
their sincere cooperation in furnishing relevant information to complete this Project well in time
successfully.
I extend a special word to my friends, who have been a constant source of inspiration throughout
my project work.
Lastly but not least I must express my cordial thank to my parent and family members who gave
me the moral support without that it is impossible to complete my project work. With this note, I thank
everyone for the support.
(<Aniket Chaurasiya>)
Session-2021-2024
Page4|
CONTENTS
REPORT...................................................................................................……………………………………………...
INTRODUCTION........................................................................................................................................8
OBJECTIVE.............................................................................................................................................. 9
ADVANTAGES OF JAVA........................................................................................................................11
TOOLS/PLATFORM required...................................................................................................................13
PROBLEM DEFINITION...........................................................................................................................14
REQUIREMENT SPECIFICATIONS......................................................................................................14
GANTT CHART......................................................................................................................................16
PERT CHART..........................................................................................................................................18
SYSTEM ANALYSIS......................................................................................................................................1
IDENTIFICATION OF NEED..................................................................................................................1
FEASIBILITY STUDY...............................................................................................................................6
TECHNICAL FEASIBILITY:.................................................................................................................7
ECONOMICAL FEASIBILITY:.............................................................................................................7
OPERATIONAL FEASIBILITY:............................................................................................................8
ANALYSIS................................................................................................................................................... 10
DFD..........................................................................................................................................................10
MODULE DESCRIPTION..........................................................................................................................16
LIST OF REPORTS.....................................................................................................................................22
IMPLEMENTATION METHODOLOGY..............................................................................................23
Page5|
TESTING.....................................................................................................................................................25
LIMITATIONSANDFURTHER ENHANCEMENTS................................................................................28
SECURITY MECHANISM.........................................................................................................................29
SNAPSHOTS.............................................................................................................................................. 30
Page6|
SAMPLE PROJECT
Page7|
INTRODUCTION
The “SCHOOL MANAGEMENT SYSTEM” has been design with the help of two
powerful programming languages “JAVA” and “MySQL”. The “JAVA” being in the
The foreground language is favorite today, due to his interactive user interface and
The background language is favorite many of the programmers because it offers the
much wanted structured query facility. The MySQL provides high security, as the
database is stored in the logical area called “DB Engine”. As “DB Engine” is created
in the virtual memory and end user cannot access that directly it.
developed. The “JAVA” gives the interactive look and “MySQL” gives high security.
have high security. So the “SCHOOL MANAGEMENT SYSTEM” has been developed
VIDYALAYA”.
Page8|
OBJECTIVE
Page9|
PROJECT CATEGORY M E R N
P a g e 10 |
ADVANTAGES OF JAVA
P a g e 11 |
5. Java is interpreted: An interpreter is needed in order to run Java
programs. The programs are compiled into Java Virtual Machine code
called bytecode.
P a g e 12 |
TOOLS/PLATFORM REQUIRED
Operating System
Windows XP ,Windows 7.
Hardware Requirements:
Pentium IV Processor
512 MB RAM
80 GB Hard Disk
Software Requirements:
JDK 5.0
MySQL
Notepad/Editor
Netbeans 7.0
P a g e 13 |
PROBLEM DEFINITION
REQUIREMENT SPECIFICATIONS
P a g e 14 |
Project planning is part of project management, which relates to the use of
schedules such as Gantt charts to plan and subsequently report progress
within the project environment.
Initially, the project scope is defined and the appropriate methods for
completing the project are determined. Following this step, the durations
for the various tasks necessary to complete the work are listed and grouped
into a work breakdown structure. The logical dependencies between tasks
are defined using an activity network diagram that enables identification of
the critical path. Float or slack time in the schedule can be calculated using
software. Then the necessary resources can be estimated and costs for each
activity can be allocated to each resource, giving the total project cost. At
this stage, the project plan may be optimized to achieve the appropriate
balance between resource usage and project duration to comply with the
project objectives. Once established and agreed, the plan becomes what is
known as the baseline. Progress will be measured against the baseline
throughout the life of the project. Analyzing progress compared to the
baseline is known as earned value management.
P a g e 15 |
GANTT CHART
The bars are drawn against a time line. The length of each bar is
proportional to the length of time planned for the activity. Gantt chart can
take different phase depending on their intended use. The Gantt chart of
School Management System is drawn for the time management. The
Gantt chart is drawn below:
P a g e 16 |
YEAR 2015
15st Mar 31st March 1st April 30th April 1st May 31th May
Start
ANALYSI
DESIGN DATABASE(BACKEND)
Report
Write Manual
Finish
P a g e 17 |
PERT CHART
PERT controls time and cost during the project and also facilitate
finding the right balance between completing a project on time and
completing it within the budget. There are thus not one but many critical
paths, depending on the permutations of the estimates for each task. This
makes analysis of critical path in PERT charts very complex. The PERT
chart representation of the School Management System is shown below.
IDENTIFICATION OF NEED
Requirement elicitation.
Requirement specification.
System Modeling.
Requirement validation.
Requirement Management.
Page1|
In other words we can say that requirement analysis is a software
task that bridges the gap between system level requirement
engineering and software design.
say or ask; Both are worried that what they do say will be
misinterpreted; both are thinking about where it might lead (Both
likely have radically different expectation here); Both want to get the
think over with, but at the same time, both want it to be a success.
Page2|
encounter itself. The first set of Context-free question focuses on the
customer, the overall goals, and the benefits. For example, the analyst
might ask: -
Can you show me (or describe) the environment in which the solution
will be used?
Page3|
Are you the right person to answer these questions? Are your answers?
Official”?
Preliminary Investigation: -
Page4|
Here for the Ngo Management System, I have worked on the
preliminary investigation that accomplished the following objectives: -
Conducting interviews.
Page5|
FEASIBILITY STUDY
Technical feasibility.
Operational feasibility.
Economic feasibility.
Social feasibility.
Management feasibility.
Legal feasibility.
Time feasibility.
Page6|
necessary that it should be conducted competently and that no
fundamental errors of judgment are made.
TECHNICAL FEASIBILITY: -
ECONOMICAL FEASIBILITY: -
Page7|
known as Cost/Benefit analysis, the procedure is to determine the
benefits and saving that are expected from a proposed system and
compare them with costs. If benefits outweigh costs, a decision is
taken to design and implement the system. Other weight costs, a
decision is taken to design and implement the system. Otherwise,
further justification or alternative in the proposed system will have to
be made if is to have a chance of being approved. This is an ongoing
effort that improves in accuracy at each phase of the system life cycle.
OPERATIONAL FEASIBILITY: -
Page8|
My project is also fit in Operational Feasibility Study. As I have
explained before this about Technical Feasibility and Economical
Feasibility, this Software is very easy and user-friendly.
I have used a very easy menu system and also used some control
buttons in the easy way by which one can choose the options on his
desire.
1. It is User-Friendly.
2. It is having less paperwork.
3. Efficient tractability.
4. Query can be generated.
5. Various Reports and Forms can be generated.
6. Fully protected by Password and User name for unauthorized
access.
Page9|
ANALYSIS
View/Delete
FEE DETAIL
STUDEN
Demand T
STUDENT REGISTRATION
Add/Update
View/ Print
STUDENT DETAILS
REPORT
P a g e 10 |
REPORT
P a g e 11 |
ACCOUNTANT
LIBRARY CHARGE
TUTION CHARGE
View & Print
OTHER CHARGE ADDMITION CHARGE
PAYMENT MODE
P a g e 12 |
P a g e 13 |
OPERATOR OF SCHOOL
DESIGNATION
V View/Delete/Search
Enter Update EMPLOYEE DETAIL
Demand EMPLOUYpEdEate
P a g e 14 |
MODULE DESCRIPTION
P a g e 15 |
DATA STRUCTURE SNAP SHOT
P a g e 16 |
Student Details (student_add):
P a g e 17 |
Staff Details (Staff_add):-
P a g e 18 |
Admission fees (addfees):
P a g e 19 |
Monthly fees(transaction):-
P a g e 20 |
LIST OF REPORTS
P a g e 21 |
1. Registration: - This report contains the information of all
registered students of the school.
The project can be used as a sub-project for any other projects. The
main future scope is as follows:-
🞛It gives correct information about Student details, Staff details, Fee
etc.
IMPLEMENTATION METHODOLOGY
P a g e 22 |
limitation. To implement of this software, the followings are the
necessary:
TESTING
b) TESTING STRATEGY:-
c) UNIT TESTING:-
P a g e 24 |
modules must be successful in the unit test before start of the
integration testing. The software developed for e-banking is tested
module wise by giving normal values and extreme values as input. All
the bugs have been identified and removed. The software designed is
tested module wise. Before using the software, an employee has to give
organization name and password.
INTEGRATION TESTING:-
VALIDATION TESTING:-
P a g e 25 |
TEST CASE DESIGN
The techniques that are used in deriving the test cases are explained
below.
CONDITION TESTING:-
EQUIVALENCE PARTITIONING:-
P a g e 26 |
test cases can be derived. A typical test uncovers a class errors might
otherwise require many more test cases before the error is observed.
Equivalence classes for input determine the valid and invalid inputs for
the program
LIMITATIONSANDFURTHER ENHANCEMENTS
LIMITATIONS:
Considering the fact that has already gone ahead the following areas
needs to be further probed for improving the system to meet the
changing scenario.
P a g e 27 |
indenting, micro transactions, and customer relationship
management.
SECURITY MECHANISM
P a g e 28 |
password to a user. A user is able to work on the software if s/he is an
authorized user with user id and password.
SNAPSHOTS
P a g e 29 |
LOGIN FORM (login.java)
import javax.swing.JOptionPane;
import java.sql.*;
//ResultSet rs;
/**
*/
public login() {
initComponents();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
P a g e 30 |
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
txtpass = new
javax.swing.JButton();
jLabel6 = new
javax.swing.JLabel(); jLabel8 =
new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(204, 204, 204), new java.awt.Color(204, 204, 204)));
P a g e 31 |
jLabel1.setBackground(new java.awt.Color(0, 204, 102));
P a g e 32 |
jLabel1.setForeground(new java.awt.Color(102, 102, 102));
jLabel1.setText("LOGIN - Panel");
jLabel2.setText("USER ID :");
jLabel3.setText("PASSWORD :");
login.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow"
));
login.setText("Submit");
login.addActionListener(new java.awt.event.ActionListener() {
loginActionPerformed(evt);
});
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
P a g e 33 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
P a g e 34 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(txtuser, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33,
Short.MAX_VALUE)
.addComponent(login)
);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/child.jpg"))); //
NOI18N
P a g e 35 |
jLabel6.setFont(new java.awt.Font("Trebuchet MS", 1, 14)); // NOI18N
jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/login.jpg"))); //
NOI18N
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel5)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel6)))
P a g e 36 |
.addGap(114, 114, 114))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addContainerGap())))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 37 |
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 227,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
Statement st;
Connection cn;
ResultSet rs;
String user,pass,name;
user=txtuser.getText().toLowerCase();
pass=txtpass.getText();
try
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","bhaskar");
st=cn.createStatement();
P a g e 38 |
if(user.equals("admin"))
{
new main_admin().show();
this.dispose();
}
else
{
main_user obj= new main_user();
obj.hello.setText("WELCOME "+name);
obj.setVisible(true);
this.dispose();
}
}
else
{
sql="Select* from login where user='"+user+"'";
rs=st.executeQuery(sql);
if(rs.next())
{
JOptionPane.showMessageDialog(rootPane,"password is wrong");
}
else
{
JOptionPane.showMessageDialog(rootPane,"User is wrong");
}
// JOptionPane.showMessageDialog(null, "Invalid Login");
txtpass.setText(null);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
// TODO add your handling code here:
P a g e 39 |
}//GEN-LAST:event_loginActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
P a g e 40 |
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel
jPanel1; private
javax.swing.JButton login;
private javax.swing.JPasswordField
txtpass; private javax.swing.JTextField
txtuser;
// End of variables declaration//GEN-END:variables
}
P a g e 41 |
MAIN FORM (main_admin.java) for admin :
code :
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class home extends javax.swing.JFrame {
P a g e 42 |
/**
* Creates new form home
*/
public home() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/admission.png"))); // NOI18N
jLabel2.setText("jLabel2");
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/human.png"))); //
NOI18N
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/library.png"))); //
NOI18N
P a g e 44 |
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/setting.png"))); //
NOI18N
jLabel6.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/studentde.png"))); // NOI18N
jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fees.png"))); //
NOI18N
jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jawaher.jpg")));
// NOI18N
P a g e 45 |
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 113,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(51, 51, 51)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 819,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 810,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(132, 132, 132)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 234,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel10)
.addGap(18, 18, 18)
.addComponent(jLabel11)
.addGap(103, 103, 103))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel10)
.addComponent(jLabel11)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 292,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
P a g e 46 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
60, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel4)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 91,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(82, 82, 82)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 97,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(70, 70, 70)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 97,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
jMenu1.setText("Student");
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_A, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText("Admission");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_D, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Student Details");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
P a g e 47 |
}
});
jMenu1.add(jMenuItem5);
jMenuItem24.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_U, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem24.setText("Update Student profile");
jMenuItem24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem24ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem24);
jMenuItem26.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_D, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem26.setText("Delete Student Profile");
jMenuItem26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem26ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem26);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_E, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Exit");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);
jMenuBar1.add(jMenu1);
jMenu2.setText("Teacher");
jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_M, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem6.setText("Create faculty member");
P a g e 48 |
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);
jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_F, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem7.setText("View Faculty Information");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem7);
jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_I, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem8.setText("Update Faculty Information");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem8);
jMenuBar1.add(jMenu2);
jMenu4.setText("Fee management");
P a g e 49 |
}
});
jMenu4.add(jMenuItem12);
jMenuItem22.setText("monthly fees");
jMenuItem22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem22ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem22);
jMenuItem28.setText("Monthly Report");
jMenu7.add(jMenuItem28);
jMenuItem29.setText("Yearly Report");
jMenu7.add(jMenuItem29);
jMenu4.add(jMenu7);
jMenuBar1.add(jMenu4);
jMenu5.setText("Setting");
jMenuItem9.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_U, java.awt.event.InputEvent.CTRL_MASK));
P a g e 50 |
jMenuItem9.setText("Create User");
jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem9ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem9);
jMenuItem10.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_U, java.awt.event.InputEvent.SHIFT_MASK));
jMenuItem10.setText("Modify User");
jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem10ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem10);
jMenuItem11.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_D, java.awt.event.InputEvent.SHIFT_MASK));
jMenuItem11.setText("Delete User");
jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem11ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem11);
jMenuItem15.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_S, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem15.setText("Search User Information");
jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem15ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem15);
jMenuItem14.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_B, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem14.setText("Backup database");
P a g e 51 |
jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem14ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem14);
jMenuItem13.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_R, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem13.setText("Restore database");
jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem13ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem13);
jMenu6.setText("Change Password");
jMenuItem19.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.
VK_P, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem19.setText("User Password");
jMenuItem19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem19ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem19);
jMenuItem20.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_P, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem20.setText("Admin password");
jMenuItem20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem20ActionPerformed(evt);
}
});
jMenu6.add(jMenuItem20);
jMenu5.add(jMenu6);
P a g e 52 |
jMenuItem25.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent
.VK_H, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem25.setText("Help");
jMenuItem25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem25ActionPerformed(evt);
}
});
jMenu5.add(jMenuItem25);
jMenuBar1.add(jMenu5);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
P a g e 53 |
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
update_teacher_form myform = new update_teacher_form();
myform.setVisible(true);
// TODO add your handling code here:
}
P a g e 54 |
if(processComplete==1){//if values equal 1 process failed
}catch(Exception e){
JOptionPane.showMessageDialog(null,e);//exeception handling
}
// TODO add your handling code here:
}
P a g e 55 |
update_user_profile myform = new update_user_profile();
myform.setVisible(true);
// TODO add your handling code here:
}
P a g e 56 |
myform.setVisible(true);
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
P a g e 57 |
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(home.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
P a g e 58 |
private javax.swing.JMenu jMenu7;
private javax.swing.JMenuBar
jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem10;
private javax.swing.JMenuItem jMenuItem11;
private javax.swing.JMenuItem jMenuItem12;
private javax.swing.JMenuItem jMenuItem13;
private javax.swing.JMenuItem jMenuItem14;
private javax.swing.JMenuItem jMenuItem15;
private javax.swing.JMenuItem jMenuItem19;
private javax.swing.JMenuItem jMenuItem20;
private javax.swing.JMenuItem jMenuItem21;
private javax.swing.JMenuItem jMenuItem22;
private javax.swing.JMenuItem jMenuItem23;
private javax.swing.JMenuItem jMenuItem24;
private javax.swing.JMenuItem jMenuItem25;
private javax.swing.JMenuItem jMenuItem26;
private javax.swing.JMenuItem jMenuItem27;
private javax.swing.JMenuItem jMenuItem28;
private javax.swing.JMenuItem jMenuItem29;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenuItem jMenuItem7;
private javax.swing.JMenuItem jMenuItem8;
private javax.swing.JMenuItem jMenuItem9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
// End of variables declaration
}
P a g e 59 |
Student Admission form :
code :
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
P a g e 60 |
* @author sand
*/
public class student_admission extends javax.swing.JFrame {
/**
* Creates new form student_admission
*/
public student_admission() {
initComponents();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//get current date time with Date()
Date date = new Date();
txtadmissiondate.setText(dateFormat.format(date));
int i;
for(i=1;i<=31;i++)
{
cmbdate.addItem(i);
} for(i=1900;i<=2015;i+
+)
{
cmbyear.addItem(i);
Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
int addno;
P a g e 61 |
if (rs.next()) {
addno = rs.getInt("admissionno");
addno = addno + 1;
} else {
addno = 1;
}
txtadmission.setText("" + addno);
} catch (Exception e) {
JOptionPane.showMessageDialog(rootPane, e.getMessage());
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new
javax.swing.JLabel();
cmbclass = new javax.swing.JComboBox();
cmbsection = new javax.swing.JComboBox();
txtroll = new javax.swing.JTextField();
txtadmission = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
P a g e 62 |
txtstudentname = new javax.swing.JTextField();
P a g e 63 |
txtfathername = new javax.swing.JTextField();
txtmothername = new javax.swing.JTextField();
txtfatheroccupation = new javax.swing.JTextField();
cmbdate = new javax.swing.JComboBox();
cmbmonth = new javax.swing.JComboBox();
cmbyear = new javax.swing.JComboBox();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtcontactno = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtpaddress = new javax.swing.JTextArea();
jLabel15 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jScrollPane2 = new
javax.swing.JScrollPane(); txtladdress = new
javax.swing.JTextArea();
txtpicturename = new
javax.swing.JTextField(); jLabel16 = new
javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
txtadmissiondate = new
javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(" ");
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
});
addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
formKeyPressed(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
formKeyTyped(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), new java.awt.Color(204, 204, 204)),
"Create Student Admission :", javax.swing.border.TitledBorder.CENTER,
P a g e 64 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14),
new java.awt.Color(153, 0, 0))); // NOI18N
P a g e 65 |
jLabel1.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N
jLabel1.setText("Class");
P a g e 66 |
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66)
.addComponent(jLabel4)
.addGap(79, 79, 79)
.addComponent(txtadmission, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(86, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(txtadmission, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(26, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(240, 240, 240), null), null), "Fill Student Details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
3, 12), new java.awt.Color(102, 0, 0))); // NOI18N
P a g e 67 |
jLabel7.setText("Mother's Name :");
txtstudentname.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtstudentnameKeyReleased(evt);
}
});
txtfathername.setText(" ");
txtfathername.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtfathernameKeyReleased(evt);
}
});
txtmothername.setText(" ");
txtmothername.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtmothernameKeyReleased(evt);
}
});
txtfatheroccupation.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
P a g e 68 |
txtfatheroccupationKeyReleased(evt);
}
});
buttonGroup1.add(rmale);
rmale.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N
rmale.setText("Male");
buttonGroup1.add(rfemale);
rfemale.setFont(new java.awt.Font("Palatino Linotype", 0, 14)); // NOI18N
rfemale.setText("Female");
txtpaddress.setColumns(20);
txtpaddress.setRows(5);
txtpaddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtpaddressKeyReleased(evt);
}
});
jScrollPane1.setViewportView(txtpaddress);
jButton2.setText("Browse ");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
P a g e 69 |
jButton1.setText("Submit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
txtladdress.setColumns(20);
txtladdress.setRows(5);
txtladdress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtladdressKeyReleased(evt);
}
});
jScrollPane2.setViewportView(txtladdress);
jLabel16.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); // NOI18N
P a g e 70 |
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(txtmothername,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfathername,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfatheroccupation,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtstudentname,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(67, 67, 67))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(63, 63, 63)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.PREFERRED_SIZE, 197,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 71 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRE
LATED)
.addComponent(cmbmonth,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELAT
ED)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
50, Short.MAX_VALUE)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(rmale)
.addGap(55, 55, 55)
.addComponent(rfemale)
.addGap(15, 15, 15)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
193, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(txtemail)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcontactno, javax.swing.GroupLayout.DEFAULT_SIZE, 185,
Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtpicturename,
javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(337, 337, 337))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 684, Short.MAX_VALUE))
P a g e 72 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 136,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 119,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(32, 32, 32)
.addComponent(jButton3)
.addGap(64, 64, 64))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtstudentname,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(25, 25, 25)
P a g e 73 |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel6)
.addComponent(txtfathername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE,
20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcontactno,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(13, 13, 13)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(txtmothername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(3, 3, 3)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel8)
.addComponent(txtfatheroccupation,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 127,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
P a g e 74 |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbmonth, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel10)
.addComponent(rmale)
.addComponent(rfemale)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(49, 49, 49)
.addComponent(jLabel14)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel15)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(96, 96, 96)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton3)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(105, 105, 105))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(59, 59, 59)
P a g e 75 |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(txtpicturename, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(70, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
admission=txtadmission.getText();
admissionno =
Integer.parseInt(admission); rollid =
txtroll.getText();
rollno = Integer.parseInt(rollid);
// sclass = cmbclass.getSelectedItem().toString();
P a g e 76 |
// section = cmbsection.getSelectedItem().toString();
// sname = txtstudentname.getText();
// fname = txtfathername.getText();
//mname = txtmothername.getText();
// foccupation = txtfatheroccupation.getText();
// date=cmbdate.getSelectedItem().toString();
//month=cmbmonth.getSelectedItem().toString();
// year=cmbyear.getSelectedItem().toString();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
// admissiondate =txtpicturename.getText();
// admissiondate = dtpadmissiondate.getDate().toString();
// contactno = txtcontactno.getText();
//email = txtemail.getText();
// paddress = txtpaddress.getText();
// laddress = txtladdress.getText();
// picturename=jLabel16.getIcon();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
// String p = "insert into studentinfo values(" + admissionno + "," + rollno + ",'" +
sclass + "','" + section + "','" + sname + "','" + fname + "','" + mname + "','" + foccupation + "','" +
date + "','" + month + "','" + year + "','" + gender + "','" + admissiondate + "','" + email + "','"
+contactno + "','" + paddress + "','" + laddress + "')";
String sql = "INSERT INTO studentinfo (admissionno, rollno, class , section , sname ,
fname , mname ,foccupation,dt,month, year ,
gender,admissiondate ,email,contactno,paddress,laddress,photo) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
P a g e 77 |
PreparedStatement statement = cn1.prepareStatement(sql);
statement.setInt(1,admissionno );
statement.setInt(2,rollno);
statement.setString(3,cmbclass.getSelectedItem().toString() );
statement.setString(4,cmbsection.getSelectedItem().toString());
statement.setString(5,txtstudentname.getText());
statement.setString(6,txtfathername.getText());
statement.setString(7,txtmothername.getText());
statement.setString(8,txtfatheroccupation.getText());
statement.setString(9,cmbdate.getSelectedItem().toString());
statement.setString(10,cmbmonth.getSelectedItem().toString());
statement.setString(11,cmbyear.getSelectedItem().toString());
statement.setString(12,gender);
statement.setString(13,txtadmissiondate.getText());
statement.setString(14,txtcontactno.getText());
statement.setString(15,txtemail.getText());
statement.setString(16,txtpaddress.getText());
statement.setString(17,txtladdress.getText());
InputStream inputStream = new
FileInputStream(new File(txtpicturename.getText()));
statement.setBlob(18, inputStream);
int row =
statement.executeUpdate(); if (row >
0) {
JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
}
// TODO add your handling code here:
}
Connection cn;
Statement st;
ResultSet rs;
sclass= cmbclass.getSelectedItem().toString();
ssection=cmbsection.getSelectedItem().toString();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
rs=st.executeQuery(sql);
if(rs.next())
{
rollno=rs.getInt("rollno");
rollno=rollno+1;
txtroll.setText(""+rollno);
}
else
{
P a g e 79 |
rollno=1;
txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
if(evt.getKeyCode() == evt.VK_C) {
JOptionPane.showMessageDialog(null,"click");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // trying
to close
} else {
System.out.println("not escaped");
}
P a g e 80 |
txtfathername.setText(null);
txtmothername.setText(null);
txtfatheroccupation.setText(null);
//cmbdate.setModel(null);
// cmbmonth.setModel(null);
//cmbyear.setModel(null);
buttonGroup1.clearSelection();
// ImageIcon imgThisImg = new ImageIcon("profilepic.png");
// jLabel16.setIcon(imgThisImg);
txtpicturename.setText(null);
txtadmissiondate.setText(null);
txtcontactno.setText(null);
txtemail.setText(null);
txtpaddress.setText(null);
txtladdress.setText(null);
Statement st;
Connection cn;
ResultSet rs;
String sql;
int addno;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
//addno=Integer.parseInt(txtadd.getText());
st=cn.createStatement();
if(rs.next())
{
addno=rs.getInt("admissionno");
addno=addno+1;
}
else
{
addno=1;
P a g e 81 |
}
txtadmission.setText(""+addno);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane, e.getMessage());
}
P a g e 82 |
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(student_admission.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 83 |
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup
buttonGroup1; private javax.swing.JComboBox
cmbclass; private javax.swing.JComboBox
cmbdate; private javax.swing.JComboBox
cmbmonth; private javax.swing.JComboBox
cmbsection; private javax.swing.JComboBox
cmbyear; private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; private
javax.swing.JRadioButton rfemale; private
javax.swing.JRadioButton rmale; private
javax.swing.JTextField txtadmission;
private javax.swing.JTextField txtadmissiondate;
private javax.swing.JTextField txtcontactno;
private javax.swing.JTextField txtemail;
private javax.swing.JTextField txtfathername;
private javax.swing.JTextField txtfatheroccupation;
private javax.swing.JTextArea txtladdress;
private javax.swing.JTextField txtmothername;
private javax.swing.JTextArea txtpaddress;
private javax.swing.JTextField txtpicturename;
private javax.swing.JTextField txtroll;
P a g e 84 |
protected javax.swing.JTextField txtstudentname;
// End of variables declaration
}
Student Details form:
Code :
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
import java.sql.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class studentdetail extends javax.swing.JFrame {
P a g e 85 |
/**
* Creates new form studentdetails
*/
public studentdetail() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/search.jpg"))); //
NOI18N
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Update student Record :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
P a g e 86 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12),
new java.awt.Color(255, 0, 0))); // NOI18N
jButton7.setText("Search");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
P a g e 87 |
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Admission no", "Student name", "Father's name", "Class", "Section", "Roll", "Contact
no"
}
));
jScrollPane1.setViewportView(jTable1);
P a g e 88 |
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
P a g e 89 |
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(20, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jButton1)
P a g e 90 |
.addComponent(jButton3)
.addComponent(jButton4)
.addComponent(jButton2)
.addComponent(jButton8)
.addComponent(jButton6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38,
Short.MAX_VALUE)
.addComponent(jButton5)
.addContainerGap())
);
pack();
}// </editor-fold>
P a g e 91 |
Connection
cn;
ResultSet rs;
String
temp,name,fname,mname,foccupation,dob,gender,contactno,paddress,laddress,sclass,sec
tion,roll,admissionno,admissiondate,photo;
int id=0;
int allot=0;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn.createStatement();
String p="select admissionno,sname,fname,class,section,rollno,contactno from
studentinfo";
rs=st1.executeQuery(p);
while (rs.next())
{
admissionno= rs.getString("admissionno");
name= rs.getString("sname");
fname= rs.getString("fname");
sclass= rs.getString("class");
section= rs.getString("section");
id = rs.getInt("rollno");
contactno = rs.getString("contactno");
model.addRow(new
Object[]{admissionno,name,fname,sclass,section,id,contactno});
}
//DefaultTableModel model = (DefaultTableModel) table.getModel();
st1.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
st1=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+n)==JOptionPane.YES_OPTION)
{
String p1="delete from studentinfo where admissionno='"+d+"'";
P a g e 93 |
st1.execute(p1);
//st1.execute(p1);
String d=jTable1.getValueAt(x,0).toString();
int id=Integer.parseInt(d);
try {
Class.forName("com.mysql.jdbc.Driver");
if(JOptionPane.showConfirmDialog(rootPane, "Want to UPDATE Name=
"+d)==JOptionPane.YES_OPTION)
{
Connection cn=
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
PreparedStatement ps = cn.prepareStatement("UPDATE studentinfo SET sname
= ? ,fname = ? ,mname = ?,foccupation = ?,dob = ?,gender = ?,contactno = ?,paddress
= ?,laddress = ?,class = ?,section = ?,roll = ?,admissiondate = ?,photo = ? WHERE
admissionno = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));
P a g e 94 |
ps.setString(8, (String) jTable1.getValueAt(x, 8));
ps.setString(9, (String) jTable1.getValueAt(x, 9));
ps.setString(10, (String) jTable1.getValueAt(x, 10));
ps.setString(11, (String) jTable1.getValueAt(x, 11));
ps.setString(12, (String) jTable1.getValueAt(x, 12));
ps.setString(13, (String) jTable1.getValueAt(x, 13));
ps.setString(14, (String) jTable1.getValueAt(x, 14));
ps.executeUpdate();
ps.close();
cn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// TODO add your handling code here:
}
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from studentinfo where admissionno ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
sclass=rs.getString("class");
section=rs.getString("section");
rollid=rs.getString("rollno");
studentname=rs.getString("sname");
fname=rs.getString("fname");
mname=rs.getString("mname");
foccupation=rs.getString("foccupation");
date =rs.getInt("dt");
P a g e 95 |
//date = rs.getString("dt");
month=rs.getString("month");
year =rs.getInt("year");
gender=rs.getString("gender");
admissiondate=rs.getString("admissiondate");
contactno=rs.getString("contactno");
email=rs.getString("email");
paddress=rs.getString("paddress");
laddress=rs.getString("laddress");
java.sql.Blob blob = rs.getBlob("photo");
student_update myform = new student_update();
myform.txtadmissionno.setText(""+admissionno);
myform.cmbclass.setSelectedItem(sclass);
myform.cmbsection.setSelectedItem(section);
myform.txtroll.setText(rollid);
myform.txtstudentname.setText(studentname);
myform.txtfathername.setText(fname);
myform.txtmothername.setText(mname);
myform.txtfatheroccupation.setText(foccupation);
//myform.txtdob.setText(month);
//myform.txtdob.setText(year);
if(gender.equals("Male"))
{
myform.rmale.setSelected(true);
}
else
{
myform.rfemale.setSelected(true);
}
myform.cmbdate.setSelectedItem(date);
myform.cmbmonth.setSelectedItem(month);
myform.cmbyear.setSelectedItem(year);
myform.txtadmissiondate.setText(admissiondate);
myform.txtemail.setText(email);
myform.txtcontactno.setText(contactno);
myform.txtpermanentaddress.setText(paddress);
myform.txtlocaladdress.setText(laddress);
BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());
Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.spicture.setIcon(icon);
P a g e 96 |
//myform.f1t2.setText(f4t2.getText());
myform.setVisible(true);
// txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (InstantiationException ex) {
P a g e 97 |
java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(studentdetail.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
}
//</editor-fold>
P a g e 98 |
Student updation form :
Code :
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class update_student_profile extends javax.swing.JFrame {
/**
* Creates new form update_student_profile
*/
public update_student_profile () {
initComponents();
P a g e 99 |
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Update Student Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(0, 102, 102))); // NOI18N
P a g e 100 |
.addComponent(txtadmissionno, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);
P a g e 101 |
Connection cn;
ResultSet rs;
String admission,rollid,studentname, fname, mname, foccupation,month, gender = "",
contactno, email, paddress, laddress, sclass, section, admissiondate,picturename;
int admissionno,date ,year;
admission=txtadmissionno.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from studentinfo where admissionno ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
rollid=rs.getString("rollno");
studentname=rs.getString("sname");
fname=rs.getString("fname");
mname=rs.getString("mname");
foccupation=rs.getString("foccupation");
date =rs.getInt("dt");
//date = rs.getString("dt");
month=rs.getString("month");
year =rs.getInt("year");
gender=rs.getString("gender");
admissiondate=rs.getString("admissiondate");
contactno=rs.getString("contactno");
email=rs.getString("email");
paddress=rs.getString("paddress");
laddress=rs.getString("laddress");
java.sql.Blob blob = rs.getBlob("photo");
student_update myform = new student_update();
myform.txtadmissionno.setText(""+admissionno);
myform.txtroll.setText(rollid);
myform.txtstudentname.setText(studentname);
myform.txtfathername.setText(fname);
myform.txtmothername.setText(mname);
myform.txtfatheroccupation.setText(foccupation);
//myform.txtdob.setText(month);
//myform.txtdob.setText(year);
if(gender.equals("Male"))
P a g e 102 |
{
myform.rmale.setSelected(true);
}
else
{
myform.rfemale.setSelected(true);
}
myform.cmbdate.setSelectedItem(date);
myform.cmbmonth.setSelectedItem(month);
myform.cmbyear.setSelectedItem(year);
myform.txtadmissiondate.setText(admissiondate);
myform.txtemail.setText(email);
myform.txtcontactno.setText(contactno);
myform.txtpermanentaddress.setText(paddress);
myform.txtlocaladdress.setText(laddress);
BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());
Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.spicture.setIcon(icon);
//myform.f1t2.setText(f4t2.getText());
myform.setVisible(true);
// txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
P a g e 103 |
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 104 |
}
Update Form :
Code :
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
P a g e 105 |
/**
*
* @author sand
*/
public class student_update extends javax.swing.JFrame {
/**
* Creates new form student_update
*/
String filename="";
public student_update() {
initComponents();
int i;
for(i=1;i<=31;i++)
{
cmbdate.addItem(i);
}
for(i=1900;i<=2015;i++)
{
cmbyear.addItem(i);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtroll = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
P a g e 106 |
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
txtstudentname = new javax.swing.JTextField();
txtfathername = new javax.swing.JTextField();
txtmothername = new javax.swing.JTextField();
txtfatheroccupation = new javax.swing.JTextField();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtadmissiondate = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
txtcontactno = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtpermanentaddress = new
javax.swing.JTextArea(); jScrollPane2 = new
javax.swing.JScrollPane(); txtlocaladdress = new
javax.swing.JTextArea(); jButton1 = new
javax.swing.JButton();
spicture = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
cmbdate = new javax.swing.JComboBox();
cmbmonth = new javax.swing.JComboBox();
cmbyear = new javax.swing.JComboBox();
txtpicturename = new
javax.swing.JTextField(); jButton3 = new
javax.swing.JButton(); cmbclass = new
javax.swing.JComboBox(); cmbsection = new
javax.swing.JComboBox();
txtadmissionno = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel2.setText("Class :");
jLabel3.setText("Section :");
jLabel4.setText("Roll No :");
P a g e 107 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createCompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(204, 204, 204), null), null), " Student Profile",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14),
new java.awt.Color(153, 0, 0))); // NOI18N
jLabel10.setText("Gender :");
jLabel12.setText("E-Mail :");
jLabel13.setText("Contact No :");
buttonGroup1.add(rmale);
rmale.setText("Male");
buttonGroup1.add(rfemale);
rfemale.setText("Female");
txtpermanentaddress.setColumns(20);
txtpermanentaddress.setRows(5);
jScrollPane1.setViewportView(txtpermanentaddress);
txtlocaladdress.setColumns(20);
txtlocaladdress.setRows(5);
jScrollPane2.setViewportView(txtlocaladdress);
P a g e 108 |
jButton1.setText("Update");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
spicture.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); // NOI18N
jButton2.setText("Brouse");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
P a g e 109 |
.addComponent(jLabel6)
.addComponent(jLabel5)
.addComponent(jLabel10))
.addGap(41, 41, 41)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING, false)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
.addComponent(txtfathername)
.addComponent(txtmothername)
.addComponent(txtfatheroccupation)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(rmale)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.REL
ATED)
.addComponent(rfemale))
.addComponent(txtstudentname))
.addGap(72, 72, 72)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.TRAILING)
.addComponent(jLabel13)
.addComponent(jLabel12)
.addComponent(jLabel14)
.addComponent(jLabel15)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(cmbmonth, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(78, 78, 78)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(txtcontactno, javax.swing.GroupLayout.PREFERRED_SIZE,
166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE, 166,
javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 110 |
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
119, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(spicture, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtpicturename))
.addGap(45, 45, 45))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(jButton3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))))
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel12)
.addComponent(txtstudentname,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
P a g e 111 |
.addComponent(jLabel6)
.addComponent(jLabel13)
.addComponent(txtfathername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtcontactno,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel14)))
.addComponent(txtmothername,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)
.addComponent(jLabel8)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(txtfatheroccupation,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(9, 9, 9)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout
.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(cmbdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbmonth,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbyear, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout
.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(rmale)
.addComponent(rfemale))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
P a g e 112 |
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(spicture, javax.swing.GroupLayout.PREFERRED_SIZE, 118,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton2)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel11)
.addComponent(txtadmissiondate,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtpicturename,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77,
Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton3))
.addGap(36, 36, 36))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel15)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))))
);
P a g e 113 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(134, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(82, 82, 82)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(87, 87, 87)
.addComponent(jLabel3)
.addGap(104, 104, 104)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(95, 95, 95)
.addComponent(jLabel4)
.addGap(58, 58, 58)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(48, 48, 48))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(372, 372, 372))))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 114 |
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(54, Short.MAX_VALUE))
);
Statement st1;
Connection cn1;
boolean q;
admission=txtadmissionno.getText();
admissionno =
Integer.parseInt(admission); rollid =
txtroll.getText();
P a g e 115 |
rollno = Integer.parseInt(rollid);
sclass = cmbclass.getSelectedItem().toString();
section = cmbsection.getSelectedItem().toString();
sname = txtstudentname.getText();
fname = txtfathername.getText();
mname = txtmothername.getText();
foccupation = txtfatheroccupation.getText();
date=cmbdate.getSelectedItem().toString();
month=cmbmonth.getSelectedItem().toString();
year=cmbyear.getSelectedItem().toString();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
picturename =txtpicturename.getText();
admissiondate = txtadmissiondate.getText();
contactno = txtcontactno.getText();
email = txtemail.getText();
paddress = txtpermanentaddress.getText();
laddress =txtlocaladdress.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
// st1=cn1.createStatement();
if(filename.equals(""))
{
P a g e 116 |
statement.setInt(1,rollno);
statement.setString(2,cmbclass.getSelectedItem().toString() );
statement.setString(3,cmbsection.getSelectedItem().toString());
statement.setString(4,txtstudentname.getText());
statement.setString(5,txtfathername.getText());
statement.setString(6,txtmothername.getText());
statement.setString(7,txtfatheroccupation.getText());
statement.setString(8,cmbdate.getSelectedItem().toString());
statement.setString(9,cmbmonth.getSelectedItem().toString());
statement.setString(10,cmbyear.getSelectedItem().toString());
statement.setString(11,gender);
statement.setString(12, txtadmissiondate.getText());
statement.setString(13,txtemail.getText());
statement.setString(14,txtcontactno.getText());
statement.setString(15,txtpermanentaddress.getText());
statement.setString(16,txtlocaladdress.getText());
int row =
statement.executeUpdate(); if (row >
0)
{
statement.setInt(1,rollno);
statement.setString(2,cmbclass.getSelectedItem().toString() );
statement.setString(3,cmbsection.getSelectedItem().toString());
statement.setString(4,txtstudentname.getText());
statement.setString(5,txtfathername.getText());
statement.setString(6,txtmothername.getText());
statement.setString(7,txtfatheroccupation.getText());
P a g e 117 |
statement.setString(8,cmbdate.getSelectedItem().toString());
statement.setString(9,cmbmonth.getSelectedItem().toString());
statement.setString(10,cmbyear.getSelectedItem().toString());
statement.setString(11,gender);
statement.setString(12, txtadmissiondate.getText());
statement.setString(13,txtemail.getText());
statement.setString(14,txtcontactno.getText());
statement.setString(15,txtpermanentaddress.getText());
statement.setString(16,txtlocaladdress.getText());
InputStream inputStream = new FileInputStream(new
File(txtpicturename.getText()));
statement.setBlob(17, inputStream);
int row = statement.executeUpdate();
if (row > 0)
{
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 118 |
catch(IOException e)
{
st=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+sname)==JOptionPane.YES_OPTION)
{
String p1="delete from studentinfo where admissionno='"+admissionno+"'";
st.execute(p1);
//st1.execute(p1);
}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
P a g e 119 |
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(student_update.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
}
//</editor-fold>
P a g e 120 |
new student_update().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup
buttonGroup1; public javax.swing.JComboBox
cmbclass;
public javax.swing.JComboBox cmbdate;
public javax.swing.JComboBox cmbmonth;
public javax.swing.JComboBox
cmbsection; public
javax.swing.JComboBox cmbyear; private
javax.swing.JButton jButton1; private
javax.swing.JButton jButton2; private
javax.swing.JButton jButton3; private
javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; public
javax.swing.JRadioButton rfemale; public
javax.swing.JRadioButton rmale; public
javax.swing.JLabel spicture;
public javax.swing.JTextField txtadmissiondate;
public javax.swing.JTextField txtadmissionno;
public javax.swing.JTextField txtcontactno;
public javax.swing.JTextField txtemail;
public javax.swing.JTextField txtfathername;
public javax.swing.JTextField txtfatheroccupation;
public javax.swing.JTextArea txtlocaladdress;
P a g e 121 |
public javax.swing.JTextField txtmothername;
public javax.swing.JTextArea
txtpermanentaddress;
P a g e 122 |
private javax.swing.JTextField txtpicturename;
public javax.swing.JTextField txtroll;
public javax.swing.JTextField txtstudentname;
// End of variables declaration
}
Delate student profile:
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
P a g e 123 |
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class delate_student_profile extends javax.swing.JFrame {
/**
* Creates new form update_student_profile
*/
public delate_student_profile() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Delate Student Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(102, 0, 102))); // NOI18N
txtadmissionsearch.addMouseMotionListener(new
java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
P a g e 124 |
txtadmissionsearchMouseMoved(evt);
}
});
txtadmissionsearch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionsearchKeyReleased(evt);
}
});
P a g e 125 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(txtadmissionsearch,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
try
{
P a g e 126 |
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Are u Sure Delete This
Profile?")==JOptionPane.YES_OPTION)
{
String p1="delete from studentinfo where admissionno='"+admissionno+"'";
st.execute(p1);
//st1.execute(p1);
}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}
P a g e 127 |
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from studentinfo where admissionno ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
studentname=rs.getString("sname");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
P a g e 128 |
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 129 |
Teacher Registration form:
Code :
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
P a g e 130 |
/**
*
* @author sand
*/
public class teacher_registration extends javax.swing.JFrame {
/**
* Creates new form teacher_registration
*/
public teacher_registration() {
initComponents();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//get current date time with Date()
Date date = new Date();
lbldate.setText(dateFormat.format(date));
Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
int addno;
P a g e 131 |
/**
P a g e 132 |
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(907, 520));
setResizable(false);
P a g e 133 |
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
P a g e 134 |
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setText("Teacher Name :");
txttname.setText(" ");
txtcontactno.setText(" ");
txtemailid.setText(" ");
txtcourse.setText(" ");
buttonGroup1.add(rmale);
P a g e 135 |
rmale.setText("Male");
buttonGroup1.add(rfemale);
rfemale.setText("Female");
teacherpic.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/teacher.gif"))); // NOI18N
txtaddress.setColumns(20);
txtaddress.setRows(5);
jScrollPane1.setViewportView(txtaddress);
jButton3.setText("Brouse");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
txtpicturename.setText(" ");
txtqualification.setText(" ");
P a g e 136 |
.addComponent(rfemale))
.addComponent(txtcontactno)
.addComponent(txttname)
.addComponent(txtemailid)
.addComponent(txtcourse)
.addComponent(txtexperience)
.addComponent(txtqualification, javax.swing.GroupLayout.DEFAULT_SIZE, 195,
Short.MAX_VALUE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(teacherpic)
.addGap(72, 72, 72)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 108,
Short.MAX_VALUE)
.addComponent(txtpicturename))
.addGap(59, 59, 59))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(jLabel8)
.addGap(40, 40, 40)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 115, Short.MAX_VALUE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(43, 43, 43)
.addComponent(jButton2)
.addGap(67, 67, 67))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
P a g e 137 |
.addComponent(jLabel2)
.addComponent(txttname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtcontactno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtemailid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtcourse, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(teacherpic)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(txtpicturename,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(txtexperience, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
P a g e 138 |
.addComponent(jLabel7)
.addComponent(txtqualification,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(rfemale)
.addComponent(rmale)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(0, 0, Short.MAX_VALUE))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(21, Short.MAX_VALUE))
);
jLabel13.setText("Date :");
P a g e 139 |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 615,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9)
.addGap(40, 40, 40)
.addComponent(lblid, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
36, Short.MAX_VALUE)
.addComponent(lbldate, javax.swing.GroupLayout.PREFERRED_SIZE, 135,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(47, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel9)
.addComponent(lblid, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 15,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel13)
.addComponent(lbldate, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE)))
P a g e 140 |
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 78,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(36, 36, 36))
);
Statement st1;
Connection cn1;
boolean q;
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
String sql = "INSERT INTO teacherinfo(id, date, tname, contactno, email , course ,
experience ,qualification ,sex ,address ,photo) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
P a g e 141 |
PreparedStatement statement = cn1.prepareStatement(sql);
statement.setInt(1,id);
statement.setString(2,lbldate.getText());
statement.setString(3,txttname.getText());
statement.setString(4,txtcontactno.getText());
statement.setString(5,txtemailid.getText());
statement.setString(6,txtcourse.getText());
statement.setString(7,txtexperience.getText());
statement.setString(8,txtqualification.getText());
statement.setString(9,gender);
statement.setString(10,txtaddress.getText());
JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 142 |
BufferedImage bi;
P a g e 143 |
try
{ //display the image in jlabel
bi=ImageIO.read(f);
teacherpic.setIcon(new ImageIcon(bi));
}
catch(IOException e)
{
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
P a g e 144 |
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 146 |
private javax.swing.JTextField txttname;
// End of variables declaration
}
All Teacher information:
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
P a g e 147 |
import java.sql.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class teacher_information extends javax.swing.JFrame {
/**
* Creates new form studentdetails
*/
public teacher_information() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
P a g e 148 |
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "All Records of
Teacher :", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Teacher Id", "Name", "Contact No.", "Email", "Qualification", "Address.", "Course"
}
));
jScrollPane1.setViewportView(jTable1);
jScrollPane2.setViewportView(jTextPane1);
P a g e 149 |
});
P a g e 150 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/inbo.png"))); //
NOI18N
jLabel3.setText(" ");
P a g e 151 |
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(45, 45, 45))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 196,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addContainerGap(20, Short.MAX_VALUE))))
);
jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jButton3)
.addGap(27, 27, 27)
.addComponent(jButton4)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jButton7)
.addGap(13, 13, 13)
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jButton5)
.addGap(25, 25, 25)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 261,
javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 152 |
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
Short.MAX_VALUE))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(2, 2, 2)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel1)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 219,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jButton8)
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
P a g e 153 |
Statement st1;
boolean q;
Connection cn;
ResultSet rs;
String tname,contactno,email,qualification,address,course;
int id=0;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn.createStatement();
String p="select id,tname,contactno,email,qualification,address,course from
teacherinfo";
rs=st1.executeQuery(p);
while (rs.next())
{
id = rs.getInt("id");
tname= rs.getString("tname");
contactno= rs.getString("contactno");
email= rs.getString("email");
qualification= rs.getString("qualification");
address= rs.getString("address");
course =
rs.getString("course");
model.addRow(new
Object[]{id,tname,contactno,email,qualification,address,course});
}
//DefaultTableModel model = (DefaultTableModel) table.getModel();
st1.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
P a g e 154 |
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
teacher_registration myform = new teacher_registration();
P a g e 155 |
myform.setVisible(true);
// TODO add your handling code here:
}
st1=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+n)==JOptionPane.YES_OPTION)
{
String p1="delete from teacherinfo where id='"+d+"'";
P a g e 156 |
st1.execute(p1);
//st1.execute(p1);
String d=jTable1.getValueAt(x,0).toString();
int id=Integer.parseInt(d);
try {
Class.forName("com.mysql.jdbc.Driver");
if(JOptionPane.showConfirmDialog(rootPane, "Want to UPDATE id =
"+d)==JOptionPane.YES_OPTION)
{
Connection cn=
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
PreparedStatement ps = cn.prepareStatement("UPDATE teacherinfo SET tname
= ? ,contactno = ?,email = ?,qualification = ?,address = ?,course = ? WHERE id = "+id+"");
//ps.setString(1, (String) jTable1. getValueAt(x, 0));
P a g e 157 |
ps.executeUpdate();
ps.close();
cn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
P a g e 158 |
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logg
ing.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 159 |
Update teacher Information :
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class update_teacher_form extends javax.swing.JFrame {
/**
* Creates new form update_student_profile
*/
public update_teacher_form () {
initComponents();
P a g e 160 |
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Update Teacher Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(0, 102, 102))); // NOI18N
P a g e 161 |
.addComponent(tid, javax.swing.GroupLayout.DEFAULT_SIZE, 186,
Short.MAX_VALUE)
.addGap(51, 51, 51)
.addComponent(jButton1)
.addGap(84, 84, 84))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(tid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);
P a g e 162 |
Connection cn;
ResultSet rs;
String
date,name,course,exeperience,qualification,sex,contactno,address,email,picturename,gen
der="";
int admissionno,id;
admissionno=Integer.parseInt(tid.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from teacherinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
id =rs.getInt("id");
date=rs.getString("date");
name=rs.getString("tname");
contactno=rs.getString("contactno");
email=rs.getString("email");
course=rs.getString("course");
exeperience =rs.getString("experience");
qualification=rs.getString("qualification");
gender=rs.getString("sex");
address=rs.getString("address");
java.sql.Blob blob = rs.getBlob("photo");
P a g e 163 |
else
{
myform.rfemale.setSelected(true);
}
BufferedInputStream is2 = new BufferedInputStream(blob.getBinaryStream());
Image raw = ImageIO.read(is2);
ImageIcon icon = new ImageIcon(raw);
myform.teacherpic.setIcon(icon);
myform.txtaddress.setText(address);
myform.setVisible(true);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
P a g e 164 |
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 165 |
}
Code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class teacher_update extends javax.swing.JFrame {
P a g e 166 |
/**
* Creates new form teacher_registration
*/
String filename ="";
public teacher_update() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new
javax.swing.ButtonGroup(); jPanel1 = new
javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
txttname = new javax.swing.JTextField();
txtcontactno = new javax.swing.JTextField();
txtemail = new javax.swing.JTextField();
txtcourse = new javax.swing.JTextField();
rmale = new javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtexeperience = new javax.swing.JTextField();
teacherpic = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtaddress = new javax.swing.JTextArea();
jButton3 = new javax.swing.JButton();
txtpicname = new javax.swing.JTextField();
txtqualification = new
javax.swing.JTextField(); jLabel1 = new
javax.swing.JLabel();
P a g e 167 |
jLabel9 = new javax.swing.JLabel();
P a g e 168 |
lbltid = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
txtdate = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(907, 520));
setResizable(false);
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
P a g e 169 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
txttname.setText(" ");
txtcontactno.setText(" ");
txtemail.setText(" ");
txtcourse.setText(" ");
buttonGroup1.add(rmale);
rmale.setText("Male");
buttonGroup1.add(rfemale);
rfemale.setText("Female");
teacherpic.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/teacher.gif"))); // NOI18N
txtaddress.setColumns(20);
txtaddress.setRows(5);
jScrollPane1.setViewportView(txtaddress);
jButton3.setText("Brouse");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
txtpicname.setText(" ");
txtpicname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpicnameActionPerformed(evt);
}
});
txtqualification.setText(" ");
P a g e 170 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(75, 75, 75)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel11))
.addGap(57, 57, 57)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(36, 36, 36)
.addComponent(rfemale))
.addComponent(txtcontactno)
.addComponent(txttname)
.addComponent(txtemail)
.addComponent(txtcourse)
.addComponent(txtexeperience)
.addComponent(txtqualification, javax.swing.GroupLayout.DEFAULT_SIZE, 195,
Short.MAX_VALUE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(teacherpic)
.addGap(72, 72, 72)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 108,
Short.MAX_VALUE)
.addComponent(txtpicname))
.addGap(59, 59, 59))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(81, 81, 81)
.addComponent(jLabel8)
.addGap(40, 40, 40)
P a g e 171 |
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 115, Short.MAX_VALUE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(43, 43, 43)
.addComponent(jButton2)
.addGap(67, 67, 67))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel2)
.addComponent(txttname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtcontactno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtcourse, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
P a g e 172 |
.addComponent(teacherpic)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(txtpicname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(txtexeperience, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel7)
.addComponent(txtqualification,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.A
lignment.BASELINE)
.addComponent(rfemale)
.addComponent(rmale)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(0, 0, Short.MAX_VALUE))))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(15, Short.MAX_VALUE))
);
P a g e 173 |
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setForeground(new java.awt.Color(156, 0, 0));
jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/teacher_update_pic.png"))); // NOI18N
jLabel13.setText("Date :");
NG) .addGroup(layout.createSequentialGroup()
.addGap(53, 53, 53)
.addComponent(lbltid, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(73, 73, 73))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))))
P a g e 174 |
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel9)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(lbltid, javax.swing.GroupLayout.PREFERRED_SIZE, 15,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D, 11, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jLabel13)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(14, 14, 14))
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 54,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(63, 63, 63))
);
Statement st1;
Connection cn1;
boolean q;
P a g e 175 |
int id,rollno;
String picturename ="";
id =
Integer.parseInt(lbltid.getText());
date= txtdate.getText();
teachername= txttname.getText();
contactno= txtcontactno.getText();
email= txtemail.getText();
course= txtcourse.getText();
exeperience= txtexeperience.getText();
qualification= txtqualification.getText();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
address= txtaddress.getText();
picturename =txtpicname.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
// st1=cn1.createStatement();
if(filename.equals(""))
{
statement.setString(1,date);
statement.setString(2,teachername);
P a g e 176 |
statement.setString(3,contactno);
P a g e 177 |
statement.setString(4,email);
statement.setString(5,course);
statement.setString(6,exeperience);
statement.setString(7,qualification);
statement.setString(8,gender);
statement.setString(9,address);
int row =
statement.executeUpdate(); if (row >
0)
{
statement.setString(1,date);
statement.setString(2,teachername);
statement.setString(3,contactno);
statement.setString(4,email);
statement.setString(5,course);
statement.setString(6,exeperience);
statement.setString(7,qualification);
statement.setString(8,gender);
statement.setString(9,address);
InputStream inputStream = new FileInputStream(new File(txtpicname.getText()));
statement.setBlob(10, inputStream);
int row =
statement.executeUpdate(); if (row >
0)
{
P a g e 179 |
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
}
// TODO add your handling code here:
}
P a g e 180 |
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+sname)==JOptionPane.YES_OPTION)
{
String p1="delete from teacherinfo where id='"+id+"'";
st.execute(p1);
//st1.execute(p1);
}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
P a g e 181 |
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(teacher_registration.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
P a g e 183 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class delate_teacher_profile extends javax.swing.JFrame {
/**
* Creates new form update_student_profile
*/
public delate_teacher_profile() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createEtchedBorder(new java.awt.Color(204, 204, 204), null), "Delate Teacher Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS",
1, 14), new java.awt.Color(0, 102, 102))); // NOI18N
P a g e 184 |
txtadmissionsearch.addMouseMotionListener(new
java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
txtadmissionsearchMouseMoved(evt);
}
});
txtadmissionsearch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionsearchKeyReleased(evt);
}
});
P a g e 185 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(txtadmissionsearch,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);
P a g e 186 |
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Are u Sure Delete This
Profile?")==JOptionPane.YES_OPTION)
{
String p1="delete from teacherinfo where id='"+admissionno+"'";
st.execute(p1);
//st1.execute(p1);
}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}
P a g e 187 |
admission=txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from teacherinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
teachername=rs.getString("tname");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
P a g e 188 |
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 189 |
Insert Fees Structure : (add_fees_structure.java)
Code:
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
P a g e 190 |
*
* @author sand
*/
public class add_fees_structure extends javax.swing.JFrame {
/**
* Creates new form add_fees_structure
*/
public add_fees_structure() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
P a g e 191 |
cmbclass = new javax.swing.JComboBox();
jButton2 = new javax.swing.JButton();
jLabel11 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jButton1.setText("Total");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel6.setText("Sports :");
lbltotal.setText("=");
jLabel12.setText("Class :");
jButton2.setText("Submit");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
P a g e 192 |
}
});
P a g e 193 |
.addComponent(tcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(37, 37, 37))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(127, 127, 127)
.addComponent(jLabel12)
.addGap(56, 56, 56)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel6)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(jLabel10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
68, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(lcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(scharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ucharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mcharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 56,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(48, 48, 48))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
P a g e 194 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel6)
.addComponent(scharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(12, 12, 12)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(pcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(lcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(rcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(ucharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel9))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
)
.addComponent(acharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel3))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(bcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
P a g e 195 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(dcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jLabel10))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(tcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
28, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lbltotal, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(mcharge, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(32, 32, 32))))
);
P a g e 196 |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 20, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel11)
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
Statement st1;
Connection cn1;
boolean q;
String sclass;
int pros,reg,add,dev,tut,sports,library,uni,book,miss,total;
sclass = cmbclass.getSelectedItem().toString();
pros=Integer.parseInt(pcharge.getText());
P a g e 197 |
reg=Integer.parseInt(rcharge.getText());
add=Integer.parseInt(acharge.getText());
dev=Integer.parseInt(dcharge.getText());
tut=Integer.parseInt(tcharge.getText());
sports=Integer.parseInt(scharge.getText());
library=Integer.parseInt(lcharge.getText());
uni=Integer.parseInt(ucharge.getText());
book=Integer.parseInt(bcharge.getText());
miss=Integer.parseInt(mcharge.getText());
total=Integer.parseInt(lbltotal.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
String sql = "INSERT INTO fees (class, prospectus, registration , addmission ,
development , tution ,sports ,library,uniform,book,misllaneous ,total) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
int row =
statement.executeUpdate(); if (row >
0) {
P a g e 198 |
JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
P a g e 199 |
java.util.logging.Logger.getLogger(add_fees_structure.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 200 |
Take Admission Fees(add_fees.java)
Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class add_fees extends javax.swing.JFrame {
/**
* Creates new form add_fees
*/
public add_fees() {
P a g e 201 |
initComponents();
Statement st;
Connection cn;
ResultSet rs;
String sql;
int invc;
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
rs=st.executeQuery(sql);
if(rs.next())
{
invc=rs.getInt("invoice");
invc=invc+1;
}
else
{
invc=1;
}
lblinvoice.setText(""+invc);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
P a g e 202 |
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
txtaddno = new javax.swing.JTextField();
txtclass = new javax.swing.JTextField();
txtsname = new javax.swing.JTextField();
txtroll = new javax.swing.JTextField();
txtsection = new javax.swing.JTextField();
txtfname = new javax.swing.JTextField();
txtdate = new javax.swing.JTextField();
lblinvoice = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
pcharge = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
scharge = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
rcharge = new javax.swing.JLabel();
acharge = new javax.swing.JLabel();
dcharge = new javax.swing.JLabel();
tcharge = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
lcharge = new javax.swing.JLabel();
ucharge = new javax.swing.JLabel();
bcharge = new javax.swing.JLabel();
mcharge = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
lbltotal = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
P a g e 203 |
jLabel1.setText("Admission no :");
jLabel2.setText("Class :");
jLabel4.setText("Invoice no :");
jLabel5.setText("Rool No :");
jLabel6.setText("Section :");
jLabel8.setText("Date :");
txtsname.setText(" ");
txtroll.setText(" ");
lblinvoice.setText(" ");
jButton1.setText("Show");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
P a g e 204 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING, false)
.addComponent(lblinvoice, javax.swing.GroupLayout.PREFERRED_SIZE, 59,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtclass)
.addComponent(txtaddno)
.addComponent(txtsname, javax.swing.GroupLayout.DEFAULT_SIZE, 99,
Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.TRAILING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel8)
.addComponent(jLabel7))
.addGap(2, 2, 2)))
.addGap(32, 32, 32)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(48, 48, 48)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton1)))
.addGap(25, 25, 25))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
P a g e 205 |
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(102, 102, 102)))))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel5)
.addComponent(txtaddno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addGap(19, 19, 19)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel6)
.addComponent(txtclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel7)
.addComponent(txtsname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel4)
.addComponent(jLabel8)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblinvoice))
.addContainerGap(33, Short.MAX_VALUE))
);
P a g e 206 |
jLabel11.setText("Prospectus Charge :");
ucharge.setText(" ");
bcharge.setText(" ");
mcharge.setText(" ");
jButton3.setText("Total :");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("Submit");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
P a g e 207 |
}
});
P a g e 208 |
.addComponent(jLabel25)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.TRAILING)
.addComponent(jLabel23)
.addComponent(jLabel24))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel26)))
.addGap(83, 83, 83)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addComponent(scharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELA
TED)
.addComponent(jButton2))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addComponent(jButton4)
.addGap(118, 118, 118))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.LEADING, false)
.addComponent(bcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ucharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(mcharge, javax.swing.GroupLayout.DEFAULT_SIZE, 44,
Short.MAX_VALUE))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
P a g e 209 |
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel11)
.addComponent(pcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(jButton2)
.addComponent(scharge, javax.swing.GroupLayout.PREFERRED_SIZE, 12,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(rcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel15)
.addComponent(jLabel23))
.addComponent(lcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(acharge, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel16)
.addComponent(jLabel24)
.addComponent(ucharge)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(dcharge, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel17)
.addComponent(jLabel25)
.addComponent(bcharge)))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
P a g e 210 |
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jLabel18)
.addComponent(mcharge)
.addComponent(jLabel26))
.addComponent(tcharge, javax.swing.GroupLayout.PREFERRED_SIZE, 17,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addComponent(lbltotal, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm
ent.BASELINE)
.addComponent(jButton3)
.addComponent(jButton4)))
.addContainerGap())
);
P a g e 211 |
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25,
Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>
Connection cn;
Statement st;
ResultSet rs;
String name,fname,sclass,section;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
txtroll.setText(""+roll);
txtsname.setText(name);
txtfname.setText(fname);
txtclass.setText(sclass);
P a g e 212 |
txtsection.setText(section);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
String sclass,sql;
sclass=txtclass.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
sql="select
prospectus,registration,addmission,development,tution,sports,library,uniform,book,misll
aneous,total from fees where class ='"+sclass+"'";
rs=st.executeQuery(sql);
//JOptionPane.showConfirmDialog(rootPane,sclass);
if(rs.next())
{
pros=rs.getInt("prospectus");
reg=rs.getInt("registration");
add=rs.getInt("addmission");
dev=rs.getInt("development");
P a g e 213 |
tution=rs.getInt("tution");
sport=rs.getInt("sports");
lib=rs.getInt("library");
uniform=rs.getInt("uniform");
book=rs.getInt("book");
miss=rs.getInt("misllaneous");
total=rs.getInt("total");
pcharge.setText(""+pros);
rcharge.setText(""+reg);
acharge.setText(""+add);
dcharge.setText(""+dev);
tcharge.setText(""+tution);
scharge.setText(""+pros);
lcharge.setText(""+lib);
ucharge.setText(""+uniform);
bcharge.setText(""+book);
mcharge.setText(""+pros);
lbltotal.setText(""+total);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
Connection cn;
Statement st;
ResultSet rs;
adate=txtdate.getText();
invc=Integer.parseInt(lblinvoice.getText());
addno=Integer.parseInt(txtaddno.getText());
P a g e 214 |
roll=Integer.parseInt(txtroll.getText());
sclass=txtclass.getText();
section=txtsection.getText();
sname=txtsname.getText();
fname=txtfname.getText();
pros=Integer.parseInt(pcharge.getText());
reg=Integer.parseInt(rcharge.getText());
adms=Integer.parseInt(acharge.getText());
dev=Integer.parseInt(dcharge.getText());
tution=Integer.parseInt(tcharge.getText());
sport=Integer.parseInt(scharge.getText());
lib=Integer.parseInt(lcharge.getText());
uniform=Integer.parseInt(ucharge.getText());
book=Integer.parseInt(bcharge.getText());
miss=Integer.parseInt(mcharge.getText());
total=Integer.parseInt(lbltotal.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
int adno;
String p="select addmission_no from addfees where addmission_no="+addno+"";
rs=st.executeQuery(p);
if(rs.next())
{
JOptionPane.showMessageDialog(rootPane,"Addmission already ");
}
else
{
sql="insert into
addfees(bdate,invoice,addmission_no,roll,class,section,name,fname,prospectus,registrati
on,admission,development,tution,sport,library,uniform,book,misslaneous,total)
values('"+adate+"',"+invc+","+addno+","+roll+",'"+sclass+"','"+section+"','"+sname+"','"+fname+
"',"+pros+","+reg+","+adms+","+dev+","+tution+","+sport+","+lib+","+uniform+","+book+","+mi
ss+","+total+")";
st.execute(sql);
JOptionPane.showMessageDialog(rootPane,"Record is saved");
}
}
catch(Exception e)
{
P a g e 215 |
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(add_fees.class.getName()).log(java.util.logging.Level.SE
VERE, null, ex);
P a g e 216 |
}
//</editor-fold>
P a g e 217 |
private javax.swing.JLabel scharge;
private javax.swing.JLabel tcharge;
private javax.swing.JTextField txtaddno;
private javax.swing.JTextField txtclass;
private javax.swing.JTextField txtdate;
private javax.swing.JTextField txtfname;
private javax.swing.JTextField txtroll;
private javax.swing.JTextField txtsection;
private javax.swing.JTextField txtsname;
private javax.swing.JLabel ucharge;
// End of variables declaration
}
Take Monthly Fees: (Monthly_fees.java)
Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
P a g e 218 |
/**
*
* @author sand
*/
public class monthly_fees extends javax.swing.JFrame {
/**
* Creates new form monthly_fees
*/
public monthly_fees() {
initComponents();
cmbfrom.addItem("January");
cmbfrom.addItem("February");
cmbfrom.addItem("March");
cmbfrom.addItem("April");
cmbfrom.addItem("May");
cmbfrom.addItem("June");
cmbfrom.addItem("July");
cmbfrom.addItem("August");
cmbfrom.addItem("September");
cmbfrom.addItem("October");
cmbfrom.addItem("November");
cmbfrom.addItem("December");
cmbto.addItem("January");
cmbto.addItem("February");
cmbto.addItem("March");
cmbto.addItem("April");
cmbto.addItem("May");
cmbto.addItem("June");
cmbto.addItem("July");
cmbto.addItem("August");
cmbto.addItem("September");
cmbto.addItem("October");
cmbto.addItem("November");
cmbto.addItem("December");
Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
P a g e 219 |
int receipt;
// sql = "select max(student_add.admission_no) from student_add";
sql = "select receipt from transaction order by receipt desc";
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
rs=st.executeQuery(sql);
if(rs.next())
{
receipt =rs.getInt("receipt");
receipt=receipt+1;
}
else
{
receipt=1;
}
lblreceipt.setText(""+receipt);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel2.setText("Addmission No :");
jLabel3.setText("Class :");
jLabel5.setText("Reciept No :");
jLabel6.setText("Roll No :");
jLabel7.setText("Section :");
jLabel9.setText("Date :");
P a g e 221 |
cmbto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "to" }));
cmbto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmbtoActionPerformed(evt);
}
});
lblttl.setText(" ");
jButton1.setText("Save");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("SHOW");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
lblinvoice.setText(" ");
P a g e 222 |
.addGap(14, 14, 14)
.addComponent(jLabel11)))
.addComponent(jLabel10))
.addGap(70, 70, 70)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lbltotal, javax.swing.GroupLayout.PREFERRED_SIZE, 63,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.TRAILING, false)
.addComponent(txtclass, javax.swing.GroupLayout.DEFAULT_SIZE, 59,
Short.MAX_VALUE)
.addComponent(txtsname)
.addComponent(txtaddno)
.addComponent(lblreceipt, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(cmbfrom, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(lblttl, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(cmbto, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(43, 43, 43))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(131, 131, 131)
P a g e 223 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING, false)
.addComponent(lblinvoice, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING))))
.addGap(81, 81, 81)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(txtsection)
.addComponent(txtfname)
.addComponent(txtdate)
.addComponent(jButton1)
.addComponent(txtroll))
.addContainerGap(157, Short.MAX_VALUE))))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel2)
.addComponent(jLabel6)
.addComponent(txtaddno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtroll, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel3)
.addComponent(jLabel7)
.addComponent(txtclass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtsection, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
P a g e 224 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel4)
.addComponent(jLabel8)
.addComponent(txtsname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtfname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel9)
.addComponent(txtdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblinvoice))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblreceipt, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel10)
.addComponent(cmbfrom, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(cmbto, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addGap(32, 32, 32)
P a g e 225 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel11)
.addComponent(lbltotal, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(lblttl)))
.addGap(18, 24, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(37, 37, 37))
);
pack();
}// </editor-fold>
int addno,roll;
P a g e 226 |
addno=Integer.parseInt(txtaddno.getText());
Connection cn;
Statement st;
ResultSet rs;
String name,fname,sclass,section,mfrom,mto;
int feesfrom=1;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
txtroll.setText(""+roll);
txtsname.setText(name);
txtfname.setText(fname);
txtclass.setText(sclass);
txtsection.setText(section);
}
cn.close();
st.close();
rs.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
try
P a g e 227 |
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
String sql="select feesto from transaction where addmission_no="+addno+" order by feesto
desc";
rs=st.executeQuery(sql);
if(rs.next())
{
mto=rs.getString("feesto");
cmbto.setSelectedItem(mto);
feesfrom=feesfrom+ cmbto.getSelectedIndex();
cmbfrom.setSelectedIndex(feesfrom);
int feesto=feesfrom;
cmbto.setSelectedIndex(feesto);
}
else
{
JOptionPane.showMessageDialog(rootPane,"You submit first time fees in the year");
cmbfrom.setSelectedIndex(4);
cmbto.setSelectedIndex(4);
}
cn.close();
st.close();
rs.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 228 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Connection cn;
Statement st;
int addno,roll,receipt,total;
String sclass,section,name,fname,recdate,ffrom,fto;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
addno=Integer.parseInt(txtaddno.getText());
roll=Integer.parseInt(txtroll.getText());
sclass=txtclass.getText();
section=txtsection.getText();
name=txtsname.getText();
fname=txtfname.getText();
receipt=Integer.parseInt(lblreceipt.getText());
recdate=txtdate.getText();
ffrom=cmbfrom.getSelectedItem().toString();
fto=cmbto.getSelectedItem().toString();
total=Integer.parseInt(lblttl.getText());
JOptionPane.showMessageDialog(rootPane,"Connection Rerady");
P a g e 229 |
private void cmbtoActionPerformed(java.awt.event.ActionEvent evt) {
int from,to=1,total=1,tt;
from
=cmbfrom.getSelectedIndex(); to =
to+cmbto.getSelectedIndex();
tt=to-from;
total=(1500*tt);
lbltotal.setText("1500 * "+tt+" = ");
lblttl.setText(""+total);
// TODO add your handling code here:
}
from
=cmbfrom.getSelectedIndex(); to =
to+cmbto.getSelectedIndex();
tt=to-from;
total=(1500*tt);
lbltotal.setText("1500 * "+tt+" = ");
lblttl.setText(""+total);
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
P a g e 230 |
E, null, ex);
P a g e 231 |
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(monthly_fees.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>
Code:
import java.net.PasswordAuthentication;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
P a g e 233 |
*
* @author sand
*/
public class send_mail extends javax.swing.JFrame {
/**
* Creates new form send_mail
*/
public send_mail() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel2.setText("Message :");
txtmassage.setColumns(20);
txtmassage.setRows(5);
jScrollPane1.setViewportView(txtmassage);
txtadmissionno.addKeyListener(new java.awt.event.KeyAdapter() {
P a g e 234 |
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionnoKeyReleased(evt);
}
});
jButton1.setText("Send");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
NG) .addComponent(jButton1)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE, 136,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE, 136,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(82, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel4)
.addComponent(txtadmissionno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
P a g e 235 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel1)
.addComponent(txtemail, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
P a g e 236 |
private void txtadmissionnoKeyReleased(java.awt.event.KeyEvent evt) {
int addno,roll;
addno=Integer.parseInt(txtadmissionno.getText());
Connection cn;
Statement st;
ResultSet rs;
String name,fname,sclass,section;
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost/school","root","sandip");
st=cn.createStatement();
// txtroll.setText(""+roll);
txtmassage.setText("student name :"+name+roll);
//txtfname.setText(fname);
//txtclass.setText(sclass);
// txtsection.setText(section);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 237 |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String email = "",msg;
msg=txtmassage.getText();
email=txtemail.getText();
String to="[email protected]";//change accordingly
{
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session =
Session.getDefaultInstance(props, new
javax.mail.Authenticator() {
// protected PasswordAuthentication getPasswordAuthentication()
{
// return new PasswordAuthentication("[email protected]","chikku@gmail");//
change accordingly
}
});
//compose message
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));//change accordingly
message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
message.setSubject("Hello");
message.setText(msg);
//send message
Transport.send(message);
} catch (MessagingException e) {
JOptionPane.showMessageDialog(rootPane, e.getMessage());
//throw new RuntimeException(e);
}
}
// TODO add your handling code here:
}
P a g e 238 |
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(send_mail.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
P a g e 239 |
// Variables declaration - do not modify
P a g e 240 |
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextField
txtadmissionno; private
javax.swing.JTextField txtemail; private
javax.swing.JTextArea txtmassage;
// End of variables declaration
}
Create User profile(user_add.java)
Code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
P a g e 241 |
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class user_add extends javax.swing.JFrame {
/**
* Creates new form user_add
*/
public user_add() {
initComponents();
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//get current date time with Date()
Date date = new Date();
accountdate.setText(dateFormat.format(date));
Statement st;
Connection cn;
ResultSet rs;
String sql,p;
boolean q;
int addno;
P a g e 242 |
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createC
ompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(51, 0, 204),
new java.awt.Color(204, 204, 204)), null), "Fill User Information",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N
lblpicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); //
NOI18N
txtmobileno.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtmobilenoKeyReleased(evt);
}
});
P a g e 244 |
txtlastname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtlastnameKeyReleased(evt);
}
});
txtemailid.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtemailidMouseEntered(evt);
}
});
txtfirstname.setText(" ");
txtfirstname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtfirstnameKeyReleased(evt);
}
});
txtaddress.setColumns(20);
txtaddress.setRows(5);
txtaddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtaddressKeyReleased(evt);
}
});
jScrollPane1.setViewportView(txtaddress);
jButton3.setText("Brouse");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
P a g e 245 |
buttonGroup1.add(rmale);
rmale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rmale.setText("Male");
buttonGroup1.add(rfemale);
rfemale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rfemale.setText("Female");
txtpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseExited(java.awt.event.MouseEvent evt) {
txtpasswordMouseExited(evt);
}
});
txtpassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpasswordActionPerformed(evt);
}
});
txtconformpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseExited(evt);
}
});
txtconformpassword.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtconformpasswordKeyReleased(evt);
}
});
P a g e 246 |
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel3)
.addComponent(jLabel9)
.addComponent(jLabel5))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING)
.addComponent(txtmobileno, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(235, 235, 235)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, 215,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(91, 91, 91)
.addComponent(rfemale)
.addGap(204, 204, 204))
.addComponent(jLabel4)
.addComponent(jLabel8)))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109)
P a g e 247 |
.addComponent(lblacid, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING, false)
.addComponent(txtconformpassword,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtemailid, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
.addComponent(txtlastname, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE))
.addGap(172, 172, 172)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtpicturename))))
.addGap(47, 47, 47))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(2, 2, 2))
.addComponent(lblacid, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel2)
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
P a g e 248 |
.addComponent(txtlastname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel3)
.addComponent(txtmobileno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(txtemailid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtconformpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel9)
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(48, 48, 48))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 153,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtpicturename, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(86, 86, 86)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel5)
P a g e 249 |
.addComponent(rmale)
.addComponent(rfemale))
.addGap(40, 40, 40))
);
P a g e 250 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(26, Short.MAX_VALUE))
);
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn1.createStatement();
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to
Save ?")==JOptionPane.YES_OPTION)
{
String sql = "INSERT INTO userinfo (id,firstname ,
lastname,mobileno ,email,password,repassword,acdate,gender,address,photo) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
P a g e 251 |
PreparedStatement statement = cn1.prepareStatement(sql);
statement.setInt(1,id );
statement.setString(2,txtfirstname.getText());
statement.setString(3,txtlastname.getText());
statement.setString(4,txtmobileno.getText());
statement.setString(5,txtemailid.getText());
statement.setString(6,txtpassword.getText());
statement.setString(7,txtconformpassword.getText());
statement.setString(8,accountdate.getText());
statement.setString(9,gender);
statement.setString(10,txtaddress.getText());
InputStream inputStream = new FileInputStream(new File(txtpicturename.getText()));
statement.setBlob(11, inputStream);
int row = statement.executeUpdate();
if (row > 0) {
JOptionPane.showMessageDialog(rootPane,"Record is Saved");
}
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 252 |
catch(IOException e)
{
}
// TODO add your handling code here:
}
P a g e 253 |
// TODO add your handling code here:
}
if (password.length < 8) {
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
P a g e 254 |
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/*
P a g e 256 |
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class update_user_profile extends javax.swing.JFrame {
/**
* Creates new form update_student_profile
*/
public update_user_profile() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createE
tchedBorder(new java.awt.Color(204, 204, 204), null), "Update User Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 14),
new java.awt.Color(0, 102, 51))); // NOI18N
P a g e 257 |
jButton1.setText("Search");
P a g e 258 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
P a g e 259 |
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(113, Short.MAX_VALUE))
);
userid =rs.getInt("id");
firstname=rs.getString("firstname");
lastname=rs.getString("lastname");
contactno=rs.getString("mobileno");
email=rs.getString("email");
password=rs.getString("password");
conpassword=rs.getString("repassword");
accountdate=rs.getString("acdate");
gender=rs.getString("gender");
address=rs.getString("address");
java.sql.Blob blob = rs.getBlob("photo");
user_update myform = new user_update();
myform.lblacid.setText(""+admissionno);
P a g e 260 |
myform.txtfirstname.setText(firstname);
myform.txtlastname.setText(lastname);
myform.txtmobileno.setText(contactno);
myform.txtemailid.setText(email);
if(gender.equals("Male"))
{
myform.rmale.setSelected(true);
}
else
{
myform.rfemale.setSelected(true);
}
myform.txtpassword.setText(password);
myform.txtconformpassword.setText(conpassword);
myform.accountdate.setText(accountdate);
myform.txtaddress.setText(address);
//myform.f1t2.setText(f4t2.getText());
myform.setVisible(true);
// txtroll.setText(""+rollno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
P a g e 261 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
}
//</editor-fold>
Code:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
P a g e 263 |
* @author sand
*/
public class user_update extends javax.swing.JFrame {
/**
* Creates new form user_add
*/
String filename ="";
public user_update() {
initComponents();
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
P a g e 264 |
jLabel5 = new javax.swing.JLabel();
rmale = new
javax.swing.JRadioButton();
rfemale = new javax.swing.JRadioButton();
txtpassword = new
javax.swing.JPasswordField();
txtconformpassword = new javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createC
ompoundBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(51, 0, 204),
new java.awt.Color(204, 204, 204)), null), "Update User Information :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 12),
new java.awt.Color(153, 0, 0))); // NOI18N
P a g e 265 |
lblpicture.setIcon(new javax.swing.ImageIcon(getClass().getResource("/profilepic.png"))); //
NOI18N
txtmobileno.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtmobilenoKeyReleased(evt);
}
});
txtlastname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtlastnameKeyReleased(evt);
}
});
txtemailid.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtemailidMouseEntered(evt);
}
});
txtfirstname.setText(" ");
txtfirstname.addKeyListener(new java.awt.event.KeyAdapter()
{ public void keyReleased(java.awt.event.KeyEvent evt) {
txtfirstnameKeyReleased(evt);
}
});
txtaddress.setColumns(20);
txtaddress.setRows(5);
txtaddress.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtaddressKeyReleased(evt);
}
});
jScrollPane1.setViewportView(txtaddress);
jButton3.setText("Brouse");
P a g e 266 |
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
buttonGroup1.add(rmale);
rmale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rmale.setText("Male");
buttonGroup1.add(rfemale);
rfemale.setFont(new java.awt.Font("Trebuchet MS", 0, 14)); // NOI18N
rfemale.setText("Female");
txtpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseExited(java.awt.event.MouseEvent evt) {
txtpasswordMouseExited(evt);
}
});
txtpassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtpasswordActionPerformed(evt);
}
});
txtconformpassword.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
txtconformpasswordMouseExited(evt);
}
});
txtconformpassword.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtconformpasswordKeyReleased(evt);
}
});
P a g e 267 |
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jLabel3)
.addComponent(jLabel9)
.addComponent(jLabel5))
.addGap(31, 31, 31)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING)
.addComponent(txtmobileno, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(235, 235, 235)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment
.TRAILING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE, 215,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(rmale)
.addGap(91, 91, 91)
P a g e 268 |
.addComponent(rfemale)
.addGap(204, 204, 204))
.addComponent(jLabel4)
.addComponent(jLabel8)))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(109, 109, 109)
.addComponent(lblacid, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.T
RAILING, false)
.addComponent(txtconformpassword,
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtemailid, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
.addComponent(txtlastname, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE))
.addGap(172, 172, 172)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 122,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtpicname))))
.addGap(47, 47, 47))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG
) .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(2, 2, 2))
P a g e 269 |
.addComponent(lblacid, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel2)
.addComponent(txtfirstname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(txtlastname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel3)
.addComponent(txtmobileno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(txtemailid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(txtpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtconformpassword, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel9)
.addComponent(accountdate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(48, 48, 48))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(lblpicture, javax.swing.GroupLayout.PREFERRED_SIZE, 153,
javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 270 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtpicname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(86, 86, 86)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel5)
.addComponent(rmale)
.addComponent(rfemale))
.addGap(40, 40, 40))
);
P a g e 271 |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(71, 71, 71)
.addComponent(jButton2)
.addGap(134, 134, 134))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE,
24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton1))
.addGap(80, 80, 80))
);
Statement st1;
Connection cn1;
boolean q;
id = Integer.parseInt(lblacid.getText());
firstname= txtfirstname.getText();
lastname=txtlastname.getText();
mobileno= txtmobileno.getText();
P a g e 272 |
email= txtemailid.getText();
password= txtpassword.getText();
conpass=txtconformpassword.getText();
acdate=accountdate.getText();
if (rmale.isSelected())
{
gender = rmale.getText();
}
else if (rfemale.isSelected()) {
gender = rfemale.getText();
}
address= txtaddress.getText();
picturename =txtpicname.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
// st1=cn1.createStatement();
if(filename.equals(""))
{
statement.setString(1,firstname);
statement.setString(2,lastname);
statement.setString(3,mobileno);
statement.setString(4,email);
statement.setString(5,password);
statement.setString(6,conpass);
statement.setString(7,acdate);
statement.setString(8,gender);
statement.setString(9,address);
int row = statement.executeUpdate();
P a g e 273 |
if (row > 0)
{
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 274 |
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
filename = f.getAbsolutePath();
txtpicname.setText(filename);
BufferedImage bi;
try
{ //display the image in jlabel
bi=ImageIO.read(f);
lblpicture.setIcon(new ImageIcon(bi));
}
catch(IOException e)
{
}
// TODO add your handling code here:
}
P a g e 275 |
private void txtconformpasswordMouseExited(java.awt.event.MouseEvent evt) {
char[] pass =txtpassword.getPassword();
char[] conpass= txtconformpassword.getPassword();
if (pass.length!= conpass.length) {
if (password.length < 8) {
P a g e 276 |
int id;
admission = lblacid.getText();
id=Integer.parseInt(admission);
uname =txtfirstname.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+uname)==JOptionPane.YES_OPTION)
{
String p1="delete from userinfo where id='"+id+"'";
st.execute(p1);
//st1.execute(p1);
}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
P a g e 277 |
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(user_add.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
P a g e 279 |
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class delate_user_profile extends javax.swing.JFrame {
/**
* Creates new form update_student_profile
*/
public delate_user_profile() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createE
tchedBorder(new java.awt.Color(204, 204, 204), null), "Delate User Profile :",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Trebuchet MS", 1, 14),
new java.awt.Color(102, 0, 102))); // NOI18N
P a g e 280 |
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
P a g e 281 |
jLabel1.setText("Enter User ID :");
txtadmissionsearch.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
txtadmissionsearchMouseMoved(evt);
}
});
txtadmissionsearch.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
txtadmissionsearchKeyReleased(evt);
}
});
P a g e 282 |
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(txtadmissionsearch, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addComponent(jLabel1))
.addContainerGap(57, Short.MAX_VALUE))
);
P a g e 283 |
admissionno=Integer.parseInt(admission);
P a g e 284 |
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Are u Sure Delete This
Profile?")==JOptionPane.YES_OPTION)
{
String p1="delete from userinfo where id='"+admissionno+"'";
st.execute(p1);
//st1.execute(p1);
}
st.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
// TODO add your handling code here:
}
P a g e 285 |
admission=txtadmissionsearch.getText();
admissionno=Integer.parseInt(admission);
try
{
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from userinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
studentname=rs.getString("firstname");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
P a g e 286 |
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(update_student_profile.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
}
//</editor-fold>
P a g e 287 |
Search User information(user_information.java)
Code:
import java.awt.Image;
import java.io.BufferedInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
import java.sql.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
P a g e 288 |
import javax.swing.table.DefaultTableModel;
public class user_information extends javax.swing.JFrame {
/**
* Creates new form studentdetails
*/
public user_information() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
P a g e 289 |
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"User Id.", "First Name.", "Last Name.", "Contact No.", "Email", "Address.", "gender"
}
));
jScrollPane1.setViewportView(jTable1);
jScrollPane2.setViewportView(jTextPane1);
P a g e 290 |
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
P a g e 292 |
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 109,
Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(45, 45, 45))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 196,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addContainerGap(20, Short.MAX_VALUE))))
);
jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jButton3)
.addGap(27, 27, 27)
.addComponent(jButton4)
.addGap(18, 18, 18)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton7)
.addGap(13, 13, 13)
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton5)
.addGap(25, 25, 25)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING, false)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 261,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE,
0, Short.MAX_VALUE))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
P a g e 293 |
.addGap(2, 2, 2)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(jLabel1)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 219,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jButton8)
.addContainerGap(30, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
try
{
P a g e 294 |
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st1=cn.createStatement();
String p="select id,firstname,lastname,mobileno,email,address,password from userinfo";
rs=st1.executeQuery(p);
while (rs.next())
{
id = rs.getInt("id");
firstname= rs.getString("firstname");
lastname= rs.getString("lastname");
mobileno= rs.getString("mobileno");
email= rs.getString("email");
address= rs.getString("address");
password = rs.getString("password");
model.addRow(new
Object[]{id,firstname,lastname,mobileno,email,address,password});
}
//DefaultTableModel model = (DefaultTableModel) table.getModel();
st1.close();
cn.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
P a g e 295 |
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
try {
if (! jTable1.print()) {
System.err.println("User cancelled printing");
}
} catch (java.awt.print.PrinterException e) {
System.err.format("Cannot print %s%n", e.getMessage());
}
st1=cn.createStatement();
//JOptionPane.showMessageDialog(rootPane,"value of x"+d);
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to Delete name =
"+n)==JOptionPane.YES_OPTION)
{
String p1="delete from userinfo where id='"+d+"'";
st1.execute(p1);
//st1.execute(p1);
P a g e 296 |
catch(Exception e)
P a g e 297 |
{
System.out.println(e.getMessage());
}
String d=jTable1.getValueAt(x,0).toString();
int id=Integer.parseInt(d);
try {
Class.forName("com.mysql.jdbc.Driver");
if(JOptionPane.showConfirmDialog(rootPane, "Want to UPDATE id =
"+d)==JOptionPane.YES_OPTION)
{
Connection cn=
DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
PreparedStatement ps = cn.prepareStatement("UPDATE userinfo SET firstname
= ? ,lastname = ?,mobileno = ?,email = ?,address = ?,gender= ? WHERE id = "+id+"");
//ps.setString(1, (String) jTable1. getValueAt(x, 0));
ps.executeUpdate();
ps.close();
cn.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
// TODO add your handling code here:
}
P a g e 298 |
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(teacher_information.class.getName()).log(java.util.logging.Level
.SEVERE, null, ex);
}
//</editor-fold>
P a g e 299 |
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new user_information().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2; private javax.swing.JTable
jTable1;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration
Help Form(Help.java)
P a g e 300 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class help extends javax.swing.JFrame {
/**
* Creates new form help
*/
public help() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
P a g e 301 |
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setAlwaysOnTop(true);
jLabel2.setText("1. First of all create database in which u want to import database in my sql. ");
jLabel7.setText(" -> here e: is a drive name nd career.sql is database who is already u have.");
jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/restorepic.png"))); //
NOI18N
P a g e 302 |
.a
d
d
C
o
m
p
o
ne
nt
(j
La
be
l1)
)
P a g e 303 |
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)))
.addComponent(jLabel8))
.addContainerGap(47, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayou
t.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 304,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
P a g e 304 |
.addGap(123, 123, 123)
.addComponent(jLabel4)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(25, 25, 25)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-
724)/2, (screenSize.height-546)/2, 724, 546);
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info
: javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
P a g e 305 |
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
P a g e 306 |
java.util.logging.Logger.getLogger(help.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
Code :
import java.io.File;
P a g e 307 |
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author sand
*/
public class change_user_password_form extends javax.swing.JFrame {
/**
* Creates new form change_user_password_form
*/
public change_user_password_form()
{ initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
P a g e 308 |
jLabel5 = new javax.swing.JLabel();
userid = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
lblname = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(new
java.awt.Color(204, 204, 204), new java.awt.Color(204, 204, 204)));
jLabel1.setText("Password :");
jButton1.setText("CHANGE");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
P a g e 309 |
.addComponent(jButton1)
.addGap(155, 155, 155))
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(txtconpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(txtoldpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35,
Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(20, 20, 20))
);
userid.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
useridKeyReleased(evt);
}
});
jLabel6.setText("Name :");
lblname.setText(" ");
P a g e 310 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAIL
ING
) .addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED
P a g e 311 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(45, Short.MAX_VALUE))
);
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
st=cn.createStatement();
String sql="Select * from userinfo where id ="+admissionno+" ";
rs=st.executeQuery(sql);
if(rs.next())
{
username=rs.getString("firstname");
lblname.setText(username);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
Statement st1;
P a g e 312 |
Connection cn1;
boolean q;
String pass,conpass,oldpass;
int admissionno,id;
id =
Integer.parseInt(userid.getText());
pass= txtpass.getText();
conpass= txtconpass.getText();
oldpass= txtoldpass.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to change your
password?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE userinfo SET
password= ?,repassword = ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1.
getValueAt(x, 0));
statement.setString(1,pass);
statement.setString(2,conpass);
int row =
statement.executeUpdate(); if (row >
0)
{
JOptionPane.showMessageDialog(rootPane,"Passwword is Succesfully Changed ");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
P a g e 313 |
/**
* @param args the command line arguments
P a g e 314 |
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 315 |
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel
lblname;
private javax.swing.JTextField txtconpass;
private javax.swing.JTextField txtoldpass;
private javax.swing.JTextField txtpass;
private javax.swing.JTextField userid;
// End of variables declaration
}
Change admin password(Change_admin_password.java)
Code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
P a g e 316 |
*
* @author sand
*/
public class change_admin_password_form extends javax.swing.JFrame {
/**
* Creates new form change_user_password_form
*/
public change_admin_password_form() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Password :");
jButton1.setText("CHANGE");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
P a g e 317 |
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(67, 67, 67)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.TRAILING)
.addComponent(txtpass)
.addComponent(txtoldpass, javax.swing.GroupLayout.DEFAULT_SIZE, 166,
Short.MAX_VALUE)
.addComponent(txtconpass,
javax.swing.GroupLayout.Alignment.LEADING)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(159, 159, 159)
.addComponent(jButton1)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel1)
.addComponent(txtpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel2)
.addComponent(txtconpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
P a g e 318 |
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignmen
t.BASELINE)
.addComponent(jLabel3)
.addComponent(txtoldpass, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36,
Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(19, 19, 19))
);
pack();
P a g e 319 |
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
java.awt.Dimension dialogSize = getSize();
setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-
dialogSize.height)/2);
}// </editor-fold>
Statement st1;
Connection cn1;
boolean q;
String pass,conpass,oldpass;
int admissionno,id;
id=2;
pass= txtpass.getText();
conpass= txtconpass.getText();
oldpass= txtoldpass.getText();
try
{
Class.forName("com.mysql.jdbc.Driver");
cn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","sandip");
if(JOptionPane.showConfirmDialog(rootPane, "Do you want to change your
password?")==JOptionPane.YES_OPTION)
{
PreparedStatement statement = cn1.prepareStatement("UPDATE login SET
password= ? WHERE id = "+id+""); //ps.setString(1, (String) jTable1. getValueAt(x, 0));
statement.setString(1,pass);
catch(Exception e)
P a g e 320 |
{
JOptionPane.showMessageDialog(rootPane,e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(change_user_password_form.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
P a g e 321 |
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new change_admin_password_form().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField txtconpass;
private javax.swing.JTextField txtoldpass;
private javax.swing.JTextField txtpass;
// End of variables declaration
}
BIBLIOGRAPHY
P a g e 322 |