コード例 #1
0
  public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == b1) {
      try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection con =
            DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123");
        PreparedStatement ps =
            con.prepareStatement("select * from LoginForm where username=? and password=?");
        String UserName = t1.getText();
        String Password = jp1.getText();
        ps.setString(1, UserName);
        ps.setString(2, Password);
        ResultSet rs = ps.executeQuery();
        boolean flag = rs.next();
        if (flag) {
          new Main();
          f.setVisible(false);
        } else {
          JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password");
        }

      } catch (Exception e) {
        System.out.println("Error:" + e);
      }
    } else if (ae.getSource() == b2) {
      t1.setText("");
      jp1.setText("");
    } else if (ae.getSource() == b3) {

      f.setVisible(false);
    }
  }
コード例 #2
0
ファイル: Head.java プロジェクト: thite-amol/payroll
  public void actionPerformed(ActionEvent ae) {

    try {
      if (ae.getSource() == b7) {

        rs = st.executeQuery("select count(*) from employeemaster");
        if (rs.next()) {
          t6.setText(rs.getString(1));
        }

        rs = st.executeQuery("select * from Head");
        if (rs.next()) {
          t1.setText(rs.getString(1));
          t2.setText(rs.getString(2));
          t7.setText(rs.getString(3));
          t4.setText(rs.getString(4));
          t5.setText(rs.getString(5));
          t3.setText(rs.getString(6));
        }
      } else if (ae.getSource() == b6) {
        dispose();
      }

    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, "Error is" + e);
    }
  }
コード例 #3
0
  // --------------------------------------------------------------------------------
  // Name: actionPerformed
  // Abstract: Event handler for control click events
  // --------------------------------------------------------------------------------
  @Override
  public void actionPerformed(ActionEvent aeSource) {
    try {
      //					// btnopenDatabaseConnection
      if (aeSource.getSource() == m_btnOK) btnOK_Click();
      else if (aeSource.getSource() == m_btnCancel) btnCancel_Click();

    } catch (Exception excError) {
      // log and display errors
      CUtilities.WriteLog(excError);
    }
  }
コード例 #4
0
ファイル: MessagePan.java プロジェクト: UlTMATE/Lookout
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();
    if (obj == replyBut) {
      try {
        if (Home.composeDial != null && Home.composeDial.isShowing()) {

        } else {
          Home.composeDial =
              new ComposeMailDialog(
                  msgID, workingSet.getString("mail_addresses"), workingSet.getString("subject"));
        }
      } catch (SQLException sqlExc) {
        sqlExc.printStackTrace();
      }
    } else if (obj == forwardBut) {
      try {
        if (Home.composeDial != null && Home.composeDial.isShowing()) {

        } else {
          Home.composeDial =
              new ComposeMailDialog(
                  msgID,
                  workingSet.getString("subject") + "\n\n" + workingSet.getString("content"));
        }
      } catch (SQLException sqlExc) {
        sqlExc.printStackTrace();
      }
    }
  }
コード例 #5
0
  // event handling
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnok) {
      PreparedStatement pstm;
      ResultSet rs;
      String sql;
      // if no entries has been made and hit ok button throw an error
      // you can do this step using try clause as well
      if ((tf1.getText().equals("") && (tf2.getText().equals("")))) {
        lblmsg.setText("Enter your details ");
        lblmsg.setForeground(Color.magenta);
      } else {

        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection connect = DriverManager.getConnection("jdbc:odbc:student_base");
          System.out.println("Connected to the database");
          pstm = connect.prepareStatement("insert into student_base values(?,?)");
          pstm.setString(1, tf1.getText());
          pstm.setString(2, tf2.getText());
          // execute method to execute the query
          pstm.executeUpdate();
          lblmsg.setText("Details have been added to database");

          // closing the prepared statement  and connection object
          pstm.close();
          connect.close();
        } catch (SQLException sqe) {
          System.out.println("SQl error");
        } catch (ClassNotFoundException cnf) {
          System.out.println("Class not found error");
        }
      }
    }
    // upon clickin button addnew , your textfield will be empty to enternext record
    if (e.getSource() == btnaddnew) {
      tf1.setText("");
      tf2.setText("");
    }

    if (e.getSource() == btnexit) {
      System.exit(1);
    }
  }
コード例 #6
0
  public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == bRes) {
      tname.setText("");
      textra.setText("");
    } else {
      if (it.isSelected()) field = 1;
      else if (civil.isSelected()) field = 2;
      else if (mech.isSelected()) field = 3;

      if (tname.getText().equals("") | textra.getText().equals("") | field == 0)
        JOptionPane.showMessageDialog(null, "Please Fill in All Entries!!");
      else {
        String sal = (String) cbsal.getSelectedItem();

        try {
          // Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          // Connection conn=DriverManager.getConnection("jdbc:odbc:go");
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          Connection conn = DriverManager.getConnection("jdbc:mysql:///go", "root", "");
          Statement pst = conn.createStatement();

          pst.executeUpdate(
              "Insert into company values('"
                  + tname.getText()
                  + "','"
                  + textra.getText()
                  + "','"
                  + (String) sal
                  + "','"
                  + field
                  + "','"
                  + tusr.getText()
                  + "','"
                  + tpwd.getText()
                  + "')");
          conn.close();
          String msg =
              "Your Details are Stored. Login again to View Related applicants!  Thank You!!";
          JOptionPane.showMessageDialog(null, msg);
          setVisible(false);
          login ab = new login();

        } catch (Exception exc) {
          JOptionPane.showMessageDialog(null, tname.getText() + " : " + exc);
          System.exit(0);
        }
      }
    }
  }
コード例 #7
0
  public void actionPerformed(ActionEvent ae) {

    if (ae.getSource() == b) {

      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintable(this);
      boolean ok = job.printDialog();

      if (ok) {
        try {
          job.print();
        } catch (PrinterException pe) {
          System.out.println(pe);
          pe.printStackTrace();
        }
      }
    }

    if (ae.getSource() == back) {
      new remindersub();
      f.dispose();
    }
  }
