com.lynk.hrm.ui.dialog.InfoEmployee.java Source code

Java tutorial

Introduction

Here is the source code for com.lynk.hrm.ui.dialog.InfoEmployee.java

Source

package com.lynk.hrm.ui.dialog;

import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.FileImageOutputStream;
import javax.swing.JDialog;

import java.awt.Component;
import java.awt.Toolkit;

import javax.swing.JOptionPane;
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;

import java.awt.Color;

import org.apache.commons.lang.StringUtils;

import com.jidesoft.swing.JideTabbedPane;
import com.lynklin.hrm.biz.HrmBiz;
import com.lynklin.hrm.common.IdCardLibrary;
import com.lynklin.hrm.common.PinyinUtil;
import com.lynklin.hrm.common.Utils;
import com.lynklin.hrm.common.UtilsClient;
import com.lynklin.hrm.common.Variables;
import com.lynklin.hrm.domain.AttendanceVacation;
import com.lynklin.hrm.domain.AttendanceVacationHistory;
import com.lynklin.hrm.domain.Employee;
import com.lynklin.hrm.domain.EmployeeHistory;
import com.lynklin.hrm.domain.EmployeePhoto;
import com.lynklin.hrm.domain.EmployeeSuspend;
import com.lynklin.hrm.domain.IdCard;
import com.lynklin.hrm.domain.JobAdjustment;
import com.lynklin.hrm.domain.PraisePunish;
import com.lynk.hrm.ui.common.PraisePunishColorRenderer;
import com.lynklin.hrm.ui.model.AttendanceVacationHistoryModel;
import com.lynklin.hrm.ui.model.JobAdjustmentModel;
import com.lynklin.hrm.ui.model.PraisePunishModel;
import com.lynk.swing.component.LynkDialog;
import com.lynk.swing.component.LynkReportDialog;
import com.lynk.swing.component.LynkTable;
import com.lynk.swing.component.LynkTable.MouseDoubleClick;
import com.lynk.swing.component.LynkTextField;
import com.lynk.swing.component.table.TableRowHead;

import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.JTabbedPane;
import javax.swing.JPanel;

import com.sun.jna.WString;
import com.toedter.calendar.JDateChooser;

import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.table.AbstractTableModel;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;

import java.awt.BorderLayout;

import javax.swing.border.EtchedBorder;

import net.miginfocom.swing.MigLayout;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.JRLoader;

import com.lynk.swing.component.ImagePane;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.image.RenderedImage;
import java.awt.Insets;

public class InfoEmployee extends LynkDialog {
    private static final long serialVersionUID = 1L;

    private static File folder = new File(System.getProperty("user.dir") + "/potevio");

    private static File file1 = new File(folder, "cardapi3.dll");
    private static File file2 = new File(folder, "license.dat");
    private static File file3 = new File(folder, "sdtapi.dll");
    private static File file4 = new File(folder, "WltRS.dll");

    private Employee employee;
    //   private List<Dept> depts;
    //   private List<Job> jobs;
    private EmployeeHistoryModel historyModel;
    private EmployeeSuspendModel suspendModel;
    private JobAdjustmentModel jobAdjustmentModel;
    private PraisePunishModel praisePunishModel;
    private AttendanceVacationHistoryModel attendanceVacationModel;

    private LynkTextField uiId;
    private LynkTextField uiName;
    private LynkTextField uiNamePy;
    private LynkTextField uiIdCard;
    private LynkTextField uiAge;
    private LynkTextField uiTimeCardLeaveCertify;
    private LynkTextField uiWorkAge;
    private LynkTextField uiBirthday;
    private LynkTextField uiGender;
    private JComboBox<String> uiMarital;
    private JDateChooser uiEntryDate;
    private LynkTextField uiJob;
    private LynkTextField uiDept;
    private JDateChooser uiProbation;
    private JDateChooser uiExpiration;
    private LynkTextField uiContact;
    private JTextArea uiCensusAddress;
    private JTextArea uiAddress;
    private JComboBox<String> uiCensus;
    private LynkTextField uiSchool;
    private LynkTextField uiMajor;
    private LynkTextField uiGuide;
    private LynkTextField uiPhoneShort;
    private LynkTextField uiSocialCard;
    private LynkTextField uiHousingCard;
    private LynkTextField uiBankCard;
    private JTextArea uiWorkExperience;
    private JTextArea uiNote;
    private JDateChooser uiLeaveDate;
    private JComboBox<String> uiLeaveType;
    private JDateChooser uiSocialEndDate;
    private JDateChooser uiHousingEndDate;
    private JTextArea uiLeaveReason;
    private JComboBox<String> uiDegree;
    private JComboBox<String> uiState;
    private JideTabbedPane uiInfoTab;
    private JComboBox<String> uiDdg;
    //   private LynkTextField uiSuspendEnd;
    private JComboBox<String> uiFactory;
    private LynkTextField uiHistoryOperator;
    private LynkTable uiEmployeeHistory;
    private JComboBox<String> uiHistoryType;
    private JLabel uiLabelLeaveDate;
    private JLabel uiLabelSocialEnd;
    private JLabel uiLabelHousingEnd;
    private JLabel uiLabelLeaveType;
    private JLabel uiLabelLeaveReason;
    private LynkTable uiJobAdjustment;
    private LynkTable uiEmpSuspend;
    private JComboBox<String> uiResidencePermit;
    private LynkTextField uiPerformance;
    private JDateChooser uiPraisePunishDateStart;
    private JDateChooser uiPraisePunishDateEnd;
    private LynkTable uiPraisePunish;
    private JComboBox<String> uiPraisePunishType;
    private ImagePane uiPhoto;
    private JLabel uiCurrentTotal;
    private JLabel uiLastLeft;
    private JLabel uiLeftHours;
    private JButton uiVacationHistoryAdd;
    private JLabel uiVacationStartEnd;
    private LynkTable uiAttendanceVacationHistory;
    private JLabel uiLastTotal;

    public static Employee showDialog(Component parent, String id) {
        InfoEmployee empInfo = new InfoEmployee(id);
        empInfo.setLocationRelativeTo(parent);
        empInfo.setVisible(true);
        return empInfo.employee;
    }

    private InfoEmployee(String id) {
        initComponents();
        initData(id);
    }

