Exemplo n.º 1
0
  public void showTables() {
    if (this.tab_PosList.getSelectedRow() == 0) {
      this.btn_PosDel.setEnabled(false);
      this.btn_PosUpdate.setEnabled(false);
      this.btn_StaffPosUpdata.setEnabled(true);
    } else {
      this.btn_PosDel.setEnabled(true);
      this.btn_PosUpdate.setEnabled(true);
      this.btn_StaffPosUpdata.setEnabled(true);
    }

    //        String tabSelect = tab_PosList.getValueAt(this.tab_PosList.getSelectedRow(),
    // 0).toString();
    String sql = "";
    ResultSet rs_Pos = null;

    try {
      if (tab_PosList.getSelectedRow() == 0) {
        sql =
            " SELECT staff_info.s_no AS NO, "
                + "concat(staff_info.firstname, staff_info.lastName) AS Name, "
                + "staff_info.nia_no AS ID_NO, "
                + "staff_info.s_id AS Account "
                + " FROM staff_info "
                + " WHERE staff_info.posi_guid IS null"
                + " AND staff_info.exist = 1";
      } else if (tab_PosList.getSelectedRow() != 0 && tab_PosList.getSelectedRow() != -1) {
        sql =
            " SELECT staff_info.s_no AS NO, "
                + "concat(staff_info.firstname, staff_info.lastName) AS Name, "
                + "staff_info.nia_no AS ID_NO, "
                + "staff_info.s_id AS Account "
                + " FROM staff_info,position "
                + " WHERE staff_info.posi_guid = position.guid "
                + " AND position.name = '"
                + tab_PosList.getValueAt(this.tab_PosList.getSelectedRow(), 0).toString()
                + "' "
                + " AND staff_info.exist = 1 ORDER BY s_id";
      }
      rs_Pos = DBC.executeQuery(sql);
      if (rs_Pos.next()) {
        tab_PosDetail.setModel(HISModel.getModel(rs_Pos, null));
      } else {
        tab_PosDetail.setModel(
            getModle(
                new String[] {"Message"},
                new String[][] {{paragraph.getLanguage(line, "NOFORMATION")}})); // 將表格清空
      }
    } catch (SQLException e) {
      ErrorMessage.setData(
          "Staff",
          "Frm_ Position",
          "showTables()",
          e.toString().substring(e.toString().lastIndexOf(".") + 1, e.toString().length()));
      System.out.println(e);
    }
  }
Exemplo n.º 2
0
 public void initTables() {
   ResultSet rs = null;
   try {
     rs = DBC.executeQuery("SELECT name FROM position");
     this.tab_PosList.setModel(
         new TableModels(rs, new String[] {paragraph.getLanguage(line, "POSITIONNAME")}));
   } catch (SQLException e) {
     ErrorMessage.setData(
         "Staff",
         "Frm_ Position",
         "initTables()",
         e.toString().substring(e.toString().lastIndexOf(".") + 1, e.toString().length()));
     System.out.println(e);
   }
   tab_PosDetail.setModel(
       getModle(
           new String[] {paragraph.getLanguage(line, "MESSAGE")},
           new String[][] {{paragraph.getLanguage(line, "NOINFORMATION")}}));
 }
Exemplo n.º 3
0
  private void btn_PosDelActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_PosDelActionPerformed
    Object getValue = tab_PosList.getValueAt(tab_PosList.getSelectedRow(), 0);
    String sql = "DELETE FROM position WHERE name = '" + getValue.toString() + "'";
    Object[] options = {
      paragraph.getLanguage(message, "YES"), paragraph.getLanguage(message, "NO")
    };
    int response =
        JOptionPane.showOptionDialog(
            new Frame(),
            paragraph.getLanguage(message, "DOYOUWANTTODELETE"),
            paragraph.getLanguage(message, "MESSAGE"),
            JOptionPane.YES_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[0]);
    if (response == 0) {
      try {
        DBC.executeUpdate(sql);

      } catch (SQLException e) {
        ErrorMessage.setData(
            "Staff",
            "Frm_ Position",
            "btn_PosDelActionPerformed()",
            e.toString().substring(e.toString().lastIndexOf(".") + 1, e.toString().length()));
      }
    }
    tab_PosDetail.setModel(
        getModle(
            new String[] {"Message"},
            new String[][] {{paragraph.getLanguage(line, "NOFORMATION")}})); // 將表格清空
    initTables();
    this.btn_PosDel.setEnabled(false);
    this.btn_PosUpdate.setEnabled(false);
    this.btn_StaffPosUpdata.setEnabled(false);
  } // GEN-LAST:event_btn_PosDelActionPerformed