コード例 #8
0
  public void actionPerformed(ActionEvent ae) {
    String str = ae.getActionCommand();
    if (str.equals("Ok")) {
      String str1 = (String) jcmname.getSelectedItem();

      Connection con = null;
      Statement stat = null;

      if (str1.equals("Pulsar")
          || str1.equals("CT 100")
          || str1.equals("Discover DTS-i")
          || str1.equals("Wave DTS-i")) {
        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          con = DriverManager.getConnection("Jdbc:Odbc:showroom");
          System.out.println("Got Connection :" + con);
          stat = con.createStatement();
          ResultSet rs = stat.executeQuery("select * from vehicle");
          System.out.println("chk1");
          while (rs.next()) {
            if (str1.equals(rs.getString(1))) {

              tfcap.setText("" + rs.getInt(2));
              tfeng.setText("" + rs.getInt(3));
              tfbhp.setText("" + rs.getInt(4));
              tfvolt.setText("" + rs.getInt(5));
              tfrpm.setText("" + rs.getInt(6));
              tfweight.setText("" + rs.getInt(7));
              tfgear.setText("" + rs.getInt(8));
            }
          }

          stat.close();
          con.close();

        } catch (Exception ex) {
        }

      } else {
        JOptionPane.showMessageDialog(
            null, "Please Choose Model Name", "Error", JOptionPane.ERROR_MESSAGE);
      }
    }

    if (str.equals("can")) {
      this.dispose();
      // new menu(1);
    }
  }
コード例 #9
0
ファイル: EchoAWT.java プロジェクト: operationcwal/app
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO action
    Object obj = e.getSource();

    if (obj.equals(jtf) || obj.equals(textin)) {
      // name.setText(" 메시지 입력 ");
      pw.println(jtf.getText());
      jtf.setText("");
    } else if (obj.equals(serveropen)) {
      ServerOpen();
    } else if (obj.equals(clientin) || obj.equals(pi)) {
      ClientIn();
    } else if (obj.equals(conf)) {
      login();
    }
  }
コード例 #10
0
  public void actionPerformed(ActionEvent e) {
    JButton b = (JButton) e.getSource();
    if (b == bu) {
      j14 = new JLabel("NEW IMAGE");
      j14.setBounds(840, 200, 300, 300);
      q.add(j14);

      JFileChooser filechooser = new JFileChooser();
      int result = filechooser.showOpenDialog(this);
      f = filechooser.getSelectedFile();
      try {
        String dir1 = f.getAbsolutePath();
        // setText(dir);
        str = dir1;
        // ResizeImage.resize(dir);
        f = new File(dir1);
      } catch (Exception e1) {
      }
      repaint();
      // b=(JButton)e.getSource();

    }
    if (b == ba) {
      try {
        read();
        patient.add(tadd.getText(), tsym.getText(), f, str);
        JOptionPane.showMessageDialog(null, "Patient ID: " + patient.pid + " Record Added");
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
    if (b == bm) {
      try {
        setVisible(false);
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
  }
コード例 #11
0
 public void actionPerformed(ActionEvent e) {
   MainMenu M = new MainMenu();
   Object source = e.getSource();
   EmployeeNewReservation o = new EmployeeNewReservation();
   EmployeeCheckRoom c = new EmployeeCheckRoom();
   EmployeeCheckOut b = new EmployeeCheckOut();
   if (source == order) {
     o.setEmployeeNewReservation();
     dispose();
   }
   if (source == exit) {
     M.setLoginPage();
     dispose();
   }
   if (source == check) {
     c.setEmployeeCheckRoom();
     dispose();
   }
   if (source == bill) {
     b.setEmployeeCheckOut();
     dispose();
   }
 }
コード例 #12
0
ファイル: BodyPan.java プロジェクト: UlTMATE/Lookout
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();

    if (obj == selectAllCB) {
      Boolean state;
      if (selectAllCB.isSelected()) {
        state = true;
        deleteBut.setVisible(true);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(true);
        }
      } else {
        state = false;
        deleteBut.setVisible(false);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(false);
        }
      }
      for (int i = 0; i < table.getRowCount(); i++) {
        table.setValueAt(state, i, 0);
      }
    } else if (obj == refreshBut || obj == backBut) {
      setContent(Home.titlePan.getTitle());
      backBut.setVisible(false);
    } else if (obj == deleteBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "DELETE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.deleteMessages(selectedMessages, Home.titlePan.getTitle());
          setContent(Home.titlePan.getTitle());
        }
      }
    } else if (obj == restoreBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "RESTORE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.restoreMessages(selectedMessages);
          setContent(Home.titlePan.getTitle());
        }
      }
    }
  }