    private void initComponents() {
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                thisWindowClosing(e);
            }
        });
        setSize(836, 674);
        setTitle("");
        setIconImage(
                Toolkit.getDefaultToolkit().getImage(InfoEmployee.class.getResource("/resource/image/icon.png")));
        setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
        getContentPane().setLayout(new BorderLayout(0, 0));
        {
            JToolBar toolBar = new JToolBar();
            toolBar.setFloatable(false);
            getContentPane().add(toolBar, BorderLayout.NORTH);
            {
                JButton uiSave = new JButton("?");
                uiSave.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        uiSaveActionPerformed(true);
                    }
                });
                uiSave.setFocusable(false);
                uiSave.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_save.png")));
                uiSave.setFont(APP_FONT);
                toolBar.add(uiSave);
            }
            toolBar.addSeparator();
            {
                JButton uiReadIdCard = new JButton("??");
                uiReadIdCard.setFont(APP_FONT);
                uiReadIdCard.setIcon(
                        new ImageIcon(InfoEmployee.class.getResource("/resource/image/manager_teacher.png")));
                uiReadIdCard.setFocusable(false);
                uiReadIdCard.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        uiReadIdCardActionPerformed(e);
                    }
                });
                toolBar.add(uiReadIdCard);
            }
            toolBar.addSeparator();
            {
                JButton uiInputFinger = new JButton("");
                uiInputFinger.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        uiInputFingerActionPerformed(e);
                    }
                });
                uiInputFinger.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/finger.png")));
                uiInputFinger.setFont(APP_FONT);
                uiInputFinger.setFocusable(false);
                toolBar.add(uiInputFinger);
            }
            toolBar.addSeparator();
            {
                JButton uiSetSuspend = new JButton("??");
                uiSetSuspend.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        uiSetSuspendActionPerformed(e);
                    }
                });
                uiSetSuspend
                        .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_retire.png")));
                uiSetSuspend.setFont(APP_FONT);
                uiSetSuspend.setFocusable(false);
                toolBar.add(uiSetSuspend);
            }
        }

        {
            JPanel panel = new JPanel();
            getContentPane().add(panel);
            panel.setLayout(new MigLayout("", "[]5[grow]25[]5[grow]25[]5[grow]5[102]", "[][][][]"));
            {
                JLabel label = new JLabel("?");
                label.setHorizontalAlignment(SwingConstants.RIGHT);
                label.setFont(APP_FONT);
                panel.add(label, "cell 0 0");
            }
            {
                uiId = new LynkTextField();
                uiId.setEditable(false);
                uiId.setForeground(Color.BLUE);
                panel.add(uiId, "cell 1 0,growx");
            }
            {
                JLabel label = new JLabel("??");
                label.setHorizontalAlignment(SwingConstants.RIGHT);
                label.setFont(APP_FONT);
                panel.add(label, "cell 2 0");
            }
            {
                uiName = new LynkTextField();
                uiName.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusLost(FocusEvent e) {
                        uiNameFocusLost(e);
                    }
                });
                panel.add(uiName, "cell 3 0,growx");
            }
            {
                JLabel label = new JLabel("?");
                label.setHorizontalAlignment(SwingConstants.RIGHT);
                label.setFont(APP_FONT);
                panel.add(label, "cell 4 0");
            }
            {
                uiNamePy = new LynkTextField();
                panel.add(uiNamePy, "cell 5 0,growx");
            }
            {
                JLabel label = new JLabel("?");
                label.setHorizontalAlignment(SwingConstants.RIGHT);
                label.setFont(APP_FONT);
                panel.add(label, "cell 0 1");
            }
            {
                uiState = new JComboBox<String>();
                uiState.setForeground(Color.BLUE);
                uiState.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        uiStateActionPerformed(e);
                    }
                });
                uiState.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.STATE_PROBATION,
                        Employee.STATE_CONTRACT, Employee.STATE_SUSPEND, Employee.STATE_LEAVE,
                        Employee.STATE_RETIRE, Employee.STATE_DELETE }));
                uiState.setFont(APP_FONT);
                panel.add(uiState, "cell 1 1,growx");
            }
            {
                uiInfoTab = new JideTabbedPane(JTabbedPane.TOP);
                uiInfoTab.addChangeListener(new ChangeListener() {
                    public void stateChanged(ChangeEvent e) {
                        uiInfoTabStateChanged(e);
                    }
                });
                uiInfoTab.setColorTheme(JideTabbedPane.COLOR_THEME_DEFAULT);
                uiInfoTab.setFont(APP_FONT);
                panel.add(uiInfoTab, "cell 0 3 7 1");
                {
                    JPanel uiInfoBasic = new JPanel();
                    uiInfoBasic.setLayout(new MigLayout("", "[473px,grow][307px,grow]", "[grow][289px][149px]"));
                    uiInfoTab.addTab("?", uiInfoBasic);
                    {
                        JPanel uiIdCardPane = new JPanel();
                        uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                        uiIdCardPane.setLayout(new MigLayout("", "[]5[grow]10[]", "[][][][][40px:40px:40px,grow]"));
                        uiInfoBasic.add(uiIdCardPane, "cell 0 0,grow");
                        {
                            JLabel label = new JLabel("??");
                            uiIdCardPane.add(label, "cell 0 0");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiIdCard = new LynkTextField();
                            uiIdCardPane.add(uiIdCard, "cell 1 0,growx");
                        }
                        {
                            JPanel pane = new JPanel();
                            uiIdCardPane.add(pane, "cell 2 0 1 5,grow");
                            pane.setLayout(new MigLayout("insets 0", "[102px:102px:102px]", "[126px:126px:126px]"));
                            {
                                uiPhoto = new ImagePane();
                                pane.add(uiPhoto, "cell 0 0,grow");
                            }
                        }
                        //                  {
                        //                     JPanel photoPane = new JPanel();
                        //                     photoPane.setLayout(new MigLayout("insets 0", "[grow]", "[grow][]"));
                        //                     uiIdCardPane.add(photoPane, "cell 2 0 2 4,grow");
                        //                     {
                        //                        uiPhoto = new ImagePane();
                        //                        photoPane.add(uiPhoto, "cell 0 0,grow");
                        //                     }
                        //                     {
                        //                        JButton uiReadIdCardDirect = new JButton("??");
                        //                        uiReadIdCardDirect.addActionListener(new ActionListener() {
                        //                           public void actionPerformed(ActionEvent e) {
                        //                              uiReadIdCardDirectActionPerformed(e);
                        //                           }
                        //                        });
                        //                        uiReadIdCardDirect.setFont(APP_FONT);
                        //                        uiReadIdCardDirect.setFocusable(false);
                        //                        photoPane.add(uiReadIdCardDirect, "cell 0 1,grow");
                        //                     }
                        //                  }
                        {
                            JLabel label = new JLabel("");
                            uiIdCardPane.add(label, "cell 0 1");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiBirthday = new LynkTextField();
                            uiIdCardPane.add(uiBirthday, "cell 1 1,growx");
                        }
                        {
                            JLabel label = new JLabel("");
                            uiIdCardPane.add(label, "cell 0 2");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiAge = new LynkTextField();
                            uiIdCardPane.add(uiAge, "cell 1 2,growx");
                        }
                        {
                            JLabel label = new JLabel("");
                            uiIdCardPane.add(label, "cell 0 3,aligny top");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiGender = new LynkTextField();
                            uiIdCardPane.add(uiGender, "cell 1 3,growx,aligny top");
                        }
                        {
                            JLabel label = new JLabel("??");
                            label.setFont(APP_FONT);
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            uiIdCardPane.add(label, "cell 0 4");
                        }
                        {
                            JScrollPane scrollPane = new JScrollPane();
                            uiIdCardPane.add(scrollPane, "cell 1 4,grow");
                            {
                                uiCensusAddress = new JTextArea();
                                uiCensusAddress.setWrapStyleWord(true);
                                uiCensusAddress.setLineWrap(true);
                                scrollPane.setViewportView(uiCensusAddress);
                                uiCensusAddress.setFont(APP_FONT);
                            }
                        }
                    }
                    {
                        JPanel uiIdCardPane = new JPanel();
                        uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                        uiIdCardPane
                                .setLayout(new MigLayout("", "[]5[grow]25[]5[grow]", "[][][40px:40px:40px,grow]"));
                        uiInfoBasic.add(uiIdCardPane, "cell 0 1,grow");
                        {
                            JLabel label = new JLabel("");
                            uiIdCardPane.add(label, "cell 0 0");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiMarital = new JComboBox<String>();
                            uiIdCardPane.add(uiMarital, "cell 1 0,growx");
                            uiMarital.setModel(new DefaultComboBoxModel<String>(
                                    new String[] { Employee.MARITAL_YES, Employee.MARITAL_NO }));
                            uiMarital.setFont(APP_FONT);
                        }
                        {
                            JLabel label = new JLabel("?");
                            uiIdCardPane.add(label, "cell 2 0");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiContact = new LynkTextField();
                            uiIdCardPane.add(uiContact, "cell 3 0,growx");
                        }
                        {
                            JLabel label = new JLabel("?");
                            uiIdCardPane.add(label, "cell 0 1");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiCensus = new JComboBox<String>();
                            uiIdCardPane.add(uiCensus, "cell 1 1,growx");
                            uiCensus.setModel(new DefaultComboBoxModel<String>(
                                    new String[] { Employee.CENSUS_A, Employee.CENSUS_B, Employee.CENSUS_C,
                                            Employee.CENSUS_D, Employee.CENSUS_E, Employee.CENSUS_F }));
                            uiCensus.setFont(APP_FONT);
                        }
                        {
                            JLabel label = new JLabel("??");
                            uiIdCardPane.add(label, "cell 2 1");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiResidencePermit = new JComboBox<String>();
                            uiIdCardPane.add(uiResidencePermit, "cell 3 1,growx");
                            uiResidencePermit
                                    .setModel(new DefaultComboBoxModel<String>(new String[] { "", "", "" }));
                            uiResidencePermit.setFont(APP_FONT);
                        }
                        {
                            JLabel label = new JLabel("");
                            uiIdCardPane.add(label, "cell 0 2");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            JScrollPane scrollPane = new JScrollPane();
                            uiIdCardPane.add(scrollPane, "cell 1 2 3 1,grow");
                            {
                                uiAddress = new JTextArea();
                                uiAddress.setWrapStyleWord(true);
                                uiAddress.setLineWrap(true);
                                scrollPane.setViewportView(uiAddress);
                                uiAddress.setFont(APP_FONT);
                            }
                        }
                    }
                    {
                        JPanel uiCompanyPanel = new JPanel();
                        uiCompanyPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                        uiCompanyPanel.setLayout(new MigLayout("", "[]5[grow][]25[]5[grow][]", "[][][][][][][][]"));
                        uiInfoBasic.add(uiCompanyPanel, "cell 0 2,growx,aligny top");
                        {
                            JLabel label = new JLabel(Employee.SUSPEND_NOTE);
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                            uiCompanyPanel.add(label, "cell 0 0");
                        }
                        {
                            uiFactory = new JComboBox<String>(new DefaultComboBoxModel<String>(
                                    new String[] { Employee.FACROTY_TC, Employee.FACTORY_SX }));
                            uiFactory.setFont(APP_FONT);
                            uiCompanyPanel.add(uiFactory, "cell 1 0 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel("");
                            uiCompanyPanel.add(label, "cell 3 0");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiDept = new LynkTextField();
                            uiDept.setEditable(false);
                            uiCompanyPanel.add(uiDept, "cell 4 0,growx");
                        }
                        {
                            JButton uiChooseDept = new JButton();
                            uiChooseDept.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiChooseDeptActionPerformed(e);
                                }
                            });
                            uiChooseDept.setIcon(new ImageIcon(
                                    InfoEmployee.class.getResource("/resource/image/choose_more.png")));
                            uiChooseDept.setMargin(new Insets(1, 1, 1, 1));
                            uiCompanyPanel.add(uiChooseDept, "cell 5 0,growx");
                        }
                        {
                            JLabel label = new JLabel("?");
                            uiCompanyPanel.add(label, "cell 0 1");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiJob = new LynkTextField();
                            uiJob.setEditable(false);
                            uiCompanyPanel.add(uiJob, "cell 1 1,growx");
                        }
                        {
                            JButton uiChooseJob = new JButton();
                            uiChooseJob.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiChooseJobActionPerformed(e);
                                }
                            });
                            uiChooseJob.setIcon(new ImageIcon(
                                    InfoEmployee.class.getResource("/resource/image/choose_more.png")));
                            uiChooseJob.setMargin(new Insets(1, 1, 1, 1));
                            uiCompanyPanel.add(uiChooseJob, "cell 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel(Employee.SUSPEND_START);
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                            uiCompanyPanel.add(label, "cell 3 1");
                        }
                        {
                            uiDdg = new JComboBox<String>(
                                    new DefaultComboBoxModel<>(new String[] { Employee.DDG_N, Employee.DDG_Y }));
                            uiDdg.setFont(APP_FONT);
                            uiCompanyPanel.add(uiDdg, "cell 4 1 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel("");
                            uiCompanyPanel.add(label, "cell 0 2");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiEntryDate = new JDateChooser();
                            uiCompanyPanel.add(uiEntryDate, "cell 1 2 2 1,growx");
                            uiEntryDate.setDateFormatString("yyyy-MM-dd");
                            uiEntryDate.setFont(APP_FONT);
                            uiEntryDate.getJCalendar().setTodayButtonVisible(true);
                            uiEntryDate.addPropertyChangeListener(new PropertyChangeListener() {

                                @Override
                                public void propertyChange(PropertyChangeEvent evt) {
                                    if ("date".equals(evt.getPropertyName())) {
                                        setWorkAge();
                                    }
                                }
                            });
                        }
                        {
                            JLabel label = new JLabel("");
                            uiCompanyPanel.add(label, "cell 3 2");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiWorkAge = new LynkTextField("0");
                            uiCompanyPanel.add(uiWorkAge, "cell 4 2 2 1,growx");
                            uiWorkAge.setEditable(false);
                        }
                        {
                            JLabel label = new JLabel("?");
                            uiCompanyPanel.add(label, "cell 0 3");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiProbation = new JDateChooser();
                            uiCompanyPanel.add(uiProbation, "cell 1 3 2 1,growx");
                            uiProbation.setDateFormatString("yyyy-MM-dd");
                            uiProbation.setFont(APP_FONT);
                            uiProbation.getJCalendar().setTodayButtonVisible(true);
                        }
                        {
                            JLabel label = new JLabel("??");
                            uiCompanyPanel.add(label, "cell 3 3");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiExpiration = new JDateChooser();
                            uiCompanyPanel.add(uiExpiration, "cell 4 3 2 1,growx");
                            uiExpiration.setDateFormatString("yyyy-MM-dd");
                            uiExpiration.setFont(APP_FONT);
                            uiExpiration.getJCalendar().setLeftButtonText(Employee.EXPIRATION_NO);
                            uiExpiration.getJCalendar().setLeftButtonVisible(true);
                            uiExpiration.getJCalendar().setRightButtonText(Employee.EXPIRATION_LONG);
                            uiExpiration.getJCalendar().setRightButtonVisible(true);
                        }
                        {
                            JLabel label = new JLabel("");
                            uiCompanyPanel.add(label, "cell 0 4");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiSchool = new LynkTextField();
                            uiCompanyPanel.add(uiSchool, "cell 1 4 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel("");
                            uiCompanyPanel.add(label, "cell 3 4");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiDegree = new JComboBox<String>();
                            uiCompanyPanel.add(uiDegree, "cell 4 4 2 1,growx");
                            uiDegree.setMaximumRowCount(12);
                            uiDegree.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.DEGREE_A,
                                    Employee.DEGREE_B, Employee.DEGREE_C, Employee.DEGREE_D, Employee.DEGREE_E,
                                    Employee.DEGREE_F, Employee.DEGREE_G, Employee.DEGREE_H, Employee.DEGREE_I,
                                    Employee.DEGREE_J }));
                            uiDegree.setFont(APP_FONT);
                        }
                        {
                            JLabel label = new JLabel("");
                            uiCompanyPanel.add(label, "cell 0 5");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                        }
                        {
                            uiMajor = new LynkTextField();
                            uiCompanyPanel.add(uiMajor, "cell 1 5 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel("");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                            uiCompanyPanel.add(label, "cell 3 5");
                        }
                        {
                            uiGuide = new LynkTextField();
                            uiCompanyPanel.add(uiGuide, "cell 4 5 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel("?");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT_BLOD);
                            uiCompanyPanel.add(label, "cell 0 6");
                        }
                        {
                            uiPhoneShort = new LynkTextField();
                            uiPhoneShort.setFont(APP_FONT_BLOD);
                            uiCompanyPanel.add(uiPhoneShort, "cell 1 6 2 1,growx");
                        }
                        {
                            JLabel label = new JLabel("?");
                            label.setHorizontalAlignment(SwingConstants.RIGHT);
                            label.setFont(APP_FONT);
                            uiCompanyPanel.add(label, "cell 3 6");
                        }
                        {
                            uiPerformance = new LynkTextField();
                            uiCompanyPanel.add(uiPerformance, "cell 4 6 2 1,growx");
                        }
                        //                  {
                        //                     JLabel label = new JLabel("??");
                        //                     label.setHorizontalAlignment(SwingConstants.RIGHT);
                        //                     label.setFont(APP_FONT);
                        //                     uiCompanyPanel.add(label, "cell 0 7");
                        //                  }
                        //                  {
                        //                     uiSuspendEnd = new LynkTextField();
                        //                     uiCompanyPanel.add(uiSuspendEnd, "cell 1 7 5 1,growx");
                        //                  }
                    }
                    {
                        JPanel panel4 = new JPanel();
                        panel4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                        panel4.setLayout(new MigLayout("", "[]5[grow]", "[][][][grow][grow]"));
                        uiInfoBasic.add(panel4, "cell 1 0 1 3,grow");
                        {
                            JLabel label = new JLabel("???");
                            panel4.add(label, "cell 0 0,grow");
                            label.setFont(APP_FONT);
                        }
                        {
                            uiSocialCard = new LynkTextField();
                            panel4.add(uiSocialCard, "cell 1 0,grow");
                        }
                        {
                            JLabel label = new JLabel("?");
                            panel4.add(label, "cell 0 1,grow");
                            label.setFont(APP_FONT);
                        }
                        {
                            uiHousingCard = new LynkTextField();
                            panel4.add(uiHousingCard, "cell 1 1,grow");
                        }
                        {
                            JLabel label = new JLabel("??");
                            panel4.add(label, "cell 0 2,grow");
                            label.setFont(APP_FONT);
                        }
                        {
                            uiBankCard = new LynkTextField();
                            panel4.add(uiBankCard, "cell 1 2,grow");
                        }
                        {
                            JLabel label = new JLabel("?");
                            panel4.add(label, "cell 0 3,growx,aligny top");
                            label.setFont(APP_FONT);
                        }
                        {
                            JScrollPane scrollPane = new JScrollPane();
                            panel4.add(scrollPane, "cell 1 3,grow");
                            uiWorkExperience = new JTextArea();
                            uiWorkExperience.setFont(APP_FONT);
                            scrollPane.setViewportView(uiWorkExperience);
                        }
                        {
                            JLabel label = new JLabel("");
                            panel4.add(label, "cell 0 4,growx,aligny top");
                            label.setFont(APP_FONT);
                        }
                        {
                            JScrollPane scrollPane = new JScrollPane();
                            panel4.add(scrollPane, "cell 1 4,grow");
                            {
                                uiNote = new JTextArea();
                                uiNote.setFont(APP_FONT);
                                scrollPane.setViewportView(uiNote);
                            }
                        }
                    }
                }
                {
                    JPanel uiInfoLeave = new JPanel();
                    uiInfoLeave.setLayout(new MigLayout("", "[]5[150px]25[]5[150px]", "[][][][grow][]"));
                    uiInfoTab.addTab("??", uiInfoLeave);
                    {
                        uiLabelLeaveDate = new JLabel("?");
                        uiLabelLeaveDate.setFont(APP_FONT);
                        uiInfoLeave.add(uiLabelLeaveDate, "cell 0 0,grow");
                    }
                    {
                        uiLeaveDate = new JDateChooser();
                        uiLeaveDate.setDateFormatString("yyyy-MM-dd");
                        uiLeaveDate.setFont(APP_FONT);
                        uiLeaveDate.getJCalendar().setTodayButtonVisible(true);
                        uiLeaveDate.getJCalendar().setNullDateButtonVisible(true);
                        uiInfoLeave.add(uiLeaveDate, "cell 1 0,growx,aligny top");
                    }
                    {
                        uiLabelSocialEnd = new JLabel("??");
                        uiLabelSocialEnd.setFont(APP_FONT);
                        uiInfoLeave.add(uiLabelSocialEnd, "cell 0 1,grow");
                    }
                    {
                        uiLabelHousingEnd = new JLabel("?");
                        uiLabelHousingEnd.setFont(APP_FONT);
                        uiInfoLeave.add(uiLabelHousingEnd, "cell 2 1,grow");
                    }
                    {
                        uiHousingEndDate = new JDateChooser();
                        uiHousingEndDate.setDateFormatString("yyyy-MM-dd");
                        uiHousingEndDate.setFont(APP_FONT);
                        uiHousingEndDate.getJCalendar().setLeftButtonText("");
                        uiHousingEndDate.getJCalendar().setLeftButtonVisible(true);
                        uiHousingEndDate.getJCalendar().setTodayButtonVisible(true);
                        uiHousingEndDate.getJCalendar().setNullDateButtonVisible(true);
                        uiInfoLeave.add(uiHousingEndDate, "cell 3 1,growx,aligny top");
                    }
                    {
                        uiLabelLeaveType = new JLabel("?");
                        uiLabelLeaveType.setFont(APP_FONT);
                        uiInfoLeave.add(uiLabelLeaveType, "cell 0 2,grow");
                    }
                    {
                        uiSocialEndDate = new JDateChooser();
                        uiSocialEndDate.setDateFormatString("yyyy-MM-dd");
                        uiSocialEndDate.setFont(APP_FONT);
                        uiSocialEndDate.getJCalendar().setLeftButtonText("");
                        uiSocialEndDate.getJCalendar().setLeftButtonVisible(true);
                        uiSocialEndDate.getJCalendar().setTodayButtonVisible(true);
                        uiSocialEndDate.getJCalendar().setNullDateButtonVisible(true);
                        uiInfoLeave.add(uiSocialEndDate, "cell 1 1,growx,aligny top");
                    }
                    {
                        uiLeaveType = new JComboBox<String>(new DefaultComboBoxModel<String>(
                                new String[] { "", Employee.LEAVE_TYPE_A, Employee.LEAVE_TYPE_B,
                                        Employee.LEAVE_TYPE_C, Employee.LEAVE_TYPE_D, Employee.LEAVE_TYPE_E,
                                        Employee.LEAVE_TYPE_F, Employee.LEAVE_TYPE_G, Employee.LEAVE_TYPE_H }));
                        uiLeaveType.setMaximumRowCount(10);
                        uiLeaveType.setFont(APP_FONT);
                        uiInfoLeave.add(uiLeaveType, "cell 1 2 3 1,grow");
                    }
                    {
                        uiLabelLeaveReason = new JLabel("?");
                        uiLabelLeaveReason.setFont(APP_FONT);
                        uiInfoLeave.add(uiLabelLeaveReason, "cell 0 3,growx,aligny top");
                    }
                    {
                        JScrollPane scrollPane_2 = new JScrollPane();
                        uiInfoLeave.add(scrollPane_2, "cell 1 3 3 1,grow");
                        {
                            uiLeaveReason = new JTextArea();
                            scrollPane_2.setViewportView(uiLeaveReason);
                            uiLeaveReason.setFont(APP_FONT);
                        }
                    }
                    {
                        JLabel label = new JLabel("??");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                        uiInfoLeave.add(label, "cell 0 4");
                    }
                    {
                        uiTimeCardLeaveCertify = new LynkTextField();
                        uiTimeCardLeaveCertify.setEditable(false);
                        uiInfoLeave.add(uiTimeCardLeaveCertify, "cell 1 4 2 1,growx");
                    }
                    {
                        JButton uiPrintLeaveCertify = new JButton("???");
                        uiPrintLeaveCertify.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiPrintLeaveCertifyActionPerformed(e);
                            }
                        });
                        uiPrintLeaveCertify.setToolTipText("???!");
                        uiPrintLeaveCertify.setFont(APP_FONT);
                        uiPrintLeaveCertify.setFocusable(false);
                        uiInfoLeave.add(uiPrintLeaveCertify, "cell 3 4,alignx right");
                    }
                }
                {
                    JPanel uiInfoSuspendHistory = new JPanel();
                    uiInfoSuspendHistory.setLayout(new BorderLayout(0, 0));
                    uiInfoTab.addTab("???", uiInfoSuspendHistory);
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        uiInfoSuspendHistory.add(scrollPane, BorderLayout.CENTER);
                        {
                            suspendModel = new EmployeeSuspendModel();
                            uiEmpSuspend = new LynkTable(suspendModel);
                            uiEmpSuspend.addHighlighter(UtilsClient.createAlignHighlighter());
                            uiEmpSuspend.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS);
                            scrollPane.setRowHeaderView(new TableRowHead(uiEmpSuspend));
                            scrollPane.setViewportView(uiEmpSuspend);
                        }
                    }
                }
                {
                    JPanel uiInfoEmpHistory = new JPanel();
                    uiInfoEmpHistory.setLayout(new BorderLayout(0, 0));
                    uiInfoTab.addTab("?", uiInfoEmpHistory);
                    {
                        JPanel pane = new JPanel();
                        pane.setLayout(new MigLayout("", "[][][][100px:100px:100px][]", "[]"));
                        uiInfoEmpHistory.add(pane, BorderLayout.NORTH);
                        {
                            JLabel label = new JLabel("");
                            label.setFont(APP_FONT);
                            pane.add(label, "cell 0 0");
                        }
                        {
                            uiHistoryType = new JComboBox<String>(new DefaultComboBoxModel<>(
                                    new String[] { "", PraisePunish.TYPE_A, PraisePunish.TYPE_B,
                                            PraisePunish.TYPE_C, PraisePunish.TYPE_D, PraisePunish.TYPE_E,
                                            PraisePunish.TYPE_F, PraisePunish.TYPE_G, PraisePunish.TYPE_H }));
                            uiHistoryType.setFont(APP_FONT);
                            pane.add(uiHistoryType, "cell 1 0");
                        }
                        {
                            JLabel label = new JLabel("?");
                            label.setFont(APP_FONT);
                            pane.add(label, "cell 2 0");
                        }
                        {
                            uiHistoryOperator = new LynkTextField();
                            pane.add(uiHistoryOperator, "cell 3 0,growx");
                        }
                        {
                            JButton uiRefresh = new JButton("");
                            uiRefresh.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiRefreshActionPerformed(e);
                                }
                            });
                            uiRefresh.setIcon(
                                    new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png")));
                            uiRefresh.setFont(APP_FONT);
                            uiRefresh.setFocusable(false);
                            pane.add(uiRefresh, "cell 4 0");
                        }
                    }
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        uiInfoEmpHistory.add(scrollPane, BorderLayout.CENTER);
                        {
                            historyModel = new EmployeeHistoryModel();
                            uiEmployeeHistory = new LynkTable(historyModel);
                            uiEmployeeHistory.setColumnSize(70, 540, 50, 130, 90);
                            scrollPane.setViewportView(uiEmployeeHistory);
                            scrollPane.setRowHeaderView(new TableRowHead(uiEmployeeHistory));

                        }
                    }
                }
                {
                    JPanel uiInfoJobAdjustment = new JPanel();
                    uiInfoJobAdjustment.setLayout(new BorderLayout(0, 0));
                    uiInfoTab.addTab("?", uiInfoJobAdjustment);
                    {
                        JToolBar toolBar = new JToolBar();
                        toolBar.setFloatable(false);
                        uiInfoJobAdjustment.add(toolBar, BorderLayout.NORTH);
                        {
                            {
                                JButton uiAddJobAdjust = new JButton("?");
                                uiAddJobAdjust.addActionListener(new ActionListener() {
                                    public void actionPerformed(ActionEvent e) {
                                        uiAddJobAdjustActionPerformed(e);
                                    }
                                });
                                uiAddJobAdjust.setIcon(
                                        new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                                uiAddJobAdjust.setFont(APP_FONT);
                                toolBar.add(uiAddJobAdjust);
                            }
                        }
                    }
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        uiInfoJobAdjustment.add(scrollPane, BorderLayout.CENTER);
                        {
                            jobAdjustmentModel = new JobAdjustmentModel();
                            uiJobAdjustment = new LynkTable(jobAdjustmentModel);
                            uiJobAdjustment.setColumnSize(50, 100, 100, 100, 100, 100, 80, 100, 150);
                            scrollPane.setRowHeaderView(new TableRowHead(uiJobAdjustment));
                            scrollPane.setViewportView(uiJobAdjustment);
                        }
                    }
                }
                {
                    JPanel uiInfoPraisePunish = new JPanel();
                    uiInfoTab.addTab("", uiInfoPraisePunish);
                    uiInfoPraisePunish.setLayout(
                            new MigLayout("", "[]10[grow]30[]10[120]5[]5[120]20[]20[][grow]", "[][grow]"));
                    {
                        uiPraisePunishDateStart = new JDateChooser();
                        uiPraisePunishDateStart.setFont(APP_FONT);
                        uiPraisePunishDateStart.setDateFormatString("yyyy-MM-dd");
                        uiInfoPraisePunish.add(uiPraisePunishDateStart, "cell 3 0,growx");
                    }
                    {
                        uiPraisePunishDateEnd = new JDateChooser();
                        uiPraisePunishDateEnd.setFont(APP_FONT);
                        uiPraisePunishDateEnd.setDateFormatString("yyyy-MM-dd");
                        uiInfoPraisePunish.add(uiPraisePunishDateEnd, "cell 5 0,growx");

                    }

                    JButton uiAddPraisePunish = new JButton("");
                    uiAddPraisePunish.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            uiAddPraisePunishActionPerformed(e);
                        }
                    });
                    {
                        JButton uiFindPraisePunish = new JButton("");
                        uiFindPraisePunish.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiFindPraisePunishActionPerformed(e);
                            }
                        });
                        {
                            JLabel label = new JLabel("");
                            label.setFont(APP_FONT);
                            uiInfoPraisePunish.add(label, "cell 0 0,alignx trailing");
                        }
                        {
                            uiPraisePunishType = new JComboBox<String>(
                                    new DefaultComboBoxModel<String>(new String[] { "", PraisePunish.TYPE_A,
                                            PraisePunish.TYPE_B, PraisePunish.TYPE_C, PraisePunish.TYPE_D,
                                            PraisePunish.TYPE_E, PraisePunish.TYPE_F, PraisePunish.TYPE_G }));
                            uiPraisePunishType.setEditable(true);
                            uiPraisePunishType.setFont(APP_FONT);
                            uiInfoPraisePunish.add(uiPraisePunishType, "cell 1 0,growx");
                        }

                        {
                            JLabel label = new JLabel("");
                            label.setFont(APP_FONT);
                            uiInfoPraisePunish.add(label, "cell 2 0");
                        }
                        {
                            JLabel label = new JLabel("");
                            label.setFont(APP_FONT);
                            uiInfoPraisePunish.add(label, "cell 4 0");
                        }
                        uiFindPraisePunish.setFocusable(false);
                        uiFindPraisePunish.setIcon(
                                new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png")));
                        uiFindPraisePunish.setFont(APP_FONT);
                        uiInfoPraisePunish.add(uiFindPraisePunish, "cell 6 0");
                    }
                    uiAddPraisePunish
                            .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                    uiAddPraisePunish.setFont(APP_FONT);
                    uiAddPraisePunish.setFocusable(false);
                    uiInfoPraisePunish.add(uiAddPraisePunish, "cell 7 0");

                    JScrollPane scrollPane = new JScrollPane();
                    uiInfoPraisePunish.add(scrollPane, "cell 0 1 9 1,grow");
                    {
                        praisePunishModel = new PraisePunishModel(
                                new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION,
                                        PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL,
                                        PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE });
                        uiPraisePunish = new LynkTable(praisePunishModel);
                        uiPraisePunish.setColumnVisible(
                                new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION,
                                        PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL,
                                        PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE });
                        uiPraisePunish.setDefaultRenderer(Object.class, new PraisePunishColorRenderer());
                        uiPraisePunish.setMouseDoubleClick(new MouseDoubleClick() {

                            @Override
                            public void doubleClick(int index) {
                                if (index != -1) {
                                    index = uiPraisePunish.convertRowIndexToModel(index);
                                    PraisePunish pp = praisePunishModel.getPp(index);
                                    pp = InfoPraisePunish.showdialog(InfoEmployee.this, pp, null);
                                    if (pp != null) {
                                        praisePunishModel.updatePp(pp);
                                    }
                                }
                            }
                        });
                        scrollPane.setViewportView(uiPraisePunish);
                        scrollPane.setRowHeaderView(new TableRowHead(uiPraisePunish));
                    }
                }
                {
                    JPanel uiPanelVacation = new JPanel();
                    uiPanelVacation.setLayout(new BorderLayout());
                    uiInfoTab.addTab("?", uiPanelVacation);
                    {
                        JToolBar uiVacationToolBar = new JToolBar();
                        uiVacationToolBar.setFloatable(false);
                        uiPanelVacation.add(uiVacationToolBar, BorderLayout.NORTH);
                        {
                            JButton uiVacationRefresh = new JButton("");
                            uiVacationRefresh.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiVacationRefreshActionPerformed(e);
                                }
                            });
                            uiVacationRefresh.setIcon(
                                    new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png")));
                            uiVacationRefresh.setFocusable(false);
                            uiVacationRefresh.setFont(APP_FONT);
                            uiVacationToolBar.add(uiVacationRefresh);
                        }
                        uiVacationToolBar.addSeparator();
                        {
                            uiVacationHistoryAdd = new JButton("");
                            uiVacationHistoryAdd.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiVacationAddActionPerformed(e);
                                }
                            });
                            uiVacationHistoryAdd.setIcon(
                                    new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                            uiVacationHistoryAdd.setFocusable(false);
                            uiVacationHistoryAdd.setFont(APP_FONT);
                            uiVacationToolBar.add(uiVacationHistoryAdd);
                        }
                        uiVacationToolBar.addSeparator();
                        {
                            JButton uiEndLastLeft = new JButton("");
                            uiEndLastLeft.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiEndLastLeftActionPerformed(e);
                                }
                            });
                            uiEndLastLeft.setIcon(
                                    new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                            uiEndLastLeft.setFocusable(false);
                            uiEndLastLeft.setFont(APP_FONT);
                            uiVacationToolBar.add(uiEndLastLeft);
                        }
                    }
                    {
                        JPanel uiPanelVacationInfo = new JPanel();
                        uiPanelVacation.add(uiPanelVacationInfo, BorderLayout.CENTER);
                        uiPanelVacationInfo.setLayout(new MigLayout("", "[grow]", "[][grow]"));

                        JPanel paneAv = new JPanel();
                        uiPanelVacationInfo.add(paneAv, "cell 0 0,grow");
                        paneAv.setLayout(new MigLayout("", "[][grow]50[][grow]", "[][][]"));
                        {
                            uiVacationStartEnd = new JLabel("Time");
                            uiVacationStartEnd.setHorizontalAlignment(SwingConstants.CENTER);
                            paneAv.add(uiVacationStartEnd, "cell 0 0 4 1,growx");
                            uiVacationStartEnd.setForeground(Color.BLUE);
                            uiVacationStartEnd.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            JLabel labe = new JLabel(":");
                            paneAv.add(labe, "cell 0 1");
                            labe.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            uiLastTotal = new JLabel("");
                            paneAv.add(uiLastTotal, "cell 1 1,alignx left");
                            uiLastTotal.setForeground(Color.BLUE);
                            uiLastTotal.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            JLabel labe = new JLabel(":");
                            paneAv.add(labe, "cell 2 1");
                            labe.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            uiLastLeft = new JLabel("");
                            paneAv.add(uiLastLeft, "cell 3 1,alignx left");
                            uiLastLeft.setForeground(Color.BLUE);
                            uiLastLeft.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            JLabel labe = new JLabel(":");
                            paneAv.add(labe, "cell 0 2");
                            labe.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            uiCurrentTotal = new JLabel("");
                            paneAv.add(uiCurrentTotal, "cell 1 2,alignx left");
                            uiCurrentTotal.setForeground(Color.BLUE);
                            uiCurrentTotal.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            JLabel labe = new JLabel("?:");
                            paneAv.add(labe, "cell 2 2");
                            labe.setFont(APP_FONT.deriveFont(16f));
                        }
                        {
                            uiLeftHours = new JLabel("");
                            paneAv.add(uiLeftHours, "cell 3 2,alignx left");
                            uiLeftHours.setForeground(Color.BLUE);
                            uiLeftHours.setFont(APP_FONT.deriveFont(16f));
                        }

                        JScrollPane scrollPane = new JScrollPane();
                        uiPanelVacationInfo.add(scrollPane, "cell 0 1,grow");
                        {
                            attendanceVacationModel = new AttendanceVacationHistoryModel();
                            uiAttendanceVacationHistory = new LynkTable(attendanceVacationModel);
                            uiAttendanceVacationHistory.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS);
                            scrollPane.setViewportView(uiAttendanceVacationHistory);
                            scrollPane.setRowHeaderView(new TableRowHead(uiAttendanceVacationHistory));
                        }
                    }
                }
            }
        }

    }

    private void updateData() {
        uiId.setText(employee.getId());
        uiName.setText(employee.getName());
        uiNamePy.setText(employee.getNamePy());
        if (StringUtils.isNotEmpty(employee.getState())) {
            uiState.setSelectedItem(employee.getState());
            switch (employee.getState()) {
            case Employee.STATE_LEAVE:
            case Employee.STATE_RETIRE:
            case Employee.STATE_DELETE:
                uiInfoTab.setSelectedIndex(1);
                break;
            case Employee.STATE_SUSPEND:
                uiInfoTab.setSelectedIndex(2);
                break;
            case Employee.STATE_PROBATION:
            case Employee.STATE_CONTRACT:
            default:
                break;
            }
        }
        uiTimeCardLeaveCertify.setText(employee.getTimeCard());
        uiIdCard.setText(employee.getIdCard());
        uiBirthday.setText(employee.getBirthday());
        uiAge.setText(employee.getAge().toString());
        uiGender.setText(employee.getGender());
        if (StringUtils.isNotEmpty(employee.getMaritalStatus())) {
            uiMarital.setSelectedItem(employee.getMaritalStatus());
        }
        uiContact.setText(employee.getContact());
        if (StringUtils.isNotEmpty(employee.getCensus())) {
            uiCensus.setSelectedItem(employee.getCensus());
        }
        uiCensusAddress.setText(employee.getCensusAddress());

        // ?
        if (employee.getEmployeePhoto() != null && employee.getEmployeePhoto().getPhoto() != null
                && employee.getEmployeePhoto().getPhoto().length > 0) {
            EmployeePhoto photo = employee.getEmployeePhoto();
            try {
                File imageFile = new File(System.getProperty("user.dir") + "/temp/" + employee.getId() + ".png");
                FileImageOutputStream fios = new FileImageOutputStream(imageFile);
                fios.write(photo.getPhoto());
                fios.flush();
                fios.close();
                uiPhoto.putClientProperty("path", imageFile.getPath());
                uiPhoto.setImage(imageFile.getPath());
            } catch (Exception e) {
                showErrorMsg(e);
            }
        } else {
            uiPhoto.setImage("resource/image/default_emp_photo.png", true);
        }

        uiAddress.setText(employee.getAddress());
        if (StringUtils.isNotEmpty(employee.getCensusProvince())) {
            uiResidencePermit.setSelectedItem(employee.getCensusProvince());
        }
        if (StringUtils.isNotEmpty(employee.getDept())) {
            uiDept.setText(employee.getDept());
        }
        if (StringUtils.isNotEmpty(employee.getJob())) {
            uiJob.setText(employee.getJob());
        }
        if (StringUtils.isNotEmpty(employee.getEntryDate())) {
            uiEntryDate.setDate(Utils.dateFromStr(employee.getEntryDate()));
        }
        uiWorkAge.setText(UtilsClient.convertWorkAgeToStr(employee.getWorkAge()));
        if (StringUtils.isNotEmpty(employee.getProbationDate())) {
            uiProbation.setDate(Utils.dateFromStr(employee.getProbationDate()));
        }
        if (StringUtils.isNotEmpty(employee.getExpirationDate())) {
            uiExpiration.setText(employee.getExpirationDate());
        }
        if (StringUtils.isNotEmpty(employee.getDegree())) {
            uiDegree.setSelectedItem(employee.getDegree());
        }
        uiSchool.setText(employee.getSchool());
        uiMajor.setText(employee.getMajor());
        //      uiSuspendEnd.setText(employee.getSuspendEnd());
        uiWorkExperience.setText(employee.getWorkExperience());
        uiSocialCard.setText(employee.getSocialCard());
        uiHousingCard.setText(employee.getHousingCard());
        uiBankCard.setText(employee.getBankCard());
        uiNote.setText(employee.getNote());
        uiPerformance.setText(employee.getCensusCity());
        if (StringUtils.isNotEmpty(employee.getLeaveDate())) {
            uiLeaveDate.setDate(Utils.dateFromStr(employee.getLeaveDate()));
        }

        if (StringUtils.isNotEmpty(employee.getSocialEndDate())) {
            uiSocialEndDate.setText(employee.getSocialEndDate());
        }
        if (StringUtils.isNotEmpty(employee.getHousingEndDate())) {
            uiHousingEndDate.setText(employee.getHousingEndDate());
        }
        uiLeaveType.setSelectedItem(employee.getLeaveType());
        uiLeaveReason.setText(employee.getLeaveReason());
        uiFactory.setSelectedItem(employee.getSuspendNote());
        uiDdg.setSelectedItem(employee.getSuspendStart());
    }

    private void initData(final String id) {
        showWaitPanel("?......");
        new SwingWorker<Employee, Void>() {

            @Override
            protected Employee doInBackground() throws Exception {
                if (StringUtils.isEmpty(id)) {
                    return Employee.createNewEmployee();
                } else {
                    return HrmBiz.getInstance().getEmployee(id);
                }
            }

            @Override
            protected void done() {
                try {
                    employee = get();
                    uiEntryDate.setCalendar(Calendar.getInstance());
                    uiId.setText(employee.getId());
                    uiName.setText(employee.getName());
                    uiNamePy.setText(employee.getNamePy());
                    if (StringUtils.isNotEmpty(employee.getState())) {
                        uiState.setSelectedItem(employee.getState());
                        switch (employee.getState()) {
                        case Employee.STATE_LEAVE:
                        case Employee.STATE_RETIRE:
                        case Employee.STATE_DELETE:
                            uiInfoTab.setSelectedIndex(1);
                            break;
                        case Employee.STATE_SUSPEND:
                            uiInfoTab.setSelectedIndex(2);
                            break;
                        case Employee.STATE_PROBATION:
                        case Employee.STATE_CONTRACT:
                        default:
                            break;
                        }
                    }
                    uiTimeCardLeaveCertify.setText(employee.getTimeCard());
                    uiIdCard.setText(employee.getIdCard());
                    uiBirthday.setText(employee.getBirthday());
                    uiAge.setText(employee.getAge().toString());
                    uiGender.setText(employee.getGender());
                    if (StringUtils.isNotEmpty(employee.getMaritalStatus())) {
                        uiMarital.setSelectedItem(employee.getMaritalStatus());
                    }
                    uiContact.setText(employee.getContact());
                    if (StringUtils.isNotEmpty(employee.getCensus())) {
                        uiCensus.setSelectedItem(employee.getCensus());
                    }
                    uiCensusAddress.setText(employee.getCensusAddress());

                    // ?
                    if (employee.getEmployeePhoto() != null && employee.getEmployeePhoto().getPhoto() != null
                            && employee.getEmployeePhoto().getPhoto().length > 0) {
                        EmployeePhoto photo = employee.getEmployeePhoto();
                        uiPhoto.putClientProperty("photo", employee.getEmployeePhoto().getPhoto());
                        try {
                            File imageFile = new File(
                                    System.getProperty("user.dir") + "/temp/" + employee.getId() + ".png");
                            FileImageOutputStream fios = new FileImageOutputStream(imageFile);
                            fios.write(photo.getPhoto());
                            fios.flush();
                            fios.close();
                            uiPhoto.putClientProperty("path", imageFile.getPath());
                            uiPhoto.setImage(imageFile.getPath());
                        } catch (Exception e) {
                            showErrorMsg(e);
                        }
                    } else {
                        uiPhoto.setImage("resource/image/default_emp_photo.png", true);
                    }

                    uiAddress.setText(employee.getAddress());
                    if (StringUtils.isNotEmpty(employee.getCensusProvince())) {
                        uiResidencePermit.setSelectedItem(employee.getCensusProvince());
                    }
                    if (StringUtils.isNotEmpty(employee.getSuspendNote())) {
                        uiFactory.setSelectedItem(employee.getSuspendNote());
                    }
                    if (StringUtils.isNotEmpty(employee.getDept())) {
                        uiDept.setText(employee.getDept());
                    }
                    if (StringUtils.isNotEmpty(employee.getJob())) {
                        uiJob.setText(employee.getJob());
                    }
                    if (StringUtils.isNotEmpty(employee.getSuspendStart())) {
                        uiDdg.setSelectedItem(employee.getSuspendStart());
                    }
                    if (StringUtils.isNotEmpty(employee.getEntryDate())) {
                        uiEntryDate.setDate(Utils.dateFromStr(employee.getEntryDate()));
                    }
                    uiWorkAge.setText(UtilsClient.convertWorkAgeToStr(employee.getWorkAge()));
                    if (StringUtils.isNotEmpty(employee.getProbationDate())) {
                        uiProbation.setDate(Utils.dateFromStr(employee.getProbationDate()));
                    }
                    if (StringUtils.isNotEmpty(employee.getExpirationDate())) {
                        uiExpiration.setText(employee.getExpirationDate());
                    }
                    if (StringUtils.isNotEmpty(employee.getDegree())) {
                        uiDegree.setSelectedItem(employee.getDegree());
                    }
                    uiSchool.setText(employee.getSchool());
                    uiMajor.setText(employee.getMajor());
                    uiWorkExperience.setText(employee.getWorkExperience());
                    //               uiSuspendEnd.setText(employee.getSuspendEnd());
                    uiSocialCard.setText(employee.getSocialCard());
                    uiHousingCard.setText(employee.getHousingCard());
                    uiBankCard.setText(employee.getBankCard());
                    uiNote.setText(employee.getNote());
                    uiPerformance.setText(employee.getCensusCity());
                    uiPhoneShort.setText(employee.getPhoneShort());
                    if (StringUtils.isNotEmpty(employee.getLeaveDate())) {
                        uiLeaveDate.setDate(Utils.dateFromStr(employee.getLeaveDate()));
                    }

                    if (StringUtils.isNotEmpty(employee.getSocialEndDate())) {
                        uiSocialEndDate.setText(employee.getSocialEndDate());
                    }
                    if (StringUtils.isNotEmpty(employee.getHousingEndDate())) {
                        uiHousingEndDate.setText(employee.getHousingEndDate());
                    }
                    uiLeaveType.setSelectedItem(employee.getLeaveType());
                    uiLeaveReason.setText(employee.getLeaveReason());
                    if (StringUtils.isNotEmpty(employee.getJobTitle())) {
                        uiGuide.setText(employee.getJobTitle());
                    }
                    hideWaitPanel();
                } catch (Exception e) {
                    hideWaitPanel();
                    showErrorMsg(e);
                }

            }

        }.execute();
    }

    protected void setWorkAge() {
        Calendar probationCalendar = uiEntryDate.getCalendar();
        uiWorkAge.setText(UtilsClient.convertWorkAgeToStr(UtilsClient.getWorkAge(probationCalendar)));

        probationCalendar.add(Calendar.MONTH, 6);
        probationCalendar.add(Calendar.DAY_OF_MONTH, -1);
        uiProbation.setCalendar(probationCalendar);

        Calendar expirationCalendar = uiEntryDate.getCalendar();
        expirationCalendar.add(Calendar.YEAR, 3);
        expirationCalendar.set(Calendar.DAY_OF_MONTH, expirationCalendar.getActualMaximum(Calendar.DAY_OF_MONTH));
        uiExpiration.setCalendar(expirationCalendar);
    }

    protected void uiSaveActionPerformed(final boolean showInfoMsg) {
        try {
            // 
            if (StringUtils.isEmpty(uiName.getText())) {
                throw new Exception("???!");
            }
            if (StringUtils.isEmpty(uiNamePy.getText())) {
                uiNamePy.setText(PinyinUtil.getPinpin(uiName.getText()));
            }
            if (uiState.getSelectedIndex() == 0) {
                throw new Exception("??!");
            }
            if (StringUtils.isEmpty(uiIdCard.getText())) {
                throw new Exception("??!");
            }
            if (uiContact.getText().length() != 0 && uiContact.getText().length() != 11) {
                throw new Exception("??11?!");
            }
            switch (uiState.getSelectedItem().toString()) {
            case "":
                throw new Exception("??!");
            case Employee.STATE_LEAVE:
                if (uiLeaveDate.getCalendar() == null) {
                    throw new Exception("??!");
                }
                if (StringUtils.isEmpty(uiLeaveType.getSelectedItem().toString())) {
                    throw new Exception("??!");
                }
                break;
            case Employee.STATE_DELETE:
                if (uiLeaveDate.getCalendar() == null) {
                    throw new Exception("?!");
                }
                break;
            case Employee.STATE_RETIRE:
                if (uiLeaveDate.getCalendar() == null) {
                    throw new Exception("?!");
                }
                break;
            default:
                break;
            }
            if (StringUtils.isEmpty(uiDept.getText())) {
                throw new Exception("?!");
            }
            if (StringUtils.isEmpty(uiJob.getText())) {
                throw new Exception("??!");
            }
        } catch (Exception e) {
            showErrorMsg(e);
            return;
        }
        showWaitPanel("?......");
        new SwingWorker<String, Void>() {

            @Override
            protected String doInBackground() throws Exception {
                Employee employee = initEmpFromUi();
                return checkEmployeeInfo(employee);
            }

            @Override
            protected void done() {
                try {
                    String info = get();
                    hideWaitPanel();
                    if (info == null) {
                        saveEmpInfo(showInfoMsg);
                    } else {
                        int operation = JOptionPane.showConfirmDialog(InfoEmployee.this,
                                "<html>" + info + "<br/>???</html>", APP_NAME,
                                JOptionPane.YES_NO_OPTION);
                        if (operation == JOptionPane.YES_OPTION) {
                            saveEmpInfo(showInfoMsg);
                        }
                    }
                } catch (Exception e) {
                    hideWaitPanel();
                    showErrorMsg(e);
                }
            }
        }.execute();
    }

    private void saveEmpInfo(final boolean showInfoMsg) {
        showWaitPanel("?......");
        new SwingWorker<Employee, Void>() {

            @Override
            protected Employee doInBackground() throws Exception {
                Employee employee = initEmpFromUi();
                if (StringUtils.isEmpty(employee.getId())) {
                    return HrmBiz.getInstance().insertEmp(employee);
                } else {
                    return HrmBiz.getInstance().updateEmp(employee);
                }
            }

            @Override
            protected void done() {
                try {
                    hideWaitPanel();
                    employee = get();
                    updateData();
                    if (showInfoMsg) {
                        showInfoMsg("??!");
                    }
                } catch (Exception e) {
                    hideWaitPanel();
                    showErrorMsg(e);
                }
            }
        }.execute();
    }

    protected void uiRefreshActionPerformed(ActionEvent evt) {
        queryHistory();
    }

    protected void uiInfoTabStateChanged(ChangeEvent evt) {
        int index = uiInfoTab.getSelectedIndex();
        if (index == 2 && StringUtils.isNotEmpty(uiId.getText())) {
            querySuspend();
        } else if (index == 3 && StringUtils.isNotEmpty(uiId.getText())) {
            queryHistory();
        } else if (index == 4 && StringUtils.isNotEmpty(uiId.getText())) {
            queryJobAdjustment();
        } else if (index == 5 && StringUtils.isNotEmpty(uiId.getText())) {
            uiFindPraisePunishActionPerformed(null);
        } else if (index == 6 && StringUtils.isNotEmpty(uiId.getText())) {
            uiVacationRefreshActionPerformed(null);
        }
    }

    protected void uiStateActionPerformed(ActionEvent evt) {
        switch (uiState.getSelectedItem().toString()) {
        case Employee.STATE_PROBATION:
        case Employee.STATE_CONTRACT:
            uiInfoTab.setEnabledAt(0, true);
            uiInfoTab.setEnabledAt(1, false);
            uiInfoTab.setSelectedIndex(0);
            break;
        case Employee.STATE_LEAVE:
            uiLabelLeaveDate.setText("?");

            uiLabelSocialEnd.setVisible(true);
            uiSocialEndDate.setVisible(true);

            uiLabelHousingEnd.setVisible(true);
            uiHousingEndDate.setVisible(true);

            uiLabelLeaveType.setVisible(true);
            uiLeaveType.setVisible(true);

            uiLabelLeaveReason.setText("?");

            uiInfoTab.setEnabledAt(0, true);
            uiInfoTab.setEnabledAt(1, true);
            uiInfoTab.setSelectedIndex(1);
            break;
        case Employee.STATE_RETIRE:
            uiLabelLeaveDate.setText("");

            uiLabelSocialEnd.setVisible(true);
            uiSocialEndDate.setVisible(true);

            uiLabelHousingEnd.setVisible(true);
            uiHousingEndDate.setVisible(true);

            uiLabelLeaveType.setVisible(false);
            uiLeaveType.setVisible(false);

            uiLabelLeaveReason.setText("");

            uiInfoTab.setEnabledAt(0, true);
            uiInfoTab.setEnabledAt(1, true);
            uiInfoTab.setSelectedIndex(1);
            break;
        case Employee.STATE_DELETE:
            uiLabelLeaveDate.setText("");

            uiLabelSocialEnd.setVisible(false);
            uiSocialEndDate.setVisible(false);

            uiLabelHousingEnd.setVisible(false);
            uiHousingEndDate.setVisible(false);

            uiLabelLeaveType.setVisible(false);
            uiLeaveType.setVisible(false);

            uiLabelLeaveReason.setText("");

            uiInfoTab.setEnabledAt(0, true);
            uiInfoTab.setEnabledAt(1, true);
            uiInfoTab.setSelectedIndex(1);
            break;
        case Employee.STATE_SUSPEND:
            uiInfoTab.setEnabledAt(0, true);
            uiInfoTab.setEnabledAt(1, false);
            uiInfoTab.setEnabledAt(2, true);
            uiInfoTab.setSelectedIndex(2);
            break;
        default:
            //         uiInfoTab.setEnabledAt(0, false);
            //         uiInfoTab.setEnabledAt(1, false);
            //         uiInfoTab.setEnabledAt(2, false);
            uiInfoTab.setSelectedIndex(0);
            break;
        }
    }

    /**
     * ??(?,?,??)
     * @return ?
     */
    private String checkEmployeeInfo(Employee employee) throws Exception {
        List<Employee> emps;

        emps = HrmBiz.getInstance().getRepeatedIdCardEmp(employee);
        if (emps != null) {
            return "??: " + getinfo(emps);
        }

        emps = HrmBiz.getInstance().getRepeatedCensusEmp(employee);
        if (emps != null) {
            return "???: " + getinfo(emps);
        }
        if (employee.getContact().length() > 0) {
            emps = HrmBiz.getInstance().getRepeatedContactEmp(employee);
            if (emps != null) {
                return "???: " + getinfo(emps);
            }
        }
        return null;
    }

    /**
     * ????
     * @param emps
     * @return
     */
    private String getinfo(List<Employee> emps) {
        if (emps != null && emps.size() > 0) {
            String info = "";
            for (Employee emp : emps) {
                info = info + ",[" + emp.getId() + "]" + emp.getName();
            }
            info = info.substring(1);
            return info;
        }
        return null;
    }

    private void queryHistory() {
        new SwingWorker<List<EmployeeHistory>, Void>() {

            @Override
            protected List<EmployeeHistory> doInBackground() throws Exception {
                EmployeeHistory empHistory = new EmployeeHistory();
                empHistory.setEmpId(uiId.getText());
                if (uiHistoryType.getSelectedIndex() > 0) {
                    empHistory.setType(uiHistoryType.getSelectedItem().toString());
                }
                empHistory.setOperator(uiHistoryOperator.getText());
                return HrmBiz.getInstance().getEmpHistory(empHistory);
            }

            @Override
            protected void done() {
                try {
                    List<EmployeeHistory> empHistory = get();
                    if (empHistory != null) {
                        historyModel.setData(empHistory);
                    }
                } catch (Exception e) {
                    showErrorMsg(e);
                }
            }
        }.execute();
    }

    private void querySuspend() {
        new SwingWorker<List<EmployeeSuspend>, Void>() {

            @Override
            protected List<EmployeeSuspend> doInBackground() throws Exception {
                EmployeeSuspend employeeSuspend = new EmployeeSuspend();
                employeeSuspend.setEmpId(uiId.getText());
                return HrmBiz.getInstance().getEmpSuspend(employeeSuspend);
            }

            @Override
            protected void done() {
                try {
                    List<EmployeeSuspend> empSuspend = get();
                    if (empSuspend != null) {
                        suspendModel.setData(empSuspend);
                        uiEmpSuspend.packAll();
                    }
                } catch (Exception e) {
                    showErrorMsg(e);
                }
            }
        }.execute();
    }

    private void queryJobAdjustment() {
        new SwingWorker<List<JobAdjustment>, Void>() {

            @Override
            protected List<JobAdjustment> doInBackground() throws Exception {
                return HrmBiz.getInstance().getJobAdjustmentByEmp(uiId.getText());
            }

            @Override
            protected void done() {
                try {
                    List<JobAdjustment> empHistory = get();
                    if (empHistory != null) {
                        jobAdjustmentModel.setData(empHistory);
                    }
                } catch (Exception e) {
                    showErrorMsg(e);
                }
            }
        }.execute();
    }

    protected void uiAddJobAdjustActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            showErrorMsg("???!");
            return;
        }
        JobAdjustment jobAdjustment = JobAdjustmentInfo.showDialog(InfoEmployee.this, employee);
        if (jobAdjustment != null) {
            jobAdjustmentModel.add(jobAdjustment);
            employee.setDept(jobAdjustment.getNewDept());
            employee.setJob(jobAdjustment.getNewJob());

            uiDept.setText(jobAdjustment.getNewDept());
            uiJob.setText(jobAdjustment.getNewJob());
        }
        dispose();
    }

    protected void uiFindPraisePunishActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            return;
        }
        new SwingWorker<List<PraisePunish>, Void>() {

            @Override
            protected List<PraisePunish> doInBackground() throws Exception {
                Map<String, String> map = new HashMap<String, String>();
                map.put("empId", employee.getId());
                map.put("dateStart", uiPraisePunishDateStart.getText());
                map.put("dateEnd", uiPraisePunishDateEnd.getText());
                if (uiPraisePunishType.getSelectedIndex() != 0) {
                    map.put("ppType", uiPraisePunishType.getSelectedItem().toString());
                }
                return HrmBiz.getInstance().getPraisePunish(map);
            }

            @Override
            protected void done() {
                try {
                    List<PraisePunish> pps = get();
                    if (pps != null) {
                        praisePunishModel.setPps(pps);
                    }
                } catch (Exception e) {
                    hideWaitPanel();
                }
            }
        }.execute();
    }

    protected void uiAddPraisePunishActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            showErrorMsg("???!");
            return;
        }
        PraisePunish pp = InfoPraisePunish.showdialog(this, null, employee);
        if (pp != null) {
            praisePunishModel.addPp(pp);
        }
    }

    private Employee initEmpFromUi() throws Exception {
        Employee employee = new Employee();
        employee.setId(uiId.getText());
        employee.setName(uiName.getText());
        employee.setNamePy(uiNamePy.getText());
        employee.setState(uiState.getSelectedItem().toString());
        employee.setTimeCard(uiTimeCardLeaveCertify.getText());
        employee.setIdCard(uiIdCard.getText());
        employee.setBirthday(uiBirthday.getText());
        employee.setAge(Integer.parseInt(uiAge.getText()));
        employee.setGender(uiGender.getText());
        employee.setMaritalStatus(uiMarital.getSelectedItem().toString());
        employee.setContact(uiContact.getText());
        employee.setCensus(uiCensus.getSelectedItem().toString());
        employee.setCensusAddress(uiCensusAddress.getText());
        employee.setAddress(uiAddress.getText());
        employee.setCensusProvince(uiResidencePermit.getSelectedItem().toString());
        employee.setSuspendNote(uiFactory.getSelectedItem().toString());
        employee.setSuspendStart(uiDdg.getSelectedItem().toString());
        employee.setDept(uiDept.getText());
        employee.setJob(uiJob.getText());
        employee.setEntryDate(Utils.StrFromObj(uiEntryDate.getCalendar()));
        employee.setWorkAge(UtilsClient.convertWorkAgeToInt(uiWorkAge.getText()));
        employee.setProbationDate(Utils.StrFromObj(uiProbation.getCalendar()));
        employee.setExpirationDate(uiExpiration.getText());
        employee.setDegree(uiDegree.getSelectedItem().toString());
        employee.setSchool(uiSchool.getText());
        employee.setMajor(uiMajor.getText());
        employee.setCensusCity(uiPerformance.getText());
        //      employee.setSuspendEnd(uiSuspendEnd.getText());
        employee.setWorkExperience(uiWorkExperience.getText().toString());
        employee.setSocialCard(uiSocialCard.getText().toString());
        employee.setHousingCard(uiHousingCard.getText());
        employee.setBankCard(uiBankCard.getText());
        if (uiPhoneShort.getText().length() != 0) {
            employee.setPhoneShort(uiPhoneShort.getText());
        } else {
            employee.setPhoneShort(uiContact.getText());
        }
        employee.setJobTitle(uiGuide.getText());
        employee.setNote(uiNote.getText());

        EmployeePhoto photo = new EmployeePhoto();
        photo.setEmpId(employee.getId());
        if (uiPhoto.getClientProperty("photo") != null) {
            byte[] photoByte = (byte[]) uiPhoto.getClientProperty("photo");
            photo.setPhoto(photoByte);
        }
        employee.setEmployeePhoto(photo);

        if (Employee.STATE_LEAVE.equals(employee.getState()) || Employee.STATE_RETIRE.equals(employee.getState())
                || Employee.STATE_DELETE.equals(employee.getState())) {
            employee.setCensusCity("");
            employee.setLeaveDate(uiLeaveDate.getText());
            employee.setSocialEndDate(uiSocialEndDate.getText());
            employee.setHousingEndDate(uiHousingEndDate.getText());
            employee.setLeaveType(uiLeaveType.getSelectedItem().toString());
            employee.setLeaveReason(uiLeaveReason.getText());
        } else {
            employee.setLeaveDate("");
            employee.setSocialEndDate("");
            employee.setHousingEndDate("");
            employee.setLeaveType("");
            employee.setLeaveReason("");
        }
        return employee;
    }

    protected void thisWindowClosing(WindowEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            employee = null;
        }
        dispose();
    }

    protected void uiReadIdCardActionPerformed(ActionEvent evt) {
        //      Map<String, String> map = InfoIdCard.showDialog(this);
        //      if (map != null) {
        //         uiName.setText(map.get("name"));
        //         uiIdCard.setText(map.get("idCard"));
        //         uiGender.setText(map.get("gender"));
        //         uiBirthday.setText(map.get("brithday"));
        //         uiAge.setText(Integer.toString(Utils.getAge(map.get("brithday"))));
        //         uiCensusAddress.setText(map.get("address"));
        //         uiPhoto.setImage(map.get("photo"));
        //         uiPhoto.putClientProperty("path", map.get("photo"));
        //         uiNamePy.setText(Pinyin.getPinpin(uiName.getText()));
        //      }
        uiReadIdCardDirectActionPerformed(evt);
    }

    protected void uiReadIdCardDirectActionPerformed(ActionEvent evt) {
        if (!folder.exists() || !file1.exists() || !file2.exists() || !file3.exists() || !file4.exists()) {
            downDlls();
        }
        startRead();
    }

    /**
     * ??dll
     */
    private void downDlls() {
        showWaitPanel("?......");
        new SwingWorker<String, String>() {

            @Override
            protected String doInBackground() throws Exception {
                if (!folder.exists()) {
                    folder.mkdirs();
                }
                if (file1.exists()) {
                    file1.delete();
                }
                if (file2.exists()) {
                    file2.delete();
                }
                if (file3.exists()) {
                    file3.delete();
                }
                if (file4.exists()) {
                    file4.delete();
                }

                HrmBiz.getInstance().downloadFile(file1.getPath(), "/download/potevio/cardapi3.dll");
                HrmBiz.getInstance().downloadFile(file2.getPath(), "/download/potevio/license.dat");
                HrmBiz.getInstance().downloadFile(file3.getPath(), "/download/potevio/sdtapi.dll");
                HrmBiz.getInstance().downloadFile(file4.getPath(), "/download/potevio/WltRS.dll");

                return null;
            }

            @Override
            protected void done() {
                try {
                    get();
                    hideWaitPanel();
                } catch (Exception e) {
                    hideWaitPanel();
                    showErrorMsg(e);
                }
            }

        }.execute();
    }

    private void startRead() {
        new SwingWorker<String, Void>() {
            @Override
            protected String doInBackground() throws Exception {
                int result;
                IdCard idCard = new IdCard();
                String photoPath = System.getProperty("user.dir") + "/temp/" + "idCard.bmp";
                WString imageFile = new WString(photoPath);
                result = IdCardLibrary.INSTANCE.OpenCardReader(0, 4, 115200);
                if (result != 0) {
                    showErrorMsg(IdCard.getErrorMsg(result));
                    return null;
                }
                try {
                    result = IdCardLibrary.INSTANCE.GetPersonMsgW(idCard, imageFile);
                    if (result == 0) {
                        uiName.setText(idCard.getName());
                        uiNamePy.setText(PinyinUtil.getPinpin(idCard.getName()));
                        uiIdCard.setText(idCard.getCardId());
                        uiGender.setText(idCard.getSex());
                        uiBirthday.setText(idCard.getBirthday());
                        uiAge.setText(Integer.toString(Utils.getAge(idCard.getBirthday())));
                        uiCensusAddress.setText(idCard.getAddress());

                        RenderedImage imgOri = ImageIO.read(new File(photoPath));
                        File imgFile = File.createTempFile("photo_", ".png",
                                new File(System.getProperty("user.dir") + "/temp"));
                        ImageIO.write(imgOri, "png", imgFile);

                        uiPhoto.setImage(imgFile.getPath());
                        uiPhoto.putClientProperty("path", imgFile.getPath());
                        FileImageInputStream fiis = new FileImageInputStream(new File(imgFile.getPath()));
                        byte[] photoByte = new byte[(int) fiis.length()];
                        fiis.read(photoByte);
                        fiis.flush();
                        fiis.close();
                        uiPhoto.putClientProperty("photo", photoByte);

                        IdCardLibrary.INSTANCE.CloseCardReader();
                    }
                    Thread.sleep(1000);
                } catch (Exception e) {
                    showErrorMsg(e);
                }
                return null;
            }
        }.execute();
    }

    protected void uiInputFingerActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            showErrorMsg("???!");
            return;
        }
        ZktecoInputFinger.showDialog(this, employee.getId());
    }

    protected void uiSetSuspendActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            showErrorMsg("?????!");
            return;
        }
        if (!employee.getState().equals(Employee.STATE_PROBATION)
                && !employee.getState().equals(Employee.STATE_CONTRACT)) {
            showErrorMsg("?!");
            return;
        }
        EmployeeSuspend es = InfoEmployeeSuspend.showDialog(this, employee.getId(), employee.getName());
        if (es != null) {
            employee.setState(es.getState());
            uiState.setSelectedItem(es.getState());
        }
        updateData();
    }

    protected void uiNameFocusLost(FocusEvent evt) {
        if (StringUtils.isNotEmpty(uiName.getText())) {
            uiNamePy.setText(PinyinUtil.getPinpin(uiName.getText()));
        }
    }

    protected void uiPrintLeaveCertifyActionPerformed(ActionEvent evt) {
        if (!"?".equals(employee.getState())) {
            showErrorMsg("???!");
            return;
        }
        if (Variables.appUser.haveNoRight("rePrintLeaveCertify")
                && uiTimeCardLeaveCertify.getText().equals("???")) {
            showErrorMsg("??????!");
            return;
        }
        final String[] leaveParams = ChooseLeaveCertifyParams.showDialog(this);
        if (leaveParams != null && leaveParams.length == 2) {
            showWaitPanel("??......");
            new SwingWorker<JasperPrint, String>() {

                @Override
                protected JasperPrint doInBackground() throws Exception {
                    File file = File.createTempFile("report_", ".jasper",
                            new File(System.getProperty("user.dir") + File.separator + "temp"));
                    HrmBiz.getInstance().downloadFile(file.getPath(),
                            "/download/reports/EmpLeaveCertificate.jasper");
                    String entryDate = UtilsClient.formatDateToCn(employee.getEntryDate());
                    String printDate = UtilsClient.formatDateToCn(leaveParams[1]);
                    List<Employee> emps = new ArrayList<>();
                    emps.add(employee);
                    Map<String, Object> parameters = new HashMap<String, Object>();
                    parameters.put("leaveReason", leaveParams[0]);
                    parameters.put("declare1", "" + entryDate + "??"
                            + employee.getJob() + "?" + printDate
                            + "??????");
                    parameters.put("declare2", "" + entryDate + "??"
                            + employee.getJob() + "?" + printDate
                            + "??????");
                    parameters.put("serverPath", "http://" + UtilsClient.getLocalProp("server") + ":"
                            + UtilsClient.getStaticProp("server_port") + "/HRM_Server");
                    parameters.put("printDate", printDate);
                    JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file);
                    return JasperFillManager.fillReport(jasperReport, parameters,
                            new JRBeanCollectionDataSource(emps));
                }

                @Override
                protected void done() {
                    try {
                        JasperPrint jasperPrint = get();
                        hideWaitPanel();
                        LynkReportDialog.showDialog(InfoEmployee.this, jasperPrint);
                        uiTimeCardLeaveCertify.setText("???");
                        //                  uiLeaveReason.setText(uiLeaveReason.getText()
                        //                        + "\n???");
                        uiSaveActionPerformed(false);
                    } catch (Exception e) {
                        hideWaitPanel();
                        showErrorMsg(e);
                    }
                }

            }.execute();
        }
    }

    protected void uiVacationRefreshActionPerformed(ActionEvent evt) {
        showWaitPanel("......");
        new SwingWorker<AttendanceVacation, Void>() {

            @Override
            protected AttendanceVacation doInBackground() throws Exception {
                AttendanceVacation av = HrmBiz.getInstance().getAttendanceVacationByEmp(uiId.getText());
                if (av != null) {
                    List<AttendanceVacationHistory> histories = HrmBiz.getInstance()
                            .getAttendanceVacationHistoriesEmp(uiId.getText());
                    av.setHistories(histories);
                } else {
                    av = new AttendanceVacation();
                    av.setStartDay("");
                    av.setEndDay("");
                    av.setLastTotal(0);
                    av.setLastLeft(0);
                    av.setCurrentTotal(0);
                    av.setLeftHours(0);
                }
                return av;
            }

            @Override
            protected void done() {
                try {
                    AttendanceVacation vacation = get();
                    if (vacation == null || "".equals(vacation.getStartDay())) {
                        uiVacationStartEnd.setText("");
                        uiCurrentTotal.setText("");
                        uiLastLeft.setText("");
                        uiLeftHours.setText("");
                    } else {
                        uiVacationStartEnd.setText(vacation.getStartDay() + "  " + vacation.getEndDay());
                        uiCurrentTotal.setText(vacation.getCurrentTotal().toString());
                        uiLastTotal.setText(vacation.getLastTotal().toString());
                        uiLastLeft.setText(vacation.getLastLeft().toString());
                        uiLeftHours.setText(vacation.getLeftHours().toString());
                        if (vacation.getHistories() != null) {
                            attendanceVacationModel.setHistories(vacation.getHistories());
                        }
                    }
                    hideWaitPanel();
                } catch (Exception e) {
                    hideWaitPanel();
                    showErrorMsg(e);
                }
            }
        }.execute();
    }

    protected void uiVacationAddActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            showErrorMsg("???!");
            return;
        }
        if (uiVacationStartEnd.getText().equals("")) {
            showErrorMsg("!");
            return;
        }
        AttendanceVacation av = AttendanceVacationHistoryDetail.showDialog(this, uiId.getText(), uiName.getText());
        if (av != null) {
            uiLeftHours.setText(av.getLeftHours().toString());
            if (av.getHistories() != null && av.getHistories().size() == 1) {
                attendanceVacationModel.addHistory(av.getHistories().get(0));
            }
        }
    }

    protected void uiEndLastLeftActionPerformed(ActionEvent evt) {
        if (StringUtils.isEmpty(employee.getId())) {
            showErrorMsg("???!");
            return;
        }
        if (uiVacationStartEnd.getText().equals("")) {
            showErrorMsg("!");
            return;
        }
        int op = JOptionPane.showConfirmDialog(this, "?????! ?", APP_NAME,
                JOptionPane.YES_NO_OPTION);
        if (op == JOptionPane.YES_OPTION) {
            showWaitPanel("?......");
            new SwingWorker<AttendanceVacation, Void>() {

                @Override
                protected AttendanceVacation doInBackground() throws Exception {
                    return HrmBiz.getInstance().endAttendanceVacationLastLeft(uiId.getText());
                }

                @Override
                protected void done() {
                    try {
                        get();
                        hideWaitPanel();
                        uiVacationRefreshActionPerformed(null);
                    } catch (Exception e) {
                        hideWaitPanel();
                        showErrorMsg(e);
                    }
                }
            }.execute();
        }
    }

    protected void uiChooseJobActionPerformed(ActionEvent evt) {
        if (uiDept.getText().length() == 0) {
            showErrorMsg("!");
            return;
        }
        String job = ChooseJobDialog.showDialog(this, uiDept.getText());
        if (job != null) {
            uiJob.setText(job);
        }
    }

    protected void uiChooseDeptActionPerformed(ActionEvent evt) {
        String dept = ChooseDeptDialog.showDialog(this);
        if (dept != null) {
            uiDept.setText(dept);
        }
    }
}

