content: 
  import java.awt.Color;
  import java.sql.Connection;
  import java.sql.SQLException;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.swing.JOptionPane;
  
  /*
   * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
   * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
   */
  /**
   *
   * @author ahmed
   */
  public class UpdateSection extends javax.swing.JFrame {
  
      /**
       * Creates new form UpdateSection
       */
      public UpdateSection() {
          initComponents();
          this.setLocationRelativeTo(null);
          Semester.setVisible(false);
          Year.setVisible(false);
      }
  
      /**
       * 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">//GEN-BEGIN:initComponents
      private void initComponents() {
  
          jPanel1 = new javax.swing.JPanel();
          Year = new javax.swing.JPanel();
          newYear = new javax.swing.JTextField();
          UpdateYearButton = new javax.swing.JButton();
          Semester = new javax.swing.JPanel();
          sem = new javax.swing.JTextField();
          UpdateSemesterButton1 = new javax.swing.JButton();
          Sec_id = new javax.swing.JTextField();
          jButton8 = new javax.swing.JButton();
          SemesterButton = new javax.swing.JPanel();
          a6 = new javax.swing.JLabel();
          Yeat_Button = new javax.swing.JPanel();
          a4 = new javax.swing.JLabel();
          jLabel2 = new javax.swing.JLabel();
          jButton10 = new javax.swing.JButton();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
          setPreferredSize(new java.awt.Dimension(600, 300));
          setResizable(false);
  
          jPanel1.setBackground(new java.awt.Color(0, 64, 128));
          jPanel1.setPreferredSize(new java.awt.Dimension(572, 500));
  
          Year.setBackground(new java.awt.Color(173, 216, 230));
  
          newYear.setText("New Year");
          newYear.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  newYearActionPerformed(evt);
              }
          });
  
          UpdateYearButton.setBackground(new java.awt.Color(0, 64, 128));
          UpdateYearButton.setForeground(new java.awt.Color(255, 255, 255));
          UpdateYearButton.setText("Enter");
          UpdateYearButton.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  UpdateYearButtonActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout YearLayout = new javax.swing.GroupLayout(Year);
          Year.setLayout(YearLayout);
          YearLayout.setHorizontalGroup(
              YearLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(YearLayout.createSequentialGroup()
                  .addGap(25, 25, 25)
                  .addGroup(YearLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addComponent(UpdateYearButton)
                      .addComponent(newYear, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addContainerGap(33, Short.MAX_VALUE))
          );
          YearLayout.setVerticalGroup(
              YearLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(YearLayout.createSequentialGroup()
                  .addGap(45, 45, 45)
                  .addComponent(newYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                  .addComponent(UpdateYearButton)
                  .addContainerGap(11, Short.MAX_VALUE))
          );
  
          Semester.setBackground(new java.awt.Color(173, 216, 230));
  
          sem.setText("New Semester");
  
          UpdateSemesterButton1.setBackground(new java.awt.Color(0, 64, 128));
          UpdateSemesterButton1.setForeground(new java.awt.Color(255, 255, 255));
          UpdateSemesterButton1.setText("Enter");
          UpdateSemesterButton1.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  UpdateSemesterButton1ActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout SemesterLayout = new javax.swing.GroupLayout(Semester);
          Semester.setLayout(SemesterLayout);
          SemesterLayout.setHorizontalGroup(
              SemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(SemesterLayout.createSequentialGroup()
                  .addGap(19, 19, 19)
                  .addGroup(SemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addComponent(UpdateSemesterButton1)
                      .addComponent(sem, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addContainerGap(39, Short.MAX_VALUE))
          );
          SemesterLayout.setVerticalGroup(
              SemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(SemesterLayout.createSequentialGroup()
                  .addGap(47, 47, 47)
                  .addComponent(sem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addComponent(UpdateSemesterButton1)
                  .addContainerGap(14, Short.MAX_VALUE))
          );
  
          Sec_id.setText("Section ID");
  
          jButton8.setBackground(new java.awt.Color(0, 64, 128));
          jButton8.setForeground(new java.awt.Color(255, 255, 255));
          jButton8.setText("Enter");
  
          SemesterButton.setBackground(new java.awt.Color(10, 50, 100));
          SemesterButton.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mouseEntered(java.awt.event.MouseEvent evt) {
                  SemesterButtonMouseEntered(evt);
              }
              public void mouseExited(java.awt.event.MouseEvent evt) {
                  SemesterButtonMouseExited(evt);
              }
              public void mousePressed(java.awt.event.MouseEvent evt) {
                  SemesterButtonMousePressed(evt);
              }
          });
  
          a6.setForeground(new java.awt.Color(255, 255, 255));
          a6.setText("Update Semester");
  
          javax.swing.GroupLayout SemesterButtonLayout = new javax.swing.GroupLayout(SemesterButton);
          SemesterButton.setLayout(SemesterButtonLayout);
          SemesterButtonLayout.setHorizontalGroup(
              SemesterButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(SemesterButtonLayout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(a6, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(79, Short.MAX_VALUE))
          );
          SemesterButtonLayout.setVerticalGroup(
              SemesterButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(SemesterButtonLayout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(a6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                  .addContainerGap())
          );
  
          Yeat_Button.setBackground(new java.awt.Color(10, 50, 100));
          Yeat_Button.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mouseEntered(java.awt.event.MouseEvent evt) {
                  Yeat_ButtonMouseEntered(evt);
              }
              public void mouseExited(java.awt.event.MouseEvent evt) {
                  Yeat_ButtonMouseExited(evt);
              }
              public void mousePressed(java.awt.event.MouseEvent evt) {
                  Yeat_ButtonMousePressed(evt);
              }
          });
  
          a4.setForeground(new java.awt.Color(255, 255, 255));
          a4.setText("Update Year");
  
          javax.swing.GroupLayout Yeat_ButtonLayout = new javax.swing.GroupLayout(Yeat_Button);
          Yeat_Button.setLayout(Yeat_ButtonLayout);
          Yeat_ButtonLayout.setHorizontalGroup(
              Yeat_ButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(Yeat_ButtonLayout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(a4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addContainerGap(100, Short.MAX_VALUE))
          );
          Yeat_ButtonLayout.setVerticalGroup(
              Yeat_ButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(Yeat_ButtonLayout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(a4)
                  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
          );
  
          jLabel2.setIcon(new javax.swing.ImageIcon("C:\\Users\\ahmed\\OneDrive\\Desktop\\download-removebg-preview (1) - Copy.png")); // NOI18N
  
          jButton10.setBackground(new java.awt.Color(0, 64, 128));
          jButton10.setForeground(new java.awt.Color(255, 255, 255));
          jButton10.setText("back");
          jButton10.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mousePressed(java.awt.event.MouseEvent evt) {
                  jButton10MousePressed(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()
                  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                          .addComponent(Year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addComponent(Semester, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addGap(36, 36, 36)
                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addComponent(Yeat_Button, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                              .addComponent(SemesterButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                      .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                          .addContainerGap()
                          .addComponent(Sec_id, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addComponent(jButton8)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                          .addComponent(jButton10)))
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                  .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addGap(81, 81, 81))
          );
          jPanel1Layout.setVerticalGroup(
              jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(jPanel1Layout.createSequentialGroup()
                  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(jPanel1Layout.createSequentialGroup()
                          .addGap(73, 73, 73)
                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addComponent(Year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                              .addComponent(Semester, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                              .addGroup(jPanel1Layout.createSequentialGroup()
                                  .addComponent(Yeat_Button, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addComponent(SemesterButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                      .addGroup(jPanel1Layout.createSequentialGroup()
                          .addGap(23, 23, 23)
                          .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(Sec_id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                              .addComponent(jButton8)
                              .addComponent(jButton10)))
                      .addGroup(jPanel1Layout.createSequentialGroup()
                          .addContainerGap()
                          .addComponent(jLabel2)))
                  .addContainerGap(15, Short.MAX_VALUE))
          );
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1013, javax.swing.GroupLayout.PREFERRED_SIZE)
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
          );
  
          pack();
      }// </editor-fold>//GEN-END:initComponents
  
      private void newYearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newYearActionPerformed
          // TODO add your handling code here:
      }//GEN-LAST:event_newYearActionPerformed
  
      private void SemesterButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SemesterButtonMouseEntered
          // TODO add your handling code here:
          a6.setForeground(new java.awt.Color(173, 216, 230));
      }//GEN-LAST:event_SemesterButtonMouseEntered
  
      private void SemesterButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SemesterButtonMouseExited
          // TODO add your handling code here:
          a6.setForeground(Color.WHITE);
      }//GEN-LAST:event_SemesterButtonMouseExited
  
      private void SemesterButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SemesterButtonMousePressed
          // TODO add your handling code here:
          Year.setVisible(false);
          Semester.setVisible(true);
      }//GEN-LAST:event_SemesterButtonMousePressed
  
      private void Yeat_ButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Yeat_ButtonMouseEntered
          // TODO add your handling code here:
          a4.setForeground(new java.awt.Color(173, 216, 230));
      }//GEN-LAST:event_Yeat_ButtonMouseEntered
  
      private void Yeat_ButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Yeat_ButtonMouseExited
          // TODO add your handling code here:
          a4.setForeground(Color.WHITE);
  
      }//GEN-LAST:event_Yeat_ButtonMouseExited
  
      private void Yeat_ButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Yeat_ButtonMousePressed
          // TODO add your handling code here:
          Year.setVisible(true);
          Semester.setVisible(false);
      }//GEN-LAST:event_Yeat_ButtonMousePressed
  
      private void jButton10MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton10MousePressed
          // TODO add your handling code here:
          if (Login.adminlogin) {
              systemManag s = new systemManag();
              s.setVisible(true);
              s.setLocationRelativeTo(null);//center
              this.dispose();
          } else {
              InstructorManag s = new InstructorManag();
              s.setVisible(true);
              s.setLocationRelativeTo(null);//center
              this.dispose();
          }
      }//GEN-LAST:event_jButton10MousePressed
  
      private void UpdateYearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UpdateYearButtonActionPerformed
          // TODO add your handling code here:
          // TODO add your handling code here:
          int year = Integer.parseInt(newYear.getText());
          int section_id = Integer.parseInt(Sec_id.getText());
  
  // Database operation
          try (Connection connection = ConnectToDB.getConnection(); java.sql.PreparedStatement preparedStatement = connection.prepareStatement(
                  "UPDATE Section SET YEAR = ? WHERE Section_ID = ?;")) {
  
              // Set values for the prepared statement
              preparedStatement.setInt(1, year);
              preparedStatement.setInt(2, section_id);
  
              // Execute the insert operation
              preparedStatement.executeUpdate();
  
              // Success message
              JOptionPane.showMessageDialog(this, "Section Year Update Successfully");
  
          } catch (SQLException e) {
              Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, "Database error: ", e);
              JOptionPane.showMessageDialog(this, "An error occurred while saving This data. Please try again.");
          }
      }//GEN-LAST:event_UpdateYearButtonActionPerformed
  
      private void UpdateSemesterButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UpdateSemesterButton1ActionPerformed
          // TODO add your handling code here:
          // TODO add your handling code here:
          String semester = sem.getText();
          int section_id = Integer.parseInt(Sec_id.getText());
  
  // Database operation
          try (Connection connection = ConnectToDB.getConnection(); java.sql.PreparedStatement preparedStatement = connection.prepareStatement(
                  "UPDATE Section SET Semester = ? WHERE Section_ID = ?;")) {
  
              // Set values for the prepared statement
              preparedStatement.setString(1, semester);
              preparedStatement.setInt(2, section_id);
  
              // Execute the insert operation
              preparedStatement.executeUpdate();
  
              // Success message
              JOptionPane.showMessageDialog(this, "Section Semester Update Successfully");
  
          } catch (SQLException e) {
              Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, "Database error: ", e);
              JOptionPane.showMessageDialog(this, "An error occurred while saving This data. Please try again.");
          }
      }//GEN-LAST:event_UpdateSemesterButton1ActionPerformed
  
      /**
       * @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(UpdateSection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (InstantiationException ex) {
              java.util.logging.Logger.getLogger(UpdateSection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (IllegalAccessException ex) {
              java.util.logging.Logger.getLogger(UpdateSection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
          } catch (javax.swing.UnsupportedLookAndFeelException ex) {
              java.util.logging.Logger.getLogger(UpdateSection.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 UpdateSection().setVisible(true);
              }
          });
      }
  
      // Variables declaration - do not modify//GEN-BEGIN:variables
      private javax.swing.JTextField Sec_id;
      private javax.swing.JPanel Semester;
      private javax.swing.JPanel SemesterButton;
      private javax.swing.JButton UpdateSemesterButton1;
      private javax.swing.JButton UpdateYearButton;
      private javax.swing.JPanel Year;
      private javax.swing.JPanel Yeat_Button;
      private javax.swing.JLabel a4;
      private javax.swing.JLabel a6;
      private javax.swing.JButton jButton10;
      private javax.swing.JButton jButton8;
      private javax.swing.JLabel jLabel2;
      private javax.swing.JPanel jPanel1;
      private javax.swing.JTextField newYear;
      private javax.swing.JTextField sem;
      // End of variables declaration//GEN-END:variables
  }
  