Here are the key steps to implement the Student Information System using Java:
1. Create classes for each entity (Student, Course, Batch, etc.) with appropriate attributes and methods.
2. Create a Database class to connect to the database and perform CRUD (create, read, update, delete) operations.
3. Create GUI forms for each use case using Swing/AWT components.
4. Add action listeners to buttons to call relevant methods on form submit/update. For example, on student add button click - call method to insert data into database.
5. Write methods in respective classes to encapsulate database operations. For example, a save() method in Student class to insert student data into
Language in leadership and management: ACE School Management and Leadership (...Saide OER Africa
This module serves a dual purpose. On the one hand it is aimed at developing the reading, writing, speaking and listening skills you need to successfully work your way through all the modules included in this ACE programme. On the other hand the module is aimed at providing you with the ability to use language as a management and leadership tool, specifically in the area of policy development and implementation.
As a Search Quality Rater, you will work on many different types of rating projects. These guidelines cover just one type of search quality rating – URL rating.
Please take the time to carefully read through these guidelines. The ideas presented here are important for other types of rating. When you can do URL rating, you will be well on your way to becoming a successful Search Quality Rater!
Webspam is the term for webpages that are designed by webmasters to trick search engines and direct traffic to their websites. We sometimes refer to webmasters who use deceptive techniques as “spammers”.
Language in leadership and management: ACE School Management and Leadership (...Saide OER Africa
This module serves a dual purpose. On the one hand it is aimed at developing the reading, writing, speaking and listening skills you need to successfully work your way through all the modules included in this ACE programme. On the other hand the module is aimed at providing you with the ability to use language as a management and leadership tool, specifically in the area of policy development and implementation.
As a Search Quality Rater, you will work on many different types of rating projects. These guidelines cover just one type of search quality rating – URL rating.
Please take the time to carefully read through these guidelines. The ideas presented here are important for other types of rating. When you can do URL rating, you will be well on your way to becoming a successful Search Quality Rater!
Webspam is the term for webpages that are designed by webmasters to trick search engines and direct traffic to their websites. We sometimes refer to webmasters who use deceptive techniques as “spammers”.
The Tellurium Automated Testing Framework (Tellurium) is a UI module-based automated testing framework for web applications and it is robust, expressive, flexible, and reusable. This is Tellurium 0.6.0 User Guide.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Why React Native as a Strategic Advantage for Startup Innovation.pdfayushiqss
Do you know that React Native is being increasingly adopted by startups as well as big companies in the mobile app development industry? Big names like Facebook, Instagram, and Pinterest have already integrated this robust open-source framework.
In fact, according to a report by Statista, the number of React Native developers has been steadily increasing over the years, reaching an estimated 1.9 million by the end of 2024. This means that the demand for this framework in the job market has been growing making it a valuable skill.
But what makes React Native so popular for mobile application development? It offers excellent cross-platform capabilities among other benefits. This way, with React Native, developers can write code once and run it on both iOS and Android devices thus saving time and resources leading to shorter development cycles hence faster time-to-market for your app.
Let’s take the example of a startup, which wanted to release their app on both iOS and Android at once. Through the use of React Native they managed to create an app and bring it into the market within a very short period. This helped them gain an advantage over their competitors because they had access to a large user base who were able to generate revenue quickly for them.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
1. HND in Computing & Programming in
System Development Java
1
Contents
Task1.....................................................................................................................................................................................................3
1.1. Briefly explain the principles, characteristics features and in Java programming. ....................................................................3
1.2 Explain environmental flexibility of programming in Java programming and evaluate your answer........................................5
Task 02..................................................................................................................................................................................................6
2.1. Design a database with necessary tables....................................................................................................................................6
Normalization....................................................................................................................................................................................6
2.2 Set up the database structure by using suitable RDBMS............................................................................................................9
2.2 b) Populatethe database with suitable test data........................................................................................................................13
Task 03................................................................................................................................................................................................16
3.1. The designs of all the required algorithms are required as part of this task. You can use suitable design techniques ............16
Activity diagram for student registration in Propose System......................................................................................................17
Activity Diagram For record the Payment details in Propose System........................................................................................18
Flow chart for check the validity of users to usethe data in the propose program.....................................................................19
Use case diagram for proposed system .......................................................................................................................................20
3.2. Design necessary user interfaces Login Form..........................................................................................................................21
Main Form..................................................................................................................................................................................21
Student Details form....................................................................................................................................................................22
Add New Student Details Form ..................................................................................................................................................22
Edit Student Details Form...........................................................................................................................................................23
Course Details Form....................................................................................................................................................................23
Add New course Details form.....................................................................................................................................................24
Edit course details Form..............................................................................................................................................................24
Batch Details Form......................................................................................................................................................................25
Add New Batch Details Form.....................................................................................................................................................25
Edit Batch Details........................................................................................................................................................................26
Create New User Account Form.................................................................................................................................................26
Edit User Account .......................................................................................................................................................................27
Payment Details Form.................................................................................................................................................................27
Receive Payments Form..............................................................................................................................................................28
Task 04................................................................................................................................................................................................29
4.1. Using java programming language, implement the Student information system for the HE Institute designed in Task 03. ..29
Login Form......................................................................................................................................................................................29
Main Form.......................................................................................................................................................................................36
Edit Student Details Form ...........................................................................................................................................................69
Course Details Form........................................................................................................................................................................79
Add Course detail Form ..................................................................................................................................................................91
Edit Course Details Form.............................................................................................................................................................102
4.2. Provide evidence and solutions for error handling during software implementation. ..........................................................191
2. HND in Computing & Programming in
System Development Java
2
Use “Try catch” method...........................................................................................................................................................191
Validate text fields....................................................................................................................................................................192
Task 5...............................................................................................................................................................................................194
5.1. Carry out complete systemtestingand provide user guide. Systemtesting and user guide must include suitable screen shots.
Test your complete project with suitable data. ............................................................................................................................194
Name=Admin password=admin) .................................................................................................................................................194
5.2. Produce suitable screenshots and solutions for error handling during testing. .....................................................................217
When creating new user account..............................................................................................................................................217
When Login to system..................................................................................................................................................................218
When Updating a Student detail…...............................................................................................................................................219
5.3. Include feedbacks on provided java solution (surveys, questionnaire, analyzefeedback and present results), evaluate all and
provide summery report...............................................................................................................................................................220
Required Improvements ...............................................................................................................................................................222
Task 06.............................................................................................................................................................................................223
6.1. Produce a publishable working copy a compiled version of thecompleted assignment together with softwareinstallation
notes, recommendations and future improvements. The installation note should include the system requirements ..................223
Hardware requirements ................................................................................................................................................................223
Software Requirements ................................................................................................................................................................223
Installation Note.......................................................................................................................................................................223
Select the installation Path and click on next button...............................................................................................................226
3. HND in Computing & Programming in
System Development Java
3
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 language.so 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 portable.so 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.
4. HND in Computing & Programming in
System Development Java
4
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 network.java 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.
5. HND in Computing & Programming in
System Development Java
5
1.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.
6. HND in Computing & Programming in
System Development Java
6
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 }
7. HND in Computing & Programming in
System Development Java
7
Student_Course{ Student ID , Course ID }
Student_Batch{ Student ID , Batch ID }
Student_Staff{{ Student ID , Staff ID }
9. HND in Computing & Programming in
System Development Java
9
2.2 Set up the database structure by using suitable RDBMS.
10. HND in Computing & Programming in
System Development Java
10
Table –Staff
Figure 1
Table_student
Figure 2
Table- student_Staff
Figure 3
-
11. HND in Computing & Programming in
System Development Java
11
Table-Batch
Figure 4
Table-Student_Batch
Figure 5
Table-Course
Figure 6
12. HND in Computing & Programming in
System Development Java
12
Table – Student_Course
Figure 7
Table- Payment
Figure 8
13. HND in Computing & Programming in
System Development Java
13
2.2 b) Populate the database with suitable test data.
Table-Staff
Figure 9
Table -Student
Figure 10
14. HND in Computing & Programming in
System Development Java
14
Table- Student_Staff
Figure 11
Table-Batch
Figure 12
Table-Student_Batch
Figure 13
15. HND in Computing & Programming in
System Development Java
15
Table-Course
Figure 14
Table – Student_Course
Figure 15
Table- Payment
Figure 16
16. HND in Computing & Programming in
System Development Java
16
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
=
Student
Student_ID
Student_Name
Age
Telephone_no
Payments
Payment_code
Payment_Method
Total Amount
Course
Course_ID
Course_Name
Duration
Course_Fee
Staff
Staff ID
Staff Name
User Name
Password
Account type
*
1 *
1
1
Batch
Batch_ID
Start_date
End Date
number_Of_Student
Course_ID
*
*
*
1*
*
*
17. HND in Computing & Programming in
System Development Java
17
Activity diagram for student registration in Propose System
Input: Course Details
Student Details
Batch Details
Select a Student
If student Want
to Follow a new
Course
Select a Course
If student want to
follow the
selected course
student
Assign to a Batch
True
False
True
False
18. HND in Computing & Programming in
System Development Java
18
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
pay a premium of
the course
Select a Payment Method
Receive the payments
Record the payment detail
True
False
19. HND in Computing & Programming in
System Development Java
19
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
person is
an Admin
Check the person is a staff member
Give the full permission to use the
data in the program
If the
person is
a staff
Stop
Give the limited permission to use
the data in the program
True
False
True
False
Provide an error Message
20. HND in Computing & Programming in
System Development Java
20
Use case diagram for proposed system
Add Studentdetails
EditStudentdetails
Delete Student Details
Add Course Details
EditCourse details
Face to the Assignmentsand
Exams
Admin
Students
Attend to the classes
Delete Course Details
Add Batch details
Select courses
Do payments
Edit Batch details
Add Payment Details
Staff
Edit Payment Details
Delete Payment Details
Provide student Informations
21. HND in Computing & Programming in
System Development Java
21
3.2. Design necessary user interfaces Login Form
Figure 17
Main Form
Figure 18
22. HND in Computing & Programming in
System Development Java
22
Student Details form
Figure 19
Add New Student Details Form
Figure 20
23. HND in Computing & Programming in
System Development Java
23
Edit Student Details Form
Figure 21
Course Details Form
Figure 22
24. HND in Computing & Programming in
System Development Java
24
Add New course Details form
Figure 23
Edit course details Form
Figure 24
25. HND in Computing & Programming in
System Development Java
25
Batch Details Form
Figure 25
Add New Batch Details Form
Figure 26
26. HND in Computing & Programming in
System Development Java
26
Edit Batch Details
Figure 27
Create New User Account Form
Figure 28
27. HND in Computing & Programming in
System Development Java
27
Edit User Account
Figure 29
Payment Details Form
Figure 30
28. HND in Computing & Programming in
System Development Java
28
Receive Payments Form
Figure 31
29. HND in Computing & Programming in
System Development Java
29
Task 04
4.1. Using java programming language, implement the Student information system
for the HE Institute designed in Task 03.
Login Form
Figure 32
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 javax.swing.JOptionPane;
import
java.sql.Connection;
import
java.sql.DriverManager;
import
java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.swing.UIManager;
/**
*
30. HND in Computing & Programming in
System Development Java
30
* @author Anushka
*/
public class Login extends javax.swing.JFrame {
/**
* Creates new form Login
*/
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
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("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 = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery(SQL);
return rs.first(); //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
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
31. HND in Computing & Programming in
System Development Java
31
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("Successfuly Connected "); // connection ok
// Get staff name
String SQL = "SELECT * FROM Staff WHERE User_name='"+user+"'AND
Password='"+pass+"'";
Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery(SQL);
rs.first();
staffname= rs.getString(2);
privileges=rs.getBoolean(5);
staffid=rs.getInt(1);
} // end con method
public void displayMain(){
//display main interface
Main main = new
Main(staffname,privileges,staffid);
main.setVisible(true);
main.setLocationRelativeTo(null);
main.setResizable(false);
}// end displayMain
public void loginToSystem()throws ClassNotFoundException, SQLException {
String username=txtUser.getText();
String password=txtPass.getText();
if (this.checkLogin(username,password)==true){
this.getStaffName_privileges(username,password);
this.displayMain();
this.setVisible(false);
}//end if
else if(this.checkLogin(username,password)==false){
32. HND in Computing & Programming in
System Development Java
32
JOptionPane.showMessageDialog(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
javax.swing.JPasswordField();
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
txtUser = new javax.swing.JTextField();
btnlogin = new javax.swing.JButton();
btnExit = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
txtPass.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
txtPassActionPerformed(evt);
}
});
jLabel2.setText("Pasword :");
jLabel1.setText("User Name :");
btnlogin.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/heinstitute/login.png"))); // NOI18N
btnlogin.setText("LOGIN"); btnlogin.addActionListener(new
33. HND in Computing & Programming in
System Development Java
33
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnloginActionPerformed(evt);
}
});
btnlogin.addKeyListener(new
java.awt.event.KeyAdapter() { public void
keyPressed(java.awt.event.KeyEvent evt) {
btnloginKeyPressed(evt);
}
});
btnExit.setText("Exit");
btnExit.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnExitActionPerformed(evt);
}
});
jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/heinstitute/1397005153_Refresh_key.png"))); //
NOI18N jLabel3.setText("jLabel3");
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(txtPass, javax.swing.GroupLayout.DEFAULT_SIZE, 147,
Short.MAX_VALUE) .addComponent(txtUser)))
.addComponent(btnlogin, javax.swing.GroupLayout.PREFERRED_SIZE, 90,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
35. HND in Computing & Programming in
System Development Java
35
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
catch (SQLException e){
System.out.println(e);
}
}
private void btnloginKeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
}
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: int result
=JOptionPane.showConfirmDialog(null, "Do you Want To Exit ?", "Exit",
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_ME
SSAGE); if(result==0){ System.exit(0);
}
else if(result==1){
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable()
{ public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnExit;
private javax.swing.JButton btnlogin;
private javax.swing.JLabel jLabel1;
36. HND in Computing & Programming in
System Development Java
36
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPasswordField
txtPass; private javax.swing.JTextField
txtUser;
// End of variables declaration
}
Main Form
Figure 33
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
java.awt.Frame; import
java.sql.Connection;
import
java.sql.DriverManager;
37. HND in Computing & Programming in
System Development Java
37
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import
javax.swing.JFrame;
import
javax.swing.JOptionPane;
import
javax.swing.UIManager;
/**
*
* @author Anushka
*/
public class Main extends javax.swing.JFrame {
/**
* Creates new form Main
*/
private boolean privileges;
private int staffid;
private String
S_name;
public Main(String staffname,boolean p,int id) {
initComponents();
lblStaffName.setText(staffname.toUpperCase());
this.setUserLimitations(p);
staffid=id; // set Staff id
S_name=staffname;
}
public void setUserLimitations(boolean prm){
privileges=prm;
menuAddUsers.setEnabled(prm);
}
/**
* This method is called from within the constructor to
initialize the form. * WARNING: Do NOT modify this code.
38. HND in Computing & Programming in
System Development Java
38
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
javax.swing.JButton(); lblStaffName2
= new javax.swing.JLabel(); btnStudent
= new javax.swing.JButton();
lblStaffName3 = new javax.swing.JLabel();
btnCourse1 = new javax.swing.JButton();
lblStaffName4 = new javax.swing.JLabel();
lblStaffName1 = new javax.swing.JLabel();
lblStaffName = new javax.swing.JLabel();
btnCourse2 = new javax.swing.JButton();
lblStaffName5 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu3 = new javax.swing.JMenu();
menuAddUsers = new
javax.swing.JMenuItem();
menuEditMyAcc = new
javax.swing.JMenuItem(); menulogout
= new javax.swing.JMenu(); jMenu2 =
new javax.swing.JMenu(); jMenuItem1
= new javax.swing.JMenuItem();
jMenuItem2 = new
javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnCourse.setBackground(new java.awt.Color(0, 0, 0));
btnCourse.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/heinstitute/1397062581_Courses.png"))); //
NOI18N
btnCourse.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnCourseActionPerformed(evt);
}
});
44. HND in Computing & Programming in
System Development Java
44
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[]
{btnCourse, btnStudent});
pack();
}// </editor-fold>
private void
menuAddUsersActionPerformed(java.awt.event.ActionEvent evt)
{ // TODO add your handling
code here: AddUser adduser = new AddUser();
adduser.setLocationRelativeTo(null);
adduser.setResizable(false); adduser.setVisible(true);
}
private void menuEditMyAccActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
EditMyUserAcc editmyacc = new EditMyUserAcc(staffid);
editmyacc.setLocationRelativeTo(null);
editmyacc.setResizable(false);
editmyacc.setVisible(true);
}
private void
menulogoutMouseClicked(java.awt.event.MouseEvent evt) {
this.setVisible(false); Login log = new Login();
log.setVisible(true);
log.setLocationRelativeTo(null);
}
private void menulogoutActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
45. HND in Computing & Programming in
System Development Java
45
private void
jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt)
{ // TODO add your handling
code here: About about = new About();
about.setVisible(true);
about.setLocationRelativeTo(null);
}
private void btnStudentActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
StudentDetails sudentdetails= new
StudentDetails(privileges); sudentdetails.setVisible(true);
sudentdetails.setLocationRelativeTo(null);
sudentdetails.setResizable(false);
}
private void btnCourseActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
CourseDetails csdetails= new
CourseDetails(privileges);
csdetails.setVisible(true);
csdetails.setLocationRelativeTo(null);
csdetails.setResizable(false);
}
private void btnCourse2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
BatchDetails batch= new BatchDetails(privileges);
batch.setVisible(true);
batch.setLocationRelativeTo(null);
batch.setResizable(false);
}
/**
* @param args the command line arguments
*/
public static void main(String args[])throws ClassNotFoundException,
SQLException {
46. HND in Computing & Programming in
System Development Java
46
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception er) {
System.out.println(er.toString());
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{ public void run() {
//Main m =new Main();
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCourse;
private javax.swing.JButton btnCourse1;
private javax.swing.JButton btnCourse2;
private javax.swing.JButton btnStudent;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar
jMenuBar1; private
javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem
jMenuItem2; private
javax.swing.JLabel lblStaffName;
private javax.swing.JLabel
lblStaffName1; private
javax.swing.JLabel lblStaffName2;
private javax.swing.JLabel
lblStaffName3; private
javax.swing.JLabel lblStaffName4;
private javax.swing.JLabel
lblStaffName5; private
javax.swing.JMenuItem menuAddUsers;
private javax.swing.JMenuItem
menuEditMyAcc; private
javax.swing.JMenu menulogout;
// End of variables declaration
}
47. HND in Computing & Programming in
System Development Java
47
Student Details form
Figure 34
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
java.sql.Connection;
import
java.sql.DriverManager;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import
javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Anushka
*/
48. HND in Computing & Programming in
System Development Java
48
public class StudentDetails extends javax.swing.JFrame {
/**
* Creates new form StudentDetails
*/
DefaultTableModel model;
public StudentDetails(boolean q) {
initComponents();
model = new DefaultTableModel();
model.addColumn("Student_ID");
model.addColumn("Student_Name");
model.addColumn("Age");
model.addColumn("Telephone_no");
tblStudent.setModel(model);
this.setUserLimitations(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 javax.swing.JButton();
jScrollPane1 = new
javax.swing.JScrollPane(); tblStudent
= new javax.swing.JTable(); btnDelete
= new javax.swing.JButton(); btnEdit =
new javax.swing.JButton();
txtStudentID = new
javax.swing.JTextField();
btnAddNewStudent = new
49. HND in Computing & Programming in
System Development Java
49
javax.swing.JButton(); jLabel1 = new
javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setBackground(new java.awt.Color(255,
153, 0)); jButton1.setFont(new
java.awt.Font("Tahoma", 1, 10)); // NOI18N
jButton1.setText("OK");
jButton1.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
tblStudent.setAutoCreateRowSorter(true);
tblStudent.setModel(new
javax.swing.table.DefaultTableModel( 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 [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(tblStudent); if
(tblStudent.getColumnModel().getColumnCount() > 0) {
tblStudent.getColumnModel().getColumn(0).setHeaderValue("
Title 1");
tblStudent.getColumnModel().getColumn(1).setHeaderValue("
Title 2");
tblStudent.getColumnModel().getColumn(2).setHeaderValue("
Title 3");
50. HND in Computing & Programming in
System Development Java
50
tblStudent.getColumnModel().getColumn(3).setHeaderValue("
Title 4");
}
btnDelete.setBackground(new java.awt.Color(0, 0, 0));
btnDelete.setForeground(new java.awt.Color(255, 255, 255));
btnDelete.setText("Delete Student Details");
btnDelete.setHorizontalTextPosition(javax.swing.SwingConstants.RIG
HT); btnDelete.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnDeleteActionPerformed(evt);
}
});
btnEdit.setBackground(new java.awt.Color(0, 0, 0));
btnEdit.setForeground(new java.awt.Color(255, 255, 255));
btnEdit.setText("Edit Student Detais");
btnEdit.setHorizontalTextPosition(javax.swing.SwingConstants.RIG
HT); btnEdit.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnEditActionPerformed(evt);
}
});
txtStudentID.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
txtStudentIDActionPerformed(evt);
}
});
btnAddNewStudent.setBackground(new java.awt.Color(0, 0, 0));
btnAddNewStudent.setForeground(new java.awt.Color(255, 255, 255));
btnAddNewStudent.setText("Add New Student Detail");
btnAddNewStudent.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnAddNewStudentActionPerformed(evt);
}
});
52. HND in Computing & Programming in
System Development Java
52
.addComponent(txtStudentID, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 195,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnAddNewStudent,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
pack();
}// </editor-fold>
public void setUserLimitations(boolean prm){
btnDelete.setEnabled(prm);
}
public void findStudentDetails() throws ClassNotFoundException,
SQLException{ // connect to the sql server
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("Successfuly Connected ");
53. HND in Computing & Programming in
System Development Java
53
String SQL1 = " SELECT * FROM Student_Details WHERE Student_ID LIKE" + "'%"+
txtStudentID.getText() +"%'";
Statement stmt2 =
connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls = stmt2.executeQuery(SQL1);
this.refreshTable();
while(rls.next())
{
model.addRow(new Object[]{
rls.getString(1),
rls.getString(2),
rls.getString(3),
rls.getString(4),
}
);
}
}
//--------refreshthe table-------
---- public void
refreshTable(){ while
(model.getRowCount() > 0) {
model.removeRow(0);
}
}
// Delete Student details-------------------
public void deletestudentDetails(String selRow) throws ClassNotFoundException,
SQLException
{
// connect to the sql server
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("Successfuly Connected ");
54. HND in Computing & Programming in
System Development Java
54
Statement statement = connection.createStatement();
statement.executeUpdate("DELETE FROM Student_Details WHERE Student_ID='" +
selRow + "'");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
}
private void
btnDeleteActionPerformed(java.awt.event.ActionEvent evt)
{ // TODO add your handling
code here: try{
if (tblStudent.getSelectedRow() < 0 || tblStudent.getSelectedColumn() < 0) {
JOptionPane.showMessageDialog(this, "Select a Record From Table To Delete","NO
RECORD
SELECTED",JOptionPane.WARNING_MESSAGE);
}
else {
int respond =JOptionPane.showConfirmDialog(this, "Are You Sure You Want To Delete
This?","Confirm
Deletion",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTIN_
MESSAGE);
if (respond==0){
String selectedRec =
(String)tblStudent.getValueAt(tblStudent.getSelectedRow(), 0);
this.deletestudentDetails(selectedRec); // deleting a cake from Db
this.refreshTable();
this.findStudentDetails();
}
else{
}
}
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
55. HND in Computing & Programming in
System Development Java
55
catch (SQLException e){
JOptionPane.showMessageDialog(null, e, "ERROR", JOptionPane.ERROR_MESSAGE);
}
}
private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (tblStudent.getSelectedRow() <0 || tblStudent.getSelectedColumn()<0) {
JOptionPane.showMessageDialog(this, "First select a record to Edit!", "NO RECORD
SELECTED",
JOptionPane.WARNING_MESSAGE);
} else {
String st = (String)
tblStudent.getValueAt(tblStudent.getSelectedRow(), 0);
EditStudentDetails editstudentdetails = new EditStudentDetails(st);
editstudentdetails.setVisible(true);
editstudentdetails.setLocationRelativeTo(null);
editstudentdetails.setResizable(false);
}
}
private void btnAddNewStudentActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
AddNewStudent addnewstudent = new AddNewStudent ();
addnewstudent.setVisible(true);
addnewstudent.setResizable(false);
addnewstudent.setLocationRelativeTo(null);
}
private void txtStudentIDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
if (txtStudentID.getText().equals("")){
//txtStudentID empty
JOptionPane.showMessageDialog(null, "The Student ID Field Is Empty,Enter Student ID
And Search", "EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
56. HND in Computing & Programming in
System Development Java
56
else{//txtxCake not empty
this.findStudentDetails();
if(model.getRowCount()==0){
JOptionPane.showMessageDialog(this, "No Data Found", "NO DATA",
JOptionPane.ERROR_MESSAGE);
}
}
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
catch (SQLException e){
JOptionPane.showMessageDialog(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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) { if
("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
57. HND in Computing & Programming in
System Development Java
57
java.util.logging.Logger.getLogger(StudentDetails.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StudentDetails.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StudentDetails.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StudentDetails.class.getName()).log(java.util.logging.Level.
SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new
Runnable() { public void run() {
// new StudentDetails().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnAddNewStudent;
private javax.swing.JButton
btnDelete; private
javax.swing.JButton btnEdit; private
javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane
jScrollPane1; private
javax.swing.JTable tblStudent;
private javax.swing.JTextField
txtStudentID;
// End of variables declaration
}
58. HND in Computing & Programming in
System Development Java
58
Add New Student Details Form
Figure 35
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
java.sql.Connection;
import
java.sql.DriverManager;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author Anushka
*/
public class AddNewStudent extends javax.swing.JFrame {
/**
59. HND in Computing & Programming in
System Development Java
59
* Creates new form AddNewStudent
*/
public AddNewStudent() {
initComponents();
try{
this.generateID();
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
catch (SQLException e){
System.out.println(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 javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
txtstudID = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
txtstudName = new
javax.swing.JTextField(); txtAge = new
javax.swing.JTextField(); txtTp = new
javax.swing.JTextField(); txtCsID =
new javax.swing.JTextField();
txtBatchID = new javax.swing.JTextField();
btnAdd = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
jSeparator2 = new javax.swing.JSeparator();
jLabel7 = new javax.swing.JLabel();
60. HND in Computing & Programming in
System Development Java
60
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setBackground(new java.awt.Color(255, 153, 0));
jButton1.setText("ok");
jButton1.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Add new Student",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION,new java.awt.Font("Arial Unicode MS", 0, 14),
new java.awt.Color(255, 153, 0))); // NOI18N
jLabel5.setText("Name :");
jLabel3.setText("Age :");
jLabel1.setText("Student ID :");
txtstudID.setDisabledTextColor(new java.awt.Color(255, 51, 51));
txtstudID.setEnabled(false);
jLabel4.setText("Telephone_no :");
jLabel2.setText("Course ID :");
jLabel6.setText("Batch ID :");
txtAge.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
txtAgeActionPerformed(evt);
}
});
txtTp.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
txtTpActionPerformed(evt);
}
});
63. HND in Computing & Programming in
System Development Java
63
btnClear.setHorizontalTextPosition(javax.swing.SwingConstants.RIG
HT); btnClear.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
jLabel7.setText("He Institute ");
jLabel7.setEnabled(false);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup() .addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(btnClear, javax.swing.GroupLayout.PREFERRED_SIZE, 73,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 87,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 111,
Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2)))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnAdd,
btnClear, jButton1});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
64. HND in Computing & Programming in
System Development Java
64
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup() .addGap(21, 21, 21)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 32,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnClear))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnAdd,
btnClear, jButton1});
pack();
}// </editor-fold>
public void add_student() throws ClassNotFoundException, SQLException{
// connection to the sql server
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("The database is Connected ");
Statement statement = connection.createStatement();
if(txtstudName.getText().equals("")){
JOptionPane.showMessageDialog(null, "The Student name Field Is Empty,Enter the Student name
Name", "EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else if(txtAge.getText().equals("")){
JOptionPane.showMessageDialog(null, "The Age Field Is Empty,Enter the Student Age", "EMPTY
FIELD", JOptionPane.ERROR_MESSAGE);
65. HND in Computing & Programming in
System Development Java
65
}
else if(txtTp.getText().equals("")){
JOptionPane.showMessageDialog(null, "The Telephone number Field Is Empty,Enter the Student
Telephone number", "EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else if(txtCsID.getText().equals("")){
JOptionPane.showMessageDialog(null, "The Course ID Field Is Empty,Enter a Course ID",
"EMPTY FIELD", JOptionPane.ERROR_MESSAGE);
}
else if(txtBatchID.getText().equals("")){
JOptionPane.showMessageDialog(null, "The Batch ID Field Is Empty,Enter a Batch ID", "EMPTY
FIELD", JOptionPane.ERROR_MESSAGE);
}
else {
statement.executeUpdate("INSERT INTO Student_Details VALUES " +"( '" + txtstudID.getText()
+ "'" + "," +
"'" + txtstudName.getText() + "'" + "," +
"'" + txtAge.getText()+ "'" + "," +
"'" + txtTp.getText() + "'" + ")" + "");
statement.executeUpdate("INSERT INTO [Student_ Course] VALUES "+"( '" +
txtstudID.getText() + "'" + "," +
"'" + txtCsID.getText() + "'" + ")" + "");
statement.executeUpdate("INSERT INTO [Student_ Batch] VALUES "+"( '" +
txtstudID.getText() + "'" + "," +
"'" + txtBatchID.getText() + "'" + ")" + "");
JOptionPane.showMessageDialog(null, "Record has been saved in the database", "INSERT
SUCCESSFUL", JOptionPane.INFORMATION_MESSAGE);
}
}
//-----------------------End of Add Student-------------------------------------------------------
66. HND in Computing & Programming in
System Development Java
66
public void clearAll(){
txtstudName.setText("");
txtstudID.setText("");
txtAge.setText("");
txtTp.setText("");
txtCsID.setText("");
txtBatchID.setText("");
}
public void generateID()throws ClassNotFoundException, SQLException{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("The database is Connected ");
String sql="SELECT * FROM Student_Details ORDER BY Student_ID ASC";
Statement stmt2 = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs =
stmt2.executeQuery(sql); int id;
if(!rs.next()){
id=1;
txtstudID.setText(Integer.toString(id));
}
else{
rs.last();
id=Integer.valueOf(rs.getString(1));
String
str_newid=Integer.toString(id+1);
txtstudID.setText(str_newid);
}
}// end of get details from student
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
67. HND in Computing & Programming in
System Development Java
67
}
private void
btnAddActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here: try{
this.add_student();//add new cake to
database this.clearAll();
this.generateID();
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
catch (SQLException e){
JOptionPane.showMessageDialog(null,e, "ERROR", JOptionPane.ERROR_MESSAGE);
System.out.println(e);
}
}
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.clearAll();
}
private void txtAgeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txtTpActionPerformed(java.awt.event.ActionEvent 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.
68. HND in Computing & Programming in
System Development Java
68
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) { if
("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{ public void run() {
new AddNewStudent().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnAdd;
private javax.swing.JButton btnClear;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
69. HND in Computing & Programming in
System Development Java
69
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator
jSeparator2; private
javax.swing.JTextField txtAge; private
javax.swing.JTextField txtBatchID;
private javax.swing.JTextField txtCsID;
private javax.swing.JTextField txtTp;
private javax.swing.JTextField txtstudID;
private javax.swing.JTextField txtstudName;
// End of variables declaration
}
Edit Student Details Form
Figure 36
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.
*/
70. HND in Computing & Programming in
System Development Java
70
package heinstitute; import
java.sql.Connection;
import
java.sql.DriverManager;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author Anushka
*/
public class EditStudentDetails extends javax.swing.JFrame {
/**
* Creates new form EditStudentDetails
*/
public EditStudentDetails(String id) {
initComponents();
txtstudID.setText(id);
try{
this.setStudentDetails(id);
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
catch (SQLException e){
JOptionPane.showMessageDialog(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.
*/
71. HND in Computing & Programming in
System Development Java
71
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
btnEdit = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtstudName = new
javax.swing.JTextField(); jLabel1 =
new javax.swing.JLabel(); txtstudID =
new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
txtAge = new javax.swing.JTextField();
txtTp = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnEdit.setText("Update ");
btnEdit.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnEditActionPerformed(evt);
}
});
btnClear.setText("Clear");
btnClear.setHorizontalTextPosition(javax.swing.SwingConstant
s.RIGHT); btnClear.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
btnCancel.setText("OK");
btnCancel.addActionListener(new
java.awt.event.ActionListener() { public void
72. HND in Computing & Programming in
System Development Java
72
actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Edit Student
details",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Unicode
MS", 0, 14), new java.awt.Color(255, 153, 0))); // NOI18N
jLabel5.setText("Name :");
jLabel3.setText("Age :");
jLabel1.setText("Student ID :");
txtstudID.setDisabledTextColor(new java.awt.Color(255, 51, 51));
txtstudID.setEnabled(false);
jLabel4.setText("Telephone_no :");
javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILIN
G, false)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
75. HND in Computing & Programming in
System Development Java
75
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]
{btnCancel, btnClear, btnEdit});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 165,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnClear)
.addComponent(btnCancel))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[]
{btnCancel, btnClear, btnEdit});
pack();
}// </editor-fold>
public void clearAll(){
txtstudName.setText("");
txtAge.setText("");
txtTp.setText("");
}//***********************end cl ******************
public void updateStudentDetails() throws ClassNotFoundException, SQLException
76. HND in Computing & Programming in
System Development Java
76
{
// connection to the sql server
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("Successfuly Connected ");
Statement statement = connection.createStatement();
String sql = "UPDATE Student_Details SET Student_Name='"+ txtstudName.getText()+
"'" + ","+
"Age='"+ txtAge.getText()+ "'" + ","+
"Telephone_no='"+ txtTp.getText() + "'" +
"WHERE Student_ID='"+ txtstudID.getText() +"'";
statement.executeUpdate(sql);
}//------------------endupdate--------------------------------
public void setStudentDetails(String S_id) throws ClassNotFoundException,
SQLException{ // sql server connection
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://Anushka-
PCSQLEXPRESS;database=He_Institute;IntegratedSecurity=true;";
Connection connection = DriverManager.getConnection(connectionUrl);
System.out.println("Successfuly Connected ");
String SQL1 = " SELECT * FROM Student_Details WHERE Student_ID ='"+ S_id +"'";
Statement stmt2 =
connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rls = stmt2.executeQuery(SQL1);
77. HND in Computing & Programming in
System Development Java
77
rls.first();
txtstudName.setText(rls.getString(2));
txtAge.setText(rls.getString(3));
txtTp.setText(rls.getString(4));
}
private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {
try{
int respond =JOptionPane.showConfirmDialog(this, "Are You Sure You
Want To Update This record?","Confirm
Update",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE)
; if (respond==0){ this.updateStudentDetails();
this.setVisible(false);
}
else{
}
}//end try
catch (ClassNotFoundException e){
System.out.println(e);
}
catch (SQLException e){
JOptionPane.showMessageDialog(null, e, "ERROR",
JOptionPane.ERROR_MESSAGE);
}
}
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.clearAll();
}
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.setVisible(false);
}
78. HND in Computing & Programming in
System Development Java
78
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting
code (optional) "> /* If Nimbus (introduced in Java SE 6) is not
available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) { if
("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(EditStudentDetails.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(EditStudentDetails.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(EditStudentDetails.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(EditStudentDetails.class.getName()).log(java.util.logging.
Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable()
{ public void run() {
new EditStudentDetails("s").setVisible(true);
}
79. HND in Computing & Programming in
System Development Java
79
});
}
// Variables declaration - do not modify
private javax.swing.JButton
btnCancel; private
javax.swing.JButton btnClear;
private javax.swing.JButton btnEdit;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator
jSeparator2; private
javax.swing.JTextField txtAge;
private javax.swing.JTextField txtTp;
private javax.swing.JTextField
txtstudID; private
javax.swing.JTextField txtstudName;
// End of variables declaration
}
Course Details Form
Figure 37
80. HND in Computing & Programming in
System Development Java
80
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
java.sql.Connection;
import
java.sql.DriverManager;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import
javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Anushka
*/
public class CourseDetails extends javax.swing.JFrame {
/**
* Creates new form CourseDetails
*/
DefaultTableModel model;
public CourseDetails(boolean r) {
initComponents();
model = new DefaultTableModel();
81. HND in Computing & Programming in
System Development Java
81
model.addColumn("Course_ID");
model.addColumn("Course_Name");
model.addColumn("Duration");
model.addColumn("Course_Fee");
tblCourse.setModel(model);
this.setUserLimitations(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
javax.swing.JButton();
btnAddNewCourse = new
javax.swing.JButton(); btnEdit = new
javax.swing.JButton(); jButton1 = new
javax.swing.JButton(); jScrollPane1 =
new javax.swing.JScrollPane();
tblCourse = new javax.swing.JTable();
txtCourseID1 = new
javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_O
N_CLOSE); setName("Course Details"); // NOI18N
btnDelete.setBackground(new java.awt.Color(0, 0, 0));
btnDelete.setForeground(new java.awt.Color(255, 255, 255));
btnDelete.setText("Delete Course Details");
btnDelete.setHorizontalTextPosition(javax.swing.SwingConstant
s.RIGHT); btnDelete.addActionListener(new
java.awt.event.ActionListener() { public void
actionPerformed(java.awt.event.ActionEvent evt) {
btnDeleteActionPerformed(evt);