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

📄 stockaccountentrycreateframe.java~260~

📁 一个使用java 写的进销存代码 使用了ejb 等技术 是学习j2ee的好
💻 JAVA~260~
📖 第 1 页 / 共 3 页
字号:
    contentPane.add(jTextField11, null);
    contentPane.add(jScrollPane1, null);
    contentPane.add(jScrollPane2, null);
    contentPane.add(jScrollPane3, null);
    contentPane.add(jButton1, null);
    contentPane.add(jButton2, null);
    contentPane.add(jButton3, null);
    contentPane.add(jButton4, null);
    contentPane.add(jButton5, null);
    contentPane.add(jButton6, null);
    contentPane.add(jButton7, null);
    contentPane.add(jButton8, null);
    contentPane.add(jComboBox1, null);
    contentPane.add(jComboBox2, null);
    contentPane.add(jButton9, null);
    contentPane.add(jButton10, null);
    //设置窗口类的字体和为按钮加入动作接收器
    setupFontAndListener();
    //检查按钮状态的方法
    this.checkBtn(false);
    this.checkSubBtn(false);
  }
  //设置窗口类的字体和为按钮加入动作接收器的方法
  public void setupFontAndListener(){
    Component[] components = contentPane.getComponents();
    //创建临时按钮控件
    JButton tmpBtn = new JButton();
    for(int i = 0; i < components.length; i++){
      components[i].setFont(dialog13);
      if(components[i].getClass().getName().equals("javax.swing.JButton")){
        tmpBtn = (JButton)components[i];
        tmpBtn.addActionListener(this);
      }
    }
  }
  //退出方法
  public void exit(){
    //隐藏窗口
    this.setVisible(false);
    //清空数组的内容
    accountEntryLedgers = new String[0][8];
    accountEntrySubLedgers = new String[0][5];
    accountEntrySubLedgerObjects = new Object[0][5];
    //清空列表框的内容
    listData1.clear();
    //清空文本框的内容
    jTextArea1.setText("");
    //清空表格的内容
    this.showTableData(accountEntrySubLedgerObjects);
    //取得面板上的所有控件
    Component[] components = contentPane.getComponents();
    //创建临时编辑框控件
    JTextField tmpTextField = new JTextField();
    for(int i = 0; i < components.length; i++){
      if(components[i].getClass().getName().equals("javax.swing.JTextField")){
        tmpTextField = (JTextField)components[i];
        //清空编辑框的内容
        tmpTextField.setText("");
      }
    }
  }
  //设置用户的方法
  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);
    //设置表格的列编辑状态,第1、2列不能编辑
    aeslTableModel.setColumnEditState(0);
    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);
    //取得表格的行
    ListSelectionModel rowSM = jTable1.getSelectionModel();
    //加入行选择接收器
    rowSM.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        //当多种事件被激发的时候,不执行接收器后面的代码
        if (e.getValueIsAdjusting()) return;
        jTable1_valueChanged(e);
      }
    });
  }
  //转换表格数据的方法
  public void transferTableData(){
    accountEntrySubLedgers = new String[accountEntrySubLedgerObjects.length][6];
    for(int i = 0; i < accountEntrySubLedgerObjects.length; i++){
      accountEntrySubLedgers[i][0] = ((Integer)accountEntrySubLedgerObjects[i][0]).toString();
      accountEntrySubLedgers[i][1] = ((Integer)accountEntrySubLedgerObjects[i][1]).toString();
      if(((String)accountEntrySubLedgerObjects[i][2]).equals("借")){
        accountEntrySubLedgers[i][2] = "0";
      }else{
        accountEntrySubLedgers[i][2] = "1";
      }
      //将会计科目的--标识转换为@@标识
      accountEntrySubLedgers[i][3] = dataMethod.transferAccountNameBack( (
          String) accountEntrySubLedgerObjects[i][3]);
      accountEntrySubLedgers[i][4] = ((Double)accountEntrySubLedgerObjects[i][4]).toString();
    }
  }
  //重新计算借货平衡
  public void recountBalance(){
    int debitCredit = 0;
    double amount = 0;
    double total = 0;
    for(int i = 0; i < accountEntrySubLedgerObjects.length; i++){
      if(((String)accountEntrySubLedgerObjects[i][2]).equals("借")){
        debitCredit = 0;
      }else{
        debitCredit = 1;
      }
      amount = dataMethod.round(((Double)accountEntrySubLedgerObjects[i][4]).doubleValue());
      if(debitCredit == 0){
        total += amount;
      }else{
        total -= amount;
      }
    }
    jTextField11.setText(String.valueOf(dataMethod.round(total)));
  }
  //清空单个会计分录显示的方法
  public void clearAccountEntryLedger(){
    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.clearAccountEntryLedger();
    }
  }
  //表格行选择事件
  public void jTable1_valueChanged(ListSelectionEvent e) {
    //重新计算金额
    this.recountBalance();
  }
  //检查按钮的状态
  public void checkBtn(boolean isManipulated){
    if(isManipulated){
      jButton2.setEnabled(false);
      jButton3.setEnabled(false);
      jButton4.setEnabled(false);
      jButton5.setEnabled(false);
      jButton6.setEnabled(true);
      jButton7.setEnabled(true);
    }else{
      jButton2.setEnabled(true);
      jButton3.setEnabled(true);
      jButton4.setEnabled(true);
      jButton5.setEnabled(true);
      jButton6.setEnabled(false);
      jButton7.setEnabled(false);
    }
  }
  //检查明细账按钮的状态
  public void checkSubBtn(boolean isCreated){
    if(isCreated){
      jButton9.setEnabled(true);
      jButton10.setEnabled(true);
    }else{
      jButton9.setEnabled(false);
      jButton10.setEnabled(false);
    }
  }

  //查询方法
  public void search(){
    //取得查询选项

⌨️ 快捷键说明

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