示例#1
0
  /** 查询 */
  private void search() {
    // 调用查询窗口
    Function function = new Function();
    Search search = new Search(this, staffInfo);
    function.setFunctionDialog(search);
    function.create();
    if (search.isUpdate()) {
      int searched = search.getSearched();

      switch (searched) {
        case 0:
          DMManage();
          break;
        case 1:
          break;
        case 3:
          break;
        case 4:
          break;
        case 5:
          break;
      }
      content = search.getResultContent();
      header = search.getResultHeader();
      displayPanel.setBorder(
          BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "查询结果"));
      setTable(content, header);
    }
  }
示例#2
0
  /** 生成面板内容 */
  private void createContent() {
    contentPanel = new JPanel(new BorderLayout());
    panel.add(contentPanel, BorderLayout.CENTER);

    Box message = Box.createVerticalBox();
    message.setBorder(BorderFactory.createEtchedBorder());

    dateImg = new JLabel(new ImageIcon(TMFrame.class.getResource("/images/calendar.gif")));
    String today = Today.getYear() + "年" + Today.getMonth() + "月" + Today.getDate() + "日";
    date = new JLabel(today);
    date.setFont(font);
    week = new JLabel(Today.getWeek());
    week.setFont(font);
    nameImg = new JLabel(new ImageIcon(TMFrame.class.getResource("/images/role.png")));
    name = new JLabel(staffInfo.getStaffName());
    name.setFont(font);
    role = new JLabel("总经理");
    role.setFont(font);

    Box messageTop = Box.createVerticalBox();
    Box messageCenter = Box.createHorizontalBox();
    Box messageBottom = Box.createVerticalBox();

    messageTop.add(Box.createVerticalStrut(1));
    messageCenter.add(Box.createHorizontalStrut(5));
    messageCenter.add(dateImg);
    messageCenter.add(Box.createHorizontalStrut(2));
    messageCenter.add(date);
    messageCenter.add(Box.createHorizontalStrut(20));
    messageCenter.add(week);
    messageCenter.add(Box.createHorizontalStrut(50));
    messageCenter.add(nameImg);
    messageCenter.add(Box.createHorizontalStrut(2));
    messageCenter.add(name);
    messageCenter.add(Box.createHorizontalStrut(20));
    messageCenter.add(role);
    messageCenter.add(Box.createHorizontalGlue());
    messageBottom.add(Box.createVerticalStrut(1));

    message.add(messageTop);
    message.add(messageCenter);
    message.add(messageBottom);
    contentPanel.add(message, BorderLayout.NORTH);
  }
示例#3
0
  /** 人员管理 */
  private void DMManage() {
    print.setEnabled(true);
    printAction.setEnabled(true);

    // 删除原有内容
    if (displayPanel != null && tips != null) {
      contentPanel.remove(displayPanel);
      contentPanel.remove(tips);
      validate();
      repaint();
    }

    staffContent = GetInfo.getStaffInfo();
    staffTitle = GetInfo.getStaffTitle();

    content = VectorFilter.doubleFilter(VectorFilter.STAFFFILTER, staffContent);
    content = VectorFilter.dataFilter(1, staffInfo.getStaffName(), content); // 过滤自己
    content = VectorFilter.positionFilter(4, "部门经理", content); // 过滤得到部门经理
    header = VectorFilter.singleFilter(VectorFilter.STAFFFILTER, staffTitle);

    // 建立显示区面板
    displayPanel = new JPanel(new BorderLayout());
    displayPanel.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "人员管理"));

    // 加入JTable
    setTable(content, header);
    scrollPanel = new JScrollPane(table);
    displayPanel.add(scrollPanel, BorderLayout.CENTER);

    // 加入功能区
    Box functionBox = Box.createVerticalBox();
    Box functionTop = Box.createVerticalBox();
    Box functionCenter = Box.createHorizontalBox();
    Box functionUnderCenterTop = Box.createVerticalBox();
    Box functionUnderCenter = Box.createHorizontalBox();
    Box functionBottom = Box.createVerticalBox();

    functionTop.add(Box.createVerticalStrut(10));
    functionUnderCenterTop.add(Box.createVerticalStrut(10));
    functionBottom.add(Box.createVerticalStrut(20));

    JLabel sift = new JLabel("筛选");
    sift.setFont(font);
    siftKey.setText("");
    JLabel fun = new JLabel("功能");
    fun.setFont(font);
    viewDM.setText("查看");
    viewDM.setFont(font);
    addDM.setText("增加");
    addDM.setFont(font);
    deleteDM.setText("删除");
    deleteDM.setFont(font);
    modifyDM.setText("修改");
    modifyDM.setFont(font);
    modifyDMPassword.setText("设置密码");
    modifyDMPassword.setFont(font);
    hideOutDate.setFont(font);
    functionCenter.add(Box.createHorizontalStrut(2));
    functionCenter.add(sift);
    functionCenter.add(Box.createHorizontalStrut(10));
    functionCenter.add(siftKey);
    functionCenter.add(Box.createHorizontalStrut(100));
    functionCenter.add(hideOutDate);
    functionCenter.add(Box.createHorizontalStrut(180));
    functionUnderCenter.add(Box.createHorizontalStrut(2));
    functionUnderCenter.add(fun);
    functionUnderCenter.add(Box.createHorizontalStrut(10));
    functionUnderCenter.add(viewDM);
    functionUnderCenter.add(Box.createHorizontalStrut(10));
    functionUnderCenter.add(addDM);
    functionUnderCenter.add(Box.createHorizontalStrut(10));
    functionUnderCenter.add(deleteDM);
    functionUnderCenter.add(Box.createHorizontalStrut(10));
    functionUnderCenter.add(modifyDM);
    functionUnderCenter.add(Box.createHorizontalStrut(10));
    functionUnderCenter.add(modifyDMPassword);
    functionUnderCenter.add(Box.createHorizontalGlue());

    functionBox.add(functionTop);
    functionBox.add(functionCenter);
    functionBox.add(functionUnderCenterTop);
    functionBox.add(functionUnderCenter);
    functionBox.add(functionBottom);
    displayPanel.add(functionBox, BorderLayout.SOUTH);

    // 建立提示区面板
    tips = Box.createHorizontalBox();
    tips.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "系统提示"));
    tips.add(Box.createHorizontalStrut(200));

    // 加入系统提示
    // TODO 加入系统提示信息

    contentPanel.add(displayPanel, BorderLayout.CENTER);
    contentPanel.add(tips, BorderLayout.EAST);

    validate();
  }
示例#4
0
  /** 创建工具栏 */
  private void createToolBar() {
    panel = new JPanel(new BorderLayout());

    // 加入工具栏
    toolBar = new JToolBar();
    panel.add(toolBar, BorderLayout.NORTH);

    // 保存
    saveAction =
        new AbstractAction("保存", new ImageIcon(TMFrame.class.getResource("/images/TSave.gif"))) {

          public void actionPerformed(ActionEvent e) {
            save();
          }
        };

    // 打印
    printAction =
        new AbstractAction("打印", new ImageIcon(TMFrame.class.getResource("/images/TPrint.gif"))) {

          public void actionPerformed(ActionEvent e) {
            print();
          }
        };

    // 人员管理
    DMManageAction =
        new AbstractAction("人员管理", new ImageIcon(TMFrame.class.getResource("/images/TStaff.gif"))) {

          public void actionPerformed(ActionEvent e) {
            DMManage();
          }
        };

    // 备份数据库
    Action backupAction =
        new AbstractAction(
            "备份数据库", new ImageIcon(TMFrame.class.getResource("/images/TBackup.gif"))) {

          public void actionPerformed(ActionEvent e) {
            backup();
          }
        };

    // 恢复数据库
    Action restoreAction =
        new AbstractAction(
            "恢复数据库", new ImageIcon(TMFrame.class.getResource("/images/TRestore.gif"))) {

          public void actionPerformed(ActionEvent e) {
            restore();
          }
        };

    Action searchAction =
        new AbstractAction("查询", new ImageIcon(TMFrame.class.getResource("/images/TSearch.gif"))) {

          public void actionPerformed(ActionEvent e) {
            search();
          }
        };

    // 帮助文档
    Action helpAction =
        new AbstractAction("帮助", new ImageIcon(TMFrame.class.getResource("/images/THelp.gif"))) {

          public void actionPerformed(ActionEvent e) {
            help();
          }
        };

    // 关于我们
    Action aboutAction =
        new AbstractAction(
            "关于我们", new ImageIcon(TMFrame.class.getResource("/images/TAboutUS.gif"))) {

          public void actionPerformed(ActionEvent e) {
            about();
          }
        };

    Action exitAction =
        new AbstractAction("退出", new ImageIcon(TMFrame.class.getResource("/images/TExit.gif"))) {

          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        };

    // 为工具栏图标加入提示
    saveAction.putValue(Action.SHORT_DESCRIPTION, "保存");
    printAction.putValue(Action.SHORT_DESCRIPTION, "打印");
    DMManageAction.putValue(Action.SHORT_DESCRIPTION, "人员管理");
    backupAction.putValue(Action.SHORT_DESCRIPTION, "备份数据库");
    restoreAction.putValue(Action.SHORT_DESCRIPTION, "恢复数据库");
    searchAction.putValue(Action.SHORT_DESCRIPTION, "查询");
    helpAction.putValue(Action.SHORT_DESCRIPTION, "帮助文档");
    aboutAction.putValue(Action.SHORT_DESCRIPTION, "关于我们");
    exitAction.putValue(Action.SHORT_DESCRIPTION, "退出系统");

    toolBar.add(saveAction);
    toolBar.add(printAction);
    toolBar.add(DMManageAction);
    toolBar.add(backupAction);
    toolBar.add(restoreAction);
    toolBar.add(searchAction);
    toolBar.add(helpAction);
    toolBar.add(aboutAction);
    toolBar.add(exitAction);

    toolBar.setBorder(BorderFactory.createEtchedBorder());
    toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2));
    add(panel);

    // 设置图标活动性
    saveAction.setEnabled(false);
    printAction.setEnabled(false);
    backupAction.setEnabled(false);
    restoreAction.setEnabled(false);
  }