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

📄 stockaccountentrycheckframe.java~253~

📁 一个使用java 写的进销存代码 使用了ejb 等技术 是学习j2ee的好
💻 JAVA~253~
📖 第 1 页 / 共 2 页
字号:
  //设置用户的方法
  public void setUser(User user) {
    this.user = user;
  }
  //设置账套的方法
  public void setLedgerDate(String ledgerDate) {
    this.ledgerDate = ledgerDate;
  }
  protected void processWindowEvent(WindowEvent e) {
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      exit();
    }
  }
  //显示查询会计分录的方法
  public void showSearchAccountEntryLedger(){
    listData1.clear();
    //为会计分录列表框加入会计分录数据
    for(int i = 0; i < accountEntryLedgers.length; i++){
      listData1.addElement(accountEntryLedgers[i][0]);
    }
  }
  //显示单个会计分录的方法
  public void showAccountEntryLedger(){
    //取得当前选择项的位置
    int selectedIndex = jList1.getSelectedIndex();
    //当列表框不处于选择状态,不显示商品数据
    if(selectedIndex == -1){
       return;
    }
    //显示会计分录的数据
    jTextField4.setText(accountEntryLedgers[selectedIndex][0]);
    jTextField5.setText(accountEntryLedgers[selectedIndex][1]);
    jTextField6.setText(accountEntryLedgers[selectedIndex][2]);
    jTextField7.setText(accountEntryLedgers[selectedIndex][3]);
    jTextField8.setText(accountEntryLedgers[selectedIndex][4]);
    jTextField9.setText(accountEntryLedgers[selectedIndex][5]);
    jTextField10.setText(onProcesses[Integer.parseInt(accountEntryLedgers[selectedIndex][6])]);
    jTextArea1.setText(accountEntryLedgers[selectedIndex][7]);
    //显示会计分录明细数据
    this.showAccountEntrySubLedger();
  }
  //显示会计分录明细数据的方法
  public void showAccountEntrySubLedger(){
    //取得当前选择项的位置
    int selectedIndex = jList1.getSelectedIndex();
    int serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]);
    accountEntrySubLedgers = stockManagementData.getAccountEntrySubLedgerByLinkSerialId(ledgerDate, serialId);
    //将数组数据转换为表格数据
    accountEntrySubLedgerObjects = new Object[accountEntrySubLedgers.length][5];
    double total = 0;
    for(int i = 0; i < accountEntrySubLedgers.length; i++){
      accountEntrySubLedgerObjects[i][0] = new Integer(accountEntrySubLedgers[i][0]);
      accountEntrySubLedgerObjects[i][1] = new Integer(accountEntrySubLedgers[i][1]);
      int debitCredit = Integer.parseInt(accountEntrySubLedgers[i][2]);
      accountEntrySubLedgerObjects[i][2] = debitCreditStrs[debitCredit];
      accountEntrySubLedgerObjects[i][3] = dataMethod.transferAccountName(accountEntrySubLedgers[i][3]);
      double amount = dataMethod.round(Double.parseDouble(accountEntrySubLedgers[i][4]));
      accountEntrySubLedgerObjects[i][4] = new Double(amount);
      if(debitCredit == 0){
        total += amount;
      }else{
        total -= amount;
      }
    }
    //显示借贷平衡数字
    jTextField11.setText(String.valueOf(dataMethod.round(total)));
    //显示表格的内容
    this.showTableData(accountEntrySubLedgerObjects);
  }
  //显示表格内容的方法
  public void showTableData(Object[][] detail){
    //设置表格的标题
    aeslTableModel.setColumnNames(colNames);
    //设置表格的数据
    aeslTableModel.setData(detail);
    //设置表格的列编辑状态,所有列不能编辑
    aeslTableModel.setColumnEditState(1);
    jTable1 = new JTable(aeslTableModel);
    //设置表格的字体
    jTable1.setFont(dialog13);
    //将数据表格加入数据滚动框
    jScrollPane3.getViewport().add(jTable1, null);
    //为表格科目标识列加入下拉列表框
    javax.swing.table.TableColumn debitCreditColumn = jTable1.getColumnModel().getColumn(2);
    JComboBox comboBox = new JComboBox(new String[] {"借","贷"});
    debitCreditColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //设置列的宽度
    jTable1.getColumnModel().getColumn(0).setPreferredWidth(20);
    jTable1.getColumnModel().getColumn(1).setPreferredWidth(20);
    jTable1.getColumnModel().getColumn(2).setPreferredWidth(20);
    jTable1.getColumnModel().getColumn(3).setPreferredWidth(120);
    jTable1.getColumnModel().getColumn(4).setPreferredWidth(20);
  }
  //清空单个会计分录显示的方法
  public void clearStockLedger(){
    jTextField4.setText("");
    jTextField5.setText("");
    jTextField6.setText("");
    jTextField7.setText("");
    jTextField8.setText("");
    jTextField9.setText("");
    jTextField10.setText("");
    jTextField11.setText("");
    jTextArea1.setText("");
    accountEntrySubLedgers = new String[0][5];
    accountEntrySubLedgerObjects = new Object[0][5];
    this.showTableData(accountEntrySubLedgerObjects);
  }
  //列表1的选择事件
  void jList1_valueChanged(ListSelectionEvent e) {
    if(listData1.size() > 0){
      this.showAccountEntryLedger();
    }else{
      this.clearStockLedger();
    }
  }
  //查询方法
  public void search(){
    //取得查询选项
    int selectedIndex = jComboBox2.getSelectedIndex();
    int accountNameSelectedIndex = jComboBox1.getSelectedIndex();
    //创建科目查询字符串数组
    String[] accountNamesSearch = {"应付账款", "存货", "现金", ""};
    String accountNameSearch = accountNamesSearch[accountNameSelectedIndex];
    //取得编辑框的变量
    String searchValue = jTextField1.getText().trim();
    String startDateStr = jTextField2.getText().trim();
    String endDateStr = jTextField3.getText().trim();
    if (selectedIndex == 0 | selectedIndex == 1 | selectedIndex == 2 |
        selectedIndex == 3) {
      if (searchValue.length() == 0) {
        JOptionPane.showMessageDialog(null, "请输入查询值");
        return;
      }
      switch (selectedIndex) {
        case 0:
          //根据关联标识取得记录
          accountEntryLedgers = stockManagementData.getAccountEntryLedgerByStringField(
              ledgerDate, accountNameSearch, "linkId", searchValue);
          break;
        case 1:
          //根据记账用户取得记录
          accountEntryLedgers = stockManagementData.getAccountEntryLedgerByStringField(
              ledgerDate, accountNameSearch, "filler", searchValue);
          break;
        case 2:
          //根据审核用户取得记录
          accountEntryLedgers = stockManagementData.getAccountEntryLedgerByStringField(
              ledgerDate, accountNameSearch, "auditUser", searchValue);
          break;
        case 3:
          if(dataMethod.checkInt(searchValue) == 0){
            JOptionPane.showMessageDialog(null, "按完成状态查询时,输入值必须是整数,"
                                          + "0表示进行,1表示撤消,2表示完成.");
            return;
          }
          //根据完成状态取得记录
          accountEntryLedgers = stockManagementData.getAccountEntryLedgerByOnProcess(
              ledgerDate, accountNameSearch, Integer.parseInt(searchValue));
          break;
      }
    }else{
      java.sql.Timestamp startDate = dataMethod.transferDate(startDateStr);
      java.sql.Timestamp endDate = dataMethod.transferEndDate(endDateStr);
      if(startDate == null | endDate == null){
        JOptionPane.showMessageDialog(null, "日期输入错误,正确的日期格式是"
                                      + "yyyy-mm-dd(年-月-日),如2004-1-1");
        return;
      }
      //根据日期取得记录
      accountEntryLedgers = stockManagementData.getAccountEntryLedgerByFillDate(
          ledgerDate, startDate, endDate, accountNameSearch);
    }
    this.showSearchAccountEntryLedger();
  }
  //单击事件
  public void actionPerformed(ActionEvent e) {
    //取得按钮的动作字符串
    String actionCommand = e.getActionCommand().trim();
    int selectedIndex = 0;
    int serialId = 0;
    String userName = user.getUserName();
    String remark = jTextArea1.getText().trim();
    if (actionCommand.equals("sign") |
        actionCommand.equals("unSign") |
        actionCommand.equals("cancel") |
        actionCommand.equals("restore")
        ) {
      //检查打开的账套是否当前账套
      int result = stockManagementData.isCurrentLedger(ledgerDate);
      if(result == 0){
        JOptionPane.showMessageDialog(null, ledgerDate + "是往期账套,不能进行电子签名和撤消操作.");
        return;
      }
      if(jList1.isSelectionEmpty()){
        JOptionPane.showMessageDialog(null, "先选择会计分录序号.");
        return;
      }
      selectedIndex = jList1.getSelectedIndex();
      serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]);
      //检查会计分录是否上期转入
      String linkId = accountEntryLedgers[selectedIndex][1].trim();
      if(linkId.equals("上期转入")){
        JOptionPane.showMessageDialog(null, "该会计分录是上期转入分录,不能进行电子签名和撤消操作.");
        return;
      }
    }
    if(actionCommand.equals("sign") | actionCommand.equals("unSign")){
      if(Integer.parseInt(accountEntryLedgers[selectedIndex][6]) == 1){
        JOptionPane.showMessageDialog(null, "会计分录已撤消,不能进行电子签名操作.");
        return;
      }
    }
    if(actionCommand.equals("cancel") | actionCommand.equals("restore")){
      if(Integer.parseInt(accountEntryLedgers[selectedIndex][6]) == 2){
        JOptionPane.showMessageDialog(null, "会计分录已完成,不能进行撤消和恢复操作.");
        return;
      }
    }
    if (actionCommand.equals("search")) {
      //查询
      search();
    }else if(actionCommand.equals("sign")){
      //进行电子签名
      int result = stockManagementData.signAccountEntryLedger(ledgerDate, "auditUser",
          userName, serialId, 2,remark);
      if(result == 1){
        JOptionPane.showMessageDialog(null, "电子签名成功.");
        //更新数组的数据
        accountEntryLedgers[selectedIndex][3] = userName;
        accountEntryLedgers[selectedIndex][6] = "2";
        accountEntryLedgers[selectedIndex][7] = remark;
        //更新编辑框的值
        jTextField7.setText(userName);
        jTextField10.setText(onProcesses[2]);
      }else{
        JOptionPane.showMessageDialog(null, "电子签名失败.");
      }
    }else if(actionCommand.equals("unSign")){
      //取消电子签名
      int result = stockManagementData.signAccountEntryLedger(ledgerDate,
          "auditUser", "", serialId, 0, remark);
      if(result == 1){
        JOptionPane.showMessageDialog(null, "取消电子签名成功.");
        accountEntryLedgers[selectedIndex][3] = "";
        accountEntryLedgers[selectedIndex][6] = "0";
        accountEntryLedgers[selectedIndex][7] = remark;
        //更新编辑框的值
        jTextField7.setText("");
        jTextField10.setText(onProcesses[0]);
      }else{
        JOptionPane.showMessageDialog(null, "取消电子签名失败.");
      }
    }else if(actionCommand.equals("cancel")){
      //撤消会计分录
      int result = stockManagementData.cancelOrRestoreAccountEntryLedger(
          ledgerDate, serialId, 1, remark);
      if(result == 1){
        JOptionPane.showMessageDialog(null, "会计分录撤消成功.");
        //更新数组的数据
        accountEntryLedgers[selectedIndex][6] = "1";
        accountEntryLedgers[selectedIndex][7] = remark;
        //更新编辑框的值
        jTextField10.setText(onProcesses[1]);
      }else{
        JOptionPane.showMessageDialog(null, "会计分录撤消失败.");
      }
    }else if(actionCommand.equals("restore")){
      //恢复会计分录的完成状态
      int result = stockManagementData.cancelOrRestoreAccountEntryLedger(
          ledgerDate, serialId, 0, remark);
      if(result == 1){
        JOptionPane.showMessageDialog(null, "会计分录恢复成功.");
        //更新数组的数据
        accountEntryLedgers[selectedIndex][6] = "0";
        accountEntryLedgers[selectedIndex][7] = remark;
        //更新编辑框的值
        jTextField10.setText(onProcesses[1]);
      }else{
        JOptionPane.showMessageDialog(null, "会计分录恢复失败.");
      }
    }else if(actionCommand.equals("exit")){
      exit();
    }
  }
  //使窗口居中的方法
  public void setCenterPosition(JFrame frame){
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height) {
      frameSize.height = screenSize.height;
    }
    if (frameSize.width > screenSize.width) {
      frameSize.width = screenSize.width;
    }
    frame.setLocation( (screenSize.width - frameSize.width) / 2,
                           (screenSize.height - frameSize.height) / 2);
  }
}

⌨️ 快捷键说明

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