コード例 #13
0
ファイル: Deta_Ventas_r.java プロジェクト: evangx/POS-store
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == b) {
     if (makeConnection()) {
       if (!t1.getText().equals("")
           & !t2.getText().equals("")
           & !t3.getText().equals("")
           & !t4.getText().equals("")) {
         det dez = new det();
         if (dez.date(t4.getText())) {
           String a = t1.getText();
           String b = t2.getText();
           String c = t3.getText();
           String d = t4.getText();
           String ef = t5.getText();
           try {
             st = cn.createStatement();
             String sql = "insert into detalle_ventas values('";
             sql += a;
             sql += "', '";
             sql += b + "', '" + c + "', '" + d + "', '" + ef;
             sql += "')";
             int eaz = st.executeUpdate(sql);
             javax.swing.JOptionPane.showMessageDialog(
                 null,
                 "Se han creado " + eaz + " registros en la base de datos",
                 "informacion",
                 javax.swing.JOptionPane.INFORMATION_MESSAGE);
             start();
           } catch (SQLException exz) {
             javax.swing.JOptionPane.showMessageDialog(
                 null,
                 "Ha ocurrido un error, favor de checar que la clave no ha sido ingresada ya con anterioridad  \n si el problema persiste contacte con el administrador \nError: "
                     + exz.getSQLState()
                     + ""
                     + exz.getMessage(),
                 "Error",
                 javax.swing.JOptionPane.INFORMATION_MESSAGE);
           } catch (Exception ez) {
             System.out.println(ez.getMessage());
           }
         } else {
           javax.swing.JOptionPane.showMessageDialog(
               null,
               "Favor de llenar la fecha con un formato correcto dd/mm/aaaa",
               "Error!!!",
               javax.swing.JOptionPane.ERROR_MESSAGE);
         }
       } else {
         javax.swing.JOptionPane.showMessageDialog(
             null,
             "Favor de llenar todos los datos correctamente",
             "Error!!!",
             javax.swing.JOptionPane.ERROR_MESSAGE);
       }
     } else {
       javax.swing.JOptionPane.showMessageDialog(
           null,
           "Un error ha ocurrido al intentar conectar con la base de datos, \n reinicie el componente o contacte con el administrador",
           "Error",
           javax.swing.JOptionPane.ERROR_MESSAGE);
     }
   }
   try {
     cn.close();
   } catch (Exception esa) {
     System.out.println(esa.getMessage());
   }
 }
  public void actionPerformed(ActionEvent e) {
    String a, b, c, f, g, h, j, k, l, m, n, o, p, tol = "";

    try {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      con = DriverManager.getConnection("jdbc:odbc:db2");
      stm = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    } catch (Exception error) {
      System.out.println(error);
    }

    if (e.getSource() == student) {
      name = "Student";
      cl.show(pnc, "cstu");
      try {
        rs = stm.executeQuery("Select * from Student");
        rs.next();
        t1.setText(rs.getString(1));
        t2.setText(rs.getString(2));
        t3.setText(rs.getString(3));
        t4.setText(rs.getString(4));
        t5.setText(rs.getString(5));
        t6.setText(rs.getString(6));
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == teacher) {
      name = "Teacher";
      cl.show(pnc, "ctea");
      try {
        rs = stm.executeQuery("Select * from Teacher");
        rs.next();
        t11.setText(rs.getString(1));
        t12.setText(rs.getString(2));
        t13.setText(rs.getString(3));
        t14.setText(rs.getString(4));
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == course) {
      name = "Course";
      cl.show(pnc, "ccou");
      try {
        rs = stm.executeQuery("Select * from Course");
        rs.next();
        t7.setText(rs.getString(1));
        t8.setText(rs.getString(2));
        t9.setText(rs.getString(3));
        t0.setText(rs.getString(4));
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == result) {
      name = "Result";
      cl.show(pnc, "cres");
      try {
        rs = stm.executeQuery("Select * from Result");
        rs.next();
        t15.setText(rs.getString(1));
        t16.setText(rs.getString(2));
        t17.setText(rs.getString(3));
        t18.setText(rs.getString(4));
        t19.setText(rs.getString(5));
        t20.setText(rs.getString(6));
        t21.setText(rs.getString(7));
        t22.setText(rs.getString(8));
        t23.setText(rs.getString(9));
        t24.setText(rs.getString(10));
        t25.setText(rs.getString(11));
        t26.setText(rs.getString(12));
        t27.setText(rs.getString(13));
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == b6) {
      Vector cols = new Vector();
      Vector rows = new Vector();

      if (z == 1) {
        String sql = "Select * from " + co;
        try {
          rs = stm.executeQuery(sql);
          meta = rs.getMetaData();
          for (int i = 1; i <= meta.getColumnCount(); i++) cols.addElement(meta.getColumnName(i));
          while (rs.next()) {
            Vector currow = new Vector();
            for (int i = 1; i <= meta.getColumnCount(); i++) currow.addElement(rs.getString(i));
            rows.addElement(currow);
          }
        } catch (Exception ex) {
          System.out.print(ex);
        }
        tb = new JTable(rows, cols);
        js = new JScrollPane(tb);
        pne2.remove(js);
        pne2.add(blk, "bb");
        cl2.show(pne2, "bb");
        pne2.add(js, "jjs");
        cl2.show(pne2, "jjs");
        pne2.remove(blk);
        z = 0;
      }
    }

    if (e.getSource() == b1) // **** ADD BUTTON ****//
    {
      if (name == "Student") {
        a = t1.getText();
        b = t2.getText();
        c = t3.getText();
        f = t4.getText();
        g = t5.getText();
        h = t6.getText();

        tol =
            "Insert into Student values ('"
                + a
                + "','"
                + b
                + "','"
                + c
                + "','"
                + f
                + "','"
                + g
                + "','"
                + h
                + "')";
      }

      if (name == "Teacher") {
        a = t11.getText();
        b = t12.getText();
        c = t13.getText();
        f = t14.getText();

        tol = "Insert into Teacher values ('" + a + "','" + b + "','" + c + "','" + f + "')";
      }

      if (name == "Course") {
        a = t7.getText();
        b = t8.getText();
        c = t9.getText();
        f = t0.getText();

        tol = "Insert into Course values ('" + a + "','" + b + "','" + c + "','" + f + "')";
      }

      if (name == "Result") {
        a = t15.getText();
        b = t16.getText();
        c = t17.getText();
        f = t18.getText();
        g = t19.getText();
        h = t20.getText();
        j = t21.getText();
        k = t22.getText();
        l = t23.getText();
        m = t24.getText();
        n = t25.getText();
        o = t26.getText();
        p = t27.getText();

        tol =
            "Insert into Result values ('"
                + a
                + "','"
                + b
                + "','"
                + c
                + "','"
                + f
                + "','"
                + g
                + "','"
                + h
                + "','"
                + j
                + "','"
                + k
                + "','"
                + l
                + "','"
                + m
                + "','"
                + n
                + "','"
                + o
                + "','"
                + p
                + "')";
      }
      try {
        stm.executeUpdate(tol);
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == b2) // **** DELETE BUTTON ****//
    {
      if (name == "Student") {
        b = t2.getText();
        tol = "Delete from Student where Id = '" + b + "'";
      }

      if (name == "Teacher") {
        b = t12.getText();
        tol = "Delete from Teacher where Id = '" + b + "'";
      }

      if (name == "Course") {
        b = t8.getText();
        tol = "Delete from Course where Id = '" + b + "'";
      }

      if (name == "Result") {
        b = t16.getText();
        tol = "Delete from Result where Code = '" + b + "'";
      }
      try {
        stm.executeUpdate(tol);
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == b3) // **** UPDATE BUTTON ****//
    {
      if (name == "Student") {
        a = t1.getText();
        b = t2.getText();
        c = t3.getText();
        f = t4.getText();
        g = t5.getText();
        h = t6.getText();

        tol =
            "Update Student set Name = '"
                + a
                + "', ID = '"
                + b
                + "', Dept = '"
                + c
                + "', CGPA = '"
                + f
                + "', Address = '"
                + g
                + "', Cell = '"
                + h
                + "' where ID = '"
                + b
                + "'";
      }

      if (name == "Teacher") {
        a = t11.getText();
        b = t12.getText();
        c = t13.getText();
        f = t14.getText();

        tol =
            "Update Teacher set Name = '"
                + a
                + "', ID = '"
                + b
                + "', Dept = '"
                + c
                + "', Course = '"
                + f
                + "' where ID = '"
                + b
                + "'";
      }

      if (name == "Course") {
        a = t7.getText();
        b = t8.getText();
        c = t9.getText();
        f = t0.getText();

        tol =
            "Update Course set Name = '"
                + a
                + "', Code = '"
                + b
                + "', Credit = '"
                + c
                + "', Prerecusite = '"
                + f
                + "' where Code = '"
                + b
                + "'";
      }

      if (name == "Result") {
        a = t15.getText();
        b = t16.getText();
        c = t17.getText();
        f = t18.getText();
        g = t19.getText();
        h = t20.getText();
        j = t21.getText();
        k = t22.getText();
        l = t23.getText();
        m = t24.getText();
        n = t25.getText();
        o = t26.getText();
        p = t27.getText();

        tol =
            "Update Result set Course = '"
                + a
                + "', Code = '"
                + b
                + "', Credit = '"
                + c
                + "', A = '"
                + f
                + "', B+ = '"
                + g
                + "', B = '"
                + h
                + "', C+ = '"
                + j
                + "', C = '"
                + k
                + "', D+ = '"
                + l
                + "', D = '"
                + m
                + "', F = '"
                + n
                + "', I = '"
                + o
                + "', W = '"
                + p
                + "' where Code = '"
                + b
                + "'";
        // JOptionPane.showMessageDialog(null,tol,null,JOptionPane.PLAIN_MESSAGE);
        // tol = "Update Result set Course = '"+a+"', Code = '"+b+"', Credit = '"+c+"' where Code =
        // '"+b+"'";
      }
      try {
        stm.executeUpdate(tol);
      } catch (Exception error) {
        System.out.println(error);
      }
    }

    if (e.getSource() == b4) // **** NEXT BUTTON ****//
    {
      if (name == "Student") {
        try {
          if (rs.next()) {
            t1.setText(rs.getString(1));
            t2.setText(rs.getString(2));
            t3.setText(rs.getString(3));
            t4.setText(rs.getString(4));
            t5.setText(rs.getString(5));
            t6.setText(rs.getString(6));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }

      if (name == "Teacher") {
        try {
          if (rs.next()) {
            t11.setText(rs.getString(1));
            t12.setText(rs.getString(2));
            t13.setText(rs.getString(3));
            t14.setText(rs.getString(4));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }

      if (name == "Course") {
        try {
          if (rs.next()) {
            t7.setText(rs.getString(1));
            t8.setText(rs.getString(2));
            t9.setText(rs.getString(3));
            t0.setText(rs.getString(4));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }

      if (name == "Result") {
        try {
          if (rs.next()) {
            t15.setText(rs.getString(1));
            t16.setText(rs.getString(2));
            t17.setText(rs.getString(3));
            t18.setText(rs.getString(4));
            t19.setText(rs.getString(5));
            t20.setText(rs.getString(6));
            t21.setText(rs.getString(7));
            t22.setText(rs.getString(8));
            t23.setText(rs.getString(9));
            t24.setText(rs.getString(10));
            t25.setText(rs.getString(11));
            t26.setText(rs.getString(12));
            t27.setText(rs.getString(13));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }
    }

    if (e.getSource() == b5) // **** PREVIOUS BUTTON ****//
    {
      if (name == "Student") {
        try {
          if (rs.previous()) {
            t1.setText(rs.getString(1));
            t2.setText(rs.getString(2));
            t3.setText(rs.getString(3));
            t4.setText(rs.getString(4));
            t5.setText(rs.getString(5));
            t6.setText(rs.getString(6));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }

      if (name == "Teacher") {
        try {
          if (rs.previous()) {
            t11.setText(rs.getString(1));
            t12.setText(rs.getString(2));
            t13.setText(rs.getString(3));
            t14.setText(rs.getString(4));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }

      if (name == "Course") {
        try {
          if (rs.previous()) {
            t7.setText(rs.getString(1));
            t8.setText(rs.getString(2));
            t9.setText(rs.getString(3));
            t0.setText(rs.getString(4));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }

      if (name == "Result") {
        try {
          if (rs.previous()) {
            t15.setText(rs.getString(1));
            t16.setText(rs.getString(2));
            t17.setText(rs.getString(3));
            t18.setText(rs.getString(4));
            t19.setText(rs.getString(5));
            t20.setText(rs.getString(6));
            t21.setText(rs.getString(7));
            t22.setText(rs.getString(8));
            t23.setText(rs.getString(9));
            t24.setText(rs.getString(10));
            t25.setText(rs.getString(11));
            t26.setText(rs.getString(12));
            t27.setText(rs.getString(13));
          }
        } catch (Exception error) {
          System.out.println(error);
        }
      }
    }
  }
コード例 #15
0
ファイル: mupdate.java プロジェクト: ayushisrvstv/POS
  public void actionPerformed(ActionEvent ae) {

    String s1 = ae.getActionCommand();

    if (s1.equals("Calendar")) {
      // DatePicker dp=new DatePicker(f);
      // dp.displayDate();
      // f.getContentPane().add(p);

      b3.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              t6.setText(new DatePicker(f).setPickedDate());
            }
          });

    } else if (s1.equals("LogOut")) {
      f.dispose();
      start p = new start();
      p.method();

    } else if (s1.equals("Search")) {

      try {
        String data = t1.getSelectedItem();
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:raman1");
        Statement stm = con.createStatement();
        ResultSet rs = stm.executeQuery("select * from mprofile  where Manager_Id='" + data + "' ");
        while (rs.next()) {
          String a2 = rs.getString(1);
          t2.setText(a2);
          String a3 = rs.getString(2);
          t3.setText(a3);
          String a4 = rs.getString(3);
          t4.setText(a4);

          String a5 = rs.getString(4);
          t5.setText(a5);

          String a6 = rs.getString(6);
          t6.setText(a6);

          String a7 = rs.getString(7);
          t7.setText(a7);

          String a8 = rs.getString(8);
          t8.setText(a8);

          String a9 = rs.getString(9);
          t9.setText(a9);

          String a10 = rs.getString(10);
          t10.setText(a10);

          p.add(l3);
          p.add(t2);
          p.add(l4);
          p.add(t3);
          p.add(l5);
          p.add(t4);
          p.add(l6);
          p.add(t5);
          p.add(l7);
          p.add(c1);
          p.add(c2);
          p.add(l8);
          p.add(t6);
          p.add(l9);
          p.add(t7);
          p.add(l10);
          p.add(t8);
          p.add(l11);
          p.add(t9);
          p.add(l12);
          p.add(t10);
          p.add(b2);
          p.add(b3);
          p.add(b4);
        }
      } catch (Exception e) {
      }

    } else if (s1.equals("Update")) {

      String y2 = t2.getText();
      String y3 = t3.getText();
      String update_id = t4.getText();
      String y4 = t5.getText();
      String y6 = t6.getText();
      String y7 = t7.getText();
      String y8 = t8.getText();
      String y9 = t9.getText();
      String y10 = t10.getText();
      try {
        String y = t1.getSelectedItem();
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:raman1");

        PreparedStatement ps =
            con.prepareStatement(
                "update mprofile  set Location=? , E_Mail_Id=? ,Contact_No =?, Address=?, D_O_B=?,Gender=?, Password=?, Manager_Id=?,manager_father=?,manager_name=? where  Manager_Id='"
                    + y
                    + "'  ");

        ps.setString(1, y10);
        ps.setString(2, y9);
        ps.setString(3, y8);
        ps.setString(4, y7);
        ps.setString(5, y6);
        ps.setString(6, g);
        ps.setString(7, y4);
        ps.setString(8, update_id);
        ps.setString(9, y3);
        ps.setString(10, y2);

        ps.executeUpdate();
        JOptionPane.showMessageDialog(p, "data has been updated");
        f.dispose();
        project p = new project();
        p.method();
      } catch (Exception e) {
        System.out.println(e);
      }
    } else if (s1.equals("Close")) {
      f.dispose();
    } else {
      f.dispose();
      project p = new project();
      p.method();
    }
  }
コード例 #16
0
  public void actionPerformed(ActionEvent ev) {

    String s = ev.getActionCommand();

    if (s == null) {
      if (ev.getSource() instanceof JMenuItem) {
        JMenuItem i;

        s = ((JMenuItem) ev.getSource()).getText();
      }
    }

    /*
    // button replace by toolbar
            if (s.equals("Execute")) {
                execute();
            } else
    */
    if (s.equals("Exit")) {
      windowClosing(null);
    } else if (s.equals("Transfer")) {
      Transfer.work(null);
    } else if (s.equals("Dump")) {
      Transfer.work(new String[] {"-d"});
    } else if (s.equals("Restore")) {
      Transfer.work(new String[] {"-r"});
    } else if (s.equals("Logging on")) {
      javaSystem.setLogToSystem(true);
    } else if (s.equals("Logging off")) {
      javaSystem.setLogToSystem(false);
    } else if (s.equals("Refresh Tree")) {
      refreshTree();
    } else if (s.startsWith("#")) {
      int i = Integer.parseInt(s.substring(1));

      txtCommand.setText(sRecent[i]);
    } else if (s.equals("Connect...")) {
      connect(ConnectionDialogSwing.createConnection(fMain, "Connect"));
      refreshTree();
    } else if (s.equals("Results in Grid")) {
      iResult = 0;

      pResult.removeAll();
      pResult.add(gScrollPane, BorderLayout.CENTER);
      pResult.doLayout();
      gResult.fireTableChanged(null);
      pResult.repaint();
    } else if (s.equals("Open Script...")) {
      JFileChooser f = new JFileChooser(".");

      f.setDialogTitle("Open Script...");

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setCurrentDirectory(new File(defDirectory));
      }

      int option = f.showOpenDialog(fMain);

      if (option == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();

        if (file != null) {
          StringBuffer buf = new StringBuffer();

          ifHuge = DatabaseManagerCommon.readFile(file.getAbsolutePath());

          if (4096 <= ifHuge.length()) {
            buf.append("This huge file cannot be edited. Please execute\n");
            txtCommand.setText(buf.toString());
          } else {
            txtCommand.setText(ifHuge);
          }
        }
      }
    } else if (s.equals("Save Script...")) {
      JFileChooser f = new JFileChooser(".");

      f.setDialogTitle("Save Script");

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setCurrentDirectory(new File(defDirectory));
      }

      int option = f.showSaveDialog(fMain);

      if (option == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();

        if (file != null) {
          DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtCommand.getText());
        }
      }
    } else if (s.equals("Save Result...")) {
      JFileChooser f = new JFileChooser(".");

      f.setDialogTitle("Save Result...");

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setCurrentDirectory(new File(defDirectory));
      }

      int option = f.showSaveDialog(fMain);

      if (option == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();

        if (file != null) {
          showResultInText();
          DatabaseManagerCommon.writeFile(file.getAbsolutePath(), txtResult.getText());
        }
      }
    } else if (s.equals("Results in Text")) {
      iResult = 1;

      pResult.removeAll();
      pResult.add(txtResultScroll, BorderLayout.CENTER);
      pResult.doLayout();
      showResultInText();
      pResult.repaint();
    } else if (s.equals("AutoCommit on")) {
      try {
        cConn.setAutoCommit(true);
      } catch (SQLException e) {
      }
    } else if (s.equals("AutoCommit off")) {
      try {
        cConn.setAutoCommit(false);
      } catch (SQLException e) {
      }
    } else if (s.equals("Commit")) {
      try {
        cConn.commit();
      } catch (SQLException e) {
      }
    } else if (s.equals("Insert test data")) {
      insertTestData();
    } else if (s.equals("Rollback")) {
      try {
        cConn.rollback();
      } catch (SQLException e) {
      }
    } else if (s.equals("Disable MaxRows")) {
      try {
        sStatement.setMaxRows(0);
      } catch (SQLException e) {
      }
    } else if (s.equals("Set MaxRows to 100")) {
      try {
        sStatement.setMaxRows(100);
      } catch (SQLException e) {
      }
    } else if (s.equals("SELECT")) {
      showHelp(DatabaseManagerCommon.selectHelp);
    } else if (s.equals("INSERT")) {
      showHelp(DatabaseManagerCommon.insertHelp);
    } else if (s.equals("UPDATE")) {
      showHelp(DatabaseManagerCommon.updateHelp);
    } else if (s.equals("DELETE")) {
      showHelp(DatabaseManagerCommon.deleteHelp);
    } else if (s.equals("CREATE TABLE")) {
      showHelp(DatabaseManagerCommon.createTableHelp);
    } else if (s.equals("DROP TABLE")) {
      showHelp(DatabaseManagerCommon.dropTableHelp);
    } else if (s.equals("CREATE INDEX")) {
      showHelp(DatabaseManagerCommon.createIndexHelp);
    } else if (s.equals("DROP INDEX")) {
      showHelp(DatabaseManagerCommon.dropIndexHelp);
    } else if (s.equals("CHECKPOINT")) {
      showHelp(DatabaseManagerCommon.checkpointHelp);
    } else if (s.equals("SCRIPT")) {
      showHelp(DatabaseManagerCommon.scriptHelp);
    } else if (s.equals("SHUTDOWN")) {
      showHelp(DatabaseManagerCommon.shutdownHelp);
    } else if (s.equals("SET")) {
      showHelp(DatabaseManagerCommon.setHelp);
    } else if (s.equals("Test Script")) {
      showHelp(DatabaseManagerCommon.testHelp);
    }
  }
コード例 #17
0
  public void actionPerformed(ActionEvent a) {

    int code = 0;
    String roomtypeCompare_arr = null;
    String roomtypeCompare_dep = null;
    if ("book".equals(a.getActionCommand())) {
      try {
        Class.forName("com.mysql.jdbc.Driver");

        // Database connection information. Please note that when porting the code, you must have
        // the jdbc Driver installed where the code is running.
        Connection con =
            DriverManager.getConnection(
                "jdbc:mysql://67.20.111.85:3306/jeehtove_caliking?relaxAutoCommit=true",
                "jeehtove_ck",
                "Z_^PBBZT+kcy");

        // The SELECT query
        String query_arr =
            "SELECT * from reservations WHERE checkin BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";
        String query_dep =
            "SELECT * from reservations WHERE checkout BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";

        Statement stmt_arr = con.createStatement();
        Statement stmt_dep = con.createStatement();
        Statement stmt_insert = con.createStatement();
        ResultSet result_arr = stmt_arr.executeQuery(query_arr);
        ResultSet result_dep = stmt_dep.executeQuery(query_dep);

        // Get room type from radio buttons
        String room_type;
        if (standardRoom.isSelected()) {
          room_type = "Standard";
          code = 1;
        } else if (familyRoom.isSelected()) {
          room_type = "Family";
          code = 2;
        } else {
          room_type = "Suite";
          code = 3;
        }

        bookRoom();
        // ResultSet rs=stmt.executeQuery("select * from emp");
        /*if (!result_arr.next() && !result_dep.next()){

        	bookRoom();

        	//Query Prep for checking for open rooms
        	/*String query_checkrooms = "SELECT * FROM makereservation_rooms WHERE type = '" + code + "' AND booked = '0';";
        	Statement stmt_checkrooms = con.createStatement();
        	ResultSet checkrooms = stmt_checkrooms.executeQuery(query_checkrooms);

        	if (checkrooms.next()){
        	String getroomnumber = checkrooms.getString("room");
        	String insert = "INSERT INTO `reservations` VALUES ('" + getroomnumber + "', '" +  checkindateField.getText() + "', '" +  checkoutdateField.getText() + "',  '" + room_type + "',  '" + nameField.getText() + "');";
        	String bookroom = "UPDATE `makereservation_rooms` SET booked = '1' WHERE room = '" + getroomnumber + "';";
        	//System.out.println(insert);
        	int rs=stmt_insert.executeUpdate(insert);
        	int cr=stmt_checkrooms.executeUpdate(bookroom);
        	con.commit();
        	System.out.println("Room Booked!");
        }

        	else System.out.println("All " + room_type + " rooms are booked for the time requested.");
        }

        else {
        	if (result_arr.next()){
        		roomtypeCompare_arr = result_arr.getString("type");
        		System.out.println("(arrival) Does " + roomtypeCompare_arr + " equal " + room_type + "?");
        		if (roomtypeCompare_arr.equals(room_type)){
        			String  checkindateDB_arr = result_arr.getString("checkin");
        			String  checkoutdateDB_arr = result_arr.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_arr + " that checks out on " +  checkoutdateDB_arr + ". Please select another date.");
        		}

        		else {

        			System.out.println("Room Booked!");
        		}
        	}
        }
        	//System.out.println(query_dep);
        	if (result_dep.next()){
        		roomtypeCompare_dep = result_dep.getString("type");
        		System.out.println("(departure) Does " + roomtypeCompare_dep + " equal " + room_type + "?");
        		if (roomtypeCompare_dep.equals(room_type)){
        			String  checkindateDB_dep = result_dep.getString("checkin");
        			String  checkoutdateDB_dep = result_dep.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_dep + " that checks out on " +  checkoutdateDB_dep + ". Please select another date.");
        		}

        		else {
        			System.out.println("Room Booked!");
        		}
        	}*/
        con.close();

      } catch (Exception e) {
        System.out.println(e);
      }
    }
  }
コード例 #18
0
ファイル: QueryDB.java プロジェクト: chenyuguxing/utils
  public void actionPerformed(ActionEvent evt) {
    String arg = evt.getActionCommand();
    if (arg.equals("Query")) { // 用户按下Query按钮
      ResultSet rs = null;
      try {
        String author = (String) authors.getSelectedItem();
        String publisher = (String) publishers.getSelectedItem();
        if (!author.equals("Any") && !publisher.equals("Any")) {
          if (authorPublisherQueryStmt == null) {
            //  根据用户选择的出版社名和作者名查询相关的书名和书价
            String authorPublisherQuery =
                "SELECT Books.Price, Books.Title "
                    + "FROM Books, BooksAuthors, Authors, Publishers "
                    + "WHERE Authors.Author_Id = BooksAuthors.Author_Id AND "
                    + "BooksAuthors.ISBN = Books.ISBN AND "
                    + "Books.Publisher_Id = Publishers.Publisher_Id AND "
                    + "Authors.Name = ? AND "
                    + "Publishers.Name = ?";
            authorPublisherQueryStmt = con.prepareStatement(authorPublisherQuery);
          }

          authorPublisherQueryStmt.setString(1, author);
          authorPublisherQueryStmt.setString(2, publisher);
          rs = authorPublisherQueryStmt.executeQuery();
        } else if (!author.equals("Any") && publisher.equals("Any")) {
          if (authorQueryStmt == null) {
            //  根据用户选择的作者名查询相关的书名和书价
            String authorQuery =
                "SELECT Books.Price, Books.Title "
                    + "FROM Books, BooksAuthors, Authors "
                    + "WHERE Authors.Author_Id = BooksAuthors.Author_Id AND "
                    + "BooksAuthors.ISBN = Books.ISBN AND "
                    + "Authors.Name = ?";
            authorQueryStmt = con.prepareStatement(authorQuery);
          }
          authorQueryStmt.setString(1, author);
          rs = authorQueryStmt.executeQuery();
        } else if (author.equals("Any") && !publisher.equals("Any")) {
          if (publisherQueryStmt == null) {
            //  根据用户选择的出版社名查询相关的书名和书价
            String publisherQuery =
                "SELECT Books.Price, Books.Title "
                    + "FROM Books, Publishers "
                    + "WHERE Books.Publisher_Id = Publishers.Publisher_Id AND "
                    + "Publishers.Name = ?";
            publisherQueryStmt = con.prepareStatement(publisherQuery);
          }
          publisherQueryStmt.setString(1, publisher);
          rs = publisherQueryStmt.executeQuery();
        } else {
          if (allQueryStmt == null) {
            // 若用户未选任何信息,则输出所有的书名和对应的书价
            String allQuery = "SELECT Books.Price, Books.Title FROM Books";
            allQueryStmt = con.prepareStatement(allQuery);
          }
          rs = allQueryStmt.executeQuery();
        }

        result.setText("");
        while (rs.next()) result.append(rs.getString(1) + " | " + rs.getString(2) + "\n");
        rs.close();
      } catch (Exception e) {
        result.setText("Error " + e);
      }
    } else if (arg.equals("Change prices")) { //  用户选择“Change prices”按钮
      String publisher = (String) publishers.getSelectedItem();
      if (publisher.equals("Any")) result.setText("I am sorry, but I cannot do that.");
      else
        try {
          // 根据用户输入的新的书价更新Books表的数据
          String updateStatement =
              "UPDATE Books "
                  + "SET Price = Price + "
                  + priceChange.getText()
                  + " WHERE Books.Publisher_Id = "
                  + "(SELECT Publisher_Id FROM Publishers WHERE Name = '"
                  + publisher
                  + "')";
          int r = stmt.executeUpdate(updateStatement);
          result.setText(r + " records updated.");
        } catch (Exception e) {
          result.setText("Error " + e);
        }
    }
  }
コード例 #19
0
  public void actionPerformed(ActionEvent event) {

    // if clear button is pressed, clear all fields
    if (event.getSource() == clear_button) {
      // erase all fields

      taskname_field.setText("");
      taskdesc_field.setText("");

      priority_checkbox.setSelected(false);
      numberofdays_field.setText("");
      // isallocatedcheckbox.setSelected(false);
      duedate_field.setText("");
    }

    // if submit button is pressed, save all data onto database
    if (event.getSource() == submit_button) {
      try {
        {
          Calendar calendar = Calendar.getInstance();
          calendar.setTime(new Date()); // set to current date
          calendar.add(
              Calendar.DAY_OF_MONTH,
              Integer.parseInt(this.numberofdays_field.getText())
                  - 1); // add days required... then:
          // ^ subtract one day, because if task is created today and allocated tomorrow for one
          // day,
          // then it should be done by end of day tomorrow
          Date date = calendar.getTime(); // (see next *1) use this date to be the earliest
          // because of expected task duration

          /*This is a constraint
           * the date and the length of days that user expected to take
           * if not feasible then the program will say so
           * */
          // method compares the current date and the date that was entered by the user
          if (this.task_idfield.getText().length() != 7 // check chars
              || this.taskname_field.getText().length() > 50 // check chars
              || this.taskdesc_field.getText().length() > 50
              || ((Date) this.duedate_field.getValue()).compareTo(date)
                  < 0 // check that the date is possible (see last *1)
              || this.numberofdays_field.getText().length() > 2
              || this.numberofdays_field.getText().length() == 0 // check number of digits
              || Integer.parseInt(this.numberofdays_field.getText())
                  < 1) // check number of days required for task
          {
            JOptionPane.showMessageDialog(
                this,
                "Task ID has to be 7 chars; "
                    + "\n"
                    + "Description <= 50 chars; "
                    + "\n"
                    + "Because the expected duration of the task is "
                    + Integer.parseInt(this.numberofdays_field.getText())
                    + " days, the due date cannot be earlier than: "
                    + new StringBuffer(new SimpleDateFormat("dd/MM/yyyy").format(date)).toString()
                    + "; "
                    + "\n"
                    + "Task duration must be 2 digit number maximum and must be an integer greater than 0");
          } else

          // check if taskid_field is equals to any of the fields on the database

          if (task_idfield.equals("")) {
            JOptionPane.showMessageDialog(
                this, "Please insert an identification number for a task");

          } else // add constraint and tell customer to enter 7 values
          if (taskname_field.equals("")) {
            JOptionPane.showMessageDialog(this, "Please insert a name to identity the task");

          } else {

            // get all inputs from user inputs and store in variables
            taskid_input = task_idfield.getText();
            taskname_input = taskname_field.getText();
            taskdesc_input = taskdesc_field.getText();

            if (priority_checkbox.isSelected()) {
              priority_input = 1;
            } else {
              priority_input = 0;
            }

            // create and store date from user input
            date = (Date) duedate_field.getValue();

            // store number of days input from user
            numberofdays_input = Integer.parseInt(numberofdays_field.getText());

            // 	String[] column_names = { "Task ID", "Task Name", "Task Description", "Task
            // Priority", "Due Date", "Number of Days", "Is Allocated" , "Unallocateable" };

            task = new Object[8];
            task[0] = taskid_input;
            task[1] = taskname_input;
            task[2] = taskdesc_input;
            task[3] = priority_input;
            task[4] = date;
            task[5] = numberofdays_input;
            task[6] = 0;
            task[7] = 0;

            try {
              //
              SqlConnection.connect();

              SqlConnection.ps =
                  SqlConnection.connection.prepareStatement(
                      "INSERT  INTO TASK VALUES (?,?,?,?,?,?,?,?)");

              SqlConnection.ps.setString(1, taskid_input);
              SqlConnection.ps.setString(2, taskname_input);
              SqlConnection.ps.setString(3, taskdesc_input);
              SqlConnection.ps.setInt(4, priority_input);
              SqlConnection.ps.setDate(5, new java.sql.Date(date.getTime()));
              SqlConnection.ps.setInt(6, numberofdays_input);
              SqlConnection.ps.setInt(7, 0);
              SqlConnection.ps.setInt(8, 0);

              SqlConnection.ps.executeUpdate();

              // now enter skills into TASK SKILL database
              for (int i = 0; i < skill_list.size(); i++) {
                if (skill_list.get(i).isSelected()) {
                  String skillid = skill_list.get(i).getText();
                  SqlConnection.statement.executeUpdate(
                      "INSERT INTO TASKSKILL VALUES ('" + taskid_input + "', '" + skillid + "')");
                }
              }

              SqlConnection.ps.close();
            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            // SqlConnection.ps.close();
            SqlConnection.closeConnection();
            this.setVisible(false);
          }
        }

      } catch (Exception exc) {
        JOptionPane.showMessageDialog(
            this,
            "Check your inputs:"
                + "\n"
                + "Priority has to be a 1-digit number;"
                + "\n"
                + "Date has to be in the format dd/MM/yyyy;"
                + "\n"
                + "Task length has to be 2-digit number");
        System.out.println(exc);
      }
    }
    // display dialog box asking task manager if they want to quit,
    // if task manager does not want to quit, go back to adding more tasks
    // if customer quits, close the dialog box and the frame

    // now close the window after saving
  }
コード例 #20
0
ファイル: Summary.java プロジェクト: mrwarni/Diagnostic-Lab
 public void actionPerformed(ActionEvent ae) {
   if (ae.getSource() == exit) {
     this.dispose();
     new HomePage();
   }
 }
コード例 #21
0
  /**
   * Method declaration
   *
   * @param ev
   */
  public void actionPerformed(ActionEvent ev) {

    String s = ev.getActionCommand();

    if (s == null) {
      if (ev.getSource() instanceof MenuItem) {
        MenuItem i;

        s = ((MenuItem) ev.getSource()).getLabel();
      }
    }

    if (s.equals("Execute")) {
      execute();
    } else if (s.equals("Exit")) {
      windowClosing(null);
    } else if (s.equals("Transfer")) {
      Transfer.work(null);
    } else if (s.equals("Dump")) {
      Transfer.work(new String[] {"-d"});

      /* NB - 26052002 Restore is not implemented yet in the transfer tool */
      /*
              } else if (s.equals("Restore")) {
                  Transfer.work(new String[]{"-r"});
      */
    } else if (s.equals("Logging on")) {
      jdbcSystem.setLogToSystem(true);
    } else if (s.equals("Logging off")) {
      jdbcSystem.setLogToSystem(false);
    } else if (s.equals("Refresh Tree")) {
      refreshTree();
    } else if (s.startsWith("#")) {
      int i = Integer.parseInt(s.substring(1));

      txtCommand.setText(sRecent[i]);
    } else if (s.equals("Connect...")) {
      connect(ConnectionDialog.createConnection(fMain, "Connect"));
      refreshTree();
    } else if (s.equals("Results in Grid")) {
      iResult = 0;

      pResult.removeAll();
      pResult.add("Center", gResult);
      pResult.doLayout();
    } else if (s.equals("Open Script...")) {
      FileDialog f = new FileDialog(fMain, "Open Script", FileDialog.LOAD);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        txtCommand.setText(DatabaseManagerCommon.readFile(f.getDirectory() + file));
      }
    } else if (s.equals("Save Script...")) {
      FileDialog f = new FileDialog(fMain, "Save Script", FileDialog.SAVE);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtCommand.getText());
      }
    } else if (s.equals("Save Result...")) {
      FileDialog f = new FileDialog(fMain, "Save Result", FileDialog.SAVE);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        showResultInText();
        DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtResult.getText());
      }
    } else if (s.equals("Results in Text")) {
      iResult = 1;

      pResult.removeAll();
      pResult.add("Center", txtResult);
      pResult.doLayout();
      showResultInText();
    } else if (s.equals("AutoCommit on")) {
      try {
        cConn.setAutoCommit(true);
      } catch (SQLException e) {
      }
    } else if (s.equals("AutoCommit off")) {
      try {
        cConn.setAutoCommit(false);
      } catch (SQLException e) {
      }
    } else if (s.equals("Enlarge Tree")) {
      Dimension d = tTree.getMinimumSize();

      d.width += 20;

      tTree.setMinimumSize(d);
      fMain.pack();
    } else if (s.equals("Shrink Tree")) {
      Dimension d = tTree.getMinimumSize();

      d.width -= 20;

      if (d.width >= 0) {
        tTree.setMinimumSize(d);
      }

      fMain.pack();
    } else if (s.equals("Enlarge Command")) {
      txtCommand.setRows(txtCommand.getRows() + 1);
      fMain.pack();
    } else if (s.equals("Shrink Command")) {
      int i = txtCommand.getRows() - 1;

      txtCommand.setRows(i < 1 ? 1 : i);
      fMain.pack();
    } else if (s.equals("Commit")) {
      try {
        cConn.commit();
      } catch (SQLException e) {
      }
    } else if (s.equals("Insert test data")) {
      insertTestData();
    } else if (s.equals("Rollback")) {
      try {
        cConn.rollback();
      } catch (SQLException e) {
      }
    } else if (s.equals("Disable MaxRows")) {
      try {
        sStatement.setMaxRows(0);
      } catch (SQLException e) {
      }
    } else if (s.equals("Set MaxRows to 100")) {
      try {
        sStatement.setMaxRows(100);
      } catch (SQLException e) {
      }
    } else if (s.equals("SELECT")) {
      showHelp(DatabaseManagerCommon.selectHelp);
    } else if (s.equals("INSERT")) {
      showHelp(DatabaseManagerCommon.insertHelp);
    } else if (s.equals("UPDATE")) {
      showHelp(DatabaseManagerCommon.updateHelp);
    } else if (s.equals("DELETE")) {
      showHelp(DatabaseManagerCommon.deleteHelp);
    } else if (s.equals("CREATE TABLE")) {
      showHelp(DatabaseManagerCommon.createTableHelp);
    } else if (s.equals("DROP TABLE")) {
      showHelp(DatabaseManagerCommon.dropTableHelp);
    } else if (s.equals("CREATE INDEX")) {
      showHelp(DatabaseManagerCommon.createIndexHelp);
    } else if (s.equals("DROP INDEX")) {
      showHelp(DatabaseManagerCommon.dropIndexHelp);
    } else if (s.equals("CHECKPOINT")) {
      showHelp(DatabaseManagerCommon.checkpointHelp);
    } else if (s.equals("SCRIPT")) {
      showHelp(DatabaseManagerCommon.scriptHelp);
    } else if (s.equals("SHUTDOWN")) {
      showHelp(DatabaseManagerCommon.shutdownHelp);
    } else if (s.equals("SET")) {
      showHelp(DatabaseManagerCommon.setHelp);
    } else if (s.equals("Test Script")) {
      showHelp(DatabaseManagerCommon.testHelp);
    }
  }
コード例 #22
0
 /**
  * ************************************************************************ Action Listener
  *
  * @param e event
  */
 public void actionPerformed(ActionEvent e) {
   setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   if (e.getSource() == bDisassociate) cmd_disassociate();
   else if (e.getSource() == bNewProduct) cmd_newProduct();
 } //  actionPerformed