📄 attendance_edit_view.java
字号:
package project;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.SystemColor;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
import java.awt.Rectangle;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Attendance_edit_view extends JPanel implements All_view{
JTable jTable1 = null;
String showMessage = "";
JFrame mainframe = null;
JLabel id = new JLabel();
JLabel date = new JLabel();
JTextField idText = new JTextField();
JLabel jLabel2 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JTextField zcText = new JTextField();
JTextField cdText = new JTextField();
JTextField ztText = new JTextField();
JTextField kgText = new JTextField();
JButton okkBtn = new JButton();
JLabel showMsg = new JLabel();
JTextField jTextField1 = new JTextField();
JTextField monthText = new JTextField();
JButton btn = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel8 = new JLabel();
JScrollPane jScrollPane1 = new JScrollPane();
public void att_tb(){
DataBase db3 = new DataBase();
String sql = "select * from attendance_table order by id,currmonth";
ResultSet rs = db3.executeQuery(sql);
DataMap mp = new DataMap(rs);
Object[][] obj = mp.get_DataMap_Array();
String[] colnames = {//填充JTable的内容;
"工号", "月份", "正常", "迟到","早退", "旷工"};
DefaultTableModel dm = new DefaultTableModel(obj, colnames);
jTable1 = new JTable(dm);
jScrollPane1.getViewport().add(jTable1);
this.add(jScrollPane1);
}
public Attendance_edit_view() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public Attendance_edit_view(JFrame mainframe) {
// closeCurrentPanel(mainframe);
this.mainframe = mainframe;
try {
jbInit();
setPanelPosOnDesktop(this.mainframe);
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
this.setLayout(null);
setSize(new Dimension(604, 500));
this.att_tb();
id.setForeground(UIManager.getColor("Button.darkShadow"));
id.setText("工号:");
id.setBounds(new Rectangle(112, 267, 61, 27));
date.setForeground(Color.darkGray);
date.setText("考勤时间:");
date.setBounds(new Rectangle(257, 261, 64, 35));
idText.setBounds(new Rectangle(183, 265, 65, 28));
jLabel2.setText("月");
jLabel2.setBounds(new Rectangle(286, 41, 25, 29));
monthText.setDisabledTextColor(SystemColor.activeCaptionBorder);
monthText.setText("");
monthText.setBounds(new Rectangle(325, 265, 50, 28));
btn.setBackground(SystemColor.menu);
btn.setBounds(new Rectangle(426, 268, 60, 29));
btn.setFont(new java.awt.Font("幼圆", Font.BOLD, 10));
btn.setForeground(new Color(85, 45, 25));
btn.setText("开始");
btn.addActionListener(new Attendance_edit_view_btn_actionAdapter(this));
jLabel4.setFont(new java.awt.Font("幼圆", Font.PLAIN, 11));
jLabel4.setForeground(Color.darkGray);
jLabel4.setText("正常:");
jLabel4.setBounds(new Rectangle(115, 345, 62, 31));
jLabel5.setForeground(Color.darkGray);
jLabel5.setText("迟到:");
jLabel5.setBounds(new Rectangle(260, 344, 47, 31));
jLabel6.setForeground(Color.darkGray);
jLabel6.setText("早退:");
jLabel6.setBounds(new Rectangle(114, 387, 60, 31));
jLabel7.setForeground(Color.darkGray);
jLabel7.setText("旷工:");
jLabel7.setBounds(new Rectangle(259, 387, 48, 31));
zcText.setBounds(new Rectangle(183, 343, 64, 31));
cdText.setText("");
cdText.setBounds(new Rectangle(325, 343, 64, 31));
ztText.setText("");
ztText.setBounds(new Rectangle(183, 388, 64, 31));
kgText.setText("");
kgText.setBounds(new Rectangle(325, 385, 64, 31));
okkBtn.setBounds(new Rectangle(426, 355, 60, 29));
okkBtn.setForeground(new Color(85, 45, 25));
okkBtn.setText("确定");
okkBtn.addActionListener(new Attendance_edit_view_okkBtn_actionAdapter(this));
showMsg.setText("");
showMsg.setBounds(new Rectangle(234, 437, 167, 27));
jLabel1.setForeground(UIManager.getColor("Table.shadow"));
jLabel1.setText("注意:请在考勤时间内输入时间");
jLabel1.setBounds(new Rectangle(139, 303, 168, 31));
jLabel3.setText("月");
jLabel3.setBounds(new Rectangle(380, 265, 30, 30));
jLabel8.setFont(new java.awt.Font("幼圆", Font.BOLD, 20));
jLabel8.setForeground(new Color(85, 45, 25));
jLabel8.setText("修 改 考 勤 记 录");
jLabel8.setBounds(new Rectangle(203, 19, 199, 35));
jScrollPane1.setBounds(new Rectangle(70, 65, 460, 180));
editFrm();
this.add(jLabel8);
this.add(id);
this.add(idText);
this.add(cdText);
this.add(jLabel1);
this.add(btn);
this.add(jLabel3);
this.add(date);
this.add(monthText);
this.add(jLabel6);
this.add(zcText);
this.add(ztText);
this.add(kgText);
this.add(okkBtn);
this.add(jLabel5);
this.add(jLabel7);
this.add(showMsg);
this.add(jLabel4);
}
public void editFrm() {
this.add(jLabel4);
this.add(zcText);
this.add(jLabel5);
this.add(cdText);
this.add(jLabel6);
this.add(ztText);
this.add(jLabel7);
this.add(kgText);
this.add(showMsg);
this.add(okkBtn);
}
public void setPanelPosOnDesktop(JFrame frame) {
this.setLocation( (((Frame1)frame).get_Container_width()- this.getSize().width) / 2,
(((Frame1)frame).get_Container_height()- this.getSize().height) / 2);
}
public void closeCurrentPanel(JFrame frame) {
((Frame1)frame).remove_panel();
frame.repaint();
}
public void set_focus() {
idText.requestFocus();
}
public void requestFocus(){
set_focus();
}
public void clear(){
att_tb();
idText.setText("");
zcText.setText("");
cdText.setText("");
ztText.setText("");
kgText.setText("");
}
public void reSet_actionPerformed(ActionEvent e) {
this.clear();
}
public void btn_actionPerformed(ActionEvent e) {//开始查询数据并填充下列信息
Attendance_add_Model obj = new Attendance_add_Model();
Attendance_add_C att_add = new Attendance_add_C();
obj.setId(Integer.parseInt(idText.getText()));
obj.setCurrmonth(monthText.getText());
int a=att_add.edit_1(obj);
if (a==0){
JOptionPane.showMessageDialog(this,"查无此员工的记录!!","OK",1);
}
editFrm();
this.att_tb();
zcText.setText(Integer.toString(obj.getZc()));
cdText.setText(Integer.toString(obj.getCd()));
ztText.setText(Integer.toString(obj.getZt()));
kgText.setText(Integer.toString(obj.getKg()));
this.mainframe.repaint();
}
public void okkBtn_actionPerformed(ActionEvent e) {//确定修改信息
Attendance_add_Model obj = new Attendance_add_Model();
Attendance_add_C att_add = new Attendance_add_C();
obj.setId(Integer.parseInt(idText.getText()));
obj.setCurrmonth(monthText.getText());
obj.setCd(Integer.parseInt(cdText.getText()));
obj.setKg(Integer.parseInt(kgText.getText()));
obj.setZt(Integer.parseInt(ztText.getText()));
obj.setZc(Integer.parseInt(zcText.getText()));
int r = att_add.edit_2(obj);
if (r == 0) {
JOptionPane.showMessageDialog(this,"修改数据失败!!","OK",1);
}
else {
JOptionPane.showMessageDialog(this,"修改数据成功!!","OK",1);
this.att_tb();
}
}
}
class Attendance_edit_view_okkBtn_actionAdapter
implements ActionListener {
private Attendance_edit_view adaptee;
Attendance_edit_view_okkBtn_actionAdapter(Attendance_edit_view adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.okkBtn_actionPerformed(e);
}
}
class Attendance_edit_view_btn_actionAdapter
implements ActionListener {
private Attendance_edit_view adaptee;
Attendance_edit_view_btn_actionAdapter(Attendance_edit_view adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btn_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -