0% found this document useful (0 votes)
332 views186 pages

Java Programming Principles and Features

The document discusses principles, characteristics, and features of Java programming. It explains that Java is an object-oriented and platform-independent language that allows programs to run on any system with a Java Virtual Machine. The document also discusses environmental flexibility in Java programming, noting that Java byte code can be run on any platform without recompilation, but interpretation results in slower performance than native compilation. Finally, it presents an example database normalization from the Unified Normal Form to the Third Normal Form.

Uploaded by

Sammy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
332 views186 pages

Java Programming Principles and Features

The document discusses principles, characteristics, and features of Java programming. It explains that Java is an object-oriented and platform-independent language that allows programs to run on any system with a Java Virtual Machine. The document also discusses environmental flexibility in Java programming, noting that Java byte code can be run on any platform without recompilation, but interpretation results in slower performance than native compilation. Finally, it presents an example database normalization from the Unified Normal Form to the Third Normal Form.

Uploaded by

Sammy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HND in Computing & Programming in

System Development Java

Task1
1.1. Briefly explain the principles, characteristics features and in Java programming.

Java is an object oriented and architecture-neutral programming language. This agrees


programs created in Java to be ported into different platform without the need for
modifications. As a beginner to the JAVA programming language a person must want to get
the knowledge about what are the principals in java programming language, what are the
characteristics in JAVA programming language and what are the features in Java
programming language.

Basically we can identify there are five principals in java programming language.

 Simple, object oriented and familiar language – it‟s like greatly in its
consistence. Once you learn had to do one thing in Java, you know how to do
same way throughout the language. Because it never deviates from the way the
languages Architecture. It‟s an object oriented [Link] once you understand
the principals of encapsulation, inheritance and polymorphism and how those are
implemented in the java programming language you have a much better sense
of how to Architect your Applications.
 Robust and secure – its robustness likes greatly in its object oriented
characteristics. Because you designing everything as an object. Everything has
methods or functions and properties. Also known as fields. And you creating an
application by combining multiple classes together. This let you create your code
in small trunks. And it makes easy to maintain and debug your applications
overtime.
 Architecture- neutral and portable – java was designed to be [Link] that
it able to be compiled once.
 High- performance – Java was created to be high performance the Original
version of the Java virtual machine wasn‟t faster c++ applications. But over the
years it‟s been improved normally. And today justness fast sometimes even
faster. Then the Applications built in c++.
 Interpreted, threaded and dynamic

In above paragraph briefly discussed about the Principals in java programming


language .after getting knowledge about principals a beginner must have to get the
knowledge about what are the characteristics and features in Java programming
language. Because it is helping to understand why we are saying java is an object
oriented programing language and some other sort of things.

1
HND in Computing & Programming in
System Development Java

Characteristics and features of java programming

 Java Is Simple – Java is partially modeled on c++ but greatly simplified and
improved some people refer to java as “C++”because it is like C++but with more
functionality and fewer negative aspects.
 Java Is object- oriented – Java is a fully object oriented language. It supports all
the characteristics needed to be object oriented. In the Java everything is treated
as objects to which methods are applied. As the languages like Objective C, C++
fulfills the above four characteristics yet they are not fully object oriented
languages because they are structured as well as object oriented languages. But
in case of java, it is a fully Object Oriented language because object is at the
outer most level of data structure in java. No standalone methods, constants, and
variables are there in java. Everything in java is object even the primitive data
types can also be converted into object by using the wrapper class. Once of the
issue in software development is how to reprocess code. Object oriented
programming provides great Flexibility, modularity, clarity and reusability trough
polymorphism, inheritance and encapsulation.
 Java is distributed – Distributed computing involves several computers working
together on a [Link] is formed to make distributed computing case. Since
networking capability is inherently integrated into java, writing network programs
is like delivering and receiving data to and from a file.
 Java is Platform Independent - Java provides the facility to "Write once -Run
anywhere"(Known as platform independent). Not even a single language is idle
to this feature but java is closer to this feature. Java Provide the facility of cross-
platform programs by compiling in intermediate code known as byte code. This
byte code can be interpreted on any system which has Java Virtual Machine
(JVM).
 Java is interpreted – you need an interpreter to run java programs. The
programs are compiled to the java virtual machine known as byte code. The byte
code is machine independent and can run on any machine that has a java
interpreter, which is piece of the java virtual machine.
 Java is Robust – java has a runtime exception-handling feature o provide
programming support for robustness.
 Java is secure – its mean is java implements several security mechanisms to
safeguard your system against harm caused stray programs.
 Java is architecture –neutral – it mean is you can write one program that will
run on any platform
 Java is portable –because java is architecture neutral, java programs are
portable. They can be run on any platform without being recompiled.

Those are the main features, Characteristics and principal in java programming language.

2
HND in Computing & Programming in
System Development Java

2. Explain environmental flexibility of programming in Java programming and evaluate


your answer.

Java was designed to allow application programs to be built that could be run on any platform
without having to be rewritten or recompiled by the programmer for each separate platform.
Java virtual machine (JVM), an implementation of the Java Virtual Machine Specification,
interprets compiled Java byte code for a computer's processor or hardware platform so that it
can execute a Java program's commands. The Java Virtual Machine Specification defines an
abstract rather than a real machine or processor. The Specification specifies an instruction set,
a set of registers, a stack, a "garbage heap," and a method area. A Java virtual machine makes
this possible because it is aware of the specific instruction lengths and other particularities of the
platform. Once a Java virtual machine has been implemented for a given platform, any Java
program which, after compilation, the byte code can run on that platform. A Java virtual machine
can either interpret the byte code one instruction at a time or the byte code can be compiled
further for the real processor using what is called a just-in-time compiler. The one of main
advantage of the Java VM ,it is allow to a program to be written and compiled only once, which
then can be run on a wide variety of systems and operating systems without modification. Many
cell phones and embedded devices include a Java VM. Another Since programming must be
translated from generic "byte code" to the machine code for the target system as it is being run,
it is impossible for Java to perform as quickly as languages that can compile directly to machine
code for the target systems. Because the Java VM must run on a wide variety of systems,
features specific to one OS are often not implemented into Java programs. In addition, the "look
and feel" of Java applications can often be quite different than the default styles of native
applications within an operating system.

3
HND in Computing & Programming in
System Development Java

Task 02
2.1. Design a database with necessary tables.

Normalization

UNF

HE Institute{ Student ID, Name, Age, Gender, Telephone no, Course ID, Course Name, Course
Fee, Duration, Batch ID, Start date, number Of Student, End date, Payment code, Payment
type, Amount, Staff ID, Staff Name, User Name, Password , Account Type}

1NF
Student{ Student ID, Name, Age, Gender, Telephone no }
HE Institute{ Course ID, Course Name, Course Fee, Duration, Batch ID, Start date, number Of
Student, End date, Payment code, Payment type, Amount, Staff ID, Staff Name, User Name,
Password , Account Type, Student ID}

2NF

Student{ Student ID, Name, Age, Gender, Telephone no }


Course { Course ID, Course Name, Course Fee, Duration, Student ID }
HE Institute{ Batch ID, Start date, number Of Student, End date, Payment code, Payment type,
Amount, Staff ID, Staff Name, User Name, Password , Account Type, Student ID}

3NF

Student{ Student ID, Name, Age, Gender, Telephone no }


Course { Course ID, Course Name, Course Fee, Duration, Student ID }
Batch{ Batch ID, Start date, number Of Student, End date, Student ID, Course ID }
Payment{ Payment code, Payment type, Amount, Student ID , Course ID }
Staff{ Staff ID, Staff Name, User Name, Password , Account Type, Student ID }
HE Institute{ Student ID , Course ID , Batch ID , Payment code, Staff ID}

BCNF
Student{ Student ID, Name, Age, Gender, Telephone no }
Course { Course ID, Course Name, Course Fee, Duration, Student ID }
Batch{ Batch ID, Start date, number Of Student, End date, Student ID, Course ID }
Payment{ Payment code, Payment type, Amount, Student ID , Course ID }
Staff{ Staff ID, Staff Name, User Name, Password , Account Type, Student ID }
Student_Course{ Student ID , Course ID }
Student_Batch{ Student ID , Batch ID }
Student_Staff{{ Student ID , Staff ID }

4
HND in Computing & Programming in
System Development Java

ER Diagram

Start date
Batch ID Course Name
number Of Student
Course Fee
Batch Course

End date Course ID


Course ID Duration

Student ID Student ID
Student_ Batch Student_
Course
Course ID
Batch ID

Student ID
Name

Payment code
Student
Payment type

Age
Payment
Telephone no

Gender Amount
Student ID

Course ID
Stud_Staff Staff ID

Student ID Staff ID

Staff
Password

User Name
Staff Name Account Type

5
HND in Computing & Programming in
System Development Java

2.2 Set up the database structure by using suitable RDBMS.

6
HND in Computing & Programming in
System Development Java

Table –Staff

Table-Student

Table- student_Staff

7
HND in Computing & Programming in
System Development Java

Table-Batch

Table-Student_Batch

Table-Course

8
HND in Computing & Programming in
System Development Java
Table – Student_Course

Table- Payment

9
HND in Computing & Programming in
System Development Java

2.3. Populate the database with suitable test data.

Table-Staff

Table -Student

10
HND in Computing & Programming in
System Development Java

Table- Student_Staff

Table-Batch

Table-Student_Batch

11
HND in Computing & Programming in
System Development Java

Table-Course

Table – Student_Course

Table- Payment

12
HND in Computing & Programming in
System Development Java

Task 03

3.1. The designs of all the required algorithms are required as part of this task.
You can use suitable design techniques

Class diagram for proposed system

Payments
Student
Payment_code
Student_ID
1 * Payment_Method
Student_Name 1
Total Amount
Age =
Telephone_no

* 1
*
* * Course

*
Course_ID
Batch Course_Name
Duration
* Batch_ID
* 1 Course_Fee
Staff Start_date
Staff ID End Date
Staff Name number_Of_Student
User Name Course_ID
Password
Account type

13
HND in Computing & Programming in
System Development Java

Activity diagram For student registration in Propose System

Input: Course Details


Student Details
Batch Details

Select a Student

If student Want False


to Follow a new
Course

True

Select a Course

If student want to True


follow the Assign to a Batch
selected course
student

False

14
HND in Computing & Programming in
System Development Java

Activity Diagram For record the Payment details in Propose System

Input: Course Details


Student Details
Payment Details

Select a student and the


course

If student want to False


pay a premium of
the course

True

Select a Payment Method

Receive the payments

Record the payment detail

15
HND in Computing & Programming in
System Development Java

Flow chart for check the validity of users to use the data in the propose program

Start

Input: User type (Admin or Staff


member) password, user name

Enter the User Name and Password

Check the person is an Admin or a staff


member by comparing user Name and
password

If the True Give the full permission to use the


person is data in the program
an Admin

False
Stop

Check the person is a staff member

If the True
person is Give the limited permission to use
a staff the data in the program

False
Provide an error Message
16
HND in Computing & Programming in
System Development Java

Use case diagram for proposed system

Add Student details

Edit Student details

Delete Student Details

Add Course Details Staff

Edit Course details

Delete Course Details

Add Batch details


Admin

Edit Batch details

Add Payment Details

Edit Payment Details

Delete Payment Details

Provide student Informations

Select courses

Attend to the classes

Do payments Students

Face to the Assignments and


Exams
17
HND in Computing & Programming in
System Development Java

3.2. Design necessary user interfaces

Login Form

Main Form

18
HND in Computing & Programming in
System Development Java

Student Details form

Add New Student Details Form

19
HND in Computing & Programming in
System Development Java

Edit Student Details Form

Course Details Form

20
HND in Computing & Programming in
System Development Java

Add New course Details form

Edit course details Form

21
HND in Computing & Programming in
System Development Java

Batch Details Form

Add New Batch Details Form

22
HND in Computing & Programming in
System Development Java

Edit Batch Details

Create New User Account Form

23
HND in Computing & Programming in
System Development Java

Edit User Account

Payment Details Form

24
HND in Computing & Programming in
System Development Java

Receive Payments Form

25
HND in Computing & Programming in
System Development Java

Task 04

4.1. Using java programming language, implement the Student information


system for the HE Institute designed in Task 03.

Login Form

Program code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/
public class Login extends [Link] {

/**
* Creates new form Login
*/

26
HND in Computing & Programming in
System Development Java
private String staffname;
private boolean privileges;
private int staffid;
public Login() {

initComponents();
}
public boolean checkLogin(String user,String pass) throws ClassNotFoundException, SQLException
{
// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected "); // connection ok

// retriving user and password gave by user


String SQL = "SELECT * FROM Staff WHERE User_name='"+user+"'AND Password='"+pass+"'";
Statement stmt = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](SQL);

return [Link](); //returns true if ResultSet has a row valid login

} // end con method

public void getStaffName_privileges(String user,String pass) throws ClassNotFoundException, SQLException


{
// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected "); // connection ok

// Get staff name


String SQL = "SELECT * FROM Staff WHERE User_name='"+user+"'AND Password='"+pass+"'";
Statement stmt = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](SQL);

[Link]();
staffname= [Link](2);
privileges=[Link](5);
staffid=[Link](1);

} // end con method

public void displayMain(){


//display main interface
Main main = new Main(staffname,privileges,staffid);
[Link](true);
[Link](null);

27
HND in Computing & Programming in
System Development Java
[Link](false);

}// end displayMain

public void loginToSystem()throws ClassNotFoundException, SQLException {


String username=[Link]();
String password=[Link]();

if ([Link](username,password)==true){
this.getStaffName_privileges(username,password);
[Link]();
[Link](false);

}//end if
else if([Link](username,password)==false){
[Link](null, " None Authorized Access please enter a valid User-Name and a
Password","Error",JOptionPane.ERROR_MESSAGE);
}//end else

}// end of login to system

/**
* 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() {

txtPass = new [Link]();


jLabel2 = new [Link]();
jLabel1 = new [Link]();
txtUser = new [Link]();
btnlogin = new [Link]();
btnExit = new [Link]();
jLabel3 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtPassActionPerformed(evt);
}

28
HND in Computing & Programming in
System Development Java
});

[Link]("Pasword :");

[Link]("User Name :");

[Link](new [Link](getClass().getResource("/heinstitute/[Link]"))); // NOI18N


[Link]("LOGIN");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnloginActionPerformed(evt);
}
});
[Link](new [Link]() {
public void keyPressed([Link] evt) {
btnloginKeyPressed(evt);
}
});

[Link]("Exit");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnExitActionPerformed(evt);
}
});

[Link](new
[Link](getClass().getResource("/heinstitute/1397005153_Refresh_key.png"))); // NOI18N
[Link]("jLabel3");

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(jLabel1))
.addPreferredGap([Link])
.addGroup([Link]([Link], false)
.addComponent(txtPass, [Link].DEFAULT_SIZE, 147, Short.MAX_VALUE)
.addComponent(txtUser)))
.addComponent(btnlogin, [Link].PREFERRED_SIZE, 90,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup([Link]([Link])
.addComponent(jLabel3, [Link].PREFERRED_SIZE, 71,
[Link].PREFERRED_SIZE)
.addComponent(btnExit, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE))
.addContainerGap(18, Short.MAX_VALUE))

29
HND in Computing & Programming in
System Development Java
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGap(23, 23, 23)
.addGroup([Link]([Link])
.addComponent(jLabel1)
.addComponent(txtUser, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(12, 12, 12)
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtPass, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(27, 27, 27))
.addGroup([Link], [Link]()
.addContainerGap()
.addComponent(jLabel3)
.addPreferredGap([Link])))
.addGroup([Link]([Link])
.addComponent(btnExit, [Link].PREFERRED_SIZE, 33,
[Link].PREFERRED_SIZE)
.addComponent(btnlogin, [Link].PREFERRED_SIZE, 33,
[Link].PREFERRED_SIZE))
.addContainerGap(19, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void txtPassActionPerformed([Link] evt) {


// TODO add your handling code here:
}

private void btnloginActionPerformed([Link] evt) {


// TODO add your handling code here:
try{
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](e);
}

private void btnloginKeyPressed([Link] evt) {

30
HND in Computing & Programming in
System Development Java
// TODO add your handling code here:

private void btnExitActionPerformed([Link] evt) {


// TODO add your handling code here:
int result =[Link](null, "Do you Want To Exit ?", "Exit",
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if(result==0){
[Link](0);
}
else if(result==1){

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
[Link](new Runnable() {
public void run() {
new Login().setVisible(true);

}
});
}

// Variables declaration - do not modify


private [Link] btnExit;
private [Link] btnlogin;
private [Link] jLabel1;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] txtPass;
private [Link] txtUser;
// End of variables declaration
}

31
HND in Computing & Programming in
System Development Java

Main Form

Program Code :
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
*
* @author Anushka
*/
public class Main extends [Link] {

/**
* Creates new form Main
*/

32
HND in Computing & Programming in
System Development Java
private boolean privileges;
private int staffid;
private String S_name;

public Main(String staffname,boolean p,int id) {


initComponents();

[Link]([Link]());
[Link](p);
staffid=id; // set Staff id
S_name=staffname;
}
public void setUserLimitations(boolean prm){
privileges=prm;
[Link](prm);

}
/**
* 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() {

btnCourse = new [Link]();


lblStaffName2 = new [Link]();
btnStudent = new [Link]();
lblStaffName3 = new [Link]();
btnCourse1 = new [Link]();
lblStaffName4 = new [Link]();
lblStaffName1 = new [Link]();
lblStaffName = new [Link]();
btnCourse2 = new [Link]();
lblStaffName5 = new [Link]();
jMenuBar1 = new [Link]();
jMenu3 = new [Link]();
menuAddUsers = new [Link]();
menuEditMyAcc = new [Link]();
menulogout = new [Link]();
jMenu2 = new [Link]();
jMenuItem1 = new [Link]();
jMenuItem2 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](new [Link](0, 0, 0));


[Link](new
[Link](getClass().getResource("/heinstitute/1397062581_Courses.png"))); // NOI18N
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCourseActionPerformed(evt);

33
HND in Computing & Programming in
System Development Java
}
});

[Link](new [Link]("Tahoma", 0, 14)); // NOI18N


[Link](new [Link](255, 255, 255));
[Link]([Link]);
[Link]("Course Details");

[Link](new [Link](0, 0, 0));


[Link](new
[Link](getClass().getResource("/heinstitute/1397061362_elementary_school.png"))); // NOI18N
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnStudentActionPerformed(evt);
}
});

[Link](new [Link]("Tahoma", 0, 14)); // NOI18N


[Link](new [Link](255, 255, 255));
[Link]([Link]);
[Link]("Student Details");

[Link](new [Link](0, 0, 0));


[Link](new
[Link](getClass().getResource("/heinstitute/1397064740_Money.png"))); // NOI18N

[Link](new [Link]("Tahoma", 0, 14)); // NOI18N


[Link](new [Link](255, 255, 255));
[Link]([Link]);
[Link]("Batch Details");

[Link](new [Link]("Tahoma", 0, 14)); // NOI18N


[Link](new [Link](255, 102, 0));
[Link]("User:");

[Link](new [Link]("Tahoma", 0, 14)); // NOI18N


[Link](new [Link](255, 102, 0));
[Link]("jLabel8");

[Link](new [Link](0, 0, 0));


[Link](new
[Link](getClass().getResource("/heinstitute/1397132431_MySpace.png"))); // NOI18N
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCourse2ActionPerformed(evt);
}
});

[Link](new [Link]("Tahoma", 0, 14)); // NOI18N


[Link](new [Link](255, 255, 255));
[Link]([Link]);
[Link]("Payment Details");

[Link]("Configuration");

34
HND in Computing & Programming in
System Development Java

[Link]("Create New User");


[Link](new [Link]() {
public void actionPerformed([Link] evt) {
menuAddUsersActionPerformed(evt);
}
});
[Link](menuAddUsers);

[Link]("Edit User Account");


[Link](new [Link]() {
public void actionPerformed([Link] evt) {
menuEditMyAccActionPerformed(evt);
}
});
[Link](menuEditMyAcc);

[Link](jMenu3);

[Link]("Log Out");
[Link](new [Link]() {
public void mouseClicked([Link] evt) {
menulogoutMouseClicked(evt);
}
});
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
menulogoutActionPerformed(evt);
}
});
[Link](menulogout);

[Link]("Help");

[Link]("Help ");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
jMenuItem1ActionPerformed(evt);
}
});
[Link](jMenuItem1);

[Link]("About");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
jMenuItem2ActionPerformed(evt);
}
});
[Link](jMenuItem2);

[Link](jMenu2);

setJMenuBar(jMenuBar1);

35
HND in Computing & Programming in
System Development Java
[Link] layout = new [Link](getContentPane());
getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGap(10, 10, 10)
.addComponent(lblStaffName1)
.addGap(3, 3, 3)
.addComponent(lblStaffName, [Link].PREFERRED_SIZE, 161,
[Link].PREFERRED_SIZE))
.addGroup([Link]()
.addGroup([Link]([Link])
.addComponent(lblStaffName3, [Link].PREFERRED_SIZE, 150,
[Link].PREFERRED_SIZE)
.addComponent(btnStudent, [Link].PREFERRED_SIZE, 139,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup([Link]([Link], false)
.addComponent(btnCourse, [Link].DEFAULT_SIZE, 144, Short.MAX_VALUE)
.addComponent(lblStaffName2, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(btnCourse1, [Link].PREFERRED_SIZE, 156,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnCourse2, [Link].PREFERRED_SIZE, 156,
[Link].PREFERRED_SIZE))
.addGroup([Link], [Link]()
.addComponent(lblStaffName5, [Link].PREFERRED_SIZE, 156,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(lblStaffName4, [Link].PREFERRED_SIZE, 156,
[Link].PREFERRED_SIZE)
.addGap(8, 8, 8)))))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnCourse, btnCourse1,


btnStudent, lblStaffName4});

[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(btnStudent, [Link].PREFERRED_SIZE, 217,
[Link].PREFERRED_SIZE)
.addGroup([Link]()
.addGroup([Link]([Link])

36
HND in Computing & Programming in
System Development Java
.addComponent(btnCourse, [Link].PREFERRED_SIZE, 217,
[Link].PREFERRED_SIZE)
.addComponent(btnCourse1, [Link].PREFERRED_SIZE, 217,
[Link].PREFERRED_SIZE)
.addComponent(btnCourse2, [Link].PREFERRED_SIZE, 217,
[Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addGroup([Link]([Link])
.addComponent(lblStaffName3)
.addComponent(lblStaffName2)
.addComponent(lblStaffName5))
.addComponent(lblStaffName4))))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(lblStaffName)
.addComponent(lblStaffName1))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnCourse, btnStudent});

pack();
}// </editor-fold>

private void menuAddUsersActionPerformed([Link] evt) {


// TODO add your handling code here:
AddUser adduser = new AddUser();
[Link](null);
[Link](false);
[Link](true);

private void menuEditMyAccActionPerformed([Link] evt) {


// TODO add your handling code here:
EditMyUserAcc editmyacc = new EditMyUserAcc(staffid);
[Link](null);
[Link](false);
[Link](true);

private void menulogoutMouseClicked([Link] evt) {


[Link](false);
Login log = new Login();
[Link](true);
[Link](null);
}

private void menulogoutActionPerformed([Link] evt) {

37
HND in Computing & Programming in
System Development Java

private void jMenuItem1ActionPerformed([Link] evt) {


// TODO add your handling code here:

private void jMenuItem2ActionPerformed([Link] evt) {


// TODO add your handling code here:
About about = new About();
[Link](true);
[Link](null);

private void btnStudentActionPerformed([Link] evt) {


// TODO add your handling code here:
StudentDetails sudentdetails= new StudentDetails(privileges);
[Link](true);
[Link](null);
[Link](false);
}

private void btnCourseActionPerformed([Link] evt) {


// TODO add your handling code here:

CourseDetails csdetails= new CourseDetails(privileges);


[Link](true);
[Link](null);
[Link](false);

private void btnCourse2ActionPerformed([Link] evt) {


// TODO add your handling code here:
BatchDetails batch= new BatchDetails(privileges);
[Link](true);
[Link](null);
[Link](false);

/**
* @param args the command line arguments
*/
public static void main(String args[])throws ClassNotFoundException, SQLException {
try {
[Link]("[Link]");
} catch (Exception er) {
[Link]([Link]());
}

/* Create and display the form */


[Link](new Runnable() {
public void run() {

38
HND in Computing & Programming in
System Development Java
//Main m =new Main();
}
});
}

// Variables declaration - do not modify


private [Link] btnCourse;
private [Link] btnCourse1;
private [Link] btnCourse2;
private [Link] btnStudent;
private [Link] jMenu2;
private [Link] jMenu3;
private [Link] jMenuBar1;
private [Link] jMenuItem1;
private [Link] jMenuItem2;
private [Link] lblStaffName;
private [Link] lblStaffName1;
private [Link] lblStaffName2;
private [Link] lblStaffName3;
private [Link] lblStaffName4;
private [Link] lblStaffName5;
private [Link] menuAddUsers;
private [Link] menuEditMyAcc;
private [Link] menulogout;
// End of variables declaration
}

39
HND in Computing & Programming in
System Development Java

Student Details form

Program Code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/
public class StudentDetails extends [Link] {

/**
* Creates new form StudentDetails
*/

DefaultTableModel model;

public StudentDetails(boolean q) {

40
HND in Computing & Programming in
System Development Java
initComponents();
model = new DefaultTableModel();

[Link]("Student_ID");
[Link]("Student_Name");
[Link]("Age");
[Link]("Telephone_no");
[Link](model);
[Link](q);

/**
* 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() {

jButton1 = new [Link]();


jScrollPane1 = new [Link]();
tblStudent = new [Link]();
btnDelete = new [Link]();
btnEdit = new [Link]();
txtStudentID = new [Link]();
btnAddNewStudent = new [Link]();
jLabel1 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](new [Link](255, 153, 0));


[Link](new [Link]("Tahoma", 1, 10)); // NOI18N
[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
jButton1ActionPerformed(evt);
}
});

[Link](true);
[Link](new [Link](
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}

41
HND in Computing & Programming in
System Development Java
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
[Link](tblStudent);
if ([Link]().getColumnCount() > 0) {
[Link]().getColumn(0).setHeaderValue("Title 1");
[Link]().getColumn(1).setHeaderValue("Title 2");
[Link]().getColumn(2).setHeaderValue("Title 3");
[Link]().getColumn(3).setHeaderValue("Title 4");
}

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Delete Student Details");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnDeleteActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Edit Student Detais");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnEditActionPerformed(evt);
}
});

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtStudentIDActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Add New Student Detail");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddNewStudentActionPerformed(evt);
}
});

[Link]("Student ID :");

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])

42
HND in Computing & Programming in
System Development Java
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(btnAddNewStudent)
.addPreferredGap([Link])
.addComponent(btnEdit)
.addPreferredGap([Link])
.addComponent(btnDelete, [Link].PREFERRED_SIZE, 149,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(jButton1, [Link].PREFERRED_SIZE, 79,
[Link].PREFERRED_SIZE))
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE, 742,
[Link].PREFERRED_SIZE))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup([Link], [Link]()
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap([Link])
.addComponent(txtStudentID, [Link].PREFERRED_SIZE, 105,
[Link].PREFERRED_SIZE)
.addContainerGap())
);
[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap(18, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(txtStudentID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE, 195,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jButton1, [Link].PREFERRED_SIZE, 31,
[Link].PREFERRED_SIZE)
.addGroup([Link]([Link])
.addComponent(btnDelete, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnEdit, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnAddNewStudent, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)))
.addContainerGap())
);

pack();
}// </editor-fold>
public void setUserLimitations(boolean prm){
[Link](prm);

43
HND in Computing & Programming in
System Development Java

public void findStudentDetails() throws ClassNotFoundException, SQLException{


// connect to the sql server

[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

String SQL1 = " SELECT * FROM Student_Details WHERE Student_ID LIKE" + "'%"+ [Link]()
+"%'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls = [Link](SQL1);

[Link]();

while([Link]())
{
[Link](new Object[]{
[Link](1),
[Link](2),
[Link](3),
[Link](4),
}
);
}

}
//--------refresh the table-----------
public void refreshTable(){
while ([Link]() > 0) {
[Link](0);
}
}

// Delete Student details-------------------

public void deletestudentDetails(String selRow) throws ClassNotFoundException, SQLException


{
// connect to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

Statement statement = [Link]();

44
HND in Computing & Programming in
System Development Java
[Link]("DELETE FROM Student_Details WHERE Student_ID='" + selRow + "'");

private void jButton1ActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void btnDeleteActionPerformed([Link] evt) {


// TODO add your handling code here:
try{
if ([Link]() < 0 || [Link]() < 0) {
[Link](this, "Select a Record From Table To Delete","NO RECORD
SELECTED",JOptionPane.WARNING_MESSAGE);
}
else {

int respond =[Link](this, "Are You Sure You Want To Delete This?","Confirm
Deletion",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
String selectedRec = (String)[Link]([Link](), 0);
[Link](selectedRec); // deleting a cake from Db
[Link]();
[Link]();
}
else{
}
}
}//end try
catch (ClassNotFoundException e){
[Link](e);
}
catch (SQLException e){
[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}

private void btnEditActionPerformed([Link] evt) {


// TODO add your handling code here:
if ([Link]() <0 || [Link]()<0) {
[Link](this, "First select a record to Edit!", "NO RECORD SELECTED",
JOptionPane.WARNING_MESSAGE);
} else {
String st = (String) [Link]([Link](), 0);
EditStudentDetails editstudentdetails = new EditStudentDetails(st);
[Link](true);
[Link](null);
[Link](false);
}

45
HND in Computing & Programming in
System Development Java

private void btnAddNewStudentActionPerformed([Link] evt) {


// TODO add your handling code here:

AddNewStudent addnewstudent = new AddNewStudent ();


[Link](true);
[Link](false);
[Link](null);

private void txtStudentIDActionPerformed([Link] evt) {


// TODO add your handling code here:

try{
if ([Link]().equals("")){
//txtStudentID empty
[Link](null, "The Student ID Field Is Empty,Enter Student ID And Search", "EMPTY
FIELD", JOptionPane.ERROR_MESSAGE);
}
else{//txtxCake not empty
[Link]();
if([Link]()==0){
[Link](this, "No Data Found", "NO DATA", JOptionPane.ERROR_MESSAGE);
}
}
}//end try

catch (ClassNotFoundException e){


[Link](e);

}
catch (SQLException e){
[Link](null, e, "ERROR IN CONNECTION", JOptionPane.ERROR_MESSAGE);
}

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}

46
HND in Computing & Programming in
System Development Java
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null,
ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
// new StudentDetails().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAddNewStudent;
private [Link] btnDelete;
private [Link] btnEdit;
private [Link] jButton1;
private [Link] jLabel1;
private [Link] jScrollPane1;
private [Link] tblStudent;
private [Link] txtStudentID;
// End of variables declaration
}

47
HND in Computing & Programming in
System Development Java

Add New Student Details Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/
public class AddNewStudent extends [Link] {

/**
* Creates new form AddNewStudent
*/
public AddNewStudent() {
initComponents();

48
HND in Computing & Programming in
System Development Java

try{
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}
catch (SQLException e){
[Link](e);
}

/**
* 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() {

jButton1 = new [Link]();


jPanel1 = new [Link]();
jLabel5 = new [Link]();
jLabel3 = new [Link]();
jLabel1 = new [Link]();
txtstudID = new [Link]();
jLabel4 = new [Link]();
jLabel2 = new [Link]();
jLabel6 = new [Link]();
txtstudName = new [Link]();
txtAge = new [Link]();
txtTp = new [Link]();
txtCsID = new [Link]();
txtBatchID = new [Link]();
btnAdd = new [Link]();
btnClear = new [Link]();
jSeparator2 = new [Link]();
jLabel7 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](new [Link](255, 153, 0));


[Link]("ok");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
jButton1ActionPerformed(evt);
}
});

49
HND in Computing & Programming in
System Development Java
[Link]([Link](null, "Add new Student",
[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial Unicode MS", 0, 14), new [Link](255, 153, 0))); // NOI18N

[Link]("Name :");

[Link]("Age :");

[Link]("Student ID :");

[Link](new [Link](255, 51, 51));


[Link](false);

[Link]("Telephone_no :");

[Link]("Course ID :");

[Link]("Batch ID :");

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtAgeActionPerformed(evt);
}
});

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtTpActionPerformed(evt);
}
});

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]([Link], false)
.addComponent(jLabel5, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel3)
.addComponent(jLabel4)
.addGroup([Link]([Link], false)
.addComponent(jLabel6, [Link],
[Link].DEFAULT_SIZE, [Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, [Link],
[Link].DEFAULT_SIZE, [Link].DEFAULT_SIZE, Short.MAX_VALUE)))
.addGap(10, 10, 10)
.addGroup([Link]([Link])
.addComponent(txtstudName)
.addGroup([Link]()

50
HND in Computing & Programming in
System Development Java
.addGroup([Link]([Link], false)
.addComponent(txtstudID, [Link].PREFERRED_SIZE, 122,
[Link].PREFERRED_SIZE)
.addComponent(txtAge, [Link].DEFAULT_SIZE, 123, Short.MAX_VALUE)
.addComponent(txtTp)
.addComponent(txtCsID)
.addComponent(txtBatchID))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(txtstudID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtstudName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(txtAge, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtTp, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtCsID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtBatchID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel6))
.addGap(5, 5, 5))
);

[Link]("Save");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddActionPerformed(evt);
}
});

[Link]("Clear");

51
HND in Computing & Programming in
System Development Java
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link]("He Institute ");


[Link](false);

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap()
.addComponent(jPanel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup([Link]()
.addGap(12, 12, 12)
.addComponent(btnClear, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 87,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link], 111,
Short.MAX_VALUE)
.addComponent(jButton1, [Link].PREFERRED_SIZE, 75,
[Link].PREFERRED_SIZE))
.addGroup([Link]()
.addContainerGap()
.addComponent(jLabel7)
.addPreferredGap([Link])
.addComponent(jSeparator2)))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnAdd, btnClear,


jButton1});

[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addGap(21, 21, 21)
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(jSeparator2, [Link].PREFERRED_SIZE, 10,
[Link].PREFERRED_SIZE)

52
HND in Computing & Programming in
System Development Java
.addComponent(jLabel7, [Link].PREFERRED_SIZE, 19,
[Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jButton1, [Link].PREFERRED_SIZE, 32,
[Link].PREFERRED_SIZE)
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnClear))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnAdd, btnClear,


jButton1});

pack();
}// </editor-fold>

public void add_student() throws ClassNotFoundException, SQLException{

// connection to the sql server


[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected ");

Statement statement = [Link]();

if([Link]().equals("")){
[Link](null, "The Student name Field Is Empty,Enter the Student name Name",
"EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The Age Field Is Empty,Enter the Student Age", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The Telephone number Field Is Empty,Enter the Student Telephone
number", "EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}

else if([Link]().equals("")){
[Link](null, "The Course ID Field Is Empty,Enter a Course ID", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The Batch ID Field Is Empty,Enter a Batch ID", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else {
[Link]("INSERT INTO Student_Details VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +

53
HND in Computing & Programming in
System Development Java
"'" + [Link]()+ "'" + "," +
"'" + [Link]() + "'" + ")" + "");

[Link]("INSERT INTO [Student_ Course] VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + ")" + "");

[Link]("INSERT INTO [Student_ Batch] VALUES " +"( '" + [Link]() + "'" + "," +

"'" + [Link]() + "'" + ")" + "");

[Link](null, "Record has been saved in the database", "INSERT SUCCESSFUL",


JOptionPane.INFORMATION_MESSAGE);
}

//-----------------------End of Add Student-------------------------------------------------------

public void clearAll(){

[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");

public void generateID()throws ClassNotFoundException, SQLException{

[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected ");
String sql="SELECT * FROM Student_Details ORDER BY Student_ID ASC";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
int id;

if(![Link]()){
id=1;
[Link]([Link](id));
}
else{
[Link]();
id=[Link]([Link](1));
String str_newid=[Link](id+1);
[Link](str_newid);

54
HND in Computing & Programming in
System Development Java
}

}// end of get details from student

private void jButton1ActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);

private void btnAddActionPerformed([Link] evt) {


// TODO add your handling code here:
try{

this.add_student();//add new cake to database


[Link]();
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null,e, "ERROR", JOptionPane.ERROR_MESSAGE);
[Link](e);

}
}

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();

private void txtAgeActionPerformed([Link] evt) {


// TODO add your handling code here:
}

private void txtTpActionPerformed([Link] evt) {


// 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 [Link]

55
HND in Computing & Programming in
System Development Java
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link],
null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new AddNewStudent().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAdd;
private [Link] btnClear;
private [Link] jButton1;
private [Link] jLabel1;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jLabel6;
private [Link] jLabel7;
private [Link] jPanel1;
private [Link] jSeparator2;
private [Link] txtAge;
private [Link] txtBatchID;
private [Link] txtCsID;
private [Link] txtTp;
private [Link] txtstudID;
private [Link] txtstudName;
// End of variables declaration
}

56
HND in Computing & Programming in
System Development Java

Edit Student Details Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
*
* @author Anushka
*/
public class EditStudentDetails extends [Link] {

/**
* Creates new form EditStudentDetails
*/
public EditStudentDetails(String id) {
initComponents();

[Link](id);

57
HND in Computing & Programming in
System Development Java
try{

[Link](id);

}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}

/**
* 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() {

btnEdit = new [Link]();


btnClear = new [Link]();
btnCancel = new [Link]();
jPanel1 = new [Link]();
jLabel5 = new [Link]();
jLabel3 = new [Link]();
txtstudName = new [Link]();
jLabel1 = new [Link]();
txtstudID = new [Link]();
jLabel4 = new [Link]();
txtAge = new [Link]();
txtTp = new [Link]();
jLabel6 = new [Link]();
jSeparator2 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]("Update ");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnEditActionPerformed(evt);
}
});

[Link]("Clear");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {

58
HND in Computing & Programming in
System Development Java
btnClearActionPerformed(evt);
}
});

[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCancelActionPerformed(evt);
}
});

[Link]([Link](null, "Edit Student details",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial Unicode MS", 0, 14), new [Link](255, 153, 0))); // NOI18N

[Link]("Name :");

[Link]("Age :");

[Link]("Student ID :");

[Link](new [Link](255, 51, 51));


[Link](false);

[Link]("Telephone_no :");

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link], false)
.addComponent(jLabel5, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtstudName, [Link].PREFERRED_SIZE, 205,
[Link].PREFERRED_SIZE)
.addComponent(txtstudID, [Link].PREFERRED_SIZE, 122,
[Link].PREFERRED_SIZE)))
.addGroup([Link]()
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap([Link])
.addGroup([Link]([Link], false)
.addComponent(txtAge)
.addComponent(txtTp, [Link].DEFAULT_SIZE, 123, Short.MAX_VALUE))))
.addContainerGap(77, Short.MAX_VALUE))

59
HND in Computing & Programming in
System Development Java
);

[Link]([Link], new [Link][] {jLabel1,


jLabel3, jLabel4, jLabel5});

[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(jLabel1)
.addComponent(txtstudID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtstudName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(txtAge, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtTp, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(53, 53, 53))
);

[Link]("He Institute ");


[Link](false);

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(jPanel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]()
.addComponent(btnClear)
.addPreferredGap([Link])
.addComponent(btnEdit)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancel))
.addGroup([Link]()
.addComponent(jLabel6)
.addPreferredGap([Link])
.addComponent(jSeparator2)))

60
HND in Computing & Programming in
System Development Java
.addContainerGap())
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnEdit});

[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, [Link].PREFERRED_SIZE, 165,
[Link].PREFERRED_SIZE)
.addGap(37, 37, 37)
.addGroup([Link]([Link])
.addComponent(jSeparator2, [Link].PREFERRED_SIZE, 10,
[Link].PREFERRED_SIZE)
.addComponent(jLabel6, [Link].PREFERRED_SIZE, 19,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup([Link]([Link])
.addComponent(btnEdit, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnClear)
.addComponent(btnCancel))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnEdit});

pack();
}// </editor-fold>

public void clearAll(){

[Link]("");
[Link]("");
[Link]("");
}//***********************end cl ******************

public void updateStudentDetails() throws ClassNotFoundException, SQLException


{
// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

Statement statement = [Link]();

61
HND in Computing & Programming in
System Development Java
String sql = "UPDATE Student_Details SET Student_Name='"+ [Link]()+ "'" + ","+
"Age='"+ [Link]()+ "'" + ","+
"Telephone_no='"+ [Link]() + "'" +
"WHERE Student_ID='"+ [Link]() +"'";

[Link](sql);

}//------------------endupdate--------------------------------

public void setStudentDetails(String S_id) throws ClassNotFoundException, SQLException{


// sql server connection
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

String SQL1 = " SELECT * FROM Student_Details WHERE Student_ID ='"+ S_id +"'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls = [Link](SQL1);

[Link]();

[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));

private void btnEditActionPerformed([Link] evt) {

try{
int respond =[Link](this, "Are You Sure You Want To Update This
record?","Confirm Update",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
[Link]();
[Link](false);
}
else{
}
}//end try

catch (ClassNotFoundException e){


[Link](e);

62
HND in Computing & Programming in
System Development Java
}

catch (SQLException e){


[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();
}

private void btnCancelActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link],
null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new EditStudentDetails("s").setVisible(true);
}
});

63
HND in Computing & Programming in
System Development Java
}

// Variables declaration - do not modify


private [Link] btnCancel;
private [Link] btnClear;
private [Link] btnEdit;
private [Link] jLabel1;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jLabel6;
private [Link] jPanel1;
private [Link] jSeparator2;
private [Link] txtAge;
private [Link] txtTp;
private [Link] txtstudID;
private [Link] txtstudName;
// End of variables declaration
}

Course Details Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;

64
HND in Computing & Programming in
System Development Java
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
*
* @author Anushka
*/
public class CourseDetails extends [Link] {

/**
* Creates new form CourseDetails
*/

DefaultTableModel model;

public CourseDetails(boolean r) {
initComponents();

model = new DefaultTableModel();

[Link]("Course_ID");
[Link]("Course_Name");
[Link]("Duration");
[Link]("Course_Fee");
[Link](model);
[Link](r);

/**
* 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() {

btnDelete = new [Link]();


btnAddNewCourse = new [Link]();
btnEdit = new [Link]();
jButton1 = new [Link]();
jScrollPane1 = new [Link]();
tblCourse = new [Link]();
txtCourseID1 = new [Link]();
jLabel1 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

65
HND in Computing & Programming in
System Development Java
setName("Course Details"); // NOI18N

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Delete Course Details");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnDeleteActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Add New Course Detail");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddNewCourseActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("EditCourse Detais");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnEditActionPerformed(evt);
}
});

[Link](new [Link](255, 153, 0));


[Link](new [Link]("Tahoma", 1, 10)); // NOI18N
[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
jButton1ActionPerformed(evt);
}
});

[Link](new [Link](
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {

66
HND in Computing & Programming in
System Development Java
"Title 1", "Title 2", "Title 3", "Title 4"
}
){
boolean[] canEdit = new boolean [] {
false, false, false, false
};

public boolean isCellEditable(int rowIndex, int columnIndex) {


return canEdit [columnIndex];
}
});
[Link]().setReorderingAllowed(false);
[Link](tblCourse);
if ([Link]().getColumnCount() > 0) {
[Link]().getColumn(0).setResizable(false);
[Link]().getColumn(1).setResizable(false);
[Link]().getColumn(2).setResizable(false);
[Link]().getColumn(3).setResizable(false);
}

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtCourseID1ActionPerformed(evt);
}
});

[Link]("Course ID");

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link], false)
.addGroup([Link]()
.addComponent(btnAddNewCourse)
.addPreferredGap([Link])
.addComponent(btnDelete, [Link].PREFERRED_SIZE, 149,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(btnEdit)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, [Link].PREFERRED_SIZE, 79,
[Link].PREFERRED_SIZE))
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(jLabel1)
.addPreferredGap([Link])
.addComponent(txtCourseID1, [Link].PREFERRED_SIZE, 116,
[Link].PREFERRED_SIZE))
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE, 742,
[Link].PREFERRED_SIZE)))

67
HND in Computing & Programming in
System Development Java
.addContainerGap(12, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnAddNewCourse,


btnDelete, btnEdit});

[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addGap(10, 10, 10)
.addGroup([Link]([Link])
.addComponent(txtCourseID1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap([Link])
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE, 195,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link], 57, Short.MAX_VALUE)
.addGroup([Link]([Link], false)
.addGroup([Link]([Link])
.addComponent(btnEdit, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(jButton1, [Link].PREFERRED_SIZE, 31,
[Link].PREFERRED_SIZE))
.addComponent(btnAddNewCourse, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnDelete, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnAddNewCourse,


btnDelete, btnEdit});

pack();
}// </editor-fold>

public void setUserLimitations(boolean prm){


[Link](prm);
[Link](prm);
[Link](prm);
}

public void findCourseDetails() throws ClassNotFoundException, SQLException{


// connect to the sql server

[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

68
HND in Computing & Programming in
System Development Java
String SQL1 = " SELECT * FROM Course_Details WHERE Course_ID LIKE" + "'%"+ [Link]()
+"%'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls1 = [Link](SQL1);

[Link]();
while([Link]())
{
[Link](new Object[]{
[Link](1),
[Link](2),
[Link](3),
[Link](4),
}
);
}

//--------refresh the table-----------


public void refreshTable(){
while ([Link]() > 0) {
[Link](0);
}
}

// Delete SCourse details-------------------

public void deleteCourseDetails(String selRow) throws ClassNotFoundException, SQLException


{
// connect to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

Statement statement = [Link]();


[Link]("DELETE FROM Course_Details WHERE Course_ID='" + selRow + "'");
}

private void btnDeleteActionPerformed([Link] evt) {


// TODO add your handling code here:
try{

69
HND in Computing & Programming in
System Development Java
if ([Link]() < 0 || [Link]() < 0) {
[Link](this, "Select a Record From Table To Delete","NO RECORD
SELECTED",JOptionPane.WARNING_MESSAGE);
}
else {

int respond =[Link](this, "Are You Sure You Want To Delete This?","Confirm
Deletion",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
String selectedRec = (String)[Link]([Link](), 0);
[Link](selectedRec); // deleting a cake from Db
[Link]();
[Link]();
}
else{
}
}
}//end try
catch (ClassNotFoundException e){
[Link](e);
}
catch (SQLException e){
[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

private void btnAddNewCourseActionPerformed([Link] evt) {


// TODO add your handling code here:
AddNewCourse addnewcourse = new AddNewCourse ();
[Link](true);
[Link](false);
[Link](null);

private void btnEditActionPerformed([Link] evt) {


// TODO add your handling code here:
if ([Link]() <0 || [Link]()<0) {
[Link](this, "First select a record to Edit!", "NO RECORD SELECTED",
JOptionPane.WARNING_MESSAGE);
} else {
String str = (String) [Link]([Link](), 0);
EditCourseDetails editcoursedetails = new EditCourseDetails(str);
[Link](true);
[Link](null);
[Link](false);
}
}

private void jButton1ActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

70
HND in Computing & Programming in
System Development Java
private void txtCourseID1ActionPerformed([Link] evt) {
// TODO add your handling code here:

try{
if ([Link]().equals("")){
//txtcake empty
[Link](null, "The Cake Name Field Is Empty,Enter Cake Name And Search",
"EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else{//txtxCake not empty
[Link]();
if([Link]()==0){
[Link](this, "No Data Found", "NO DATA", JOptionPane.ERROR_MESSAGE);
}
}

}//end try

catch (ClassNotFoundException e){


[Link](e);

}
catch (SQLException e){
[Link](null, e, "ERROR IN CONNECTION", JOptionPane.ERROR_MESSAGE);
}

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (IllegalAccessException ex) {

71
HND in Computing & Programming in
System Development Java
[Link]([Link]()).log([Link], null,
ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null,
ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
//new CourseDetails().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAddNewCourse;
private [Link] btnDelete;
private [Link] btnEdit;
private [Link] jButton1;
private [Link] jLabel1;
private [Link] jScrollPane1;
private [Link] tblCourse;
private [Link] txtCourseID1;
// End of variables declaration
}

Add Course detail Form

72
HND in Computing & Programming in
System Development Java

Program Code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/
public class AddNewCourse extends [Link] {

/**
* Creates new form AddNewCourse
*/
public AddNewCourse() {
initComponents();

try{
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}
catch (SQLException e){
[Link](e);
}

/**
* 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 = new [Link]();


jLabel5 = new [Link]();
jLabel3 = new [Link]();
jLabel1 = new [Link]();
txtCsID = new [Link]();
jLabel4 = new [Link]();

73
HND in Computing & Programming in
System Development Java
txtcsName = new [Link]();
txtDuration = new [Link]();
txtFee = new [Link]();
btnClear = new [Link]();
btnSave = new [Link]();
btnCancel = new [Link]();
jLabel6 = new [Link]();
jSeparator2 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]([Link](null, "Add New Course ",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial Unicode MS", 0, 14), new [Link](255, 153, 0))); // NOI18N

[Link]("Course Name :");

[Link]("Duration :");

[Link]("Course ID :");

[Link](new [Link](255, 51, 51));


[Link](false);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtCsIDActionPerformed(evt);
}
});

[Link]("Course fee :");

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtFeeActionPerformed(evt);
}
});

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link], false)
.addComponent(jLabel5, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(29, 29, 29)
.addGroup([Link]([Link])
.addComponent(txtCsID, [Link].PREFERRED_SIZE, 122,
[Link].PREFERRED_SIZE)
.addComponent(txtcsName, [Link].DEFAULT_SIZE, 326, Short.MAX_VALUE)))
.addGroup([Link]()
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(29, 29, 29)
.addGroup([Link]([Link], false)
.addComponent(txtDuration)

74
HND in Computing & Programming in
System Development Java
.addComponent(txtFee, [Link].DEFAULT_SIZE, 123, Short.MAX_VALUE))))
.addContainerGap())
);

[Link]([Link], new [Link][] {jLabel1,


jLabel3, jLabel4, jLabel5});

[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(jLabel1)
.addComponent(txtCsID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtcsName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(txtDuration, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(12, 12, 12)
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtFee, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(53, 53, 53))
);

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Clear");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Save");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnSaveActionPerformed(evt);
}
});

[Link](new [Link](255, 153, 0));


[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCancelActionPerformed(evt);
}
});

[Link]("He Institute ");


[Link](false);

75
HND in Computing & Programming in
System Development Java

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(jPanel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]()
.addComponent(btnClear)
.addPreferredGap([Link])
.addComponent(btnSave, [Link].PREFERRED_SIZE, 83,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancel, [Link].PREFERRED_SIZE, 71,
[Link].PREFERRED_SIZE))
.addGroup([Link]()
.addComponent(jLabel6)
.addPreferredGap([Link])
.addComponent(jSeparator2)))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnClear, btnSave});

[Link](
[Link]([Link])
.addGroup([Link]()
.addGap(19, 19, 19)
.addComponent(jPanel1, [Link].PREFERRED_SIZE, 165,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup([Link]([Link])
.addComponent(jSeparator2, [Link].PREFERRED_SIZE, 10,
[Link].PREFERRED_SIZE)
.addComponent(jLabel6, [Link].PREFERRED_SIZE, 19,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup([Link]([Link])
.addComponent(btnSave)
.addComponent(btnClear)
.addComponent(btnCancel))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnSave});

pack();
}// </editor-fold>
public void generateID()throws ClassNotFoundException, SQLException{
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected "); // connection ok

String sql="SELECT * FROM Course_Details ORDER BY Course_ID ASC;";

76
HND in Computing & Programming in
System Development Java
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
int id;
if(![Link]()){
id=1;
[Link]([Link](id));
}
else{
[Link]();
id=[Link]([Link](1));
[Link]([Link](id+1));
}

public void add_Course() throws ClassNotFoundException, SQLException{

// connection to the sql server


[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected ");

Statement statement = [Link]();

if([Link]().equals("")){
[Link](null, "The Course name Field Is Empty,Enter the Course name Name",
"EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The Duration Field Is Empty,Enter the Duration", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The Course Fee Field Is Empty,Enter the Course Fee ", "EMPTY
FIELD", JOptionPane.ERROR_MESSAGE);
}

else if([Link]().equals("")){
[Link](null, "The Course ID Field Is Empty,Enter a Course ID", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else {
[Link]("INSERT INTO Course_Details VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]()+ "'" + "," +
"'" + [Link]() + "'" + ")" + "");
[Link](null, "Record has been saved in the database", "INSERT SUCCESSFUL",
JOptionPane.INFORMATION_MESSAGE);
}
}

public void clearAll(){


[Link]("");
[Link]("");
[Link]("");
[Link]("");
}

77
HND in Computing & Programming in
System Development Java

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();
}

private void btnSaveActionPerformed([Link] evt) {


try{

this.add_Course();//add new cake to database


[Link]();
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null,e, "ERROR", JOptionPane.ERROR_MESSAGE);
[Link](e);

private void btnCancelActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void txtCsIDActionPerformed([Link] evt) {


// TODO add your handling code here:
}

private void txtFeeActionPerformed([Link] evt) {


// 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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (InstantiationException ex) {

78
HND in Computing & Programming in
System Development Java
[Link]([Link]()).log([Link], null,
ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null,
ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new AddNewCourse().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnCancel;
private [Link] btnClear;
private [Link] btnSave;
private [Link] jLabel1;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jLabel6;
private [Link] jPanel1;
private [Link] jSeparator2;
private [Link] txtCsID;
private [Link] txtDuration;
private [Link] txtFee;
private [Link] txtcsName;
// End of variables declaration
}

Edit Course Details Form

79
HND in Computing & Programming in
System Development Java

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
*
* @author Anushka
*/
public class EditCourseDetails extends [Link] {

/**
* Creates new form EditCourseDetails
*/
public EditCourseDetails(String id) {
initComponents();
[Link](id);

try{
[Link](id);

}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}

/**
* 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">

80
HND in Computing & Programming in
System Development Java
private void initComponents() {

jPanel1 = new [Link]();


jLabel5 = new [Link]();
jLabel3 = new [Link]();
txtcsName = new [Link]();
jLabel1 = new [Link]();
txtcourseID = new [Link]();
jLabel4 = new [Link]();
txtDuration = new [Link]();
txtFee = new [Link]();
btnEdit = new [Link]();
btnClear = new [Link]();
btnCancel = new [Link]();
jSeparator2 = new [Link]();
jLabel6 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]([Link](null, "Edit Course details",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial Unicode MS", 0, 14), new [Link](255, 153, 0))); // NOI18N

[Link]("Course Name :");

[Link]("Duration :");

[Link]("Course ID :");

[Link](new [Link](255, 51, 51));


[Link](false);

[Link]("Course fee :");

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtFeeActionPerformed(evt);
}
});

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]([Link], false)
.addComponent(jLabel5, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel3)
.addComponent(jLabel4))

81
HND in Computing & Programming in
System Development Java
.addGap(29, 29, 29)
.addGroup([Link]([Link])
.addGroup([Link]([Link], false)
.addComponent(txtDuration, [Link],
[Link].DEFAULT_SIZE, 122, Short.MAX_VALUE)
.addComponent(txtFee)
.addComponent(txtcourseID, [Link],
[Link].PREFERRED_SIZE, 40, [Link].PREFERRED_SIZE))
.addComponent(txtcsName, [Link].PREFERRED_SIZE, 221,
[Link].PREFERRED_SIZE))
.addContainerGap(28, Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(jLabel1)
.addComponent(txtcourseID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtcsName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(txtDuration, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(12, 12, 12)
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtFee, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(53, 53, 53))
);

[Link]().setAccessibleName("Course ID :");

[Link]("Update ");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnEditActionPerformed(evt);
}
});

[Link]("Clear");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

82
HND in Computing & Programming in
System Development Java

[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCancelActionPerformed(evt);
}
});

[Link]("He Institute ");


[Link](false);

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(jPanel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup([Link]()
.addGap(23, 23, 23)
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(btnClear)
.addPreferredGap([Link])
.addComponent(btnEdit)
.addPreferredGap([Link], 148,
Short.MAX_VALUE)
.addComponent(btnCancel))
.addGroup([Link]()
.addComponent(jLabel6)
.addPreferredGap([Link])
.addComponent(jSeparator2)))))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnEdit});

[Link](
[Link]([Link])
.addGroup([Link]()
.addGap(34, 34, 34)
.addComponent(jPanel1, [Link].PREFERRED_SIZE, 165,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup([Link]([Link])
.addComponent(jSeparator2, [Link].PREFERRED_SIZE, 10,
[Link].PREFERRED_SIZE)
.addComponent(jLabel6, [Link].PREFERRED_SIZE, 19,
[Link].PREFERRED_SIZE))
.addGap(18, 18, 18)

83
HND in Computing & Programming in
System Development Java
.addGroup([Link]([Link])
.addComponent(btnEdit, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnClear)
.addComponent(btnCancel))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnEdit});

pack();
}// </editor-fold>
public void clearAll(){

[Link]("");
[Link]("");
[Link]("");
}
//----------------------end of clearing-----------

public void updateCourseDetails() throws ClassNotFoundException, SQLException


{
// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

Statement statement = [Link]();

String sql = "UPDATE Course_Details SET Course_Name='"+ [Link]()+ "'" + ","+


"Duration='"+ [Link]()+ "'" + ","+
"Course_Fee='"+ [Link]() + "'" +
"WHERE Course_ID='"+ [Link]() +"'";

[Link](sql);

//--------------------------End Update--------------------------------

public void setCourseDetails(String CS_id) throws ClassNotFoundException, SQLException{


// sql server connection
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

84
HND in Computing & Programming in
System Development Java

String SQL1 = " SELECT * FROM Course_Details WHERE Course_ID ='"+ CS_id +"'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls = [Link](SQL1);

[Link]();

[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));

}
//--------------------------end setting-------------------------------

private void btnEditActionPerformed([Link] evt) {

try{
int respond =[Link](this, "Are You Sure You Want To Update This
record?","Confirm Update",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
[Link]();
[Link](false);
}
else{
}
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();
}

private void btnCancelActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void txtFeeActionPerformed([Link] evt) {


// TODO add your handling code here:

85
HND in Computing & Programming in
System Development Java
}

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link],
null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new EditCourseDetails("Cs").setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnCancel;
private [Link] btnClear;
private [Link] btnEdit;
private [Link] jLabel1;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jLabel6;
private [Link] jPanel1;

86
HND in Computing & Programming in
System Development Java
private [Link] jSeparator2;
private [Link] txtDuration;
private [Link] txtFee;
private [Link] txtcourseID;
private [Link] txtcsName;
// End of variables declaration
}

Batch details Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
*

87
HND in Computing & Programming in
System Development Java
* @author Anushka
*/
public class BatchDetails extends [Link] {

/**
* Creates new form BatchDetails
*/

DefaultTableModel model;
public BatchDetails(boolean w) {
initComponents();

model = new DefaultTableModel();

[Link]("Batch_ID");
[Link]("Start_Date");
[Link]("End_Date");
[Link]("Number_of_Students");
[Link]("Course_ID");
[Link](model);
[Link](w);

/**
* 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() {

jScrollPane1 = new [Link]();


tblBatch = new [Link]();
btnEdit = new [Link]();
btnAdd = new [Link]();
btnCancel = new [Link]();
txtbatchID = new [Link]();
jLabel1 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](new [Link](
new Object [][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4", "Title 5"
}
){

88
HND in Computing & Programming in
System Development Java
boolean[] canEdit = new boolean [] {
true, true, true, true, false
};

public boolean isCellEditable(int rowIndex, int columnIndex) {


return canEdit [columnIndex];
}
});
[Link](tblBatch);
if ([Link]().getColumnCount() > 0) {
[Link]().getColumn(4).setResizable(false);
}

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Edit Batch");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnEditActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Add Batch");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddActionPerformed(evt);
}
});

[Link](new [Link](255, 153, 0));


[Link]("OK");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCancelActionPerformed(evt);
}
});

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtbatchIDActionPerformed(evt);
}
});

[Link]("Batch ID");

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()

89
HND in Computing & Programming in
System Development Java
.addGroup([Link]([Link])
.addGroup([Link]()
.addContainerGap(568, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap([Link])
.addComponent(txtbatchID, [Link].PREFERRED_SIZE, 120,
[Link].PREFERRED_SIZE))
.addGroup([Link]()
.addGap(12, 12, 12)
.addComponent(btnEdit, [Link].PREFERRED_SIZE, 93,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 93,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancel, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE)))
.addContainerGap())
.addGroup([Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(jScrollPane1, [Link].DEFAULT_SIZE, 729, Short.MAX_VALUE)
.addContainerGap()))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(txtbatchID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap([Link], 310, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(btnCancel, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnEdit, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE))
.addContainerGap())
.addGroup([Link]([Link])
.addGroup([Link]()
.addGap(48, 48, 48)
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE, 282,
[Link].PREFERRED_SIZE)
.addContainerGap(52, Short.MAX_VALUE)))
);

pack();
}// </editor-fold>
public void setUserLimitations(boolean prm){
[Link](prm);

90
HND in Computing & Programming in
System Development Java
[Link](prm);
}

public void findBatchDetails() throws ClassNotFoundException, SQLException{


// connect to the sql server

[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

String SQL1 = " SELECT * FROM Batch_Details WHERE Batch_ID LIKE" + "'%"+ [Link]() +"%'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls1 = [Link](SQL1);

[Link]();
while([Link]())
{
[Link](new Object[]{
[Link](1),
[Link](2),
[Link](3),
[Link](4),
[Link](5),
}
);
}

}
//

public void refreshTable(){


while ([Link]() > 0) {
[Link](0);
}

private void btnEditActionPerformed([Link] evt) {


// TODO add your handling code here:
if ([Link]() <0 || [Link]()<0) {
[Link](this, "Please Select record to edit!", "NO RECORD SELECTED",
JOptionPane.WARNING_MESSAGE);
}
else {
String s = (String) [Link]([Link](), 0);
EditBatchDetails editbatch = new EditBatchDetails(s);
[Link](true);

91
HND in Computing & Programming in
System Development Java
[Link](null);
[Link](false);
}

private void btnAddActionPerformed([Link] evt) {


// TODO add your handling code here:
AddBatch addbatch = new AddBatch();
[Link](true);
[Link](true);
[Link](false);
[Link](null);

private void btnCancelActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void txtbatchIDActionPerformed([Link] evt) {


// TODO add your handling code here:

try{
if ([Link]().equals("")){
//txtcake empty
[Link](null, "The Cake Name Field Is Empty,Enter Cake Name And Search",
"EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else{//txtxCake not empty
[Link]();
if([Link]()==0){
[Link](this, "No Data Found", "NO DATA", JOptionPane.ERROR_MESSAGE);
}
}

}//end try

catch (ClassNotFoundException e){


[Link](e);

}
catch (SQLException e){
[Link](null, e, "ERROR IN CONNECTION", JOptionPane.ERROR_MESSAGE);
}

/**
* @param args the command line arguments
*/

92
HND in Computing & Programming in
System Development Java
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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null,
ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
//new BatchDetails().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAdd;
private [Link] btnCancel;
private [Link] btnEdit;
private [Link] jLabel1;
private [Link] jScrollPane1;
private [Link] tblBatch;
private [Link] txtbatchID;
// End of variables declaration
}

93
HND in Computing & Programming in
System Development Java

Add New Batch Details Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/
public class AddBatch extends [Link] {

/**
* Creates new form AddBatch
*/
public AddBatch() {
initComponents();

try{
[Link]();

94
HND in Computing & Programming in
System Development Java
}//end try

catch (ClassNotFoundException e){


[Link](e);
}
catch (SQLException e){
[Link](e);
}

/**
* 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 = new [Link]();


jLabel1 = new [Link]();
jLabel2 = new [Link]();
jLabel3 = new [Link]();
jLabel4 = new [Link]();
jLabel5 = new [Link]();
txtStartDate = new [Link]();
txtEndDate = new [Link]();
txtNumofst = new [Link]();
txtCsID = new [Link]();
txtBatchID = new [Link]();
btnClear = new [Link]();
btnAdd = new [Link]();
btnOk = new [Link]();
jSeparator2 = new [Link]();
jLabel6 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]([Link](null, "Add New Batch",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial", 0, 12), new [Link](255, 153, 0))); // NOI18N

[Link]("Batch ID :");

[Link]("Start Date :");

[Link]("End Date :");

[Link]("Number of students :");

[Link]("Course ID :");

[Link](new [Link](new
[Link](new [Link]("dd/mm/yyyy"))));
[Link](new [Link]([Link].TEXT_CURSOR));

[Link](new [Link](new
[Link](new [Link]("dd/mm/yyyy"))));
[Link](new [Link]([Link].TEXT_CURSOR));

[Link](new [Link]("Tahoma", 1, 11)); // NOI18N

95
HND in Computing & Programming in
System Development Java
[Link](new [Link](240, 240, 240));
[Link](new [Link](255, 0, 0));
[Link](false);

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(jLabel4, [Link].PREFERRED_SIZE, 109,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(txtNumofst, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE))
.addGroup([Link]([Link])
.addComponent(txtStartDate, [Link].PREFERRED_SIZE, 171,
[Link].PREFERRED_SIZE)
.addGroup([Link]()
.addGroup([Link]([Link],
false)
.addComponent(jLabel3, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup([Link]([Link])
.addGroup([Link]()
.addGap(59, 59, 59)
.addGroup([Link]([Link])
.addComponent(txtEndDate, [Link].PREFERRED_SIZE, 171,
[Link].PREFERRED_SIZE)
.addComponent(txtCsID, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE)))
.addGroup([Link],
[Link]()
.addPreferredGap([Link])
.addComponent(txtBatchID, [Link].PREFERRED_SIZE, 88,
[Link].PREFERRED_SIZE)
.addGap(81, 81, 81))))))
.addContainerGap(74, Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(jLabel1)
.addComponent(txtBatchID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(14, 14, 14)
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtStartDate, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])

96
HND in Computing & Programming in
System Development Java
.addComponent(jLabel3)
.addComponent(txtEndDate, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(14, 14, 14)
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtNumofst, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtCsID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addContainerGap(37, Short.MAX_VALUE))
);

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("CLEAR");
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Save");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddActionPerformed(evt);
}
});

[Link](new [Link](255, 153, 0));


[Link]("Ok");
[Link]([Link]);
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnOkActionPerformed(evt);
}
});

[Link]("He Institute ");


[Link](false);

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link], false)
.addGroup([Link]()
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 82,
[Link].PREFERRED_SIZE)

97
HND in Computing & Programming in
System Development Java
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addGroup([Link]()
.addGap(6, 6, 6)
.addComponent(jLabel6)
.addPreferredGap([Link])
.addComponent(jSeparator2, [Link].PREFERRED_SIZE, 316,
[Link].PREFERRED_SIZE)))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnAdd, btnClear});

[Link](
[Link]([Link])
.addGroup([Link]()
.addGap(13, 13, 13)
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jSeparator2, [Link].PREFERRED_SIZE, 10,
[Link].PREFERRED_SIZE)
.addComponent(jLabel6, [Link].PREFERRED_SIZE, 19,
[Link].PREFERRED_SIZE))
.addPreferredGap([Link], 24, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(btnAdd)
.addGroup([Link]([Link])
.addComponent(btnClear, [Link].PREFERRED_SIZE, 24,
[Link].PREFERRED_SIZE)
.addComponent(btnOk, [Link].PREFERRED_SIZE, 19,
[Link].PREFERRED_SIZE)))
.addGap(19, 19, 19))
);

[Link]([Link], new [Link][] {btnAdd, btnClear, btnOk});

pack();
}// </editor-fold>
public void generateID()throws ClassNotFoundException, SQLException{
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected ");

String sql="SELECT * FROM Batch_Details ORDER BY Batch_ID ASC;";


Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
int id;
if(![Link]()){
id=1;
[Link]([Link](id));
}
else{
[Link]();

98
HND in Computing & Programming in
System Development Java
id=[Link]([Link](1));
[Link]([Link](id+1));
}

public void AddBatch() throws ClassNotFoundException, SQLException{

// connection to the sql server


[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected ");

Statement statement = [Link]();


if([Link]().equals("")){
[Link](null, "The Start Date Field Is Empty,Enter the Start Date ", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The Number of student Field Is Empty,Enter the Number of student ",
"EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}

else if([Link]().equals("")){
[Link](null, "The Course ID Field Is Empty,Enter a Course ID", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else {
[Link]("INSERT INTO Batch_Details VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]()+ "'" + "," +
"'" + [Link]()+ "'" + "," +
"'" + [Link]() + "'" + ")" + "");

[Link](null, "Record has been saved in the database", "INSERT SUCCESSFUL",


JOptionPane.INFORMATION_MESSAGE);
}

public void clearAll(){


[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();
}

99
HND in Computing & Programming in
System Development Java
private void btnAddActionPerformed([Link] evt) {
// TODO add your handling code here:
try{

[Link]();//add new user to database


[Link]();
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](this, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

private void btnOkActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new AddBatch().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAdd;
private [Link] btnClear;
private [Link] btnOk;

100
HND in Computing & Programming in
System Development Java
private [Link] jLabel1;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jLabel6;
private [Link] jPanel1;
private [Link] jSeparator2;
private [Link] txtBatchID;
private [Link] txtCsID;
private [Link] txtEndDate;
private [Link] txtNumofst;
private [Link] txtStartDate;
// End of variables declaration
}

Edit Batch Detail Form

Program Code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

101
HND in Computing & Programming in
System Development Java

/**
*
* @author Anushka
*/
public class EditBatchDetails extends [Link] {

/**
* Creates new form EditBatchDetails
*/
public EditBatchDetails(String id) {
initComponents();
[Link](id);
try{
[Link](id);

}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}

/**
* 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")

public void clearAll(){


[Link]("");
[Link]("");
[Link]("");

[Link]("");

[Link]("");

}// end of clear all

public void updateBatchDetails() throws ClassNotFoundException, SQLException


{

[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected ");

Statement statement = [Link]();

String sql = "UPDATE Batch_Details SET Start_date='"+ [Link]()+ "'" + ","+


"End_date='"+ [Link]()+ "'" + ","+

102
HND in Computing & Programming in
System Development Java
"number_Of_Student='"+ [Link]() + "'" +
"Course_ID='"+ [Link]() + "'" +
"WHERE Batch_ID='"+ [Link]() +"'";

[Link](sql);

//-------------------------end update method---------------------------

public void setBatchDetails(String Bt_id) throws ClassNotFoundException, SQLException{


// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected "); // connection ok

String SQL3 = " SELECT * FROM Batch_Details WHERE Batch_ID='"+ Bt_id +"'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rslst = [Link](SQL3);

[Link]();
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));
[Link]([Link](5));

}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new [Link]();


jLabel1 = new [Link]();
jLabel2 = new [Link]();
jLabel3 = new [Link]();
jLabel4 = new [Link]();
jLabel5 = new [Link]();
txtStartDate = new [Link]();
txtEndDate = new [Link]();
txtNumofst = new [Link]();
txtCsID = new [Link]();
txtBatchID = new [Link]();
btnClear = new [Link]();
btnEdit1 = new [Link]();
btnCancel = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]([Link](null, "Edit Batch Details",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial", 0, 12), new [Link](255, 153, 0))); // NOI18N

[Link]("Batch ID :");

[Link]("Start Date :");

103
HND in Computing & Programming in
System Development Java
[Link]("End Date :");

[Link]("Number of students :");

[Link]("Course ID :");

[Link](new [Link](new
[Link](new [Link]("dd/mm/yyyy"))));
[Link](new [Link]([Link].TEXT_CURSOR));

[Link](new [Link](new
[Link](new [Link]("dd/mm/yyyy"))));
[Link](new [Link]([Link].TEXT_CURSOR));

[Link](new [Link](255, 51, 51));


[Link](false);

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link], false)
.addComponent(jLabel3, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtStartDate, [Link].PREFERRED_SIZE, 171,
[Link].PREFERRED_SIZE)
.addComponent(txtEndDate, [Link].PREFERRED_SIZE, 171,
[Link].PREFERRED_SIZE)
.addComponent(txtCsID, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE)
.addComponent(txtBatchID, [Link].PREFERRED_SIZE, 40,
[Link].PREFERRED_SIZE)))
.addGroup([Link]()
.addComponent(jLabel4, [Link].PREFERRED_SIZE, 109,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(txtNumofst, [Link].PREFERRED_SIZE, 73,
[Link].PREFERRED_SIZE)))
.addContainerGap(67, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {jLabel4,


jLabel5});

[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(jLabel1)

104
HND in Computing & Programming in
System Development Java
.addComponent(txtBatchID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtStartDate, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(txtEndDate, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtNumofst, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtCsID, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addContainerGap(37, Short.MAX_VALUE))
);

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Clear");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("Update ");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnEdit1ActionPerformed(evt);
}
});

[Link](new [Link](255, 153, 0));


[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnCancelActionPerformed(evt);
}
});

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGap(0, 0, Short.MAX_VALUE)

105
HND in Computing & Programming in
System Development Java
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGroup([Link]()
.addComponent(btnClear)
.addPreferredGap([Link])
.addComponent(btnEdit1)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancel)))
.addContainerGap())
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnEdit1});

[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addGap(49, 49, 49)
.addGroup([Link]([Link], false)
.addGroup([Link]([Link])
.addComponent(btnEdit1, [Link].DEFAULT_SIZE, 30, Short.MAX_VALUE)
.addComponent(btnCancel))
.addComponent(btnClear, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {btnCancel, btnClear,


btnEdit1});

pack();
}// </editor-fold>

private void btnEdit1ActionPerformed([Link] evt) {


// TODO add your handling code here:

try{
int respond =[Link](this, "Do You Want To Update This record?","Confirm
Update",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
[Link]();
[Link](false);
}
else{
}
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

private void btnCancelActionPerformed([Link] evt) {


// TODO add your handling code here:

106
HND in Computing & Programming in
System Development Java
[Link](false);
}

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:

[Link]();

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link],
null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new EditBatchDetails("Bt").setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnCancel;
private [Link] btnClear;
private [Link] btnEdit1;
private [Link] jLabel1;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jPanel1;
private [Link] txtBatchID;
private [Link] txtCsID;
private [Link] txtEndDate;

107
HND in Computing & Programming in
System Development Java
private [Link] txtNumofst;
private [Link] txtStartDate;
// End of variables declaration
}

Create New User Account Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**

108
HND in Computing & Programming in
System Development Java
*
* @author Anushka
*/
public class AddUser extends [Link] {

/**
* Creates new form AddUser
*/

DefaultTableModel model;

public AddUser() {
initComponents();

try{
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}
catch (SQLException e){
[Link](e);
}

}
/**
* 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() {

btnOk = new [Link]();


btnAdd = new [Link]();
txtStaffid = new [Link]();
jLabel2 = new [Link]();
btnClear = new [Link]();
jLabel5 = new [Link]();
jLabel3 = new [Link]();
txtStaffName = new [Link]();
txtPassword = new [Link]();
jLabel7 = new [Link]();
txtUserName = new [Link]();
jPanel1 = new [Link]();
rbStaff = new [Link]();
rbAdmin = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]("Ok");

109
HND in Computing & Programming in
System Development Java
[Link]([Link]);
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnOkActionPerformed(evt);
}
});

[Link]("Save");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddActionPerformed(evt);
}
});

[Link](new [Link]("Tahoma", 1, 11)); // NOI18N


[Link](new [Link](240, 240, 240));
[Link](new [Link](255, 0, 0));
[Link](false);

[Link]("Password");

[Link]("CLEAR");
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link](" Staff Name");

[Link]("User Name");

[Link](" Staff ID");

[Link]([Link](null, "Account Type",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial", 1, 12))); // NOI18N

[Link](true);
[Link]("Staff Account");

[Link]("Admin Account");

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addGap(21, 21, 21)
.addComponent(rbAdmin)
.addPreferredGap([Link], 35, Short.MAX_VALUE)
.addComponent(rbStaff)

110
HND in Computing & Programming in
System Development Java
.addGap(18, 18, 18))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addGap(16, 16, 16)
.addGroup([Link]([Link])
.addComponent(rbStaff)
.addComponent(rbAdmin))
.addContainerGap(20, Short.MAX_VALUE))
);

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addGroup([Link]([Link])
.addComponent(jLabel7, [Link].PREFERRED_SIZE, 63,
[Link].PREFERRED_SIZE)
.addComponent(jLabel5, [Link].PREFERRED_SIZE, 72,
[Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtStaffid, [Link].PREFERRED_SIZE, 88,
[Link].PREFERRED_SIZE)
.addComponent(txtStaffName)))
.addGroup([Link]()
.addGroup([Link]([Link])
.addGroup([Link]()
.addPreferredGap([Link], 6,
[Link].PREFERRED_SIZE)
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGroup([Link]()
.addGroup([Link]([Link], false)
.addComponent(jLabel3, [Link].DEFAULT_SIZE, 72, Short.MAX_VALUE)
.addGroup([Link]()
.addGap(6, 6, 6)
.addComponent(jLabel2, [Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap([Link])
.addGroup([Link]([Link], false)
.addComponent(txtUserName)
.addComponent(txtPassword, [Link].PREFERRED_SIZE, 174,
[Link].PREFERRED_SIZE)))
.addGroup([Link]()
.addGap(30, 30, 30)
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link])

111
HND in Computing & Programming in
System Development Java
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 82,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)))
.addGap(0, 117, Short.MAX_VALUE)))
.addContainerGap())
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap(36, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(txtStaffid, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtStaffName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3, [Link].PREFERRED_SIZE, 20,
[Link].PREFERRED_SIZE)
.addComponent(txtUserName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtPassword, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addGap(28, 28, 28)
.addGroup([Link]([Link])
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 33,
[Link].PREFERRED_SIZE))
.addGap(20, 20, 20))
);

pack();
}// </editor-fold>

public void generateID()throws ClassNotFoundException, SQLException{


[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);

112
HND in Computing & Programming in
System Development Java
[Link]("The database is Connected "); // connection ok

String sql="SELECT * FROM Staff ORDER BY Staff_ID ASC;";


Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
int id;
if(![Link]()){
id=1;
[Link]([Link](id));
}
else{
[Link]();
id=[Link]([Link](1));
[Link]([Link](id+1));
}

}// end of generateID

public void clearAll(){

[Link]("");
[Link]("");
[Link]("");

}// end **********************************

public void add_User() throws ClassNotFoundException, SQLException{

// connection to the sql server


[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected to MS SQL 2005 using windows authentication 1"); // connection ok

// inserting new user

Statement statement = [Link]();

if([Link]().equals("")){
[Link](null, "The Staff Name Field Is Empty,Enter Staff Name", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){
[Link](null, "The User Name Field Is Empty,Enter User Name", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}
else if([Link]().equals("")){

113
HND in Computing & Programming in
System Development Java
[Link](null, "The Password Field Is Empty,Enter Password", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);
}

else {
[Link]("INSERT INTO Staff VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + ")" +" ");

[Link](null, "Record are saved in the database", "INSERT SUCCESSFUL",


JOptionPane.INFORMATION_MESSAGE);
}
}

public boolean getAccType(){


if([Link]()==true){
return false;
}
else if([Link]()==true){
return true;
}
else{
return false;
}
}

private void btnOkActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void btnAddActionPerformed([Link] evt) {


// TODO add your handling code here:
try{

this.add_User();//add new user to database


[Link]();
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](this, e, "ERROR", JOptionPane.ERROR_MESSAGE);

114
HND in Computing & Programming in
System Development Java
}
}

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new AddUser().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAdd;
private [Link] btnClear;
private [Link] btnOk;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] jLabel5;
private [Link] jLabel7;
private [Link] jPanel1;
private [Link] rbAdmin;

115
HND in Computing & Programming in
System Development Java
private [Link] rbStaff;
private [Link] txtPassword;
private [Link] txtStaffName;
private [Link] txtStaffid;
private [Link] txtUserName;
// End of variables declaration
}

Edit User Account Form

Program Code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
*
* @author Anushka
*/
public class EditMyUserAcc extends [Link] {

116
HND in Computing & Programming in
System Development Java
/**
* Creates new form EditMyUserAcc
*/
public EditMyUserAcc(int staffid) {
initComponents();
try{
[Link](staffid);
}//end try
catch (ClassNotFoundException e){
[Link](e);
}
catch (SQLException e){
[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

/**
* 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() {

btnClear = new [Link]();


btnOk = new [Link]();
btnUpdate = new [Link]();
jPanel1 = new [Link]();
txtStaffid = new [Link]();
txtUserName = new [Link]();
jLabel2 = new [Link]();
jLabel5 = new [Link]();
jLabel3 = new [Link]();
jLabel7 = new [Link]();
txtPassword = new [Link]();
txtStaffName = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link]("Clear");
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link]("Ok");
[Link](new [Link]([Link].HAND_CURSOR));
[Link]([Link]);
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {

117
HND in Computing & Programming in
System Development Java
btnOkActionPerformed(evt);
}
});

[Link]("Save");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnUpdateActionPerformed(evt);
}
});

[Link]([Link](null, "Edit User Account",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial", 0, 12), new [Link](255, 153, 0))); // NOI18N

[Link](new [Link]("Tahoma", 1, 11)); // NOI18N


[Link](new [Link](240, 240, 240));
[Link](new [Link](255, 51, 51));
[Link](false);

[Link]("Password");

[Link](" Staff Name");

[Link]("User Name");

[Link](" Staff ID");

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(jLabel3, [Link].PREFERRED_SIZE, 67,
[Link].PREFERRED_SIZE)
.addComponent(jLabel2, [Link].PREFERRED_SIZE, 62,
[Link].PREFERRED_SIZE)
.addComponent(jLabel5, [Link].PREFERRED_SIZE, 72,
[Link].PREFERRED_SIZE)
.addComponent(jLabel7, [Link].PREFERRED_SIZE, 63,
[Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtStaffid, [Link].PREFERRED_SIZE, 105,
[Link].PREFERRED_SIZE)
.addGroup([Link]([Link], false)
.addComponent(txtPassword)
.addComponent(txtUserName)
.addComponent(txtStaffName, [Link].PREFERRED_SIZE, 166,
[Link].PREFERRED_SIZE)))
.addContainerGap(150, Short.MAX_VALUE))
);

118
HND in Computing & Programming in
System Development Java
[Link](
[Link]([Link])
.addGroup([Link]()
.addGap(28, 28, 28)
.addGroup([Link]([Link])
.addComponent(txtStaffid, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel5)
.addComponent(txtStaffName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3, [Link].PREFERRED_SIZE, 20,
[Link].PREFERRED_SIZE)
.addComponent(txtUserName, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtPassword, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addContainerGap(29, Short.MAX_VALUE))
);

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup([Link]()
.addComponent(btnUpdate)
.addPreferredGap([Link])
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addGap(24, 24, 24))))
);

[Link]([Link], new [Link][] {btnClear, btnUpdate});

[Link](
[Link]([Link])

119
HND in Computing & Programming in
System Development Java
.addGroup([Link]()
.addGap(36, 36, 36)
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link], 24, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(btnUpdate, [Link].PREFERRED_SIZE, 33,
[Link].PREFERRED_SIZE))
.addContainerGap())
);

pack();
}// </editor-fold>
public void getDetails(int Staffid)throws ClassNotFoundException, SQLException {
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected");

String SQL1 = " SELECT * FROM Staff WHERE Staff_ID=" + "'"+Staffid+"'";


Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](SQL1);

[Link]();
[Link]([Link](1));
[Link]([Link](2));
[Link]([Link](3));
[Link]([Link](4));

public void update_user() throws ClassNotFoundException, SQLException


{
// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
// [Link]("Successfuly Connected to MS SQL 2005 using windows authentication 1"); // command

Statement statement = [Link]();

String sql = "UPDATE Staff SET Staff_name='"+ [Link]()+ "'" + ","+


"User_name='"+ [Link]() + "'" + ","+
"Password='" + [Link]() + "'" +

120
HND in Computing & Programming in
System Development Java

"WHERE Staff_ID='" + [Link]() +"'";

int updateCount = [Link](sql);

public void clearAll(){

[Link]("");
[Link]("");
[Link]("");

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();

private void btnOkActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void btnUpdateActionPerformed([Link] evt) {


// TODO add your handling code here:
try{

int respond =[Link](this, "Do You Want To Update This Record?","Confirm


Update",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
this.update_user();
}
else{
}
}//end try
catch (ClassNotFoundException e){
[Link](e);
}
catch (SQLException e){
[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

/**
* @param args the command line arguments
*/

121
HND in Computing & Programming in
System Development Java
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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null,
ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
//new EditMyUserAcc().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnClear;
private [Link] btnOk;
private [Link] btnUpdate;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] jLabel5;
private [Link] jLabel7;
private [Link] jPanel1;
private [Link] txtPassword;
private [Link] txtStaffName;
private [Link] txtStaffid;
private [Link] txtUserName;
// End of variables declaration
}

122
HND in Computing & Programming in
System Development Java

Payment Details Form

Code :

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/
public class frmPaymentDetails extends [Link] {

/**
* Creates new form frmPaymentDetails
*/
DefaultTableModel model;
public frmPaymentDetails(boolean z) {
initComponents();
model = new DefaultTableModel();
[Link]("Payment_code");
[Link]("Payment_Method");
[Link]("Credit_Card_Number");

123
HND in Computing & Programming in
System Development Java
[Link]("Bank_Name");
[Link]("Total_Amount");
[Link]("Course_ID");
[Link]("Student_ID");

[Link](model);
[Link](z);
}

/**
* 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() {

jScrollPane1 = new [Link]();


tblPayments = new [Link]();
btnAddPay = new [Link]();
jLabel1 = new [Link]();
txtPaycode = new [Link]();
btnDelete = new [Link]();
jButton1 = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

[Link](true);
[Link](new [Link](
new Object [][] {
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null}
},
new String [] {
"Title1", "Title2", "Title3", "Title4", "Title5", "Title6", "Title7"
}
));
[Link](tblPayments);

124
HND in Computing & Programming in
System Development Java
[Link](new [Link](0, 0, 0));
[Link](new [Link](255, 255, 255));
[Link]("Receive Payment");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddPayActionPerformed(evt);
}
});

[Link]("Payment Code :");

[Link](new [Link]() {
public void actionPerformed([Link] evt) {
txtPaycodeActionPerformed(evt);
}
});

[Link](new [Link](0, 0, 0));


[Link](new [Link](255, 255, 255));
[Link]("DeletePayment Detail");
[Link]([Link]);
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnDeleteActionPerformed(evt);
}
});

[Link](new [Link](255, 153, 0));


[Link](new [Link]("Tahoma", 1, 10)); // NOI18N
[Link]("OK");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
jButton1ActionPerformed(evt);
}
});

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(jScrollPane1, [Link].DEFAULT_SIZE, 824, Short.MAX_VALUE)
.addGroup([Link]()
.addComponent(btnAddPay)
.addPreferredGap([Link])
.addComponent(btnDelete, [Link].PREFERRED_SIZE, 149,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, [Link].PREFERRED_SIZE, 79,
[Link].PREFERRED_SIZE))
.addGroup([Link], [Link]()

125
HND in Computing & Programming in
System Development Java
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap([Link])
.addComponent(txtPaycode, [Link].PREFERRED_SIZE, 105,
[Link].PREFERRED_SIZE)))
.addContainerGap())
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap(18, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(txtPaycode, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, [Link].PREFERRED_SIZE, 195,
[Link].PREFERRED_SIZE)
.addGap(26, 26, 26)
.addGroup([Link]([Link])
.addGroup([Link]([Link])
.addComponent(btnAddPay, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE)
.addComponent(btnDelete, [Link].PREFERRED_SIZE, 30,
[Link].PREFERRED_SIZE))
.addComponent(jButton1, [Link].PREFERRED_SIZE, 31,
[Link].PREFERRED_SIZE))
.addGap(21, 21, 21))
);

pack();
}// </editor-fold>
public void setUserLimitations(boolean prm){

[Link](prm);

public void findPaymentDetails() throws ClassNotFoundException, SQLException{


// connect to the sql server

[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

String SQL1 = " SELECT * FROM Student_Details WHERE Student_ID LIKE" + "'%"+ [Link]()
+"%'";
Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls = [Link](SQL1);

126
HND in Computing & Programming in
System Development Java

[Link]();

while([Link]())
{
[Link](new Object[]{
[Link](1),
[Link](2),
[Link](3),
[Link](4),
}
);
}

}
//--------refresh the table-----------
public void refreshTable(){
while ([Link]() > 0) {
[Link](0);
}
}
// Delete payment details-------------------

public void deletePaymentDetail(String selRow) throws ClassNotFoundException, SQLException


{
// connect to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected ");

Statement statement = [Link]();


[Link]("DELETE FROM Payment_Details WHERE Payment_code='" + selRow + "'");

private void btnAddPayActionPerformed([Link] evt) {


// TODO add your handling code here:

Addpay addpa = new Addpay ();


[Link](true);
[Link](false);
[Link](null);

private void txtPaycodeActionPerformed([Link] evt) {


// TODO add your handling code here:

try{
if ([Link]().equals("")){

127
HND in Computing & Programming in
System Development Java
//txtStudentID empty
[Link](null, "The Payment Code Field Is Empty,Enter Payment Code And
Search", "EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else{//txtxCake not empty
[Link]();
if([Link]()==0){
[Link](this, "No Data Found", "NO DATA",
JOptionPane.ERROR_MESSAGE);
}
}

}//end try

catch (ClassNotFoundException e){


[Link](e);

}
catch (SQLException e){
[Link](null, e, "ERROR IN CONNECTION", JOptionPane.ERROR_MESSAGE);
}

private void btnDeleteActionPerformed([Link] evt) {


// TODO add your handling code here:
try{
if ([Link]() < 0 || [Link]() < 0) {
[Link](this, "Select a Record From Table To Delete","NO RECORD
SELECTED",JOptionPane.WARNING_MESSAGE);
}
else {

int respond =[Link](this, "Are You Sure You Want To Delete This?","Confirm
Deletion",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if (respond==0){
String selectedRec = (String)[Link]([Link](), 0);
[Link](selectedRec); // deleting a payment from Db
[Link]();
[Link]();
}
else{
}
}
}//end try
catch (ClassNotFoundException e){
[Link](e);
}
catch (SQLException e){
[Link](null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}

private void jButton1ActionPerformed([Link] evt) {

128
HND in Computing & Programming in
System Development Java
// TODO add your handling code here:
[Link](false);
}

/**
* @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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link],
null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link],
null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
// new frmPaymentDetails().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAddPay;
private [Link] btnDelete;
private [Link] jButton1;
private [Link] jLabel1;
private [Link] jScrollPane1;
private [Link] tblPayments;
private [Link] txtPaycode;
// End of variables declaration
}

129
HND in Computing & Programming in
System Development Java

Receive payment detail form.

Code :
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package heinstitute;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Anushka
*/

130
HND in Computing & Programming in
System Development Java
public class Addpay extends [Link] {

/**
* Creates new form Add pay
*/
DefaultTableModel model;
public Addpay() {
initComponents();
try{
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}
catch (SQLException e){
[Link](e);
}

/**
* 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() {

jPanel2 = new [Link]();


txtcridetNO = new [Link]();
jLabel6 = new [Link]();
txtCiD = new [Link]();
jLabel4 = new [Link]();
txtSiD = new [Link]();
jLabel3 = new [Link]();
txtPaycode = new [Link]();
jLabel2 = new [Link]();
jComboBox1 = new [Link]();
jLabel8 = new [Link]();
jPanel1 = new [Link]();
rbCashe = new [Link]();
rdbCcard = new [Link]();
jLabel5 = new [Link]();
jLabel7 = new [Link]();
btnAdd = new [Link]();
txtTot = new [Link]();
btnClear = new [Link]();
btnOk = new [Link]();

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);

131
HND in Computing & Programming in
System Development Java

[Link]([Link](null, "Recive Payment",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial", 1, 12), new [Link](255, 102, 0))); // NOI18N

[Link]("Credit Card Number");

[Link]("Course ID");

[Link]("Total Ammount");

[Link](new [Link]("Tahoma", 1, 11)); // NOI18N


[Link](new [Link](240, 240, 240));
[Link](new [Link](255, 0, 0));
[Link](false);

[Link]("Stuent ID");

[Link](new [Link](new String[] { "Select One......", "Sampath


Bank", "Bank of ceylone", "NSB Bank", "Hattern National Bank", "Comercial Bank" }));
[Link]("com"); // NOI18N

[Link]("Bank Name");

[Link]([Link](null, "Payment Method",


[Link].DEFAULT_JUSTIFICATION, [Link].DEFAULT_POSITION,
new [Link]("Arial", 1, 12))); // NOI18N

[Link](true);
[Link]("Cashe");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
rbCasheActionPerformed(evt);
}
});

[Link]("Credit Card");

[Link] jPanel1Layout = new [Link](jPanel1);


[Link](jPanel1Layout);
[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap()
.addComponent(rdbCcard)
.addPreferredGap([Link],
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(rbCashe)
.addContainerGap())
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()

132
HND in Computing & Programming in
System Development Java
.addGroup([Link]([Link])
.addComponent(rbCashe)
.addComponent(rdbCcard))
.addContainerGap([Link].DEFAULT_SIZE, Short.MAX_VALUE))
);

[Link]("Payment Method");

[Link]("Payment Code");

[Link]("Save");
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnAddActionPerformed(evt);
}
});

[Link]("CLEAR");
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnClearActionPerformed(evt);
}
});

[Link]("Ok");
[Link]([Link]);
[Link](new [Link](70, 33));
[Link](new [Link]() {
public void actionPerformed([Link] evt) {
btnOkActionPerformed(evt);
}
});

[Link] jPanel2Layout = new [Link](jPanel2);


[Link](jPanel2Layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(jLabel8)
.addPreferredGap([Link])
.addComponent(jComboBox1, [Link].PREFERRED_SIZE, 139,
[Link].PREFERRED_SIZE))
.addGroup([Link]()
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 82,
[Link].PREFERRED_SIZE)
.addGap(18, 18, 18)

133
HND in Computing & Programming in
System Development Java
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addGroup([Link]()
.addGroup([Link]([Link])
.addGroup([Link]([Link],
false)
.addComponent(jLabel7, [Link].PREFERRED_SIZE, 81,
[Link].PREFERRED_SIZE)
.addComponent(jLabel5))
.addComponent(jLabel6, [Link]))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtcridetNO, [Link].PREFERRED_SIZE, 139,
[Link].PREFERRED_SIZE)
.addComponent(txtPaycode, [Link].PREFERRED_SIZE, 88,
[Link].PREFERRED_SIZE)
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)))
.addGroup([Link]()
.addGroup([Link]([Link])
.addComponent(jLabel3)
.addComponent(jLabel4, [Link].PREFERRED_SIZE, 66,
[Link].PREFERRED_SIZE)
.addComponent(jLabel2, [Link].PREFERRED_SIZE, 66,
[Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(txtSiD, [Link].PREFERRED_SIZE, 80,
[Link].PREFERRED_SIZE)
.addComponent(txtCiD, [Link].PREFERRED_SIZE, 80,
[Link].PREFERRED_SIZE)
.addComponent(txtTot, [Link],
[Link].PREFERRED_SIZE, 138, [Link].PREFERRED_SIZE))))
.addContainerGap(66, Short.MAX_VALUE))
);

[Link]([Link], new [Link][] {jLabel2,


jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8});

[Link](
[Link]([Link])
.addGroup([Link]()
.addGap(31, 31, 31)
.addGroup([Link]([Link])
.addComponent(txtPaycode, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addGroup([Link]()
.addComponent(jPanel1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addPreferredGap([Link])
.addGroup([Link]([Link])

134
HND in Computing & Programming in
System Development Java
.addComponent(txtcridetNO, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(jLabel6, [Link].PREFERRED_SIZE, 20,
[Link].PREFERRED_SIZE)))
.addComponent(jLabel5))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel8, [Link].PREFERRED_SIZE, 20,
[Link].PREFERRED_SIZE)
.addComponent(jComboBox1, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel3, [Link].PREFERRED_SIZE, 20,
[Link].PREFERRED_SIZE)
.addComponent(txtTot, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel2)
.addComponent(txtSiD, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link])
.addGroup([Link]([Link])
.addComponent(jLabel4)
.addComponent(txtCiD, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE))
.addPreferredGap([Link], 31, Short.MAX_VALUE)
.addGroup([Link]([Link])
.addComponent(btnOk, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(btnClear, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addComponent(btnAdd, [Link].PREFERRED_SIZE, 33,
[Link].PREFERRED_SIZE))
.addGap(24, 24, 24))
);

[Link]().setAccessibleName("Payment method");

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(jPanel2, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addContainerGap(27, Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link], [Link]()
.addContainerGap(24, Short.MAX_VALUE)

135
HND in Computing & Programming in
System Development Java
.addComponent(jPanel2, [Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE, [Link].PREFERRED_SIZE)
.addContainerGap())
);

pack();
}// </editor-fold>
public void generateID()throws ClassNotFoundException, SQLException{
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("The database is Connected "); // connection ok

String sql="SELECT * FROM Payment_Details ORDER BY Payment_code ASC;";


Statement stmt2 = [Link](ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = [Link](sql);
int id;
if(![Link]()){
id=1;
[Link]([Link](id));
}
else{
[Link]();
id=[Link]([Link](1));
[Link]([Link](id+1));
}

}// end of generateID

public void clearAll(){

[Link]("");
[Link]("");
[Link]("");
[Link]("");

}
public void add_payment() throws ClassNotFoundException, SQLException{
// connection to the sql server
[Link]("[Link]");
String connectionUrl = "jdbc:sqlserver://Anushka-
PC\\SQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = [Link](connectionUrl);
[Link]("Successfuly Connected to MS SQL 2005 using windows authentication 1"); // connection ok
Statement statement = [Link]();
if([Link]().equals("")){
[Link](null, "The Total Amount Field Is Empty,Enter Total Amount", "EMPTY
FIELD", JOptionPane.ERROR_MESSAGE);
}
else{

136
HND in Computing & Programming in
System Development Java
if([Link]()==true){
[Link]("INSERT INTO Payment_Details VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + ","+
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + ")" +" ");

[Link](null, "Record are saved in the database", "INSERT SUCCESSFUL",


JOptionPane.INFORMATION_MESSAGE);
}
else if([Link]()==true){

[Link]("INSERT INTO Payment_Details VALUES " +"( '" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + ","+
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + "," +
"'" + [Link]() + "'" + ","+
"'" + [Link]() + "'" + ","+
"'" + [Link]()+ "'" + " )" +" ");

}
else{
}

}
}
public boolean getPayMethod(){
if([Link]()==true){
return false;
}
else if([Link]()==true){
return true;
}
else{
return false;
}
}

private void btnAddActionPerformed([Link] evt) {


// TODO add your handling code here:
try{

this.add_payment();//add new Payment to database


[Link]();
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](this, e, "ERROR", JOptionPane.ERROR_MESSAGE);

137
HND in Computing & Programming in
System Development Java
}
}

private void btnOkActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link](false);
}

private void btnClearActionPerformed([Link] evt) {


// TODO add your handling code here:
[Link]();
}

private void rbCasheActionPerformed([Link] evt) {


// 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 [Link]
*/
try {
for ([Link] info : [Link]()) {
if ("Nimbus".equals([Link]())) {
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch (InstantiationException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch (IllegalAccessException ex) {
[Link]([Link]()).log([Link], null, ex);
} catch ([Link] ex) {
[Link]([Link]()).log([Link], null, ex);
}
//</editor-fold>

/* Create and display the form */


[Link](new Runnable() {
public void run() {
new Addpay().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btnAdd;

138
HND in Computing & Programming in
System Development Java
private [Link] btnClear;
private [Link] btnOk;
private [Link] jComboBox1;
private [Link] jLabel2;
private [Link] jLabel3;
private [Link] jLabel4;
private [Link] jLabel5;
private [Link] jLabel6;
private [Link] jLabel7;
private [Link] jLabel8;
private [Link] jPanel1;
private [Link] jPanel2;
private [Link] rbCashe;
private [Link] rdbCcard;
private [Link] txtCiD;
private [Link] txtPaycode;
private [Link] txtSiD;
private [Link] txtTot;
private [Link] txtcridetNO;
// End of variables declaration
}

139
HND in Computing & Programming in
System Development Java

4.2. Provide evidence and solutions for error handling during software
implementation.

In Software programming, a development error is one that can be prevented. Such an


error can occur in syntax or logic.

 Syntax errors, which are typographical mistakes or improper use of special


characters, are handled by rigorous proofreading.
 Logic errors, also called bugs, occur when executed code does not produce the
expected or desired result. Logic errors are best handled by meticulous program
debugging.

This can be an ongoing process that involves, in addition to the traditional debugging
routine, beta testing prior to official release and customer feedback after official release.

There are several techniques that I used to handle above mentioned errors. Those are
given below.

Use “Try catch” method

A try statement is used to catcha exceptions thata mighta be thrown as program


a a a a a

executes . Should use a try statement wherever use a statement that might throw an
a a

exception that way, program won‟t crash if the exception occurs. This is the code of this
method. I used this method in my all application forms.

try{

this.add_payment();//add new Payment to database


[Link]();
[Link]();
}//end try

catch (ClassNotFoundException e){


[Link](e);
}

catch (SQLException e){


[Link](this, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}

140
HND in Computing & Programming in
System Development Java

Validate text fields

This is the second method that I used to handle errors. If any user will press a button
without filling the required data it will show the error message As the following picture.

private void btnAddActionPerformed([Link] evt) {

if([Link]().equals("")){ [Link](null, "The Student


name Field Is Empty,Enter the Student name Name", "EMPTY FIELD",
JOptionPane.ERROR_MESSAGE);

}else if { ……..

141
HND in Computing & Programming in
System Development Java

Enable/ Disable buttons.

This is the third method that I used to handle the errors. In here I disable some buttons
when window [Link] an example in student details interface the delete student detail
button is disabled because this User haven‟t permission to use it.

public void setUserLimitations(boolean prm) {


[Link](prm);

142
HND in Computing & Programming in
System Development Java

Task 05
5.1. Carry out complete system testing and provide user guide. System testing
and user guide must include suitable screen shots. Test your complete
project with suitable data.

First I‟m tried to login to the system by using default User Name and password ( user
Name=Admin password=admin)

Then it continued to the main Interface.

143
HND in Computing & Programming in
System Development Java

Then I‟m tried to create personal account to an user , to create new account first click
on the Configuration in the menu bar and expand it. After that click on the Create
new User

So it continued to an interface as the following picture.(I early day created some user
accounts so the User ID is Start With the number 4)

Blanks

144
HND in Computing & Programming in
System Development Java

I filled the blanks that what they need to know about the new user in above form and I
clicked on Save button.

If filled data is correct, it will show a message as the following picture. then I clicked on
the ok button

To return to the Main interface I click on the ok button in the Add user details form.

145
HND in Computing & Programming in
System Development Java

As the final of Adding new User I tried to login to the system by using the new
Account(user Name = Rajapaksha, Password = 11 ).

Then it continued to the Main interface. to View the Course details Interface I clicked on
the Course details button ( I used an Administrator Account to use the all the
functions).

146
HND in Computing & Programming in
System Development Java

As my need it continued to the Course details Interface

To Add a new Course detail i clicked on Add New Course details button then it
showed the Add new Course interface as the following picture.

Blanks

147
HND in Computing & Programming in
System Development Java

So I Filled the blanks and I clicked on save button

Then it showed the following message after that I clicked on ok button.

Finally return to the Course details interface I clicked on ok button in the Add new
course interface then it return to the Course details interface….

148
HND in Computing & Programming in
System Development Java

To Edit a Course detail, i entered a course id on the text box and pressed enter
[Link] the final I was selected that Course id from the table and clicked on
Edit Course details button .

Text Box

Edit Course details button

Course details Table

149
HND in Computing & Programming in
System Development Java

then it showed the Edit Course interface as the following picture….

I done some modifications to the information.(as a modification I changed the course


fee to $200)

150
HND in Computing & Programming in
System Development Java

As the final I clicked on Update button .after that it showed the following message then
I clicked on yes button.

For return to the Course details Interface I clicked on Ok button in the Edit course
details interface.

151
HND in Computing & Programming in
System Development Java

Then it was returned to Course Details [Link] return from this interface to the
Main interface I clicked on the ok button ….

Then it was returned to the Main interface. To view Batch details interface I clicked on
the Batch details Button.

152
HND in Computing & Programming in
System Development Java

Then it was continued to the batch details Interface.

So first I tried to add a batch [Link] view Add batch interface I was clicked on Add
batch button.

Then it was showed the Add batch Interface.

Blanks

153
HND in Computing & Programming in
System Development Java

So I was filled the blanks and I clicked on ok button

It was showed the following message. then i clicked on ok button in the message

154
HND in Computing & Programming in
System Development Java

For return to the Batch details I clicked on the ok button in the Add New Batch
Interface.

Then it returned to the Batch details interface. To edit a batch detail I was Entered a
batch id on the text box and I pressed enter button then the detail was showed on
the table finally I was selected that record and clicked on the Edit batch detail button.

155
HND in Computing & Programming in
System Development Java

then it was viewed the Edit Batch detail Form with the Batch information….

In the above interface I had done a modification to the information (as a modification I
was changed the Number of students up to 70 ) then I clicked on Update button.

156
HND in Computing & Programming in
System Development Java

Finally it was showed a message as below. Then I clicked on yes button.

Then the record was updated.

To return from the Edit batch details interface to the Batch details interface I was clicked
on the ok button.

157
HND in Computing & Programming in
System Development Java

Finally it returned to the Batch details Interface .to return to the Main interface I was
clicked on the Ok button under the Batch details interface…

After that it was returned …

To view the Student details I was clicked on the Student details button.

158
HND in Computing & Programming in
System Development Java

Then it continued to Student details Interface.

To Add a new student detail i clicked on Add New student details button then it
showed the Add new student interface as the following picture.

Blanks

159
HND in Computing & Programming in
System Development Java

So I Filled that Blanks and I clicked on Save button .

To confirm it showed a message as below then i clicked on OK button.

To return to the student details interface I clicked on ok button in the Add new student
interface .then it was returned…

160
HND in Computing & Programming in
System Development Java

To view edit student detail interface first I was entered a user ID on the text box and
pressed the enter [Link] the second step I was selected that user id from the table
and clicked on Edit Student Details button.

Then it was viewed as below …

161
HND in Computing & Programming in
System Development Java

As a modification I was changed telephone number to 0774455754… then I clicked on


Update button

Finally it showed a message as below ,then I was clicked on Yes button.

162
HND in Computing & Programming in
System Development Java

To return to the Student details interface I was clicked on ok button in the Edit
student details interface.

Then it returned to the Student detail [Link] return from this to the Min interface I
was clicked on ok button.

163
HND in Computing & Programming in
System Development Java

Then it was return to the Main [Link] View the payment detail interface I was
clicked on the payment details button in the Main interface..

Then it was continued to the Payment details form.

164
HND in Computing & Programming in
System Development Java

To receive a payment I was clicked on Receive payment button. Then It was showed
the following form

I was filled that form and I clicked on Save button then it was showed the following
message then I was clicked on the ok button .

 According to customer requirements the above interfaces are I had implemented


to the new [Link] one by one i was tested in this software and there is no any
errors.

165
HND in Computing & Programming in
System Development Java

5.2. Produce suitable screenshots and solutions for error handling during testing.

 When creating new user account

When creating a new account customer must enter the valid data to the system. If
Customer didn‟t enter the correct data there will some Error messages.

If User click Save button without fills the data, it will show a message as the following
picture.

166
HND in Computing & Programming in
System Development Java

When Login to system

When log in to the system the user must enter their correct user name and password.
Otherwise there will be an error message as following picture. For this User should
enter the correct user name and password.

167
HND in Computing & Programming in
System Development Java

When Updating a Student detail…

When updating a student detail the user must confirm it. Else it wont to be update.

168
HND in Computing & Programming in
System Development Java

5.3. Include feedbacks on provided java solution (surveys, questionnaire, analyze


feedback and present results), evaluate all and provide summery report

Questionnaire for Administrator.


1) As an administrator what do you thinking about the new Software?
 Excellent
 Very good
 Good
 Poor
2) Is this system easy to Handel?
 Yes
 No
 May be
 No idea
3) Are you satisfied with the new System?
 Satisfied
 Fairly Satisfied
 Dissatisfied
4) What accept were you mostly satisfied?
 When entering a new student
 When make a payment
 When adding a course detail
 When adding a batch detail
 No idea

169
HND in Computing & Programming in
System Development Java

5) What you accept were you mostly dissatisfied?


 When entering a new student
 When make a payment
 When adding a course detail
 When adding a batch detail
 When deleting the student details
 No idea
6) Do you have any comments ?

This software is easy to understand any one when it operate first time.
There is a little issue when back to previous interface by using close button. But in
this software it approaches to a new method to prevent the above problem by giving
the close command to ok button. That is good and deviation from other softwares.
When we‟re doing payments, this software gives us better help to increase accuracy
of that step.
This software is easy to handle and anyone can get an idea by operate this once.
because of that, this software is really successful and good solution to the given
problem.

170
HND in Computing & Programming in
System Development Java

Questionnaire For Staff Members

2) As a Staff member what do you thinking about the new Software?


 Excellent
 Very good
 Good
 Poor
7) Is this system easy to Handel?
 Yes
 No
 May be
 No idea
8) Are you satisfied with the new System?
 Satisfied
 Fairly Satisfied
 Dissatisfied
9) What accept were you mostly satisfied?
 When entering a new student
 When make a payment
 When adding a course detail
 When adding a batch detail
 No idea

171
HND in Computing & Programming in
System Development Java

10) What you accept were you mostly dissatisfied?


 When entering a new student
 When make a payment
 When adding a course detail
 When adding a batch detail
 When deleting students details
 No idea

11) Do you have any comments ?

This software gives some benefits to staff members as well as administrators.


Because staff members also allowed to keep user accounts to their own. This
benefit is useful to decrease errors when operate the software by difference users.

Summary Report of the User feedback


How many customers are satisfied with about the system : 05

How many customers are dis-satisfied about the system : 03

How many customers said the system is difficult to handle : 02

How many customers said the system is easy to handle : 03

How many customers said „No idea‟ about the system : 03

*According to above feedback many Users are satisfied with the system*

Required Improvements

 So according above answers to the above Questionnaires, the followings are the
some required improvements to the software.
 IF the User wants to delete a specific record about the student from the
database then it can be achieve without using many interfaces.
 The program won‟t to be fully terminate by Clicking on the close button.
 A profile picture can be added to the user profile.

172
HND in Computing & Programming in
System Development Java

Task 06
6.1. Produce a publishable working copy a compiled version of the completed
assignment together with software installation notes, recommendations and
future improvements. The installation note should include the system
requirements

Software Installation

 System requirements for the software installation

Hardware requirements

PIV or Higher Computer 1.6GHz or faster processor 40GB Hard disk Minimum 512 MB RAM
Free Disk Space 11 MB

Software Requirements

Any kind of an Operating system form this : Windows XP/ Windows 8 (Desktop) / Windows 7/
Windows Vista SP2/ Mac OS/ Oracle Linux 5.5+/ Ubuntu Linux* 10.04 and above. Java
Platform, Standard Edition Development Kit (Java SE 6 Update 27).

Installation Note

 Double click on the He institute Folder

 Then it will show an icon and a folder. click on the folder.

173
HND in Computing & Programming in
System Development Java

 An user can see the following setup file then double click on it

 After that the installation will start as the following picture. Then click Next button
to go to the next step.

174
HND in Computing & Programming in
System Development Java

 In here ,Click on next button…

 Select the installation Path and click on next button

175
HND in Computing & Programming in
System Development Java

 In here Click on Start button

 After that the software will be installing. When it complete can see the below
window. Then simply click Next button and then click finish.

176
HND in Computing & Programming in
System Development Java

 Finally click on the Exit button…

 After completing those things the user must restore the Database to the system. then the
user must follow the following steps.
1. Double click on the He institute folder.

177
HND in Computing & Programming in
System Development Java

2. Then Copy the database backup folder to the system.

3. After that double click on the SQL server management studio Express…

178
HND in Computing & Programming in
System Development Java

4. Then it will continue to the following interface. Then click on the Connect button.

179
HND in Computing & Programming in
System Development Java

5. So it will continue ... then right click on the database tab and click on Restore
database as the following picture.

180
HND in Computing & Programming in
System Development Java

6. Then it will show an interface as below.. then type the name of a new database
as mention in the following picture and specify the source and location of backup
sets to restore.

Database
Name

Click on
here

181
HND in Computing & Programming in
System Development Java

7. When click on as it mention in the above picture then it will show a interface as
below. Then click on Add button.

182
HND in Computing & Programming in
System Development Java

8. Then give the path as below. And click ok

183
HND in Computing & Programming in
System Development Java

9. After that you can see the following specify backup interface as below. Click on
ok button.

184
HND in Computing & Programming in
System Development Java

10. Finally it will return to the following Interface then Select the backup sets to
restore as below picture and click on ok button.

To start the software click on the icon as the following picture.

185
HND in Computing & Programming in
System Development Java

Reference Sheet
[Link]

[Link]

[Link]

[Link]

[Link]

[Link]

[Link]

[Link]

186

You might also like