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

📄 stockaccountentrycreateframe.java~257~

📁 一个使用java 写的进销存代码 使用了ejb 等技术 是学习j2ee的好
💻 JAVA~257~
📖 第 1 页 / 共 3 页
字号:
    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 linkId = "";
    String remark = jTextArea1.getText().trim();
    if (actionCommand.equals("create") |
        actionCommand.equals("update") |
        actionCommand.equals("cancelAccountEntry") |
        actionCommand.equals("restore")
        ) {
      //检查打开的账套是否当前账套
      int result = stockManagementData.isCurrentLedger(ledgerDate);
      if(result == 0){
        JOptionPane.showMessageDialog(null, ledgerDate + "是往期账套,不能进行电子签名和撤消操作.");
        return;
      }
    }
    if (actionCommand.equals("update") |
        actionCommand.equals("cancelAccountEntry") |
        actionCommand.equals("restore")
        ) {
      if(jList1.isSelectionEmpty()){
        JOptionPane.showMessageDialog(null, "先选择会计分录序号.");
        return;
      }
      selectedIndex = jList1.getSelectedIndex();
      //检查会计分录是否上期转入
      linkId = accountEntryLedgers[selectedIndex][1].trim();
      if(linkId.equals("上期转入")){
        JOptionPane.showMessageDialog(null, "该会计分录是上期转入分录,不能进行修改、撤消和恢复操作.");
        return;
      }
      if(Integer.parseInt(accountEntryLedgers[selectedIndex][6]) == 2){
        JOptionPane.showMessageDialog(null, "会计分录已完成,不能进行修改、撤消和恢复操作.");
        return;
      }

    }
    if (actionCommand.equals("search")) {
      //查询
      search();
    }else if(actionCommand.equals("create")){
      action = "create";
      this.clearAccountEntryLedger();
      this.checkBtn(true);
      this.checkSubBtn(true);
    }else if(actionCommand.equals("update")){
      action = "update";
      this.checkBtn(true);
    }else if(actionCommand.equals("ok")){
      //创建会计分录数据表的单个记录数组
      String[] accountEntryLedger = new String[8];
      //取得会计分录的值
      accountEntryLedger[1] = jTextField5.getText().trim(); //相关票据标识
      accountEntryLedger[2] = user.getUserName();           //记账用户
      accountEntryLedger[3] = "";                           //审核用户
      accountEntryLedger[4] = jTextField8.getText().trim(); //记账日期
      accountEntryLedger[5] = null;                         //审核日期
      accountEntryLedger[6] = "0";                          //完成状态
      accountEntryLedger[7] = remark;                       //备注
      int result = 0;
      if(action.equals("create") | action.equals("update")){
        //检查明细账是否为空
        if(accountEntrySubLedgerObjects.length == 0){
          JOptionPane.showMessageDialog(null, "明细账数据表为空,不可以创建会计分录.");
          return;
        }
        //检查借货是否平衡
        this.recountBalance();
        double total = Double.parseDouble(jTextField11.getText().trim());
        if(total != 0){
          JOptionPane.showMessageDialog(null, "明细账借贷不平衡,不可以创建会计分录.");
          return;
        }
        //检查记账日期是否正确
        if(dataMethod.transferDate(accountEntryLedger[4]) == null){
          JOptionPane.showMessageDialog(null, "记账日期不正确,请重新重入.");
          return;
        }
        //转换表格数据
        this.transferTableData();
      }
      if(action.equals("create")){
        //创建添加的会计分录数组
        String[] accountEntryLedgerForCreate = new String[7];
        System.arraycopy(accountEntryLedger, 1, accountEntryLedgerForCreate, 0, 7);
        //创建添加的会计分录的明细数组
        String[][] accountEntrySubLedgersForCreate = new String[accountEntrySubLedgers.length][3];
        for(int i = 0; i < accountEntrySubLedgers.length; i++){
          System.arraycopy(accountEntrySubLedgers[i], 2, accountEntrySubLedgersForCreate[i], 0, 3);
        }
        //添加会计分录
        result = stockManagementData.createAccountEntry(ledgerDate,
            accountEntryLedgerForCreate, accountEntrySubLedgersForCreate);
        if(result == 1){
          JOptionPane.showMessageDialog(null, "会计分录添加成功,请重新执行查询操作显示新的会计分录.");
        }else{
          JOptionPane.showMessageDialog(null, "会计分录添加失败,请检查输入值是否大于字段范围.");
        }
      }else if (action.equals("update")){
        selectedIndex = jList1.getSelectedIndex();
        //序号、记帐用户保持不变
        accountEntryLedger[0] = accountEntryLedgers[selectedIndex][0];
        accountEntryLedger[2] = accountEntryLedgers[selectedIndex][2];
        //更新会计分录,更新会计分录后将会计分录的完成状态设为进行
        result = stockManagementData.updateAccountEntry(ledgerDate,
            accountEntryLedger, accountEntrySubLedgers);
        if(result == 1){
          JOptionPane.showMessageDialog(null, "会计分录更新成功.");
          //更新会计分录数组
          accountEntryLedgers[selectedIndex][1] = accountEntryLedger[1]; //关联标识
          accountEntryLedgers[selectedIndex][3] = "";                    //审核用户
          accountEntryLedgers[selectedIndex][4] = accountEntryLedger[4]; //记账日期
          accountEntryLedgers[selectedIndex][5] = "";                    //审核日期
          accountEntryLedgers[selectedIndex][6] = "0";                   //完成状态
          accountEntryLedgers[selectedIndex][7] = remark;                //备注
          //更新编辑框的状态
          jTextField7.setText("");
          jTextField9.setText("");
          jTextField10.setText(onProcesses[0]);
        }else{
          JOptionPane.showMessageDialog(null, "会计分录更新失败.");
        }
      }
      this.checkSubBtn(false);
      this.checkBtn(false);
    }else if(actionCommand.equals("cancel")){
      this.jList1_valueChanged(null);
      this.checkBtn(false);
      this.checkSubBtn(false);
    }else if(actionCommand.equals("cancelAccountEntry")){
      selectedIndex = jList1.getSelectedIndex();
      serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]);
      //撤消会计分录
      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")){
      selectedIndex = jList1.getSelectedIndex();
      serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]);
      //恢复会计分录的完成状态
      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[0]);
      }else{
        JOptionPane.showMessageDialog(null, "会计分录恢复失败.");
      }
    }else if(actionCommand.equals("createSub")){
      //为会计分录明细表添加一个空行
      int objectsLength = accountEntrySubLedgerObjects.length;
      Object[][] tempObjs = new Object[objectsLength + 1][5];
      System.arraycopy(accountEntrySubLedgerObjects, 0, tempObjs, 0, objectsLength);
      tempObjs[objectsLength][0] = new Integer(0);
      tempObjs[objectsLength][1] = new Integer(0);
      tempObjs[objectsLength][2] = "借";
      tempObjs[objectsLength][3] = "";
      tempObjs[objectsLength][4] = new Double(0);
      accountEntrySubLedgerObjects = tempObjs;
      this.showTableData(accountEntrySubLedgerObjects);
    }else if(actionCommand.equals("deleteSub")){
      if(jTable1.getSelectedRowCount() == 0){
        JOptionPane.showMessageDialog(null, "请选择明细记录.");
        return;
      }
      //删除选择的记录
      int tableSelectedIndex = jTable1.getSelectedRow();
      Object[][] tempObjs = new Object[accountEntrySubLedgerObjects.length - 1][5];
      int line = 0;
      for(int i = 0; i < accountEntrySubLedgerObjects.length; i++){
        if(i == tableSelectedIndex){
          continue;
        }else{
          for(int j = 0; j < 5; j++){
            tempObjs[line][j] = accountEntrySubLedgerObjects[i][j];
          }
          line++;
        }
      }
      accountEntrySubLedgerObjects = tempObjs;
      this.showTableData(accountEntrySubLedgerObjects);
    }else if(actionCommand.equals("exit")){
      exit();
    }
  }
}

⌨️ 快捷键说明

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