/**
   * 判断填写的内容是否正确
   *
   * @param jtextField
   * @param jLabel
   * @param tip
   */
  private void judgeTextContent(
      JTextField jtextField, JLabel jLabel, String tip, Boolean obligatory) {
    if (StringUtil.isNotNull(jtextField.getText())) {
      if (StringUtil.isNull(tip)) {
        jLabel.setIcon(ImageService.getImageIcon("onCorrect"));
        jLabel.setToolTipText("");
      } else {
        jLabel.setIcon(ImageService.getImageIcon("onError"));
        jLabel.setToolTipText(tip);
      }

    } else {
      jLabel.setIcon(ImageService.getImageIcon(obligatory ? "onError" : "onShow"));
      jLabel.setToolTipText(tip);
    }
  }
 private void jTextField9FocusLost(
     java.awt.event.FocusEvent evt) { // GEN-FIRST:event_jTextField9FocusLost
   // 判断是否正确
   String message = "备注为空";
   if (StringUtil.isNotNull(jTextField9.getText())) {
     message = "";
   }
   judgeTextContent(jTextField9, jLabel16, message, false);
 } // GEN-LAST:event_jTextField9FocusLost
 private void jTextField3FocusLost(
     java.awt.event.FocusEvent evt) { // GEN-FIRST:event_jTextField3FocusLost
   // 正则判断用户名是否正确
   String message = "姓名为空";
   if (StringUtil.isNotNull(jTextField3.getText())) {
     message = "";
   }
   judgeTextContent(jTextField3, jLabel10, message, true);
 } // GEN-LAST:event_jTextField3FocusLost
 private void jTextField8FocusLost(
     java.awt.event.FocusEvent evt) { // GEN-FIRST:event_jTextField8FocusLost
   // 判断是否正确
   String message = "邮箱为空";
   if (StringUtil.isNotNull(jTextField8.getText())) {
     message =
         RegExUtil.ereg(RegExUtil.regexData.email, jTextField8.getText().trim()) ? "" : "邮箱输入不正确";
   }
   judgeTextContent(jTextField8, jLabel15, message, false);
 } // GEN-LAST:event_jTextField8FocusLost
  /**
   * 保存
   *
   * @param evt
   */
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    String message = "";
    String name = (String) jComboBox1.getSelectedItem();
    if (CommonSession.getGroupName().equals(name)) {
      message = "请选择公司";
      javax.swing.JOptionPane.showConfirmDialog(
          (java.awt.Component) null, message, "提示", javax.swing.JOptionPane.DEFAULT_OPTION);
      return;
    }
    String departmentName = (String) jComboBox2.getSelectedItem();
    if (CommonConstant.CONSTANT_DEFAULT_DEPARTMENT.equals(departmentName)) {
      message = "请选择部门";
      javax.swing.JOptionPane.showConfirmDialog(
          (java.awt.Component) null, message, "提示", javax.swing.JOptionPane.DEFAULT_OPTION);
      return;
    }
    String username = jTextField3.getText();
    if (StringUtil.isNull(username)) {
      message = "姓名为空";
      javax.swing.JOptionPane.showConfirmDialog(
          (java.awt.Component) null, message, "提示", javax.swing.JOptionPane.DEFAULT_OPTION);
      return;
    }

    ContactInfo ci = new ContactInfo();
    // 获取公司 部门ID
    //        String companyId = "";
    //        String departmentId = "";
    //        List<Department> departmentList = mapDepartment.get(name);
    //        for (Department d : departmentList) {
    //            if (d.getDepartment().equalsIgnoreCase(departmentName)) {
    //                companyId = d.getCompany();
    //                departmentId = d.getId();
    //                break;
    //            }
    //        }
    //        ci.setCompany(companyId);
    //        ci.setDepartment(departmentId);

    ci.setCompany((String) jComboBox1.getSelectedItem());
    ci.setDepartment((String) jComboBox2.getSelectedItem());

    ci.setEmail(jTextField8.getText());
    ci.setFax(jTextField6.getText());
    ci.setInside(jTextField5.getText());
    ci.setMobile(jTextField7.getText());
    ci.setName(jTextField3.getText());
    ci.setRemark(jTextField9.getText());
    ci.setTel(jTextField4.getText());
    ContactInfoService contactInfoService = new ContactInfoService();
    contactInfoService.save(ci);
    String sql = "select max(id) from contactinfo ";
    int id = contactInfoService.countByHql(sql);
    ci.setId(String.valueOf(id));
    setVisible(false);
    dispose();
    message = "联系人新增成功";
    javax.swing.JOptionPane.showConfirmDialog(
        (java.awt.Component) null, message, "提示", javax.swing.JOptionPane.DEFAULT_OPTION);

    // 新增系统中的数据
    this.mainJFrame.getListContactInfo().add(ci);
    // 新增JTree1的数据
    this.mainJFrame.getMapContactInfo().get(ci.getCompany()).get(ci.getDepartment()).add(ci);
    // 初始化JTree1
    this.mainJFrame.initJTree1();
  } // GEN-LAST:event_jButton1ActionPerformed