⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 require_attendance_c.java

📁 javaGUI编写的人事管理系统(毕业学生答辩可参考)
💻 JAVA
字号:
package project;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.sql.ResultSet;
import java.sql.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Require_attendance_C {
  JFrame mainframe = null;
  JPanel Require_attendance_C_view = null;
  public Require_attendance_C(JFrame mainframe, JPanel Require_attendance_C_view) {
    this.mainframe = mainframe;
    this.Require_attendance_C_view = Require_attendance_C_view;
  }

  public void show_record(String str, JLabel[][] label,JLabel l1,JLabel l2,JLabel l3,JLabel l4){

    try{
      int id = Integer.parseInt(str);
      DataBase db = new DataBase();
      String sql = "select * from employee_table where employee_id="+id+" and useful=1";
      ResultSet rs = db.executeQuery(sql);
      try {
        if (!rs.next()) {
          JOptionPane.showMessageDialog(this.mainframe,"工号输入有误,没有该条记录或则该记录已被删除!","提示",JOptionPane.INFORMATION_MESSAGE);
          rs.close();
          db.close();
          ((Require_attendance_view)Require_attendance_C_view).requestFocus();
          return;
        }else{
          rs.close();
          String newsql = "select * from attendance_table where id="+id;
          rs = db.executeQuery(newsql);

          if(!rs.next()){
            JOptionPane.showMessageDialog(this.mainframe,"该员工的考勤记录不存在!","提示",JOptionPane.INFORMATION_MESSAGE);
            rs.close();
            db.close();
            ((Require_attendance_view)Require_attendance_C_view).requestFocus();
            return;

          }else{
            rs.close();
            String sql2 = "select * from attendance_table where id="+id;
            rs = db.executeQuery(newsql);
            DataMap dm = new DataMap(rs);
            rs.close();
            db.close();
            Object[][] obj = dm.get_DataMap_Array();
            for(int i = 0; i< label.length; i++){
              for(int j = 0; j < label[i].length; j++){
                label[i][j].setText("0");
              }
            }

            for(int i = 0; i < obj.length; i++){
              label[0][Integer.parseInt(obj[i][1].toString())-1].setText(obj[i][2].toString());
              label[1][Integer.parseInt(obj[i][1].toString())-1].setText(obj[i][3].toString());
              label[2][Integer.parseInt(obj[i][1].toString())-1].setText(obj[i][4].toString());
              label[3][Integer.parseInt(obj[i][1].toString())-1].setText(obj[i][5].toString());
            }

            int[] num = new int[4];
            for(int i = 0; i < 4; i++){
              for(int j = 0; j < 12;j++){
                num[i] +=Integer.parseInt(label[i][j].getText());
              }
            }

            l1.setText(String.valueOf(num[0]));
            l2.setText(String.valueOf(num[1]));
            l3.setText(String.valueOf(num[2]));
            l4.setText(String.valueOf(num[3]));


          }
        }
      }
      catch (SQLException ex) {
        JOptionPane.showMessageDialog(this.mainframe,"数据集有错误!","提示",JOptionPane.INFORMATION_MESSAGE);
      }



    }
    catch(NumberFormatException e){
      //e.printStackTrace();
      JOptionPane.showMessageDialog(this.mainframe,"工号输入有误!","提示",JOptionPane.INFORMATION_MESSAGE);
      ((Require_attendance_view)Require_attendance_C_view).requestFocus();
    }

  }




}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -