School Management System Java Project With Source Code
The School Management System Java Project is developed using Java Programming Language, This School Management System Java is an application developed for schools. School Management System Project Report In Java is an application developed in Java which is used to store all the school-related records. It stores information related to students, staff, and teachers. The database used is MS-Access. The objective of developing such a system was to reduce the errors that creep in the manual system where it was very difficult to store the records.
A School Management System In Java also provides the facility to calculate the attendance of the student. There are four types of login for this system the administrator, student, teacher and staff login. This Project is handled by the administrator who has all the rights to edit or modify any school member information.
This School Management System In Java Netbeans was developed to provide a secure, easy to use a reliable system. In this Java Code For School Management System was created to handle all the school-related information and save it in records.
In this School Management System Project Report In Java also includes a downloadable School Management System In Java Source Code for free, just find the downloadable source code below and click to start downloading.
Watch the video here to see the full running School Management System in Java Projects with Source code
To start creating a School Management System Java Project, makes sure that you have NeatBeans IDE or any platform of Java installed in your computer.
School Management System Java Project Features
- Student Records Management
- Staff Records Management
- Teacher Record Management
- Admission Form
- Login/Logout System
School Management System Java Project With Source Code steps on how to create the project
Time needed: 5 minutes.
These are the steps on how to create School Management System Java Project With Source Code
- Step 1: Create project.
First, open file and then click “project” to create.
- Step 2: Create project name.
Second, name your project.
- Step 3: Create JFrame.
Third, create “JFrame” form.
- Step 4: Create JFrame name.
Fourth, name your JFrame form.
- Step 5: Project Design.
Fifth, The actual design of the project.
The Code Given Below Is For The Log In Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) { con=Connect.ConnectDB(); String sql= "select * from Users where Username= '" + userNameField.getText() + "' and User_Password ='" + passwordField.getText() + "'"; try { pst=con.prepareStatement(sql); rs= pst.executeQuery(); //(""==usernamField.getText()) if("".equals(userNameField.getText()) && "".equals(passwordField.getText())){ JOptionPane.showMessageDialog(null,"Please Enter Username and Password!"); } else if (rs.next()){ this.hide(); MainMenu menu=new MainMenu(); menu.setVisible(true); } else{ JOptionPane.showMessageDialog(null, "Login Failed..Try again !","Access denied",JOptionPane.ERROR_MESSAGE); userNameField.setText(""); passwordField.setText(""); userNameField.requestFocus(); } } catch(SQLException | HeadlessException e) { JOptionPane.showMessageDialog(null, e); } } private void passwordFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void passwordFieldKeyPressed(java.awt.event.KeyEvent evt) { if(evt.getKeyCode()==KeyEvent.VK_ENTER){ con=Connect.ConnectDB(); String sql= "select * from Users where Username= '" + userNameField.getText() + "' and User_Password ='" + passwordField.getText() + "'"; try { pst=con.prepareStatement(sql); rs= pst.executeQuery(); if("".equals(userNameField.getText()) && "".equals(passwordField.getText())){ JOptionPane.showMessageDialog(null,"Please Enter Username and Password!"); } else if (rs.next()){ this.hide(); MainMenu menu=new MainMenu(); menu.setVisible(true); } else{ JOptionPane.showMessageDialog(null, "Login Failed..Try again !","Access denied",JOptionPane.ERROR_MESSAGE); userNameField.setText(""); passwordField.setText(""); userNameField.requestFocus(); } } catch(SQLException | HeadlessException e) { JOptionPane.showMessageDialog(null, e); } } } private void userNameFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } |
In this module which is the login module of the system.
The Code Given Below Is For The Student Form Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
package GUI; import java.awt.HeadlessException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.swing.JOptionPane; /** * * @author M Azhar Durrani */ public class StudentForm extends javax.swing.JFrame { Connection con=null; ResultSet rs=null; PreparedStatement pst=null; /** * Creates new form StudentForm1 */ public StudentForm() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { stud = new javax.swing.JSplitPane(); jPanel6 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); firstNameLabel = new javax.swing.JLabel(); firstNameField = new javax.swing.JTextField(); lastNameLabel = new javax.swing.JLabel(); lastNameField = new javax.swing.JTextField(); fatherNameLabel = new javax.swing.JLabel(); fatherNameField = new javax.swing.JTextField(); cnicLabel = new javax.swing.JLabel(); cnicField = new javax.swing.JTextField(); mobileLabel = new javax.swing.JLabel(); mobileField = new javax.swing.JTextField(); addressLabel = new javax.swing.JLabel(); addressField = new javax.swing.JTextField(); genderLabel = new javax.swing.JLabel(); cmbGender = new javax.swing.JComboBox<>(); dobLabel = new javax.swing.JLabel(); dobField = new javax.swing.JTextField(); PhoneLabel1 = new javax.swing.JLabel(); phoneField = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); studentIdField = new javax.swing.JTextField(); studentIdLabel = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); admissionClass = new javax.swing.JTextField(); doaLabel = new javax.swing.JLabel(); doaField = new javax.swing.JTextField(); lastSchoolLabel = new javax.swing.JLabel(); lastSchoolAttendedField = new javax.swing.JTextField(); lastClassLabel = new javax.swing.JLabel(); lastClassAttendedField = new javax.swing.JTextField(); jPanel4 = new javax.swing.JPanel(); backButton = new javax.swing.JButton(); newButton = new javax.swing.JButton(); updateButton = new javax.swing.JButton(); saveButton = new javax.swing.JButton(); getDataButton = new javax.swing.JButton(); deleteButton = new javax.swing.JButton(); studentRecord = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Student Form"); stud.setDividerLocation(0); stud.setAutoscrolls(true); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 0, Short.MAX_VALUE) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 727, Short.MAX_VALUE) ); stud.setLeftComponent(jPanel6); jLabel1.setBackground(new java.awt.Color(153, 153, 153)); jLabel1.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N jLabel1.setForeground(new java.awt.Color(0, 153, 153)); jLabel1.setText(" Student's Details"); jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 4)); jPanel1.setBackground(new java.awt.Color(102, 102, 102)); jPanel1.setMaximumSize(new java.awt.Dimension(1366, 720)); jPanel1.setMinimumSize(new java.awt.Dimension(1366, 700)); jPanel1.setPreferredSize(new java.awt.Dimension(1366, 710)); jPanel2.setBackground(new java.awt.Color(102, 102, 102)); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Basic Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N jPanel2.setForeground(new java.awt.Color(255, 255, 255)); firstNameLabel.setBackground(new java.awt.Color(0, 0, 0)); firstNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N firstNameLabel.setForeground(new java.awt.Color(255, 255, 255)); firstNameLabel.setText("First Name:"); firstNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N firstNameField.setToolTipText("Enter First Name here"); firstNameField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { firstNameFieldActionPerformed(evt); } }); firstNameField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { firstNameFieldKeyTyped(evt); } }); lastNameLabel.setBackground(new java.awt.Color(0, 0, 0)); lastNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lastNameLabel.setForeground(new java.awt.Color(255, 255, 255)); lastNameLabel.setText("Last Name:"); lastNameLabel.setToolTipText(""); lastNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N lastNameField.setToolTipText("Enter Last Name Here"); lastNameField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lastNameFieldActionPerformed(evt); } }); lastNameField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { lastNameFieldKeyTyped(evt); } }); fatherNameLabel.setBackground(new java.awt.Color(0, 0, 0)); fatherNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N fatherNameLabel.setForeground(new java.awt.Color(255, 255, 255)); fatherNameLabel.setText("Father's Name:"); fatherNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N fatherNameField.setToolTipText("Enter Father's Name here"); fatherNameField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { fatherNameFieldActionPerformed(evt); } }); fatherNameField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { fatherNameFieldKeyTyped(evt); } }); cnicLabel.setBackground(new java.awt.Color(0, 0, 0)); cnicLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N cnicLabel.setForeground(new java.awt.Color(255, 255, 255)); cnicLabel.setText("Father's CNIC:"); cnicField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N cnicField.setToolTipText("Enter Father's CNIC Number"); cnicField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { cnicFieldKeyTyped(evt); } }); mobileLabel.setBackground(new java.awt.Color(0, 0, 0)); mobileLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N mobileLabel.setForeground(new java.awt.Color(255, 255, 255)); mobileLabel.setText("Father's Mobile: "); mobileField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N mobileField.setToolTipText("Enter Father's Mobile Number here"); mobileField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { mobileFieldKeyTyped(evt); } }); addressLabel.setBackground(new java.awt.Color(0, 0, 0)); addressLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N addressLabel.setForeground(new java.awt.Color(255, 255, 255)); addressLabel.setText("Address:"); addressField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N addressField.setToolTipText("EnterStudent's Address here"); addressField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addressFieldActionPerformed(evt); } }); genderLabel.setBackground(new java.awt.Color(0, 0, 0)); genderLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N genderLabel.setForeground(new java.awt.Color(255, 255, 255)); genderLabel.setText("Gender:"); cmbGender.setBackground(new java.awt.Color(102, 102, 102)); cmbGender.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N cmbGender.setForeground(new java.awt.Color(255, 255, 255)); cmbGender.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "", "Male", "Female" })); dobLabel.setBackground(new java.awt.Color(0, 0, 0)); dobLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N dobLabel.setForeground(new java.awt.Color(255, 255, 255)); dobLabel.setText("Date of Birth:"); dobField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N dobField.setToolTipText("Enter Student's Date of Birth here"); dobField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { dobFieldActionPerformed(evt); } }); PhoneLabel1.setBackground(new java.awt.Color(0, 0, 0)); PhoneLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N PhoneLabel1.setForeground(new java.awt.Color(255, 255, 255)); PhoneLabel1.setText("Father's Phone:"); phoneField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N phoneField.setToolTipText("Enter Father's Phone Number here"); phoneField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { phoneFieldActionPerformed(evt); } }); phoneField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { phoneFieldKeyTyped(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(fatherNameLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(firstNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE) .addComponent(fatherNameField))) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(dobLabel) .addGap(30, 30, 30) .addComponent(dobField, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(mobileLabel) .addComponent(cnicLabel) .addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(lastNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE) .addComponent(cnicField) .addComponent(mobileField))) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(4, 4, 4) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(addressField) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(PhoneLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(phoneField, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGap(343, 343, 343)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(30, 30, 30) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(fatherNameLabel) .addComponent(fatherNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cnicLabel) .addComponent(cnicField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(30, 30, 30) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(mobileLabel) .addComponent(mobileField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(dobLabel) .addComponent(dobField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(30, 30, 30) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(PhoneLabel1) .addComponent(phoneField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); jPanel3.setBackground(new java.awt.Color(102, 102, 102)); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Academic Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N jPanel3.setForeground(new java.awt.Color(255, 255, 255)); studentIdField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N studentIdField.setToolTipText("Enter Student ID here"); studentIdField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { studentIdFieldActionPerformed(evt); } }); studentIdField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { studentIdFieldKeyTyped(evt); } }); studentIdLabel.setBackground(new java.awt.Color(0, 0, 0)); studentIdLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N studentIdLabel.setForeground(new java.awt.Color(255, 255, 255)); studentIdLabel.setText("Student ID:"); jLabel2.setBackground(new java.awt.Color(0, 0, 0)); jLabel2.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N jLabel2.setForeground(new java.awt.Color(255, 255, 255)); jLabel2.setText("Admission in Class:"); admissionClass.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N doaLabel.setBackground(new java.awt.Color(0, 0, 0)); doaLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N doaLabel.setForeground(new java.awt.Color(255, 255, 255)); doaLabel.setText("Date of Admission:"); doaField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N doaField.setToolTipText("Enter Student's Date of Admission here"); doaField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { doaFieldActionPerformed(evt); } }); lastSchoolLabel.setBackground(new java.awt.Color(0, 0, 0)); lastSchoolLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lastSchoolLabel.setForeground(new java.awt.Color(255, 255, 255)); lastSchoolLabel.setText("Last School Attended:"); lastSchoolAttendedField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N lastSchoolAttendedField.setToolTipText("Enter Last School Name"); lastSchoolAttendedField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lastSchoolAttendedFieldActionPerformed(evt); } }); lastClassLabel.setBackground(new java.awt.Color(0, 0, 0)); lastClassLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lastClassLabel.setForeground(new java.awt.Color(255, 255, 255)); lastClassLabel.setText("Last Class Attended:"); lastClassAttendedField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N lastClassAttendedField.setToolTipText("Enter Last Class Attended"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(studentIdLabel) .addGap(82, 82, 82)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addComponent(lastSchoolLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(studentIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(99, 99, 99) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(admissionClass, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(lastSchoolAttendedField)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 111, Short.MAX_VALUE) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addComponent(doaLabel) .addGap(44, 44, 44) .addComponent(doaField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addComponent(lastClassLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lastClassAttendedField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(29, 29, 29)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(3, 3, 3) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(studentIdLabel) .addComponent(studentIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(admissionClass, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(doaField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(doaLabel))) .addGap(25, 25, 25) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lastClassAttendedField, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lastClassLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lastSchoolLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lastSchoolAttendedField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel4.setBackground(new java.awt.Color(102, 102, 102)); backButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N backButton.setText("Back"); backButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backButtonActionPerformed(evt); } }); newButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N newButton.setText("New"); newButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newButtonActionPerformed(evt); } }); updateButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N updateButton.setText("Update"); updateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updateButtonActionPerformed(evt); } }); saveButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N saveButton.setText("Save"); saveButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveButtonActionPerformed(evt); } }); getDataButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N getDataButton.setText("Get Data"); getDataButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { getDataButtonActionPerformed(evt); } }); deleteButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N deleteButton.setText("Delete"); deleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { deleteButtonActionPerformed(evt); } }); studentRecord.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N studentRecord.setText("Student Record"); studentRecord.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { studentRecordActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(backButton) .addGap(18, 18, 18) .addComponent(newButton) .addGap(18, 18, 18) .addComponent(saveButton) .addGap(18, 18, 18) .addComponent(updateButton) .addGap(18, 18, 18) .addComponent(deleteButton) .addGap(18, 18, 18) .addComponent(getDataButton) .addGap(18, 18, 18) .addComponent(studentRecord) .addGap(185, 185, 185)) ); jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, deleteButton, getDataButton, newButton, saveButton, studentRecord, updateButton}); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(23, 23, 23) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(deleteButton) .addComponent(getDataButton) .addComponent(studentRecord) .addComponent(updateButton) .addComponent(saveButton) .addComponent(newButton) .addComponent(backButton)) .addContainerGap(28, Short.MAX_VALUE)) ); 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) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(72, 72, 72) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(32, 32, 32) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 666, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); stud.setRightComponent(jPanel5); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(stud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(stud) ); pack(); }// </editor-fold> private void firstNameFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void lastNameFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void fatherNameFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void addressFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void dobFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void phoneFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void studentIdFieldActionPerformed(java.awt.event.ActionEvent evt) { } private void doaFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void lastSchoolAttendedFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void backButtonActionPerformed(java.awt.event.ActionEvent evt) { MainMenu menu=new MainMenu(); this.hide(); menu.setVisible(true); } private void newButtonActionPerformed(java.awt.event.ActionEvent evt) { firstNameField.setText(""); studentIdField.setText(""); lastNameField.setText(""); lastSchoolAttendedField.setText(""); fatherNameField.setText(""); phoneField.setText(""); mobileField.setText(""); cnicField.setText(""); lastClassAttendedField.setText(""); addressField.setText(""); cmbGender.setSelectedIndex(0); admissionClass.setText(""); dobField.setText(""); doaField.setText(""); deleteButton.setEnabled(false); updateButton.setEnabled(false); studentIdField.requestFocus(); } private void getDataButtonActionPerformed(java.awt.event.ActionEvent evt) { this.hide(); StudentRecord record=new StudentRecord(); record.setVisible(true); } private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) { try{ con = Connect.ConnectDB(); String sql = "update StudentRecord set FirstName='"+firstNameField.getText()+"',LastName='"+lastNameField.getText()+"',DateOfBirth='"+dobField.getText()+"',FatherName='"+fatherNameField.getText()+"',FatherCNIC='"+cnicField.getText()+"',FatherPhone='"+phoneField.getText()+"',FatherMobile='"+mobileField.getText()+"',Address='"+addressField.getText()+"',DOA='"+doaField.getText()+"',LCA='"+lastClassAttendedField.getText()+"',PSN='"+lastSchoolAttendedField.getText()+"',Gender='"+cmbGender.getSelectedItem()+"',Class='"+ admissionClass.getText()+"'where StudentID='"+studentIdField.getText()+"'"; pst = con.prepareStatement(sql); pst.execute(); if("".equals(studentIdField.getText())){ JOptionPane.showMessageDialog(null, "Please select a record to update!"); return; } JOptionPane.showMessageDialog(this, "Updated Successfully!","Record",JOptionPane.INFORMATION_MESSAGE); updateButton.setEnabled(false); } catch(HeadlessException | SQLException ex){ JOptionPane.showMessageDialog(this,ex); } } private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) { try{ con = Connect.ConnectDB(); if("".equals(studentIdField.getText())){ JOptionPane.showMessageDialog(null, "Please Enter Student ID", "Error", JOptionPane.ERROR_MESSAGE); return; } Statement st; st = con.createStatement(); String sql1="select StudentID from StudentRecord where StudentID='"+studentIdField.getText()+"'"; rs = st.executeQuery(sql1); if(rs.next()){ JOptionPane.showMessageDialog(null, "Student ID already exists", "Error", JOptionPane.ERROR_MESSAGE); studentIdField.setText(""); studentIdField.requestDefaultFocus(); return; } String sql= "insert into StudentRecord(StudentID,FirstName,LastName,DateOfBirth,FatherName,FatherCNIC,FatherPhone,FatherMobile,Address,DOA,LCA,PSN,Gender,Class) values ('"+studentIdField.getText()+"','"+firstNameField.getText()+"','"+lastNameField.getText()+"','"+dobField.getText()+"','"+fatherNameField.getText()+"','"+cnicField.getText()+"','"+phoneField.getText()+"','"+mobileField.getText()+"','"+addressField.getText()+"','"+doaField.getText()+"','"+lastClassAttendedField.getText()+"','"+lastSchoolAttendedField.getText()+"','"+cmbGender.getSelectedItem()+"','"+admissionClass.getText()+"')"; pst = con.prepareStatement(sql); pst.execute(); JOptionPane.showMessageDialog(null, "Successfully Registered!", "Student", JOptionPane.INFORMATION_MESSAGE); saveButton.setEnabled(false); } catch(HeadlessException | SQLException ex){ JOptionPane.showMessageDialog(this,ex); } } private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) { try{ if("".equals(studentIdField.getText())){ JOptionPane.showMessageDialog(null, "Please enter Student ID to delete record!"); return; } int d = JOptionPane.showConfirmDialog(this, "Are sure want to delete.?", "Confirmation", JOptionPane.YES_NO_OPTION); if(d==0){ con = Connect.ConnectDB(); String sql = "delete from StudentRecord where StudentID='"+studentIdField.getText()+"'"; pst = con.prepareStatement(sql); pst.execute(); JOptionPane.showMessageDialog(this,"Successfully deleted","Record",JOptionPane.INFORMATION_MESSAGE); reset(); } } catch(Exception ex){ JOptionPane.showMessageDialog(this, ex); } } private void studentRecordActionPerformed(java.awt.event.ActionEvent evt) { StudentRecord record = new StudentRecord(); this.hide(); record.setVisible(true); } private void cnicFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if((input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Please enter digits!"); } } private void mobileFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if((input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Please enter digits!"); } } private void studentIdFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if((input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Please enter digits!"); } } private void phoneFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if((input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Please enter digits!"); } } private void firstNameFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if(!(input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Name does not contain any numbers!"); } } private void fatherNameFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if(!(input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Name does not contain any numbers!"); } } private void lastNameFieldKeyTyped(java.awt.event.KeyEvent evt) { char input = evt.getKeyChar(); if(!(input<'0' || input>'9') && input!='\b'){ evt.consume(); JOptionPane.showMessageDialog(this, "Name does not contain any numbers!"); } } void reset(){ firstNameField.setText(""); studentIdField.setText(""); lastNameField.setText(""); lastSchoolAttendedField.setText(""); fatherNameField.setText(""); phoneField.setText(""); mobileField.setText(""); cnicField.setText(""); lastClassAttendedField.setText(""); addressField.setText(""); cmbGender.setSelectedIndex(0); admissionClass.setText(""); dobField.setText(""); doaField.setText(""); deleteButton.setEnabled(false); updateButton.setEnabled(false); studentIdField.requestFocus(); } |
In this module which is the student form module.
The Code Given Below Is For The Student Record Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
package GUI; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import javax.swing.JOptionPane; import net.proteanit.sql.DbUtils; /** * * @author M Azhar Durrani */ public class StudentRecord extends javax.swing.JFrame { Connection con=null; ResultSet rs=null; PreparedStatement pst=null; /** * Creates new form StudentRecord */ public StudentRecord() { initComponents(); con=Connect.ConnectDB(); Get_Data(); setLocationRelativeTo(null); } private void Get_Data(){ String sql = "select StudentID as [Student ID], FirstName"+" +"+"LastName as [Full Name], Class as [Class] from StudentRecord"; try{ pst = con.prepareStatement(sql); rs = pst.executeQuery(); dataTable.setModel(DbUtils.resultSetToTableModel(rs)); } catch(Exception ex){ JOptionPane.showMessageDialog(null, ex); } } /** * 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 javax.swing.JScrollPane(); dataTable = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); teacherRecord = new javax.swing.JButton(); staffRecord = new javax.swing.JButton(); teacherForm = new javax.swing.JButton(); staffForm = new javax.swing.JButton(); jButton11 = new javax.swing.JButton(); backButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Student Record"); dataTable.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N dataTable.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, 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 [] { "Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7", "Title 8", "Title 9", "Title 10", "Title 11", "Title 12", "Title 13", "Title 14" } )); dataTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { dataTableMouseClicked(evt); } }); jScrollPane1.setViewportView(dataTable); jPanel1.setBackground(new java.awt.Color(102, 102, 102)); teacherRecord.setText("Teacher Record"); teacherRecord.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { teacherRecordActionPerformed(evt); } }); staffRecord.setText("Staff Record"); staffRecord.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { staffRecordActionPerformed(evt); } }); teacherForm.setText("Teacher Form"); teacherForm.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { teacherFormActionPerformed(evt); } }); staffForm.setText("Staff Form"); staffForm.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { staffFormActionPerformed(evt); } }); jButton11.setText("Logout"); jButton11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton11ActionPerformed(evt); } }); backButton.setText("Main Menu"); backButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backButtonActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(96, 96, 96) .addComponent(backButton) .addGap(18, 18, 18) .addComponent(teacherRecord) .addGap(18, 18, 18) .addComponent(staffRecord) .addGap(18, 18, 18) .addComponent(teacherForm) .addGap(18, 18, 18) .addComponent(staffForm) .addGap(18, 18, 18) .addComponent(jButton11) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, jButton11, staffForm, staffRecord, teacherForm, teacherRecord}); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(24, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(teacherForm) .addComponent(staffForm) .addComponent(jButton11)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(teacherRecord) .addComponent(staffRecord) .addComponent(backButton))) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1050, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(64, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void dataTableMouseClicked(java.awt.event.MouseEvent evt) { try{ con = Connect.ConnectDB(); int row = dataTable.getSelectedRow(); String tableClick = dataTable.getModel().getValueAt(row, 0).toString(); String sql = "select * from StudentRecord where StudentID= "+tableClick; pst = con.prepareStatement(sql); rs = pst.executeQuery(); if(rs.next()){ this.hide(); StudentForm student=new StudentForm(); student.setVisible(true); String add1 = rs.getString("StudentID"); student.studentIdField.setText(add1); String add2 = rs.getString("FirstName"); student.firstNameField.setText(add2); String add3 = rs.getString("LastName"); student.lastNameField.setText(add3); String add4 = rs.getString("DateOfBirth"); student.dobField.setText(add4); String add5 = rs.getString("FatherName"); student.fatherNameField.setText(add5); String add6 = rs.getString("FatherCNIC"); student.cnicField.setText(add6); String add7 = rs.getString("FatherPhone"); student.phoneField.setText(add7); String add8 = rs.getString("FatherMobile"); student.mobileField.setText(add8); String add9 = rs.getString("Address"); student.addressField.setText(add9); String add10 = rs.getString("DOA"); student.doaField.setText(add10); String add11 = rs.getString("LCA"); student.lastClassAttendedField.setText(add11); String add12 = rs.getString("PSN"); student.lastSchoolAttendedField.setText(add12); String add13 = rs.getString("Gender"); student.cmbGender.setSelectedItem(add13); String add14 = rs.getString("Class"); student.admissionClass.setText(add14); student.updateButton.setEnabled(true); student.deleteButton.setEnabled(true); student.saveButton.setEnabled(true); //student.studentIdField.setEnabled(true); } } catch(Exception ex){ JOptionPane.showMessageDialog(null, ex); } } private void teacherRecordActionPerformed(java.awt.event.ActionEvent evt) { TeacherRecord record=new TeacherRecord(); this.hide(); record.setVisible(true); } private void staffRecordActionPerformed(java.awt.event.ActionEvent evt) { StaffRecord record=new StaffRecord(); this.hide(); record.setVisible(true); } private void teacherFormActionPerformed(java.awt.event.ActionEvent evt) { TeacherForm form=new TeacherForm(); this.hide(); form.setVisible(true); } private void staffFormActionPerformed(java.awt.event.ActionEvent evt) { StaffForm form=new StaffForm(); this.hide(); form.setVisible(true); } private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) { Login login=new Login(); this.hide(); login.setVisible(true); } private void backButtonActionPerformed(java.awt.event.ActionEvent evt) { /*StudentForm menu=new StudentForm(); this.hide(); menu.setVisible(true);*/ MainMenu m=new MainMenu(); m.setVisible(true); this.hide(); } private void formWindowClosing(java.awt.event.WindowEvent evt) { this.hide(); StudentForm form = new StudentForm(); form.setVisible(true); } |
In this module which is the student record module .
The Code Given Below Is For The Teacher Form Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
import java.awt.HeadlessException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.swing.JOptionPane; /** * * @author M Azhar Durrani */ public class TeacherForm extends javax.swing.JFrame { Connection con=null; ResultSet rs=null; PreparedStatement pst=null; /** * Creates new form TeacherForm1 */ public TeacherForm() { initComponents(); } void reset(){ firstNameField.setText(""); teacherIdField.setText(""); lastNameField.setText(""); salaryField.setText(""); fatherNameField.setText(""); emailAddress.setText(""); mobileField.setText(""); cnicField.setText(""); designationField.setText(""); aqField.setText(""); addressField.setText(""); cmbGender.setSelectedIndex(0); experienceField.setText(""); dobField.setText(""); deleteButton.setEnabled(false); updateButton.setEnabled(false); teacherIdField.requestFocus(); } /** * 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 javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); firstNameLabel = new javax.swing.JLabel(); firstNameField = new javax.swing.JTextField(); lastNameLabel = new javax.swing.JLabel(); lastNameField = new javax.swing.JTextField(); fatherNameLabel = new javax.swing.JLabel(); fatherNameField = new javax.swing.JTextField(); cnicLabel = new javax.swing.JLabel(); cnicField = new javax.swing.JTextField(); mobileLabel = new javax.swing.JLabel(); mobileField = new javax.swing.JTextField(); addressLabel = new javax.swing.JLabel(); addressField = new javax.swing.JTextField(); genderLabel = new javax.swing.JLabel(); cmbGender = new javax.swing.JComboBox<>(); dobLabel = new javax.swing.JLabel(); dobField = new javax.swing.JTextField(); PhoneLabel1 = new javax.swing.JLabel(); emailAddress = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); designationField = new javax.swing.JTextField(); |