class EmployeeHistoryModel extends AbstractTableModel {
    private static final long serialVersionUID = 1L;

    private final String[] heads = new String[] { "", "", "?", "",
            "" };
    private List<EmployeeHistory> data;

    public EmployeeHistoryModel() {
        data = new ArrayList<EmployeeHistory>();
    }

    public EmployeeHistoryModel(List<EmployeeHistory> data) {
        this.data = data;
    }

    public void setData(List<EmployeeHistory> data) {
        this.data = data;
        fireTableDataChanged();
    }

    public List<EmployeeHistory> getData() {
        return data;
    }

    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return heads.length;
    }

    @Override
    public String getColumnName(int column) {
        return heads[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
        case 0:
            return data.get(rowIndex).getType();
        case 1:
            return data.get(rowIndex).getChangeValue();
        case 2:
            return data.get(rowIndex).getOperator();
        case 3:
            return data.get(rowIndex).getTime();
        case 4:
            return data.get(rowIndex).getNote();
        default:
            return null;
        }
    }
}

class EmployeeSuspendModel extends AbstractTableModel {
    private static final long serialVersionUID = 1L;

    private final String[] heads = new String[] { "?", "??", "" };
    private List<EmployeeSuspend> data;

    public EmployeeSuspendModel() {
        data = new ArrayList<EmployeeSuspend>();
    }

    public EmployeeSuspendModel(List<EmployeeSuspend> data) {
        this.data = data;
    }

    public void setData(List<EmployeeSuspend> data) {
        this.data = data;
        fireTableDataChanged();
    }

    public List<EmployeeSuspend> getData() {
        return data;
    }

    @Override
    public int getRowCount() {
        return data.size();
    }

    @Override
    public int getColumnCount() {
        return heads.length;
    }

    @Override
    public String getColumnName(int column) {
        return heads[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
        case 0:
            return data.get(rowIndex).getSuspendStart();
        case 1:
            return data.get(rowIndex).getSuspendEnd();
        case 2:
            return data.get(rowIndex).getNote();
        default:
            return null;
        }
    }
}